Passed
Pull Request — master (#250)
by Viruthagiri
09:05
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.
Spacing   +899 added lines, -899 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('geodirectory-font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION);
90 90
         wp_enqueue_style('geodirectory-font-awesome');
91 91
 
92
-        wp_register_script('geodirectory-admin', geodir_plugin_url() . '/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION);
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,59 +108,59 @@  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();
129
+            $map_lang = "&language=".geodir_get_map_default_language();
130 130
             /** This filter is documented in geodirectory_template_tags.php */
131 131
             $map_extra = apply_filters('geodir_googlemap_script_extra', '');
132
-            wp_enqueue_script('geodirectory-googlemap-script', '//maps.google.com/maps/api/js?' . $map_lang . $map_extra, '', NULL);
132
+            wp_enqueue_script('geodirectory-googlemap-script', '//maps.google.com/maps/api/js?'.$map_lang.$map_extra, '', NULL);
133 133
         }
134 134
         
135 135
         if ($geodir_map_name == 'osm') {
136 136
             // Leaflet OpenStreetMap
137
-            wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
137
+            wp_register_style('geodirectory-leaflet-style', geodir_plugin_url().'/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
138 138
             wp_enqueue_style('geodirectory-leaflet-style');
139 139
                 
140
-            wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
140
+            wp_register_script('geodirectory-leaflet-script', geodir_plugin_url().'/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
141 141
             wp_enqueue_script('geodirectory-leaflet-script');
142 142
             
143
-            wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
143
+            wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url().'/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
144 144
             wp_enqueue_script('geodirectory-leaflet-geo-script');
145 145
         }
146
-        wp_enqueue_script( 'jquery-ui-autocomplete' );
146
+        wp_enqueue_script('jquery-ui-autocomplete');
147 147
         
148
-        wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true);
148
+        wp_register_script('geodirectory-goMap-script', geodir_plugin_url().'/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION, true);
149 149
         wp_enqueue_script('geodirectory-goMap-script');
150 150
 
151
-        wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
151
+        wp_register_script('geodirectory-goMap-script', geodir_plugin_url().'/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
152 152
         wp_enqueue_script('geodirectory-goMap-script');
153 153
 
154 154
 		// font awesome rating script
155 155
 		if (get_option('geodir_reviewrating_enable_font_awesome')) {
156
-			wp_register_script('geodir-barrating-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.barrating.min.js', array(), GEODIRECTORY_VERSION);
156
+			wp_register_script('geodir-barrating-js', geodir_plugin_url().'/geodirectory-assets/js/jquery.barrating.min.js', array(), GEODIRECTORY_VERSION);
157 157
 			wp_enqueue_script('geodir-barrating-js');
158 158
 		} else { // default rating script
159
-			wp_register_script('geodir-jRating-js', geodir_plugin_url() . '/geodirectory-assets/js/jRating.jquery.js', array(), GEODIRECTORY_VERSION);
159
+			wp_register_script('geodir-jRating-js', geodir_plugin_url().'/geodirectory-assets/js/jRating.jquery.js', array(), GEODIRECTORY_VERSION);
160 160
 			wp_enqueue_script('geodir-jRating-js');
161 161
 		}
162 162
 
163
-        wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.js', array(), GEODIRECTORY_VERSION);
163
+        wp_register_script('geodir-on-document-load', geodir_plugin_url().'/geodirectory-assets/js/on_document_load.js', array(), GEODIRECTORY_VERSION);
164 164
         wp_enqueue_script('geodir-on-document-load');
165 165
 
166 166
 
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         wp_enqueue_script('plupload-all');
169 169
         wp_enqueue_script('jquery-ui-sortable');
170 170
 
171
-        wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
171
+        wp_register_script('geodirectory-plupload-script', geodir_plugin_url().'/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
172 172
         wp_enqueue_script('geodirectory-plupload-script');
173 173
 
174 174
         // SCRIPT FOR UPLOAD END
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
         wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data);
223 223
 
224 224
 
225
-        wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
225
+        wp_register_script('geodirectory-admin-script', geodir_plugin_url().'/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
226 226
         wp_enqueue_script('geodirectory-admin-script');
227 227
 
228 228
         wp_enqueue_style('farbtastic');
@@ -230,10 +230,10 @@  discard block
 block discarded – undo
230 230
 
231 231
         $screen = get_current_screen();
232 232
         if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) {
233
-            wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js');
233
+            wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url().'/geodirectory-assets/js/listing_validation_admin.js');
234 234
         }
235 235
 
236
-        $ajax_cons_data = array('url' => __(get_option('siteurl') . '?geodir_ajax=true'));
236
+        $ajax_cons_data = array('url' => __(get_option('siteurl').'?geodir_ajax=true'));
237 237
         wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data);
238 238
 
239 239
     }
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 
257 257
         if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
258 258
 
259
-        add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
259
+        add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url().'/geodirectory-assets/images/favicon.ico', '55.1984');
260 260
 
261 261
 
262 262
     }
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
                 $geodir_menu_order[] = 'separator-geodirectory';
291 291
                 if (!empty($post_types)) {
292 292
                     foreach ($post_types as $post_type) {
293
-                        $geodir_menu_order[] = 'edit.php?post_type=' . $post_type;
293
+                        $geodir_menu_order[] = 'edit.php?post_type='.$post_type;
294 294
                     }
295 295
                 }
296 296
                 $geodir_menu_order[] = $item;
@@ -333,8 +333,8 @@  discard block
 block discarded – undo
333 333
 {
334 334
     if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') {
335 335
         echo '<div id="message" class="updated fade">
336
-                        <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>
337
-                        <p><strong>' . __('Geodirectory has been installed and setup. Enjoy :)', 'geodirectory') . '</strong></p>
336
+                        <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>
337
+                        <p><strong>' . __('Geodirectory has been installed and setup. Enjoy :)', 'geodirectory').'</strong></p>
338 338
                 </div>';
339 339
 
340 340
     }
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
     if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') {
343 343
         switch ($_REQUEST['msg']) {
344 344
             case 'success':
345
-                echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>';
345
+                echo '<div id="message" class="updated fade"><p><strong>'.__('Your settings have been saved.', 'geodirectory').'</strong></p></div>';
346 346
                 flush_rewrite_rules(false);
347 347
 
348 348
                 break;
@@ -350,20 +350,20 @@  discard block
 block discarded – undo
350 350
 				$gderr = isset($_REQUEST['gderr']) ? $_REQUEST['gderr'] : '';
351 351
 				
352 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>';
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 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>';
355
+					echo '<div id="message" class="error fade"><p><strong>'.__('Error: Your settings have not been saved, please try again.', 'geodirectory').'</strong></p></div>';
356 356
                 break;
357 357
         }
358 358
     }
359 359
 
360 360
     if (!geodir_is_default_location_set()) {
361
-        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>';
361
+        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>';
362 362
 
363 363
     }
364 364
 
365 365
     if (!function_exists('curl_init')) {
366
-        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>';
366
+        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>';
367 367
 
368 368
     }
369 369
 }
@@ -379,18 +379,18 @@  discard block
 block discarded – undo
379 379
 function geodir_handle_option_form_submit($current_tab)
380 380
 {
381 381
     global $geodir_settings;
382
-    if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
382
+    if (file_exists(dirname(__FILE__).'/option-pages/'.$current_tab.'_array.php')) {
383 383
         /**
384 384
          * Contains settings array for current tab.
385 385
          *
386 386
          * @since 1.0.0
387 387
          * @package GeoDirectory
388 388
          */
389
-        include_once('option-pages/' . $current_tab . '_array.php');
389
+        include_once('option-pages/'.$current_tab.'_array.php');
390 390
     }
391 391
     if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') :
392 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'));
393
+        if (!wp_verify_nonce($_REQUEST['_wpnonce-'.$current_tab], 'geodir-settings-'.$current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
394 394
 		
395 395
 		/**
396 396
 		 * Fires before updating geodirectory admin settings.
@@ -423,13 +423,13 @@  discard block
 block discarded – undo
423 423
          * @param string $current_tab The current settings tab name.
424 424
          * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab.
425 425
          */
426
-        do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
426
+        do_action('geodir_update_options_'.$current_tab, $geodir_settings[$current_tab]);
427 427
 
428 428
         flush_rewrite_rules(false);
429 429
 
430 430
         $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : '';
431 431
 
432
-        $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
432
+        $redirect_url = admin_url('admin.php?page=geodirectory&tab='.$current_tab.'&active_tab='.$_REQUEST['active_tab'].'&msg=success');
433 433
 
434 434
         wp_redirect($redirect_url);
435 435
         exit();
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 }
440 440
 
441 441
 
442
-if (!function_exists('geodir_autoinstall_admin_header') && (get_option('geodir_installed') || defined( 'GD_TESTING_MODE' ))) {
442
+if (!function_exists('geodir_autoinstall_admin_header') && (get_option('geodir_installed') || defined('GD_TESTING_MODE'))) {
443 443
     /**
444 444
      * GeoDirectory dummy data installation.
445 445
      *
@@ -455,18 +455,18 @@  discard block
 block discarded – undo
455 455
         global $wpdb, $plugin_prefix;
456 456
 
457 457
         if (!geodir_is_default_location_set()) {
458
-            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>';
458
+            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>';
459 459
         } else {
460 460
 
461
-            $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab=';
461
+            $geodir_url = admin_url().'admin.php?page=geodirectory&tab=general_settings&active_tab=';
462 462
 
463
-            $post_counts = $wpdb->get_var("SELECT count(post_id) FROM " . $plugin_prefix . $post_type . "_detail WHERE post_dummy='1'");
463
+            $post_counts = $wpdb->get_var("SELECT count(post_id) FROM ".$plugin_prefix.$post_type."_detail WHERE post_dummy='1'");
464 464
 
465 465
             if ($post_counts > 0) {
466 466
                 $nonce = wp_create_nonce('geodir_dummy_posts_delete_noncename');
467 467
 
468
-                $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>';
469
-                $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>';
468
+                $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>';
469
+                $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>';
470 470
             } else {
471 471
                 $options_list = '';
472 472
                 for ($option = 1; $option <= 30; $option++) {
@@ -474,13 +474,13 @@  discard block
 block discarded – undo
474 474
                     if ($option == 10)
475 475
                         $selected = 'selected="selected"';
476 476
 
477
-                    $options_list .= '<option ' . $selected . ' value="' . $option . '">' . $option . '</option>';
477
+                    $options_list .= '<option '.$selected.' value="'.$option.'">'.$option.'</option>';
478 478
                 }
479 479
 
480 480
                 $nonce = wp_create_nonce('geodir_dummy_posts_insert_noncename');
481 481
 
482
-                $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>';
483
-                $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>';
482
+                $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>';
483
+                $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>';
484 484
 
485 485
             }
486 486
             echo $dummy_msg;
@@ -488,14 +488,14 @@  discard block
 block discarded – undo
488 488
             <script>
489 489
                 <?php
490 490
                   $default_location = geodir_get_default_location();
491
-                  $city =  isset($default_location->city) ? $default_location->city : '';
492
-                  $region =isset($default_location->region) ? $default_location->region : '';
493
-                  $country =isset($default_location->country) ? $default_location->country : '';
494
-                  $city_latitude =isset($default_location->city_latitude) ? $default_location->city_latitude : '';
495
-                  $city_longitude =isset($default_location->city_longitude) ? $default_location->city_longitude : '';
491
+                  $city = isset($default_location->city) ? $default_location->city : '';
492
+                  $region = isset($default_location->region) ? $default_location->region : '';
493
+                  $country = isset($default_location->country) ? $default_location->country : '';
494
+                  $city_latitude = isset($default_location->city_latitude) ? $default_location->city_latitude : '';
495
+                  $city_longitude = isset($default_location->city_longitude) ? $default_location->city_longitude : '';
496 496
                 ?>
497 497
                 var geocoder = window.gdMaps == 'google' ? new google.maps.Geocoder() : null;
498
-                var CITY_ADDRESS = '<?php echo $city.','.$region.','.$country;?>';
498
+                var CITY_ADDRESS = '<?php echo $city.','.$region.','.$country; ?>';
499 499
                 var bound_lat_lng;
500 500
                 var latlng = ['<?php echo $city_latitude; ?>', <?php echo $city_longitude; ?>];
501 501
                 var lat = <?php echo $city_latitude; ?>;
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
                                 );
539 539
 
540 540
                             } else {
541
-                                alert("<?php _e('Geocode was not successful for the following reason:','geodirectory');?> " + status);
541
+                                alert("<?php _e('Geocode was not successful for the following reason:', 'geodirectory'); ?> " + status);
542 542
                             }
543 543
                         });
544 544
                 }
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
                     var total_dummy_post_count = jQuery('#sub_' + active_tab).find('.selected_sample_data').val();
552 552
 
553 553
                     if (id == 'geodir_dummy_delete') {
554
-                        if (confirm('<?php _e('Are you sure you want to delete dummy data?' , 'geodirectory'); ?>')) {
554
+                        if (confirm('<?php _e('Are you sure you want to delete dummy data?', 'geodirectory'); ?>')) {
555 555
                             jQuery('#sub_' + active_tab).find('.geodir_auto_install').hide();
556 556
                             jQuery('#sub_' + active_tab).find('.geodir_show_progress').show();
557 557
                             jQuery.post('<?php echo geodir_get_ajax_url(); ?>&geodir_autofill=' + id + '&posttype=' + posttype + '&_wpnonce=' + nonce,
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
                         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,
571 571
                             function (data) {
572 572
 
573
-                                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 + '');
573
+                                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 + '');
574 574
                                 dummy_post_index++;
575 575
                                 if (dummy_post_index <= total_dummy_post_count)
576 576
                                     geodir_autoinstall(obj, id, nonce, posttype);
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
      * @package GeoDirectory
612 612
      */
613 613
     include_once('place_dummy_post.php');
614
-    delete_transient( 'cached_dummy_images' );
614
+    delete_transient('cached_dummy_images');
615 615
 
616 616
 }
617 617
 
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
     global $wpdb, $plugin_prefix;
629 629
 
630 630
 
631
-    $post_ids = $wpdb->get_results("SELECT post_id FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
631
+    $post_ids = $wpdb->get_results("SELECT post_id FROM ".$plugin_prefix."gd_place_detail WHERE post_dummy='1'");
632 632
 
633 633
 
634 634
     foreach ($post_ids as $post_ids_obj) {
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
     }
637 637
 
638 638
     //double check posts are deleted
639
-    $wpdb->get_results("DELETE FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
639
+    $wpdb->get_results("DELETE FROM ".$plugin_prefix."gd_place_detail WHERE post_dummy='1'");
640 640
 }
641 641
 
642 642
 /**
@@ -674,14 +674,14 @@  discard block
 block discarded – undo
674 674
 
675 675
 
676 676
                     if (geodir_dummy_folder_exists())
677
-                        $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
677
+                        $dummy_image_url = geodir_plugin_url()."/geodirectory-admin/dummy/cat_icon";
678 678
                     else
679 679
                         $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
680 680
 
681 681
                     $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
682 682
 
683 683
                     $catname = str_replace(' ', '_', $catname);
684
-                    $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
684
+                    $uploaded = (array) fetch_remote_file("$dummy_image_url/".$catname.".png");
685 685
 
686 686
                     if (empty($uploaded['error'])) {
687 687
                         $new_path = $uploaded['file'];
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
                     $wp_filetype = wp_check_filetype(basename($new_path), null);
692 692
 
693 693
                     $attachment = array(
694
-                        'guid' => $uploads['baseurl'] . '/' . basename($new_path),
694
+                        'guid' => $uploads['baseurl'].'/'.basename($new_path),
695 695
                         'post_mime_type' => $wp_filetype['type'],
696 696
                         'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
697 697
                         'post_content' => '',
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
 
702 702
                     // you must first include the image.php file
703 703
                     // for the function wp_generate_attachment_metadata() to work
704
-                    require_once(ABSPATH . 'wp-admin/includes/image.php');
704
+                    require_once(ABSPATH.'wp-admin/includes/image.php');
705 705
                     $attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
706 706
                     wp_update_attachment_metadata($attach_id, $attach_data);
707 707
 
@@ -718,14 +718,14 @@  discard block
 block discarded – undo
718 718
                 $last_catid = wp_insert_term($catname, 'gd_placecategory');
719 719
 
720 720
                 if (geodir_dummy_folder_exists())
721
-                    $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
721
+                    $dummy_image_url = geodir_plugin_url()."/geodirectory-admin/dummy/cat_icon";
722 722
                 else
723 723
                     $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
724 724
 
725 725
                 $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
726 726
 
727 727
                 $catname = str_replace(' ', '_', $catname);
728
-                $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
728
+                $uploaded = (array) fetch_remote_file("$dummy_image_url/".$catname.".png");
729 729
 
730 730
                 if (empty($uploaded['error'])) {
731 731
                     $new_path = $uploaded['file'];
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
                 $wp_filetype = wp_check_filetype(basename($new_path), null);
736 736
 
737 737
                 $attachment = array(
738
-                    'guid' => $uploads['baseurl'] . '/' . basename($new_path),
738
+                    'guid' => $uploads['baseurl'].'/'.basename($new_path),
739 739
                     'post_mime_type' => $wp_filetype['type'],
740 740
                     'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
741 741
                     'post_content' => '',
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
 
748 748
                 // you must first include the image.php file
749 749
                 // for the function wp_generate_attachment_metadata() to work
750
-                require_once(ABSPATH . 'wp-admin/includes/image.php');
750
+                require_once(ABSPATH.'wp-admin/includes/image.php');
751 751
                 $attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
752 752
                 wp_update_attachment_metadata($attach_id, $attach_data);
753 753
 
@@ -789,18 +789,18 @@  discard block
 block discarded – undo
789 789
 
790 790
         elseif (isset($value['type']) && $value['type'] == 'image_width') :
791 791
 
792
-            if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
793
-                update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']);
794
-                update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']);
795
-                if (isset($_POST[$value['id'] . '_crop'])) :
796
-                    update_option($value['id'] . '_crop', 1);
792
+            if (isset($value['id']) && isset($_POST[$value['id'].'_width'])) {
793
+                update_option($value['id'].'_width', $_POST[$value['id'].'_width']);
794
+                update_option($value['id'].'_height', $_POST[$value['id'].'_height']);
795
+                if (isset($_POST[$value['id'].'_crop'])) :
796
+                    update_option($value['id'].'_crop', 1);
797 797
                 else :
798
-                    update_option($value['id'] . '_crop', 0);
798
+                    update_option($value['id'].'_crop', 0);
799 799
                 endif;
800 800
             } else {
801
-                update_option($value['id'] . '_width', $value['std']);
802
-                update_option($value['id'] . '_height', $value['std']);
803
-                update_option($value['id'] . '_crop', 1);
801
+                update_option($value['id'].'_width', $value['std']);
802
+                update_option($value['id'].'_height', $value['std']);
803
+                update_option($value['id'].'_crop', 1);
804 804
             }
805 805
 
806 806
         elseif (isset($value['type']) && $value['type'] == 'map') :
@@ -842,12 +842,12 @@  discard block
 block discarded – undo
842 842
         elseif (isset($value['type']) && $value['type'] == 'file') :
843 843
 
844 844
 
845
-            if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
845
+            if (isset($_POST[$value['id'].'_remove']) && $_POST[$value['id'].'_remove']) {// if remove is set then remove the file
846 846
 
847 847
                 if (get_option($value['id'])) {
848 848
                     $image_name_arr = explode('/', get_option($value['id']));
849 849
                     $noimg_name = end($image_name_arr);
850
-                    $img_path = $uploads['path'] . '/' . $noimg_name;
850
+                    $img_path = $uploads['path'].'/'.$noimg_name;
851 851
                     if (file_exists($img_path))
852 852
                         unlink($img_path);
853 853
                 }
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
                 if (get_option($value['id'])) {
876 876
                     $image_name_arr = explode('/', get_option($value['id']));
877 877
                     $noimg_name = end($image_name_arr);
878
-                    $img_path = $uploads['path'] . '/' . $noimg_name;
878
+                    $img_path = $uploads['path'].'/'.$noimg_name;
879 879
                     if (file_exists($img_path))
880 880
                         unlink($img_path);
881 881
                 }
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
             // same menu setting per theme.
897 897
             if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
898 898
                 $theme = wp_get_theme();
899
-                update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
899
+                update_option('geodir_theme_location_nav_'.$theme->name, $_POST[$value['id']]);
900 900
             }
901 901
 
902 902
             if (isset($value['id']) && isset($_POST[$value['id']])) {
@@ -966,8 +966,8 @@  discard block
 block discarded – undo
966 966
 
967 967
             $listing_slug = $geodir_posttype_info['labels']['singular_name'];
968 968
 
969
-            $tabs[$geodir_post_type . '_fields_settings'] = array(
970
-                'label' => __(ucfirst($listing_slug) . ' Settings', 'geodirectory'),
969
+            $tabs[$geodir_post_type.'_fields_settings'] = array(
970
+                'label' => __(ucfirst($listing_slug).' Settings', 'geodirectory'),
971 971
                 'subtabs' => array(
972 972
                     array('subtab' => 'custom_fields',
973 973
                         'label' => __('Custom Fields', 'geodirectory'),
@@ -1000,7 +1000,7 @@  discard block
 block discarded – undo
1000 1000
  */
1001 1001
 function geodir_tools_setting_tab($tabs)
1002 1002
 {
1003
-    wp_enqueue_script( 'jquery-ui-progressbar' );
1003
+    wp_enqueue_script('jquery-ui-progressbar');
1004 1004
     $tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
1005 1005
     return $tabs;
1006 1006
 }
@@ -1034,7 +1034,7 @@  discard block
 block discarded – undo
1034 1034
  */
1035 1035
 function geodir_extend_geodirectory_setting_tab($tabs)
1036 1036
 {
1037
-    $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
1037
+    $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory').' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
1038 1038
     return $tabs;
1039 1039
 }
1040 1040
 
@@ -1094,8 +1094,8 @@  discard block
 block discarded – undo
1094 1094
                     _e('Unknown', 'geodirectory');
1095 1095
                 } else {
1096 1096
                     /* If there is a city id, append 'city name' to the text string. */
1097
-                    $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
1098
-                    echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id);
1097
+                    $add_location_id = $location_id > 0 ? ' ('.$location_id.')' : '';
1098
+                    echo(__($location->country, 'geodirectory').'-'.$location->region.'-'.$location->city.$add_location_id);
1099 1099
                 }
1100 1100
                 break;
1101 1101
 
@@ -1113,14 +1113,14 @@  discard block
 block discarded – undo
1113 1113
                         $expire_class = 'expire_over';
1114 1114
                     }
1115 1115
                     $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days
1116
-                    $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
1116
+                    $date_diff_text = '<br /><span class="'.$expire_class.'">('.$date_diff.' '.$state.')</span>';
1117 1117
                 }
1118 1118
                 /* If no expire_date is found, output a default message. */
1119 1119
                 if (empty($expire_date))
1120 1120
                     echo __('Unknown', 'geodirectory');
1121 1121
                 /* If there is a expire_date, append 'days left' to the text string. */
1122 1122
                 else
1123
-                    echo $expire_date . $date_diff_text;
1123
+                    echo $expire_date.$date_diff_text;
1124 1124
                 break;
1125 1125
 
1126 1126
             /* If displaying the 'categorys' column. */
@@ -1187,7 +1187,7 @@  discard block
 block discarded – undo
1187 1187
 function geodir_post_information_save($post_id, $post) {
1188 1188
     global $wpdb, $current_user;
1189 1189
 
1190
-    if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
1190
+    if (isset($post->post_type) && ($post->post_type == 'nav_menu_item' || $post->post_type == 'page' || $post->post_type == 'post')) {
1191 1191
         return;
1192 1192
     }
1193 1193
 
@@ -1255,7 +1255,7 @@  discard block
 block discarded – undo
1255 1255
                     $tab_id = $value['id'];
1256 1256
 
1257 1257
                 if (isset($value['desc']) && $value['desc'])
1258
-                    $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>';
1258
+                    $desc = '<span style=" text-transform:none;">:- '.$value['desc'].'</span>';
1259 1259
 
1260 1260
                 if (isset($value['name']) && $value['name']) {
1261 1261
                     if ($first_title === true) {
@@ -1263,9 +1263,9 @@  discard block
 block discarded – undo
1263 1263
                     } else {
1264 1264
                         echo '</div>';
1265 1265
                     }
1266
-                    echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>';
1266
+                    echo '<dd id="'.trim($tab_id).'" class="geodir_option_tabs" ><a href="javascript:void(0);">'.$value['name'].'</a></dd>';
1267 1267
 
1268
-                    echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
1268
+                    echo '<div id="sub_'.trim($tab_id).'" class="gd-content-heading" style=" margin-bottom:10px;" >';
1269 1269
                 }
1270 1270
 
1271 1271
                 /**
@@ -1275,21 +1275,21 @@  discard block
 block discarded – undo
1275 1275
                  *
1276 1276
                  * @since 1.0.0
1277 1277
                  */
1278
-                do_action('geodir_settings_' . sanitize_title($value['id']));
1278
+                do_action('geodir_settings_'.sanitize_title($value['id']));
1279 1279
                 break;
1280 1280
 
1281 1281
             case 'no_tabs':
1282 1282
 
1283 1283
                 echo '<div class="inner_content_tab_main">';
1284
-                echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
1284
+                echo '<div id="sub_'.trim($tab_id).'" class="gd-content-heading" style=" margin-bottom:10px;" >';
1285 1285
 
1286 1286
                 break;
1287 1287
 
1288 1288
             case 'sectionstart':
1289 1289
                 if (isset($value['desc']) && $value['desc'])
1290
-                    $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>';
1290
+                    $desc = '<span style=" text-transform:none;"> - '.$value['desc'].'</span>';
1291 1291
                 if (isset($value['name']) && $value['name'])
1292
-                    echo '<h3>' . $value['name'] . $desc . '</h3>';
1292
+                    echo '<h3>'.$value['name'].$desc.'</h3>';
1293 1293
                 /**
1294 1294
                  * Called after a GeoDirectory settings sectionstart is output in the GD settings page.
1295 1295
                  *
@@ -1297,8 +1297,8 @@  discard block
 block discarded – undo
1297 1297
                  *
1298 1298
                  * @since 1.0.0
1299 1299
                  */
1300
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
1301
-                echo '<table class="form-table">' . "\n\n";
1300
+                if (isset($value['id']) && $value['id']) do_action('geodir_settings_'.sanitize_title($value['id']).'_start');
1301
+                echo '<table class="form-table">'."\n\n";
1302 1302
 
1303 1303
                 break;
1304 1304
             case 'sectionend':
@@ -1309,7 +1309,7 @@  discard block
 block discarded – undo
1309 1309
                  *
1310 1310
                  * @since 1.0.0
1311 1311
                  */
1312
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
1312
+                if (isset($value['id']) && $value['id']) do_action('geodir_settings_'.sanitize_title($value['id']).'_end');
1313 1313
                 echo '</table>';
1314 1314
                 /**
1315 1315
                  * Called after a GeoDirectory settings sectionend is output in the GD settings page.
@@ -1318,7 +1318,7 @@  discard block
 block discarded – undo
1318 1318
                  *
1319 1319
                  * @since 1.0.0
1320 1320
                  */
1321
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
1321
+                if (isset($value['id']) && $value['id']) do_action('geodir_settings_'.sanitize_title($value['id']).'_after');
1322 1322
                 break;
1323 1323
             case 'text':
1324 1324
                 ?>
@@ -1327,7 +1327,7 @@  discard block
 block discarded – undo
1327 1327
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
1328 1328
                                            id="<?php echo esc_attr($value['id']); ?>"
1329 1329
                                            type="<?php echo esc_attr($value['type']); ?>"
1330
-                                           <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1330
+                                           <?php if (isset($value['placeholder'])) {?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1331 1331
                                            style=" <?php echo esc_attr($value['css']); ?>"
1332 1332
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1333 1333
                                                echo esc_attr(stripslashes(get_option($value['id'])));
@@ -1344,7 +1344,7 @@  discard block
 block discarded – undo
1344 1344
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
1345 1345
                                            id="<?php echo esc_attr($value['id']); ?>"
1346 1346
                                            type="<?php echo esc_attr($value['type']); ?>"
1347
-                                           <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1347
+                                           <?php if (isset($value['placeholder'])) {?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1348 1348
                                            style="<?php echo esc_attr($value['css']); ?>"
1349 1349
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1350 1350
                                                echo esc_attr(stripslashes(get_option($value['id'])));
@@ -1390,17 +1390,17 @@  discard block
 block discarded – undo
1390 1390
                     <?php _e('Width', 'geodirectory'); ?> <input
1391 1391
                         name="<?php echo esc_attr($value['id']); ?>_width"
1392 1392
                         id="<?php echo esc_attr($value['id']); ?>_width" type="text" size="3"
1393
-                        value="<?php if ($size = get_option($value['id'] . '_width')) echo stripslashes($size); else echo $value['std']; ?>"/>
1393
+                        value="<?php if ($size = get_option($value['id'].'_width')) echo stripslashes($size); else echo $value['std']; ?>"/>
1394 1394
 
1395 1395
                     <?php _e('Height', 'geodirectory'); ?> <input
1396 1396
                         name="<?php echo esc_attr($value['id']); ?>_height"
1397 1397
                         id="<?php echo esc_attr($value['id']); ?>_height" type="text" size="3"
1398
-                        value="<?php if ($size = get_option($value['id'] . '_height')) echo stripslashes($size); else echo $value['std']; ?>"/>
1398
+                        value="<?php if ($size = get_option($value['id'].'_height')) echo stripslashes($size); else echo $value['std']; ?>"/>
1399 1399
 
1400 1400
                     <label><?php _e('Hard Crop', 'geodirectory'); ?> <input
1401 1401
                             name="<?php echo esc_attr($value['id']); ?>_crop"
1402 1402
                             id="<?php echo esc_attr($value['id']); ?>_crop"
1403
-                            type="checkbox" <?php if (get_option($value['id'] . '_crop') != '') checked(get_option($value['id'] . '_crop'), 1); else checked(1); ?> /></label>
1403
+                            type="checkbox" <?php if (get_option($value['id'].'_crop') != '') checked(get_option($value['id'].'_crop'), 1); else checked(1); ?> /></label>
1404 1404
 
1405 1405
                     <span class="description"><?php echo $value['desc'] ?></span></td>
1406 1406
                 </tr><?php
@@ -1450,7 +1450,7 @@  discard block
 block discarded – undo
1450 1450
                                             id="<?php echo esc_attr($value['id']); ?>"
1451 1451
                                             style="<?php echo esc_attr($value['css']); ?>"
1452 1452
                                             class="<?php if (isset($value['class'])) echo $value['class']; ?>"
1453
-                                            data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>"
1453
+                                            data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text']; ?>"
1454 1454
                                             option-ajaxchosen="false">
1455 1455
                         <?php
1456 1456
                         foreach ($value['options'] as $key => $val) {
@@ -1461,7 +1461,7 @@  discard block
 block discarded – undo
1461 1461
                             } else {
1462 1462
                                 ?>
1463 1463
                                 <option
1464
-                                    value="<?php echo esc_attr($key); ?>" <?php selected(true, (is_array($option_values) && in_array($key, $option_values)));?>><?php echo ucfirst($val) ?></option>
1464
+                                    value="<?php echo esc_attr($key); ?>" <?php selected(true, (is_array($option_values) && in_array($key, $option_values))); ?>><?php echo ucfirst($val) ?></option>
1465 1465
                             <?php
1466 1466
                             }
1467 1467
                         }
@@ -1496,7 +1496,7 @@  discard block
 block discarded – undo
1496 1496
                 ?>
1497 1497
 
1498 1498
                 <tr valign="top">
1499
-                    <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory');?></th>
1499
+                    <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory'); ?></th>
1500 1500
                     <td width="60%">
1501 1501
                         <select name="geodir_default_map_language" style="width:60%">
1502 1502
                             <?php
@@ -1578,7 +1578,7 @@  discard block
 block discarded – undo
1578 1578
 
1579 1579
                 <tr valign="top">
1580 1580
                     <th class="titledesc"
1581
-                        width="40%"><?php _e('Default post type search on map', 'geodirectory');?></th>
1581
+                        width="40%"><?php _e('Default post type search on map', 'geodirectory'); ?></th>
1582 1582
                     <td width="60%">
1583 1583
                         <select name="geodir_default_map_search_pt" style="width:60%">
1584 1584
                             <?php
@@ -1619,7 +1619,7 @@  discard block
 block discarded – undo
1619 1619
                         $cat_display = 'checkbox';
1620 1620
                         $gd_post_types = get_option('geodir_exclude_post_type_on_map');
1621 1621
                         $gd_cats = get_option('geodir_exclude_cat_on_map');
1622
-                        $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
1622
+                        $gd_cats_upgrade = (int) get_option('geodir_exclude_cat_on_map_upgrade');
1623 1623
                         $count = 1;
1624 1624
                         ?>
1625 1625
                         <table width="70%" class="widefat">
@@ -1648,7 +1648,7 @@  discard block
 block discarded – undo
1648 1648
                                                                                            name="home_map_post_types[]"
1649 1649
                                                                                            id="<?php echo esc_attr($value['id']); ?>"
1650 1650
                                                                                            value="<?php echo $key; ?>"
1651
-                                                                                           class="map_post_type" <?php echo $checked;?> />
1651
+                                                                                           class="map_post_type" <?php echo $checked; ?> />
1652 1652
                                         <?php echo $post_types_obj->labels->singular_name; ?></td>
1653 1653
                                     <td width="40%">
1654 1654
                                         <div class="home_map_category" style="overflow:auto;width:200px;height:100px;"
@@ -1706,12 +1706,12 @@  discard block
 block discarded – undo
1706 1706
                 ?>
1707 1707
                 <fieldset>
1708 1708
                     <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend>
1709
-                    <label for="<?php echo $value['id'];?>">
1709
+                    <label for="<?php echo $value['id']; ?>">
1710 1710
                         <input name="<?php echo esc_attr($value['id']); ?>"
1711
-                               id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio"
1711
+                               id="<?php echo esc_attr($value['id'].$value['value']); ?>" type="radio"
1712 1712
                                value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) {
1713 1713
                             echo 'checked="checked"';
1714
-                        }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
1714
+                        }elseif (get_option($value['id']) == '' && $value['std'] == $value['value']) {echo 'checked="checked"'; } ?> />
1715 1715
                         <?php echo $value['desc']; ?></label><br>
1716 1716
                 </fieldset>
1717 1717
                 <?php
@@ -1731,9 +1731,9 @@  discard block
 block discarded – undo
1731 1731
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1732 1732
                 <td class="forminp">
1733 1733
                     <textarea
1734
-                        <?php if (isset($value['args'])) echo $value['args'] . ' '; ?>name="<?php echo esc_attr($value['id']); ?>"
1734
+                        <?php if (isset($value['args'])) echo $value['args'].' '; ?>name="<?php echo esc_attr($value['id']); ?>"
1735 1735
                         id="<?php echo esc_attr($value['id']); ?>"
1736
-                        <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1736
+                        <?php if (isset($value['placeholder'])) {?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1737 1737
                         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
1738 1738
                         class="description"><?php echo $value['desc'] ?></span>
1739 1739
 
@@ -1778,7 +1778,7 @@  discard block
 block discarded – undo
1778 1778
 					}
1779 1779
 				}
1780 1780
 				//
1781
-				$page_setting = (int)get_option($value['id']);
1781
+				$page_setting = (int) get_option($value['id']);
1782 1782
 
1783 1783
                 $args = array('name' => $value['id'],
1784 1784
                     'id' => $value['id'],
@@ -1795,7 +1795,7 @@  discard block
 block discarded – undo
1795 1795
                 <tr valign="top" class="single_select_page">
1796 1796
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1797 1797
                 <td class="forminp">
1798
-                    <?php echo str_replace(' id=', " data-placeholder='" . __('Select a page...', 'geodirectory') . "' style='" . $value['css'] . "' class='" . $value['class'] . "' " . $disabled . " id=", wp_dropdown_pages($args)); ?>
1798
+                    <?php echo str_replace(' id=', " data-placeholder='".__('Select a page...', 'geodirectory')."' style='".$value['css']."' class='".$value['class']."' ".$disabled." id=", wp_dropdown_pages($args)); ?>
1799 1799
                     <span class="description"><?php echo $value['desc'] ?></span>
1800 1800
                 </td>
1801 1801
                 </tr><?php
@@ -1804,7 +1804,7 @@  discard block
 block discarded – undo
1804 1804
 				}
1805 1805
                 break;
1806 1806
             case 'single_select_country' :
1807
-                $country_setting = (string)get_option($value['id']);
1807
+                $country_setting = (string) get_option($value['id']);
1808 1808
                 if (strstr($country_setting, ':')) :
1809 1809
                     $country = current(explode(':', $country_setting));
1810 1810
                     $state = end(explode(':', $country_setting));
@@ -1827,7 +1827,7 @@  discard block
 block discarded – undo
1827 1827
             case 'multi_select_countries' :
1828 1828
                 $countries = $geodirectory->countries->countries;
1829 1829
                 asort($countries);
1830
-                $selections = (array)get_option($value['id']);
1830
+                $selections = (array) get_option($value['id']);
1831 1831
                 ?>
1832 1832
                 <tr valign="top">
1833 1833
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
@@ -1837,7 +1837,7 @@  discard block
 block discarded – undo
1837 1837
                             title="Country" class="chosen_select">
1838 1838
                         <?php
1839 1839
                         if ($countries) foreach ($countries as $key => $val) :
1840
-                            echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>';
1840
+                            echo '<option value="'.$key.'" '.selected(in_array($key, $selections), true, false).'>'.$val.'</option>';
1841 1841
                         endforeach;
1842 1842
                         ?>
1843 1843
                     </select>
@@ -1849,8 +1849,8 @@  discard block
 block discarded – undo
1849 1849
                 break;
1850 1850
 
1851 1851
             case 'google_analytics' :
1852
-                $selections = (array)get_option($value['id']);
1853
-                if(get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret') ) {
1852
+                $selections = (array) get_option($value['id']);
1853
+                if (get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret')) {
1854 1854
                     ?>
1855 1855
                     <tr valign="top">
1856 1856
                         <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
@@ -1861,20 +1861,20 @@  discard block
 block discarded – undo
1861 1861
 
1862 1862
                             $oAuthURL = "https://accounts.google.com/o/oauth2/auth?";
1863 1863
                             $scope = "scope=https://www.googleapis.com/auth/analytics.readonly";
1864
-                            $state = "&state=123";//any string
1865
-                            $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
1864
+                            $state = "&state=123"; //any string
1865
+                            $redirect_uri = "&redirect_uri=".admin_url('admin-ajax.php')."?action=geodir_ga_callback";
1866 1866
                             $response_type = "&response_type=code";
1867 1867
                             $client_id = "&client_id=".get_option('geodir_ga_client_id');
1868 1868
                             $access_type = "&access_type=offline";
1869 1869
                             $approval_prompt = "&approval_prompt=force";
1870 1870
 
1871
-                            $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt;
1871
+                            $auth_url = $oAuthURL.$scope.$state.$redirect_uri.$response_type.$client_id.$access_type.$approval_prompt;
1872 1872
 
1873 1873
 
1874 1874
                             ?>
1875 1875
                             <script>
1876 1876
                                 function gd_ga_popup() {
1877
-                                    var win = window.open("<?php echo $auth_url;?>", "Google Analytics", "");
1877
+                                    var win = window.open("<?php echo $auth_url; ?>", "Google Analytics", "");
1878 1878
                                     var pollTimer = window.setInterval(function () {
1879 1879
                                         if (win.closed !== false) { // !== is required for compatibility with Opera
1880 1880
                                             window.clearInterval(pollTimer);
@@ -1896,7 +1896,7 @@  discard block
 block discarded – undo
1896 1896
                             } else {
1897 1897
                                 ?>
1898 1898
                                 <span class="button-primary"
1899
-                                      onclick="gd_ga_popup();"><?php _e('Authorize', 'geodirectory');?></span>
1899
+                                      onclick="gd_ga_popup();"><?php _e('Authorize', 'geodirectory'); ?></span>
1900 1900
                             <?php
1901 1901
                             }
1902 1902
                             ?>
@@ -1967,9 +1967,9 @@  discard block
 block discarded – undo
1967 1967
 
1968 1968
             <?php if (isset($_REQUEST['active_tab']) && $_REQUEST['active_tab'] != '') { ?>
1969 1969
             jQuery('.geodir_option_tabs').removeClass('gd-tab-active');
1970
-            jQuery('#<?php echo sanitize_text_field($_REQUEST['active_tab']);?>').addClass('gd-tab-active');
1970
+            jQuery('#<?php echo sanitize_text_field($_REQUEST['active_tab']); ?>').addClass('gd-tab-active');
1971 1971
             jQuery('.gd-content-heading').hide();
1972
-            jQuery('#sub_<?php echo sanitize_text_field($_REQUEST['active_tab']);?>').show();
1972
+            jQuery('#sub_<?php echo sanitize_text_field($_REQUEST['active_tab']); ?>').show();
1973 1973
             <?php } ?>
1974 1974
         });
1975 1975
     </script>
@@ -2055,7 +2055,7 @@  discard block
 block discarded – undo
2055 2055
     wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename');
2056 2056
 
2057 2057
     if (geodir_get_featured_image($post_id, 'thumbnail')) {
2058
-        echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
2058
+        echo '<h4>'.__('Featured Image', 'geodirectory').'</h4>';
2059 2059
         geodir_show_featured_image($post_id, 'thumbnail');
2060 2060
     }
2061 2061
 
@@ -2066,13 +2066,13 @@  discard block
 block discarded – undo
2066 2066
 
2067 2067
     <h5 class="form_title">
2068 2068
         <?php if ($image_limit != 0 && $image_limit == 1) {
2069
-            echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
2069
+            echo '<br /><small>('.__('You can upload', 'geodirectory').' '.$image_limit.' '.__('image with this package', 'geodirectory').')</small>';
2070 2070
         } ?>
2071 2071
         <?php if ($image_limit != 0 && $image_limit > 1) {
2072
-            echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
2072
+            echo '<br /><small>('.__('You can upload', 'geodirectory').' '.$image_limit.' '.__('images with this package', 'geodirectory').')</small>';
2073 2073
         } ?>
2074 2074
         <?php if ($image_limit == 0) {
2075
-            echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
2075
+            echo '<br /><small>('.__('You can upload unlimited images with this package', 'geodirectory').')</small>';
2076 2076
         } ?>
2077 2077
     </h5>
2078 2078
 
@@ -2111,10 +2111,10 @@  discard block
 block discarded – undo
2111 2111
         <div
2112 2112
             class="plupload-upload-uic hide-if-no-js <?php if ($multiple): ?>plupload-upload-uic-multiple<?php endif; ?>"
2113 2113
             id="<?php echo $id; ?>plupload-upload-ui">
2114
-            <h4><?php _e('Drop files to upload', 'geodirectory');?></h4>
2114
+            <h4><?php _e('Drop files to upload', 'geodirectory'); ?></h4>
2115 2115
             <input id="<?php echo $id; ?>plupload-browse-button" type="button"
2116 2116
                    value="<?php _e('Select Files', 'geodirectory'); ?>" class="button"/>
2117
-            <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce($id . 'pluploadan'); ?>"></span>
2117
+            <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce($id.'pluploadan'); ?>"></span>
2118 2118
             <?php if ($width && $height): ?>
2119 2119
                 <span class="plupload-resize"></span>
2120 2120
                 <span class="plupload-width" id="plupload-width<?php echo $width; ?>"></span>
@@ -2126,7 +2126,7 @@  discard block
 block discarded – undo
2126 2126
              id="<?php echo $id; ?>plupload-thumbs" style="border-top:1px solid #ccc; padding-top:10px;">
2127 2127
         </div>
2128 2128
         <span
2129
-            id="upload-msg"><?php _e('Please drag &amp; drop the images to rearrange the order', 'geodirectory');?></span>
2129
+            id="upload-msg"><?php _e('Please drag &amp; drop the images to rearrange the order', 'geodirectory'); ?></span>
2130 2130
         <span id="<?php echo $id; ?>upload-error" style="display:none"></span>
2131 2131
     </div>
2132 2132
 
@@ -2336,9 +2336,9 @@  discard block
 block discarded – undo
2336 2336
     $plugin = 'avada-nag';
2337 2337
     $timestamp = 'avada-nag1234';
2338 2338
     $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');
2339
-    echo '<div id="' . $timestamp . '"  class="error">';
2340
-    echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>';
2341
-    echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
2339
+    echo '<div id="'.$timestamp.'"  class="error">';
2340
+    echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\''.$plugin.'\',\''.$timestamp.'\');" ><i class="fa fa-times"></i></span>';
2341
+    echo "<img class='gd-icon-noti' src='".plugin_dir_url('')."geodirectory/geodirectory-assets/images/favicon.ico' > ";
2342 2342
     echo "<p>$message</p>";
2343 2343
     echo "</div>";
2344 2344
 
@@ -2471,7 +2471,7 @@  discard block
 block discarded – undo
2471 2471
 		
2472 2472
 		// Don't allow same slug url for listing and location
2473 2473
 		if (geodir_strtolower($listing_prefix) == geodir_strtolower($location_prefix)) {
2474
-			$redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab . '&msg=fail&gderr=21');
2474
+			$redirect_url = admin_url('admin.php?page=geodirectory&tab='.$current_tab.'&active_tab='.$active_tab.'&msg=fail&gderr=21');
2475 2475
         	wp_redirect($redirect_url);
2476 2476
 			exit;
2477 2477
 		}
@@ -2483,7 +2483,7 @@  discard block
 block discarded – undo
2483 2483
 			$default_language = $sitepress->get_default_language();
2484 2484
 			
2485 2485
 			if ($current_language != 'all' && $current_language != $default_language) {
2486
-				$redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab);
2486
+				$redirect_url = admin_url('admin.php?page=geodirectory&tab='.$current_tab.'&active_tab='.$active_tab);
2487 2487
 				wp_redirect($redirect_url);
2488 2488
 				exit;
2489 2489
 			}
@@ -2504,11 +2504,11 @@  discard block
 block discarded – undo
2504 2504
 function geodir_hide_admin_preview_button() {
2505 2505
     global $post_type;
2506 2506
     $post_types = geodir_get_posttypes();
2507
-    if(in_array($post_type, $post_types))
2507
+    if (in_array($post_type, $post_types))
2508 2508
         echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
2509 2509
 }
2510
-add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' );
2511
-add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' );
2510
+add_action('admin_head-post-new.php', 'geodir_hide_admin_preview_button');
2511
+add_action('admin_head-post.php', 'geodir_hide_admin_preview_button');
2512 2512
 
2513 2513
 /**
2514 2514
  * Add the tab in left sidebar menu fro import & export page.
@@ -2518,8 +2518,8 @@  discard block
 block discarded – undo
2518 2518
  *
2519 2519
  * @return array Array of tab data.
2520 2520
  */
2521
-function geodir_import_export_tab( $tabs ) {
2522
-	$tabs['import_export'] = array( 'label' => __( 'Import & Export', 'geodirectory' ) );
2521
+function geodir_import_export_tab($tabs) {
2522
+	$tabs['import_export'] = array('label' => __('Import & Export', 'geodirectory'));
2523 2523
     return $tabs;
2524 2524
 }
2525 2525
 
@@ -2533,8 +2533,8 @@  discard block
 block discarded – undo
2533 2533
  * @return string Html content.
2534 2534
  */
2535 2535
 function geodir_import_export_page() {
2536
-	$nonce = wp_create_nonce( 'geodir_import_export_nonce' );
2537
-	$gd_cats_sample_csv = geodir_plugin_url() . '/geodirectory-assets/gd_sample_categories.csv';
2536
+	$nonce = wp_create_nonce('geodir_import_export_nonce');
2537
+	$gd_cats_sample_csv = geodir_plugin_url().'/geodirectory-assets/gd_sample_categories.csv';
2538 2538
     /**
2539 2539
      * Filter sample category data csv file url.
2540 2540
      *
@@ -2543,9 +2543,9 @@  discard block
 block discarded – undo
2543 2543
      *
2544 2544
      * @param string $gd_cats_sample_csv Sample category data csv file url.
2545 2545
      */
2546
-	$gd_cats_sample_csv = apply_filters( 'geodir_export_cats_sample_csv', $gd_cats_sample_csv );
2546
+	$gd_cats_sample_csv = apply_filters('geodir_export_cats_sample_csv', $gd_cats_sample_csv);
2547 2547
 	
2548
-	$gd_posts_sample_csv = geodir_plugin_url() . '/geodirectory-assets/place_listing.csv';
2548
+	$gd_posts_sample_csv = geodir_plugin_url().'/geodirectory-assets/place_listing.csv';
2549 2549
     /**
2550 2550
      * Filter sample post data csv file url.
2551 2551
      *
@@ -2554,15 +2554,15 @@  discard block
 block discarded – undo
2554 2554
      *
2555 2555
      * @param string $gd_posts_sample_csv Sample post data csv file url.
2556 2556
      */
2557
-    $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv );
2557
+    $gd_posts_sample_csv = apply_filters('geodir_export_posts_sample_csv', $gd_posts_sample_csv);
2558 2558
 	
2559
-	$gd_posttypes = geodir_get_posttypes( 'array' );
2559
+	$gd_posttypes = geodir_get_posttypes('array');
2560 2560
 	
2561 2561
 	$gd_posttypes_option = '';
2562
-	foreach ( $gd_posttypes as $gd_posttype => $row ) {
2563
-		$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>';
2562
+	foreach ($gd_posttypes as $gd_posttype => $row) {
2563
+		$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>';
2564 2564
 	}
2565
-	wp_enqueue_script( 'jquery-ui-progressbar' );
2565
+	wp_enqueue_script('jquery-ui-progressbar');
2566 2566
 	
2567 2567
 	$gd_chunksize_options = array();
2568 2568
 	$gd_chunksize_options[100] = 100;
@@ -2584,49 +2584,49 @@  discard block
 block discarded – undo
2584 2584
      *
2585 2585
      * @param string $gd_chunksize_options Entries options.
2586 2586
      */
2587
-    $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options );
2587
+    $gd_chunksize_options = apply_filters('geodir_export_csv_chunksize_options', $gd_chunksize_options);
2588 2588
 	
2589 2589
 	$gd_chunksize_option = '';
2590 2590
 	foreach ($gd_chunksize_options as $value => $title) {
2591
-		$gd_chunksize_option .= '<option value="' . $value . '" ' . selected($value, 5000, false) . '>' . $title . '</option>';
2591
+		$gd_chunksize_option .= '<option value="'.$value.'" '.selected($value, 5000, false).'>'.$title.'</option>';
2592 2592
 	}
2593 2593
 	
2594 2594
 	$uploads = wp_upload_dir();
2595 2595
 ?>
2596 2596
 </form>
2597 2597
 <div class="inner_content_tab_main gd-import-export">
2598
-  <h3><?php _e( 'GD Import & Export CSV', 'geodirectory' ) ;?></h3>
2599
-  <span class="description"><?php _e( 'Import & export csv for GD listings & categories.', 'geodirectory' ) ;?></span>
2598
+  <h3><?php _e('GD Import & Export CSV', 'geodirectory'); ?></h3>
2599
+  <span class="description"><?php _e('Import & export csv for GD listings & categories.', 'geodirectory'); ?></span>
2600 2600
   <div class="gd-content-heading">
2601 2601
 
2602 2602
   <?php
2603 2603
     ini_set('max_execution_time', 999999);
2604
-    $ini_max_execution_time_check = @ini_get( 'max_execution_time' );
2604
+    $ini_max_execution_time_check = @ini_get('max_execution_time');
2605 2605
     ini_restore('max_execution_time');
2606 2606
 
2607
-    if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
2607
+    if ($ini_max_execution_time_check != 999999) { // only show these setting to the user if we can't change the ini setting
2608 2608
         ?>
2609 2609
 	<div id="gd_ie_reqs" class="metabox-holder">
2610 2610
       <div class="meta-box-sortables ui-sortable">
2611 2611
         <div class="postbox">
2612
-          <h3 class="hndle"><span style='vertical-align:top;'><?php echo __( 'PHP Requirements for GD Import & Export CSV', 'geodirectory' );?></span></h3>
2612
+          <h3 class="hndle"><span style='vertical-align:top;'><?php echo __('PHP Requirements for GD Import & Export CSV', 'geodirectory'); ?></span></h3>
2613 2613
           <div class="inside">
2614
-            <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>
2614
+            <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>
2615 2615
 			<table class="form-table">
2616 2616
 				<thead>
2617 2617
 				  <tr>
2618
-				  	<th><?php _e( 'PHP Settings', 'geodirectory' );?></th><th><?php _e( 'Current Value', 'geodirectory' );?></th><th><?php _e( 'Recommended Value', 'geodirectory' );?></th>
2618
+				  	<th><?php _e('PHP Settings', 'geodirectory'); ?></th><th><?php _e('Current Value', 'geodirectory'); ?></th><th><?php _e('Recommended Value', 'geodirectory'); ?></th>
2619 2619
 				  </tr>
2620 2620
 				</thead>
2621 2621
 				<tbody>
2622 2622
 				  <tr>
2623
-				  	<td>max_input_time</td><td><?php echo @ini_get( 'max_input_time' );?></td><td>3000</td>
2623
+				  	<td>max_input_time</td><td><?php echo @ini_get('max_input_time'); ?></td><td>3000</td>
2624 2624
 				  </tr>
2625 2625
 				  <tr>
2626
-				  	<td>max_execution_time</td><td><?php  echo @ini_get( 'max_execution_time' );?></td><td>3000</td>
2626
+				  	<td>max_execution_time</td><td><?php  echo @ini_get('max_execution_time'); ?></td><td>3000</td>
2627 2627
 				  </tr>
2628 2628
 				  <tr>
2629
-				  	<td>memory_limit</td><td><?php echo @ini_get( 'memory_limit' );?></td><td>256M</td>
2629
+				  	<td>memory_limit</td><td><?php echo @ini_get('memory_limit'); ?></td><td>256M</td>
2630 2630
 				  </tr>
2631 2631
 				</tbody>
2632 2632
 		    </table>
@@ -2638,21 +2638,21 @@  discard block
 block discarded – undo
2638 2638
 	<div id="gd_ie_imposts" class="metabox-holder">
2639 2639
       <div class="meta-box-sortables ui-sortable">
2640 2640
         <div id="gd_ie_im_posts" class="postbox gd-hndle-pbox">
2641
-          <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>
2642
-          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __( 'GD Listings: Import CSV', 'geodirectory' );?></span></h3>
2641
+          <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>
2642
+          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __('GD Listings: Import CSV', 'geodirectory'); ?></span></h3>
2643 2643
           <div class="inside">
2644 2644
             <table class="form-table">
2645 2645
 				<tbody>
2646 2646
 				  <tr>
2647 2647
 					<td class="gd-imex-box">
2648 2648
 						<div class="gd-im-choices">
2649
-						<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>
2650
-						<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>
2649
+						<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>
2650
+						<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>
2651 2651
 						</div>
2652 2652
 						<div class="plupload-upload-uic hide-if-no-js" id="gd_im_postplupload-upload-ui">
2653 2653
 							<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');" />
2654
-							<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">
2655
-						<input type="hidden" id="gd_ie_imposts_csv" value="<?php echo $gd_posts_sample_csv;?>" />
2654
+							<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">
2655
+						<input type="hidden" id="gd_ie_imposts_csv" value="<?php echo $gd_posts_sample_csv; ?>" />
2656 2656
 							<?php
2657 2657
 							/**
2658 2658
 							 * Called just after the sample CSV download link.
@@ -2661,7 +2661,7 @@  discard block
 block discarded – undo
2661 2661
 							 */
2662 2662
 							do_action('geodir_sample_csv_download_link');
2663 2663
 							?>
2664
-							<span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce( 'gd_im_postpluploadan' ); ?>"></span>
2664
+							<span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce('gd_im_postpluploadan'); ?>"></span>
2665 2665
 							<div class="filelist"></div>
2666 2666
 						</div>
2667 2667
 						<span id="gd_im_catupload-error" style="display:none"></span>
@@ -2679,7 +2679,7 @@  discard block
 block discarded – undo
2679 2679
 							<input type="hidden" id="gd_terminateaction" value="continue"/>
2680 2680
 						</div>
2681 2681
 						<div class="gd-import-progress" id="gd-import-progress" style="display:none">
2682
-							<div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory');?> </b><font
2682
+							<div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory'); ?> </b><font
2683 2683
 									id="gd-import-done">0</font> / <font id="gd-import-total">0</font>&nbsp;( <font
2684 2684
 									id="gd-import-perc">0%</font> )
2685 2685
 								<div class="gd-fileprogress"></div>
@@ -2691,10 +2691,10 @@  discard block
 block discarded – undo
2691 2691
                     	<div class="gd-imex-btns" style="display:none;">
2692 2692
                         	<input type="hidden" class="geodir_import_file" name="geodir_import_file" value="save"/>
2693 2693
                         	<input onclick="gd_imex_PrepareImport(this, 'post')" type="button" value="<?php echo CSV_IMPORT_DATA; ?>" id="gd_import_data" class="button-primary" />
2694
-                        	<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"/>
2695
-                        	<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')"/>
2694
+                        	<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"/>
2695
+                        	<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')"/>
2696 2696
 							<div id="gd_process_data" style="display:none">
2697
-								<span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory');?>
2697
+								<span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory'); ?>
2698 2698
 							</div>
2699 2699
 						</div>
2700 2700
 					</td>
@@ -2708,26 +2708,26 @@  discard block
 block discarded – undo
2708 2708
 	<div id="gd_ie_excategs" class="metabox-holder">
2709 2709
 	  <div class="meta-box-sortables ui-sortable">
2710 2710
 		<div id="gd_ie_ex_posts" class="postbox gd-hndle-pbox">
2711
-		  <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>
2712
-          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __( 'GD Listings: Export CSV', 'geodirectory' );?></span></h3>
2711
+		  <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>
2712
+          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __('GD Listings: Export CSV', 'geodirectory'); ?></span></h3>
2713 2713
 		  <div class="inside">
2714 2714
 			<table class="form-table">
2715 2715
 			  <tbody>
2716 2716
 				<tr>
2717 2717
 				  <td class="fld"><label for="gd_post_type">
2718
-					<?php _e( 'Post Type:', 'geodirectory' );?>
2718
+					<?php _e('Post Type:', 'geodirectory'); ?>
2719 2719
 					</label></td>
2720 2720
 				  <td><select name="gd_post_type" id="gd_post_type" style="min-width:140px">
2721
-					  <?php echo $gd_posttypes_option;?>
2721
+					  <?php echo $gd_posttypes_option; ?>
2722 2722
 					</select></td>
2723 2723
 				</tr>
2724 2724
 				<tr>
2725
-					<td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e( 'Max entries per csv file:', 'geodirectory' );?></label></td>
2726
-					<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>
2725
+					<td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e('Max entries per csv file:', 'geodirectory'); ?></label></td>
2726
+					<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>
2727 2727
 				  </tr>
2728 2728
 				<tr>
2729 2729
 				  <td class="fld" style="vertical-align:top"><label>
2730
-					<?php _e( 'Progress:', 'geodirectory' );?>
2730
+					<?php _e('Progress:', 'geodirectory'); ?>
2731 2731
 					</label></td>
2732 2732
 				  <td><div id='gd_progressbar_box'>
2733 2733
 					  <div id="gd_progressbar" class="gd_progressbar">
@@ -2735,13 +2735,13 @@  discard block
 block discarded – undo
2735 2735
 					  </div>
2736 2736
 					</div>
2737 2737
 					<p style="display:inline-block">
2738
-					  <?php _e( 'Elapsed Time:', 'geodirectory' );?>
2738
+					  <?php _e('Elapsed Time:', 'geodirectory'); ?>
2739 2739
 					</p>
2740 2740
 					  
2741 2741
 					<p id="gd_timer" class="gd_timer">00:00:00</p></td>
2742 2742
 				</tr>
2743 2743
 				<tr class="gd-ie-actions">
2744
-				  <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">
2744
+				  <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">
2745 2745
 				  </td>
2746 2746
 				  <td id="gd_ie_ex_files" class="gd-ie-files"></td>
2747 2747
 				</tr>
@@ -2754,21 +2754,21 @@  discard block
 block discarded – undo
2754 2754
 	<div id="gd_ie_imcategs" class="metabox-holder">
2755 2755
       <div class="meta-box-sortables ui-sortable">
2756 2756
         <div id="gd_ie_imcats" class="postbox gd-hndle-pbox">
2757
-          <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>
2758
-          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __( 'GD Categories: Import CSV', 'geodirectory' );?></span></h3>
2757
+          <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>
2758
+          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __('GD Categories: Import CSV', 'geodirectory'); ?></span></h3>
2759 2759
           <div class="inside">
2760 2760
             <table class="form-table">
2761 2761
 				<tbody>
2762 2762
 				  <tr>
2763 2763
 					<td class="gd-imex-box">
2764 2764
 						<div class="gd-im-choices">
2765
-						<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>
2766
-						<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>
2765
+						<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>
2766
+						<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>
2767 2767
 						</div>
2768 2768
 						<div class="plupload-upload-uic hide-if-no-js" id="gd_im_catplupload-upload-ui">
2769 2769
 							<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');" />
2770
-							<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">
2771
-						<input type="hidden" id="gd_ie_imcats_csv" value="<?php echo $gd_cats_sample_csv;?>" />
2770
+							<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">
2771
+						<input type="hidden" id="gd_ie_imcats_csv" value="<?php echo $gd_cats_sample_csv; ?>" />
2772 2772
 						<?php
2773 2773
 						/**
2774 2774
 						 * Called just after the sample CSV download link.
@@ -2778,7 +2778,7 @@  discard block
 block discarded – undo
2778 2778
 						 */
2779 2779
 						do_action('geodir_sample_cats_csv_download_link');
2780 2780
 						?>
2781
-							<span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce( 'gd_im_catpluploadan' ); ?>"></span>
2781
+							<span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce('gd_im_catpluploadan'); ?>"></span>
2782 2782
 							<div class="filelist"></div>
2783 2783
 						</div>
2784 2784
 						<span id="gd_im_catupload-error" style="display:none"></span>
@@ -2795,7 +2795,7 @@  discard block
 block discarded – undo
2795 2795
 							<input type="hidden" id="gd_terminateaction" value="continue"/>
2796 2796
 						</div>
2797 2797
 						<div class="gd-import-progress" id="gd-import-progress" style="display:none">
2798
-							<div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory');?> </b><font
2798
+							<div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory'); ?> </b><font
2799 2799
 									id="gd-import-done">0</font> / <font id="gd-import-total">0</font>&nbsp;( <font
2800 2800
 									id="gd-import-perc">0%</font> )
2801 2801
 								<div class="gd-fileprogress"></div>
@@ -2807,10 +2807,10 @@  discard block
 block discarded – undo
2807 2807
                     	<div class="gd-imex-btns" style="display:none;">
2808 2808
                         	<input type="hidden" class="geodir_import_file" name="geodir_import_file" value="save"/>
2809 2809
                         	<input onclick="gd_imex_PrepareImport(this, 'cat')" type="button" value="<?php echo CSV_IMPORT_DATA; ?>" id="gd_import_data" class="button-primary" />
2810
-                        	<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"/>
2811
-                        	<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')"/>
2810
+                        	<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"/>
2811
+                        	<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')"/>
2812 2812
 							<div id="gd_process_data" style="display:none">
2813
-								<span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory');?>
2813
+								<span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory'); ?>
2814 2814
 							</div>
2815 2815
 						</div>
2816 2816
 					</td>
@@ -2824,26 +2824,26 @@  discard block
 block discarded – undo
2824 2824
 	<div id="gd_ie_excategs" class="metabox-holder">
2825 2825
       <div class="meta-box-sortables ui-sortable">
2826 2826
         <div id="gd_ie_ex_cats" class="postbox gd-hndle-pbox">
2827
-          <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>
2828
-          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __( 'GD Categories: Export CSV', 'geodirectory' );?></span></h3>
2827
+          <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>
2828
+          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __('GD Categories: Export CSV', 'geodirectory'); ?></span></h3>
2829 2829
           <div class="inside">
2830 2830
             <table class="form-table">
2831 2831
 				<tbody>
2832 2832
 				  <tr>
2833
-					<td class="fld"><label for="gd_post_type"><?php _e( 'Post Type:', 'geodirectory' );?></label></td>
2834
-					<td><select name="gd_post_type" id="gd_post_type" style="min-width:140px"><?php echo $gd_posttypes_option;?></select></td>
2833
+					<td class="fld"><label for="gd_post_type"><?php _e('Post Type:', 'geodirectory'); ?></label></td>
2834
+					<td><select name="gd_post_type" id="gd_post_type" style="min-width:140px"><?php echo $gd_posttypes_option; ?></select></td>
2835 2835
 				  </tr>
2836 2836
 				   <tr>
2837
-					<td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e( 'Max entries per csv file:', 'geodirectory' );?></label></td>
2838
-					<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>
2837
+					<td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e('Max entries per csv file:', 'geodirectory'); ?></label></td>
2838
+					<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>
2839 2839
 				  </tr>
2840 2840
 				  <tr>
2841
-					<td class="fld" style="vertical-align:top"><label><?php _e( 'Progress:', 'geodirectory' );?></label></td>
2842
-					<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>
2841
+					<td class="fld" style="vertical-align:top"><label><?php _e('Progress:', 'geodirectory'); ?></label></td>
2842
+					<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>
2843 2843
 				  </tr>
2844 2844
 				  <tr class="gd-ie-actions">
2845 2845
 					<td style="vertical-align:top">
2846
-						<input type="submit" value="<?php echo esc_attr( __( 'Export CSV', 'geodirectory' ) );?>" class="button-primary" name="gd_ie_excats_submit" id="gd_ie_excats_submit">
2846
+						<input type="submit" value="<?php echo esc_attr(__('Export CSV', 'geodirectory')); ?>" class="button-primary" name="gd_ie_excats_submit" id="gd_ie_excats_submit">
2847 2847
 					</td>
2848 2848
 					<td id="gd_ie_ex_files" class="gd-ie-files"></td>
2849 2849
 				  </tr>
@@ -2865,7 +2865,7 @@  discard block
 block discarded – undo
2865 2865
      * @param array $gd_chunksize_options File chunk size options.
2866 2866
      * @param string $nonce Wordpress security token for GD import & export.
2867 2867
 	 */
2868
-	do_action( 'geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce );
2868
+	do_action('geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce);
2869 2869
 	?>
2870 2870
   </div>
2871 2871
 </div>
@@ -2884,7 +2884,7 @@  discard block
 block discarded – undo
2884 2884
         jQuery.ajax({
2885 2885
             url: ajaxurl,
2886 2886
             type: "POST",
2887
-            data: 'action=geodir_import_export&task=prepare_import&_pt=' + type + '&_file=' + uploadedFile + '&_nonce=<?php echo $nonce;?>',
2887
+            data: 'action=geodir_import_export&task=prepare_import&_pt=' + type + '&_file=' + uploadedFile + '&_nonce=<?php echo $nonce; ?>',
2888 2888
             dataType: 'json',
2889 2889
             cache: false,
2890 2890
             success: function(data) {
@@ -2936,7 +2936,7 @@  discard block
 block discarded – undo
2936 2936
 
2937 2937
         jQuery(cont).find('.filelist .file').remove();
2938 2938
         
2939
-        jQuery('#gd-import-msg', cont).find('#message').removeClass('updated').addClass('error').html("<p><?php echo esc_attr( PLZ_SELECT_CSV_FILE );?></p>");
2939
+        jQuery('#gd-import-msg', cont).find('#message').removeClass('updated').addClass('error').html("<p><?php echo esc_attr(PLZ_SELECT_CSV_FILE); ?></p>");
2940 2940
         jQuery('#gd-import-msg', cont).show();
2941 2941
         
2942 2942
         return false;
@@ -2995,7 +2995,7 @@  discard block
 block discarded – undo
2995 2995
     jQuery.ajax({
2996 2996
         url: ajaxurl,
2997 2997
         type: "POST",
2998
-        data: 'action=geodir_import_export&task=import_' + type + '&_pt=' + type + '&_file=' + uploadedFile + gddata + '&_ch=' + choice + '&_nonce=<?php echo $nonce;?>',
2998
+        data: 'action=geodir_import_export&task=import_' + type + '&_pt=' + type + '&_file=' + uploadedFile + gddata + '&_ch=' + choice + '&_nonce=<?php echo $nonce; ?>',
2999 2999
         dataType : 'json',
3000 3000
         cache: false,
3001 3001
         success: function (data) {
@@ -3184,27 +3184,27 @@  discard block
 block discarded – undo
3184 3184
 
3185 3185
     var gdMsg = '<p></p>';
3186 3186
     if ( processed > 0 ) {
3187
-        var msgParse = '<p><?php echo addslashes( sprintf( __( 'Total %s item(s) found.', 'geodirectory' ), '%s' ) );?></p>';
3187
+        var msgParse = '<p><?php echo addslashes(sprintf(__('Total %s item(s) found.', 'geodirectory'), '%s')); ?></p>';
3188 3188
         msgParse = msgParse.replace("%s", processed);
3189 3189
         gdMsg += msgParse;
3190 3190
     }
3191 3191
 
3192 3192
     if ( updated > 0 ) {
3193
-        var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) updated.', 'geodirectory' ), '%s', '%d' ) );?></p>';
3193
+        var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) updated.', 'geodirectory'), '%s', '%d')); ?></p>';
3194 3194
         msgParse = msgParse.replace("%s", updated);
3195 3195
         msgParse = msgParse.replace("%d", processed);
3196 3196
         gdMsg += msgParse;
3197 3197
     }
3198 3198
 
3199 3199
     if ( created > 0 ) {
3200
-        var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) added.', 'geodirectory' ), '%s', '%d' ) );?></p>';
3200
+        var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) added.', 'geodirectory'), '%s', '%d')); ?></p>';
3201 3201
         msgParse = msgParse.replace("%s", created);
3202 3202
         msgParse = msgParse.replace("%d", processed);
3203 3203
         gdMsg += msgParse;
3204 3204
     }
3205 3205
 
3206 3206
     if ( skipped > 0 ) {
3207
-        var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) ignored due to already exists.', 'geodirectory' ), '%s', '%d' ) );?></p>';
3207
+        var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) ignored due to already exists.', 'geodirectory'), '%s', '%d')); ?></p>';
3208 3208
         msgParse = msgParse.replace("%s", skipped);
3209 3209
         msgParse = msgParse.replace("%d", processed);
3210 3210
         gdMsg += msgParse;
@@ -3214,17 +3214,17 @@  discard block
 block discarded – undo
3214 3214
         if (type=='loc') {
3215 3215
             invalid_addr = invalid;
3216 3216
         }
3217
-        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>';
3217
+        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>';
3218 3218
         msgParse = msgParse.replace("%s", invalid_addr);
3219 3219
         msgParse = msgParse.replace("%d", total);
3220 3220
         gdMsg += msgParse;
3221 3221
     }
3222 3222
 
3223 3223
     if (invalid > 0 && type!='loc') {
3224
-        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>';
3224
+        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>';
3225 3225
         
3226 3226
         if (type=='hood') {
3227
-            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>';
3227
+            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>';
3228 3228
         }
3229 3229
         msgParse = msgParse.replace("%s", invalid);
3230 3230
         msgParse = msgParse.replace("%d", total);
@@ -3232,7 +3232,7 @@  discard block
 block discarded – undo
3232 3232
     }
3233 3233
 
3234 3234
     if (images > 0) {
3235
-        gdMsg += '<p><?php echo addslashes( sprintf( CSV_TRANSFER_IMG_FOLDER, $uploads['subdir'] ) );?></p>';
3235
+        gdMsg += '<p><?php echo addslashes(sprintf(CSV_TRANSFER_IMG_FOLDER, $uploads['subdir'])); ?></p>';
3236 3236
     }
3237 3237
     gdMsg += '<p></p>';
3238 3238
     jQuery('#gd-import-msg', cont).find('#message').removeClass('error').addClass('updated').html(gdMsg);
@@ -3381,7 +3381,7 @@  discard block
 block discarded – undo
3381 3381
         
3382 3382
     function gd_process_export_posts(el, post_type, total_posts, chunk_size, pages, page) {
3383 3383
         if (page < 2) {
3384
-            gd_progressbar(el, 0, '0% (0 / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr( __( 'Exporting...', 'geodirectory' ) );?>');
3384
+            gd_progressbar(el, 0, '0% (0 / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Exporting...', 'geodirectory')); ?>');
3385 3385
             jQuery(el).find('#gd_timer').text('00:00:01');
3386 3386
             jQuery('#gd_ie_ex_files', el).html('');
3387 3387
         }
@@ -3389,7 +3389,7 @@  discard block
 block discarded – undo
3389 3389
         jQuery.ajax({
3390 3390
             url: ajaxurl,
3391 3391
             type: "POST",
3392
-            data: 'action=geodir_import_export&task=export_posts&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce;?>&_p=' + page,
3392
+            data: 'action=geodir_import_export&task=export_posts&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce; ?>&_p=' + page,
3393 3393
             dataType : 'json',
3394 3394
             cache: false,
3395 3395
             beforeSend: function (jqXHR, settings) {},
@@ -3403,11 +3403,11 @@  discard block
 block discarded – undo
3403 3403
                     } else {
3404 3404
                         if (pages < page || pages == page) {
3405 3405
                             window.clearInterval(timer_posts);
3406
-                            gd_progressbar(el, 100, '100% (' + total_posts + ' / ' + total_posts + ') <i class="fa fa-check"></i><?php echo esc_attr( __( 'Complete!', 'geodirectory' ) );?>');
3406
+                            gd_progressbar(el, 100, '100% (' + total_posts + ' / ' + total_posts + ') <i class="fa fa-check"></i><?php echo esc_attr(__('Complete!', 'geodirectory')); ?>');
3407 3407
                         } else {
3408 3408
                             var percentage = Math.round(((page * chunk_size) / total_posts) * 100);
3409 3409
                             percentage = percentage > 100 ? 100 : percentage;
3410
-                            gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr( __( 'Exporting...', 'geodirectory' ) );?>');
3410
+                            gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Exporting...', 'geodirectory')); ?>');
3411 3411
                         }
3412 3412
                         if (typeof data.files != 'undefined' && jQuery(data.files).length ) {
3413 3413
                             var obj_files = data.files;
@@ -3437,7 +3437,7 @@  discard block
 block discarded – undo
3437 3437
 
3438 3438
     function gd_process_export_cats(el, post_type, total_cats, chunk_size, pages, page) {
3439 3439
         if (page < 2) {
3440
-            gd_progressbar(el, 0, '0% (0 / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr( __( 'Exporting...', 'geodirectory' ) );?>');
3440
+            gd_progressbar(el, 0, '0% (0 / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Exporting...', 'geodirectory')); ?>');
3441 3441
             jQuery(el).find('#gd_timer').text('00:00:01');
3442 3442
             jQuery('#gd_ie_ex_files', el).html('');
3443 3443
         }
@@ -3445,7 +3445,7 @@  discard block
 block discarded – undo
3445 3445
         jQuery.ajax({
3446 3446
             url: ajaxurl,
3447 3447
             type: "POST",
3448
-            data: 'action=geodir_import_export&task=export_cats&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce;?>&_p=' + page,
3448
+            data: 'action=geodir_import_export&task=export_cats&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce; ?>&_p=' + page,
3449 3449
             dataType : 'json',
3450 3450
             cache: false,
3451 3451
             beforeSend: function (jqXHR, settings) {},
@@ -3459,11 +3459,11 @@  discard block
 block discarded – undo
3459 3459
                     } else {
3460 3460
                         if (pages < page || pages == page) {
3461 3461
                             window.clearInterval(timer_cats);
3462
-                            gd_progressbar(el, 100, '100% (' + total_cats + ' / ' + total_cats + ') <i class="fa fa-check"></i><?php echo esc_attr( __( 'Complete!', 'geodirectory' ) );?>');
3462
+                            gd_progressbar(el, 100, '100% (' + total_cats + ' / ' + total_cats + ') <i class="fa fa-check"></i><?php echo esc_attr(__('Complete!', 'geodirectory')); ?>');
3463 3463
                         } else {
3464 3464
                             var percentage = Math.round(((page * chunk_size) / total_cats) * 100);
3465 3465
                             percentage = percentage > 100 ? 100 : percentage;
3466
-                            gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php esc_attr_e( 'Exporting...', 'geodirectory' );?>');
3466
+                            gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php esc_attr_e('Exporting...', 'geodirectory'); ?>');
3467 3467
                         }
3468 3468
                         if (typeof data.files != 'undefined' && jQuery(data.files).length ) {
3469 3469
                             var obj_files = data.files;
@@ -3520,13 +3520,13 @@  discard block
 block discarded – undo
3520 3520
 function geodir_init_filesystem()
3521 3521
 {
3522 3522
 
3523
-    if(!function_exists('get_filesystem_method')){
3523
+    if (!function_exists('get_filesystem_method')) {
3524 3524
         require_once(ABSPATH."/wp-admin/includes/file.php");
3525 3525
     }
3526 3526
     $access_type = get_filesystem_method();
3527 3527
     if ($access_type === 'direct') {
3528 3528
         /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
3529
-        $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3529
+        $creds = request_filesystem_credentials(trailingslashit(site_url()).'wp-admin/', '', false, false, array());
3530 3530
 
3531 3531
         /* initialize the API */
3532 3532
         if (!WP_Filesystem($creds)) {
@@ -3539,7 +3539,7 @@  discard block
 block discarded – undo
3539 3539
         return $wp_filesystem;
3540 3540
         /* do our file manipulations below */
3541 3541
     } elseif (defined('FTP_USER')) {
3542
-        $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3542
+        $creds = request_filesystem_credentials(trailingslashit(site_url()).'wp-admin/', '', false, false, array());
3543 3543
 
3544 3544
         /* initialize the API */
3545 3545
         if (!WP_Filesystem($creds)) {
@@ -3574,7 +3574,7 @@  discard block
 block discarded – undo
3574 3574
  * @package GeoDirectory
3575 3575
  */
3576 3576
 function geodir_filesystem_notice()
3577
-{   if ( defined( 'DOING_AJAX' ) ){return;}
3577
+{   if (defined('DOING_AJAX')) {return; }
3578 3578
     $access_type = get_filesystem_method();
3579 3579
     if ($access_type === 'direct') {
3580 3580
     } elseif (!defined('FTP_USER')) {
@@ -3611,64 +3611,64 @@  discard block
 block discarded – undo
3611 3611
     // try to set higher limits for import
3612 3612
     $max_input_time = ini_get('max_input_time');
3613 3613
     $max_execution_time = ini_get('max_execution_time');
3614
-    $memory_limit= ini_get('memory_limit');
3614
+    $memory_limit = ini_get('memory_limit');
3615 3615
 
3616
-    if(!$max_input_time || $max_input_time<3000){
3616
+    if (!$max_input_time || $max_input_time < 3000) {
3617 3617
         ini_set('max_input_time', 3000);
3618 3618
     }
3619 3619
 
3620
-    if(!$max_execution_time || $max_execution_time<3000){
3620
+    if (!$max_execution_time || $max_execution_time < 3000) {
3621 3621
         ini_set('max_execution_time', 3000);
3622 3622
     }
3623 3623
 
3624
-    if($memory_limit && str_replace('M','',$memory_limit)){
3625
-        if(str_replace('M','',$memory_limit)<256){
3624
+    if ($memory_limit && str_replace('M', '', $memory_limit)) {
3625
+        if (str_replace('M', '', $memory_limit) < 256) {
3626 3626
             ini_set('memory_limit', '256M');
3627 3627
         }
3628 3628
     }
3629 3629
 
3630 3630
     $json = array();
3631 3631
 
3632
-    if ( !current_user_can( 'manage_options' ) ) {
3633
-        wp_send_json( $json );
3632
+    if (!current_user_can('manage_options')) {
3633
+        wp_send_json($json);
3634 3634
     }
3635 3635
 
3636
-    $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL;
3637
-    $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL;
3638
-    $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false;
3636
+    $task = isset($_REQUEST['task']) ? $_REQUEST['task'] : NULL;
3637
+    $nonce = isset($_REQUEST['_nonce']) ? $_REQUEST['_nonce'] : NULL;
3638
+    $stat = isset($_REQUEST['_st']) ? $_REQUEST['_st'] : false;
3639 3639
 
3640
-    if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
3641
-        wp_send_json( $json );
3640
+    if (!wp_verify_nonce($nonce, 'geodir_import_export_nonce')) {
3641
+        wp_send_json($json);
3642 3642
     }
3643 3643
 
3644
-    $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL;
3645
-    $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL;
3644
+    $post_type = isset($_REQUEST['_pt']) ? $_REQUEST['_pt'] : NULL;
3645
+    $chunk_per_page = isset($_REQUEST['_n']) ? absint($_REQUEST['_n']) : NULL;
3646 3646
     $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page;
3647
-    $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1;
3647
+    $chunk_page_no = isset($_REQUEST['_p']) ? absint($_REQUEST['_p']) : 1;
3648 3648
 
3649 3649
     $wp_filesystem = geodir_init_filesystem();
3650 3650
     if (!$wp_filesystem) {
3651
-        $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' );
3652
-        wp_send_json( $json );
3651
+        $json['error'] = __('Filesystem ERROR: Could not access filesystem.', 'geodirectory');
3652
+        wp_send_json($json);
3653 3653
     }
3654 3654
 
3655 3655
     if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
3656
-        $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' );
3657
-        wp_send_json( $json );
3656
+        $json['error'] = __('Filesystem ERROR: '.$wp_filesystem->errors->get_error_message(), 'geodirectory');
3657
+        wp_send_json($json);
3658 3658
     }
3659 3659
 
3660
-    $csv_file_dir = geodir_path_import_export( false );
3661
-    if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
3662
-        if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
3663
-            $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' );
3664
-            wp_send_json( $json );
3660
+    $csv_file_dir = geodir_path_import_export(false);
3661
+    if (!$wp_filesystem->is_dir($csv_file_dir)) {
3662
+        if (!$wp_filesystem->mkdir($csv_file_dir, FS_CHMOD_DIR)) {
3663
+            $json['error'] = __('ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory');
3664
+            wp_send_json($json);
3665 3665
         }
3666 3666
     }
3667 3667
     
3668 3668
     $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
3669 3669
     $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
3670 3670
 
3671
-    switch ( $task ) {
3671
+    switch ($task) {
3672 3672
         case 'export_posts': {
3673 3673
             // WPML
3674 3674
             $is_wpml = geodir_is_wpml();
@@ -3679,22 +3679,22 @@  discard block
 block discarded – undo
3679 3679
                 $sitepress->switch_lang('all', true);
3680 3680
             }
3681 3681
             // WPML
3682
-            if ( $post_type == 'gd_event' ) {
3683
-                add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 );
3682
+            if ($post_type == 'gd_event') {
3683
+                add_filter('geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2);
3684 3684
             }
3685
-            $file_name = $post_type . '_' . date( 'dmyHi' );
3686
-            $posts_count = geodir_get_posts_count( $post_type );
3687
-            $file_url_base = geodir_path_import_export() . '/';
3688
-            $file_url = $file_url_base . $file_name . '.csv';
3689
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3690
-            $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv';
3685
+            $file_name = $post_type.'_'.date('dmyHi');
3686
+            $posts_count = geodir_get_posts_count($post_type);
3687
+            $file_url_base = geodir_path_import_export().'/';
3688
+            $file_url = $file_url_base.$file_name.'.csv';
3689
+            $file_path = $csv_file_dir.'/'.$file_name.'.csv';
3690
+            $file_path_temp = $csv_file_dir.'/'.$post_type.'_'.$nonce.'.csv';
3691 3691
             
3692 3692
             $chunk_file_paths = array();
3693 3693
 
3694
-            if ( isset( $_REQUEST['_st'] ) ) {
3695
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3696
-                $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0;
3697
-                $percentage = min( $percentage, 100 );
3694
+            if (isset($_REQUEST['_st'])) {
3695
+                $line_count = (int) geodir_import_export_line_count($file_path_temp);
3696
+                $percentage = count($posts_count) > 0 && $line_count > 0 ? ceil($line_count / $posts_count) * 100 : 0;
3697
+                $percentage = min($percentage, 100);
3698 3698
                 
3699 3699
                 $json['percentage'] = $percentage;
3700 3700
                 // WPML
@@ -3702,45 +3702,45 @@  discard block
 block discarded – undo
3702 3702
                     $sitepress->switch_lang($active_lang, true);
3703 3703
                 }
3704 3704
                 // WPML
3705
-                wp_send_json( $json );
3705
+                wp_send_json($json);
3706 3706
                 gd_die();
3707 3707
             } else {
3708
-                if ( !$posts_count > 0 ) {
3709
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3708
+                if (!$posts_count > 0) {
3709
+                    $json['error'] = __('No records to export.', 'geodirectory');
3710 3710
                 } else {
3711 3711
                     $total_posts = $posts_count;
3712 3712
                     if ($chunk_per_page > $total_posts) {
3713 3713
                         $chunk_per_page = $total_posts;
3714 3714
                     }
3715
-                    $chunk_total_pages = ceil( $total_posts / $chunk_per_page );
3715
+                    $chunk_total_pages = ceil($total_posts / $chunk_per_page);
3716 3716
                     
3717 3717
                     $j = $chunk_page_no;
3718
-                    $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j );
3718
+                    $chunk_save_posts = geodir_imex_get_posts($post_type, $chunk_per_page, $j);
3719 3719
                     
3720 3720
                     $per_page = 500;
3721 3721
                     if ($per_page > $chunk_per_page) {
3722 3722
                         $per_page = $chunk_per_page;
3723 3723
                     }
3724
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3724
+                    $total_pages = ceil($chunk_per_page / $per_page);
3725 3725
                     
3726
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3727
-                        $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page );
3726
+                    for ($i = 0; $i <= $total_pages; $i++) {
3727
+                        $save_posts = array_slice($chunk_save_posts, ($i * $per_page), $per_page);
3728 3728
                         
3729 3729
                         $clear = $i == 0 ? true : false;
3730
-                        geodir_save_csv_data( $file_path_temp, $save_posts, $clear );
3730
+                        geodir_save_csv_data($file_path_temp, $save_posts, $clear);
3731 3731
                     }
3732 3732
                         
3733
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3734
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3735
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3736
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3737
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3733
+                    if ($wp_filesystem->exists($file_path_temp)) {
3734
+                        $chunk_page_no = $chunk_total_pages > 1 ? '-'.$j : '';
3735
+                        $chunk_file_name = $file_name.$chunk_page_no.'.csv';
3736
+                        $file_path = $csv_file_dir.'/'.$chunk_file_name;
3737
+                        $wp_filesystem->move($file_path_temp, $file_path, true);
3738 3738
                         
3739
-                        $file_url = $file_url_base . $chunk_file_name;
3740
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3739
+                        $file_url = $file_url_base.$chunk_file_name;
3740
+                        $chunk_file_paths[] = array('i' => $j.'.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3741 3741
                     }
3742 3742
                     
3743
-                    if ( !empty($chunk_file_paths) ) {
3743
+                    if (!empty($chunk_file_paths)) {
3744 3744
                         $json['total'] = $posts_count;
3745 3745
                         $json['files'] = $chunk_file_paths;
3746 3746
                     } else {
@@ -3748,7 +3748,7 @@  discard block
 block discarded – undo
3748 3748
                             $json['total'] = $posts_count;
3749 3749
                             $json['files'] = array();
3750 3750
                         } else {
3751
-                            $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3751
+                            $json['error'] = __('ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory');
3752 3752
                         }
3753 3753
                     }
3754 3754
                 }
@@ -3757,7 +3757,7 @@  discard block
 block discarded – undo
3757 3757
                     $sitepress->switch_lang($active_lang, true);
3758 3758
                 }
3759 3759
                 // WPML
3760
-                wp_send_json( $json );
3760
+                wp_send_json($json);
3761 3761
             }
3762 3762
         }
3763 3763
         break;
@@ -3771,20 +3771,20 @@  discard block
 block discarded – undo
3771 3771
                 $sitepress->switch_lang('all', true);
3772 3772
             }
3773 3773
             // WPML
3774
-            $file_name = $post_type . 'category_' . date( 'dmyHi' );
3774
+            $file_name = $post_type.'category_'.date('dmyHi');
3775 3775
             
3776
-            $terms_count = geodir_get_terms_count( $post_type );
3777
-            $file_url_base = geodir_path_import_export() . '/';
3778
-            $file_url = $file_url_base . $file_name . '.csv';
3779
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3780
-            $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv';
3776
+            $terms_count = geodir_get_terms_count($post_type);
3777
+            $file_url_base = geodir_path_import_export().'/';
3778
+            $file_url = $file_url_base.$file_name.'.csv';
3779
+            $file_path = $csv_file_dir.'/'.$file_name.'.csv';
3780
+            $file_path_temp = $csv_file_dir.'/'.$post_type.'category_'.$nonce.'.csv';
3781 3781
             
3782 3782
             $chunk_file_paths = array();
3783 3783
             
3784
-            if ( isset( $_REQUEST['_st'] ) ) {
3785
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3786
-                $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0;
3787
-                $percentage = min( $percentage, 100 );
3784
+            if (isset($_REQUEST['_st'])) {
3785
+                $line_count = (int) geodir_import_export_line_count($file_path_temp);
3786
+                $percentage = count($terms_count) > 0 && $line_count > 0 ? ceil($line_count / $terms_count) * 100 : 0;
3787
+                $percentage = min($percentage, 100);
3788 3788
                 
3789 3789
                 $json['percentage'] = $percentage;
3790 3790
                 // WPML
@@ -3792,48 +3792,48 @@  discard block
 block discarded – undo
3792 3792
                     $sitepress->switch_lang($active_lang, true);
3793 3793
                 }
3794 3794
                 // WPML
3795
-                wp_send_json( $json );
3795
+                wp_send_json($json);
3796 3796
             } else {
3797
-                if ( !$terms_count > 0 ) {
3798
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3797
+                if (!$terms_count > 0) {
3798
+                    $json['error'] = __('No records to export.', 'geodirectory');
3799 3799
                 } else {
3800 3800
                     $total_terms = $terms_count;
3801 3801
                     if ($chunk_per_page > $terms_count) {
3802 3802
                         $chunk_per_page = $terms_count;
3803 3803
                     }
3804
-                    $chunk_total_pages = ceil( $total_terms / $chunk_per_page );
3804
+                    $chunk_total_pages = ceil($total_terms / $chunk_per_page);
3805 3805
                     
3806 3806
                     $j = $chunk_page_no;
3807
-                    $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j );
3807
+                    $chunk_save_terms = geodir_imex_get_terms($post_type, $chunk_per_page, $j);
3808 3808
                     
3809 3809
                     $per_page = 500;
3810 3810
                     if ($per_page > $chunk_per_page) {
3811 3811
                         $per_page = $chunk_per_page;
3812 3812
                     }
3813
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3813
+                    $total_pages = ceil($chunk_per_page / $per_page);
3814 3814
                     
3815
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3816
-                        $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page );
3815
+                    for ($i = 0; $i <= $total_pages; $i++) {
3816
+                        $save_terms = array_slice($chunk_save_terms, ($i * $per_page), $per_page);
3817 3817
                         
3818 3818
                         $clear = $i == 0 ? true : false;
3819
-                        geodir_save_csv_data( $file_path_temp, $save_terms, $clear );
3819
+                        geodir_save_csv_data($file_path_temp, $save_terms, $clear);
3820 3820
                     }
3821 3821
                     
3822
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3823
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3824
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3825
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3826
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3822
+                    if ($wp_filesystem->exists($file_path_temp)) {
3823
+                        $chunk_page_no = $chunk_total_pages > 1 ? '-'.$j : '';
3824
+                        $chunk_file_name = $file_name.$chunk_page_no.'.csv';
3825
+                        $file_path = $csv_file_dir.'/'.$chunk_file_name;
3826
+                        $wp_filesystem->move($file_path_temp, $file_path, true);
3827 3827
                         
3828
-                        $file_url = $file_url_base . $chunk_file_name;
3829
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3828
+                        $file_url = $file_url_base.$chunk_file_name;
3829
+                        $chunk_file_paths[] = array('i' => $j.'.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3830 3830
                     }
3831 3831
                     
3832
-                    if ( !empty($chunk_file_paths) ) {
3832
+                    if (!empty($chunk_file_paths)) {
3833 3833
                         $json['total'] = $terms_count;
3834 3834
                         $json['files'] = $chunk_file_paths;
3835 3835
                     } else {
3836
-                        $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3836
+                        $json['error'] = __('ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory');
3837 3837
                     }
3838 3838
                 }
3839 3839
                 // WPML
@@ -3841,127 +3841,127 @@  discard block
 block discarded – undo
3841 3841
                     $sitepress->switch_lang($active_lang, true);
3842 3842
                 }
3843 3843
                 // WPML
3844
-                wp_send_json( $json );
3844
+                wp_send_json($json);
3845 3845
             }
3846 3846
         }
3847 3847
         break;
3848 3848
         case 'export_locations': {
3849
-            $file_url_base = geodir_path_import_export() . '/';
3850
-            $file_name = 'gd_locations_' . date( 'dmyHi' );
3851
-            $file_url = $file_url_base . $file_name . '.csv';
3852
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3853
-            $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv';
3849
+            $file_url_base = geodir_path_import_export().'/';
3850
+            $file_name = 'gd_locations_'.date('dmyHi');
3851
+            $file_url = $file_url_base.$file_name.'.csv';
3852
+            $file_path = $csv_file_dir.'/'.$file_name.'.csv';
3853
+            $file_path_temp = $csv_file_dir.'/gd_locations_'.$nonce.'.csv';
3854 3854
             
3855
-            $items_count = (int)geodir_location_imex_count_locations();
3855
+            $items_count = (int) geodir_location_imex_count_locations();
3856 3856
             
3857
-            if ( isset( $_REQUEST['_st'] ) ) {
3858
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3859
-                $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3860
-                $percentage = min( $percentage, 100 );
3857
+            if (isset($_REQUEST['_st'])) {
3858
+                $line_count = (int) geodir_import_export_line_count($file_path_temp);
3859
+                $percentage = count($items_count) > 0 && $line_count > 0 ? ceil($line_count / $items_count) * 100 : 0;
3860
+                $percentage = min($percentage, 100);
3861 3861
                 
3862 3862
                 $json['percentage'] = $percentage;
3863
-                wp_send_json( $json );
3863
+                wp_send_json($json);
3864 3864
             } else {
3865 3865
                 $chunk_file_paths = array();
3866 3866
                 
3867
-                if ( !$items_count > 0 ) {
3868
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3867
+                if (!$items_count > 0) {
3868
+                    $json['error'] = __('No records to export.', 'geodirectory');
3869 3869
                 } else {
3870
-                    $chunk_per_page = min( $chunk_per_page, $items_count );
3871
-                    $chunk_total_pages = ceil( $items_count / $chunk_per_page );
3870
+                    $chunk_per_page = min($chunk_per_page, $items_count);
3871
+                    $chunk_total_pages = ceil($items_count / $chunk_per_page);
3872 3872
                     
3873 3873
                     $j = $chunk_page_no;
3874
-                    $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j );
3874
+                    $chunk_save_items = geodir_location_imex_locations_data($chunk_per_page, $j);
3875 3875
                     
3876 3876
                     $per_page = 500;
3877
-                    $per_page = min( $per_page, $chunk_per_page );
3878
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3877
+                    $per_page = min($per_page, $chunk_per_page);
3878
+                    $total_pages = ceil($chunk_per_page / $per_page);
3879 3879
                     
3880
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3881
-                        $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3880
+                    for ($i = 0; $i <= $total_pages; $i++) {
3881
+                        $save_items = array_slice($chunk_save_items, ($i * $per_page), $per_page);
3882 3882
                         
3883 3883
                         $clear = $i == 0 ? true : false;
3884
-                        geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3884
+                        geodir_save_csv_data($file_path_temp, $save_items, $clear);
3885 3885
                     }
3886 3886
                     
3887
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3888
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3889
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3890
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3891
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3887
+                    if ($wp_filesystem->exists($file_path_temp)) {
3888
+                        $chunk_page_no = $chunk_total_pages > 1 ? '-'.$j : '';
3889
+                        $chunk_file_name = $file_name.$chunk_page_no.'.csv';
3890
+                        $file_path = $csv_file_dir.'/'.$chunk_file_name;
3891
+                        $wp_filesystem->move($file_path_temp, $file_path, true);
3892 3892
                         
3893
-                        $file_url = $file_url_base . $chunk_file_name;
3894
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3893
+                        $file_url = $file_url_base.$chunk_file_name;
3894
+                        $chunk_file_paths[] = array('i' => $j.'.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3895 3895
                     }
3896 3896
                     
3897
-                    if ( !empty($chunk_file_paths) ) {
3897
+                    if (!empty($chunk_file_paths)) {
3898 3898
                         $json['total'] = $items_count;
3899 3899
                         $json['files'] = $chunk_file_paths;
3900 3900
                     } else {
3901
-                        $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3901
+                        $json['error'] = __('Fail, something wrong to create csv file.', 'geodirectory');
3902 3902
                     }
3903 3903
                 }
3904
-                wp_send_json( $json );
3904
+                wp_send_json($json);
3905 3905
             }
3906 3906
         }
3907 3907
         break;
3908 3908
         case 'export_hoods': {
3909
-            $file_url_base = geodir_path_import_export() . '/';
3910
-            $file_name = 'gd_neighbourhoods_' . date( 'dmyHi' );
3911
-            $file_url = $file_url_base . $file_name . '.csv';
3912
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3913
-            $file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv';
3909
+            $file_url_base = geodir_path_import_export().'/';
3910
+            $file_name = 'gd_neighbourhoods_'.date('dmyHi');
3911
+            $file_url = $file_url_base.$file_name.'.csv';
3912
+            $file_path = $csv_file_dir.'/'.$file_name.'.csv';
3913
+            $file_path_temp = $csv_file_dir.'/gd_neighbourhoods_'.$nonce.'.csv';
3914 3914
             
3915
-            $items_count = (int)geodir_location_imex_count_neighbourhoods();
3915
+            $items_count = (int) geodir_location_imex_count_neighbourhoods();
3916 3916
             
3917
-            if ( isset( $_REQUEST['_st'] ) ) {
3918
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3919
-                $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3920
-                $percentage = min( $percentage, 100 );
3917
+            if (isset($_REQUEST['_st'])) {
3918
+                $line_count = (int) geodir_import_export_line_count($file_path_temp);
3919
+                $percentage = count($items_count) > 0 && $line_count > 0 ? ceil($line_count / $items_count) * 100 : 0;
3920
+                $percentage = min($percentage, 100);
3921 3921
                 
3922 3922
                 $json['percentage'] = $percentage;
3923
-                wp_send_json( $json );
3923
+                wp_send_json($json);
3924 3924
             } else {
3925 3925
                 $chunk_file_paths = array();
3926 3926
                 
3927
-                if ( !$items_count > 0 ) {
3928
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3927
+                if (!$items_count > 0) {
3928
+                    $json['error'] = __('No records to export.', 'geodirectory');
3929 3929
                 } else {
3930
-                    $chunk_per_page = min( $chunk_per_page, $items_count );
3931
-                    $chunk_total_pages = ceil( $items_count / $chunk_per_page );
3930
+                    $chunk_per_page = min($chunk_per_page, $items_count);
3931
+                    $chunk_total_pages = ceil($items_count / $chunk_per_page);
3932 3932
                     
3933 3933
                     $j = $chunk_page_no;
3934
-                    $chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j );
3934
+                    $chunk_save_items = geodir_location_imex_neighbourhoods_data($chunk_per_page, $j);
3935 3935
                     
3936 3936
                     $per_page = 500;
3937
-                    $per_page = min( $per_page, $chunk_per_page );
3938
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3937
+                    $per_page = min($per_page, $chunk_per_page);
3938
+                    $total_pages = ceil($chunk_per_page / $per_page);
3939 3939
                     
3940
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3941
-                        $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3940
+                    for ($i = 0; $i <= $total_pages; $i++) {
3941
+                        $save_items = array_slice($chunk_save_items, ($i * $per_page), $per_page);
3942 3942
                         
3943 3943
                         $clear = $i == 0 ? true : false;
3944
-                        geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3944
+                        geodir_save_csv_data($file_path_temp, $save_items, $clear);
3945 3945
                     }
3946 3946
                     
3947
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3948
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3949
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3950
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3951
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3947
+                    if ($wp_filesystem->exists($file_path_temp)) {
3948
+                        $chunk_page_no = $chunk_total_pages > 1 ? '-'.$j : '';
3949
+                        $chunk_file_name = $file_name.$chunk_page_no.'.csv';
3950
+                        $file_path = $csv_file_dir.'/'.$chunk_file_name;
3951
+                        $wp_filesystem->move($file_path_temp, $file_path, true);
3952 3952
                         
3953
-                        $file_url = $file_url_base . $chunk_file_name;
3954
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3953
+                        $file_url = $file_url_base.$chunk_file_name;
3954
+                        $chunk_file_paths[] = array('i' => $j.'.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3955 3955
                     }
3956 3956
                     
3957
-                    if ( !empty($chunk_file_paths) ) {
3957
+                    if (!empty($chunk_file_paths)) {
3958 3958
                         $json['total'] = $items_count;
3959 3959
                         $json['files'] = $chunk_file_paths;
3960 3960
                     } else {
3961
-                        $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3961
+                        $json['error'] = __('Fail, something wrong to create csv file.', 'geodirectory');
3962 3962
                     }
3963 3963
                 }
3964
-                wp_send_json( $json );
3964
+                wp_send_json($json);
3965 3965
             }
3966 3966
         }
3967 3967
         break;
@@ -3978,33 +3978,33 @@  discard block
 block discarded – undo
3978 3978
             }
3979 3979
             // WPML
3980 3980
             
3981
-            ini_set( 'auto_detect_line_endings', true );
3981
+            ini_set('auto_detect_line_endings', true);
3982 3982
             
3983 3983
             $uploads = wp_upload_dir();
3984 3984
             $uploads_dir = $uploads['path'];
3985 3985
             $uploads_subdir = $uploads['subdir'];
3986 3986
             
3987
-            $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL;
3988
-            $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip';
3987
+            $csv_file = isset($_POST['_file']) ? $_POST['_file'] : NULL;
3988
+            $import_choice = isset($_REQUEST['_ch']) ? $_REQUEST['_ch'] : 'skip';
3989 3989
             
3990
-            $csv_file_arr = explode( '/', $csv_file );
3991
-            $csv_filename = end( $csv_file_arr );
3992
-            $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename;
3990
+            $csv_file_arr = explode('/', $csv_file);
3991
+            $csv_filename = end($csv_file_arr);
3992
+            $target_path = $uploads_dir.'/temp_'.$current_user->data->ID.'/'.$csv_filename;
3993 3993
             
3994 3994
             $json['file'] = $csv_file;
3995
-            $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' );
3995
+            $json['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
3996 3996
             $file = array();
3997 3997
 
3998
-            if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
3999
-                $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename );
3998
+            if ($csv_file && $wp_filesystem->is_file($target_path) && $wp_filesystem->exists($target_path)) {
3999
+                $wp_filetype = wp_check_filetype_and_ext($target_path, $csv_filename);
4000 4000
                 
4001 4001
                 if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
4002 4002
                     $json['error'] = NULL;
4003 4003
                     $json['rows'] = 0;
4004 4004
                     
4005
-                    if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
4006
-                        while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
4007
-                            if ( !empty( $data ) ) {
4005
+                    if (($handle = fopen($target_path, "r")) !== FALSE) {
4006
+                        while (($data = fgetcsv($handle, 100000, ",")) !== FALSE) {
4007
+                            if (!empty($data)) {
4008 4008
                                 $file[] = $data;
4009 4009
                             }
4010 4010
                         }
@@ -4017,19 +4017,19 @@  discard block
 block discarded – undo
4017 4017
                         $json['error'] = __('No data found in csv file.', 'geodirectory');
4018 4018
                     }
4019 4019
                 } else {
4020
-                    wp_send_json( $json );
4020
+                    wp_send_json($json);
4021 4021
                 }
4022 4022
             } else {
4023
-                wp_send_json( $json );
4023
+                wp_send_json($json);
4024 4024
             }
4025 4025
             
4026
-            if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
4027
-                wp_send_json( $json );
4026
+            if ($task == 'prepare_import' || !empty($json['error'])) {
4027
+                wp_send_json($json);
4028 4028
             }
4029 4029
             
4030 4030
             $total = $json['rows'];
4031
-            $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1;
4032
-            $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0;
4031
+            $limit = isset($_POST['limit']) ? (int) $_POST['limit'] : 1;
4032
+            $processed = isset($_POST['processed']) ? (int) $_POST['processed'] : 0;
4033 4033
             
4034 4034
             $count = $limit;
4035 4035
             
@@ -4054,13 +4054,13 @@  discard block
 block discarded – undo
4054 4054
             
4055 4055
             $post_types = geodir_get_posttypes();
4056 4056
 
4057
-            if ( $task == 'import_cat' ) {
4057
+            if ($task == 'import_cat') {
4058 4058
                 if (!empty($file)) {
4059 4059
                     $columns = isset($file[0]) ? $file[0] : NULL;
4060 4060
                     
4061 4061
                     if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4062 4062
                         $json['error'] = CSV_INVAILD_FILE;
4063
-                        wp_send_json( $json );
4063
+                        wp_send_json($json);
4064 4064
                         exit;
4065 4065
                     }
4066 4066
                     
@@ -4071,7 +4071,7 @@  discard block
 block discarded – undo
4071 4071
                         
4072 4072
                         if (isset($file[$index])) {
4073 4073
                             $row = $file[$index];
4074
-                            $row = array_map( 'trim', $row );
4074
+                            $row = array_map('trim', $row);
4075 4075
                             //$row = array_map( 'utf8_encode', $row );
4076 4076
                             
4077 4077
                             $cat_id = '';
@@ -4088,42 +4088,42 @@  discard block
 block discarded – undo
4088 4088
                             $cat_id_original = '';
4089 4089
                             
4090 4090
                             $c = 0;
4091
-                            foreach ($columns as $column ) {
4092
-                                if ( $column == 'cat_id' ) {
4093
-                                    $cat_id = (int)$row[$c];
4094
-                                } else if ( $column == 'cat_name' ) {
4091
+                            foreach ($columns as $column) {
4092
+                                if ($column == 'cat_id') {
4093
+                                    $cat_id = (int) $row[$c];
4094
+                                } else if ($column == 'cat_name') {
4095 4095
                                     $cat_name = $row[$c];
4096
-                                } else if ( $column == 'cat_slug' ) {
4096
+                                } else if ($column == 'cat_slug') {
4097 4097
                                     $cat_slug = $row[$c];
4098
-                                } else if ( $column == 'cat_posttype' ) {
4098
+                                } else if ($column == 'cat_posttype') {
4099 4099
                                     $cat_posttype = $row[$c];
4100
-                                } else if ( $column == 'cat_parent' ) {
4100
+                                } else if ($column == 'cat_parent') {
4101 4101
                                     $cat_parent = trim($row[$c]);
4102
-                                } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
4102
+                                } else if ($column == 'cat_schema' && $row[$c] != '') {
4103 4103
                                     $cat_schema = $row[$c];
4104
-                                } else if ( $column == 'cat_description' ) {
4104
+                                } else if ($column == 'cat_description') {
4105 4105
                                     $cat_description = $row[$c];
4106
-                                } else if ( $column == 'cat_top_description' ) {
4106
+                                } else if ($column == 'cat_top_description') {
4107 4107
                                     $cat_top_description = $row[$c];
4108
-                                } else if ( $column == 'cat_image' ) {
4108
+                                } else if ($column == 'cat_image') {
4109 4109
                                     $cat_image = $row[$c];
4110
-                                } else if ( $column == 'cat_icon' ) {
4110
+                                } else if ($column == 'cat_icon') {
4111 4111
                                     $cat_icon = $row[$c];
4112 4112
                                 }
4113 4113
                                 // WPML
4114
-                                if ( $is_wpml ) {
4115
-                                    if ( $column == 'cat_language' ) {
4116
-                                        $cat_language = geodir_strtolower( trim( $row[$c] ) );
4117
-                                    } else if ( $column == 'cat_id_original' ) {
4118
-                                        $cat_id_original = (int)$row[$c];
4114
+                                if ($is_wpml) {
4115
+                                    if ($column == 'cat_language') {
4116
+                                        $cat_language = geodir_strtolower(trim($row[$c]));
4117
+                                    } else if ($column == 'cat_id_original') {
4118
+                                        $cat_id_original = (int) $row[$c];
4119 4119
                                     }
4120 4120
                                 }
4121 4121
                                 // WPML
4122 4122
                                 $c++;
4123 4123
                             }
4124 4124
                             
4125
-                            if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
4126
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
4125
+                            if ($cat_name == '' || !in_array($cat_posttype, $post_types)) {
4126
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be added due to blank title/invalid post type', 'geodirectory'));
4127 4127
                                 
4128 4128
                                 $invalid++;
4129 4129
                                 continue;
@@ -4141,24 +4141,24 @@  discard block
 block discarded – undo
4141 4141
                             $term_data['description'] = $cat_description;
4142 4142
                             $term_data['cat_schema'] = $cat_schema;
4143 4143
                             $term_data['top_description'] = $cat_top_description;
4144
-                            $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : '';
4145
-                            $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : '';
4144
+                            $term_data['image'] = $cat_image != '' ? basename($cat_image) : '';
4145
+                            $term_data['icon'] = $cat_icon != '' ? basename($cat_icon) : '';
4146 4146
                             
4147 4147
                             //$term_data = array_map( 'utf8_encode', $term_data );
4148 4148
                             
4149
-                            $taxonomy = $cat_posttype . 'category';
4149
+                            $taxonomy = $cat_posttype.'category';
4150 4150
                             
4151 4151
                             $term_data['taxonomy'] = $taxonomy;
4152 4152
 
4153 4153
                             $term_parent_id = 0;
4154
-                            if ($cat_parent != "" || (int)$cat_parent > 0) {
4154
+                            if ($cat_parent != "" || (int) $cat_parent > 0) {
4155 4155
                                 $term_parent = '';
4156 4156
                                 
4157
-                                if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
4157
+                                if ($term_parent = get_term_by('name', $cat_parent, $taxonomy)) {
4158 4158
                                     //
4159
-                                } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
4159
+                                } else if ($term_parent = get_term_by('slug', $cat_parent, $taxonomy)) {
4160 4160
                                     //
4161
-                                } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
4161
+                                } else if ($term_parent = get_term_by('id', $cat_parent, $taxonomy)) {
4162 4162
                                     //
4163 4163
                                 } else {
4164 4164
                                     $term_parent_data = array();
@@ -4166,104 +4166,104 @@  discard block
 block discarded – undo
4166 4166
                                     //$term_parent_data = array_map( 'utf8_encode', $term_parent_data );
4167 4167
                                     $term_parent_data['taxonomy'] = $taxonomy;
4168 4168
                                     
4169
-                                    $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data );
4169
+                                    $term_parent_id = (int) geodir_imex_insert_term($taxonomy, $term_parent_data);
4170 4170
                                 }
4171 4171
                                 
4172
-                                if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
4173
-                                    $term_parent_id = (int)$term_parent->term_id;
4172
+                                if (!empty($term_parent) && !is_wp_error($term_parent)) {
4173
+                                    $term_parent_id = (int) $term_parent->term_id;
4174 4174
                                 }
4175 4175
                             }
4176
-                            $term_data['parent'] = (int)$term_parent_id;
4176
+                            $term_data['parent'] = (int) $term_parent_id;
4177 4177
 
4178 4178
                             $term_id = NULL;
4179
-                            if ( $import_choice == 'update' ) {
4180
-                                if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
4179
+                            if ($import_choice == 'update') {
4180
+                                if ($cat_id > 0 && $term = (array) term_exists($cat_id, $taxonomy)) {
4181 4181
                                     $term_data['term_id'] = $term['term_id'];
4182 4182
                                     
4183
-                                    if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
4183
+                                    if ($term_id = geodir_imex_update_term($taxonomy, $term_data)) {
4184 4184
                                         $updated++;
4185 4185
                                     } else {
4186 4186
                                         $invalid++;
4187
-                                        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' ) );
4187
+                                        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'));
4188 4188
                                     }
4189
-                                } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4189
+                                } else if ($term_data['slug'] != '' && $term = (array) term_exists($term_data['slug'], $taxonomy)) {
4190 4190
                                     $term_data['term_id'] = $term['term_id'];
4191 4191
                                     
4192
-                                    if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
4192
+                                    if ($term_id = geodir_imex_update_term($taxonomy, $term_data)) {
4193 4193
                                         $updated++;
4194 4194
                                     } else {
4195 4195
                                         $invalid++;
4196
-                                        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' ) );
4196
+                                        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'));
4197 4197
                                     }
4198 4198
                                 } else {
4199
-                                    if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
4199
+                                    if ($term_id = geodir_imex_insert_term($taxonomy, $term_data)) {
4200 4200
                                         $created++;
4201 4201
                                     } else {
4202 4202
                                         $invalid++;
4203
-                                        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' ) );
4203
+                                        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'));
4204 4204
                                     }
4205 4205
                                 }
4206
-                            } else if ( $import_choice == 'skip' ) {
4207
-                                if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
4206
+                            } else if ($import_choice == 'skip') {
4207
+                                if ($cat_id > 0 && $term = (array) term_exists($cat_id, $taxonomy)) {
4208 4208
                                     $skipped++;
4209
-                                } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4209
+                                } else if ($term_data['slug'] != '' && $term = (array) term_exists($term_data['slug'], $taxonomy)) {
4210 4210
                                     $skipped++;
4211 4211
                                 } else {
4212
-                                    if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
4212
+                                    if ($term_id = geodir_imex_insert_term($taxonomy, $term_data)) {
4213 4213
                                         $created++;
4214 4214
                                     } else {
4215 4215
                                         $invalid++;
4216
-                                        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' ) );
4216
+                                        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'));
4217 4217
                                     }
4218 4218
                                 }
4219 4219
                             } else {
4220 4220
                                 $invalid++;
4221
-                                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' ) );
4221
+                                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'));
4222 4222
                             }
4223 4223
                             
4224
-                            if ( $term_id ) {
4224
+                            if ($term_id) {
4225 4225
                                 // WPML
4226 4226
                                 if ($is_wpml && $cat_id_original > 0 && $cat_language != '') {
4227
-                                    $wpml_element_type = 'tax_' . $taxonomy;
4228
-                                    $source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type );
4227
+                                    $wpml_element_type = 'tax_'.$taxonomy;
4228
+                                    $source_language = geodir_get_language_for_element($cat_id_original, $wpml_element_type);
4229 4229
                                     $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4230 4230
 
4231
-                                    $trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type );
4231
+                                    $trid = $sitepress->get_element_trid($cat_id_original, $wpml_element_type);
4232 4232
                                     
4233
-                                    $sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language );
4233
+                                    $sitepress->set_element_language_details($term_id, $wpml_element_type, $trid, $cat_language, $source_language);
4234 4234
                                 }
4235 4235
                                 // WPML
4236 4236
                                 
4237
-                                if ( isset( $term_data['top_description'] ) ) {
4238
-                                    update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype );
4237
+                                if (isset($term_data['top_description'])) {
4238
+                                    update_tax_meta($term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype);
4239 4239
                                 }
4240 4240
                                 
4241
-                                if ( isset( $term_data['cat_schema'] ) ) {
4242
-                                    update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype );
4241
+                                if (isset($term_data['cat_schema'])) {
4242
+                                    update_tax_meta($term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype);
4243 4243
                                 }
4244 4244
             
4245 4245
                                 $attachment = false;
4246
-                                if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
4247
-                                    $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype );
4248
-                                    $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : '';
4246
+                                if (isset($term_data['image']) && $term_data['image'] != '') {
4247
+                                    $cat_image = geodir_get_default_catimage($term_id, $cat_posttype);
4248
+                                    $cat_image = !empty($cat_image) && isset($cat_image['src']) ? $cat_image['src'] : '';
4249 4249
                                     
4250
-                                    if ( basename($cat_image) != $term_data['image'] ) {
4250
+                                    if (basename($cat_image) != $term_data['image']) {
4251 4251
                                         $attachment = true;
4252
-                                        update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype );
4252
+                                        update_tax_meta($term_id, 'ct_cat_default_img', array('id' => 'image', 'src' => $uploads['url'].'/'.$term_data['image']), $cat_posttype);
4253 4253
                                     }
4254 4254
                                 }
4255 4255
                                 
4256
-                                if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
4257
-                                    $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype );
4258
-                                    $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : '';
4256
+                                if (isset($term_data['icon']) && $term_data['icon'] != '') {
4257
+                                    $cat_icon = get_tax_meta($term_id, 'ct_cat_icon', false, $cat_posttype);
4258
+                                    $cat_icon = !empty($cat_icon) && isset($cat_icon['src']) ? $cat_icon['src'] : '';
4259 4259
                                         
4260
-                                    if ( basename($cat_icon) != $term_data['icon'] ) {
4260
+                                    if (basename($cat_icon) != $term_data['icon']) {
4261 4261
                                         $attachment = true;
4262
-                                        update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype );
4262
+                                        update_tax_meta($term_id, 'ct_cat_icon', array('id' => 'icon', 'src' => $uploads['url'].'/'.$term_data['icon']), $cat_posttype);
4263 4263
                                     }
4264 4264
                                 }
4265 4265
                                 
4266
-                                if ( $attachment ) {
4266
+                                if ($attachment) {
4267 4267
                                     $images++;
4268 4268
                                 }
4269 4269
                             }
@@ -4285,13 +4285,13 @@  discard block
 block discarded – undo
4285 4285
                 $json['invalid'] = $invalid;
4286 4286
                 $json['images'] = $images;
4287 4287
                 
4288
-                wp_send_json( $json );
4288
+                wp_send_json($json);
4289 4289
                 exit;
4290
-            } else if ( $task == 'import_post' ) {
4290
+            } else if ($task == 'import_post') {
4291 4291
                 //run some stuff to make the import quicker
4292
-                wp_defer_term_counting( true );
4293
-                wp_defer_comment_counting( true );
4294
-                $wpdb->query( 'SET autocommit = 0;' );
4292
+                wp_defer_term_counting(true);
4293
+                wp_defer_comment_counting(true);
4294
+                $wpdb->query('SET autocommit = 0;');
4295 4295
 
4296 4296
                 //remove_all_actions('publish_post');
4297 4297
                 //remove_all_actions('transition_post_status');
@@ -4300,18 +4300,18 @@  discard block
 block discarded – undo
4300 4300
                 if (!empty($file)) {
4301 4301
                     $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
4302 4302
                     $default_status = 'publish';
4303
-                    $current_date = date_i18n( 'Y-m-d', time() );
4303
+                    $current_date = date_i18n('Y-m-d', time());
4304 4304
                     
4305 4305
                     $columns = isset($file[0]) ? $file[0] : NULL;
4306 4306
                     
4307 4307
                     if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4308 4308
                         $json['error'] = CSV_INVAILD_FILE;
4309
-                        wp_send_json( $json );
4309
+                        wp_send_json($json);
4310 4310
                         exit;
4311 4311
                     }
4312 4312
 
4313 4313
                     $gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory');
4314
-                    $wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' );
4314
+                    $wp_chars_error = __('(check & remove if any invalid characters used in data)', 'geodirectory');
4315 4315
                     $processed_actual = 0;
4316 4316
                     for ($i = 1; $i <= $limit; $i++) {
4317 4317
                         $index = $processed + $i;
@@ -4320,9 +4320,9 @@  discard block
 block discarded – undo
4320 4320
                         if (isset($file[$index])) {
4321 4321
                             $processed_actual++;
4322 4322
                             $row = $file[$index];
4323
-                            $row = array_map( 'trim', $row );
4323
+                            $row = array_map('trim', $row);
4324 4324
                             //$row = array_map( 'utf8_encode', $row );
4325
-                            $row = array_map( 'addslashes_gpc', $row );
4325
+                            $row = array_map('addslashes_gpc', $row);
4326 4326
                             
4327 4327
                             $post_id = '';
4328 4328
                             $post_title = '';
@@ -4359,78 +4359,78 @@  discard block
 block discarded – undo
4359 4359
                             $original_post_id = '';
4360 4360
                                                         
4361 4361
                             $c = 0;
4362
-                            foreach ($columns as $column ) {
4362
+                            foreach ($columns as $column) {
4363 4363
                                 $gd_post[$column] = $row[$c];
4364 4364
                                 
4365
-                                if ( $column == 'post_id' ) {
4365
+                                if ($column == 'post_id') {
4366 4366
                                     $post_id = $row[$c];
4367
-                                } else if ( $column == 'post_title' ) {
4367
+                                } else if ($column == 'post_title') {
4368 4368
                                     $post_title = sanitize_text_field($row[$c]);
4369
-                                } else if ( $column == 'post_author' ) {
4369
+                                } else if ($column == 'post_author') {
4370 4370
                                     $post_author = $row[$c];
4371
-                                } else if ( $column == 'post_content' ) {
4371
+                                } else if ($column == 'post_content') {
4372 4372
                                     $post_content = $row[$c];
4373
-                                } else if ( $column == 'post_category' && $row[$c] != '' ) {
4374
-                                    $post_category_arr = explode( ',', $row[$c] );
4375
-                                } else if ( $column == 'default_category' ) {
4373
+                                } else if ($column == 'post_category' && $row[$c] != '') {
4374
+                                    $post_category_arr = explode(',', $row[$c]);
4375
+                                } else if ($column == 'default_category') {
4376 4376
                                     $default_category = wp_kses_normalize_entities($row[$c]);
4377
-                                } else if ( $column == 'post_tags' && $row[$c] != '' ) {
4378
-                                    $post_tags = explode( ',', sanitize_text_field($row[$c]) );
4379
-                                } else if ( $column == 'post_type' ) {
4377
+                                } else if ($column == 'post_tags' && $row[$c] != '') {
4378
+                                    $post_tags = explode(',', sanitize_text_field($row[$c]));
4379
+                                } else if ($column == 'post_type') {
4380 4380
                                     $post_type = $row[$c];
4381
-                                } else if ( $column == 'post_status' ) {
4382
-                                    $post_status = sanitize_key( $row[$c] );
4383
-                                } else if ( $column == 'is_featured' ) {
4384
-                                    $is_featured = (int)$row[$c];
4385
-                                } else if ( $column == 'geodir_video' ) {
4381
+                                } else if ($column == 'post_status') {
4382
+                                    $post_status = sanitize_key($row[$c]);
4383
+                                } else if ($column == 'is_featured') {
4384
+                                    $is_featured = (int) $row[$c];
4385
+                                } else if ($column == 'geodir_video') {
4386 4386
                                     $geodir_video = $row[$c];
4387
-                                } else if ( $column == 'post_address' ) {
4387
+                                } else if ($column == 'post_address') {
4388 4388
                                     $post_address = sanitize_text_field($row[$c]);
4389
-                                } else if ( $column == 'post_city' ) {
4389
+                                } else if ($column == 'post_city') {
4390 4390
                                     $post_city = sanitize_text_field($row[$c]);
4391
-                                } else if ( $column == 'post_region' ) {
4391
+                                } else if ($column == 'post_region') {
4392 4392
                                     $post_region = sanitize_text_field($row[$c]);
4393
-                                } else if ( $column == 'post_country' ) {
4393
+                                } else if ($column == 'post_country') {
4394 4394
                                     $post_country = sanitize_text_field($row[$c]);
4395
-                                } else if ( $column == 'post_zip' ) {
4395
+                                } else if ($column == 'post_zip') {
4396 4396
                                     $post_zip = sanitize_text_field($row[$c]);
4397
-                                } else if ( $column == 'post_latitude' ) {
4397
+                                } else if ($column == 'post_latitude') {
4398 4398
                                     $post_latitude = sanitize_text_field($row[$c]);
4399
-                                } else if ( $column == 'post_longitude' ) {
4399
+                                } else if ($column == 'post_longitude') {
4400 4400
                                     $post_longitude = sanitize_text_field($row[$c]);
4401
-                                } else if ( $column == 'post_neighbourhood' ) {
4401
+                                } else if ($column == 'post_neighbourhood') {
4402 4402
                                     $post_neighbourhood = sanitize_text_field($row[$c]);
4403 4403
                                     unset($gd_post[$column]);
4404
-                                } else if ( $column == 'neighbourhood_latitude' ) {
4404
+                                } else if ($column == 'neighbourhood_latitude') {
4405 4405
                                     $neighbourhood_latitude = sanitize_text_field($row[$c]);
4406
-                                } else if ( $column == 'neighbourhood_longitude' ) {
4406
+                                } else if ($column == 'neighbourhood_longitude') {
4407 4407
                                     $neighbourhood_longitude = sanitize_text_field($row[$c]);
4408
-                                } else if ( $column == 'geodir_timing' ) {
4408
+                                } else if ($column == 'geodir_timing') {
4409 4409
                                     $geodir_timing = sanitize_text_field($row[$c]);
4410
-                                } else if ( $column == 'geodir_contact' ) {
4410
+                                } else if ($column == 'geodir_contact') {
4411 4411
                                     $geodir_contact = sanitize_text_field($row[$c]);
4412
-                                } else if ( $column == 'geodir_email' ) {
4412
+                                } else if ($column == 'geodir_email') {
4413 4413
                                     $geodir_email = sanitize_email($row[$c]);
4414
-                                } else if ( $column == 'geodir_website' ) {
4414
+                                } else if ($column == 'geodir_website') {
4415 4415
                                     $geodir_website = sanitize_text_field($row[$c]);
4416
-                                } else if ( $column == 'geodir_twitter' ) {
4416
+                                } else if ($column == 'geodir_twitter') {
4417 4417
                                     $geodir_twitter = sanitize_text_field($row[$c]);
4418
-                                } else if ( $column == 'geodir_facebook' ) {
4418
+                                } else if ($column == 'geodir_facebook') {
4419 4419
                                     $geodir_facebook = sanitize_text_field($row[$c]);
4420
-                                } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
4420
+                                } else if ($column == 'IMAGE' && !empty($row[$c]) && $row[$c] != '') {
4421 4421
                                     $post_images[] = $row[$c];
4422
-                                } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
4423
-                                    $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) );
4424
-                                } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
4422
+                                } else if ($column == 'alive_days' && (int) $row[$c] > 0) {
4423
+                                    $expire_date = date_i18n('Y-m-d', strtotime($current_date.'+'.(int) $row[$c].' days'));
4424
+                                } else if ($column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never') {
4425 4425
                                     $row[$c] = str_replace('/', '-', $row[$c]);
4426
-                                    $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) );
4426
+                                    $expire_date = date_i18n('Y-m-d', strtotime($row[$c]));
4427 4427
                                 }
4428 4428
                                 // WPML
4429 4429
                                 if ($is_wpml) {
4430 4430
                                     if ($column == 'language') {
4431 4431
                                         $language = geodir_strtolower(trim($row[$c]));
4432 4432
                                     } else if ($column == 'original_post_id') {
4433
-                                        $original_post_id = (int)$row[$c];
4433
+                                        $original_post_id = (int) $row[$c];
4434 4434
                                     }
4435 4435
                                 }
4436 4436
                                 // WPML
@@ -4445,43 +4445,43 @@  discard block
 block discarded – undo
4445 4445
 
4446 4446
                             $gd_post['IMAGE'] = $post_images;
4447 4447
                             
4448
-                            $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
4449
-                            $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
4448
+                            $post_status = !empty($post_status) ? sanitize_key($post_status) : $default_status;
4449
+                            $post_status = !empty($wp_post_statuses) && !isset($wp_post_statuses[$post_status]) ? $default_status : $post_status;
4450 4450
                                                                                                                 
4451 4451
                             $valid = true;
4452 4452
                             
4453
-                            if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
4453
+                            if ($post_title == '' || !in_array($post_type, $post_types)) {
4454 4454
                                 $invalid++;
4455 4455
                                 $valid = false;
4456
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
4456
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be added due to blank title/invalid post type', 'geodirectory'));
4457 4457
                             }
4458 4458
                             
4459
-                            $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
4460
-                            if ( $location_allowed ) {
4459
+                            $location_allowed = function_exists('geodir_cpt_no_location') && geodir_cpt_no_location($post_type) ? false : true;
4460
+                            if ($location_allowed) {
4461 4461
                                 $location_result = geodir_get_default_location();
4462
-                                if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
4462
+                                if ($post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '') {
4463 4463
                                     $invalid_addr++;
4464 4464
                                     $valid = false;
4465
-                                    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' ) );
4466
-                                } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
4467
-                                    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 ) ) ) {
4465
+                                    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'));
4466
+                                } else if (!empty($location_result) && $location_result->location_id == 0) {
4467
+                                    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))) {
4468 4468
                                         $invalid_addr++;
4469 4469
                                         $valid = false;
4470
-                                        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' ) );
4470
+                                        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'));
4471 4471
                                     } else {
4472 4472
                                         if (!$location_manager) {
4473
-                                            $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.
4473
+                                            $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.
4474 4474
                                         }
4475 4475
                                     }
4476 4476
                                 }
4477 4477
                             }
4478 4478
                             
4479
-                            if ( !$valid ) {
4479
+                            if (!$valid) {
4480 4480
                                 continue;
4481 4481
                             }
4482 4482
 
4483
-                            $cat_taxonomy = $post_type . 'category';
4484
-                            $tags_taxonomy = $post_type . '_tags';
4483
+                            $cat_taxonomy = $post_type.'category';
4484
+                            $tags_taxonomy = $post_type.'_tags';
4485 4485
                             
4486 4486
                             if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
4487 4487
                                 $post_category_arr = array_merge(array($default_category), $post_category_arr);
@@ -4489,29 +4489,29 @@  discard block
 block discarded – undo
4489 4489
 
4490 4490
                             $post_category = array();
4491 4491
                             $default_category_id = NULL;
4492
-                            if ( !empty( $post_category_arr ) ) {
4493
-                                foreach ( $post_category_arr as $value ) {
4494
-                                    $category_name = wp_kses_normalize_entities( trim( $value ) );
4492
+                            if (!empty($post_category_arr)) {
4493
+                                foreach ($post_category_arr as $value) {
4494
+                                    $category_name = wp_kses_normalize_entities(trim($value));
4495 4495
                                     
4496
-                                    if ( $category_name != '' ) {
4496
+                                    if ($category_name != '') {
4497 4497
                                         $term_category = array();
4498 4498
                                         
4499
-                                        if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
4499
+                                        if ($term = get_term_by('name', $category_name, $cat_taxonomy)) {
4500 4500
                                             $term_category = $term;
4501
-                                        } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
4501
+                                        } else if ($term = get_term_by('slug', $category_name, $cat_taxonomy)) {
4502 4502
                                             $term_category = $term;
4503 4503
                                         } else {
4504 4504
                                             $term_data = array();
4505 4505
                                             $term_data['name'] = $category_name;
4506 4506
                                             $term_data['taxonomy'] = $cat_taxonomy;
4507 4507
                                             
4508
-                                            $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data );
4509
-                                            if ( $term_id ) {
4510
-                                                $term_category = get_term( $term_id, $cat_taxonomy );
4508
+                                            $term_id = geodir_imex_insert_term($cat_taxonomy, $term_data);
4509
+                                            if ($term_id) {
4510
+                                                $term_category = get_term($term_id, $cat_taxonomy);
4511 4511
                                             }
4512 4512
                                         }
4513 4513
                                         
4514
-                                        if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
4514
+                                        if (!empty($term_category) && !is_wp_error($term_category)) {
4515 4515
                                             $post_category[] = intval($term_category->term_id);
4516 4516
                                             
4517 4517
                                             if ($category_name == $default_category) {
@@ -4532,15 +4532,15 @@  discard block
 block discarded – undo
4532 4532
                             $save_post['post_tags'] = $post_tags;
4533 4533
 
4534 4534
                             $saved_post_id = NULL;
4535
-                            if ( $import_choice == 'update' ) {
4536
-                                $gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' );
4535
+                            if ($import_choice == 'update') {
4536
+                                $gd_wp_error = __('Unable to add listing, please check the listing data.', 'geodirectory');
4537 4537
                                 
4538
-                                if ( $post_id > 0 && get_post( $post_id ) ) {
4538
+                                if ($post_id > 0 && get_post($post_id)) {
4539 4539
                                     $save_post['ID'] = $post_id;
4540 4540
                                     
4541
-                                    if ( $saved_post_id = wp_update_post( $save_post, true ) ) {
4542
-                                        if ( is_wp_error( $saved_post_id ) ) {
4543
-                                            $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4541
+                                    if ($saved_post_id = wp_update_post($save_post, true)) {
4542
+                                        if (is_wp_error($saved_post_id)) {
4543
+                                            $gd_wp_error = $saved_post_id->get_error_message().' '.$wp_chars_error;
4544 4544
                                             $saved_post_id = 0;
4545 4545
                                         } else {
4546 4546
                                             $saved_post_id = $post_id;
@@ -4548,9 +4548,9 @@  discard block
 block discarded – undo
4548 4548
                                         }
4549 4549
                                     }
4550 4550
                                 } else {
4551
-                                    if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4552
-                                        if ( is_wp_error( $saved_post_id ) ) {
4553
-                                            $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4551
+                                    if ($saved_post_id = wp_insert_post($save_post, true)) {
4552
+                                        if (is_wp_error($saved_post_id)) {
4553
+                                            $gd_wp_error = $saved_post_id->get_error_message().' '.$wp_chars_error;
4554 4554
                                             $saved_post_id = 0;
4555 4555
                                         } else {
4556 4556
                                             $created++;
@@ -4558,19 +4558,19 @@  discard block
 block discarded – undo
4558 4558
                                     }
4559 4559
                                 }
4560 4560
                                 
4561
-                                if ( !$saved_post_id > 0 ) {
4561
+                                if (!$saved_post_id > 0) {
4562 4562
                                     $invalid++;
4563
-                                    geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error );
4563
+                                    geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_wp_error);
4564 4564
                                 }
4565
-                            } else if ( $import_choice == 'skip' ) {
4566
-                                if ( $post_id > 0 && get_post( $post_id ) ) {
4565
+                            } else if ($import_choice == 'skip') {
4566
+                                if ($post_id > 0 && get_post($post_id)) {
4567 4567
                                     $skipped++;	
4568 4568
                                 } else {
4569
-                                    if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4570
-                                        if ( is_wp_error( $saved_post_id ) ) {
4569
+                                    if ($saved_post_id = wp_insert_post($save_post, true)) {
4570
+                                        if (is_wp_error($saved_post_id)) {
4571 4571
                                             $invalid++;
4572 4572
                                             
4573
-                                            geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error );
4573
+                                            geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$saved_post_id->get_error_message().' '.$wp_chars_error);
4574 4574
                                             $saved_post_id = 0;
4575 4575
                                         } else {
4576 4576
                                             $created++;
@@ -4578,28 +4578,28 @@  discard block
 block discarded – undo
4578 4578
                                     } else {
4579 4579
                                         $invalid++;
4580 4580
                                         
4581
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4581
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$wp_chars_error);
4582 4582
                                     }
4583 4583
                                 }
4584 4584
                             } else {
4585 4585
                                 $invalid++;
4586 4586
                                 
4587
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4587
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$wp_chars_error);
4588 4588
                             }
4589 4589
 
4590
-                            if ( (int)$saved_post_id > 0 ) {
4590
+                            if ((int) $saved_post_id > 0) {
4591 4591
                                 // WPML
4592 4592
                                 if ($is_wpml && $original_post_id > 0 && $language != '') {
4593
-                                    $wpml_post_type = 'post_' . $post_type;
4594
-                                    $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type );
4593
+                                    $wpml_post_type = 'post_'.$post_type;
4594
+                                    $source_language = geodir_get_language_for_element($original_post_id, $wpml_post_type);
4595 4595
                                     $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4596 4596
 
4597
-                                    $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type );
4597
+                                    $trid = $sitepress->get_element_trid($original_post_id, $wpml_post_type);
4598 4598
                                     
4599
-                                    $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language );
4599
+                                    $sitepress->set_element_language_details($saved_post_id, $wpml_post_type, $trid, $language, $source_language);
4600 4600
                                 }
4601 4601
                                 // WPML
4602
-                                $gd_post_info = geodir_get_post_info( $saved_post_id );
4602
+                                $gd_post_info = geodir_get_post_info($saved_post_id);
4603 4603
                                 
4604 4604
                                 $gd_post['post_id'] = $saved_post_id;
4605 4605
                                 $gd_post['ID'] = $saved_post_id;
@@ -4611,7 +4611,7 @@  discard block
 block discarded – undo
4611 4611
                                                     
4612 4612
                                 // post location
4613 4613
                                 $post_location_id = 0;
4614
-                                if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
4614
+                                if ($location_allowed && !empty($location_result) && $location_result->location_id > 0) {
4615 4615
                                     $gd_post['post_neighbourhood'] = '';
4616 4616
                                     
4617 4617
                                     $post_location_info = array(
@@ -4621,7 +4621,7 @@  discard block
 block discarded – undo
4621 4621
                                                                 'geo_lat' => $post_latitude,
4622 4622
                                                                 'geo_lng' => $post_longitude
4623 4623
                                                             );
4624
-                                    if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
4624
+                                    if ($location_id = (int) geodir_add_new_location($post_location_info)) {
4625 4625
                                         $post_location_id = $location_id;
4626 4626
                                     }
4627 4627
                                     
@@ -4659,14 +4659,14 @@  discard block
 block discarded – undo
4659 4659
                                 $gd_post['post_location_id'] = $post_location_id;
4660 4660
                                 
4661 4661
                                 // post package info
4662
-                                $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0;
4662
+                                $package_id = isset($gd_post['package_id']) && !empty($gd_post['package_id']) ? (int) $gd_post['package_id'] : 0;
4663 4663
                                 if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
4664 4664
                                     $package_id = $gd_post_info->package_id;
4665 4665
                                 }
4666 4666
                                 
4667 4667
                                 $package_info = array();
4668 4668
                                 if ($package_id && function_exists('geodir_get_package_info_by_id')) {
4669
-                                    $package_info = (array)geodir_get_package_info_by_id($package_id);
4669
+                                    $package_info = (array) geodir_get_package_info_by_id($package_id);
4670 4670
                                     
4671 4671
                                     if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
4672 4672
                                         $package_info = array();
@@ -4674,18 +4674,18 @@  discard block
 block discarded – undo
4674 4674
                                 }
4675 4675
                                 
4676 4676
                                 if (empty($package_info)) {
4677
-                                    $package_info = (array)geodir_post_package_info( array(), '', $post_type );
4677
+                                    $package_info = (array) geodir_post_package_info(array(), '', $post_type);
4678 4678
                                 }
4679 4679
                                  
4680
-                                if (!empty($package_info))	 {
4680
+                                if (!empty($package_info)) {
4681 4681
                                     $package_id = $package_info['pid'];
4682 4682
                                     
4683 4683
                                     if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
4684 4684
                                         $gd_post['expire_date'] = $expire_date;
4685 4685
                                     } else {
4686
-                                        if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
4687
-                                            $gd_post['alive_days'] = (int)$package_info['days'];
4688
-                                            $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) );
4686
+                                        if (isset($package_info['days']) && (int) $package_info['days'] > 0) {
4687
+                                            $gd_post['alive_days'] = (int) $package_info['days'];
4688
+                                            $gd_post['expire_date'] = date_i18n('Y-m-d', strtotime($current_date.'+'.(int) $package_info['days'].' days'));
4689 4689
                                         } else {
4690 4690
                                             $gd_post['expire_date'] = 'Never';
4691 4691
                                         }
@@ -4694,7 +4694,7 @@  discard block
 block discarded – undo
4694 4694
                                     $gd_post['package_id'] = $package_id;
4695 4695
                                 }
4696 4696
 
4697
-                                $table = $plugin_prefix . $post_type . '_detail';
4697
+                                $table = $plugin_prefix.$post_type.'_detail';
4698 4698
                                 
4699 4699
                                 if ($post_type == 'gd_event') {
4700 4700
                                     $gd_post = geodir_imex_process_event_data($gd_post);
@@ -4705,28 +4705,28 @@  discard block
 block discarded – undo
4705 4705
                                 }
4706 4706
 
4707 4707
                                 // Export franchise fields
4708
-                                $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false;
4708
+                                $is_franchise_active = is_plugin_active('geodir_franchise/geodir_franchise.php') && geodir_franchise_enabled($post_type) ? true : false;
4709 4709
                                 if ($is_franchise_active) {
4710
-                                    if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
4710
+                                    if (isset($gd_post['gd_is_franchise']) && (int) $gd_post['gd_is_franchise'] == 1) {
4711 4711
                                         $gd_franchise_lock = array();
4712 4712
                                         
4713
-                                        if ( isset( $gd_post['gd_franchise_lock'] ) ) {
4714
-                                            $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
4715
-                                            $gd_franchise_lock = trim( $gd_franchise_lock );
4716
-                                            $gd_franchise_lock = explode( ",", $gd_franchise_lock );
4713
+                                        if (isset($gd_post['gd_franchise_lock'])) {
4714
+                                            $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock']);
4715
+                                            $gd_franchise_lock = trim($gd_franchise_lock);
4716
+                                            $gd_franchise_lock = explode(",", $gd_franchise_lock);
4717 4717
                                         }
4718 4718
                                         
4719
-                                        update_post_meta( $saved_post_id, 'gd_is_franchise', 1 );
4720
-                                        update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock );
4719
+                                        update_post_meta($saved_post_id, 'gd_is_franchise', 1);
4720
+                                        update_post_meta($saved_post_id, 'gd_franchise_lock', $gd_franchise_lock);
4721 4721
                                     } else {
4722
-                                        if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
4723
-                                            geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] );
4722
+                                        if (isset($gd_post['franchise']) && (int) $gd_post['franchise'] > 0 && geodir_franchise_check((int) $gd_post['franchise'])) {
4723
+                                            geodir_save_post_meta($saved_post_id, 'franchise', (int) $gd_post['franchise']);
4724 4724
                                         }
4725 4725
                                     }
4726 4726
                                 }
4727 4727
                                 
4728 4728
                                 if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
4729
-                                    $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) );
4729
+                                    $save_post['post_category'] = array_unique(array_map('intval', $save_post['post_category']));
4730 4730
                                     if ($default_category_id) {
4731 4731
                                         $save_post['post_default_category'] = $default_category_id;
4732 4732
                                         $gd_post['default_category'] = $default_category_id;
@@ -4735,34 +4735,34 @@  discard block
 block discarded – undo
4735 4735
                                 }
4736 4736
                                 
4737 4737
                                 // Save post info
4738
-                                geodir_save_post_info( $saved_post_id, $gd_post );
4738
+                                geodir_save_post_info($saved_post_id, $gd_post);
4739 4739
                                 // post taxonomies
4740
-                                if ( !empty( $save_post['post_category'] ) ) {
4741
-                                    wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy );
4740
+                                if (!empty($save_post['post_category'])) {
4741
+                                    wp_set_object_terms($saved_post_id, $save_post['post_category'], $cat_taxonomy);
4742 4742
                                     
4743
-                                    $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : '';
4743
+                                    $post_default_category = isset($save_post['post_default_category']) ? $save_post['post_default_category'] : '';
4744 4744
                                     if ($default_category_id) {
4745 4745
                                         $post_default_category = $default_category_id;
4746 4746
                                     }
4747 4747
                                     $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy);
4748 4748
                                     $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
4749
-                                    $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
4749
+                                    $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']).',y:' : '';
4750 4750
                                     
4751 4751
                                     if ($post_category_str != '' && $post_default_category) {
4752
-                                        $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str);
4752
+                                        $post_category_str = str_replace($post_default_category.',y:', $post_default_category.',y,d:', $post_category_str);
4753 4753
                                     }
4754 4754
                                     
4755 4755
                                     $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : '';
4756 4756
                                     
4757
-                                    geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str );
4757
+                                    geodir_set_postcat_structure($saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str);
4758 4758
                                 }
4759 4759
 
4760
-                                if ( !empty( $save_post['post_tags'] ) ) {
4761
-                                    wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy );
4760
+                                if (!empty($save_post['post_tags'])) {
4761
+                                    wp_set_object_terms($saved_post_id, $save_post['post_tags'], $tags_taxonomy);
4762 4762
                                 }
4763 4763
 
4764 4764
                                 // Post images
4765
-                                if ( !empty( $post_images ) ) {
4765
+                                if (!empty($post_images)) {
4766 4766
                                     $post_images = array_unique($post_images);
4767 4767
                                     
4768 4768
                                     $old_post_images_arr = array();
@@ -4770,61 +4770,61 @@  discard block
 block discarded – undo
4770 4770
                                     
4771 4771
                                     $order = 1;
4772 4772
                                     
4773
-                                    $old_post_images = geodir_get_images( $saved_post_id );
4773
+                                    $old_post_images = geodir_get_images($saved_post_id);
4774 4774
                                     if (!empty($old_post_images)) {
4775
-                                        foreach( $old_post_images as $old_post_image ) {
4775
+                                        foreach ($old_post_images as $old_post_image) {
4776 4776
                                             if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
4777 4777
                                                 $old_post_images_arr[] = $old_post_image->file;
4778 4778
                                             }
4779 4779
                                         }
4780 4780
                                     }
4781 4781
 
4782
-                                    foreach ( $post_images as $post_image ) {
4783
-                                        $image_name = basename( $post_image );
4782
+                                    foreach ($post_images as $post_image) {
4783
+                                        $image_name = basename($post_image);
4784 4784
                                         $saved_post_images_arr[] = $image_name;
4785 4785
                                         
4786
-                                        if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
4786
+                                        if (!empty($old_post_images_arr) && in_array($image_name, $old_post_images_arr)) {
4787 4787
                                             continue; // Skip if image already exists.
4788 4788
                                         }
4789 4789
                                         
4790
-                                        $image_name_parts = explode( '.', $image_name );
4791
-                                        array_pop( $image_name_parts );
4792
-                                        $proper_image_name = implode( '.', $image_name_parts );
4790
+                                        $image_name_parts = explode('.', $image_name);
4791
+                                        array_pop($image_name_parts);
4792
+                                        $proper_image_name = implode('.', $image_name_parts);
4793 4793
                                         
4794
-                                        $arr_file_type = wp_check_filetype( $image_name );
4794
+                                        $arr_file_type = wp_check_filetype($image_name);
4795 4795
                                         
4796
-                                        if ( !empty( $arr_file_type ) ) {
4796
+                                        if (!empty($arr_file_type)) {
4797 4797
                                             $uploaded_file_type = $arr_file_type['type'];
4798 4798
                                             
4799 4799
                                             $attachment = array();
4800 4800
                                             $attachment['post_id'] = $saved_post_id;
4801 4801
                                             $attachment['title'] = $proper_image_name;
4802 4802
                                             $attachment['content'] = '';
4803
-                                            $attachment['file'] = $uploads_subdir . '/' . $image_name;
4803
+                                            $attachment['file'] = $uploads_subdir.'/'.$image_name;
4804 4804
                                             $attachment['mime_type'] = $uploaded_file_type;
4805 4805
                                             $attachment['menu_order'] = $order;
4806 4806
                                             $attachment['is_featured'] = 0;
4807 4807
 
4808 4808
                                             $attachment_set = '';
4809
-                                            foreach ( $attachment as $key => $val ) {
4810
-                                                if ( $val != '' ) {
4811
-                                                    $attachment_set .= $key . " = '" . $val . "', ";
4809
+                                            foreach ($attachment as $key => $val) {
4810
+                                                if ($val != '') {
4811
+                                                    $attachment_set .= $key." = '".$val."', ";
4812 4812
                                                 }
4813 4813
                                             }
4814
-                                            $attachment_set = trim( $attachment_set, ", " );
4814
+                                            $attachment_set = trim($attachment_set, ", ");
4815 4815
                                                                                         
4816 4816
                                             // Add new attachment
4817
-                                            $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set );
4817
+                                            $wpdb->query("INSERT INTO ".GEODIR_ATTACHMENT_TABLE." SET ".$attachment_set);
4818 4818
                                                                                         
4819 4819
                                             $order++;
4820 4820
                                         }
4821 4821
                                     }
4822 4822
 
4823
-                                    $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/",  $saved_post_images_arr) . "' )" : '';
4823
+                                    $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/".implode("' AND file NOT LIKE '%/", $saved_post_images_arr)."' )" : '';
4824 4824
                                     // Remove previous attachment
4825
-                                    $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql );
4825
+                                    $wpdb->query("DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE post_id = ".(int) $saved_post_id." ".$saved_post_images_sql);
4826 4826
                                     
4827
-                                    if ( !empty( $saved_post_images_arr ) ) {
4827
+                                    if (!empty($saved_post_images_arr)) {
4828 4828
                                         geodir_set_wp_featured_image($saved_post_id);
4829 4829
                                         /*
4830 4830
                                         $menu_order = 1;
@@ -4841,13 +4841,13 @@  discard block
 block discarded – undo
4841 4841
                                         }*/
4842 4842
                                     }
4843 4843
                                     
4844
-                                    if ( $order > 1 ) {
4844
+                                    if ($order > 1) {
4845 4845
                                         $images++;
4846 4846
                                     }
4847 4847
                                 }
4848 4848
 
4849 4849
                                 /** This action is documented in geodirectory-functions/post-functions.php */
4850
-                                do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post );
4850
+                                do_action('geodir_after_save_listing', $saved_post_id, $gd_post);
4851 4851
                                 
4852 4852
                                 if (isset($is_featured)) {
4853 4853
                                     geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured);
@@ -4867,10 +4867,10 @@  discard block
 block discarded – undo
4867 4867
                 }
4868 4868
 
4869 4869
                 //undo some stuff to make the import quicker
4870
-                wp_defer_term_counting( false );
4871
-                wp_defer_comment_counting( false );
4872
-                $wpdb->query( 'COMMIT;' );
4873
-                $wpdb->query( 'SET autocommit = 1;' );
4870
+                wp_defer_term_counting(false);
4871
+                wp_defer_comment_counting(false);
4872
+                $wpdb->query('COMMIT;');
4873
+                $wpdb->query('SET autocommit = 1;');
4874 4874
 
4875 4875
                 $json = array();
4876 4876
                 $json['processed'] = $processed_actual;
@@ -4881,9 +4881,9 @@  discard block
 block discarded – undo
4881 4881
                 $json['invalid_addr'] = $invalid_addr;
4882 4882
                 $json['images'] = $images;
4883 4883
                 
4884
-                wp_send_json( $json );
4884
+                wp_send_json($json);
4885 4885
                 exit;
4886
-            } else if ( $task == 'import_loc' ) {
4886
+            } else if ($task == 'import_loc') {
4887 4887
                 global $gd_post_types;
4888 4888
                 $gd_post_types = $post_types;
4889 4889
                 
@@ -4892,82 +4892,82 @@  discard block
 block discarded – undo
4892 4892
                     
4893 4893
                     if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4894 4894
                         $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4895
-                        wp_send_json( $json );
4895
+                        wp_send_json($json);
4896 4896
                     }
4897 4897
                     
4898 4898
                     $gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory');
4899
-                    $gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' );
4899
+                    $gd_error_location = __('Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory');
4900 4900
                     for ($i = 1; $i <= $limit; $i++) {
4901 4901
                         $index = $processed + $i;
4902 4902
                         
4903 4903
                         if (isset($file[$index])) {
4904 4904
                             $row = $file[$index];
4905
-                            $row = array_map( 'trim', $row );
4905
+                            $row = array_map('trim', $row);
4906 4906
                             $data = array();
4907 4907
                             
4908
-                            foreach ($columns as $c => $column ) {
4908
+                            foreach ($columns as $c => $column) {
4909 4909
                                 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'))) {
4910 4910
                                     $data[$column] = $row[$c];
4911 4911
                                 }
4912 4912
                             }
4913 4913
 
4914
-                            if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
4914
+                            if (empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude'])) {
4915 4915
                                 $invalid++;
4916
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4916
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location);
4917 4917
                                 continue;
4918 4918
                             }
4919 4919
                             
4920 4920
                             $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0;
4921 4921
                             
4922
-                            if ( $import_choice == 'update' ) {
4923
-                                if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4924
-                                    if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4922
+                            if ($import_choice == 'update') {
4923
+                                if ((int) $data['location_id'] > 0 && $location = geodir_get_location_by_id('', (int) $data['location_id'])) {
4924
+                                    if ($location_id = geodir_location_update_city($data, true, $location)) {
4925 4925
                                         $updated++;
4926 4926
                                     } else {
4927 4927
                                         $invalid++;
4928
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4928
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location);
4929 4929
                                     }
4930
-                                } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4931
-                                    $data['location_id'] = (int)$location->location_id;
4930
+                                } else if (!empty($data['city_slug']) && $location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug']))) {
4931
+                                    $data['location_id'] = (int) $location->location_id;
4932 4932
                                     
4933
-                                    if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
4934
-                                        $data['location_id'] = (int)$location->location_id;
4935
-                                    } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
4936
-                                        $data['location_id'] = (int)$location->location_id;
4937
-                                    } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
4938
-                                        $data['location_id'] = (int)$location->location_id;
4933
+                                    if ($location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region']))) {
4934
+                                        $data['location_id'] = (int) $location->location_id;
4935
+                                    } else if ($location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug'], 'region' => $data['region']))) {
4936
+                                        $data['location_id'] = (int) $location->location_id;
4937
+                                    } else if ($location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug'], 'country' => $data['country']))) {
4938
+                                        $data['location_id'] = (int) $location->location_id;
4939 4939
                                     }
4940 4940
                                     
4941
-                                    if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4941
+                                    if ($location_id = geodir_location_update_city($data, true, $location)) {
4942 4942
                                         $updated++;
4943 4943
                                     } else {
4944 4944
                                         $invalid++;
4945
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4945
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location);
4946 4946
                                     }
4947 4947
                                 } else {
4948
-                                    if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4948
+                                    if ($location_id = geodir_location_insert_city($data, true)) {
4949 4949
                                         $created++;
4950 4950
                                     } else {
4951 4951
                                         $invalid++;
4952
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4952
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location);
4953 4953
                                     }
4954 4954
                                 }
4955
-                            } elseif ( $import_choice == 'skip' ) {
4956
-                                if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4955
+                            } elseif ($import_choice == 'skip') {
4956
+                                if ((int) $data['location_id'] > 0 && $location = geodir_get_location_by_id('', (int) $data['location_id'])) {
4957 4957
                                     $skipped++;
4958
-                                } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4958
+                                } else if (!empty($data['city_slug']) && $location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug']))) {
4959 4959
                                     $skipped++;
4960 4960
                                 } else {
4961
-                                    if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4961
+                                    if ($location_id = geodir_location_insert_city($data, true)) {
4962 4962
                                         $created++;
4963 4963
                                     } else {
4964 4964
                                         $invalid++;
4965
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4965
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location);
4966 4966
                                     }
4967 4967
                                 }
4968 4968
                             } else {
4969 4969
                                 $invalid++;
4970
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4970
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location);
4971 4971
                             }
4972 4972
                         }
4973 4973
                     }
@@ -4981,24 +4981,24 @@  discard block
 block discarded – undo
4981 4981
                 $json['invalid'] = $invalid;
4982 4982
                 $json['images'] = $images;
4983 4983
                 
4984
-                wp_send_json( $json );
4985
-            } else if ( $task == 'import_hood' ) {               
4984
+                wp_send_json($json);
4985
+            } else if ($task == 'import_hood') {               
4986 4986
                 if (!empty($file)) {
4987 4987
                     $columns = isset($file[0]) ? $file[0] : NULL;
4988 4988
                     
4989 4989
                     if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4990 4990
                         $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4991
-                        wp_send_json( $json );
4991
+                        wp_send_json($json);
4992 4992
                     }
4993 4993
                     
4994 4994
                     $gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory');
4995
-                    $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' );
4995
+                    $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');
4996 4996
                     for ($i = 1; $i <= $limit; $i++) {
4997 4997
                         $index = $processed + $i;
4998 4998
                         
4999 4999
                         if (isset($file[$index])) {
5000 5000
                             $row = $file[$index];
5001
-                            $row = array_map( 'trim', $row );
5001
+                            $row = array_map('trim', $row);
5002 5002
                             $data = array();
5003 5003
                             
5004 5004
                             foreach ($columns as $c => $column) {
@@ -5009,20 +5009,20 @@  discard block
 block discarded – undo
5009 5009
 
5010 5010
                             if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
5011 5011
                                 $invalid++;
5012
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5012
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood);
5013 5013
                                 continue;
5014 5014
                             }
5015 5015
                             
5016 5016
                             $location_info = array();
5017
-                            if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
5018
-                                $location_info = geodir_get_location_by_id('', (int)$data['location_id']);
5017
+                            if (!empty($data['location_id']) && (int) $data['location_id'] > 0) {
5018
+                                $location_info = geodir_get_location_by_id('', (int) $data['location_id']);
5019 5019
                             } else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
5020 5020
                                 $location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
5021 5021
                             }
5022 5022
 
5023 5023
                             if (empty($location_info)) {
5024 5024
                                 $invalid++;
5025
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5025
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood);
5026 5026
                                 continue;
5027 5027
                             }
5028 5028
                             
@@ -5037,35 +5037,35 @@  discard block
 block discarded – undo
5037 5037
                             $hood_data['hood_longitude'] = $data['longitude'];
5038 5038
                             $hood_data['hood_location_id'] = $location_id;
5039 5039
                                     
5040
-                            if ( $import_choice == 'update' ) {
5041
-                                if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
5042
-                                    $hood_data['hood_id'] = (int)$data['neighbourhood_id'];
5040
+                            if ($import_choice == 'update') {
5041
+                                if ((int) $data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int) $data['neighbourhood_id']))) {
5042
+                                    $hood_data['hood_id'] = (int) $data['neighbourhood_id'];
5043 5043
                                     
5044 5044
                                     if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5045 5045
                                         $updated++;
5046 5046
                                     } else {
5047 5047
                                         $invalid++;
5048
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5048
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood);
5049 5049
                                     }
5050 5050
                                 } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
5051
-                                    $hood_data['hood_id'] = (int)$neighbourhood->hood_id;
5051
+                                    $hood_data['hood_id'] = (int) $neighbourhood->hood_id;
5052 5052
                                     
5053 5053
                                     if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5054 5054
                                         $updated++;
5055 5055
                                     } else {
5056 5056
                                         $invalid++;
5057
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5057
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood);
5058 5058
                                     }
5059 5059
                                 } else {
5060 5060
                                     if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5061 5061
                                         $created++;
5062 5062
                                     } else {
5063 5063
                                         $invalid++;
5064
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5064
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood);
5065 5065
                                     }
5066 5066
                                 }
5067
-                            } elseif ( $import_choice == 'skip' ) {
5068
-                                if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
5067
+                            } elseif ($import_choice == 'skip') {
5068
+                                if ((int) $data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int) $data['neighbourhood_id']))) {
5069 5069
                                     $skipped++;
5070 5070
                                 } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
5071 5071
                                     $skipped++;
@@ -5075,12 +5075,12 @@  discard block
 block discarded – undo
5075 5075
                                         $created++;
5076 5076
                                     } else {
5077 5077
                                         $invalid++;
5078
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5078
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood);
5079 5079
                                     }
5080 5080
                                 }
5081 5081
                             } else {
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
                             }
5085 5085
                         }
5086 5086
                     }
@@ -5094,7 +5094,7 @@  discard block
 block discarded – undo
5094 5094
                 $json['invalid'] = $invalid;
5095 5095
                 $json['images'] = $images;
5096 5096
                 
5097
-                wp_send_json( $json );
5097
+                wp_send_json($json);
5098 5098
             }
5099 5099
         }
5100 5100
         break;
@@ -5138,29 +5138,29 @@  discard block
 block discarded – undo
5138 5138
  * }
5139 5139
  * @return int|bool Term id when success, false when fail.
5140 5140
  */
5141
-function geodir_imex_insert_term( $taxonomy, $term_data ) {
5142
-	if ( empty( $taxonomy ) || empty( $term_data ) ) {
5141
+function geodir_imex_insert_term($taxonomy, $term_data) {
5142
+	if (empty($taxonomy) || empty($term_data)) {
5143 5143
 		return false;
5144 5144
 	}
5145 5145
 	
5146
-	$term = isset( $term_data['name'] ) && !empty( $term_data['name'] ) ? $term_data['name'] : '';
5146
+	$term = isset($term_data['name']) && !empty($term_data['name']) ? $term_data['name'] : '';
5147 5147
 	$args = array();
5148
-	$args['description'] = isset( $term_data['description'] ) ? $term_data['description'] : '';
5149
-	$args['slug'] = isset( $term_data['slug'] ) ? $term_data['slug'] : '';
5150
-	$args['parent'] = isset( $term_data['parent'] ) ? (int)$term_data['parent'] : '';
5148
+	$args['description'] = isset($term_data['description']) ? $term_data['description'] : '';
5149
+	$args['slug'] = isset($term_data['slug']) ? $term_data['slug'] : '';
5150
+	$args['parent'] = isset($term_data['parent']) ? (int) $term_data['parent'] : '';
5151 5151
 	
5152
-	if ( ( !empty( $args['slug'] ) && term_exists( $args['slug'], $taxonomy ) ) || empty( $args['slug'] ) ) {
5153
-		$term_args = array_merge( $term_data, $args );
5154
-		$defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
5155
-		$term_args = wp_parse_args( $term_args, $defaults );
5156
-		$term_args = sanitize_term( $term_args, $taxonomy, 'db' );
5157
-		$args['slug'] = wp_unique_term_slug( $args['slug'], (object)$term_args );
5152
+	if ((!empty($args['slug']) && term_exists($args['slug'], $taxonomy)) || empty($args['slug'])) {
5153
+		$term_args = array_merge($term_data, $args);
5154
+		$defaults = array('alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
5155
+		$term_args = wp_parse_args($term_args, $defaults);
5156
+		$term_args = sanitize_term($term_args, $taxonomy, 'db');
5157
+		$args['slug'] = wp_unique_term_slug($args['slug'], (object) $term_args);
5158 5158
 	}
5159 5159
 	
5160
-    if( !empty( $term ) ) {
5161
-		$result = wp_insert_term( $term, $taxonomy, $args );
5162
-        if( !is_wp_error( $result ) ) {
5163
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5160
+    if (!empty($term)) {
5161
+		$result = wp_insert_term($term, $taxonomy, $args);
5162
+        if (!is_wp_error($result)) {
5163
+            return isset($result['term_id']) ? $result['term_id'] : 0;
5164 5164
         }
5165 5165
     }
5166 5166
 	
@@ -5190,36 +5190,36 @@  discard block
 block discarded – undo
5190 5190
  * }
5191 5191
  * @return int|bool Term id when success, false when fail.
5192 5192
  */
5193
-function geodir_imex_update_term( $taxonomy, $term_data ) {
5194
-	if ( empty( $taxonomy ) || empty( $term_data ) ) {
5193
+function geodir_imex_update_term($taxonomy, $term_data) {
5194
+	if (empty($taxonomy) || empty($term_data)) {
5195 5195
 		return false;
5196 5196
 	}
5197 5197
 	
5198
-	$term_id = isset( $term_data['term_id'] ) && !empty( $term_data['term_id'] ) ? $term_data['term_id'] : 0;
5198
+	$term_id = isset($term_data['term_id']) && !empty($term_data['term_id']) ? $term_data['term_id'] : 0;
5199 5199
 	
5200 5200
 	$args = array();
5201
-	$args['description'] = isset( $term_data['description'] ) ? $term_data['description'] : '';
5202
-	$args['slug'] = isset( $term_data['slug'] ) ? $term_data['slug'] : '';
5203
-	$args['parent'] = isset( $term_data['parent'] ) ? (int)$term_data['parent'] : '';
5201
+	$args['description'] = isset($term_data['description']) ? $term_data['description'] : '';
5202
+	$args['slug'] = isset($term_data['slug']) ? $term_data['slug'] : '';
5203
+	$args['parent'] = isset($term_data['parent']) ? (int) $term_data['parent'] : '';
5204 5204
 	
5205
-	if ( $term_id > 0 && $term_info = (array)get_term( $term_id, $taxonomy ) ) {
5205
+	if ($term_id > 0 && $term_info = (array) get_term($term_id, $taxonomy)) {
5206 5206
 		$term_data['term_id'] = $term_info['term_id'];
5207 5207
 		
5208
-		$result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
5208
+		$result = wp_update_term($term_data['term_id'], $taxonomy, $term_data);
5209 5209
 		
5210
-		if( !is_wp_error( $result ) ) {
5211
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5210
+		if (!is_wp_error($result)) {
5211
+            return isset($result['term_id']) ? $result['term_id'] : 0;
5212 5212
         }
5213
-	} else if ( $term_data['slug'] != '' && $term_info = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
5213
+	} else if ($term_data['slug'] != '' && $term_info = (array) term_exists($term_data['slug'], $taxonomy)) {
5214 5214
 		$term_data['term_id'] = $term_info['term_id'];
5215 5215
 		
5216
-		$result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
5216
+		$result = wp_update_term($term_data['term_id'], $taxonomy, $term_data);
5217 5217
 		
5218
-		if( !is_wp_error( $result ) ) {
5219
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5218
+		if (!is_wp_error($result)) {
5219
+            return isset($result['term_id']) ? $result['term_id'] : 0;
5220 5220
         }
5221 5221
 	} else {
5222
-		return geodir_imex_insert_term( $taxonomy, $term_data );
5222
+		return geodir_imex_insert_term($taxonomy, $term_data);
5223 5223
 	}
5224 5224
 	
5225 5225
 	return false;
@@ -5237,25 +5237,25 @@  discard block
 block discarded – undo
5237 5237
  * @param string $post_type Post type.
5238 5238
  * @return int Posts count.
5239 5239
  */
5240
-function geodir_get_posts_count( $post_type ) {
5240
+function geodir_get_posts_count($post_type) {
5241 5241
     global $wpdb, $plugin_prefix;
5242 5242
 
5243
-    if ( !post_type_exists( $post_type ) ) {
5243
+    if (!post_type_exists($post_type)) {
5244 5244
         return 0;
5245 5245
     }
5246 5246
         
5247
-    $table = $plugin_prefix . $post_type . '_detail';
5247
+    $table = $plugin_prefix.$post_type.'_detail';
5248 5248
 
5249 5249
     // Skip listing with statuses trash, auto-draft etc...
5250 5250
     $skip_statuses = geodir_imex_export_skip_statuses();
5251 5251
     $where_statuses = '';
5252
-    if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5253
-        $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5252
+    if (!empty($skip_statuses) && is_array($skip_statuses)) {
5253
+        $where_statuses = "AND `".$wpdb->posts."`.`post_status` NOT IN('".implode("','", $skip_statuses)."')";
5254 5254
     }
5255 5255
 
5256
-    $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 );
5256
+    $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);
5257 5257
 
5258
-    $posts_count = (int)$wpdb->get_var( $query );
5258
+    $posts_count = (int) $wpdb->get_var($query);
5259 5259
     
5260 5260
     /**
5261 5261
      * Modify returned post counts for the current post type.
@@ -5266,7 +5266,7 @@  discard block
 block discarded – undo
5266 5266
      * @param int $posts_count Post counts.
5267 5267
      * @param string $post_type Post type.
5268 5268
      */
5269
-    $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type );
5269
+    $posts_count = apply_filters('geodir_imex_count_posts', $posts_count, $post_type);
5270 5270
 
5271 5271
     return $posts_count;
5272 5272
 }
@@ -5287,17 +5287,17 @@  discard block
 block discarded – undo
5287 5287
  * @param int $page_no Page number. Default 0.
5288 5288
  * @return array Array of posts data.
5289 5289
  */
5290
-function geodir_imex_get_posts( $post_type, $per_page = 0, $page_no = 0 ) {	
5290
+function geodir_imex_get_posts($post_type, $per_page = 0, $page_no = 0) {	
5291 5291
 	global $wp_filesystem;
5292 5292
 
5293
-	$posts = geodir_get_export_posts( $post_type, $per_page, $page_no );
5293
+	$posts = geodir_get_export_posts($post_type, $per_page, $page_no);
5294 5294
 
5295 5295
 	$csv_rows = array();
5296 5296
 	
5297
-	if ( !empty( $posts ) ) {
5298
-		$is_payment_plugin = is_plugin_active( 'geodir_payment_manager/geodir_payment_manager.php' );
5297
+	if (!empty($posts)) {
5298
+		$is_payment_plugin = is_plugin_active('geodir_payment_manager/geodir_payment_manager.php');
5299 5299
         $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
5300
-        $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
5300
+        $location_allowed = function_exists('geodir_cpt_no_location') && geodir_cpt_no_location($post_type) ? false : true;
5301 5301
         $neighbourhood_active = $location_manager && $location_allowed && get_option('location_neighbourhoods') ? true : false;
5302 5302
 		
5303 5303
 		$csv_row = array();
@@ -5309,7 +5309,7 @@  discard block
 block discarded – undo
5309 5309
 		$csv_row[] = 'default_category';
5310 5310
 		$csv_row[] = 'post_tags';
5311 5311
 		$csv_row[] = 'post_type';
5312
-		if ( $post_type == 'gd_event' ) {
5312
+		if ($post_type == 'gd_event') {
5313 5313
 			$csv_row[] = 'event_date';
5314 5314
 			$csv_row[] = 'event_enddate';
5315 5315
 			$csv_row[] = 'starttime';
@@ -5363,15 +5363,15 @@  discard block
 block discarded – undo
5363 5363
 		}
5364 5364
 		// WPML
5365 5365
 
5366
-		$custom_fields = geodir_imex_get_custom_fields( $post_type );
5367
-		if ( !empty( $custom_fields ) ) {
5368
-			foreach ( $custom_fields as $custom_field ) {
5366
+		$custom_fields = geodir_imex_get_custom_fields($post_type);
5367
+		if (!empty($custom_fields)) {
5368
+			foreach ($custom_fields as $custom_field) {
5369 5369
 				$csv_row[] = $custom_field->htmlvar_name;
5370 5370
 			}
5371 5371
 		}
5372 5372
 
5373 5373
 		// Export franchise fields
5374
-		$is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false;
5374
+		$is_franchise_active = is_plugin_active('geodir_franchise/geodir_franchise.php') && geodir_franchise_enabled($post_type) ? true : false;
5375 5375
 		if ($is_franchise_active) {
5376 5376
 			$csv_row[] = 'gd_is_franchise';
5377 5377
 			$csv_row[] = 'gd_franchise_lock';
@@ -5381,28 +5381,28 @@  discard block
 block discarded – undo
5381 5381
 		$csv_rows[] = $csv_row;
5382 5382
 
5383 5383
 		$images_count = 5;
5384
-        $xx=0;
5385
-		foreach ( $posts as $post ) {$xx++;
5384
+        $xx = 0;
5385
+		foreach ($posts as $post) {$xx++;
5386 5386
 			$post_id = $post['ID'];
5387 5387
 			
5388
-			$gd_post_info = geodir_get_post_info( $post_id );
5389
-			$post_info = (array)$gd_post_info;
5388
+			$gd_post_info = geodir_get_post_info($post_id);
5389
+			$post_info = (array) $gd_post_info;
5390 5390
 						
5391
-			$taxonomy_category = $post_type . 'category';
5392
-			$taxonomy_tags = $post_type . '_tags';
5391
+			$taxonomy_category = $post_type.'category';
5392
+			$taxonomy_tags = $post_type.'_tags';
5393 5393
 			
5394 5394
 			$post_category = '';
5395 5395
 			$default_category_id = $gd_post_info->default_category;
5396 5396
 			$default_category = '';
5397 5397
 			$post_tags = '';
5398
-			$terms = wp_get_post_terms( $post_id, array( $taxonomy_category, $taxonomy_tags ) );
5398
+			$terms = wp_get_post_terms($post_id, array($taxonomy_category, $taxonomy_tags));
5399 5399
 			
5400
-			if ( !empty( $terms ) && !is_wp_error( $terms ) ) {
5400
+			if (!empty($terms) && !is_wp_error($terms)) {
5401 5401
 				$post_category = array();
5402 5402
 				$post_tags = array();
5403 5403
 			
5404
-				foreach ( $terms as $term ) {
5405
-					if ( $term->taxonomy == $taxonomy_category ) {
5404
+				foreach ($terms as $term) {
5405
+					if ($term->taxonomy == $taxonomy_category) {
5406 5406
 						$post_category[] = $term->name;
5407 5407
 						
5408 5408
 						if ($default_category_id == $term->term_id) {
@@ -5410,7 +5410,7 @@  discard block
 block discarded – undo
5410 5410
 						}
5411 5411
 					}
5412 5412
 					
5413
-					if ( $term->taxonomy == $taxonomy_tags ) {
5413
+					if ($term->taxonomy == $taxonomy_tags) {
5414 5414
 						$post_tags[] = $term->name;
5415 5415
 					}
5416 5416
 				}
@@ -5418,47 +5418,47 @@  discard block
 block discarded – undo
5418 5418
 				if (empty($default_category) && !empty($post_category)) {
5419 5419
 					$default_category = $post_category[0]; // Set first one as default category.
5420 5420
 				}
5421
-				$post_category = !empty( $post_category ) ? implode( ',', $post_category ) : '';
5422
-				$post_tags = !empty( $post_tags ) ? implode( ',', $post_tags ) : '';
5421
+				$post_category = !empty($post_category) ? implode(',', $post_category) : '';
5422
+				$post_tags = !empty($post_tags) ? implode(',', $post_tags) : '';
5423 5423
 			}
5424 5424
 
5425 5425
 			// Franchise data
5426
-			if ($is_franchise_active && isset($post_info['franchise']) && (int)$post_info['franchise'] > 0 && geodir_franchise_check((int)$post_info['franchise'])) {
5426
+			if ($is_franchise_active && isset($post_info['franchise']) && (int) $post_info['franchise'] > 0 && geodir_franchise_check((int) $post_info['franchise'])) {
5427 5427
 				$franchise_id = $post_info['franchise'];
5428 5428
 				$gd_franchise_info = geodir_get_post_info($franchise_id);
5429 5429
 
5430 5430
 				if (geodir_franchise_pkg_is_active($gd_franchise_info)) {
5431
-					$franchise_info = (array)$gd_franchise_info;
5431
+					$franchise_info = (array) $gd_franchise_info;
5432 5432
 					$locked_fields = geodir_franchise_get_locked_fields($franchise_id, true);
5433 5433
 					
5434 5434
 					if (!empty($locked_fields)) {
5435
-						foreach( $locked_fields as $locked_field) {
5435
+						foreach ($locked_fields as $locked_field) {
5436 5436
 							if (isset($post_info[$locked_field]) && isset($franchise_info[$locked_field])) {
5437 5437
 								$post_info[$locked_field] = $franchise_info[$locked_field];
5438 5438
 							}
5439 5439
 							
5440 5440
 							if (in_array($taxonomy_category, $locked_fields) || in_array('post_tags', $locked_fields)) {
5441
-								$franchise_terms = wp_get_post_terms( $franchise_id, array( $taxonomy_category, $taxonomy_tags ) );
5441
+								$franchise_terms = wp_get_post_terms($franchise_id, array($taxonomy_category, $taxonomy_tags));
5442 5442
 			
5443
-								if ( !empty( $franchise_terms ) && !is_wp_error( $franchise_terms ) ) {
5443
+								if (!empty($franchise_terms) && !is_wp_error($franchise_terms)) {
5444 5444
 									$franchise_post_category = array();
5445 5445
 									$franchise_post_tags = array();
5446 5446
 								
5447
-									foreach ( $franchise_terms as $franchise_term ) {
5448
-										if ( $franchise_term->taxonomy == $taxonomy_category ) {
5447
+									foreach ($franchise_terms as $franchise_term) {
5448
+										if ($franchise_term->taxonomy == $taxonomy_category) {
5449 5449
 											$franchise_post_category[] = $franchise_term->name;
5450 5450
 										}
5451 5451
 										
5452
-										if ( $franchise_term->taxonomy == $taxonomy_tags ) {
5452
+										if ($franchise_term->taxonomy == $taxonomy_tags) {
5453 5453
 											$franchise_post_tags[] = $franchise_term->name;
5454 5454
 										}
5455 5455
 									}
5456 5456
 									
5457 5457
 									if (in_array($taxonomy_category, $locked_fields)) {
5458
-										$post_category = !empty( $franchise_post_category ) ? implode( ',', $franchise_post_category ) : '';
5458
+										$post_category = !empty($franchise_post_category) ? implode(',', $franchise_post_category) : '';
5459 5459
 									}
5460 5460
 									if (in_array('post_tags', $locked_fields)) {
5461
-										$post_tags = !empty( $franchise_post_tags ) ? implode( ',', $franchise_post_tags ) : '';
5461
+										$post_tags = !empty($franchise_post_tags) ? implode(',', $franchise_post_tags) : '';
5462 5462
 									}
5463 5463
 								}
5464 5464
 							}
@@ -5467,18 +5467,18 @@  discard block
 block discarded – undo
5467 5467
 				}
5468 5468
 			}
5469 5469
 						
5470
-			$post_images = geodir_get_images( $post_id );
5470
+			$post_images = geodir_get_images($post_id);
5471 5471
 			$current_images = array();
5472
-			if ( !empty( $post_images ) ) {
5473
-				foreach ( $post_images as $post_image ) {
5474
-					$post_image = (array)$post_image;
5475
-					$image = !empty( $post_image ) && isset( $post_image['path'] ) && $wp_filesystem->is_file( $post_image['path'] ) && $wp_filesystem->exists( $post_image['path'] ) ? $post_image['src'] : '';
5476
-					if ( $image ) {
5472
+			if (!empty($post_images)) {
5473
+				foreach ($post_images as $post_image) {
5474
+					$post_image = (array) $post_image;
5475
+					$image = !empty($post_image) && isset($post_image['path']) && $wp_filesystem->is_file($post_image['path']) && $wp_filesystem->exists($post_image['path']) ? $post_image['src'] : '';
5476
+					if ($image) {
5477 5477
 						$current_images[] = $image;
5478 5478
 					}
5479 5479
 				}
5480 5480
 				
5481
-				$images_count = max( $images_count, count( $current_images ) );
5481
+				$images_count = max($images_count, count($current_images));
5482 5482
 			}
5483 5483
 
5484 5484
 			$csv_row = array();
@@ -5490,7 +5490,7 @@  discard block
 block discarded – undo
5490 5490
 			$csv_row[] = $default_category; // default_category
5491 5491
 			$csv_row[] = $post_tags; // post_tags
5492 5492
 			$csv_row[] = $post_type; // post_type
5493
-			if ( $post_type == 'gd_event' ) {
5493
+			if ($post_type == 'gd_event') {
5494 5494
 				$event_data = geodir_imex_get_event_data($post, $gd_post_info);
5495 5495
 				$csv_row[] = $event_data['event_date']; // event_date
5496 5496
 				$csv_row[] = $event_data['event_enddate']; // enddate
@@ -5511,9 +5511,9 @@  discard block
 block discarded – undo
5511 5511
 				$csv_row[] = $event_data['recurring_end_date']; // repeat_end
5512 5512
 			}
5513 5513
 			$csv_row[] = $post_info['post_status']; // post_status
5514
-			$csv_row[] = (int)$post_info['is_featured'] == 1 ? 1 : ''; // is_featured
5514
+			$csv_row[] = (int) $post_info['is_featured'] == 1 ? 1 : ''; // is_featured
5515 5515
 			if ($is_payment_plugin) {
5516
-				$csv_row[] = (int)$post_info['package_id']; // package_id
5516
+				$csv_row[] = (int) $post_info['package_id']; // package_id
5517 5517
 				$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
5518 5518
 			}
5519 5519
 			$csv_row[] = $post_info['geodir_video']; // geodir_video
@@ -5549,14 +5549,14 @@  discard block
 block discarded – undo
5549 5549
 			$csv_row[] = $post_info['geodir_special_offers']; // geodir_special_offers
5550 5550
 			// WPML
5551 5551
 			if ($is_wpml) {
5552
-				$csv_row[] = geodir_get_language_for_element( $post_id, 'post_' . $post_type );
5553
-				$csv_row[] = geodir_imex_original_post_id( $post_id, 'post_' . $post_type );
5552
+				$csv_row[] = geodir_get_language_for_element($post_id, 'post_'.$post_type);
5553
+				$csv_row[] = geodir_imex_original_post_id($post_id, 'post_'.$post_type);
5554 5554
 			}
5555 5555
 			// WPML
5556 5556
 			
5557
-			if ( !empty( $custom_fields ) ) {
5558
-				foreach ( $custom_fields as $custom_field ) {
5559
-					$csv_row[] = isset( $post_info[$custom_field->htmlvar_name] ) ? $post_info[$custom_field->htmlvar_name] : '';
5557
+			if (!empty($custom_fields)) {
5558
+				foreach ($custom_fields as $custom_field) {
5559
+					$csv_row[] = isset($post_info[$custom_field->htmlvar_name]) ? $post_info[$custom_field->htmlvar_name] : '';
5560 5560
 				}
5561 5561
 			}
5562 5562
 			
@@ -5567,26 +5567,26 @@  discard block
 block discarded – undo
5567 5567
 				$franchise = '';
5568 5568
 					
5569 5569
 				if (geodir_franchise_pkg_is_active($gd_post_info)) {
5570
-					$gd_is_franchise = (int)get_post_meta( $post_id, 'gd_is_franchise', true );
5571
-					$locaked_fields = $gd_is_franchise ? get_post_meta( $post_id, 'gd_franchise_lock', true ) : '';
5570
+					$gd_is_franchise = (int) get_post_meta($post_id, 'gd_is_franchise', true);
5571
+					$locaked_fields = $gd_is_franchise ? get_post_meta($post_id, 'gd_franchise_lock', true) : '';
5572 5572
 					$locaked_fields = (is_array($locaked_fields) && !empty($locaked_fields) ? implode(",", $locaked_fields) : '');
5573
-					$franchise = !$gd_is_franchise && isset($post_info['franchise']) && (int)$post_info['franchise'] > 0 ? (int)$post_info['franchise'] : 0; // franchise id
5573
+					$franchise = !$gd_is_franchise && isset($post_info['franchise']) && (int) $post_info['franchise'] > 0 ? (int) $post_info['franchise'] : 0; // franchise id
5574 5574
 				}
5575 5575
 				
5576
-				$csv_row[] = (int)$gd_is_franchise; // gd_is_franchise
5576
+				$csv_row[] = (int) $gd_is_franchise; // gd_is_franchise
5577 5577
 				$csv_row[] = $locaked_fields; // gd_franchise_lock fields
5578
-				$csv_row[] = (int)$franchise; // franchise id
5578
+				$csv_row[] = (int) $franchise; // franchise id
5579 5579
 			}
5580 5580
 			
5581
-			for ( $c = 0; $c < $images_count; $c++ ) {
5582
-				$csv_row[] = isset( $current_images[$c] ) ? $current_images[$c] : ''; // IMAGE
5581
+			for ($c = 0; $c < $images_count; $c++) {
5582
+				$csv_row[] = isset($current_images[$c]) ? $current_images[$c] : ''; // IMAGE
5583 5583
 			}
5584 5584
 			
5585 5585
 			$csv_rows[] = $csv_row;
5586 5586
 
5587 5587
 		}
5588 5588
 
5589
-		for ( $c = 0; $c < $images_count; $c++ ) {
5589
+		for ($c = 0; $c < $images_count; $c++) {
5590 5590
 			$csv_rows[0][] = 'IMAGE';
5591 5591
 		}
5592 5592
 	}
@@ -5608,33 +5608,33 @@  discard block
 block discarded – undo
5608 5608
  * @param int $page_no Page number. Default 0.
5609 5609
  * @return array Array of posts data.
5610 5610
  */
5611
-function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) {
5611
+function geodir_get_export_posts($post_type, $per_page = 0, $page_no = 0) {
5612 5612
     global $wpdb, $plugin_prefix;
5613 5613
 
5614
-    if ( ! post_type_exists( $post_type ) )
5614
+    if (!post_type_exists($post_type))
5615 5615
         return new stdClass;
5616 5616
         
5617
-    $table = $plugin_prefix . $post_type . '_detail';
5617
+    $table = $plugin_prefix.$post_type.'_detail';
5618 5618
 
5619 5619
     $limit = '';
5620
-    if ( $per_page > 0 && $page_no > 0 ) {
5621
-        $offset = ( $page_no - 1 ) * $per_page;
5620
+    if ($per_page > 0 && $page_no > 0) {
5621
+        $offset = ($page_no - 1) * $per_page;
5622 5622
         
5623
-        if ( $offset > 0 ) {
5624
-            $limit = " LIMIT " . $offset . "," . $per_page;
5623
+        if ($offset > 0) {
5624
+            $limit = " LIMIT ".$offset.",".$per_page;
5625 5625
         } else {
5626
-            $limit = " LIMIT " . $per_page;
5626
+            $limit = " LIMIT ".$per_page;
5627 5627
         }
5628 5628
     }
5629 5629
 
5630 5630
     // Skip listing with statuses trash, auto-draft etc...
5631 5631
     $skip_statuses = geodir_imex_export_skip_statuses();
5632 5632
     $where_statuses = '';
5633
-    if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5634
-        $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5633
+    if (!empty($skip_statuses) && is_array($skip_statuses)) {
5634
+        $where_statuses = "AND `".$wpdb->posts."`.`post_status` NOT IN('".implode("','", $skip_statuses)."')";
5635 5635
     }
5636 5636
 
5637
-    $query = "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;
5637
+    $query = "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;
5638 5638
     /**
5639 5639
      * Modify returned posts SQL query for the current post type.
5640 5640
      *
@@ -5644,9 +5644,9 @@  discard block
 block discarded – undo
5644 5644
      * @param int $query The SQL query.
5645 5645
      * @param string $post_type Post type.
5646 5646
      */
5647
-    $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type );
5647
+    $query = apply_filters('geodir_imex_export_posts_query', $query, $post_type);
5648 5648
 
5649
-    $results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A );
5649
+    $results = (array) $wpdb->get_results($wpdb->prepare($query, $post_type), ARRAY_A);
5650 5650
 
5651 5651
     /**
5652 5652
      * Modify returned post results for the current post type.
@@ -5657,7 +5657,7 @@  discard block
 block discarded – undo
5657 5657
      * @param object $results An object containing all post ids.
5658 5658
      * @param string $post_type Post type.
5659 5659
      */
5660
-    return apply_filters( 'geodir_export_posts', $results, $post_type );
5660
+    return apply_filters('geodir_export_posts', $results, $post_type);
5661 5661
 }
5662 5662
 
5663 5663
 /**
@@ -5674,21 +5674,21 @@  discard block
 block discarded – undo
5674 5674
  * @param string $post_type Post type.
5675 5675
  * @return string The SQL query.
5676 5676
  */
5677
-function geodir_imex_get_events_query( $query, $post_type ) {
5678
-    if ( $post_type == 'gd_event' ) {
5677
+function geodir_imex_get_events_query($query, $post_type) {
5678
+    if ($post_type == 'gd_event') {
5679 5679
         global $wpdb, $plugin_prefix;
5680 5680
         
5681
-        $table = $plugin_prefix . $post_type . '_detail';
5681
+        $table = $plugin_prefix.$post_type.'_detail';
5682 5682
         $schedule_table = EVENT_SCHEDULE;
5683 5683
         
5684 5684
         // Skip listing with statuses trash, auto-draft etc...
5685 5685
         $skip_statuses = geodir_imex_export_skip_statuses();
5686 5686
         $where_statuses = '';
5687
-        if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5688
-            $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5687
+        if (!empty($skip_statuses) && is_array($skip_statuses)) {
5688
+            $where_statuses = "AND `".$wpdb->posts."`.`post_status` NOT IN('".implode("','", $skip_statuses)."')";
5689 5689
         }
5690 5690
 
5691
-        $query = "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";
5691
+        $query = "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";
5692 5692
     }
5693 5693
 
5694 5694
     return $query;
@@ -5712,35 +5712,35 @@  discard block
 block discarded – undo
5712 5712
  * @param  string $post_type Post type.
5713 5713
  * @return int Total terms count.
5714 5714
  */
5715
-function geodir_get_terms_count( $post_type ) {
5716
-    $args = array( 'hide_empty' => 0 );
5715
+function geodir_get_terms_count($post_type) {
5716
+    $args = array('hide_empty' => 0);
5717 5717
 
5718
-    remove_all_filters( 'get_terms' );
5718
+    remove_all_filters('get_terms');
5719 5719
 
5720
-    $taxonomy = $post_type . 'category';
5720
+    $taxonomy = $post_type.'category';
5721 5721
 
5722 5722
     // WPML
5723 5723
     $is_wpml = geodir_is_wpml();
5724 5724
     $active_lang = 'all';
5725
-    if ( $is_wpml ) {
5725
+    if ($is_wpml) {
5726 5726
         global $sitepress;
5727 5727
         $active_lang = $sitepress->get_current_language();
5728 5728
         
5729
-        if ( $active_lang != 'all' ) {
5730
-            $sitepress->switch_lang( 'all', true );
5729
+        if ($active_lang != 'all') {
5730
+            $sitepress->switch_lang('all', true);
5731 5731
         }
5732 5732
     }
5733 5733
     // WPML
5734 5734
             
5735
-    $count_terms = wp_count_terms( $taxonomy, $args );
5735
+    $count_terms = wp_count_terms($taxonomy, $args);
5736 5736
 
5737 5737
     // WPML
5738
-    if ( $is_wpml && $active_lang !== 'all' ) {
5738
+    if ($is_wpml && $active_lang !== 'all') {
5739 5739
         global $sitepress;
5740
-        $sitepress->switch_lang( $active_lang, true );
5740
+        $sitepress->switch_lang($active_lang, true);
5741 5741
     }
5742 5742
     // WPML
5743
-    $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0;
5743
+    $count_terms = !is_wp_error($count_terms) ? $count_terms : 0;
5744 5744
      
5745 5745
     return $count_terms;
5746 5746
 }
@@ -5757,23 +5757,23 @@  discard block
 block discarded – undo
5757 5757
  * @param int $page_no Page number. Default 0.
5758 5758
  * @return array Array of terms data.
5759 5759
  */
5760
-function geodir_imex_get_terms( $post_type, $per_page = 0, $page_no = 0 ) {
5761
-	$args = array( 'hide_empty' => 0, 'orderby' => 'id' );
5760
+function geodir_imex_get_terms($post_type, $per_page = 0, $page_no = 0) {
5761
+	$args = array('hide_empty' => 0, 'orderby' => 'id');
5762 5762
 	
5763
-	remove_all_filters( 'get_terms' );
5763
+	remove_all_filters('get_terms');
5764 5764
 	
5765
-	$taxonomy = $post_type . 'category';
5765
+	$taxonomy = $post_type.'category';
5766 5766
 	
5767
-	if ( $per_page > 0 && $page_no > 0 ) {
5768
-		$args['offset'] = ( $page_no - 1 ) * $per_page;
5767
+	if ($per_page > 0 && $page_no > 0) {
5768
+		$args['offset'] = ($page_no - 1) * $per_page;
5769 5769
 		$args['number'] = $per_page;
5770 5770
 	}
5771 5771
 	
5772
-	$terms = get_terms( $taxonomy, $args );
5772
+	$terms = get_terms($taxonomy, $args);
5773 5773
 
5774 5774
 	$csv_rows = array();
5775 5775
 	
5776
-	if ( !empty( $terms ) ) {
5776
+	if (!empty($terms)) {
5777 5777
 		$csv_row = array();
5778 5778
 		$csv_row[] = 'cat_id';
5779 5779
 		$csv_row[] = 'cat_name';
@@ -5795,16 +5795,16 @@  discard block
 block discarded – undo
5795 5795
 		
5796 5796
 		$csv_rows[] = $csv_row;
5797 5797
 		
5798
-		foreach ( $terms as $term ) {
5799
-			$cat_icon = get_tax_meta( $term->term_id, 'ct_cat_icon', false, $post_type );
5800
-			$cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : '';
5798
+		foreach ($terms as $term) {
5799
+			$cat_icon = get_tax_meta($term->term_id, 'ct_cat_icon', false, $post_type);
5800
+			$cat_icon = !empty($cat_icon) && isset($cat_icon['src']) ? $cat_icon['src'] : '';
5801 5801
 			
5802
-			$cat_image = geodir_get_default_catimage( $term->term_id, $post_type );
5803
-			$cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; 
5802
+			$cat_image = geodir_get_default_catimage($term->term_id, $post_type);
5803
+			$cat_image = !empty($cat_image) && isset($cat_image['src']) ? $cat_image['src'] : ''; 
5804 5804
 			
5805 5805
 			$cat_parent = '';
5806
-			if (isset($term->parent) && (int)$term->parent > 0 && term_exists((int)$term->parent, $taxonomy)) {
5807
-				$parent_term = (array)get_term_by( 'id', (int)$term->parent, $taxonomy );
5806
+			if (isset($term->parent) && (int) $term->parent > 0 && term_exists((int) $term->parent, $taxonomy)) {
5807
+				$parent_term = (array) get_term_by('id', (int) $term->parent, $taxonomy);
5808 5808
 				$cat_parent = !empty($parent_term) && isset($parent_term['name']) ? $parent_term['name'] : '';
5809 5809
 			}
5810 5810
 			
@@ -5814,15 +5814,15 @@  discard block
 block discarded – undo
5814 5814
 			$csv_row[] = $term->slug;
5815 5815
 			$csv_row[] = $post_type;
5816 5816
 			$csv_row[] = $cat_parent;
5817
-			$csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_schema', false, $post_type );
5817
+			$csv_row[] = get_tax_meta($term->term_id, 'ct_cat_schema', false, $post_type);
5818 5818
             // WPML
5819 5819
 			if ($is_wpml) {
5820
-				$csv_row[] = geodir_get_language_for_element( $term->term_id, 'tax_' . $taxonomy );
5821
-                $csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy );
5820
+				$csv_row[] = geodir_get_language_for_element($term->term_id, 'tax_'.$taxonomy);
5821
+                $csv_row[] = geodir_imex_original_post_id($term->term_id, 'tax_'.$taxonomy);
5822 5822
 			}
5823 5823
 			// WPML
5824 5824
 			$csv_row[] = $term->description;
5825
-			$csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_top_desc', false, $post_type );
5825
+			$csv_row[] = get_tax_meta($term->term_id, 'ct_cat_top_desc', false, $post_type);
5826 5826
 			$csv_row[] = $cat_image;
5827 5827
 			$csv_row[] = $cat_icon;
5828 5828
 			
@@ -5841,10 +5841,10 @@  discard block
 block discarded – undo
5841 5841
  * @param  bool $relative True for relative path & False for absolute path.
5842 5842
  * @return string Path to the cache directory.
5843 5843
  */
5844
-function geodir_path_import_export( $relative = true ) {
5844
+function geodir_path_import_export($relative = true) {
5845 5845
 	$upload_dir = wp_upload_dir();
5846 5846
 	
5847
-	return $relative ? $upload_dir['baseurl'] . '/cache' : $upload_dir['basedir'] . '/cache';
5847
+	return $relative ? $upload_dir['baseurl'].'/cache' : $upload_dir['basedir'].'/cache';
5848 5848
 }
5849 5849
 
5850 5850
 /**
@@ -5860,8 +5860,8 @@  discard block
 block discarded – undo
5860 5860
  * @param  bool $clear If true then it overwrite data otherwise add rows at the end of file.
5861 5861
  * @return bool true if success otherwise false.
5862 5862
  */
5863
-function geodir_save_csv_data( $file_path, $csv_data = array(), $clear = true ) {
5864
-	if ( empty( $csv_data ) ) {
5863
+function geodir_save_csv_data($file_path, $csv_data = array(), $clear = true) {
5864
+	if (empty($csv_data)) {
5865 5865
 		return false;
5866 5866
 	}
5867 5867
 	
@@ -5869,17 +5869,17 @@  discard block
 block discarded – undo
5869 5869
 	
5870 5870
 	$mode = $clear ? 'w+' : 'a+';
5871 5871
 	
5872
-	if ( function_exists( 'fputcsv' ) ) {
5873
-		$file = fopen( $file_path, $mode );
5874
-		foreach( $csv_data as $csv_row ) {
5872
+	if (function_exists('fputcsv')) {
5873
+		$file = fopen($file_path, $mode);
5874
+		foreach ($csv_data as $csv_row) {
5875 5875
 			//$csv_row = array_map( 'utf8_decode', $csv_row );
5876
-			$write_successful = fputcsv( $file, $csv_row, ",", $enclosure = '"' );
5876
+			$write_successful = fputcsv($file, $csv_row, ",", $enclosure = '"');
5877 5877
 		}
5878
-		fclose( $file );
5878
+		fclose($file);
5879 5879
 	} else {
5880
-		foreach( $csv_data as $csv_row ) {
5880
+		foreach ($csv_data as $csv_row) {
5881 5881
 			//$csv_row = array_map( 'utf8_decode', $csv_row );
5882
-			$wp_filesystem->put_contents( $file_path, $csv_row );
5882
+			$wp_filesystem->put_contents($file_path, $csv_row);
5883 5883
 		}
5884 5884
 	}
5885 5885
 		
@@ -5897,14 +5897,14 @@  discard block
 block discarded – undo
5897 5897
  * @param  string $file Full path to file.
5898 5898
  * @return int No of file rows.
5899 5899
  */
5900
-function geodir_import_export_line_count( $file ) {
5900
+function geodir_import_export_line_count($file) {
5901 5901
 	global $wp_filesystem;
5902 5902
 	
5903
-	if ( $wp_filesystem->is_file( $file ) && $wp_filesystem->exists( $file ) ) {
5904
-		$contents = $wp_filesystem->get_contents_array( $file );
5903
+	if ($wp_filesystem->is_file($file) && $wp_filesystem->exists($file)) {
5904
+		$contents = $wp_filesystem->get_contents_array($file);
5905 5905
 		
5906
-		if ( !empty( $contents ) && is_array( $contents ) ) {
5907
-			return count( $contents ) - 1;
5906
+		if (!empty($contents) && is_array($contents)) {
5907
+			return count($contents) - 1;
5908 5908
 		}
5909 5909
 	}
5910 5910
 	
@@ -5921,11 +5921,11 @@  discard block
 block discarded – undo
5921 5921
  * @param string $post_type The post type.
5922 5922
  * @return object Queried object.
5923 5923
  */
5924
-function geodir_imex_get_custom_fields( $post_type ) {
5924
+function geodir_imex_get_custom_fields($post_type) {
5925 5925
 	global $wpdb;
5926 5926
 	 
5927
-	$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 ) );
5928
-	$rows = $wpdb->get_results( $sql );
5927
+	$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));
5928
+	$rows = $wpdb->get_results($sql);
5929 5929
 	 
5930 5930
 	return $rows;
5931 5931
 }
@@ -6004,14 +6004,14 @@  discard block
 block discarded – undo
6004 6004
 	global $wpdb, $plugin_prefix;
6005 6005
 	
6006 6006
 	$post_type = get_post_type($master_post_id);
6007
-	$post_table = $plugin_prefix . $post_type . '_detail';
6007
+	$post_table = $plugin_prefix.$post_type.'_detail';
6008 6008
 	
6009
-	$query = $wpdb->prepare("SELECT * FROM " . $post_table . " WHERE post_id = %d", array($master_post_id));
6010
-	$data = (array)$wpdb->get_row($query);
6009
+	$query = $wpdb->prepare("SELECT * FROM ".$post_table." WHERE post_id = %d", array($master_post_id));
6010
+	$data = (array) $wpdb->get_row($query);
6011 6011
 	
6012
-	if ( !empty( $data ) ) {
6012
+	if (!empty($data)) {
6013 6013
 		$data['post_id'] = $tr_post_id;
6014
-		unset($data['default_category'], $data['marker_json'], $data['featured_image'], $data[$post_type . 'category'], $data['overall_rating'], $data['rating_count'], $data['ratings']);
6014
+		unset($data['default_category'], $data['marker_json'], $data['featured_image'], $data[$post_type.'category'], $data['overall_rating'], $data['rating_count'], $data['ratings']);
6015 6015
 		
6016 6016
 		$wpdb->update($post_table, $data, array('post_id' => $tr_post_id));		
6017 6017
 		return true;
@@ -6037,7 +6037,7 @@  discard block
 block discarded – undo
6037 6037
 	global $sitepress, $wpdb;
6038 6038
 	$post_type = get_post_type($master_post_id);
6039 6039
 	
6040
-	remove_filter('get_term', array($sitepress,'get_term_adjust_id')); // AVOID filtering to current language
6040
+	remove_filter('get_term', array($sitepress, 'get_term_adjust_id')); // AVOID filtering to current language
6041 6041
 
6042 6042
 	$taxonomies = get_object_taxonomies($post_type);
6043 6043
 	foreach ($taxonomies as $taxonomy) {
@@ -6046,9 +6046,9 @@  discard block
 block discarded – undo
6046 6046
 		
6047 6047
 		if ($terms) {
6048 6048
 			foreach ($terms as $term) {
6049
-				$tr_id = apply_filters( 'translate_object_id',$term->term_id, $taxonomy, false, $lang);
6049
+				$tr_id = apply_filters('translate_object_id', $term->term_id, $taxonomy, false, $lang);
6050 6050
 				
6051
-				if (!is_null($tr_id)){
6051
+				if (!is_null($tr_id)) {
6052 6052
 					// not using get_term - unfiltered get_term
6053 6053
 					$translated_term = $wpdb->get_row($wpdb->prepare("
6054 6054
 						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));
@@ -6057,14 +6057,14 @@  discard block
 block discarded – undo
6057 6057
 				}
6058 6058
 			}
6059 6059
 
6060
-			if (!is_taxonomy_hierarchical($taxonomy)){
6061
-				$terms_array = array_unique( array_map( 'intval', $terms_array ) );
6060
+			if (!is_taxonomy_hierarchical($taxonomy)) {
6061
+				$terms_array = array_unique(array_map('intval', $terms_array));
6062 6062
 			}
6063 6063
 
6064 6064
 			wp_set_post_terms($tr_post_id, $terms_array, $taxonomy);
6065 6065
 			
6066
-			if ($taxonomy == $post_type . 'category') {
6067
-				geodir_set_postcat_structure($tr_post_id, $post_type . 'category');
6066
+			if ($taxonomy == $post_type.'category') {
6067
+				geodir_set_postcat_structure($tr_post_id, $post_type.'category');
6068 6068
 			}
6069 6069
 		}
6070 6070
 	}
@@ -6085,15 +6085,15 @@  discard block
 block discarded – undo
6085 6085
 function geodir_icl_duplicate_post_images($master_post_id, $tr_post_id, $lang) {
6086 6086
 	global $wpdb;
6087 6087
 	
6088
-	$query = $wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d", array('%image%', $tr_post_id));
6088
+	$query = $wpdb->prepare("DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE mime_type like %s AND post_id = %d", array('%image%', $tr_post_id));
6089 6089
 	$wpdb->query($query);
6090 6090
 	
6091
-	$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));
6091
+	$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));
6092 6092
 	$post_images = $wpdb->get_results($query);
6093 6093
 	
6094
-	if ( !empty( $post_images ) ) {
6095
-		foreach ( $post_images as $post_image) {
6096
-			$image_data = (array)$post_image;
6094
+	if (!empty($post_images)) {
6095
+		foreach ($post_images as $post_image) {
6096
+			$image_data = (array) $post_image;
6097 6097
 			unset($image_data['ID']);
6098 6098
 			$image_data['post_id'] = $tr_post_id;
6099 6099
 			
@@ -6119,10 +6119,10 @@  discard block
 block discarded – undo
6119 6119
  * @return array Event data array.
6120 6120
  */
6121 6121
 function geodir_imex_get_event_data($post, $gd_post_info) {
6122
-	$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'] ) ) : '';
6122
+	$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'])) : '';
6123 6123
 	$event_enddate = $event_date;
6124
-	$starttime = isset( $post['starttime'] ) && $post['starttime'] != '' && $post['starttime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $post['starttime'] ) ) : '';
6125
-	$endtime = isset( $post['endtime'] ) && $post['endtime'] != '' && $post['endtime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $post['endtime'] ) ) : '';
6124
+	$starttime = isset($post['starttime']) && $post['starttime'] != '' && $post['starttime'] != '00:00:00' ? date_i18n('H:i', strtotime($post['starttime'])) : '';
6125
+	$endtime = isset($post['endtime']) && $post['endtime'] != '' && $post['endtime'] != '00:00:00' ? date_i18n('H:i', strtotime($post['endtime'])) : '';
6126 6126
 	
6127 6127
 	$is_recurring_event = '';
6128 6128
 	$event_duration_days = '';
@@ -6139,15 +6139,15 @@  discard block
 block discarded – undo
6139 6139
 		
6140 6140
 	$recurring_data = isset($gd_post_info->recurring_dates) ? maybe_unserialize($gd_post_info->recurring_dates) : array();
6141 6141
 	if (!empty($recurring_data)) {
6142
-		$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;
6143
-		$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;
6144
-		$starttime = isset( $recurring_data['starttime'] ) && $recurring_data['starttime'] != '' && $recurring_data['starttime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $recurring_data['starttime'] ) ) : $starttime;
6145
-		$endtime = isset( $recurring_data['endtime'] ) && $recurring_data['endtime'] != '' && $recurring_data['endtime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $recurring_data['endtime'] ) ) : $endtime;
6142
+		$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;
6143
+		$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;
6144
+		$starttime = isset($recurring_data['starttime']) && $recurring_data['starttime'] != '' && $recurring_data['starttime'] != '00:00:00' ? date_i18n('H:i', strtotime($recurring_data['starttime'])) : $starttime;
6145
+		$endtime = isset($recurring_data['endtime']) && $recurring_data['endtime'] != '' && $recurring_data['endtime'] != '00:00:00' ? date_i18n('H:i', strtotime($recurring_data['endtime'])) : $endtime;
6146 6146
 		$is_whole_day_event = !empty($recurring_data['all_day']) ? 1 : '';
6147 6147
 		$different_times = !empty($recurring_data['different_times']) ? true : false;
6148 6148
 	
6149
-		$recurring_pkg = geodir_event_recurring_pkg( $gd_post_info );
6150
-		$is_recurring = isset( $gd_post_info->is_recurring ) && (int)$gd_post_info->is_recurring == 0 ? false : true;
6149
+		$recurring_pkg = geodir_event_recurring_pkg($gd_post_info);
6150
+		$is_recurring = isset($gd_post_info->is_recurring) && (int) $gd_post_info->is_recurring == 0 ? false : true;
6151 6151
 			
6152 6152
 		if ($recurring_pkg && $is_recurring) {
6153 6153
 			$recurring_dates = $event_date;
@@ -6157,13 +6157,13 @@  discard block
 block discarded – undo
6157 6157
 			$recurring_type = !empty($recurring_data['repeat_type']) && in_array($recurring_data['repeat_type'], array('day', 'week', 'month', 'year', 'custom')) ? $recurring_data['repeat_type'] : 'custom';
6158 6158
 			
6159 6159
 			if (!empty($recurring_data['event_recurring_dates'])) {
6160
-				$event_recurring_dates = explode( ',', $recurring_data['event_recurring_dates'] );
6160
+				$event_recurring_dates = explode(',', $recurring_data['event_recurring_dates']);
6161 6161
 				
6162 6162
 				if (!empty($event_recurring_dates)) {
6163 6163
 					$recurring_dates = array();
6164 6164
 					
6165 6165
 					foreach ($event_recurring_dates as $date) {
6166
-						$recurring_dates[] = date_i18n( 'd/m/Y', strtotime( $date ) );
6166
+						$recurring_dates[] = date_i18n('d/m/Y', strtotime($date));
6167 6167
 					}
6168 6168
 					
6169 6169
 					$recurring_dates = implode(",", $recurring_dates);
@@ -6179,7 +6179,7 @@  discard block
 block discarded – undo
6179 6179
 						$times = array();
6180 6180
 						
6181 6181
 						foreach ($recurring_data['starttimes'] as $time) {
6182
-							$times[] = $time != '00:00:00' ? date_i18n( 'H:i', strtotime( $time ) ) : '00:00';
6182
+							$times[] = $time != '00:00:00' ? date_i18n('H:i', strtotime($time)) : '00:00';
6183 6183
 						}
6184 6184
 						
6185 6185
 						$event_starttimes = implode(",", $times);
@@ -6189,7 +6189,7 @@  discard block
 block discarded – undo
6189 6189
 						$times = array();
6190 6190
 						
6191 6191
 						foreach ($recurring_data['endtimes'] as $time) {
6192
-							$times[] = $time != '00:00:00' ? date_i18n( 'H:i', strtotime( $time ) ) : '00:00';
6192
+							$times[] = $time != '00:00:00' ? date_i18n('H:i', strtotime($time)) : '00:00';
6193 6193
 						}
6194 6194
 						
6195 6195
 						$event_endtimes = implode(",", $times);
@@ -6201,8 +6201,8 @@  discard block
 block discarded – undo
6201 6201
 					}
6202 6202
 				}
6203 6203
 			} else {
6204
-				$event_duration_days = isset($recurring_data['duration_x']) ? (int)$recurring_data['duration_x'] : 1;
6205
-				$recurring_interval = !empty($recurring_data['repeat_x']) && (int)$recurring_data['repeat_x'] > 0 ? $recurring_data['repeat_x'] : 1;
6204
+				$event_duration_days = isset($recurring_data['duration_x']) ? (int) $recurring_data['duration_x'] : 1;
6205
+				$recurring_interval = !empty($recurring_data['repeat_x']) && (int) $recurring_data['repeat_x'] > 0 ? $recurring_data['repeat_x'] : 1;
6206 6206
 				
6207 6207
 				if (($recurring_type == 'week' || $recurring_type == 'month') && !empty($recurring_data['repeat_days'])) {
6208 6208
 					$week_days = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
@@ -6218,11 +6218,11 @@  discard block
 block discarded – undo
6218 6218
 				}
6219 6219
 				
6220 6220
 				$recurring_week_nos = $recurring_type == 'month' && !empty($recurring_data['repeat_weeks']) ? implode(",", $recurring_data['repeat_weeks']) : $recurring_week_nos;
6221
-				if (!empty($recurring_data['repeat_end_type']) && (int)$recurring_data['repeat_end_type'] == 1) {
6222
-					$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'] ) ) : '';
6221
+				if (!empty($recurring_data['repeat_end_type']) && (int) $recurring_data['repeat_end_type'] == 1) {
6222
+					$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'])) : '';
6223 6223
 					$max_recurring_count = empty($recurring_end_date) ? 1 : '';
6224 6224
 				} else {
6225
-					$max_recurring_count = (!empty($recurring_data['max_repeat']) && (int)$recurring_data['max_repeat'] > 0 ? (int)$recurring_data['max_repeat'] : 1);
6225
+					$max_recurring_count = (!empty($recurring_data['max_repeat']) && (int) $recurring_data['max_repeat'] > 0 ? (int) $recurring_data['max_repeat'] : 1);
6226 6226
 				}
6227 6227
 			}
6228 6228
 		}
@@ -6286,9 +6286,9 @@  discard block
 block discarded – undo
6286 6286
  * @return array Event data array.
6287 6287
  */
6288 6288
 function geodir_imex_process_event_data($gd_post) {
6289
-	$recurring_pkg = geodir_event_recurring_pkg( (object)$gd_post );
6289
+	$recurring_pkg = geodir_event_recurring_pkg((object) $gd_post);
6290 6290
 
6291
-	$is_recurring = isset( $gd_post['is_recurring_event'] ) && (int)$gd_post['is_recurring_event'] == 0 ? false : true;
6291
+	$is_recurring = isset($gd_post['is_recurring_event']) && (int) $gd_post['is_recurring_event'] == 0 ? false : true;
6292 6292
 	$event_date = isset($gd_post['event_date']) && $gd_post['event_date'] != '' ? geodir_imex_get_date_ymd($gd_post['event_date']) : '';
6293 6293
 	$event_enddate = isset($gd_post['event_enddate']) && $gd_post['event_enddate'] != '' ? geodir_imex_get_date_ymd($gd_post['event_enddate']) : $event_date;
6294 6294
 	$all_day = isset($gd_post['is_whole_day_event']) && !empty($gd_post['is_whole_day_event']) ? true : false;
@@ -6335,17 +6335,17 @@  discard block
 block discarded – undo
6335 6335
 				$event_recurring_dates = implode(",", $event_recurring_dates);
6336 6336
 			}
6337 6337
 		} else {
6338
-			$duration_x = !empty( $gd_post['event_duration_days'] ) ? (int)$gd_post['event_duration_days'] : 1;
6339
-			$repeat_x = !empty( $gd_post['recurring_interval'] ) ? (int)$gd_post['recurring_interval'] : 1;
6340
-			$max_repeat = !empty( $gd_post['max_recurring_count'] ) ? (int)$gd_post['max_recurring_count'] : 1;
6341
-			$repeat_end = !empty( $gd_post['recurring_end_date'] ) ? geodir_imex_get_date_ymd($gd_post['recurring_end_date']) : '';
6338
+			$duration_x = !empty($gd_post['event_duration_days']) ? (int) $gd_post['event_duration_days'] : 1;
6339
+			$repeat_x = !empty($gd_post['recurring_interval']) ? (int) $gd_post['recurring_interval'] : 1;
6340
+			$max_repeat = !empty($gd_post['max_recurring_count']) ? (int) $gd_post['max_recurring_count'] : 1;
6341
+			$repeat_end = !empty($gd_post['recurring_end_date']) ? geodir_imex_get_date_ymd($gd_post['recurring_end_date']) : '';
6342 6342
 			
6343 6343
 			$repeat_end_type = $repeat_end != '' ? 1 : 0;
6344 6344
 			$max_repeat = $repeat_end != '' ? '' : $max_repeat;
6345 6345
 			
6346 6346
 			$week_days = array_flip(array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'));
6347 6347
 			
6348
-			$a_repeat_days = isset($gd_post['recurring_week_days']) && trim($gd_post['recurring_week_days'])!='' ? explode(',', trim($gd_post['recurring_week_days'])) : array();
6348
+			$a_repeat_days = isset($gd_post['recurring_week_days']) && trim($gd_post['recurring_week_days']) != '' ? explode(',', trim($gd_post['recurring_week_days'])) : array();
6349 6349
 			$repeat_days = array();
6350 6350
 			if (!empty($a_repeat_days)) {
6351 6351
 				foreach ($a_repeat_days as $repeat_day) {
@@ -6363,7 +6363,7 @@  discard block
 block discarded – undo
6363 6363
 			$repeat_weeks = array();
6364 6364
 			if (!empty($a_repeat_weeks)) {
6365 6365
 				foreach ($a_repeat_weeks as $repeat_week) {
6366
-					$repeat_weeks[] = (int)$repeat_week;
6366
+					$repeat_weeks[] = (int) $repeat_week;
6367 6367
 				}
6368 6368
 				
6369 6369
 				$repeat_weeks = array_unique($repeat_weeks);
@@ -6427,7 +6427,7 @@  discard block
 block discarded – undo
6427 6427
 
6428 6428
     $page_found = $wpdb->get_var(
6429 6429
         $wpdb->prepare(
6430
-            "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
6430
+            "SELECT ID FROM ".$wpdb->posts." WHERE post_name = %s LIMIT 1;",
6431 6431
             array($slug)
6432 6432
         )
6433 6433
     );
@@ -6482,7 +6482,7 @@  discard block
 block discarded – undo
6482 6482
  */
6483 6483
 function geodir_admin_upgrade_notice() {
6484 6484
     $class = "error";
6485
-    $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
6485
+    $message = __("Please update core GeoDirectory or some addons may not function correctly.", "geodirectory");
6486 6486
     echo"<div class=\"$class\"> <p>$message</p></div>";
6487 6487
 }
6488 6488
 
@@ -6494,7 +6494,7 @@  discard block
 block discarded – undo
6494 6494
  * @param (object) $r
6495 6495
  * @return (string) $output
6496 6496
  */
6497
-function geodire_admin_upgrade_notice( $plugin_data, $r )
6497
+function geodire_admin_upgrade_notice($plugin_data, $r)
6498 6498
 {
6499 6499
     // readme contents
6500 6500
     $args = array(
@@ -6502,7 +6502,7 @@  discard block
 block discarded – undo
6502 6502
         'redirection' => 5
6503 6503
     );
6504 6504
     $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt";
6505
-    $data       = wp_remote_get( $url, $args );
6505
+    $data = wp_remote_get($url, $args);
6506 6506
 
6507 6507
     if (!is_wp_error($data) && $data['response']['code'] == 200) {
6508 6508
 
@@ -6517,20 +6517,20 @@  discard block
 block discarded – undo
6517 6517
 function geodir_in_plugin_update_message($content) {
6518 6518
     // Output Upgrade Notice
6519 6519
     $matches        = null;
6520
-    $regexp         = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis';
6520
+    $regexp         = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*'.preg_quote(GEODIRECTORY_VERSION).'\s*=|$)~Uis';
6521 6521
     $upgrade_notice = '';
6522
-    if ( preg_match( $regexp, $content, $matches ) ) {
6523
-        if(empty($matches)){return;}
6522
+    if (preg_match($regexp, $content, $matches)) {
6523
+        if (empty($matches)) {return; }
6524 6524
 
6525
-        $version = trim( $matches[1] );
6526
-        if($version && $version>GEODIRECTORY_VERSION){
6525
+        $version = trim($matches[1]);
6526
+        if ($version && $version > GEODIRECTORY_VERSION) {
6527 6527
 
6528 6528
 
6529
-        $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
6530
-        if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
6529
+        $notices = (array) preg_split('~[\r\n]+~', trim($matches[2]));
6530
+        if (version_compare(GEODIRECTORY_VERSION, $version, '<')) {
6531 6531
             $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">';
6532
-            foreach ( $notices as $index => $line ) {
6533
-                $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
6532
+            foreach ($notices as $index => $line) {
6533
+                $upgrade_notice .= wp_kses_post(preg_replace('~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line));
6534 6534
             }
6535 6535
             $upgrade_notice .= '</div> ';
6536 6536
         }
@@ -6554,7 +6554,7 @@  discard block
 block discarded – undo
6554 6554
 		$default_language = $sitepress->get_default_language();
6555 6555
 		if ($current_language != 'all' && $current_language != $default_language) {
6556 6556
 	?>
6557
-	<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>
6557
+	<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>
6558 6558
 	<?php
6559 6559
 		}
6560 6560
 	}
@@ -6569,7 +6569,7 @@  discard block
 block discarded – undo
6569 6569
  * @param array Listing statuses to be skipped.
6570 6570
  */
6571 6571
 function geodir_imex_export_skip_statuses() {
6572
-    $statuses = array( 'trash', 'auto-draft' );
6572
+    $statuses = array('trash', 'auto-draft');
6573 6573
     
6574 6574
     /**
6575 6575
      * Filter the statuses to skip during GD export listings.
@@ -6579,7 +6579,7 @@  discard block
 block discarded – undo
6579 6579
      *
6580 6580
      * @param array $statuses Listing statuses to be skipped.
6581 6581
      */
6582
-    $statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses );
6582
+    $statuses = apply_filters('geodir_imex_export_skip_statuses', $statuses);
6583 6583
      
6584 6584
     return $statuses;
6585 6585
 }
Please login to merge, or discard this patch.
Indentation   +2817 added lines, -2817 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,124 +32,124 @@  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
-            /** This filter is documented in geodirectory_template_tags.php */
131
-            $map_extra = apply_filters('geodir_googlemap_script_extra', '');
132
-            wp_enqueue_script('geodirectory-googlemap-script', '//maps.google.com/maps/api/js?' . $map_lang . $map_extra, '', NULL);
133
-        }
128
+		if (in_array($geodir_map_name, array('auto', 'google'))) {
129
+			$map_lang = "&language=" . geodir_get_map_default_language();
130
+			/** This filter is documented in geodirectory_template_tags.php */
131
+			$map_extra = apply_filters('geodir_googlemap_script_extra', '');
132
+			wp_enqueue_script('geodirectory-googlemap-script', '//maps.google.com/maps/api/js?' . $map_lang . $map_extra, '', NULL);
133
+		}
134 134
         
135
-        if ($geodir_map_name == 'osm') {
136
-            // Leaflet OpenStreetMap
137
-            wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
138
-            wp_enqueue_style('geodirectory-leaflet-style');
135
+		if ($geodir_map_name == 'osm') {
136
+			// Leaflet OpenStreetMap
137
+			wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
138
+			wp_enqueue_style('geodirectory-leaflet-style');
139 139
                 
140
-            wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
141
-            wp_enqueue_script('geodirectory-leaflet-script');
140
+			wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
141
+			wp_enqueue_script('geodirectory-leaflet-script');
142 142
             
143
-            wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
144
-            wp_enqueue_script('geodirectory-leaflet-geo-script');
145
-        }
146
-        wp_enqueue_script( 'jquery-ui-autocomplete' );
143
+			wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
144
+			wp_enqueue_script('geodirectory-leaflet-geo-script');
145
+		}
146
+		wp_enqueue_script( 'jquery-ui-autocomplete' );
147 147
         
148
-        wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true);
149
-        wp_enqueue_script('geodirectory-goMap-script');
148
+		wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true);
149
+		wp_enqueue_script('geodirectory-goMap-script');
150 150
 
151
-        wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
152
-        wp_enqueue_script('geodirectory-goMap-script');
151
+		wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
152
+		wp_enqueue_script('geodirectory-goMap-script');
153 153
 
154 154
 		// font awesome rating script
155 155
 		if (get_option('geodir_reviewrating_enable_font_awesome')) {
@@ -160,167 +160,167 @@  discard block
 block discarded – undo
160 160
 			wp_enqueue_script('geodir-jRating-js');
161 161
 		}
162 162
 
163
-        wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.js', array(), GEODIRECTORY_VERSION);
164
-        wp_enqueue_script('geodir-on-document-load');
165
-
166
-
167
-        // SCRIPT FOR UPLOAD
168
-        wp_enqueue_script('plupload-all');
169
-        wp_enqueue_script('jquery-ui-sortable');
170
-
171
-        wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
172
-        wp_enqueue_script('geodirectory-plupload-script');
173
-
174
-        // SCRIPT FOR UPLOAD END
175
-
176
-
177
-        // place js config array for plupload
178
-        $plupload_init = array(
179
-            'runtimes' => 'html5,silverlight,flash,html4',
180
-            'browse_button' => 'plupload-browse-button', // will be adjusted per uploader
181
-            'container' => 'plupload-upload-ui', // will be adjusted per uploader
182
-            'drop_element' => 'dropbox', // will be adjusted per uploader
183
-            'file_data_name' => 'async-upload', // will be adjusted per uploader
184
-            'multiple_queues' => true,
185
-            'max_file_size' => geodir_max_upload_size(),
186
-            'url' => admin_url('admin-ajax.php'),
187
-            'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
188
-            'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
189
-            'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
190
-            'multipart' => true,
191
-            'urlstream_upload' => true,
192
-            'multi_selection' => false, // will be added per uploader
193
-            // additional post data to send to our ajax hook
194
-            'multipart_params' => array(
195
-                '_ajax_nonce' => "", // will be added per uploader
196
-                'action' => 'plupload_action', // the ajax action name
197
-                'imgid' => 0 // will be added per uploader
198
-            )
199
-        );
200
-        $base_plupload_config = json_encode($plupload_init);
201
-
202
-
203
-        $thumb_img_arr = array();
204
-
205
-        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
206
-            $thumb_img_arr = geodir_get_images($_REQUEST['pid']);
207
-
208
-        $totImg = '';
209
-        $image_limit = '';
210
-        if (!empty($thumb_img_arr)) {
211
-            $totImg = count($thumb_img_arr);
212
-        }
163
+		wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.js', array(), GEODIRECTORY_VERSION);
164
+		wp_enqueue_script('geodir-on-document-load');
165
+
166
+
167
+		// SCRIPT FOR UPLOAD
168
+		wp_enqueue_script('plupload-all');
169
+		wp_enqueue_script('jquery-ui-sortable');
170
+
171
+		wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
172
+		wp_enqueue_script('geodirectory-plupload-script');
173
+
174
+		// SCRIPT FOR UPLOAD END
175
+
176
+
177
+		// place js config array for plupload
178
+		$plupload_init = array(
179
+			'runtimes' => 'html5,silverlight,flash,html4',
180
+			'browse_button' => 'plupload-browse-button', // will be adjusted per uploader
181
+			'container' => 'plupload-upload-ui', // will be adjusted per uploader
182
+			'drop_element' => 'dropbox', // will be adjusted per uploader
183
+			'file_data_name' => 'async-upload', // will be adjusted per uploader
184
+			'multiple_queues' => true,
185
+			'max_file_size' => geodir_max_upload_size(),
186
+			'url' => admin_url('admin-ajax.php'),
187
+			'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
188
+			'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
189
+			'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
190
+			'multipart' => true,
191
+			'urlstream_upload' => true,
192
+			'multi_selection' => false, // will be added per uploader
193
+			// additional post data to send to our ajax hook
194
+			'multipart_params' => array(
195
+				'_ajax_nonce' => "", // will be added per uploader
196
+				'action' => 'plupload_action', // the ajax action name
197
+				'imgid' => 0 // will be added per uploader
198
+			)
199
+		);
200
+		$base_plupload_config = json_encode($plupload_init);
201
+
202
+
203
+		$thumb_img_arr = array();
204
+
205
+		if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
206
+			$thumb_img_arr = geodir_get_images($_REQUEST['pid']);
207
+
208
+		$totImg = '';
209
+		$image_limit = '';
210
+		if (!empty($thumb_img_arr)) {
211
+			$totImg = count($thumb_img_arr);
212
+		}
213 213
 
214
-        $gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
215
-            'totalImg' => $totImg,
216
-            'image_limit' => $image_limit,
217
-            'upload_img_size' => geodir_max_upload_size());
214
+		$gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
215
+			'totalImg' => $totImg,
216
+			'image_limit' => $image_limit,
217
+			'upload_img_size' => geodir_max_upload_size());
218 218
 
219
-        wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
219
+		wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
220 220
 
221
-        $ajax_cons_data = array('url' => __(admin_url('admin-ajax.php')));
222
-        wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data);
221
+		$ajax_cons_data = array('url' => __(admin_url('admin-ajax.php')));
222
+		wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data);
223 223
 
224 224
 
225
-        wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
226
-        wp_enqueue_script('geodirectory-admin-script');
225
+		wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
226
+		wp_enqueue_script('geodirectory-admin-script');
227 227
 
228
-        wp_enqueue_style('farbtastic');
229
-        wp_enqueue_script('farbtastic');
228
+		wp_enqueue_style('farbtastic');
229
+		wp_enqueue_script('farbtastic');
230 230
 
231
-        $screen = get_current_screen();
232
-        if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) {
233
-            wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js');
234
-        }
231
+		$screen = get_current_screen();
232
+		if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) {
233
+			wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js');
234
+		}
235 235
 
236
-        $ajax_cons_data = array('url' => __(get_option('siteurl') . '?geodir_ajax=true'));
237
-        wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data);
236
+		$ajax_cons_data = array('url' => __(get_option('siteurl') . '?geodir_ajax=true'));
237
+		wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data);
238 238
 
239
-    }
239
+	}
240 240
 }
241 241
 
242 242
 if (!function_exists('geodir_admin_menu')) {
243
-    /**
244
-     * Admin Menus
245
-     *
246
-     * Sets up the admin menus in wordpress.
247
-     *
248
-     * @since 1.0.0
249
-     * @package GeoDirectory
250
-     * @global array $menu Menu array.
251
-     * @global object $geodirectory GeoDirectory plugin object.
252
-     */
253
-    function geodir_admin_menu()
254
-    {
255
-        global $menu, $geodirectory;
243
+	/**
244
+	 * Admin Menus
245
+	 *
246
+	 * Sets up the admin menus in wordpress.
247
+	 *
248
+	 * @since 1.0.0
249
+	 * @package GeoDirectory
250
+	 * @global array $menu Menu array.
251
+	 * @global object $geodirectory GeoDirectory plugin object.
252
+	 */
253
+	function geodir_admin_menu()
254
+	{
255
+		global $menu, $geodirectory;
256 256
 
257
-        if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
257
+		if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
258 258
 
259
-        add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
259
+		add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
260 260
 
261 261
 
262
-    }
262
+	}
263 263
 }
264 264
 
265 265
 if (!function_exists('geodir_admin_menu_order')) {
266
-    /**
267
-     * Order admin menus.
268
-     *
269
-     * @since 1.0.0
270
-     * @package GeoDirectory
271
-     * @param array $menu_order Menu order array.
272
-     * @return array Modified menu order array.
273
-     */
274
-    function geodir_admin_menu_order($menu_order)
275
-    {
276
-
277
-        // Initialize our custom order array
278
-        $geodir_menu_order = array();
279
-
280
-        // Get the index of our custom separator
281
-        $geodir_separator = array_search('separator-geodirectory', $menu_order);
282
-
283
-        // Get index of posttype menu
284
-        $post_types = geodir_get_posttypes();
285
-
286
-        // Loop through menu order and do some rearranging
287
-        foreach ($menu_order as $index => $item) :
288
-
289
-            if ((('geodirectory') == $item)) :
290
-                $geodir_menu_order[] = 'separator-geodirectory';
291
-                if (!empty($post_types)) {
292
-                    foreach ($post_types as $post_type) {
293
-                        $geodir_menu_order[] = 'edit.php?post_type=' . $post_type;
294
-                    }
295
-                }
296
-                $geodir_menu_order[] = $item;
266
+	/**
267
+	 * Order admin menus.
268
+	 *
269
+	 * @since 1.0.0
270
+	 * @package GeoDirectory
271
+	 * @param array $menu_order Menu order array.
272
+	 * @return array Modified menu order array.
273
+	 */
274
+	function geodir_admin_menu_order($menu_order)
275
+	{
297 276
 
298
-                unset($menu_order[$geodir_separator]);
299
-            //unset( $menu_order[$geodir_places] );
300
-            elseif (!in_array($item, array('separator-geodirectory'))) :
301
-                $geodir_menu_order[] = $item;
302
-            endif;
277
+		// Initialize our custom order array
278
+		$geodir_menu_order = array();
303 279
 
304
-        endforeach;
280
+		// Get the index of our custom separator
281
+		$geodir_separator = array_search('separator-geodirectory', $menu_order);
305 282
 
306
-        // Return order
307
-        return $geodir_menu_order;
308
-    }
283
+		// Get index of posttype menu
284
+		$post_types = geodir_get_posttypes();
285
+
286
+		// Loop through menu order and do some rearranging
287
+		foreach ($menu_order as $index => $item) :
288
+
289
+			if ((('geodirectory') == $item)) :
290
+				$geodir_menu_order[] = 'separator-geodirectory';
291
+				if (!empty($post_types)) {
292
+					foreach ($post_types as $post_type) {
293
+						$geodir_menu_order[] = 'edit.php?post_type=' . $post_type;
294
+					}
295
+				}
296
+				$geodir_menu_order[] = $item;
297
+
298
+				unset($menu_order[$geodir_separator]);
299
+			//unset( $menu_order[$geodir_places] );
300
+			elseif (!in_array($item, array('separator-geodirectory'))) :
301
+				$geodir_menu_order[] = $item;
302
+			endif;
303
+
304
+		endforeach;
305
+
306
+		// Return order
307
+		return $geodir_menu_order;
308
+	}
309 309
 }
310 310
 
311 311
 if (!function_exists('geodir_admin_custom_menu_order')) {
312
-    /**
313
-     * Enables custom menu order.
314
-     *
315
-     * @since 1.0.0
316
-     * @package GeoDirectory
317
-     * @return bool
318
-     */
319
-    function geodir_admin_custom_menu_order()
320
-    {
321
-        if (!current_user_can('manage_options')) return false;
322
-        return true;
323
-    }
312
+	/**
313
+	 * Enables custom menu order.
314
+	 *
315
+	 * @since 1.0.0
316
+	 * @package GeoDirectory
317
+	 * @return bool
318
+	 */
319
+	function geodir_admin_custom_menu_order()
320
+	{
321
+		if (!current_user_can('manage_options')) return false;
322
+		return true;
323
+	}
324 324
 }
325 325
 
326 326
 /**
@@ -331,41 +331,41 @@  discard block
 block discarded – undo
331 331
  */
332 332
 function geodir_before_admin_panel()
333 333
 {
334
-    if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') {
335
-        echo '<div id="message" class="updated fade">
334
+	if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') {
335
+		echo '<div id="message" class="updated fade">
336 336
                         <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>
337 337
                         <p><strong>' . __('Geodirectory has been installed and setup. Enjoy :)', 'geodirectory') . '</strong></p>
338 338
                 </div>';
339 339
 
340
-    }
340
+	}
341 341
 
342
-    if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') {
343
-        switch ($_REQUEST['msg']) {
344
-            case 'success':
345
-                echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>';
346
-                flush_rewrite_rules(false);
342
+	if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') {
343
+		switch ($_REQUEST['msg']) {
344
+			case 'success':
345
+				echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>';
346
+				flush_rewrite_rules(false);
347 347
 
348
-                break;
348
+				break;
349 349
 			case 'fail':
350 350
 				$gderr = isset($_REQUEST['gderr']) ? $_REQUEST['gderr'] : '';
351 351
 				
352 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>';
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 354
 				else
355 355
 					echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>';
356
-                break;
357
-        }
358
-    }
356
+				break;
357
+		}
358
+	}
359 359
 
360
-    if (!geodir_is_default_location_set()) {
361
-        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>';
360
+	if (!geodir_is_default_location_set()) {
361
+		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>';
362 362
 
363
-    }
363
+	}
364 364
 
365
-    if (!function_exists('curl_init')) {
366
-        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>';
365
+	if (!function_exists('curl_init')) {
366
+		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>';
367 367
 
368
-    }
368
+	}
369 369
 }
370 370
 
371 371
 /**
@@ -378,19 +378,19 @@  discard block
 block discarded – undo
378 378
  */
379 379
 function geodir_handle_option_form_submit($current_tab)
380 380
 {
381
-    global $geodir_settings;
382
-    if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
383
-        /**
384
-         * Contains settings array for current tab.
385
-         *
386
-         * @since 1.0.0
387
-         * @package GeoDirectory
388
-         */
389
-        include_once('option-pages/' . $current_tab . '_array.php');
390
-    }
391
-    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'));
381
+	global $geodir_settings;
382
+	if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
383
+		/**
384
+		 * Contains settings array for current tab.
385
+		 *
386
+		 * @since 1.0.0
387
+		 * @package GeoDirectory
388
+		 */
389
+		include_once('option-pages/' . $current_tab . '_array.php');
390
+	}
391
+	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'));
394 394
 		
395 395
 		/**
396 396
 		 * Fires before updating geodirectory admin settings.
@@ -402,98 +402,98 @@  discard block
 block discarded – undo
402 402
 		 */
403 403
 		do_action('geodir_before_update_options', $current_tab, $geodir_settings);		
404 404
 		
405
-        if (!empty($geodir_settings[$current_tab]))
406
-            geodir_update_options($geodir_settings[$current_tab]);
405
+		if (!empty($geodir_settings[$current_tab]))
406
+			geodir_update_options($geodir_settings[$current_tab]);
407 407
 
408
-        /**
409
-         * Called after GeoDirectory options settings are updated.
410
-         *
411
-         * @since 1.0.0
412
-         * @param array $geodir_settings The array of GeoDirectory settings.
413
-         * @see 'geodir_before_update_options'
414
-         */
415
-        do_action('geodir_update_options', $geodir_settings);
408
+		/**
409
+		 * Called after GeoDirectory options settings are updated.
410
+		 *
411
+		 * @since 1.0.0
412
+		 * @param array $geodir_settings The array of GeoDirectory settings.
413
+		 * @see 'geodir_before_update_options'
414
+		 */
415
+		do_action('geodir_update_options', $geodir_settings);
416 416
 
417
-        /**
418
-         * Called after GeoDirectory options settings are updated.
419
-         *
420
-         * Provides tab specific settings.
421
-         *
422
-         * @since 1.0.0
423
-         * @param string $current_tab The current settings tab name.
424
-         * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab.
425
-         */
426
-        do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
417
+		/**
418
+		 * Called after GeoDirectory options settings are updated.
419
+		 *
420
+		 * Provides tab specific settings.
421
+		 *
422
+		 * @since 1.0.0
423
+		 * @param string $current_tab The current settings tab name.
424
+		 * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab.
425
+		 */
426
+		do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
427 427
 
428
-        flush_rewrite_rules(false);
428
+		flush_rewrite_rules(false);
429 429
 
430
-        $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : '';
430
+		$current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : '';
431 431
 
432
-        $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
432
+		$redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
433 433
 
434
-        wp_redirect($redirect_url);
435
-        exit();
436
-    endif;
434
+		wp_redirect($redirect_url);
435
+		exit();
436
+	endif;
437 437
 
438 438
 
439 439
 }
440 440
 
441 441
 
442 442
 if (!function_exists('geodir_autoinstall_admin_header') && (get_option('geodir_installed') || defined( 'GD_TESTING_MODE' ))) {
443
-    /**
444
-     * GeoDirectory dummy data installation.
445
-     *
446
-     * @since 1.0.0
447
-     * @package GeoDirectory
448
-     * @global object $wpdb WordPress Database object.
449
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
450
-     * @param string $post_type The post type.
451
-     */
452
-    function geodir_autoinstall_admin_header($post_type = 'gd_place')
453
-    {
443
+	/**
444
+	 * GeoDirectory dummy data installation.
445
+	 *
446
+	 * @since 1.0.0
447
+	 * @package GeoDirectory
448
+	 * @global object $wpdb WordPress Database object.
449
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
450
+	 * @param string $post_type The post type.
451
+	 */
452
+	function geodir_autoinstall_admin_header($post_type = 'gd_place')
453
+	{
454 454
 
455
-        global $wpdb, $plugin_prefix;
455
+		global $wpdb, $plugin_prefix;
456 456
 
457
-        if (!geodir_is_default_location_set()) {
458
-            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>';
459
-        } else {
457
+		if (!geodir_is_default_location_set()) {
458
+			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>';
459
+		} else {
460 460
 
461
-            $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab=';
461
+			$geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab=';
462 462
 
463
-            $post_counts = $wpdb->get_var("SELECT count(post_id) FROM " . $plugin_prefix . $post_type . "_detail WHERE post_dummy='1'");
463
+			$post_counts = $wpdb->get_var("SELECT count(post_id) FROM " . $plugin_prefix . $post_type . "_detail WHERE post_dummy='1'");
464 464
 
465
-            if ($post_counts > 0) {
466
-                $nonce = wp_create_nonce('geodir_dummy_posts_delete_noncename');
465
+			if ($post_counts > 0) {
466
+				$nonce = wp_create_nonce('geodir_dummy_posts_delete_noncename');
467 467
 
468
-                $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>';
469
-                $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>';
470
-            } else {
471
-                $options_list = '';
472
-                for ($option = 1; $option <= 30; $option++) {
473
-                    $selected = '';
474
-                    if ($option == 10)
475
-                        $selected = 'selected="selected"';
468
+				$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>';
469
+				$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>';
470
+			} else {
471
+				$options_list = '';
472
+				for ($option = 1; $option <= 30; $option++) {
473
+					$selected = '';
474
+					if ($option == 10)
475
+						$selected = 'selected="selected"';
476 476
 
477
-                    $options_list .= '<option ' . $selected . ' value="' . $option . '">' . $option . '</option>';
478
-                }
477
+					$options_list .= '<option ' . $selected . ' value="' . $option . '">' . $option . '</option>';
478
+				}
479 479
 
480
-                $nonce = wp_create_nonce('geodir_dummy_posts_insert_noncename');
480
+				$nonce = wp_create_nonce('geodir_dummy_posts_insert_noncename');
481 481
 
482
-                $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>';
483
-                $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>';
482
+				$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>';
483
+				$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>';
484 484
 
485
-            }
486
-            echo $dummy_msg;
487
-            ?>
485
+			}
486
+			echo $dummy_msg;
487
+			?>
488 488
             <script>
489 489
                 <?php
490
-                  $default_location = geodir_get_default_location();
491
-                  $city =  isset($default_location->city) ? $default_location->city : '';
492
-                  $region =isset($default_location->region) ? $default_location->region : '';
493
-                  $country =isset($default_location->country) ? $default_location->country : '';
494
-                  $city_latitude =isset($default_location->city_latitude) ? $default_location->city_latitude : '';
495
-                  $city_longitude =isset($default_location->city_longitude) ? $default_location->city_longitude : '';
496
-                ?>
490
+				  $default_location = geodir_get_default_location();
491
+				  $city =  isset($default_location->city) ? $default_location->city : '';
492
+				  $region =isset($default_location->region) ? $default_location->region : '';
493
+				  $country =isset($default_location->country) ? $default_location->country : '';
494
+				  $city_latitude =isset($default_location->city_latitude) ? $default_location->city_latitude : '';
495
+				  $city_longitude =isset($default_location->city_longitude) ? $default_location->city_longitude : '';
496
+				?>
497 497
                 var geocoder = window.gdMaps == 'google' ? new google.maps.Geocoder() : null;
498 498
                 var CITY_ADDRESS = '<?php echo $city.','.$region.','.$country;?>';
499 499
                 var bound_lat_lng;
@@ -584,8 +584,8 @@  discard block
 block discarded – undo
584 584
                 }
585 585
             </script>
586 586
         <?php
587
-        }
588
-    }
587
+		}
588
+	}
589 589
 }
590 590
 
591 591
 /**
@@ -598,20 +598,20 @@  discard block
 block discarded – undo
598 598
  */
599 599
 function geodir_insert_dummy_posts()
600 600
 {
601
-    geodir_default_taxonomies();
601
+	geodir_default_taxonomies();
602 602
 
603
-    ini_set('max_execution_time', 999999); //300 seconds = 5 minutes
603
+	ini_set('max_execution_time', 999999); //300 seconds = 5 minutes
604 604
 
605
-    global $wpdb, $current_user;
605
+	global $wpdb, $current_user;
606 606
 
607
-    /**
608
-     * Contains dummy post content.
609
-     *
610
-     * @since 1.0.0
611
-     * @package GeoDirectory
612
-     */
613
-    include_once('place_dummy_post.php');
614
-    delete_transient( 'cached_dummy_images' );
607
+	/**
608
+	 * Contains dummy post content.
609
+	 *
610
+	 * @since 1.0.0
611
+	 * @package GeoDirectory
612
+	 */
613
+	include_once('place_dummy_post.php');
614
+	delete_transient( 'cached_dummy_images' );
615 615
 
616 616
 }
617 617
 
@@ -625,18 +625,18 @@  discard block
 block discarded – undo
625 625
  */
626 626
 function geodir_delete_dummy_posts()
627 627
 {
628
-    global $wpdb, $plugin_prefix;
628
+	global $wpdb, $plugin_prefix;
629 629
 
630 630
 
631
-    $post_ids = $wpdb->get_results("SELECT post_id FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
631
+	$post_ids = $wpdb->get_results("SELECT post_id FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
632 632
 
633 633
 
634
-    foreach ($post_ids as $post_ids_obj) {
635
-        wp_delete_post($post_ids_obj->post_id);
636
-    }
634
+	foreach ($post_ids as $post_ids_obj) {
635
+		wp_delete_post($post_ids_obj->post_id);
636
+	}
637 637
 
638
-    //double check posts are deleted
639
-    $wpdb->get_results("DELETE FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
638
+	//double check posts are deleted
639
+	$wpdb->get_results("DELETE FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
640 640
 }
641 641
 
642 642
 /**
@@ -650,114 +650,114 @@  discard block
 block discarded – undo
650 650
  * @global string $dummy_image_path The dummy image path.
651 651
  */
652 652
 function geodir_default_taxonomies() {
653
-    global $wpdb, $dummy_image_path;
653
+	global $wpdb, $dummy_image_path;
654 654
 
655
-    $category_array = array('Attractions', 'Hotels', 'Restaurants', 'Food Nightlife', 'Festival', 'Videos', 'Feature');
655
+	$category_array = array('Attractions', 'Hotels', 'Restaurants', 'Food Nightlife', 'Festival', 'Videos', 'Feature');
656 656
 
657
-    $last_catid = '';
657
+	$last_catid = '';
658 658
 
659
-    $uploads = wp_upload_dir(); // Array of key => value pairs
659
+	$uploads = wp_upload_dir(); // Array of key => value pairs
660 660
 
661
-    for ($i = 0; $i < count($category_array); $i++) {
662
-        $parent_catid = 0;
663
-        if (is_array($category_array[$i])) {
664
-            $cat_name_arr = $category_array[$i];
665
-            for ($j = 0; $j < count($cat_name_arr); $j++) {
666
-                $catname = $cat_name_arr[$j];
661
+	for ($i = 0; $i < count($category_array); $i++) {
662
+		$parent_catid = 0;
663
+		if (is_array($category_array[$i])) {
664
+			$cat_name_arr = $category_array[$i];
665
+			for ($j = 0; $j < count($cat_name_arr); $j++) {
666
+				$catname = $cat_name_arr[$j];
667 667
 
668
-                if (!term_exists($catname, 'gd_placecategory')) {
669
-                    $last_catid = wp_insert_term($catname, 'gd_placecategory', $args = array('parent' => $parent_catid));
668
+				if (!term_exists($catname, 'gd_placecategory')) {
669
+					$last_catid = wp_insert_term($catname, 'gd_placecategory', $args = array('parent' => $parent_catid));
670 670
 
671
-                    if ($j == 0) {
672
-                        $parent_catid = $last_catid;
673
-                    }
671
+					if ($j == 0) {
672
+						$parent_catid = $last_catid;
673
+					}
674 674
 
675 675
 
676
-                    if (geodir_dummy_folder_exists())
677
-                        $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
678
-                    else
679
-                        $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
676
+					if (geodir_dummy_folder_exists())
677
+						$dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
678
+					else
679
+						$dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
680 680
 
681
-                    $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
681
+					$dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
682 682
 
683
-                    $catname = str_replace(' ', '_', $catname);
684
-                    $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
683
+					$catname = str_replace(' ', '_', $catname);
684
+					$uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
685 685
 
686
-                    if (empty($uploaded['error'])) {
687
-                        $new_path = $uploaded['file'];
688
-                        $new_url = $uploaded['url'];
689
-                    }
686
+					if (empty($uploaded['error'])) {
687
+						$new_path = $uploaded['file'];
688
+						$new_url = $uploaded['url'];
689
+					}
690 690
 
691
-                    $wp_filetype = wp_check_filetype(basename($new_path), null);
692
-
693
-                    $attachment = array(
694
-                        'guid' => $uploads['baseurl'] . '/' . basename($new_path),
695
-                        'post_mime_type' => $wp_filetype['type'],
696
-                        'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
697
-                        'post_content' => '',
698
-                        'post_status' => 'inherit'
699
-                    );
700
-                    $attach_id = wp_insert_attachment($attachment, $new_path);
701
-
702
-                    // you must first include the image.php file
703
-                    // for the function wp_generate_attachment_metadata() to work
704
-                    require_once(ABSPATH . 'wp-admin/includes/image.php');
705
-                    $attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
706
-                    wp_update_attachment_metadata($attach_id, $attach_data);
707
-
708
-                    if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
709
-                        update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => 'icon', 'src' => $new_url), 'gd_place');
710
-                    }
711
-                }
712
-            }
691
+					$wp_filetype = wp_check_filetype(basename($new_path), null);
692
+
693
+					$attachment = array(
694
+						'guid' => $uploads['baseurl'] . '/' . basename($new_path),
695
+						'post_mime_type' => $wp_filetype['type'],
696
+						'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
697
+						'post_content' => '',
698
+						'post_status' => 'inherit'
699
+					);
700
+					$attach_id = wp_insert_attachment($attachment, $new_path);
701
+
702
+					// you must first include the image.php file
703
+					// for the function wp_generate_attachment_metadata() to work
704
+					require_once(ABSPATH . 'wp-admin/includes/image.php');
705
+					$attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
706
+					wp_update_attachment_metadata($attach_id, $attach_data);
707
+
708
+					if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
709
+						update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => 'icon', 'src' => $new_url), 'gd_place');
710
+					}
711
+				}
712
+			}
713 713
 
714
-        } else {
715
-            $catname = $category_array[$i];
714
+		} else {
715
+			$catname = $category_array[$i];
716 716
 
717
-            if (!term_exists($catname, 'gd_placecategory')) {
718
-                $last_catid = wp_insert_term($catname, 'gd_placecategory');
717
+			if (!term_exists($catname, 'gd_placecategory')) {
718
+				$last_catid = wp_insert_term($catname, 'gd_placecategory');
719 719
 
720
-                if (geodir_dummy_folder_exists())
721
-                    $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
722
-                else
723
-                    $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
720
+				if (geodir_dummy_folder_exists())
721
+					$dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
722
+				else
723
+					$dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
724 724
 
725
-                $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
725
+				$dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
726 726
 
727
-                $catname = str_replace(' ', '_', $catname);
728
-                $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
727
+				$catname = str_replace(' ', '_', $catname);
728
+				$uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
729 729
 
730
-                if (empty($uploaded['error'])) {
731
-                    $new_path = $uploaded['file'];
732
-                    $new_url = $uploaded['url'];
733
-                }
730
+				if (empty($uploaded['error'])) {
731
+					$new_path = $uploaded['file'];
732
+					$new_url = $uploaded['url'];
733
+				}
734 734
 
735
-                $wp_filetype = wp_check_filetype(basename($new_path), null);
735
+				$wp_filetype = wp_check_filetype(basename($new_path), null);
736 736
 
737
-                $attachment = array(
738
-                    'guid' => $uploads['baseurl'] . '/' . basename($new_path),
739
-                    'post_mime_type' => $wp_filetype['type'],
740
-                    'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
741
-                    'post_content' => '',
742
-                    'post_status' => 'inherit'
743
-                );
737
+				$attachment = array(
738
+					'guid' => $uploads['baseurl'] . '/' . basename($new_path),
739
+					'post_mime_type' => $wp_filetype['type'],
740
+					'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
741
+					'post_content' => '',
742
+					'post_status' => 'inherit'
743
+				);
744 744
 
745
-                $attach_id = wp_insert_attachment($attachment, $new_path);
745
+				$attach_id = wp_insert_attachment($attachment, $new_path);
746 746
 
747 747
 
748
-                // you must first include the image.php file
749
-                // for the function wp_generate_attachment_metadata() to work
750
-                require_once(ABSPATH . 'wp-admin/includes/image.php');
751
-                $attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
752
-                wp_update_attachment_metadata($attach_id, $attach_data);
748
+				// you must first include the image.php file
749
+				// for the function wp_generate_attachment_metadata() to work
750
+				require_once(ABSPATH . 'wp-admin/includes/image.php');
751
+				$attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
752
+				wp_update_attachment_metadata($attach_id, $attach_data);
753 753
 
754
-                if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
755
-                    update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => $attach_id, 'src' => $new_url), 'gd_place');
756
-                }
757
-            }
758
-        }
754
+				if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
755
+					update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => $attach_id, 'src' => $new_url), 'gd_place');
756
+				}
757
+			}
758
+		}
759 759
 
760
-    }
760
+	}
761 761
 }
762 762
 
763 763
 /**
@@ -772,144 +772,144 @@  discard block
 block discarded – undo
772 772
  * @return bool Returns true if saved.
773 773
  */
774 774
 function geodir_update_options($options, $dummy = false) {
775
-    if ((!isset($_POST) || !$_POST) && !$dummy) return false;
775
+	if ((!isset($_POST) || !$_POST) && !$dummy) return false;
776 776
 
777
-    foreach ($options as $value) {
778
-        if ($dummy && isset($value['std']))
779
-            $_POST[$value['id']] = $value['std'];
777
+	foreach ($options as $value) {
778
+		if ($dummy && isset($value['std']))
779
+			$_POST[$value['id']] = $value['std'];
780 780
 
781 781
 
782
-        if (isset($value['type']) && $value['type'] == 'checkbox') :
782
+		if (isset($value['type']) && $value['type'] == 'checkbox') :
783 783
 
784
-            if (isset($value['id']) && isset($_POST[$value['id']])) {
785
-                update_option($value['id'], $_POST[$value['id']]);
786
-            } else {
787
-                update_option($value['id'], 0);
788
-            }
784
+			if (isset($value['id']) && isset($_POST[$value['id']])) {
785
+				update_option($value['id'], $_POST[$value['id']]);
786
+			} else {
787
+				update_option($value['id'], 0);
788
+			}
789 789
 
790
-        elseif (isset($value['type']) && $value['type'] == 'image_width') :
790
+		elseif (isset($value['type']) && $value['type'] == 'image_width') :
791 791
 
792
-            if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
793
-                update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']);
794
-                update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']);
795
-                if (isset($_POST[$value['id'] . '_crop'])) :
796
-                    update_option($value['id'] . '_crop', 1);
797
-                else :
798
-                    update_option($value['id'] . '_crop', 0);
799
-                endif;
800
-            } else {
801
-                update_option($value['id'] . '_width', $value['std']);
802
-                update_option($value['id'] . '_height', $value['std']);
803
-                update_option($value['id'] . '_crop', 1);
804
-            }
792
+			if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
793
+				update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']);
794
+				update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']);
795
+				if (isset($_POST[$value['id'] . '_crop'])) :
796
+					update_option($value['id'] . '_crop', 1);
797
+				else :
798
+					update_option($value['id'] . '_crop', 0);
799
+				endif;
800
+			} else {
801
+				update_option($value['id'] . '_width', $value['std']);
802
+				update_option($value['id'] . '_height', $value['std']);
803
+				update_option($value['id'] . '_crop', 1);
804
+			}
805 805
 
806
-        elseif (isset($value['type']) && $value['type'] == 'map') :
807
-            $post_types = array();
808
-            $categories = array();
806
+		elseif (isset($value['type']) && $value['type'] == 'map') :
807
+			$post_types = array();
808
+			$categories = array();
809 809
 
810
-            if (!empty($_POST['home_map_post_types'])) :
811
-                foreach ($_POST['home_map_post_types'] as $post_type) :
812
-                    $post_types[] = $post_type;
813
-                endforeach;
814
-            endif;
810
+			if (!empty($_POST['home_map_post_types'])) :
811
+				foreach ($_POST['home_map_post_types'] as $post_type) :
812
+					$post_types[] = $post_type;
813
+				endforeach;
814
+			endif;
815 815
 
816
-            update_option('geodir_exclude_post_type_on_map', $post_types);
816
+			update_option('geodir_exclude_post_type_on_map', $post_types);
817 817
 
818
-            if (!empty($_POST['post_category'])) :
819
-                foreach ($_POST['post_category'] as $texonomy => $cat_arr) :
820
-                    $categories[$texonomy] = array();
821
-                    foreach ($cat_arr as $category) :
822
-                        $categories[$texonomy][] = $category;
823
-                    endforeach;
824
-                    $categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array();
825
-                endforeach;
826
-            endif;
827
-            update_option('geodir_exclude_cat_on_map', $categories);
828
-            update_option('geodir_exclude_cat_on_map_upgrade', 1);
829
-        elseif (isset($value['type']) && $value['type'] == 'map_default_settings') :
818
+			if (!empty($_POST['post_category'])) :
819
+				foreach ($_POST['post_category'] as $texonomy => $cat_arr) :
820
+					$categories[$texonomy] = array();
821
+					foreach ($cat_arr as $category) :
822
+						$categories[$texonomy][] = $category;
823
+					endforeach;
824
+					$categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array();
825
+				endforeach;
826
+			endif;
827
+			update_option('geodir_exclude_cat_on_map', $categories);
828
+			update_option('geodir_exclude_cat_on_map_upgrade', 1);
829
+		elseif (isset($value['type']) && $value['type'] == 'map_default_settings') :
830 830
 
831 831
 
832
-            if (!empty($_POST['geodir_default_map_language'])):
833
-                update_option('geodir_default_map_language', $_POST['geodir_default_map_language']);
834
-            endif;
832
+			if (!empty($_POST['geodir_default_map_language'])):
833
+				update_option('geodir_default_map_language', $_POST['geodir_default_map_language']);
834
+			endif;
835 835
 
836 836
 
837
-            if (!empty($_POST['geodir_default_map_search_pt'])):
838
-                update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']);
839
-            endif;
837
+			if (!empty($_POST['geodir_default_map_search_pt'])):
838
+				update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']);
839
+			endif;
840 840
 
841 841
 
842
-        elseif (isset($value['type']) && $value['type'] == 'file') :
842
+		elseif (isset($value['type']) && $value['type'] == 'file') :
843 843
 
844 844
 
845
-            if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
845
+			if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
846 846
 
847
-                if (get_option($value['id'])) {
848
-                    $image_name_arr = explode('/', get_option($value['id']));
849
-                    $noimg_name = end($image_name_arr);
850
-                    $img_path = $uploads['path'] . '/' . $noimg_name;
851
-                    if (file_exists($img_path))
852
-                        unlink($img_path);
853
-                }
847
+				if (get_option($value['id'])) {
848
+					$image_name_arr = explode('/', get_option($value['id']));
849
+					$noimg_name = end($image_name_arr);
850
+					$img_path = $uploads['path'] . '/' . $noimg_name;
851
+					if (file_exists($img_path))
852
+						unlink($img_path);
853
+				}
854 854
 
855
-                update_option($value['id'], '');
856
-            }
855
+				update_option($value['id'], '');
856
+			}
857 857
 
858
-            $uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : '';
859
-            $filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : '';
860
-
861
-            if (!empty($filename)):
862
-                $ext = pathinfo($filename, PATHINFO_EXTENSION);
863
-                $uplaods = array();
864
-
865
-                foreach ($uploadedfile as $key => $uplaod):
866
-                    if ($key == 'name'):
867
-                        $uplaods[$key] = $filename;
868
-                    else :
869
-                        $uplaods[$key] = $uplaod;
870
-                    endif;
871
-                endforeach;
872
-
873
-                $uploads = wp_upload_dir();
874
-
875
-                if (get_option($value['id'])) {
876
-                    $image_name_arr = explode('/', get_option($value['id']));
877
-                    $noimg_name = end($image_name_arr);
878
-                    $img_path = $uploads['path'] . '/' . $noimg_name;
879
-                    if (file_exists($img_path))
880
-                        unlink($img_path);
881
-                }
858
+			$uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : '';
859
+			$filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : '';
860
+
861
+			if (!empty($filename)):
862
+				$ext = pathinfo($filename, PATHINFO_EXTENSION);
863
+				$uplaods = array();
864
+
865
+				foreach ($uploadedfile as $key => $uplaod):
866
+					if ($key == 'name'):
867
+						$uplaods[$key] = $filename;
868
+					else :
869
+						$uplaods[$key] = $uplaod;
870
+					endif;
871
+				endforeach;
872
+
873
+				$uploads = wp_upload_dir();
874
+
875
+				if (get_option($value['id'])) {
876
+					$image_name_arr = explode('/', get_option($value['id']));
877
+					$noimg_name = end($image_name_arr);
878
+					$img_path = $uploads['path'] . '/' . $noimg_name;
879
+					if (file_exists($img_path))
880
+						unlink($img_path);
881
+				}
882 882
 
883
-                $upload_overrides = array('test_form' => false);
884
-                $movefile = wp_handle_upload($uplaods, $upload_overrides);
883
+				$upload_overrides = array('test_form' => false);
884
+				$movefile = wp_handle_upload($uplaods, $upload_overrides);
885 885
 
886
-                update_option($value['id'], $movefile['url']);
886
+				update_option($value['id'], $movefile['url']);
887 887
 
888
-            endif;
888
+			endif;
889 889
 
890
-            if (!get_option($value['id']) && isset($value['value'])):
891
-                update_option($value['id'], $value['value']);
892
-            endif;
890
+			if (!get_option($value['id']) && isset($value['value'])):
891
+				update_option($value['id'], $value['value']);
892
+			endif;
893 893
 
894 894
 
895
-        else :
896
-            // same menu setting per theme.
897
-            if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
898
-                $theme = wp_get_theme();
899
-                update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
900
-            }
895
+		else :
896
+			// same menu setting per theme.
897
+			if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
898
+				$theme = wp_get_theme();
899
+				update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
900
+			}
901 901
 
902
-            if (isset($value['id']) && isset($_POST[$value['id']])) {
903
-                update_option($value['id'], $_POST[$value['id']]);
904
-            } else {
905
-                delete_option($value['id']);
906
-            }
902
+			if (isset($value['id']) && isset($_POST[$value['id']])) {
903
+				update_option($value['id'], $_POST[$value['id']]);
904
+			} else {
905
+				delete_option($value['id']);
906
+			}
907 907
 
908
-        endif;
909
-    }
910
-    if ($dummy)
911
-        $_POST = array();
912
-    return true;
908
+		endif;
909
+	}
910
+	if ($dummy)
911
+		$_POST = array();
912
+	return true;
913 913
 
914 914
 }
915 915
 
@@ -958,33 +958,33 @@  discard block
 block discarded – undo
958 958
 function places_custom_fields_tab($tabs)
959 959
 {
960 960
 
961
-    $geodir_post_types = get_option('geodir_post_types');
961
+	$geodir_post_types = get_option('geodir_post_types');
962 962
 
963
-    if (!empty($geodir_post_types)) {
963
+	if (!empty($geodir_post_types)) {
964 964
 
965
-        foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info):
965
+		foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info):
966 966
 
967
-            $listing_slug = $geodir_posttype_info['labels']['singular_name'];
967
+			$listing_slug = $geodir_posttype_info['labels']['singular_name'];
968 968
 
969
-            $tabs[$geodir_post_type . '_fields_settings'] = array(
970
-                'label' => __(ucfirst($listing_slug) . ' Settings', 'geodirectory'),
971
-                'subtabs' => array(
972
-                    array('subtab' => 'custom_fields',
973
-                        'label' => __('Custom Fields', 'geodirectory'),
974
-                        'request' => array('listing_type' => $geodir_post_type)),
975
-                    array('subtab' => 'sorting_options',
976
-                        'label' => __('Sorting Options', 'geodirectory'),
977
-                        'request' => array('listing_type' => $geodir_post_type)),
978
-                ),
979
-                'tab_index' => 9,
980
-                'request' => array('listing_type' => $geodir_post_type)
981
-            );
969
+			$tabs[$geodir_post_type . '_fields_settings'] = array(
970
+				'label' => __(ucfirst($listing_slug) . ' Settings', 'geodirectory'),
971
+				'subtabs' => array(
972
+					array('subtab' => 'custom_fields',
973
+						'label' => __('Custom Fields', 'geodirectory'),
974
+						'request' => array('listing_type' => $geodir_post_type)),
975
+					array('subtab' => 'sorting_options',
976
+						'label' => __('Sorting Options', 'geodirectory'),
977
+						'request' => array('listing_type' => $geodir_post_type)),
978
+				),
979
+				'tab_index' => 9,
980
+				'request' => array('listing_type' => $geodir_post_type)
981
+			);
982 982
 
983
-        endforeach;
983
+		endforeach;
984 984
 
985
-    }
985
+	}
986 986
 
987
-    return $tabs;
987
+	return $tabs;
988 988
 }
989 989
 
990 990
 
@@ -1000,9 +1000,9 @@  discard block
 block discarded – undo
1000 1000
  */
1001 1001
 function geodir_tools_setting_tab($tabs)
1002 1002
 {
1003
-    wp_enqueue_script( 'jquery-ui-progressbar' );
1004
-    $tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
1005
-    return $tabs;
1003
+	wp_enqueue_script( 'jquery-ui-progressbar' );
1004
+	$tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
1005
+	return $tabs;
1006 1006
 }
1007 1007
 
1008 1008
 /**
@@ -1017,8 +1017,8 @@  discard block
 block discarded – undo
1017 1017
  */
1018 1018
 function geodir_compatibility_setting_tab($tabs)
1019 1019
 {
1020
-    $tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory'));
1021
-    return $tabs;
1020
+	$tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory'));
1021
+	return $tabs;
1022 1022
 }
1023 1023
 
1024 1024
 
@@ -1034,144 +1034,144 @@  discard block
 block discarded – undo
1034 1034
  */
1035 1035
 function geodir_extend_geodirectory_setting_tab($tabs)
1036 1036
 {
1037
-    $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
1038
-    return $tabs;
1037
+	$tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
1038
+	return $tabs;
1039 1039
 }
1040 1040
 
1041 1041
 
1042 1042
 if (!function_exists('geodir_edit_post_columns')) {
1043
-    /**
1044
-     * Modify admin post listing page columns.
1045
-     *
1046
-     * @since 1.0.0
1047
-     * @package GeoDirectory
1048
-     * @param array $columns The column array.
1049
-     * @return array Altered column array.
1050
-     */
1051
-    function geodir_edit_post_columns($columns)
1052
-    {
1053
-
1054
-        $new_columns = array('location' => __('Location (ID)', 'geodirectory'),
1055
-            'categorys' => __('Categories', 'geodirectory'));
1056
-
1057
-        if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
1058
-        {
1059
-            $offset = 0; // should we prepend $array with $data?
1060
-            $offset = count($columns); // or should we append $array with $data? lets pick this one...
1061
-        }
1043
+	/**
1044
+	 * Modify admin post listing page columns.
1045
+	 *
1046
+	 * @since 1.0.0
1047
+	 * @package GeoDirectory
1048
+	 * @param array $columns The column array.
1049
+	 * @return array Altered column array.
1050
+	 */
1051
+	function geodir_edit_post_columns($columns)
1052
+	{
1062 1053
 
1063
-        $columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset));
1054
+		$new_columns = array('location' => __('Location (ID)', 'geodirectory'),
1055
+			'categorys' => __('Categories', 'geodirectory'));
1064 1056
 
1065
-        $columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory')));
1057
+		if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
1058
+		{
1059
+			$offset = 0; // should we prepend $array with $data?
1060
+			$offset = count($columns); // or should we append $array with $data? lets pick this one...
1061
+		}
1066 1062
 
1067
-        return $columns;
1068
-    }
1063
+		$columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset));
1064
+
1065
+		$columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory')));
1066
+
1067
+		return $columns;
1068
+	}
1069 1069
 }
1070 1070
 
1071 1071
 
1072 1072
 if (!function_exists('geodir_manage_post_columns')) {
1073
-    /**
1074
-     * Adds content to our custom post listing page columns.
1075
-     *
1076
-     * @since 1.0.0
1077
-     * @package GeoDirectory
1078
-     * @global object $wpdb WordPress Database object.
1079
-     * @global object $post WordPress Post object.
1080
-     * @param string $column The column name.
1081
-     * @param int $post_id The post ID.
1082
-     */
1083
-    function geodir_manage_post_columns($column, $post_id)
1084
-    {
1085
-        global $post, $wpdb;
1086
-
1087
-        switch ($column):
1088
-            /* If displaying the 'city' column. */
1089
-            case 'location' :
1090
-                $location_id = geodir_get_post_meta($post->ID, 'post_location_id', true);
1091
-                $location = geodir_get_location($location_id);
1092
-                /* If no city is found, output a default message. */
1093
-                if (empty($location)) {
1094
-                    _e('Unknown', 'geodirectory');
1095
-                } else {
1096
-                    /* If there is a city id, append 'city name' to the text string. */
1097
-                    $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
1098
-                    echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id);
1099
-                }
1100
-                break;
1101
-
1102
-            /* If displaying the 'expire' column. */
1103
-            case 'expire' :
1104
-                $expire_date = geodir_get_post_meta($post->ID, 'expire_date', true);
1105
-                $d1 = $expire_date; // get expire_date
1106
-                $d2 = date('Y-m-d'); // get current date
1107
-                $state = __('days left', 'geodirectory');
1108
-                $date_diff_text = '';
1109
-                $expire_class = 'expire_left';
1110
-                if ($expire_date != 'Never') {
1111
-                    if (strtotime($d1) < strtotime($d2)) {
1112
-                        $state = __('days overdue', 'geodirectory');
1113
-                        $expire_class = 'expire_over';
1114
-                    }
1115
-                    $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days
1116
-                    $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
1117
-                }
1118
-                /* If no expire_date is found, output a default message. */
1119
-                if (empty($expire_date))
1120
-                    echo __('Unknown', 'geodirectory');
1121
-                /* If there is a expire_date, append 'days left' to the text string. */
1122
-                else
1123
-                    echo $expire_date . $date_diff_text;
1124
-                break;
1125
-
1126
-            /* If displaying the 'categorys' column. */
1127
-            case 'categorys' :
1128
-
1129
-                /* Get the categorys for the post. */
1130
-
1131
-
1132
-                $terms = wp_get_object_terms($post_id, get_object_taxonomies($post));
1133
-
1134
-                /* If terms were found. */
1135
-                if (!empty($terms)) {
1136
-                    $out = array();
1137
-                    /* Loop through each term, linking to the 'edit posts' page for the specific term. */
1138
-                    foreach ($terms as $term) {
1139
-                        if (!strstr($term->taxonomy, 'tag')) {
1140
-                            $out[] = sprintf('<a href="%s">%s</a>',
1141
-                                esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')),
1142
-                                esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display'))
1143
-                            );
1144
-                        }
1145
-                    }
1146
-                    /* Join the terms, separating them with a comma. */
1147
-                    echo(join(', ', $out));
1148
-                } /* If no terms were found, output a default message. */
1149
-                else {
1150
-                    _e('No Categories', 'geodirectory');
1151
-                }
1152
-                break;
1073
+	/**
1074
+	 * Adds content to our custom post listing page columns.
1075
+	 *
1076
+	 * @since 1.0.0
1077
+	 * @package GeoDirectory
1078
+	 * @global object $wpdb WordPress Database object.
1079
+	 * @global object $post WordPress Post object.
1080
+	 * @param string $column The column name.
1081
+	 * @param int $post_id The post ID.
1082
+	 */
1083
+	function geodir_manage_post_columns($column, $post_id)
1084
+	{
1085
+		global $post, $wpdb;
1086
+
1087
+		switch ($column):
1088
+			/* If displaying the 'city' column. */
1089
+			case 'location' :
1090
+				$location_id = geodir_get_post_meta($post->ID, 'post_location_id', true);
1091
+				$location = geodir_get_location($location_id);
1092
+				/* If no city is found, output a default message. */
1093
+				if (empty($location)) {
1094
+					_e('Unknown', 'geodirectory');
1095
+				} else {
1096
+					/* If there is a city id, append 'city name' to the text string. */
1097
+					$add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
1098
+					echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id);
1099
+				}
1100
+				break;
1101
+
1102
+			/* If displaying the 'expire' column. */
1103
+			case 'expire' :
1104
+				$expire_date = geodir_get_post_meta($post->ID, 'expire_date', true);
1105
+				$d1 = $expire_date; // get expire_date
1106
+				$d2 = date('Y-m-d'); // get current date
1107
+				$state = __('days left', 'geodirectory');
1108
+				$date_diff_text = '';
1109
+				$expire_class = 'expire_left';
1110
+				if ($expire_date != 'Never') {
1111
+					if (strtotime($d1) < strtotime($d2)) {
1112
+						$state = __('days overdue', 'geodirectory');
1113
+						$expire_class = 'expire_over';
1114
+					}
1115
+					$date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days
1116
+					$date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
1117
+				}
1118
+				/* If no expire_date is found, output a default message. */
1119
+				if (empty($expire_date))
1120
+					echo __('Unknown', 'geodirectory');
1121
+				/* If there is a expire_date, append 'days left' to the text string. */
1122
+				else
1123
+					echo $expire_date . $date_diff_text;
1124
+				break;
1153 1125
 
1154
-        endswitch;
1155
-    }
1126
+			/* If displaying the 'categorys' column. */
1127
+			case 'categorys' :
1128
+
1129
+				/* Get the categorys for the post. */
1130
+
1131
+
1132
+				$terms = wp_get_object_terms($post_id, get_object_taxonomies($post));
1133
+
1134
+				/* If terms were found. */
1135
+				if (!empty($terms)) {
1136
+					$out = array();
1137
+					/* Loop through each term, linking to the 'edit posts' page for the specific term. */
1138
+					foreach ($terms as $term) {
1139
+						if (!strstr($term->taxonomy, 'tag')) {
1140
+							$out[] = sprintf('<a href="%s">%s</a>',
1141
+								esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')),
1142
+								esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display'))
1143
+							);
1144
+						}
1145
+					}
1146
+					/* Join the terms, separating them with a comma. */
1147
+					echo(join(', ', $out));
1148
+				} /* If no terms were found, output a default message. */
1149
+				else {
1150
+					_e('No Categories', 'geodirectory');
1151
+				}
1152
+				break;
1153
+
1154
+		endswitch;
1155
+	}
1156 1156
 }
1157 1157
 
1158 1158
 
1159 1159
 if (!function_exists('geodir_post_sortable_columns')) {
1160
-    /**
1161
-     * Makes admin post listing page columns sortable.
1162
-     *
1163
-     * @since 1.0.0
1164
-     * @package GeoDirectory
1165
-     * @param array $columns The column array.
1166
-     * @return array Altered column array.
1167
-     */
1168
-    function geodir_post_sortable_columns($columns)
1169
-    {
1170
-
1171
-        $columns['expire'] = 'expire';
1172
-
1173
-        return $columns;
1174
-    }
1160
+	/**
1161
+	 * Makes admin post listing page columns sortable.
1162
+	 *
1163
+	 * @since 1.0.0
1164
+	 * @package GeoDirectory
1165
+	 * @param array $columns The column array.
1166
+	 * @return array Altered column array.
1167
+	 */
1168
+	function geodir_post_sortable_columns($columns)
1169
+	{
1170
+
1171
+		$columns['expire'] = 'expire';
1172
+
1173
+		return $columns;
1174
+	}
1175 1175
 }
1176 1176
 
1177 1177
 /**
@@ -1185,32 +1185,32 @@  discard block
 block discarded – undo
1185 1185
  * @param int $post_id The post ID.
1186 1186
  */
1187 1187
 function geodir_post_information_save($post_id, $post) {
1188
-    global $wpdb, $current_user;
1188
+	global $wpdb, $current_user;
1189 1189
 
1190
-    if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
1191
-        return;
1192
-    }
1190
+	if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
1191
+		return;
1192
+	}
1193 1193
 
1194
-    $geodir_posttypes = geodir_get_posttypes();
1194
+	$geodir_posttypes = geodir_get_posttypes();
1195 1195
 
1196
-    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
1197
-        return;
1196
+	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
1197
+		return;
1198 1198
 
1199
-    if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
1200
-        if (isset($_REQUEST['_status']))
1201
-            geodir_change_post_status($post_id, $_REQUEST['_status']);
1199
+	if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
1200
+		if (isset($_REQUEST['_status']))
1201
+			geodir_change_post_status($post_id, $_REQUEST['_status']);
1202 1202
 
1203
-        if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash'))
1204
-            return;
1203
+		if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash'))
1204
+			return;
1205 1205
 
1206
-        if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__)))
1207
-            return;
1206
+		if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__)))
1207
+			return;
1208 1208
 
1209
-        if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__)))
1210
-            return;
1209
+		if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__)))
1210
+			return;
1211 1211
 
1212
-        geodir_save_listing($_REQUEST);
1213
-    }
1212
+		geodir_save_listing($_REQUEST);
1213
+	}
1214 1214
 }
1215 1215
 
1216 1216
 /**
@@ -1226,102 +1226,102 @@  discard block
 block discarded – undo
1226 1226
  */
1227 1227
 function geodir_admin_fields($options)
1228 1228
 {
1229
-    global $geodirectory;
1230
-
1231
-    $first_title = true;
1232
-    $tab_id = '';
1233
-    $i = 0;
1234
-    foreach ($options as $value) :
1235
-        if (!isset($value['name'])) $value['name'] = '';
1236
-        if (!isset($value['class'])) $value['class'] = '';
1237
-        if (!isset($value['css'])) $value['css'] = '';
1238
-        if (!isset($value['std'])) $value['std'] = '';
1239
-        $desc = '';
1240
-        switch ($value['type']) :
1241
-            case 'dummy_installer':
1242
-                $post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place';
1243
-                geodir_autoinstall_admin_header($post_type);
1244
-                break;
1245
-            case 'title':
1246
-
1247
-                if ($i == 0) {
1248
-                    echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>';
1249
-                    echo '<div class="inner_content_tab_main">';
1250
-                }
1229
+	global $geodirectory;
1230
+
1231
+	$first_title = true;
1232
+	$tab_id = '';
1233
+	$i = 0;
1234
+	foreach ($options as $value) :
1235
+		if (!isset($value['name'])) $value['name'] = '';
1236
+		if (!isset($value['class'])) $value['class'] = '';
1237
+		if (!isset($value['css'])) $value['css'] = '';
1238
+		if (!isset($value['std'])) $value['std'] = '';
1239
+		$desc = '';
1240
+		switch ($value['type']) :
1241
+			case 'dummy_installer':
1242
+				$post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place';
1243
+				geodir_autoinstall_admin_header($post_type);
1244
+				break;
1245
+			case 'title':
1246
+
1247
+				if ($i == 0) {
1248
+					echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>';
1249
+					echo '<div class="inner_content_tab_main">';
1250
+				}
1251 1251
 
1252
-                $i++;
1252
+				$i++;
1253 1253
 
1254
-                if (isset($value['id']) && $value['id'])
1255
-                    $tab_id = $value['id'];
1254
+				if (isset($value['id']) && $value['id'])
1255
+					$tab_id = $value['id'];
1256 1256
 
1257
-                if (isset($value['desc']) && $value['desc'])
1258
-                    $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>';
1257
+				if (isset($value['desc']) && $value['desc'])
1258
+					$desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>';
1259 1259
 
1260
-                if (isset($value['name']) && $value['name']) {
1261
-                    if ($first_title === true) {
1262
-                        $first_title = false;
1263
-                    } else {
1264
-                        echo '</div>';
1265
-                    }
1266
-                    echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>';
1260
+				if (isset($value['name']) && $value['name']) {
1261
+					if ($first_title === true) {
1262
+						$first_title = false;
1263
+					} else {
1264
+						echo '</div>';
1265
+					}
1266
+					echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>';
1267 1267
 
1268
-                    echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
1269
-                }
1268
+					echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
1269
+				}
1270 1270
 
1271
-                /**
1272
-                 * Called after a GeoDirectory settings title is output in the GD settings page.
1273
-                 *
1274
-                 * The action is called dynamically geodir_settings_$value['id'].
1275
-                 *
1276
-                 * @since 1.0.0
1277
-                 */
1278
-                do_action('geodir_settings_' . sanitize_title($value['id']));
1279
-                break;
1280
-
1281
-            case 'no_tabs':
1282
-
1283
-                echo '<div class="inner_content_tab_main">';
1284
-                echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
1285
-
1286
-                break;
1287
-
1288
-            case 'sectionstart':
1289
-                if (isset($value['desc']) && $value['desc'])
1290
-                    $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>';
1291
-                if (isset($value['name']) && $value['name'])
1292
-                    echo '<h3>' . $value['name'] . $desc . '</h3>';
1293
-                /**
1294
-                 * Called after a GeoDirectory settings sectionstart is output in the GD settings page.
1295
-                 *
1296
-                 * The action is called dynamically geodir_settings_$value['id']_start.
1297
-                 *
1298
-                 * @since 1.0.0
1299
-                 */
1300
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
1301
-                echo '<table class="form-table">' . "\n\n";
1302
-
1303
-                break;
1304
-            case 'sectionend':
1305
-                /**
1306
-                 * Called before a GeoDirectory settings sectionend is output in the GD settings page.
1307
-                 *
1308
-                 * The action is called dynamically geodir_settings_$value['id']_end.
1309
-                 *
1310
-                 * @since 1.0.0
1311
-                 */
1312
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
1313
-                echo '</table>';
1314
-                /**
1315
-                 * Called after a GeoDirectory settings sectionend is output in the GD settings page.
1316
-                 *
1317
-                 * The action is called dynamically geodir_settings_$value['id']_end.
1318
-                 *
1319
-                 * @since 1.0.0
1320
-                 */
1321
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
1322
-                break;
1323
-            case 'text':
1324
-                ?>
1271
+				/**
1272
+				 * Called after a GeoDirectory settings title is output in the GD settings page.
1273
+				 *
1274
+				 * The action is called dynamically geodir_settings_$value['id'].
1275
+				 *
1276
+				 * @since 1.0.0
1277
+				 */
1278
+				do_action('geodir_settings_' . sanitize_title($value['id']));
1279
+				break;
1280
+
1281
+			case 'no_tabs':
1282
+
1283
+				echo '<div class="inner_content_tab_main">';
1284
+				echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
1285
+
1286
+				break;
1287
+
1288
+			case 'sectionstart':
1289
+				if (isset($value['desc']) && $value['desc'])
1290
+					$desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>';
1291
+				if (isset($value['name']) && $value['name'])
1292
+					echo '<h3>' . $value['name'] . $desc . '</h3>';
1293
+				/**
1294
+				 * Called after a GeoDirectory settings sectionstart is output in the GD settings page.
1295
+				 *
1296
+				 * The action is called dynamically geodir_settings_$value['id']_start.
1297
+				 *
1298
+				 * @since 1.0.0
1299
+				 */
1300
+				if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
1301
+				echo '<table class="form-table">' . "\n\n";
1302
+
1303
+				break;
1304
+			case 'sectionend':
1305
+				/**
1306
+				 * Called before a GeoDirectory settings sectionend is output in the GD settings page.
1307
+				 *
1308
+				 * The action is called dynamically geodir_settings_$value['id']_end.
1309
+				 *
1310
+				 * @since 1.0.0
1311
+				 */
1312
+				if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
1313
+				echo '</table>';
1314
+				/**
1315
+				 * Called after a GeoDirectory settings sectionend is output in the GD settings page.
1316
+				 *
1317
+				 * The action is called dynamically geodir_settings_$value['id']_end.
1318
+				 *
1319
+				 * @since 1.0.0
1320
+				 */
1321
+				if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
1322
+				break;
1323
+			case 'text':
1324
+				?>
1325 1325
                 <tr valign="top">
1326 1326
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1327 1327
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
@@ -1330,15 +1330,15 @@  discard block
 block discarded – undo
1330 1330
                                            <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1331 1331
                                            style=" <?php echo esc_attr($value['css']); ?>"
1332 1332
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1333
-                                               echo esc_attr(stripslashes(get_option($value['id'])));
1334
-                                           } else {
1335
-                                               echo esc_attr($value['std']);
1336
-                                           } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
1333
+											   echo esc_attr(stripslashes(get_option($value['id'])));
1334
+										   } else {
1335
+											   echo esc_attr($value['std']);
1336
+										   } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
1337 1337
                 </tr><?php
1338
-                break;
1338
+				break;
1339 1339
 
1340
-            case 'password':
1341
-                ?>
1340
+			case 'password':
1341
+				?>
1342 1342
                 <tr valign="top">
1343 1343
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1344 1344
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
@@ -1347,42 +1347,42 @@  discard block
 block discarded – undo
1347 1347
                                            <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1348 1348
                                            style="<?php echo esc_attr($value['css']); ?>"
1349 1349
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1350
-                                               echo esc_attr(stripslashes(get_option($value['id'])));
1351
-                                           } else {
1352
-                                               echo esc_attr($value['std']);
1353
-                                           } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
1350
+											   echo esc_attr(stripslashes(get_option($value['id'])));
1351
+										   } else {
1352
+											   echo esc_attr($value['std']);
1353
+										   } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
1354 1354
                 </tr><?php
1355
-                break;
1355
+				break;
1356 1356
 
1357
-            case 'html_content':
1358
-                ?>
1357
+			case 'html_content':
1358
+				?>
1359 1359
                 <tr valign="top">
1360 1360
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1361 1361
                 <td class="forminp"><span class="description"><?php echo $value['desc']; ?></span></td>
1362 1362
                 </tr><?php
1363
-                break;
1363
+				break;
1364 1364
 
1365
-            case 'color' :
1366
-                ?>
1365
+			case 'color' :
1366
+				?>
1367 1367
                 <tr valign="top">
1368 1368
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1369 1369
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
1370 1370
                                            id="<?php echo esc_attr($value['id']); ?>" type="text"
1371 1371
                                            style="<?php echo esc_attr($value['css']); ?>"
1372 1372
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1373
-                                               echo esc_attr(stripslashes(get_option($value['id'])));
1374
-                                           } else {
1375
-                                               echo esc_attr($value['std']);
1376
-                                           } ?>" class="colorpick"/> <span
1373
+											   echo esc_attr(stripslashes(get_option($value['id'])));
1374
+										   } else {
1375
+											   echo esc_attr($value['std']);
1376
+										   } ?>" class="colorpick"/> <span
1377 1377
                         class="description"><?php echo $value['desc']; ?></span>
1378 1378
 
1379 1379
                     <div id="colorPickerDiv_<?php echo esc_attr($value['id']); ?>" class="colorpickdiv"
1380 1380
                          style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div>
1381 1381
                 </td>
1382 1382
                 </tr><?php
1383
-                break;
1384
-            case 'image_width' :
1385
-                ?>
1383
+				break;
1384
+			case 'image_width' :
1385
+				?>
1386 1386
                 <tr valign="top">
1387 1387
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1388 1388
                 <td class="forminp">
@@ -1404,11 +1404,11 @@  discard block
 block discarded – undo
1404 1404
 
1405 1405
                     <span class="description"><?php echo $value['desc'] ?></span></td>
1406 1406
                 </tr><?php
1407
-                break;
1408
-            case 'select':
1409
-                $option_value = get_option($value['id']);
1410
-                $option_value = !empty($option_value) ? stripslashes_deep($option_value) : $option_value;
1411
-                ?>
1407
+				break;
1408
+			case 'select':
1409
+				$option_value = get_option($value['id']);
1410
+				$option_value = !empty($option_value) ? stripslashes_deep($option_value) : $option_value;
1411
+				?>
1412 1412
                 <tr valign="top">
1413 1413
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1414 1414
                 <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>"
@@ -1417,33 +1417,33 @@  discard block
 block discarded – undo
1417 1417
                                             class="<?php if (isset($value['class'])) echo $value['class']; ?>"
1418 1418
                                             option-ajaxchosen="false">
1419 1419
                         <?php
1420
-                        foreach ($value['options'] as $key => $val) {
1421
-                            $geodir_select_value = '';
1422
-                            if ($option_value != '') {
1423
-                                if ($option_value != '' && $option_value == $key)
1424
-                                    $geodir_select_value = ' selected="selected" ';
1425
-                            } else {
1426
-                                if ($value['std'] == $key)
1427
-                                    $geodir_select_value = ' selected="selected" ';
1428
-                            }
1429
-                            ?>
1420
+						foreach ($value['options'] as $key => $val) {
1421
+							$geodir_select_value = '';
1422
+							if ($option_value != '') {
1423
+								if ($option_value != '' && $option_value == $key)
1424
+									$geodir_select_value = ' selected="selected" ';
1425
+							} else {
1426
+								if ($value['std'] == $key)
1427
+									$geodir_select_value = ' selected="selected" ';
1428
+							}
1429
+							?>
1430 1430
                             <option
1431 1431
                                 value="<?php echo esc_attr($key); ?>" <?php echo $geodir_select_value; ?> ><?php echo ucfirst($val) ?></option>
1432 1432
                         <?php
1433
-                        }
1434
-                        ?>
1433
+						}
1434
+						?>
1435 1435
                     </select> <span class="description"><?php echo $value['desc'] ?></span>
1436 1436
                 </td>
1437 1437
                 </tr><?php
1438
-                break;
1438
+				break;
1439 1439
 
1440
-            case 'multiselect':
1441
-                $option_values = get_option($value['id']);
1442
-                if ($option_values === '' && !empty($value['std']) && is_array($value['std'])) {
1443
-                   $option_values = $value['std'];
1444
-                }
1445
-                $option_values = !empty($option_values) ? stripslashes_deep($option_values) : $option_values;
1446
-                ?>
1440
+			case 'multiselect':
1441
+				$option_values = get_option($value['id']);
1442
+				if ($option_values === '' && !empty($value['std']) && is_array($value['std'])) {
1443
+				   $option_values = $value['std'];
1444
+				}
1445
+				$option_values = !empty($option_values) ? stripslashes_deep($option_values) : $option_values;
1446
+				?>
1447 1447
                 <tr valign="top">
1448 1448
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1449 1449
                 <td class="forminp"><select multiple="multiple" name="<?php echo esc_attr($value['id']); ?>[]"
@@ -1453,25 +1453,25 @@  discard block
 block discarded – undo
1453 1453
                                             data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>"
1454 1454
                                             option-ajaxchosen="false">
1455 1455
                         <?php
1456
-                        foreach ($value['options'] as $key => $val) {
1457
-                            if (strpos($key, 'optgroup_start-') === 0) {
1458
-                                ?><optgroup label="<?php echo ucfirst($val); ?>"><?php
1459
-                            } else if (strpos($key, 'optgroup_end-') === 0) {
1460
-                                ?></optgroup><?php
1461
-                            } else {
1462
-                                ?>
1456
+						foreach ($value['options'] as $key => $val) {
1457
+							if (strpos($key, 'optgroup_start-') === 0) {
1458
+								?><optgroup label="<?php echo ucfirst($val); ?>"><?php
1459
+							} else if (strpos($key, 'optgroup_end-') === 0) {
1460
+								?></optgroup><?php
1461
+							} else {
1462
+								?>
1463 1463
                                 <option
1464 1464
                                     value="<?php echo esc_attr($key); ?>" <?php selected(true, (is_array($option_values) && in_array($key, $option_values)));?>><?php echo ucfirst($val) ?></option>
1465 1465
                             <?php
1466
-                            }
1467
-                        }
1468
-                        ?>
1466
+							}
1467
+						}
1468
+						?>
1469 1469
                     </select> <span class="description"><?php echo $value['desc'] ?></span>
1470 1470
                 </td>
1471 1471
                 </tr><?php
1472
-                break;
1473
-            case 'file':
1474
-                ?>
1472
+				break;
1473
+			case 'file':
1474
+				?>
1475 1475
                 <tr valign="top">
1476 1476
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1477 1477
                 <td class="forminp">
@@ -1491,87 +1491,87 @@  discard block
 block discarded – undo
1491 1491
                     <?php } ?>
1492 1492
                 </td>
1493 1493
                 </tr><?php
1494
-                break;
1495
-            case 'map_default_settings' :
1496
-                ?>
1494
+				break;
1495
+			case 'map_default_settings' :
1496
+				?>
1497 1497
 
1498 1498
                 <tr valign="top">
1499 1499
                     <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory');?></th>
1500 1500
                     <td width="60%">
1501 1501
                         <select name="geodir_default_map_language" style="width:60%">
1502 1502
                             <?php
1503
-                            $arr_map_langages = array(
1504
-                                'ar' => __('ARABIC', 'geodirectory'),
1505
-                                'eu' => __('BASQUE', 'geodirectory'),
1506
-                                'bg' => __('BULGARIAN', 'geodirectory'),
1507
-                                'bn' => __('BENGALI', 'geodirectory'),
1508
-                                'ca' => __('CATALAN', 'geodirectory'),
1509
-                                'cs' => __('CZECH', 'geodirectory'),
1510
-                                'da' => __('DANISH', 'geodirectory'),
1511
-                                'de' => __('GERMAN', 'geodirectory'),
1512
-                                'el' => __('GREEK', 'geodirectory'),
1513
-                                'en' => __('ENGLISH', 'geodirectory'),
1514
-                                'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'),
1515
-                                'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'),
1516
-                                'es' => __('SPANISH', 'geodirectory'),
1517
-                                'eu' => __('BASQUE', 'geodirectory'),
1518
-                                'fa' => __('FARSI', 'geodirectory'),
1519
-                                'fi' => __('FINNISH', 'geodirectory'),
1520
-                                'fil' => __('FILIPINO', 'geodirectory'),
1521
-                                'fr' => __('FRENCH', 'geodirectory'),
1522
-                                'gl' => __('GALICIAN', 'geodirectory'),
1523
-                                'gu' => __('GUJARATI', 'geodirectory'),
1524
-                                'hi' => __('HINDI', 'geodirectory'),
1525
-                                'hr' => __('CROATIAN', 'geodirectory'),
1526
-                                'hu' => __('HUNGARIAN', 'geodirectory'),
1527
-                                'id' => __('INDONESIAN', 'geodirectory'),
1528
-                                'it' => __('ITALIAN', 'geodirectory'),
1529
-                                'iw' => __('HEBREW', 'geodirectory'),
1530
-                                'ja' => __('JAPANESE', 'geodirectory'),
1531
-                                'kn' => __('KANNADA', 'geodirectory'),
1532
-                                'ko' => __('KOREAN', 'geodirectory'),
1533
-                                'lt' => __('LITHUANIAN', 'geodirectory'),
1534
-                                'lv' => __('LATVIAN', 'geodirectory'),
1535
-                                'ml' => __('MALAYALAM', 'geodirectory'),
1536
-                                'mr' => __('MARATHI', 'geodirectory'),
1537
-                                'nl' => __('DUTCH', 'geodirectory'),
1538
-                                'no' => __('NORWEGIAN', 'geodirectory'),
1539
-                                'pl' => __('POLISH', 'geodirectory'),
1540
-                                'pt' => __('PORTUGUESE', 'geodirectory'),
1541
-                                'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'),
1542
-                                'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'),
1543
-                                'ro' => __('ROMANIAN', 'geodirectory'),
1544
-                                'ru' => __('RUSSIAN', 'geodirectory'),
1545
-                                'ru' => __('RUSSIAN', 'geodirectory'),
1546
-                                'sk' => __('SLOVAK', 'geodirectory'),
1547
-                                'sl' => __('SLOVENIAN', 'geodirectory'),
1548
-                                'sr' => __('SERBIAN', 'geodirectory'),
1549
-                                'sv' => __('	SWEDISH', 'geodirectory'),
1550
-                                'tl' => __('TAGALOG', 'geodirectory'),
1551
-                                'ta' => __('TAMIL', 'geodirectory'),
1552
-                                'te' => __('TELUGU', 'geodirectory'),
1553
-                                'th' => __('THAI', 'geodirectory'),
1554
-                                'tr' => __('TURKISH', 'geodirectory'),
1555
-                                'uk' => __('UKRAINIAN', 'geodirectory'),
1556
-                                'vi' => __('VIETNAMESE', 'geodirectory'),
1557
-                                'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'),
1558
-                                'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
1559
-                            );
1560
-                            $geodir_default_map_language = get_option('geodir_default_map_language');
1561
-                            if (empty($geodir_default_map_language))
1562
-                                $geodir_default_map_language = 'en';
1563
-                            foreach ($arr_map_langages as $language_key => $language_txt) {
1564
-                                if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language)
1565
-                                    $geodir_default_language_selected = "selected='selected'";
1566
-                                else
1567
-                                    $geodir_default_language_selected = '';
1568
-
1569
-                                ?>
1503
+							$arr_map_langages = array(
1504
+								'ar' => __('ARABIC', 'geodirectory'),
1505
+								'eu' => __('BASQUE', 'geodirectory'),
1506
+								'bg' => __('BULGARIAN', 'geodirectory'),
1507
+								'bn' => __('BENGALI', 'geodirectory'),
1508
+								'ca' => __('CATALAN', 'geodirectory'),
1509
+								'cs' => __('CZECH', 'geodirectory'),
1510
+								'da' => __('DANISH', 'geodirectory'),
1511
+								'de' => __('GERMAN', 'geodirectory'),
1512
+								'el' => __('GREEK', 'geodirectory'),
1513
+								'en' => __('ENGLISH', 'geodirectory'),
1514
+								'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'),
1515
+								'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'),
1516
+								'es' => __('SPANISH', 'geodirectory'),
1517
+								'eu' => __('BASQUE', 'geodirectory'),
1518
+								'fa' => __('FARSI', 'geodirectory'),
1519
+								'fi' => __('FINNISH', 'geodirectory'),
1520
+								'fil' => __('FILIPINO', 'geodirectory'),
1521
+								'fr' => __('FRENCH', 'geodirectory'),
1522
+								'gl' => __('GALICIAN', 'geodirectory'),
1523
+								'gu' => __('GUJARATI', 'geodirectory'),
1524
+								'hi' => __('HINDI', 'geodirectory'),
1525
+								'hr' => __('CROATIAN', 'geodirectory'),
1526
+								'hu' => __('HUNGARIAN', 'geodirectory'),
1527
+								'id' => __('INDONESIAN', 'geodirectory'),
1528
+								'it' => __('ITALIAN', 'geodirectory'),
1529
+								'iw' => __('HEBREW', 'geodirectory'),
1530
+								'ja' => __('JAPANESE', 'geodirectory'),
1531
+								'kn' => __('KANNADA', 'geodirectory'),
1532
+								'ko' => __('KOREAN', 'geodirectory'),
1533
+								'lt' => __('LITHUANIAN', 'geodirectory'),
1534
+								'lv' => __('LATVIAN', 'geodirectory'),
1535
+								'ml' => __('MALAYALAM', 'geodirectory'),
1536
+								'mr' => __('MARATHI', 'geodirectory'),
1537
+								'nl' => __('DUTCH', 'geodirectory'),
1538
+								'no' => __('NORWEGIAN', 'geodirectory'),
1539
+								'pl' => __('POLISH', 'geodirectory'),
1540
+								'pt' => __('PORTUGUESE', 'geodirectory'),
1541
+								'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'),
1542
+								'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'),
1543
+								'ro' => __('ROMANIAN', 'geodirectory'),
1544
+								'ru' => __('RUSSIAN', 'geodirectory'),
1545
+								'ru' => __('RUSSIAN', 'geodirectory'),
1546
+								'sk' => __('SLOVAK', 'geodirectory'),
1547
+								'sl' => __('SLOVENIAN', 'geodirectory'),
1548
+								'sr' => __('SERBIAN', 'geodirectory'),
1549
+								'sv' => __('	SWEDISH', 'geodirectory'),
1550
+								'tl' => __('TAGALOG', 'geodirectory'),
1551
+								'ta' => __('TAMIL', 'geodirectory'),
1552
+								'te' => __('TELUGU', 'geodirectory'),
1553
+								'th' => __('THAI', 'geodirectory'),
1554
+								'tr' => __('TURKISH', 'geodirectory'),
1555
+								'uk' => __('UKRAINIAN', 'geodirectory'),
1556
+								'vi' => __('VIETNAMESE', 'geodirectory'),
1557
+								'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'),
1558
+								'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
1559
+							);
1560
+							$geodir_default_map_language = get_option('geodir_default_map_language');
1561
+							if (empty($geodir_default_map_language))
1562
+								$geodir_default_map_language = 'en';
1563
+							foreach ($arr_map_langages as $language_key => $language_txt) {
1564
+								if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language)
1565
+									$geodir_default_language_selected = "selected='selected'";
1566
+								else
1567
+									$geodir_default_language_selected = '';
1568
+
1569
+								?>
1570 1570
                                 <option
1571 1571
                                     value="<?php echo $language_key?>" <?php echo $geodir_default_language_selected; ?>><?php echo $language_txt; ?></option>
1572 1572
 
1573 1573
                             <?php }
1574
-                            ?>
1574
+							?>
1575 1575
                         </select>
1576 1576
                     </td>
1577 1577
                 </tr>
@@ -1582,46 +1582,46 @@  discard block
 block discarded – undo
1582 1582
                     <td width="60%">
1583 1583
                         <select name="geodir_default_map_search_pt" style="width:60%">
1584 1584
                             <?php
1585
-                            $post_types = geodir_get_posttypes('array');
1586
-                            $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
1587
-                            if (empty($geodir_default_map_search_pt))
1588
-                                $geodir_default_map_search_pt = 'gd_place';
1589
-                            if (is_array($post_types)) {
1590
-                                foreach ($post_types as $key => $post_types_obj) {
1591
-                                    if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt)
1592
-                                        $geodir_search_pt_selected = "selected='selected'";
1593
-                                    else
1594
-                                        $geodir_search_pt_selected = '';
1595
-
1596
-                                    ?>
1585
+							$post_types = geodir_get_posttypes('array');
1586
+							$geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
1587
+							if (empty($geodir_default_map_search_pt))
1588
+								$geodir_default_map_search_pt = 'gd_place';
1589
+							if (is_array($post_types)) {
1590
+								foreach ($post_types as $key => $post_types_obj) {
1591
+									if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt)
1592
+										$geodir_search_pt_selected = "selected='selected'";
1593
+									else
1594
+										$geodir_search_pt_selected = '';
1595
+
1596
+									?>
1597 1597
                                     <option
1598 1598
                                         value="<?php echo $key?>" <?php echo $geodir_search_pt_selected; ?>><?php echo $post_types_obj['labels']['singular_name']; ?></option>
1599 1599
 
1600 1600
                                 <?php }
1601 1601
 
1602
-                            }
1602
+							}
1603 1603
 
1604
-                            ?>
1604
+							?>
1605 1605
                         </select>
1606 1606
                     </td>
1607 1607
                 </tr>
1608 1608
 
1609 1609
                 <?php
1610
-                break;
1610
+				break;
1611 1611
 
1612
-            case 'map':
1613
-                ?>
1612
+			case 'map':
1613
+				?>
1614 1614
                 <tr valign="top">
1615 1615
                     <td class="forminp">
1616 1616
                         <?php
1617
-                        global $post_cat, $cat_display;
1618
-                        $post_types = geodir_get_posttypes('object');
1619
-                        $cat_display = 'checkbox';
1620
-                        $gd_post_types = get_option('geodir_exclude_post_type_on_map');
1621
-                        $gd_cats = get_option('geodir_exclude_cat_on_map');
1622
-                        $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
1623
-                        $count = 1;
1624
-                        ?>
1617
+						global $post_cat, $cat_display;
1618
+						$post_types = geodir_get_posttypes('object');
1619
+						$cat_display = 'checkbox';
1620
+						$gd_post_types = get_option('geodir_exclude_post_type_on_map');
1621
+						$gd_cats = get_option('geodir_exclude_cat_on_map');
1622
+						$gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
1623
+						$count = 1;
1624
+						?>
1625 1625
                         <table width="70%" class="widefat">
1626 1626
                             <thead>
1627 1627
                             <tr>
@@ -1630,18 +1630,18 @@  discard block
 block discarded – undo
1630 1630
                                 <th><b><?php echo DESIGN_POST_TYPE_CAT; ?></b></th>
1631 1631
                             </tr>
1632 1632
                             <?php
1633
-                            $gd_categs = $gd_cats;
1634
-                            foreach ($post_types as $key => $post_types_obj) :
1635
-                                $checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : '';
1636
-                                $gd_taxonomy = geodir_get_taxonomies($key);
1637
-                                if ($gd_cats_upgrade) {
1638
-                                    $gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : '';
1639
-                                    $gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array();
1640
-                                    $gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array();
1641
-                                }
1642
-                                $post_cat = implode(',', $gd_cats);
1643
-                                $gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy);
1644
-                                ?>
1633
+							$gd_categs = $gd_cats;
1634
+							foreach ($post_types as $key => $post_types_obj) :
1635
+								$checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : '';
1636
+								$gd_taxonomy = geodir_get_taxonomies($key);
1637
+								if ($gd_cats_upgrade) {
1638
+									$gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : '';
1639
+									$gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array();
1640
+									$gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array();
1641
+								}
1642
+								$post_cat = implode(',', $gd_cats);
1643
+								$gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy);
1644
+								?>
1645 1645
                                 <tr>
1646 1646
                                     <td valign="top" width="5%"><?php echo $count; ?></td>
1647 1647
                                     <td valign="top" width="25%" id="td_post_types"><input type="checkbox"
@@ -1662,19 +1662,19 @@  discard block
 block discarded – undo
1662 1662
                     </td>
1663 1663
                 </tr>
1664 1664
                 <?php
1665
-                break;
1665
+				break;
1666 1666
 
1667
-            case 'checkbox' :
1667
+			case 'checkbox' :
1668 1668
 
1669
-                if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) :
1670
-                    ?>
1669
+				if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) :
1670
+					?>
1671 1671
                     <tr valign="top">
1672 1672
                     <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1673 1673
                     <td class="forminp">
1674 1674
                 <?php
1675
-                endif;
1675
+				endif;
1676 1676
 
1677
-                ?>
1677
+				?>
1678 1678
                 <fieldset>
1679 1679
                     <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend>
1680 1680
                     <label for="<?php echo $value['id'] ?>">
@@ -1684,49 +1684,49 @@  discard block
 block discarded – undo
1684 1684
                 </fieldset>
1685 1685
                 <?php
1686 1686
 
1687
-                if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) :
1688
-                    ?>
1687
+				if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) :
1688
+					?>
1689 1689
                     </td>
1690 1690
                     </tr>
1691 1691
                 <?php
1692
-                endif;
1692
+				endif;
1693 1693
 
1694
-                break;
1694
+				break;
1695 1695
 
1696
-            case 'radio' :
1696
+			case 'radio' :
1697 1697
 
1698
-                if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) :
1699
-                    ?>
1698
+				if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) :
1699
+					?>
1700 1700
                     <tr valign="top">
1701 1701
                     <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1702 1702
                     <td class="forminp">
1703 1703
                 <?php
1704
-                endif;
1704
+				endif;
1705 1705
 
1706
-                ?>
1706
+				?>
1707 1707
                 <fieldset>
1708 1708
                     <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend>
1709 1709
                     <label for="<?php echo $value['id'];?>">
1710 1710
                         <input name="<?php echo esc_attr($value['id']); ?>"
1711 1711
                                id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio"
1712 1712
                                value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) {
1713
-                            echo 'checked="checked"';
1714
-                        }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
1713
+							echo 'checked="checked"';
1714
+						}elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
1715 1715
                         <?php echo $value['desc']; ?></label><br>
1716 1716
                 </fieldset>
1717 1717
                 <?php
1718 1718
 
1719
-                if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) :
1720
-                    ?>
1719
+				if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) :
1720
+					?>
1721 1721
                     </td>
1722 1722
                     </tr>
1723 1723
                 <?php
1724
-                endif;
1724
+				endif;
1725 1725
 
1726
-                break;
1726
+				break;
1727 1727
 
1728
-            case 'textarea':
1729
-                ?>
1728
+			case 'textarea':
1729
+				?>
1730 1730
                 <tr valign="top">
1731 1731
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1732 1732
                 <td class="forminp">
@@ -1739,30 +1739,30 @@  discard block
 block discarded – undo
1739 1739
 
1740 1740
                 </td>
1741 1741
                 </tr><?php
1742
-                break;
1742
+				break;
1743 1743
 
1744
-            case 'editor':
1745
-                ?>
1744
+			case 'editor':
1745
+				?>
1746 1746
                 <tr valign="top">
1747 1747
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1748 1748
                 <td class="forminp"><?php
1749
-                    if (get_option($value['id']))
1750
-                        $content = stripslashes(get_option($value['id']));
1751
-                    else
1752
-                        $content = $value['std'];
1749
+					if (get_option($value['id']))
1750
+						$content = stripslashes(get_option($value['id']));
1751
+					else
1752
+						$content = $value['std'];
1753 1753
 
1754
-                    $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
1754
+					$editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
1755 1755
 
1756
-                    wp_editor($content, esc_attr($value['id']), $editor_settings);
1756
+					wp_editor($content, esc_attr($value['id']), $editor_settings);
1757 1757
 
1758
-                    ?> <span class="description"><?php echo $value['desc'] ?></span>
1758
+					?> <span class="description"><?php echo $value['desc'] ?></span>
1759 1759
 
1760 1760
                 </td>
1761 1761
                 </tr><?php
1762
-                break;
1762
+				break;
1763 1763
 
1764
-            case 'single_select_page' :
1765
-                // WPML
1764
+			case 'single_select_page' :
1765
+				// WPML
1766 1766
 				$switch_lang = false;
1767 1767
 				$disabled = '';
1768 1768
 				if (geodir_is_wpml() && isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') {
@@ -1780,18 +1780,18 @@  discard block
 block discarded – undo
1780 1780
 				//
1781 1781
 				$page_setting = (int)get_option($value['id']);
1782 1782
 
1783
-                $args = array('name' => $value['id'],
1784
-                    'id' => $value['id'],
1785
-                    'sort_column' => 'menu_order',
1786
-                    'sort_order' => 'ASC',
1787
-                    'show_option_none' => ' ',
1788
-                    'class' => $value['class'],
1789
-                    'echo' => false,
1790
-                    'selected' => $page_setting);
1783
+				$args = array('name' => $value['id'],
1784
+					'id' => $value['id'],
1785
+					'sort_column' => 'menu_order',
1786
+					'sort_order' => 'ASC',
1787
+					'show_option_none' => ' ',
1788
+					'class' => $value['class'],
1789
+					'echo' => false,
1790
+					'selected' => $page_setting);
1791 1791
 
1792
-                if (isset($value['args'])) $args = wp_parse_args($value['args'], $args);
1792
+				if (isset($value['args'])) $args = wp_parse_args($value['args'], $args);
1793 1793
 
1794
-                ?>
1794
+				?>
1795 1795
                 <tr valign="top" class="single_select_page">
1796 1796
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1797 1797
                 <td class="forminp">
@@ -1802,17 +1802,17 @@  discard block
 block discarded – undo
1802 1802
 				if ($switch_lang) {
1803 1803
 					$sitepress->switch_lang($switch_lang, true);
1804 1804
 				}
1805
-                break;
1806
-            case 'single_select_country' :
1807
-                $country_setting = (string)get_option($value['id']);
1808
-                if (strstr($country_setting, ':')) :
1809
-                    $country = current(explode(':', $country_setting));
1810
-                    $state = end(explode(':', $country_setting));
1811
-                else :
1812
-                    $country = $country_setting;
1813
-                    $state = '*';
1814
-                endif;
1815
-                ?>
1805
+				break;
1806
+			case 'single_select_country' :
1807
+				$country_setting = (string)get_option($value['id']);
1808
+				if (strstr($country_setting, ':')) :
1809
+					$country = current(explode(':', $country_setting));
1810
+					$state = end(explode(':', $country_setting));
1811
+				else :
1812
+					$country = $country_setting;
1813
+					$state = '*';
1814
+				endif;
1815
+				?>
1816 1816
                 <tr valign="top">
1817 1817
                 <th scope="rpw" class="titledesc"><?php echo $value['name'] ?></th>
1818 1818
                 <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>"
@@ -1823,12 +1823,12 @@  discard block
 block discarded – undo
1823 1823
                     </select> <span class="description"><?php echo $value['desc'] ?></span>
1824 1824
                 </td>
1825 1825
                 </tr><?php
1826
-                break;
1827
-            case 'multi_select_countries' :
1828
-                $countries = $geodirectory->countries->countries;
1829
-                asort($countries);
1830
-                $selections = (array)get_option($value['id']);
1831
-                ?>
1826
+				break;
1827
+			case 'multi_select_countries' :
1828
+				$countries = $geodirectory->countries->countries;
1829
+				asort($countries);
1830
+				$selections = (array)get_option($value['id']);
1831
+				?>
1832 1832
                 <tr valign="top">
1833 1833
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1834 1834
                 <td class="forminp">
@@ -1836,22 +1836,22 @@  discard block
 block discarded – undo
1836 1836
                             data-placeholder="<?php _e('Choose countries&hellip;', 'geodirectory'); ?>"
1837 1837
                             title="Country" class="chosen_select">
1838 1838
                         <?php
1839
-                        if ($countries) foreach ($countries as $key => $val) :
1840
-                            echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>';
1841
-                        endforeach;
1842
-                        ?>
1839
+						if ($countries) foreach ($countries as $key => $val) :
1840
+							echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>';
1841
+						endforeach;
1842
+						?>
1843 1843
                     </select>
1844 1844
                 </td>
1845 1845
                 </tr>
1846 1846
 
1847 1847
                 <?php
1848 1848
 
1849
-                break;
1849
+				break;
1850 1850
 
1851
-            case 'google_analytics' :
1852
-                $selections = (array)get_option($value['id']);
1853
-                if(get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret') ) {
1854
-                    ?>
1851
+			case 'google_analytics' :
1852
+				$selections = (array)get_option($value['id']);
1853
+				if(get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret') ) {
1854
+					?>
1855 1855
                     <tr valign="top">
1856 1856
                         <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1857 1857
                         <td class="forminp">
@@ -1859,19 +1859,19 @@  discard block
 block discarded – undo
1859 1859
 
1860 1860
                             <?php
1861 1861
 
1862
-                            $oAuthURL = "https://accounts.google.com/o/oauth2/auth?";
1863
-                            $scope = "scope=https://www.googleapis.com/auth/analytics.readonly";
1864
-                            $state = "&state=123";//any string
1865
-                            $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
1866
-                            $response_type = "&response_type=code";
1867
-                            $client_id = "&client_id=".get_option('geodir_ga_client_id');
1868
-                            $access_type = "&access_type=offline";
1869
-                            $approval_prompt = "&approval_prompt=force";
1862
+							$oAuthURL = "https://accounts.google.com/o/oauth2/auth?";
1863
+							$scope = "scope=https://www.googleapis.com/auth/analytics.readonly";
1864
+							$state = "&state=123";//any string
1865
+							$redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
1866
+							$response_type = "&response_type=code";
1867
+							$client_id = "&client_id=".get_option('geodir_ga_client_id');
1868
+							$access_type = "&access_type=offline";
1869
+							$approval_prompt = "&approval_prompt=force";
1870 1870
 
1871
-                            $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt;
1871
+							$auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt;
1872 1872
 
1873 1873
 
1874
-                            ?>
1874
+							?>
1875 1875
                             <script>
1876 1876
                                 function gd_ga_popup() {
1877 1877
                                     var win = window.open("<?php echo $auth_url;?>", "Google Analytics", "");
@@ -1886,47 +1886,47 @@  discard block
 block discarded – undo
1886 1886
                             </script>
1887 1887
 
1888 1888
                             <?php
1889
-                            if (get_option('gd_ga_refresh_token')) {
1890
-                                ?>
1889
+							if (get_option('gd_ga_refresh_token')) {
1890
+								?>
1891 1891
                                 <span class="button-primary"
1892 1892
                                       onclick="gd_ga_popup();"><?php _e('Re-authorize', 'geodirectory'); ?></span>
1893 1893
                                 <span
1894 1894
                                     style="color: green; font-weight: bold;"><?php _e('Authorized', 'geodirectory'); ?></span>
1895 1895
                             <?php
1896
-                            } else {
1897
-                                ?>
1896
+							} else {
1897
+								?>
1898 1898
                                 <span class="button-primary"
1899 1899
                                       onclick="gd_ga_popup();"><?php _e('Authorize', 'geodirectory');?></span>
1900 1900
                             <?php
1901
-                            }
1902
-                            ?>
1901
+							}
1902
+							?>
1903 1903
                         </td>
1904 1904
                     </tr>
1905 1905
 
1906 1906
                 <?php
1907
-                }
1907
+				}
1908 1908
 
1909
-                break;
1909
+				break;
1910 1910
 
1911
-            case 'field_seperator' :
1911
+			case 'field_seperator' :
1912 1912
 
1913
-                ?>
1913
+				?>
1914 1914
                 <tr valign="top">
1915 1915
                     <td colspan="2" class="forminp geodir_line_seperator"></td>
1916 1916
                 </tr>
1917 1917
                 <?php
1918 1918
 
1919
-                break;
1919
+				break;
1920 1920
 
1921
-        endswitch;
1921
+		endswitch;
1922 1922
 
1923
-    endforeach;
1923
+	endforeach;
1924 1924
 
1925
-    if ($first_title === false) {
1926
-        echo "</div>";
1927
-    }
1925
+	if ($first_title === false) {
1926
+		echo "</div>";
1927
+	}
1928 1928
 
1929
-    ?>
1929
+	?>
1930 1930
 
1931 1931
     <script type="text/javascript">
1932 1932
 
@@ -1986,33 +1986,33 @@  discard block
 block discarded – undo
1986 1986
  */
1987 1987
 function geodir_post_info_setting()
1988 1988
 {
1989
-    global $post, $post_id;
1990
-
1991
-    $post_type = get_post_type();
1992
-
1993
-    $package_info = array();
1994
-
1995
-    $package_info = geodir_post_package_info($package_info, $post, $post_type);
1996
-    wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename');
1997
-    echo '<div id="geodir_wrapper">';
1998
-    /**
1999
-     * Called before the GD custom fields are output in the wp-admin area.
2000
-     *
2001
-     * @since 1.0.0
2002
-     * @see 'geodir_after_default_field_in_meta_box'
2003
-     */
2004
-    do_action('geodir_before_default_field_in_meta_box');
2005
-    //geodir_get_custom_fields_html($package_info->pid,'default',$post_type);
2006
-    // to display all fields in one information box
2007
-    geodir_get_custom_fields_html($package_info->pid, 'all', $post_type);
2008
-    /**
2009
-     * Called after the GD custom fields are output in the wp-admin area.
2010
-     *
2011
-     * @since 1.0.0
2012
-     * @see 'geodir_before_default_field_in_meta_box'
2013
-     */
2014
-    do_action('geodir_after_default_field_in_meta_box');
2015
-    echo '</div>';
1989
+	global $post, $post_id;
1990
+
1991
+	$post_type = get_post_type();
1992
+
1993
+	$package_info = array();
1994
+
1995
+	$package_info = geodir_post_package_info($package_info, $post, $post_type);
1996
+	wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename');
1997
+	echo '<div id="geodir_wrapper">';
1998
+	/**
1999
+	 * Called before the GD custom fields are output in the wp-admin area.
2000
+	 *
2001
+	 * @since 1.0.0
2002
+	 * @see 'geodir_after_default_field_in_meta_box'
2003
+	 */
2004
+	do_action('geodir_before_default_field_in_meta_box');
2005
+	//geodir_get_custom_fields_html($package_info->pid,'default',$post_type);
2006
+	// to display all fields in one information box
2007
+	geodir_get_custom_fields_html($package_info->pid, 'all', $post_type);
2008
+	/**
2009
+	 * Called after the GD custom fields are output in the wp-admin area.
2010
+	 *
2011
+	 * @since 1.0.0
2012
+	 * @see 'geodir_before_default_field_in_meta_box'
2013
+	 */
2014
+	do_action('geodir_after_default_field_in_meta_box');
2015
+	echo '</div>';
2016 2016
 }
2017 2017
 
2018 2018
 /**
@@ -2025,18 +2025,18 @@  discard block
 block discarded – undo
2025 2025
  */
2026 2026
 function geodir_post_addinfo_setting()
2027 2027
 {
2028
-    global $post, $post_id;
2028
+	global $post, $post_id;
2029 2029
 
2030
-    $post_type = get_post_type();
2030
+	$post_type = get_post_type();
2031 2031
 
2032
-    $package_info = array();
2032
+	$package_info = array();
2033 2033
 
2034
-    $package_info = geodir_post_package_info($package_info, $post, $post_type);
2034
+	$package_info = geodir_post_package_info($package_info, $post, $post_type);
2035 2035
 
2036
-    wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename');
2037
-    echo '<div id="geodir_wrapper">';
2038
-    geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type);
2039
-    echo '</div>';
2036
+	wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename');
2037
+	echo '<div id="geodir_wrapper">';
2038
+	geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type);
2039
+	echo '</div>';
2040 2040
 
2041 2041
 }
2042 2042
 
@@ -2050,60 +2050,60 @@  discard block
 block discarded – undo
2050 2050
  */
2051 2051
 function geodir_post_attachments()
2052 2052
 {
2053
-    global $post, $post_id;
2053
+	global $post, $post_id;
2054 2054
 
2055
-    wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename');
2055
+	wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename');
2056 2056
 
2057
-    if (geodir_get_featured_image($post_id, 'thumbnail')) {
2058
-        echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
2059
-        geodir_show_featured_image($post_id, 'thumbnail');
2060
-    }
2057
+	if (geodir_get_featured_image($post_id, 'thumbnail')) {
2058
+		echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
2059
+		geodir_show_featured_image($post_id, 'thumbnail');
2060
+	}
2061 2061
 
2062
-    $image_limit = 0;
2062
+	$image_limit = 0;
2063 2063
 
2064
-    ?>
2064
+	?>
2065 2065
 
2066 2066
 
2067 2067
     <h5 class="form_title">
2068 2068
         <?php if ($image_limit != 0 && $image_limit == 1) {
2069
-            echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
2070
-        } ?>
2069
+			echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
2070
+		} ?>
2071 2071
         <?php if ($image_limit != 0 && $image_limit > 1) {
2072
-            echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
2073
-        } ?>
2072
+			echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
2073
+		} ?>
2074 2074
         <?php if ($image_limit == 0) {
2075
-            echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
2076
-        } ?>
2075
+			echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
2076
+		} ?>
2077 2077
     </h5>
2078 2078
 
2079 2079
 
2080 2080
     <?php
2081 2081
 
2082
-    $curImages = geodir_get_images($post_id);
2083
-    $place_img_array = array();
2082
+	$curImages = geodir_get_images($post_id);
2083
+	$place_img_array = array();
2084 2084
 
2085
-    if (!empty($curImages)):
2086
-        foreach ($curImages as $p_img):
2087
-            $place_img_array[] = $p_img->src;
2088
-        endforeach;
2089
-    endif;
2085
+	if (!empty($curImages)):
2086
+		foreach ($curImages as $p_img):
2087
+			$place_img_array[] = $p_img->src;
2088
+		endforeach;
2089
+	endif;
2090 2090
 
2091
-    if (!empty($place_img_array))
2092
-        $curImages = implode(',', $place_img_array);
2091
+	if (!empty($place_img_array))
2092
+		$curImages = implode(',', $place_img_array);
2093 2093
 
2094 2094
 
2095
-    // adjust values here
2096
-    $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
2095
+	// adjust values here
2096
+	$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
2097 2097
 
2098
-    $svalue = $curImages; // this will be initial value of the above form field. Image urls.
2098
+	$svalue = $curImages; // this will be initial value of the above form field. Image urls.
2099 2099
 
2100
-    $multiple = true; // allow multiple files upload
2100
+	$multiple = true; // allow multiple files upload
2101 2101
 
2102
-    $width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels)
2102
+	$width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels)
2103 2103
 
2104
-    $height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels)
2104
+	$height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels)
2105 2105
 
2106
-    ?>
2106
+	?>
2107 2107
 
2108 2108
     <div class="gtd-form_row clearfix" id="<?php echo $id; ?>dropbox" style="border:1px solid #999999;padding:5px;text-align:center;">
2109 2109
         <input type="hidden" name="<?php echo $id; ?>" id="<?php echo $id; ?>" value="<?php echo $svalue; ?>"/>
@@ -2145,13 +2145,13 @@  discard block
 block discarded – undo
2145 2145
  */
2146 2146
 function geodir_action_post_updated($post_ID, $post_after, $post_before)
2147 2147
 {
2148
-    $post_type = get_post_type($post_ID);
2148
+	$post_type = get_post_type($post_ID);
2149 2149
 
2150
-    if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
2151
-        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) {
2152
-            geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title);
2153
-        }
2154
-    }
2150
+	if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
2151
+		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) {
2152
+			geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title);
2153
+		}
2154
+	}
2155 2155
 }
2156 2156
 
2157 2157
 /**
@@ -2166,39 +2166,39 @@  discard block
 block discarded – undo
2166 2166
  */
2167 2167
 function geodir_notification_add_bcc_option($settings)
2168 2168
 {
2169
-    if (!empty($settings)) {
2170
-        $new_settings = array();
2171
-        foreach ($settings as $setting) {
2172
-            if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') {
2173
-                $geodir_bcc_listing_published_yes = array(
2174
-                    'name' => __('Listing published', 'geodirectory'),
2175
-                    'desc' => __('Yes', 'geodirectory'),
2176
-                    'id' => 'geodir_bcc_listing_published',
2177
-                    'std' => 'yes',
2178
-                    'type' => 'radio',
2179
-                    'value' => '1',
2180
-                    'radiogroup' => 'start'
2181
-                );
2182
-
2183
-                $geodir_bcc_listing_published_no = array(
2184
-                    'name' => __('Listing published', 'geodirectory'),
2185
-                    'desc' => __('No', 'geodirectory'),
2186
-                    'id' => 'geodir_bcc_listing_published',
2187
-                    'std' => 'yes',
2188
-                    'type' => 'radio',
2189
-                    'value' => '0',
2190
-                    'radiogroup' => 'end'
2191
-                );
2192
-
2193
-                $new_settings[] = $geodir_bcc_listing_published_yes;
2194
-                $new_settings[] = $geodir_bcc_listing_published_no;
2195
-            }
2196
-            $new_settings[] = $setting;
2197
-        }
2198
-        $settings = $new_settings;
2199
-    }
2169
+	if (!empty($settings)) {
2170
+		$new_settings = array();
2171
+		foreach ($settings as $setting) {
2172
+			if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') {
2173
+				$geodir_bcc_listing_published_yes = array(
2174
+					'name' => __('Listing published', 'geodirectory'),
2175
+					'desc' => __('Yes', 'geodirectory'),
2176
+					'id' => 'geodir_bcc_listing_published',
2177
+					'std' => 'yes',
2178
+					'type' => 'radio',
2179
+					'value' => '1',
2180
+					'radiogroup' => 'start'
2181
+				);
2182
+
2183
+				$geodir_bcc_listing_published_no = array(
2184
+					'name' => __('Listing published', 'geodirectory'),
2185
+					'desc' => __('No', 'geodirectory'),
2186
+					'id' => 'geodir_bcc_listing_published',
2187
+					'std' => 'yes',
2188
+					'type' => 'radio',
2189
+					'value' => '0',
2190
+					'radiogroup' => 'end'
2191
+				);
2192
+
2193
+				$new_settings[] = $geodir_bcc_listing_published_yes;
2194
+				$new_settings[] = $geodir_bcc_listing_published_no;
2195
+			}
2196
+			$new_settings[] = $setting;
2197
+		}
2198
+		$settings = $new_settings;
2199
+	}
2200 2200
 
2201
-    return $settings;
2201
+	return $settings;
2202 2202
 }
2203 2203
 
2204 2204
 
@@ -2213,19 +2213,19 @@  discard block
 block discarded – undo
2213 2213
  */
2214 2214
 function get_gd_theme_compat_callback()
2215 2215
 {
2216
-    global $wpdb;
2217
-    $themes = get_option('gd_theme_compats');
2218
-
2219
-    if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) {
2220
-        if (isset($_POST['export'])) {
2221
-            echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']]));
2222
-        } else {
2223
-            echo json_encode($themes[$_POST['theme']]);
2224
-        }
2216
+	global $wpdb;
2217
+	$themes = get_option('gd_theme_compats');
2225 2218
 
2226
-    }
2219
+	if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) {
2220
+		if (isset($_POST['export'])) {
2221
+			echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']]));
2222
+		} else {
2223
+			echo json_encode($themes[$_POST['theme']]);
2224
+		}
2225
+
2226
+	}
2227 2227
 
2228
-    die();
2228
+	die();
2229 2229
 }
2230 2230
 
2231 2231
 add_action('wp_ajax_get_gd_theme_compat_import_callback', 'get_gd_theme_compat_import_callback');
@@ -2239,20 +2239,20 @@  discard block
 block discarded – undo
2239 2239
  */
2240 2240
 function get_gd_theme_compat_import_callback()
2241 2241
 {
2242
-    global $wpdb;
2243
-    $themes = get_option('gd_theme_compats');
2244
-    if (isset($_POST['theme']) && !empty($_POST['theme'])) {
2245
-        $json = json_decode(stripslashes($_POST['theme']), true);
2246
-        if (!empty($json) && is_array($json)) {
2247
-            $key = sanitize_text_field(key($json));
2248
-            $themes[$key] = $json[$key];
2249
-            update_option('gd_theme_compats', $themes);
2250
-            echo $key;
2251
-            die();
2252
-        }
2253
-    }
2254
-    echo '0';
2255
-    die();
2242
+	global $wpdb;
2243
+	$themes = get_option('gd_theme_compats');
2244
+	if (isset($_POST['theme']) && !empty($_POST['theme'])) {
2245
+		$json = json_decode(stripslashes($_POST['theme']), true);
2246
+		if (!empty($json) && is_array($json)) {
2247
+			$key = sanitize_text_field(key($json));
2248
+			$themes[$key] = $json[$key];
2249
+			update_option('gd_theme_compats', $themes);
2250
+			echo $key;
2251
+			die();
2252
+		}
2253
+	}
2254
+	echo '0';
2255
+	die();
2256 2256
 }
2257 2257
 
2258 2258
 
@@ -2265,39 +2265,39 @@  discard block
 block discarded – undo
2265 2265
  */
2266 2266
 function gd_set_theme_compat()
2267 2267
 {
2268
-    global $wpdb;
2269
-    $theme = wp_get_theme();
2268
+	global $wpdb;
2269
+	$theme = wp_get_theme();
2270 2270
 
2271
-    if ($theme->parent()) {
2272
-        $theme_name = str_replace(" ", "_", $theme->parent()->get('Name'));
2273
-    } else {
2274
-        $theme_name = str_replace(" ", "_", $theme->get('Name'));
2275
-    }
2271
+	if ($theme->parent()) {
2272
+		$theme_name = str_replace(" ", "_", $theme->parent()->get('Name'));
2273
+	} else {
2274
+		$theme_name = str_replace(" ", "_", $theme->get('Name'));
2275
+	}
2276 2276
 
2277
-    $theme_compats = get_option('gd_theme_compats');
2278
-    $current_compat = get_option('gd_theme_compat');
2279
-    $current_compat = str_replace("_custom", "", $current_compat);
2277
+	$theme_compats = get_option('gd_theme_compats');
2278
+	$current_compat = get_option('gd_theme_compat');
2279
+	$current_compat = str_replace("_custom", "", $current_compat);
2280 2280
 
2281
-    if ($current_compat == $theme_name && strpos("_custom", get_option('gd_theme_compat')) !== false) {
2282
-        return;
2283
-    }// if already running correct compat then bail
2281
+	if ($current_compat == $theme_name && strpos("_custom", get_option('gd_theme_compat')) !== false) {
2282
+		return;
2283
+	}// if already running correct compat then bail
2284 2284
 
2285
-    if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it
2286
-        update_option('gd_theme_compat', $theme_name);
2287
-        update_option('theme_compatibility_setting', $theme_compats[$theme_name]);
2285
+	if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it
2286
+		update_option('gd_theme_compat', $theme_name);
2287
+		update_option('theme_compatibility_setting', $theme_compats[$theme_name]);
2288 2288
 
2289
-        // if there are default options to set then set them
2290
-        if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) {
2289
+		// if there are default options to set then set them
2290
+		if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) {
2291 2291
 
2292
-            foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) {
2293
-                update_option($key, $val);
2294
-            }
2295
-        }
2292
+			foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) {
2293
+				update_option($key, $val);
2294
+			}
2295
+		}
2296 2296
 
2297
-    } else {
2298
-        update_option('gd_theme_compat', '');
2299
-        update_option('theme_compatibility_setting', '');
2300
-    }
2297
+	} else {
2298
+		update_option('gd_theme_compat', '');
2299
+		update_option('theme_compatibility_setting', '');
2300
+	}
2301 2301
 
2302 2302
 
2303 2303
 }
@@ -2312,9 +2312,9 @@  discard block
 block discarded – undo
2312 2312
  */
2313 2313
 function gd_check_avada_compat()
2314 2314
 {
2315
-    if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) {
2316
-        add_action('admin_notices', 'gd_avada_compat_warning');
2317
-    }
2315
+	if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) {
2316
+		add_action('admin_notices', 'gd_avada_compat_warning');
2317
+	}
2318 2318
 }
2319 2319
 
2320 2320
 
@@ -2327,22 +2327,22 @@  discard block
 block discarded – undo
2327 2327
 function gd_avada_compat_warning()
2328 2328
 {
2329 2329
 
2330
-    /*
2330
+	/*
2331 2331
     $msg_type = error
2332 2332
     $msg_type = updated fade
2333 2333
     $msg_type = update-nag
2334 2334
     */
2335 2335
 
2336
-    $plugin = 'avada-nag';
2337
-    $timestamp = 'avada-nag1234';
2338
-    $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');
2339
-    echo '<div id="' . $timestamp . '"  class="error">';
2340
-    echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>';
2341
-    echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
2342
-    echo "<p>$message</p>";
2343
-    echo "</div>";
2336
+	$plugin = 'avada-nag';
2337
+	$timestamp = 'avada-nag1234';
2338
+	$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');
2339
+	echo '<div id="' . $timestamp . '"  class="error">';
2340
+	echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>';
2341
+	echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
2342
+	echo "<p>$message</p>";
2343
+	echo "</div>";
2344 2344
 
2345
-    ?>
2345
+	?>
2346 2346
     <script>
2347 2347
         function gdRemoveANotification($plugin, $timestamp) {
2348 2348
 
@@ -2410,10 +2410,10 @@  discard block
 block discarded – undo
2410 2410
  */
2411 2411
 function geodir_avada_remove_notification()
2412 2412
 {
2413
-    update_option('avada_nag', TRUE);
2413
+	update_option('avada_nag', TRUE);
2414 2414
 
2415
-    // Always die in functions echoing ajax content
2416
-    die();
2415
+	// Always die in functions echoing ajax content
2416
+	die();
2417 2417
 }
2418 2418
 
2419 2419
 
@@ -2435,9 +2435,9 @@  discard block
 block discarded – undo
2435 2435
 	global $post, $typenow, $current_screen;
2436 2436
 	
2437 2437
 	$post_type = NULL;
2438
-    if (isset($_REQUEST['post']) && get_post_type($_REQUEST['post']))
2438
+	if (isset($_REQUEST['post']) && get_post_type($_REQUEST['post']))
2439 2439
 		$post_type = get_post_type($_REQUEST['post']);
2440
-    elseif ($post && isset($post->post_type))
2440
+	elseif ($post && isset($post->post_type))
2441 2441
 		$post_type = $post->post_type;
2442 2442
 	elseif ($typenow)
2443 2443
 		$post_type = $typenow;
@@ -2472,7 +2472,7 @@  discard block
 block discarded – undo
2472 2472
 		// Don't allow same slug url for listing and location
2473 2473
 		if (geodir_strtolower($listing_prefix) == geodir_strtolower($location_prefix)) {
2474 2474
 			$redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab . '&msg=fail&gderr=21');
2475
-        	wp_redirect($redirect_url);
2475
+			wp_redirect($redirect_url);
2476 2476
 			exit;
2477 2477
 		}
2478 2478
 		
@@ -2502,10 +2502,10 @@  discard block
 block discarded – undo
2502 2502
  * @package GeoDirectory
2503 2503
  */
2504 2504
 function geodir_hide_admin_preview_button() {
2505
-    global $post_type;
2506
-    $post_types = geodir_get_posttypes();
2507
-    if(in_array($post_type, $post_types))
2508
-        echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
2505
+	global $post_type;
2506
+	$post_types = geodir_get_posttypes();
2507
+	if(in_array($post_type, $post_types))
2508
+		echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
2509 2509
 }
2510 2510
 add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' );
2511 2511
 add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' );
@@ -2520,7 +2520,7 @@  discard block
 block discarded – undo
2520 2520
  */
2521 2521
 function geodir_import_export_tab( $tabs ) {
2522 2522
 	$tabs['import_export'] = array( 'label' => __( 'Import & Export', 'geodirectory' ) );
2523
-    return $tabs;
2523
+	return $tabs;
2524 2524
 }
2525 2525
 
2526 2526
 /**
@@ -2535,26 +2535,26 @@  discard block
 block discarded – undo
2535 2535
 function geodir_import_export_page() {
2536 2536
 	$nonce = wp_create_nonce( 'geodir_import_export_nonce' );
2537 2537
 	$gd_cats_sample_csv = geodir_plugin_url() . '/geodirectory-assets/gd_sample_categories.csv';
2538
-    /**
2539
-     * Filter sample category data csv file url.
2540
-     *
2541
-     * @since 1.0.0
2542
-     * @package GeoDirectory
2543
-     *
2544
-     * @param string $gd_cats_sample_csv Sample category data csv file url.
2545
-     */
2538
+	/**
2539
+	 * Filter sample category data csv file url.
2540
+	 *
2541
+	 * @since 1.0.0
2542
+	 * @package GeoDirectory
2543
+	 *
2544
+	 * @param string $gd_cats_sample_csv Sample category data csv file url.
2545
+	 */
2546 2546
 	$gd_cats_sample_csv = apply_filters( 'geodir_export_cats_sample_csv', $gd_cats_sample_csv );
2547 2547
 	
2548 2548
 	$gd_posts_sample_csv = geodir_plugin_url() . '/geodirectory-assets/place_listing.csv';
2549
-    /**
2550
-     * Filter sample post data csv file url.
2551
-     *
2552
-     * @since 1.0.0
2553
-     * @package GeoDirectory
2554
-     *
2555
-     * @param string $gd_posts_sample_csv Sample post data csv file url.
2556
-     */
2557
-    $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv );
2549
+	/**
2550
+	 * Filter sample post data csv file url.
2551
+	 *
2552
+	 * @since 1.0.0
2553
+	 * @package GeoDirectory
2554
+	 *
2555
+	 * @param string $gd_posts_sample_csv Sample post data csv file url.
2556
+	 */
2557
+	$gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv );
2558 2558
 	
2559 2559
 	$gd_posttypes = geodir_get_posttypes( 'array' );
2560 2560
 	
@@ -2577,14 +2577,14 @@  discard block
 block discarded – undo
2577 2577
 	$gd_chunksize_options[100000] = 100000;
2578 2578
 	 
2579 2579
 	 /**
2580
-     * Filter max entries per export csv file.
2581
-     *
2582
-     * @since 1.5.6
2583
-     * @package GeoDirectory
2584
-     *
2585
-     * @param string $gd_chunksize_options Entries options.
2586
-     */
2587
-    $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options );
2580
+	  * Filter max entries per export csv file.
2581
+	  *
2582
+	  * @since 1.5.6
2583
+	  * @package GeoDirectory
2584
+	  *
2585
+	  * @param string $gd_chunksize_options Entries options.
2586
+	  */
2587
+	$gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options );
2588 2588
 	
2589 2589
 	$gd_chunksize_option = '';
2590 2590
 	foreach ($gd_chunksize_options as $value => $title) {
@@ -2600,12 +2600,12 @@  discard block
 block discarded – undo
2600 2600
   <div class="gd-content-heading">
2601 2601
 
2602 2602
   <?php
2603
-    ini_set('max_execution_time', 999999);
2604
-    $ini_max_execution_time_check = @ini_get( 'max_execution_time' );
2605
-    ini_restore('max_execution_time');
2603
+	ini_set('max_execution_time', 999999);
2604
+	$ini_max_execution_time_check = @ini_get( 'max_execution_time' );
2605
+	ini_restore('max_execution_time');
2606 2606
 
2607
-    if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
2608
-        ?>
2607
+	if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
2608
+		?>
2609 2609
 	<div id="gd_ie_reqs" class="metabox-holder">
2610 2610
       <div class="meta-box-sortables ui-sortable">
2611 2611
         <div class="postbox">
@@ -2774,7 +2774,7 @@  discard block
 block discarded – undo
2774 2774
 						 * Called just after the sample CSV download link.
2775 2775
 						 *
2776 2776
 						 * @since 1.0.0
2777
-                         * @package GeoDirectory
2777
+						 * @package GeoDirectory
2778 2778
 						 */
2779 2779
 						do_action('geodir_sample_cats_csv_download_link');
2780 2780
 						?>
@@ -2859,11 +2859,11 @@  discard block
 block discarded – undo
2859 2859
 	 *
2860 2860
 	 * Called after the last setting on the GD > Import & Export page.
2861 2861
 	 * @since 1.4.6
2862
-     * @package GeoDirectory
2862
+	 * @package GeoDirectory
2863 2863
 	 *
2864 2864
 	 * @param array $gd_posttypes GD post types.
2865
-     * @param array $gd_chunksize_options File chunk size options.
2866
-     * @param string $nonce Wordpress security token for GD import & export.
2865
+	 * @param array $gd_chunksize_options File chunk size options.
2866
+	 * @param string $nonce Wordpress security token for GD import & export.
2867 2867
 	 */
2868 2868
 	do_action( 'geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce );
2869 2869
 	?>
@@ -3520,44 +3520,44 @@  discard block
 block discarded – undo
3520 3520
 function geodir_init_filesystem()
3521 3521
 {
3522 3522
 
3523
-    if(!function_exists('get_filesystem_method')){
3524
-        require_once(ABSPATH."/wp-admin/includes/file.php");
3525
-    }
3526
-    $access_type = get_filesystem_method();
3527
-    if ($access_type === 'direct') {
3528
-        /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
3529
-        $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3530
-
3531
-        /* initialize the API */
3532
-        if (!WP_Filesystem($creds)) {
3533
-            /* any problems and we exit */
3534
-            //return '@@@3';
3535
-            return false;
3536
-        }
3537
-
3538
-        global $wp_filesystem;
3539
-        return $wp_filesystem;
3540
-        /* do our file manipulations below */
3541
-    } elseif (defined('FTP_USER')) {
3542
-        $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3523
+	if(!function_exists('get_filesystem_method')){
3524
+		require_once(ABSPATH."/wp-admin/includes/file.php");
3525
+	}
3526
+	$access_type = get_filesystem_method();
3527
+	if ($access_type === 'direct') {
3528
+		/* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
3529
+		$creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3530
+
3531
+		/* initialize the API */
3532
+		if (!WP_Filesystem($creds)) {
3533
+			/* any problems and we exit */
3534
+			//return '@@@3';
3535
+			return false;
3536
+		}
3543 3537
 
3544
-        /* initialize the API */
3545
-        if (!WP_Filesystem($creds)) {
3546
-            /* any problems and we exit */
3547
-            //return '@@@33';
3548
-            return false;
3549
-        }
3538
+		global $wp_filesystem;
3539
+		return $wp_filesystem;
3540
+		/* do our file manipulations below */
3541
+	} elseif (defined('FTP_USER')) {
3542
+		$creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3543
+
3544
+		/* initialize the API */
3545
+		if (!WP_Filesystem($creds)) {
3546
+			/* any problems and we exit */
3547
+			//return '@@@33';
3548
+			return false;
3549
+		}
3550 3550
 
3551
-        global $wp_filesystem;
3552
-        //return '@@@1';
3553
-        return $wp_filesystem;
3551
+		global $wp_filesystem;
3552
+		//return '@@@1';
3553
+		return $wp_filesystem;
3554 3554
 
3555
-    } else {
3556
-        //return '@@@2';
3557
-        /* don't have direct write access. Prompt user with our notice */
3558
-        add_action('admin_notice', 'geodir_filesystem_notice');
3559
-        return false;
3560
-    }
3555
+	} else {
3556
+		//return '@@@2';
3557
+		/* don't have direct write access. Prompt user with our notice */
3558
+		add_action('admin_notice', 'geodir_filesystem_notice');
3559
+		return false;
3560
+	}
3561 3561
 
3562 3562
 }
3563 3563
 
@@ -3575,10 +3575,10 @@  discard block
 block discarded – undo
3575 3575
  */
3576 3576
 function geodir_filesystem_notice()
3577 3577
 {   if ( defined( 'DOING_AJAX' ) ){return;}
3578
-    $access_type = get_filesystem_method();
3579
-    if ($access_type === 'direct') {
3580
-    } elseif (!defined('FTP_USER')) {
3581
-        ?>
3578
+	$access_type = get_filesystem_method();
3579
+	if ($access_type === 'direct') {
3580
+	} elseif (!defined('FTP_USER')) {
3581
+		?>
3582 3582
         <div class="error">
3583 3583
             <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'); ?>
3584 3584
                 <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>
@@ -3604,1229 +3604,1229 @@  discard block
 block discarded – undo
3604 3604
  * @return string Json data.
3605 3605
  */
3606 3606
 function geodir_ajax_import_export() {
3607
-    global $wpdb, $plugin_prefix, $current_user, $wp_filesystem;
3607
+	global $wpdb, $plugin_prefix, $current_user, $wp_filesystem;
3608 3608
     
3609
-    error_reporting(0);
3609
+	error_reporting(0);
3610 3610
 
3611
-    // try to set higher limits for import
3612
-    $max_input_time = ini_get('max_input_time');
3613
-    $max_execution_time = ini_get('max_execution_time');
3614
-    $memory_limit= ini_get('memory_limit');
3611
+	// try to set higher limits for import
3612
+	$max_input_time = ini_get('max_input_time');
3613
+	$max_execution_time = ini_get('max_execution_time');
3614
+	$memory_limit= ini_get('memory_limit');
3615 3615
 
3616
-    if(!$max_input_time || $max_input_time<3000){
3617
-        ini_set('max_input_time', 3000);
3618
-    }
3616
+	if(!$max_input_time || $max_input_time<3000){
3617
+		ini_set('max_input_time', 3000);
3618
+	}
3619 3619
 
3620
-    if(!$max_execution_time || $max_execution_time<3000){
3621
-        ini_set('max_execution_time', 3000);
3622
-    }
3620
+	if(!$max_execution_time || $max_execution_time<3000){
3621
+		ini_set('max_execution_time', 3000);
3622
+	}
3623 3623
 
3624
-    if($memory_limit && str_replace('M','',$memory_limit)){
3625
-        if(str_replace('M','',$memory_limit)<256){
3626
-            ini_set('memory_limit', '256M');
3627
-        }
3628
-    }
3624
+	if($memory_limit && str_replace('M','',$memory_limit)){
3625
+		if(str_replace('M','',$memory_limit)<256){
3626
+			ini_set('memory_limit', '256M');
3627
+		}
3628
+	}
3629 3629
 
3630
-    $json = array();
3630
+	$json = array();
3631 3631
 
3632
-    if ( !current_user_can( 'manage_options' ) ) {
3633
-        wp_send_json( $json );
3634
-    }
3632
+	if ( !current_user_can( 'manage_options' ) ) {
3633
+		wp_send_json( $json );
3634
+	}
3635 3635
 
3636
-    $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL;
3637
-    $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL;
3638
-    $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false;
3636
+	$task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL;
3637
+	$nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL;
3638
+	$stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false;
3639 3639
 
3640
-    if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
3641
-        wp_send_json( $json );
3642
-    }
3640
+	if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
3641
+		wp_send_json( $json );
3642
+	}
3643 3643
 
3644
-    $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL;
3645
-    $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL;
3646
-    $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page;
3647
-    $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1;
3644
+	$post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL;
3645
+	$chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL;
3646
+	$chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page;
3647
+	$chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1;
3648 3648
 
3649
-    $wp_filesystem = geodir_init_filesystem();
3650
-    if (!$wp_filesystem) {
3651
-        $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' );
3652
-        wp_send_json( $json );
3653
-    }
3649
+	$wp_filesystem = geodir_init_filesystem();
3650
+	if (!$wp_filesystem) {
3651
+		$json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' );
3652
+		wp_send_json( $json );
3653
+	}
3654 3654
 
3655
-    if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
3656
-        $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' );
3657
-        wp_send_json( $json );
3658
-    }
3655
+	if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
3656
+		$json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' );
3657
+		wp_send_json( $json );
3658
+	}
3659 3659
 
3660
-    $csv_file_dir = geodir_path_import_export( false );
3661
-    if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
3662
-        if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
3663
-            $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' );
3664
-            wp_send_json( $json );
3665
-        }
3666
-    }
3660
+	$csv_file_dir = geodir_path_import_export( false );
3661
+	if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
3662
+		if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
3663
+			$json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' );
3664
+			wp_send_json( $json );
3665
+		}
3666
+	}
3667 3667
     
3668
-    $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
3669
-    $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
3670
-
3671
-    switch ( $task ) {
3672
-        case 'export_posts': {
3673
-            // WPML
3674
-            $is_wpml = geodir_is_wpml();
3675
-            if ($is_wpml) {
3676
-                global $sitepress;
3677
-                $active_lang = ICL_LANGUAGE_CODE;
3668
+	$location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
3669
+	$neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
3670
+
3671
+	switch ( $task ) {
3672
+		case 'export_posts': {
3673
+			// WPML
3674
+			$is_wpml = geodir_is_wpml();
3675
+			if ($is_wpml) {
3676
+				global $sitepress;
3677
+				$active_lang = ICL_LANGUAGE_CODE;
3678 3678
                 
3679
-                $sitepress->switch_lang('all', true);
3680
-            }
3681
-            // WPML
3682
-            if ( $post_type == 'gd_event' ) {
3683
-                add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 );
3684
-            }
3685
-            $file_name = $post_type . '_' . date( 'dmyHi' );
3686
-            $posts_count = geodir_get_posts_count( $post_type );
3687
-            $file_url_base = geodir_path_import_export() . '/';
3688
-            $file_url = $file_url_base . $file_name . '.csv';
3689
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3690
-            $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv';
3679
+				$sitepress->switch_lang('all', true);
3680
+			}
3681
+			// WPML
3682
+			if ( $post_type == 'gd_event' ) {
3683
+				add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 );
3684
+			}
3685
+			$file_name = $post_type . '_' . date( 'dmyHi' );
3686
+			$posts_count = geodir_get_posts_count( $post_type );
3687
+			$file_url_base = geodir_path_import_export() . '/';
3688
+			$file_url = $file_url_base . $file_name . '.csv';
3689
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
3690
+			$file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv';
3691 3691
             
3692
-            $chunk_file_paths = array();
3692
+			$chunk_file_paths = array();
3693 3693
 
3694
-            if ( isset( $_REQUEST['_st'] ) ) {
3695
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3696
-                $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0;
3697
-                $percentage = min( $percentage, 100 );
3694
+			if ( isset( $_REQUEST['_st'] ) ) {
3695
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
3696
+				$percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0;
3697
+				$percentage = min( $percentage, 100 );
3698 3698
                 
3699
-                $json['percentage'] = $percentage;
3700
-                // WPML
3701
-                if ($is_wpml) {
3702
-                    $sitepress->switch_lang($active_lang, true);
3703
-                }
3704
-                // WPML
3705
-                wp_send_json( $json );
3706
-                gd_die();
3707
-            } else {
3708
-                if ( !$posts_count > 0 ) {
3709
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3710
-                } else {
3711
-                    $total_posts = $posts_count;
3712
-                    if ($chunk_per_page > $total_posts) {
3713
-                        $chunk_per_page = $total_posts;
3714
-                    }
3715
-                    $chunk_total_pages = ceil( $total_posts / $chunk_per_page );
3699
+				$json['percentage'] = $percentage;
3700
+				// WPML
3701
+				if ($is_wpml) {
3702
+					$sitepress->switch_lang($active_lang, true);
3703
+				}
3704
+				// WPML
3705
+				wp_send_json( $json );
3706
+				gd_die();
3707
+			} else {
3708
+				if ( !$posts_count > 0 ) {
3709
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
3710
+				} else {
3711
+					$total_posts = $posts_count;
3712
+					if ($chunk_per_page > $total_posts) {
3713
+						$chunk_per_page = $total_posts;
3714
+					}
3715
+					$chunk_total_pages = ceil( $total_posts / $chunk_per_page );
3716 3716
                     
3717
-                    $j = $chunk_page_no;
3718
-                    $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j );
3717
+					$j = $chunk_page_no;
3718
+					$chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j );
3719 3719
                     
3720
-                    $per_page = 500;
3721
-                    if ($per_page > $chunk_per_page) {
3722
-                        $per_page = $chunk_per_page;
3723
-                    }
3724
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3720
+					$per_page = 500;
3721
+					if ($per_page > $chunk_per_page) {
3722
+						$per_page = $chunk_per_page;
3723
+					}
3724
+					$total_pages = ceil( $chunk_per_page / $per_page );
3725 3725
                     
3726
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3727
-                        $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page );
3726
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
3727
+						$save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page );
3728 3728
                         
3729
-                        $clear = $i == 0 ? true : false;
3730
-                        geodir_save_csv_data( $file_path_temp, $save_posts, $clear );
3731
-                    }
3729
+						$clear = $i == 0 ? true : false;
3730
+						geodir_save_csv_data( $file_path_temp, $save_posts, $clear );
3731
+					}
3732 3732
                         
3733
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3734
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3735
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3736
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3737
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3733
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
3734
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3735
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
3736
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
3737
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
3738 3738
                         
3739
-                        $file_url = $file_url_base . $chunk_file_name;
3740
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3741
-                    }
3739
+						$file_url = $file_url_base . $chunk_file_name;
3740
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3741
+					}
3742 3742
                     
3743
-                    if ( !empty($chunk_file_paths) ) {
3744
-                        $json['total'] = $posts_count;
3745
-                        $json['files'] = $chunk_file_paths;
3746
-                    } else {
3747
-                        if ($j > 1) {
3748
-                            $json['total'] = $posts_count;
3749
-                            $json['files'] = array();
3750
-                        } else {
3751
-                            $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3752
-                        }
3753
-                    }
3754
-                }
3755
-                // WPML
3756
-                if ($is_wpml) {
3757
-                    $sitepress->switch_lang($active_lang, true);
3758
-                }
3759
-                // WPML
3760
-                wp_send_json( $json );
3761
-            }
3762
-        }
3763
-        break;
3764
-        case 'export_cats': {
3765
-            // WPML
3766
-            $is_wpml = geodir_is_wpml();
3767
-            if ($is_wpml) {
3768
-                global $sitepress;
3769
-                $active_lang = ICL_LANGUAGE_CODE;
3743
+					if ( !empty($chunk_file_paths) ) {
3744
+						$json['total'] = $posts_count;
3745
+						$json['files'] = $chunk_file_paths;
3746
+					} else {
3747
+						if ($j > 1) {
3748
+							$json['total'] = $posts_count;
3749
+							$json['files'] = array();
3750
+						} else {
3751
+							$json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3752
+						}
3753
+					}
3754
+				}
3755
+				// WPML
3756
+				if ($is_wpml) {
3757
+					$sitepress->switch_lang($active_lang, true);
3758
+				}
3759
+				// WPML
3760
+				wp_send_json( $json );
3761
+			}
3762
+		}
3763
+		break;
3764
+		case 'export_cats': {
3765
+			// WPML
3766
+			$is_wpml = geodir_is_wpml();
3767
+			if ($is_wpml) {
3768
+				global $sitepress;
3769
+				$active_lang = ICL_LANGUAGE_CODE;
3770 3770
                 
3771
-                $sitepress->switch_lang('all', true);
3772
-            }
3773
-            // WPML
3774
-            $file_name = $post_type . 'category_' . date( 'dmyHi' );
3771
+				$sitepress->switch_lang('all', true);
3772
+			}
3773
+			// WPML
3774
+			$file_name = $post_type . 'category_' . date( 'dmyHi' );
3775 3775
             
3776
-            $terms_count = geodir_get_terms_count( $post_type );
3777
-            $file_url_base = geodir_path_import_export() . '/';
3778
-            $file_url = $file_url_base . $file_name . '.csv';
3779
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3780
-            $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv';
3776
+			$terms_count = geodir_get_terms_count( $post_type );
3777
+			$file_url_base = geodir_path_import_export() . '/';
3778
+			$file_url = $file_url_base . $file_name . '.csv';
3779
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
3780
+			$file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv';
3781 3781
             
3782
-            $chunk_file_paths = array();
3782
+			$chunk_file_paths = array();
3783 3783
             
3784
-            if ( isset( $_REQUEST['_st'] ) ) {
3785
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3786
-                $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0;
3787
-                $percentage = min( $percentage, 100 );
3784
+			if ( isset( $_REQUEST['_st'] ) ) {
3785
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
3786
+				$percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0;
3787
+				$percentage = min( $percentage, 100 );
3788 3788
                 
3789
-                $json['percentage'] = $percentage;
3790
-                // WPML
3791
-                if ($is_wpml) {
3792
-                    $sitepress->switch_lang($active_lang, true);
3793
-                }
3794
-                // WPML
3795
-                wp_send_json( $json );
3796
-            } else {
3797
-                if ( !$terms_count > 0 ) {
3798
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3799
-                } else {
3800
-                    $total_terms = $terms_count;
3801
-                    if ($chunk_per_page > $terms_count) {
3802
-                        $chunk_per_page = $terms_count;
3803
-                    }
3804
-                    $chunk_total_pages = ceil( $total_terms / $chunk_per_page );
3789
+				$json['percentage'] = $percentage;
3790
+				// WPML
3791
+				if ($is_wpml) {
3792
+					$sitepress->switch_lang($active_lang, true);
3793
+				}
3794
+				// WPML
3795
+				wp_send_json( $json );
3796
+			} else {
3797
+				if ( !$terms_count > 0 ) {
3798
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
3799
+				} else {
3800
+					$total_terms = $terms_count;
3801
+					if ($chunk_per_page > $terms_count) {
3802
+						$chunk_per_page = $terms_count;
3803
+					}
3804
+					$chunk_total_pages = ceil( $total_terms / $chunk_per_page );
3805 3805
                     
3806
-                    $j = $chunk_page_no;
3807
-                    $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j );
3806
+					$j = $chunk_page_no;
3807
+					$chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j );
3808 3808
                     
3809
-                    $per_page = 500;
3810
-                    if ($per_page > $chunk_per_page) {
3811
-                        $per_page = $chunk_per_page;
3812
-                    }
3813
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3809
+					$per_page = 500;
3810
+					if ($per_page > $chunk_per_page) {
3811
+						$per_page = $chunk_per_page;
3812
+					}
3813
+					$total_pages = ceil( $chunk_per_page / $per_page );
3814 3814
                     
3815
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3816
-                        $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page );
3815
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
3816
+						$save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page );
3817 3817
                         
3818
-                        $clear = $i == 0 ? true : false;
3819
-                        geodir_save_csv_data( $file_path_temp, $save_terms, $clear );
3820
-                    }
3818
+						$clear = $i == 0 ? true : false;
3819
+						geodir_save_csv_data( $file_path_temp, $save_terms, $clear );
3820
+					}
3821 3821
                     
3822
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3823
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3824
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3825
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3826
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3822
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
3823
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3824
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
3825
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
3826
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
3827 3827
                         
3828
-                        $file_url = $file_url_base . $chunk_file_name;
3829
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3830
-                    }
3828
+						$file_url = $file_url_base . $chunk_file_name;
3829
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3830
+					}
3831 3831
                     
3832
-                    if ( !empty($chunk_file_paths) ) {
3833
-                        $json['total'] = $terms_count;
3834
-                        $json['files'] = $chunk_file_paths;
3835
-                    } else {
3836
-                        $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3837
-                    }
3838
-                }
3839
-                // WPML
3840
-                if ($is_wpml) {
3841
-                    $sitepress->switch_lang($active_lang, true);
3842
-                }
3843
-                // WPML
3844
-                wp_send_json( $json );
3845
-            }
3846
-        }
3847
-        break;
3848
-        case 'export_locations': {
3849
-            $file_url_base = geodir_path_import_export() . '/';
3850
-            $file_name = 'gd_locations_' . date( 'dmyHi' );
3851
-            $file_url = $file_url_base . $file_name . '.csv';
3852
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3853
-            $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv';
3832
+					if ( !empty($chunk_file_paths) ) {
3833
+						$json['total'] = $terms_count;
3834
+						$json['files'] = $chunk_file_paths;
3835
+					} else {
3836
+						$json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3837
+					}
3838
+				}
3839
+				// WPML
3840
+				if ($is_wpml) {
3841
+					$sitepress->switch_lang($active_lang, true);
3842
+				}
3843
+				// WPML
3844
+				wp_send_json( $json );
3845
+			}
3846
+		}
3847
+		break;
3848
+		case 'export_locations': {
3849
+			$file_url_base = geodir_path_import_export() . '/';
3850
+			$file_name = 'gd_locations_' . date( 'dmyHi' );
3851
+			$file_url = $file_url_base . $file_name . '.csv';
3852
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
3853
+			$file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv';
3854 3854
             
3855
-            $items_count = (int)geodir_location_imex_count_locations();
3855
+			$items_count = (int)geodir_location_imex_count_locations();
3856 3856
             
3857
-            if ( isset( $_REQUEST['_st'] ) ) {
3858
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3859
-                $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3860
-                $percentage = min( $percentage, 100 );
3857
+			if ( isset( $_REQUEST['_st'] ) ) {
3858
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
3859
+				$percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3860
+				$percentage = min( $percentage, 100 );
3861 3861
                 
3862
-                $json['percentage'] = $percentage;
3863
-                wp_send_json( $json );
3864
-            } else {
3865
-                $chunk_file_paths = array();
3862
+				$json['percentage'] = $percentage;
3863
+				wp_send_json( $json );
3864
+			} else {
3865
+				$chunk_file_paths = array();
3866 3866
                 
3867
-                if ( !$items_count > 0 ) {
3868
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3869
-                } else {
3870
-                    $chunk_per_page = min( $chunk_per_page, $items_count );
3871
-                    $chunk_total_pages = ceil( $items_count / $chunk_per_page );
3867
+				if ( !$items_count > 0 ) {
3868
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
3869
+				} else {
3870
+					$chunk_per_page = min( $chunk_per_page, $items_count );
3871
+					$chunk_total_pages = ceil( $items_count / $chunk_per_page );
3872 3872
                     
3873
-                    $j = $chunk_page_no;
3874
-                    $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j );
3873
+					$j = $chunk_page_no;
3874
+					$chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j );
3875 3875
                     
3876
-                    $per_page = 500;
3877
-                    $per_page = min( $per_page, $chunk_per_page );
3878
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3876
+					$per_page = 500;
3877
+					$per_page = min( $per_page, $chunk_per_page );
3878
+					$total_pages = ceil( $chunk_per_page / $per_page );
3879 3879
                     
3880
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3881
-                        $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3880
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
3881
+						$save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3882 3882
                         
3883
-                        $clear = $i == 0 ? true : false;
3884
-                        geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3885
-                    }
3883
+						$clear = $i == 0 ? true : false;
3884
+						geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3885
+					}
3886 3886
                     
3887
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3888
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3889
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3890
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3891
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3887
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
3888
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3889
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
3890
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
3891
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
3892 3892
                         
3893
-                        $file_url = $file_url_base . $chunk_file_name;
3894
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3895
-                    }
3893
+						$file_url = $file_url_base . $chunk_file_name;
3894
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3895
+					}
3896 3896
                     
3897
-                    if ( !empty($chunk_file_paths) ) {
3898
-                        $json['total'] = $items_count;
3899
-                        $json['files'] = $chunk_file_paths;
3900
-                    } else {
3901
-                        $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3902
-                    }
3903
-                }
3904
-                wp_send_json( $json );
3905
-            }
3906
-        }
3907
-        break;
3908
-        case 'export_hoods': {
3909
-            $file_url_base = geodir_path_import_export() . '/';
3910
-            $file_name = 'gd_neighbourhoods_' . date( 'dmyHi' );
3911
-            $file_url = $file_url_base . $file_name . '.csv';
3912
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3913
-            $file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv';
3897
+					if ( !empty($chunk_file_paths) ) {
3898
+						$json['total'] = $items_count;
3899
+						$json['files'] = $chunk_file_paths;
3900
+					} else {
3901
+						$json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3902
+					}
3903
+				}
3904
+				wp_send_json( $json );
3905
+			}
3906
+		}
3907
+		break;
3908
+		case 'export_hoods': {
3909
+			$file_url_base = geodir_path_import_export() . '/';
3910
+			$file_name = 'gd_neighbourhoods_' . date( 'dmyHi' );
3911
+			$file_url = $file_url_base . $file_name . '.csv';
3912
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
3913
+			$file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv';
3914 3914
             
3915
-            $items_count = (int)geodir_location_imex_count_neighbourhoods();
3915
+			$items_count = (int)geodir_location_imex_count_neighbourhoods();
3916 3916
             
3917
-            if ( isset( $_REQUEST['_st'] ) ) {
3918
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3919
-                $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3920
-                $percentage = min( $percentage, 100 );
3917
+			if ( isset( $_REQUEST['_st'] ) ) {
3918
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
3919
+				$percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3920
+				$percentage = min( $percentage, 100 );
3921 3921
                 
3922
-                $json['percentage'] = $percentage;
3923
-                wp_send_json( $json );
3924
-            } else {
3925
-                $chunk_file_paths = array();
3922
+				$json['percentage'] = $percentage;
3923
+				wp_send_json( $json );
3924
+			} else {
3925
+				$chunk_file_paths = array();
3926 3926
                 
3927
-                if ( !$items_count > 0 ) {
3928
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3929
-                } else {
3930
-                    $chunk_per_page = min( $chunk_per_page, $items_count );
3931
-                    $chunk_total_pages = ceil( $items_count / $chunk_per_page );
3927
+				if ( !$items_count > 0 ) {
3928
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
3929
+				} else {
3930
+					$chunk_per_page = min( $chunk_per_page, $items_count );
3931
+					$chunk_total_pages = ceil( $items_count / $chunk_per_page );
3932 3932
                     
3933
-                    $j = $chunk_page_no;
3934
-                    $chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j );
3933
+					$j = $chunk_page_no;
3934
+					$chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j );
3935 3935
                     
3936
-                    $per_page = 500;
3937
-                    $per_page = min( $per_page, $chunk_per_page );
3938
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3936
+					$per_page = 500;
3937
+					$per_page = min( $per_page, $chunk_per_page );
3938
+					$total_pages = ceil( $chunk_per_page / $per_page );
3939 3939
                     
3940
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3941
-                        $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3940
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
3941
+						$save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3942 3942
                         
3943
-                        $clear = $i == 0 ? true : false;
3944
-                        geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3945
-                    }
3943
+						$clear = $i == 0 ? true : false;
3944
+						geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3945
+					}
3946 3946
                     
3947
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3948
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3949
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3950
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3951
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3947
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
3948
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3949
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
3950
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
3951
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
3952 3952
                         
3953
-                        $file_url = $file_url_base . $chunk_file_name;
3954
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3955
-                    }
3953
+						$file_url = $file_url_base . $chunk_file_name;
3954
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3955
+					}
3956 3956
                     
3957
-                    if ( !empty($chunk_file_paths) ) {
3958
-                        $json['total'] = $items_count;
3959
-                        $json['files'] = $chunk_file_paths;
3960
-                    } else {
3961
-                        $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3962
-                    }
3963
-                }
3964
-                wp_send_json( $json );
3965
-            }
3966
-        }
3967
-        break;
3968
-        case 'prepare_import':
3969
-        case 'import_cat':
3970
-        case 'import_post':
3971
-        case 'import_loc':
3972
-        case 'import_hood': {
3973
-            // WPML
3974
-            $is_wpml = geodir_is_wpml();
3975
-            if ($is_wpml) {
3976
-                global $sitepress;
3977
-                $active_lang = ICL_LANGUAGE_CODE;
3978
-            }
3979
-            // WPML
3957
+					if ( !empty($chunk_file_paths) ) {
3958
+						$json['total'] = $items_count;
3959
+						$json['files'] = $chunk_file_paths;
3960
+					} else {
3961
+						$json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3962
+					}
3963
+				}
3964
+				wp_send_json( $json );
3965
+			}
3966
+		}
3967
+		break;
3968
+		case 'prepare_import':
3969
+		case 'import_cat':
3970
+		case 'import_post':
3971
+		case 'import_loc':
3972
+		case 'import_hood': {
3973
+			// WPML
3974
+			$is_wpml = geodir_is_wpml();
3975
+			if ($is_wpml) {
3976
+				global $sitepress;
3977
+				$active_lang = ICL_LANGUAGE_CODE;
3978
+			}
3979
+			// WPML
3980 3980
             
3981
-            ini_set( 'auto_detect_line_endings', true );
3981
+			ini_set( 'auto_detect_line_endings', true );
3982 3982
             
3983
-            $uploads = wp_upload_dir();
3984
-            $uploads_dir = $uploads['path'];
3985
-            $uploads_subdir = $uploads['subdir'];
3983
+			$uploads = wp_upload_dir();
3984
+			$uploads_dir = $uploads['path'];
3985
+			$uploads_subdir = $uploads['subdir'];
3986 3986
             
3987
-            $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL;
3988
-            $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip';
3987
+			$csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL;
3988
+			$import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip';
3989 3989
             
3990
-            $csv_file_arr = explode( '/', $csv_file );
3991
-            $csv_filename = end( $csv_file_arr );
3992
-            $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename;
3990
+			$csv_file_arr = explode( '/', $csv_file );
3991
+			$csv_filename = end( $csv_file_arr );
3992
+			$target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename;
3993 3993
             
3994
-            $json['file'] = $csv_file;
3995
-            $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' );
3996
-            $file = array();
3994
+			$json['file'] = $csv_file;
3995
+			$json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' );
3996
+			$file = array();
3997 3997
 
3998
-            if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
3999
-                $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename );
3998
+			if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
3999
+				$wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename );
4000 4000
                 
4001
-                if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
4002
-                    $json['error'] = NULL;
4003
-                    $json['rows'] = 0;
4001
+				if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
4002
+					$json['error'] = NULL;
4003
+					$json['rows'] = 0;
4004 4004
                     
4005
-                    if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
4006
-                        while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
4007
-                            if ( !empty( $data ) ) {
4008
-                                $file[] = $data;
4009
-                            }
4010
-                        }
4011
-                        fclose($handle);
4012
-                    }
4005
+					if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
4006
+						while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
4007
+							if ( !empty( $data ) ) {
4008
+								$file[] = $data;
4009
+							}
4010
+						}
4011
+						fclose($handle);
4012
+					}
4013 4013
 
4014
-                    $json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
4014
+					$json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
4015 4015
                     
4016
-                    if (!$json['rows'] > 0) {
4017
-                        $json['error'] = __('No data found in csv file.', 'geodirectory');
4018
-                    }
4019
-                } else {
4020
-                    wp_send_json( $json );
4021
-                }
4022
-            } else {
4023
-                wp_send_json( $json );
4024
-            }
4016
+					if (!$json['rows'] > 0) {
4017
+						$json['error'] = __('No data found in csv file.', 'geodirectory');
4018
+					}
4019
+				} else {
4020
+					wp_send_json( $json );
4021
+				}
4022
+			} else {
4023
+				wp_send_json( $json );
4024
+			}
4025 4025
             
4026
-            if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
4027
-                wp_send_json( $json );
4028
-            }
4026
+			if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
4027
+				wp_send_json( $json );
4028
+			}
4029 4029
             
4030
-            $total = $json['rows'];
4031
-            $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1;
4032
-            $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0;
4030
+			$total = $json['rows'];
4031
+			$limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1;
4032
+			$processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0;
4033 4033
             
4034
-            $count = $limit;
4034
+			$count = $limit;
4035 4035
             
4036
-            if ($count < $total) {
4037
-                $count = $processed + $count;
4038
-                if ($count > $total) {
4039
-                    $count = $total;
4040
-                }
4041
-            } else {
4042
-                $count = $total;
4043
-            }
4036
+			if ($count < $total) {
4037
+				$count = $processed + $count;
4038
+				if ($count > $total) {
4039
+					$count = $total;
4040
+				}
4041
+			} else {
4042
+				$count = $total;
4043
+			}
4044 4044
             
4045
-            $created = 0;
4046
-            $updated = 0;
4047
-            $skipped = 0;
4048
-            $invalid = 0;
4049
-            $invalid_addr = 0;
4050
-            $images = 0;
4045
+			$created = 0;
4046
+			$updated = 0;
4047
+			$skipped = 0;
4048
+			$invalid = 0;
4049
+			$invalid_addr = 0;
4050
+			$images = 0;
4051 4051
             
4052
-            $gd_post_info = array();
4053
-            $countpost = 0;
4052
+			$gd_post_info = array();
4053
+			$countpost = 0;
4054 4054
             
4055
-            $post_types = geodir_get_posttypes();
4055
+			$post_types = geodir_get_posttypes();
4056 4056
 
4057
-            if ( $task == 'import_cat' ) {
4058
-                if (!empty($file)) {
4059
-                    $columns = isset($file[0]) ? $file[0] : NULL;
4057
+			if ( $task == 'import_cat' ) {
4058
+				if (!empty($file)) {
4059
+					$columns = isset($file[0]) ? $file[0] : NULL;
4060 4060
                     
4061
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4062
-                        $json['error'] = CSV_INVAILD_FILE;
4063
-                        wp_send_json( $json );
4064
-                        exit;
4065
-                    }
4061
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4062
+						$json['error'] = CSV_INVAILD_FILE;
4063
+						wp_send_json( $json );
4064
+						exit;
4065
+					}
4066 4066
                     
4067
-                    $gd_error_log = __('GD IMPORT CATEGORIES [ROW %d]:', 'geodirectory');
4067
+					$gd_error_log = __('GD IMPORT CATEGORIES [ROW %d]:', 'geodirectory');
4068 4068
                     
4069
-                    for ($i = 1; $i <= $limit; $i++) {
4070
-                        $index = $processed + $i;
4069
+					for ($i = 1; $i <= $limit; $i++) {
4070
+						$index = $processed + $i;
4071 4071
                         
4072
-                        if (isset($file[$index])) {
4073
-                            $row = $file[$index];
4074
-                            $row = array_map( 'trim', $row );
4075
-                            //$row = array_map( 'utf8_encode', $row );
4072
+						if (isset($file[$index])) {
4073
+							$row = $file[$index];
4074
+							$row = array_map( 'trim', $row );
4075
+							//$row = array_map( 'utf8_encode', $row );
4076 4076
                             
4077
-                            $cat_id = '';
4078
-                            $cat_name = '';
4079
-                            $cat_slug = '';
4080
-                            $cat_posttype = '';
4081
-                            $cat_parent = '';
4082
-                            $cat_description = '';
4083
-                            $cat_schema = '';
4084
-                            $cat_top_description = '';
4085
-                            $cat_image = '';
4086
-                            $cat_icon = '';
4087
-                            $cat_language = '';
4088
-                            $cat_id_original = '';
4077
+							$cat_id = '';
4078
+							$cat_name = '';
4079
+							$cat_slug = '';
4080
+							$cat_posttype = '';
4081
+							$cat_parent = '';
4082
+							$cat_description = '';
4083
+							$cat_schema = '';
4084
+							$cat_top_description = '';
4085
+							$cat_image = '';
4086
+							$cat_icon = '';
4087
+							$cat_language = '';
4088
+							$cat_id_original = '';
4089 4089
                             
4090
-                            $c = 0;
4091
-                            foreach ($columns as $column ) {
4092
-                                if ( $column == 'cat_id' ) {
4093
-                                    $cat_id = (int)$row[$c];
4094
-                                } else if ( $column == 'cat_name' ) {
4095
-                                    $cat_name = $row[$c];
4096
-                                } else if ( $column == 'cat_slug' ) {
4097
-                                    $cat_slug = $row[$c];
4098
-                                } else if ( $column == 'cat_posttype' ) {
4099
-                                    $cat_posttype = $row[$c];
4100
-                                } else if ( $column == 'cat_parent' ) {
4101
-                                    $cat_parent = trim($row[$c]);
4102
-                                } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
4103
-                                    $cat_schema = $row[$c];
4104
-                                } else if ( $column == 'cat_description' ) {
4105
-                                    $cat_description = $row[$c];
4106
-                                } else if ( $column == 'cat_top_description' ) {
4107
-                                    $cat_top_description = $row[$c];
4108
-                                } else if ( $column == 'cat_image' ) {
4109
-                                    $cat_image = $row[$c];
4110
-                                } else if ( $column == 'cat_icon' ) {
4111
-                                    $cat_icon = $row[$c];
4112
-                                }
4113
-                                // WPML
4114
-                                if ( $is_wpml ) {
4115
-                                    if ( $column == 'cat_language' ) {
4116
-                                        $cat_language = geodir_strtolower( trim( $row[$c] ) );
4117
-                                    } else if ( $column == 'cat_id_original' ) {
4118
-                                        $cat_id_original = (int)$row[$c];
4119
-                                    }
4120
-                                }
4121
-                                // WPML
4122
-                                $c++;
4123
-                            }
4090
+							$c = 0;
4091
+							foreach ($columns as $column ) {
4092
+								if ( $column == 'cat_id' ) {
4093
+									$cat_id = (int)$row[$c];
4094
+								} else if ( $column == 'cat_name' ) {
4095
+									$cat_name = $row[$c];
4096
+								} else if ( $column == 'cat_slug' ) {
4097
+									$cat_slug = $row[$c];
4098
+								} else if ( $column == 'cat_posttype' ) {
4099
+									$cat_posttype = $row[$c];
4100
+								} else if ( $column == 'cat_parent' ) {
4101
+									$cat_parent = trim($row[$c]);
4102
+								} else if ( $column == 'cat_schema' && $row[$c] != '' ) {
4103
+									$cat_schema = $row[$c];
4104
+								} else if ( $column == 'cat_description' ) {
4105
+									$cat_description = $row[$c];
4106
+								} else if ( $column == 'cat_top_description' ) {
4107
+									$cat_top_description = $row[$c];
4108
+								} else if ( $column == 'cat_image' ) {
4109
+									$cat_image = $row[$c];
4110
+								} else if ( $column == 'cat_icon' ) {
4111
+									$cat_icon = $row[$c];
4112
+								}
4113
+								// WPML
4114
+								if ( $is_wpml ) {
4115
+									if ( $column == 'cat_language' ) {
4116
+										$cat_language = geodir_strtolower( trim( $row[$c] ) );
4117
+									} else if ( $column == 'cat_id_original' ) {
4118
+										$cat_id_original = (int)$row[$c];
4119
+									}
4120
+								}
4121
+								// WPML
4122
+								$c++;
4123
+							}
4124 4124
                             
4125
-                            if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
4126
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
4125
+							if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
4126
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
4127 4127
                                 
4128
-                                $invalid++;
4129
-                                continue;
4130
-                            }
4128
+								$invalid++;
4129
+								continue;
4130
+							}
4131 4131
                             
4132
-                            // WPML
4133
-                            if ($is_wpml && $cat_language != '') {
4134
-                                $sitepress->switch_lang($cat_language, true);
4135
-                            }
4136
-                            // WPML
4132
+							// WPML
4133
+							if ($is_wpml && $cat_language != '') {
4134
+								$sitepress->switch_lang($cat_language, true);
4135
+							}
4136
+							// WPML
4137 4137
                                                         
4138
-                            $term_data = array();
4139
-                            $term_data['name'] = $cat_name;
4140
-                            $term_data['slug'] = $cat_slug;
4141
-                            $term_data['description'] = $cat_description;
4142
-                            $term_data['cat_schema'] = $cat_schema;
4143
-                            $term_data['top_description'] = $cat_top_description;
4144
-                            $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : '';
4145
-                            $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : '';
4138
+							$term_data = array();
4139
+							$term_data['name'] = $cat_name;
4140
+							$term_data['slug'] = $cat_slug;
4141
+							$term_data['description'] = $cat_description;
4142
+							$term_data['cat_schema'] = $cat_schema;
4143
+							$term_data['top_description'] = $cat_top_description;
4144
+							$term_data['image'] = $cat_image != '' ? basename( $cat_image ) : '';
4145
+							$term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : '';
4146 4146
                             
4147
-                            //$term_data = array_map( 'utf8_encode', $term_data );
4147
+							//$term_data = array_map( 'utf8_encode', $term_data );
4148 4148
                             
4149
-                            $taxonomy = $cat_posttype . 'category';
4149
+							$taxonomy = $cat_posttype . 'category';
4150 4150
                             
4151
-                            $term_data['taxonomy'] = $taxonomy;
4151
+							$term_data['taxonomy'] = $taxonomy;
4152 4152
 
4153
-                            $term_parent_id = 0;
4154
-                            if ($cat_parent != "" || (int)$cat_parent > 0) {
4155
-                                $term_parent = '';
4153
+							$term_parent_id = 0;
4154
+							if ($cat_parent != "" || (int)$cat_parent > 0) {
4155
+								$term_parent = '';
4156 4156
                                 
4157
-                                if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
4158
-                                    //
4159
-                                } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
4160
-                                    //
4161
-                                } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
4162
-                                    //
4163
-                                } else {
4164
-                                    $term_parent_data = array();
4165
-                                    $term_parent_data['name'] = $cat_parent;
4166
-                                    //$term_parent_data = array_map( 'utf8_encode', $term_parent_data );
4167
-                                    $term_parent_data['taxonomy'] = $taxonomy;
4157
+								if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
4158
+									//
4159
+								} else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
4160
+									//
4161
+								} else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
4162
+									//
4163
+								} else {
4164
+									$term_parent_data = array();
4165
+									$term_parent_data['name'] = $cat_parent;
4166
+									//$term_parent_data = array_map( 'utf8_encode', $term_parent_data );
4167
+									$term_parent_data['taxonomy'] = $taxonomy;
4168 4168
                                     
4169
-                                    $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data );
4170
-                                }
4169
+									$term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data );
4170
+								}
4171 4171
                                 
4172
-                                if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
4173
-                                    $term_parent_id = (int)$term_parent->term_id;
4174
-                                }
4175
-                            }
4176
-                            $term_data['parent'] = (int)$term_parent_id;
4172
+								if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
4173
+									$term_parent_id = (int)$term_parent->term_id;
4174
+								}
4175
+							}
4176
+							$term_data['parent'] = (int)$term_parent_id;
4177 4177
 
4178
-                            $term_id = NULL;
4179
-                            if ( $import_choice == 'update' ) {
4180
-                                if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
4181
-                                    $term_data['term_id'] = $term['term_id'];
4178
+							$term_id = NULL;
4179
+							if ( $import_choice == 'update' ) {
4180
+								if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
4181
+									$term_data['term_id'] = $term['term_id'];
4182 4182
                                     
4183
-                                    if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
4184
-                                        $updated++;
4185
-                                    } else {
4186
-                                        $invalid++;
4187
-                                        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' ) );
4188
-                                    }
4189
-                                } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4190
-                                    $term_data['term_id'] = $term['term_id'];
4183
+									if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
4184
+										$updated++;
4185
+									} else {
4186
+										$invalid++;
4187
+										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' ) );
4188
+									}
4189
+								} else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4190
+									$term_data['term_id'] = $term['term_id'];
4191 4191
                                     
4192
-                                    if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
4193
-                                        $updated++;
4194
-                                    } else {
4195
-                                        $invalid++;
4196
-                                        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' ) );
4197
-                                    }
4198
-                                } else {
4199
-                                    if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
4200
-                                        $created++;
4201
-                                    } else {
4202
-                                        $invalid++;
4203
-                                        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' ) );
4204
-                                    }
4205
-                                }
4206
-                            } else if ( $import_choice == 'skip' ) {
4207
-                                if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
4208
-                                    $skipped++;
4209
-                                } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4210
-                                    $skipped++;
4211
-                                } else {
4212
-                                    if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
4213
-                                        $created++;
4214
-                                    } else {
4215
-                                        $invalid++;
4216
-                                        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' ) );
4217
-                                    }
4218
-                                }
4219
-                            } else {
4220
-                                $invalid++;
4221
-                                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' ) );
4222
-                            }
4192
+									if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
4193
+										$updated++;
4194
+									} else {
4195
+										$invalid++;
4196
+										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' ) );
4197
+									}
4198
+								} else {
4199
+									if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
4200
+										$created++;
4201
+									} else {
4202
+										$invalid++;
4203
+										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' ) );
4204
+									}
4205
+								}
4206
+							} else if ( $import_choice == 'skip' ) {
4207
+								if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
4208
+									$skipped++;
4209
+								} else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4210
+									$skipped++;
4211
+								} else {
4212
+									if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
4213
+										$created++;
4214
+									} else {
4215
+										$invalid++;
4216
+										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' ) );
4217
+									}
4218
+								}
4219
+							} else {
4220
+								$invalid++;
4221
+								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' ) );
4222
+							}
4223 4223
                             
4224
-                            if ( $term_id ) {
4225
-                                // WPML
4226
-                                if ($is_wpml && $cat_id_original > 0 && $cat_language != '') {
4227
-                                    $wpml_element_type = 'tax_' . $taxonomy;
4228
-                                    $source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type );
4229
-                                    $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4230
-
4231
-                                    $trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type );
4224
+							if ( $term_id ) {
4225
+								// WPML
4226
+								if ($is_wpml && $cat_id_original > 0 && $cat_language != '') {
4227
+									$wpml_element_type = 'tax_' . $taxonomy;
4228
+									$source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type );
4229
+									$source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4230
+
4231
+									$trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type );
4232 4232
                                     
4233
-                                    $sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language );
4234
-                                }
4235
-                                // WPML
4233
+									$sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language );
4234
+								}
4235
+								// WPML
4236 4236
                                 
4237
-                                if ( isset( $term_data['top_description'] ) ) {
4238
-                                    update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype );
4239
-                                }
4237
+								if ( isset( $term_data['top_description'] ) ) {
4238
+									update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype );
4239
+								}
4240 4240
                                 
4241
-                                if ( isset( $term_data['cat_schema'] ) ) {
4242
-                                    update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype );
4243
-                                }
4241
+								if ( isset( $term_data['cat_schema'] ) ) {
4242
+									update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype );
4243
+								}
4244 4244
             
4245
-                                $attachment = false;
4246
-                                if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
4247
-                                    $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype );
4248
-                                    $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : '';
4245
+								$attachment = false;
4246
+								if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
4247
+									$cat_image = geodir_get_default_catimage( $term_id, $cat_posttype );
4248
+									$cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : '';
4249 4249
                                     
4250
-                                    if ( basename($cat_image) != $term_data['image'] ) {
4251
-                                        $attachment = true;
4252
-                                        update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype );
4253
-                                    }
4254
-                                }
4250
+									if ( basename($cat_image) != $term_data['image'] ) {
4251
+										$attachment = true;
4252
+										update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype );
4253
+									}
4254
+								}
4255 4255
                                 
4256
-                                if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
4257
-                                    $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype );
4258
-                                    $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : '';
4256
+								if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
4257
+									$cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype );
4258
+									$cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : '';
4259 4259
                                         
4260
-                                    if ( basename($cat_icon) != $term_data['icon'] ) {
4261
-                                        $attachment = true;
4262
-                                        update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype );
4263
-                                    }
4264
-                                }
4260
+									if ( basename($cat_icon) != $term_data['icon'] ) {
4261
+										$attachment = true;
4262
+										update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype );
4263
+									}
4264
+								}
4265 4265
                                 
4266
-                                if ( $attachment ) {
4267
-                                    $images++;
4268
-                                }
4269
-                            }
4266
+								if ( $attachment ) {
4267
+									$images++;
4268
+								}
4269
+							}
4270 4270
                             
4271
-                            // WPML
4272
-                            if ($is_wpml && $cat_language != '') {
4273
-                                $sitepress->switch_lang($active_lang, true);
4274
-                            }
4275
-                            // WPML
4276
-                        }
4277
-                    }
4278
-                }
4271
+							// WPML
4272
+							if ($is_wpml && $cat_language != '') {
4273
+								$sitepress->switch_lang($active_lang, true);
4274
+							}
4275
+							// WPML
4276
+						}
4277
+					}
4278
+				}
4279 4279
                 
4280
-                $json = array();
4281
-                $json['processed'] = $limit;
4282
-                $json['created'] = $created;
4283
-                $json['updated'] = $updated;
4284
-                $json['skipped'] = $skipped;
4285
-                $json['invalid'] = $invalid;
4286
-                $json['images'] = $images;
4280
+				$json = array();
4281
+				$json['processed'] = $limit;
4282
+				$json['created'] = $created;
4283
+				$json['updated'] = $updated;
4284
+				$json['skipped'] = $skipped;
4285
+				$json['invalid'] = $invalid;
4286
+				$json['images'] = $images;
4287 4287
                 
4288
-                wp_send_json( $json );
4289
-                exit;
4290
-            } else if ( $task == 'import_post' ) {
4291
-                //run some stuff to make the import quicker
4292
-                wp_defer_term_counting( true );
4293
-                wp_defer_comment_counting( true );
4294
-                $wpdb->query( 'SET autocommit = 0;' );
4295
-
4296
-                //remove_all_actions('publish_post');
4297
-                //remove_all_actions('transition_post_status');
4298
-                //remove_all_actions('publish_future_post');
4299
-
4300
-                if (!empty($file)) {
4301
-                    $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
4302
-                    $default_status = 'publish';
4303
-                    $current_date = date_i18n( 'Y-m-d', time() );
4288
+				wp_send_json( $json );
4289
+				exit;
4290
+			} else if ( $task == 'import_post' ) {
4291
+				//run some stuff to make the import quicker
4292
+				wp_defer_term_counting( true );
4293
+				wp_defer_comment_counting( true );
4294
+				$wpdb->query( 'SET autocommit = 0;' );
4295
+
4296
+				//remove_all_actions('publish_post');
4297
+				//remove_all_actions('transition_post_status');
4298
+				//remove_all_actions('publish_future_post');
4299
+
4300
+				if (!empty($file)) {
4301
+					$wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
4302
+					$default_status = 'publish';
4303
+					$current_date = date_i18n( 'Y-m-d', time() );
4304 4304
                     
4305
-                    $columns = isset($file[0]) ? $file[0] : NULL;
4305
+					$columns = isset($file[0]) ? $file[0] : NULL;
4306 4306
                     
4307
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4308
-                        $json['error'] = CSV_INVAILD_FILE;
4309
-                        wp_send_json( $json );
4310
-                        exit;
4311
-                    }
4307
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4308
+						$json['error'] = CSV_INVAILD_FILE;
4309
+						wp_send_json( $json );
4310
+						exit;
4311
+					}
4312 4312
 
4313
-                    $gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory');
4314
-                    $wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' );
4315
-                    $processed_actual = 0;
4316
-                    for ($i = 1; $i <= $limit; $i++) {
4317
-                        $index = $processed + $i;
4318
-                        $gd_post = array();
4313
+					$gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory');
4314
+					$wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' );
4315
+					$processed_actual = 0;
4316
+					for ($i = 1; $i <= $limit; $i++) {
4317
+						$index = $processed + $i;
4318
+						$gd_post = array();
4319 4319
                         
4320
-                        if (isset($file[$index])) {
4321
-                            $processed_actual++;
4322
-                            $row = $file[$index];
4323
-                            $row = array_map( 'trim', $row );
4324
-                            //$row = array_map( 'utf8_encode', $row );
4325
-                            $row = array_map( 'addslashes_gpc', $row );
4320
+						if (isset($file[$index])) {
4321
+							$processed_actual++;
4322
+							$row = $file[$index];
4323
+							$row = array_map( 'trim', $row );
4324
+							//$row = array_map( 'utf8_encode', $row );
4325
+							$row = array_map( 'addslashes_gpc', $row );
4326 4326
                             
4327
-                            $post_id = '';
4328
-                            $post_title = '';
4329
-                            $post_author = '';
4330
-                            $post_content = '';
4331
-                            $post_category_arr = array();
4332
-                            $default_category = '';
4333
-                            $post_tags = array();
4334
-                            $post_type = '';
4335
-                            $post_status = '';
4336
-                            $geodir_video = '';
4337
-                            $post_address = '';
4338
-                            $post_city = '';
4339
-                            $post_region = '';
4340
-                            $post_country = '';
4341
-                            $post_zip = '';
4342
-                            $post_latitude = '';
4343
-                            $post_longitude = '';
4344
-                            $post_neighbourhood = '';
4345
-                            $neighbourhood_latitude = '';
4346
-                            $neighbourhood_longitude = '';
4347
-                            $geodir_timing = '';
4348
-                            $geodir_contact = '';
4349
-                            $geodir_email = '';
4350
-                            $geodir_website = '';
4351
-                            $geodir_twitter = '';
4352
-                            $geodir_facebook = '';
4353
-                            $geodir_twitter = '';
4354
-                            $post_images = array();
4327
+							$post_id = '';
4328
+							$post_title = '';
4329
+							$post_author = '';
4330
+							$post_content = '';
4331
+							$post_category_arr = array();
4332
+							$default_category = '';
4333
+							$post_tags = array();
4334
+							$post_type = '';
4335
+							$post_status = '';
4336
+							$geodir_video = '';
4337
+							$post_address = '';
4338
+							$post_city = '';
4339
+							$post_region = '';
4340
+							$post_country = '';
4341
+							$post_zip = '';
4342
+							$post_latitude = '';
4343
+							$post_longitude = '';
4344
+							$post_neighbourhood = '';
4345
+							$neighbourhood_latitude = '';
4346
+							$neighbourhood_longitude = '';
4347
+							$geodir_timing = '';
4348
+							$geodir_contact = '';
4349
+							$geodir_email = '';
4350
+							$geodir_website = '';
4351
+							$geodir_twitter = '';
4352
+							$geodir_facebook = '';
4353
+							$geodir_twitter = '';
4354
+							$post_images = array();
4355 4355
                             
4356
-                            $expire_date = 'Never';
4356
+							$expire_date = 'Never';
4357 4357
                             
4358
-                            $language = '';
4359
-                            $original_post_id = '';
4358
+							$language = '';
4359
+							$original_post_id = '';
4360 4360
                                                         
4361
-                            $c = 0;
4362
-                            foreach ($columns as $column ) {
4363
-                                $gd_post[$column] = $row[$c];
4361
+							$c = 0;
4362
+							foreach ($columns as $column ) {
4363
+								$gd_post[$column] = $row[$c];
4364 4364
                                 
4365
-                                if ( $column == 'post_id' ) {
4366
-                                    $post_id = $row[$c];
4367
-                                } else if ( $column == 'post_title' ) {
4368
-                                    $post_title = sanitize_text_field($row[$c]);
4369
-                                } else if ( $column == 'post_author' ) {
4370
-                                    $post_author = $row[$c];
4371
-                                } else if ( $column == 'post_content' ) {
4372
-                                    $post_content = $row[$c];
4373
-                                } else if ( $column == 'post_category' && $row[$c] != '' ) {
4374
-                                    $post_category_arr = explode( ',', $row[$c] );
4375
-                                } else if ( $column == 'default_category' ) {
4376
-                                    $default_category = wp_kses_normalize_entities($row[$c]);
4377
-                                } else if ( $column == 'post_tags' && $row[$c] != '' ) {
4378
-                                    $post_tags = explode( ',', sanitize_text_field($row[$c]) );
4379
-                                } else if ( $column == 'post_type' ) {
4380
-                                    $post_type = $row[$c];
4381
-                                } else if ( $column == 'post_status' ) {
4382
-                                    $post_status = sanitize_key( $row[$c] );
4383
-                                } else if ( $column == 'is_featured' ) {
4384
-                                    $is_featured = (int)$row[$c];
4385
-                                } else if ( $column == 'geodir_video' ) {
4386
-                                    $geodir_video = $row[$c];
4387
-                                } else if ( $column == 'post_address' ) {
4388
-                                    $post_address = sanitize_text_field($row[$c]);
4389
-                                } else if ( $column == 'post_city' ) {
4390
-                                    $post_city = sanitize_text_field($row[$c]);
4391
-                                } else if ( $column == 'post_region' ) {
4392
-                                    $post_region = sanitize_text_field($row[$c]);
4393
-                                } else if ( $column == 'post_country' ) {
4394
-                                    $post_country = sanitize_text_field($row[$c]);
4395
-                                } else if ( $column == 'post_zip' ) {
4396
-                                    $post_zip = sanitize_text_field($row[$c]);
4397
-                                } else if ( $column == 'post_latitude' ) {
4398
-                                    $post_latitude = sanitize_text_field($row[$c]);
4399
-                                } else if ( $column == 'post_longitude' ) {
4400
-                                    $post_longitude = sanitize_text_field($row[$c]);
4401
-                                } else if ( $column == 'post_neighbourhood' ) {
4402
-                                    $post_neighbourhood = sanitize_text_field($row[$c]);
4403
-                                    unset($gd_post[$column]);
4404
-                                } else if ( $column == 'neighbourhood_latitude' ) {
4405
-                                    $neighbourhood_latitude = sanitize_text_field($row[$c]);
4406
-                                } else if ( $column == 'neighbourhood_longitude' ) {
4407
-                                    $neighbourhood_longitude = sanitize_text_field($row[$c]);
4408
-                                } else if ( $column == 'geodir_timing' ) {
4409
-                                    $geodir_timing = sanitize_text_field($row[$c]);
4410
-                                } else if ( $column == 'geodir_contact' ) {
4411
-                                    $geodir_contact = sanitize_text_field($row[$c]);
4412
-                                } else if ( $column == 'geodir_email' ) {
4413
-                                    $geodir_email = sanitize_email($row[$c]);
4414
-                                } else if ( $column == 'geodir_website' ) {
4415
-                                    $geodir_website = sanitize_text_field($row[$c]);
4416
-                                } else if ( $column == 'geodir_twitter' ) {
4417
-                                    $geodir_twitter = sanitize_text_field($row[$c]);
4418
-                                } else if ( $column == 'geodir_facebook' ) {
4419
-                                    $geodir_facebook = sanitize_text_field($row[$c]);
4420
-                                } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
4421
-                                    $post_images[] = $row[$c];
4422
-                                } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
4423
-                                    $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) );
4424
-                                } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
4425
-                                    $row[$c] = str_replace('/', '-', $row[$c]);
4426
-                                    $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) );
4427
-                                }
4428
-                                // WPML
4429
-                                if ($is_wpml) {
4430
-                                    if ($column == 'language') {
4431
-                                        $language = geodir_strtolower(trim($row[$c]));
4432
-                                    } else if ($column == 'original_post_id') {
4433
-                                        $original_post_id = (int)$row[$c];
4434
-                                    }
4435
-                                }
4436
-                                // WPML
4437
-                                $c++;
4438
-                            }
4365
+								if ( $column == 'post_id' ) {
4366
+									$post_id = $row[$c];
4367
+								} else if ( $column == 'post_title' ) {
4368
+									$post_title = sanitize_text_field($row[$c]);
4369
+								} else if ( $column == 'post_author' ) {
4370
+									$post_author = $row[$c];
4371
+								} else if ( $column == 'post_content' ) {
4372
+									$post_content = $row[$c];
4373
+								} else if ( $column == 'post_category' && $row[$c] != '' ) {
4374
+									$post_category_arr = explode( ',', $row[$c] );
4375
+								} else if ( $column == 'default_category' ) {
4376
+									$default_category = wp_kses_normalize_entities($row[$c]);
4377
+								} else if ( $column == 'post_tags' && $row[$c] != '' ) {
4378
+									$post_tags = explode( ',', sanitize_text_field($row[$c]) );
4379
+								} else if ( $column == 'post_type' ) {
4380
+									$post_type = $row[$c];
4381
+								} else if ( $column == 'post_status' ) {
4382
+									$post_status = sanitize_key( $row[$c] );
4383
+								} else if ( $column == 'is_featured' ) {
4384
+									$is_featured = (int)$row[$c];
4385
+								} else if ( $column == 'geodir_video' ) {
4386
+									$geodir_video = $row[$c];
4387
+								} else if ( $column == 'post_address' ) {
4388
+									$post_address = sanitize_text_field($row[$c]);
4389
+								} else if ( $column == 'post_city' ) {
4390
+									$post_city = sanitize_text_field($row[$c]);
4391
+								} else if ( $column == 'post_region' ) {
4392
+									$post_region = sanitize_text_field($row[$c]);
4393
+								} else if ( $column == 'post_country' ) {
4394
+									$post_country = sanitize_text_field($row[$c]);
4395
+								} else if ( $column == 'post_zip' ) {
4396
+									$post_zip = sanitize_text_field($row[$c]);
4397
+								} else if ( $column == 'post_latitude' ) {
4398
+									$post_latitude = sanitize_text_field($row[$c]);
4399
+								} else if ( $column == 'post_longitude' ) {
4400
+									$post_longitude = sanitize_text_field($row[$c]);
4401
+								} else if ( $column == 'post_neighbourhood' ) {
4402
+									$post_neighbourhood = sanitize_text_field($row[$c]);
4403
+									unset($gd_post[$column]);
4404
+								} else if ( $column == 'neighbourhood_latitude' ) {
4405
+									$neighbourhood_latitude = sanitize_text_field($row[$c]);
4406
+								} else if ( $column == 'neighbourhood_longitude' ) {
4407
+									$neighbourhood_longitude = sanitize_text_field($row[$c]);
4408
+								} else if ( $column == 'geodir_timing' ) {
4409
+									$geodir_timing = sanitize_text_field($row[$c]);
4410
+								} else if ( $column == 'geodir_contact' ) {
4411
+									$geodir_contact = sanitize_text_field($row[$c]);
4412
+								} else if ( $column == 'geodir_email' ) {
4413
+									$geodir_email = sanitize_email($row[$c]);
4414
+								} else if ( $column == 'geodir_website' ) {
4415
+									$geodir_website = sanitize_text_field($row[$c]);
4416
+								} else if ( $column == 'geodir_twitter' ) {
4417
+									$geodir_twitter = sanitize_text_field($row[$c]);
4418
+								} else if ( $column == 'geodir_facebook' ) {
4419
+									$geodir_facebook = sanitize_text_field($row[$c]);
4420
+								} else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
4421
+									$post_images[] = $row[$c];
4422
+								} else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
4423
+									$expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) );
4424
+								} else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
4425
+									$row[$c] = str_replace('/', '-', $row[$c]);
4426
+									$expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) );
4427
+								}
4428
+								// WPML
4429
+								if ($is_wpml) {
4430
+									if ($column == 'language') {
4431
+										$language = geodir_strtolower(trim($row[$c]));
4432
+									} else if ($column == 'original_post_id') {
4433
+										$original_post_id = (int)$row[$c];
4434
+									}
4435
+								}
4436
+								// WPML
4437
+								$c++;
4438
+							}
4439 4439
                             
4440
-                            // WPML
4441
-                            if ($is_wpml && $language != '') {
4442
-                                $sitepress->switch_lang($language, true);
4443
-                            }
4444
-                            // WPML
4440
+							// WPML
4441
+							if ($is_wpml && $language != '') {
4442
+								$sitepress->switch_lang($language, true);
4443
+							}
4444
+							// WPML
4445 4445
 
4446
-                            $gd_post['IMAGE'] = $post_images;
4446
+							$gd_post['IMAGE'] = $post_images;
4447 4447
                             
4448
-                            $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
4449
-                            $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
4448
+							$post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
4449
+							$post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
4450 4450
                                                                                                                 
4451
-                            $valid = true;
4451
+							$valid = true;
4452 4452
                             
4453
-                            if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
4454
-                                $invalid++;
4455
-                                $valid = false;
4456
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
4457
-                            }
4453
+							if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
4454
+								$invalid++;
4455
+								$valid = false;
4456
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
4457
+							}
4458 4458
                             
4459
-                            $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
4460
-                            if ( $location_allowed ) {
4461
-                                $location_result = geodir_get_default_location();
4462
-                                if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
4463
-                                    $invalid_addr++;
4464
-                                    $valid = false;
4465
-                                    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' ) );
4466
-                                } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
4467
-                                    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 ) ) ) {
4468
-                                        $invalid_addr++;
4469
-                                        $valid = false;
4470
-                                        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' ) );
4471
-                                    } else {
4472
-                                        if (!$location_manager) {
4473
-                                            $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.
4474
-                                        }
4475
-                                    }
4476
-                                }
4477
-                            }
4459
+							$location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
4460
+							if ( $location_allowed ) {
4461
+								$location_result = geodir_get_default_location();
4462
+								if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
4463
+									$invalid_addr++;
4464
+									$valid = false;
4465
+									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' ) );
4466
+								} else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
4467
+									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 ) ) ) {
4468
+										$invalid_addr++;
4469
+										$valid = false;
4470
+										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' ) );
4471
+									} else {
4472
+										if (!$location_manager) {
4473
+											$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.
4474
+										}
4475
+									}
4476
+								}
4477
+							}
4478 4478
                             
4479
-                            if ( !$valid ) {
4480
-                                continue;
4481
-                            }
4479
+							if ( !$valid ) {
4480
+								continue;
4481
+							}
4482 4482
 
4483
-                            $cat_taxonomy = $post_type . 'category';
4484
-                            $tags_taxonomy = $post_type . '_tags';
4483
+							$cat_taxonomy = $post_type . 'category';
4484
+							$tags_taxonomy = $post_type . '_tags';
4485 4485
                             
4486
-                            if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
4487
-                                $post_category_arr = array_merge(array($default_category), $post_category_arr);
4488
-                            }
4486
+							if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
4487
+								$post_category_arr = array_merge(array($default_category), $post_category_arr);
4488
+							}
4489 4489
 
4490
-                            $post_category = array();
4491
-                            $default_category_id = NULL;
4492
-                            if ( !empty( $post_category_arr ) ) {
4493
-                                foreach ( $post_category_arr as $value ) {
4494
-                                    $category_name = wp_kses_normalize_entities( trim( $value ) );
4490
+							$post_category = array();
4491
+							$default_category_id = NULL;
4492
+							if ( !empty( $post_category_arr ) ) {
4493
+								foreach ( $post_category_arr as $value ) {
4494
+									$category_name = wp_kses_normalize_entities( trim( $value ) );
4495 4495
                                     
4496
-                                    if ( $category_name != '' ) {
4497
-                                        $term_category = array();
4496
+									if ( $category_name != '' ) {
4497
+										$term_category = array();
4498 4498
                                         
4499
-                                        if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
4500
-                                            $term_category = $term;
4501
-                                        } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
4502
-                                            $term_category = $term;
4503
-                                        } else {
4504
-                                            $term_data = array();
4505
-                                            $term_data['name'] = $category_name;
4506
-                                            $term_data['taxonomy'] = $cat_taxonomy;
4499
+										if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
4500
+											$term_category = $term;
4501
+										} else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
4502
+											$term_category = $term;
4503
+										} else {
4504
+											$term_data = array();
4505
+											$term_data['name'] = $category_name;
4506
+											$term_data['taxonomy'] = $cat_taxonomy;
4507 4507
                                             
4508
-                                            $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data );
4509
-                                            if ( $term_id ) {
4510
-                                                $term_category = get_term( $term_id, $cat_taxonomy );
4511
-                                            }
4512
-                                        }
4508
+											$term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data );
4509
+											if ( $term_id ) {
4510
+												$term_category = get_term( $term_id, $cat_taxonomy );
4511
+											}
4512
+										}
4513 4513
                                         
4514
-                                        if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
4515
-                                            $post_category[] = intval($term_category->term_id);
4514
+										if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
4515
+											$post_category[] = intval($term_category->term_id);
4516 4516
                                             
4517
-                                            if ($category_name == $default_category) {
4518
-                                                $default_category_id = intval($term_category->term_id);
4519
-                                            }
4520
-                                        }
4521
-                                    }
4522
-                                }
4523
-                            }
4517
+											if ($category_name == $default_category) {
4518
+												$default_category_id = intval($term_category->term_id);
4519
+											}
4520
+										}
4521
+									}
4522
+								}
4523
+							}
4524 4524
 
4525
-                            $save_post = array();
4526
-                            $save_post['post_title'] = $post_title;
4527
-                            $save_post['post_content'] = $post_content;
4528
-                            $save_post['post_type'] = $post_type;
4529
-                            $save_post['post_author'] = $post_author;
4530
-                            $save_post['post_status'] = $post_status;
4531
-                            $save_post['post_category'] = $post_category;
4532
-                            $save_post['post_tags'] = $post_tags;
4533
-
4534
-                            $saved_post_id = NULL;
4535
-                            if ( $import_choice == 'update' ) {
4536
-                                $gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' );
4525
+							$save_post = array();
4526
+							$save_post['post_title'] = $post_title;
4527
+							$save_post['post_content'] = $post_content;
4528
+							$save_post['post_type'] = $post_type;
4529
+							$save_post['post_author'] = $post_author;
4530
+							$save_post['post_status'] = $post_status;
4531
+							$save_post['post_category'] = $post_category;
4532
+							$save_post['post_tags'] = $post_tags;
4533
+
4534
+							$saved_post_id = NULL;
4535
+							if ( $import_choice == 'update' ) {
4536
+								$gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' );
4537 4537
                                 
4538
-                                if ( $post_id > 0 && get_post( $post_id ) ) {
4539
-                                    $save_post['ID'] = $post_id;
4538
+								if ( $post_id > 0 && get_post( $post_id ) ) {
4539
+									$save_post['ID'] = $post_id;
4540 4540
                                     
4541
-                                    if ( $saved_post_id = wp_update_post( $save_post, true ) ) {
4542
-                                        if ( is_wp_error( $saved_post_id ) ) {
4543
-                                            $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4544
-                                            $saved_post_id = 0;
4545
-                                        } else {
4546
-                                            $saved_post_id = $post_id;
4547
-                                            $updated++;
4548
-                                        }
4549
-                                    }
4550
-                                } else {
4551
-                                    if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4552
-                                        if ( is_wp_error( $saved_post_id ) ) {
4553
-                                            $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4554
-                                            $saved_post_id = 0;
4555
-                                        } else {
4556
-                                            $created++;
4557
-                                        }
4558
-                                    }
4559
-                                }
4541
+									if ( $saved_post_id = wp_update_post( $save_post, true ) ) {
4542
+										if ( is_wp_error( $saved_post_id ) ) {
4543
+											$gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4544
+											$saved_post_id = 0;
4545
+										} else {
4546
+											$saved_post_id = $post_id;
4547
+											$updated++;
4548
+										}
4549
+									}
4550
+								} else {
4551
+									if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4552
+										if ( is_wp_error( $saved_post_id ) ) {
4553
+											$gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4554
+											$saved_post_id = 0;
4555
+										} else {
4556
+											$created++;
4557
+										}
4558
+									}
4559
+								}
4560 4560
                                 
4561
-                                if ( !$saved_post_id > 0 ) {
4562
-                                    $invalid++;
4563
-                                    geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error );
4564
-                                }
4565
-                            } else if ( $import_choice == 'skip' ) {
4566
-                                if ( $post_id > 0 && get_post( $post_id ) ) {
4567
-                                    $skipped++;	
4568
-                                } else {
4569
-                                    if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4570
-                                        if ( is_wp_error( $saved_post_id ) ) {
4571
-                                            $invalid++;
4561
+								if ( !$saved_post_id > 0 ) {
4562
+									$invalid++;
4563
+									geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error );
4564
+								}
4565
+							} else if ( $import_choice == 'skip' ) {
4566
+								if ( $post_id > 0 && get_post( $post_id ) ) {
4567
+									$skipped++;	
4568
+								} else {
4569
+									if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4570
+										if ( is_wp_error( $saved_post_id ) ) {
4571
+											$invalid++;
4572 4572
                                             
4573
-                                            geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error );
4574
-                                            $saved_post_id = 0;
4575
-                                        } else {
4576
-                                            $created++;
4577
-                                        }
4578
-                                    } else {
4579
-                                        $invalid++;
4573
+											geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error );
4574
+											$saved_post_id = 0;
4575
+										} else {
4576
+											$created++;
4577
+										}
4578
+									} else {
4579
+										$invalid++;
4580 4580
                                         
4581
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4582
-                                    }
4583
-                                }
4584
-                            } else {
4585
-                                $invalid++;
4581
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4582
+									}
4583
+								}
4584
+							} else {
4585
+								$invalid++;
4586 4586
                                 
4587
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4588
-                            }
4587
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4588
+							}
4589 4589
 
4590
-                            if ( (int)$saved_post_id > 0 ) {
4591
-                                // WPML
4592
-                                if ($is_wpml && $original_post_id > 0 && $language != '') {
4593
-                                    $wpml_post_type = 'post_' . $post_type;
4594
-                                    $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type );
4595
-                                    $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4590
+							if ( (int)$saved_post_id > 0 ) {
4591
+								// WPML
4592
+								if ($is_wpml && $original_post_id > 0 && $language != '') {
4593
+									$wpml_post_type = 'post_' . $post_type;
4594
+									$source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type );
4595
+									$source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4596 4596
 
4597
-                                    $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type );
4597
+									$trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type );
4598 4598
                                     
4599
-                                    $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language );
4600
-                                }
4601
-                                // WPML
4602
-                                $gd_post_info = geodir_get_post_info( $saved_post_id );
4599
+									$sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language );
4600
+								}
4601
+								// WPML
4602
+								$gd_post_info = geodir_get_post_info( $saved_post_id );
4603 4603
                                 
4604
-                                $gd_post['post_id'] = $saved_post_id;
4605
-                                $gd_post['ID'] = $saved_post_id;
4606
-                                $gd_post['post_tags'] = $post_tags;
4607
-                                $gd_post['post_title'] = $post_title;
4608
-                                $gd_post['post_status'] = $post_status;
4609
-                                $gd_post['submit_time'] = time();
4610
-                                $gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR'];
4604
+								$gd_post['post_id'] = $saved_post_id;
4605
+								$gd_post['ID'] = $saved_post_id;
4606
+								$gd_post['post_tags'] = $post_tags;
4607
+								$gd_post['post_title'] = $post_title;
4608
+								$gd_post['post_status'] = $post_status;
4609
+								$gd_post['submit_time'] = time();
4610
+								$gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR'];
4611 4611
                                                     
4612
-                                // post location
4613
-                                $post_location_id = 0;
4614
-                                if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
4615
-                                    $gd_post['post_neighbourhood'] = '';
4612
+								// post location
4613
+								$post_location_id = 0;
4614
+								if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
4615
+									$gd_post['post_neighbourhood'] = '';
4616 4616
                                     
4617
-                                    $post_location_info = array(
4618
-                                                                'city' => $post_city,
4619
-                                                                'region' => $post_region,
4620
-                                                                'country' => $post_country,
4621
-                                                                'geo_lat' => $post_latitude,
4622
-                                                                'geo_lng' => $post_longitude
4623
-                                                            );
4624
-                                    if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
4625
-                                        $post_location_id = $location_id;
4626
-                                    }
4617
+									$post_location_info = array(
4618
+																'city' => $post_city,
4619
+																'region' => $post_region,
4620
+																'country' => $post_country,
4621
+																'geo_lat' => $post_latitude,
4622
+																'geo_lng' => $post_longitude
4623
+															);
4624
+									if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
4625
+										$post_location_id = $location_id;
4626
+									}
4627 4627
                                     
4628
-                                    if ($post_location_id > 0 && $neighbourhood_active && !empty($post_neighbourhood)) {
4629
-                                        $neighbourhood_info = geodir_location_neighbourhood_by_name_loc_id($post_neighbourhood, $post_location_id);
4628
+									if ($post_location_id > 0 && $neighbourhood_active && !empty($post_neighbourhood)) {
4629
+										$neighbourhood_info = geodir_location_neighbourhood_by_name_loc_id($post_neighbourhood, $post_location_id);
4630 4630
 
4631
-                                        $hood_data = array();
4632
-                                        $hood_data['hood_location_id'] = $post_location_id;
4633
-                                        $hood_data['hood_name'] = $post_neighbourhood;
4631
+										$hood_data = array();
4632
+										$hood_data['hood_location_id'] = $post_location_id;
4633
+										$hood_data['hood_name'] = $post_neighbourhood;
4634 4634
                                         
4635
-                                        if (!empty($neighbourhood_info)) {
4636
-                                            $hood_data['hood_id'] = $neighbourhood_info->hood_id;
4637
-                                            $hood_data['hood_slug'] = $neighbourhood_info->hood_slug;
4635
+										if (!empty($neighbourhood_info)) {
4636
+											$hood_data['hood_id'] = $neighbourhood_info->hood_id;
4637
+											$hood_data['hood_slug'] = $neighbourhood_info->hood_slug;
4638 4638
                                             
4639
-                                            if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
4640
-                                                $neighbourhood_latitude = $neighbourhood_info->hood_latitude;
4641
-                                                $neighbourhood_longitude = $neighbourhood_info->hood_longitude;
4642
-                                            }
4643
-                                        }
4639
+											if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
4640
+												$neighbourhood_latitude = $neighbourhood_info->hood_latitude;
4641
+												$neighbourhood_longitude = $neighbourhood_info->hood_longitude;
4642
+											}
4643
+										}
4644 4644
                                         
4645
-                                        if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
4646
-                                            $neighbourhood_latitude = $neighbourhood_info->hood_latitude;
4647
-                                            $neighbourhood_longitude = $neighbourhood_info->hood_longitude;
4648
-                                        }
4645
+										if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
4646
+											$neighbourhood_latitude = $neighbourhood_info->hood_latitude;
4647
+											$neighbourhood_longitude = $neighbourhood_info->hood_longitude;
4648
+										}
4649 4649
                                         
4650
-                                        $hood_data['hood_latitude'] = $post_latitude;
4651
-                                        $hood_data['hood_longitude'] = $post_longitude;
4650
+										$hood_data['hood_latitude'] = $post_latitude;
4651
+										$hood_data['hood_longitude'] = $post_longitude;
4652 4652
 
4653
-                                        $neighbourhood_info = geodir_location_insert_update_neighbourhood($hood_data);
4654
-                                        if (!empty($neighbourhood_info) && isset($neighbourhood_info->hood_slug)) {
4655
-                                            $gd_post['post_neighbourhood'] = $neighbourhood_info->hood_slug;
4656
-                                        }
4657
-                                    }
4658
-                                }
4659
-                                $gd_post['post_location_id'] = $post_location_id;
4653
+										$neighbourhood_info = geodir_location_insert_update_neighbourhood($hood_data);
4654
+										if (!empty($neighbourhood_info) && isset($neighbourhood_info->hood_slug)) {
4655
+											$gd_post['post_neighbourhood'] = $neighbourhood_info->hood_slug;
4656
+										}
4657
+									}
4658
+								}
4659
+								$gd_post['post_location_id'] = $post_location_id;
4660 4660
                                 
4661
-                                // post package info
4662
-                                $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0;
4663
-                                if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
4664
-                                    $package_id = $gd_post_info->package_id;
4665
-                                }
4661
+								// post package info
4662
+								$package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0;
4663
+								if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
4664
+									$package_id = $gd_post_info->package_id;
4665
+								}
4666 4666
                                 
4667
-                                $package_info = array();
4668
-                                if ($package_id && function_exists('geodir_get_package_info_by_id')) {
4669
-                                    $package_info = (array)geodir_get_package_info_by_id($package_id);
4667
+								$package_info = array();
4668
+								if ($package_id && function_exists('geodir_get_package_info_by_id')) {
4669
+									$package_info = (array)geodir_get_package_info_by_id($package_id);
4670 4670
                                     
4671
-                                    if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
4672
-                                        $package_info = array();
4673
-                                    }
4674
-                                }
4671
+									if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
4672
+										$package_info = array();
4673
+									}
4674
+								}
4675 4675
                                 
4676
-                                if (empty($package_info)) {
4677
-                                    $package_info = (array)geodir_post_package_info( array(), '', $post_type );
4678
-                                }
4676
+								if (empty($package_info)) {
4677
+									$package_info = (array)geodir_post_package_info( array(), '', $post_type );
4678
+								}
4679 4679
                                  
4680
-                                if (!empty($package_info))	 {
4681
-                                    $package_id = $package_info['pid'];
4680
+								if (!empty($package_info))	 {
4681
+									$package_id = $package_info['pid'];
4682 4682
                                     
4683
-                                    if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
4684
-                                        $gd_post['expire_date'] = $expire_date;
4685
-                                    } else {
4686
-                                        if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
4687
-                                            $gd_post['alive_days'] = (int)$package_info['days'];
4688
-                                            $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) );
4689
-                                        } else {
4690
-                                            $gd_post['expire_date'] = 'Never';
4691
-                                        }
4692
-                                    }
4683
+									if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
4684
+										$gd_post['expire_date'] = $expire_date;
4685
+									} else {
4686
+										if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
4687
+											$gd_post['alive_days'] = (int)$package_info['days'];
4688
+											$gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) );
4689
+										} else {
4690
+											$gd_post['expire_date'] = 'Never';
4691
+										}
4692
+									}
4693 4693
                                     
4694
-                                    $gd_post['package_id'] = $package_id;
4695
-                                }
4694
+									$gd_post['package_id'] = $package_id;
4695
+								}
4696 4696
 
4697
-                                $table = $plugin_prefix . $post_type . '_detail';
4697
+								$table = $plugin_prefix . $post_type . '_detail';
4698 4698
                                 
4699
-                                if ($post_type == 'gd_event') {
4700
-                                    $gd_post = geodir_imex_process_event_data($gd_post);
4701
-                                }
4699
+								if ($post_type == 'gd_event') {
4700
+									$gd_post = geodir_imex_process_event_data($gd_post);
4701
+								}
4702 4702
                                 
4703
-                                if (isset($gd_post['post_id'])) {
4704
-                                    unset($gd_post['post_id']);
4705
-                                }
4703
+								if (isset($gd_post['post_id'])) {
4704
+									unset($gd_post['post_id']);
4705
+								}
4706 4706
 
4707
-                                // Export franchise fields
4708
-                                $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false;
4709
-                                if ($is_franchise_active) {
4710
-                                    if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
4711
-                                        $gd_franchise_lock = array();
4707
+								// Export franchise fields
4708
+								$is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false;
4709
+								if ($is_franchise_active) {
4710
+									if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
4711
+										$gd_franchise_lock = array();
4712 4712
                                         
4713
-                                        if ( isset( $gd_post['gd_franchise_lock'] ) ) {
4714
-                                            $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
4715
-                                            $gd_franchise_lock = trim( $gd_franchise_lock );
4716
-                                            $gd_franchise_lock = explode( ",", $gd_franchise_lock );
4717
-                                        }
4713
+										if ( isset( $gd_post['gd_franchise_lock'] ) ) {
4714
+											$gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
4715
+											$gd_franchise_lock = trim( $gd_franchise_lock );
4716
+											$gd_franchise_lock = explode( ",", $gd_franchise_lock );
4717
+										}
4718 4718
                                         
4719
-                                        update_post_meta( $saved_post_id, 'gd_is_franchise', 1 );
4720
-                                        update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock );
4721
-                                    } else {
4722
-                                        if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
4723
-                                            geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] );
4724
-                                        }
4725
-                                    }
4726
-                                }
4719
+										update_post_meta( $saved_post_id, 'gd_is_franchise', 1 );
4720
+										update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock );
4721
+									} else {
4722
+										if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
4723
+											geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] );
4724
+										}
4725
+									}
4726
+								}
4727 4727
                                 
4728
-                                if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
4729
-                                    $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) );
4730
-                                    if ($default_category_id) {
4731
-                                        $save_post['post_default_category'] = $default_category_id;
4732
-                                        $gd_post['default_category'] = $default_category_id;
4733
-                                    }
4734
-                                    $gd_post[$cat_taxonomy] = $save_post['post_category'];
4735
-                                }
4728
+								if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
4729
+									$save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) );
4730
+									if ($default_category_id) {
4731
+										$save_post['post_default_category'] = $default_category_id;
4732
+										$gd_post['default_category'] = $default_category_id;
4733
+									}
4734
+									$gd_post[$cat_taxonomy] = $save_post['post_category'];
4735
+								}
4736 4736
                                 
4737
-                                // Save post info
4738
-                                geodir_save_post_info( $saved_post_id, $gd_post );
4739
-                                // post taxonomies
4740
-                                if ( !empty( $save_post['post_category'] ) ) {
4741
-                                    wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy );
4737
+								// Save post info
4738
+								geodir_save_post_info( $saved_post_id, $gd_post );
4739
+								// post taxonomies
4740
+								if ( !empty( $save_post['post_category'] ) ) {
4741
+									wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy );
4742 4742
                                     
4743
-                                    $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : '';
4744
-                                    if ($default_category_id) {
4745
-                                        $post_default_category = $default_category_id;
4746
-                                    }
4747
-                                    $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy);
4748
-                                    $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
4749
-                                    $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
4743
+									$post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : '';
4744
+									if ($default_category_id) {
4745
+										$post_default_category = $default_category_id;
4746
+									}
4747
+									$post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy);
4748
+									$save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
4749
+									$post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
4750 4750
                                     
4751
-                                    if ($post_category_str != '' && $post_default_category) {
4752
-                                        $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str);
4753
-                                    }
4751
+									if ($post_category_str != '' && $post_default_category) {
4752
+										$post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str);
4753
+									}
4754 4754
                                     
4755
-                                    $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : '';
4755
+									$post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : '';
4756 4756
                                     
4757
-                                    geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str );
4758
-                                }
4757
+									geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str );
4758
+								}
4759 4759
 
4760
-                                if ( !empty( $save_post['post_tags'] ) ) {
4761
-                                    wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy );
4762
-                                }
4760
+								if ( !empty( $save_post['post_tags'] ) ) {
4761
+									wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy );
4762
+								}
4763 4763
 
4764
-                                // Post images
4765
-                                if ( !empty( $post_images ) ) {
4766
-                                    $post_images = array_unique($post_images);
4764
+								// Post images
4765
+								if ( !empty( $post_images ) ) {
4766
+									$post_images = array_unique($post_images);
4767 4767
                                     
4768
-                                    $old_post_images_arr = array();
4769
-                                    $saved_post_images_arr = array();
4768
+									$old_post_images_arr = array();
4769
+									$saved_post_images_arr = array();
4770 4770
                                     
4771
-                                    $order = 1;
4771
+									$order = 1;
4772 4772
                                     
4773
-                                    $old_post_images = geodir_get_images( $saved_post_id );
4774
-                                    if (!empty($old_post_images)) {
4775
-                                        foreach( $old_post_images as $old_post_image ) {
4776
-                                            if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
4777
-                                                $old_post_images_arr[] = $old_post_image->file;
4778
-                                            }
4779
-                                        }
4780
-                                    }
4773
+									$old_post_images = geodir_get_images( $saved_post_id );
4774
+									if (!empty($old_post_images)) {
4775
+										foreach( $old_post_images as $old_post_image ) {
4776
+											if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
4777
+												$old_post_images_arr[] = $old_post_image->file;
4778
+											}
4779
+										}
4780
+									}
4781 4781
 
4782
-                                    foreach ( $post_images as $post_image ) {
4783
-                                        $image_name = basename( $post_image );
4784
-                                        $saved_post_images_arr[] = $image_name;
4782
+									foreach ( $post_images as $post_image ) {
4783
+										$image_name = basename( $post_image );
4784
+										$saved_post_images_arr[] = $image_name;
4785 4785
                                         
4786
-                                        if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
4787
-                                            continue; // Skip if image already exists.
4788
-                                        }
4786
+										if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
4787
+											continue; // Skip if image already exists.
4788
+										}
4789 4789
                                         
4790
-                                        $image_name_parts = explode( '.', $image_name );
4791
-                                        array_pop( $image_name_parts );
4792
-                                        $proper_image_name = implode( '.', $image_name_parts );
4790
+										$image_name_parts = explode( '.', $image_name );
4791
+										array_pop( $image_name_parts );
4792
+										$proper_image_name = implode( '.', $image_name_parts );
4793 4793
                                         
4794
-                                        $arr_file_type = wp_check_filetype( $image_name );
4794
+										$arr_file_type = wp_check_filetype( $image_name );
4795 4795
                                         
4796
-                                        if ( !empty( $arr_file_type ) ) {
4797
-                                            $uploaded_file_type = $arr_file_type['type'];
4796
+										if ( !empty( $arr_file_type ) ) {
4797
+											$uploaded_file_type = $arr_file_type['type'];
4798 4798
                                             
4799
-                                            $attachment = array();
4800
-                                            $attachment['post_id'] = $saved_post_id;
4801
-                                            $attachment['title'] = $proper_image_name;
4802
-                                            $attachment['content'] = '';
4803
-                                            $attachment['file'] = $uploads_subdir . '/' . $image_name;
4804
-                                            $attachment['mime_type'] = $uploaded_file_type;
4805
-                                            $attachment['menu_order'] = $order;
4806
-                                            $attachment['is_featured'] = 0;
4807
-
4808
-                                            $attachment_set = '';
4809
-                                            foreach ( $attachment as $key => $val ) {
4810
-                                                if ( $val != '' ) {
4811
-                                                    $attachment_set .= $key . " = '" . $val . "', ";
4812
-                                                }
4813
-                                            }
4814
-                                            $attachment_set = trim( $attachment_set, ", " );
4799
+											$attachment = array();
4800
+											$attachment['post_id'] = $saved_post_id;
4801
+											$attachment['title'] = $proper_image_name;
4802
+											$attachment['content'] = '';
4803
+											$attachment['file'] = $uploads_subdir . '/' . $image_name;
4804
+											$attachment['mime_type'] = $uploaded_file_type;
4805
+											$attachment['menu_order'] = $order;
4806
+											$attachment['is_featured'] = 0;
4807
+
4808
+											$attachment_set = '';
4809
+											foreach ( $attachment as $key => $val ) {
4810
+												if ( $val != '' ) {
4811
+													$attachment_set .= $key . " = '" . $val . "', ";
4812
+												}
4813
+											}
4814
+											$attachment_set = trim( $attachment_set, ", " );
4815 4815
                                                                                         
4816
-                                            // Add new attachment
4817
-                                            $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set );
4816
+											// Add new attachment
4817
+											$wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set );
4818 4818
                                                                                         
4819
-                                            $order++;
4820
-                                        }
4821
-                                    }
4819
+											$order++;
4820
+										}
4821
+									}
4822 4822
 
4823
-                                    $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/",  $saved_post_images_arr) . "' )" : '';
4824
-                                    // Remove previous attachment
4825
-                                    $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql );
4823
+									$saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/",  $saved_post_images_arr) . "' )" : '';
4824
+									// Remove previous attachment
4825
+									$wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql );
4826 4826
                                     
4827
-                                    if ( !empty( $saved_post_images_arr ) ) {
4828
-                                        geodir_set_wp_featured_image($saved_post_id);
4829
-                                        /*
4827
+									if ( !empty( $saved_post_images_arr ) ) {
4828
+										geodir_set_wp_featured_image($saved_post_id);
4829
+										/*
4830 4830
                                         $menu_order = 1;
4831 4831
                                         
4832 4832
                                         foreach ( $saved_post_images_arr as $img_name ) {
@@ -4839,281 +4839,281 @@  discard block
 block discarded – undo
4839 4839
                                             }
4840 4840
                                             $menu_order++;
4841 4841
                                         }*/
4842
-                                    }
4842
+									}
4843 4843
                                     
4844
-                                    if ( $order > 1 ) {
4845
-                                        $images++;
4846
-                                    }
4847
-                                }
4844
+									if ( $order > 1 ) {
4845
+										$images++;
4846
+									}
4847
+								}
4848 4848
 
4849
-                                /** This action is documented in geodirectory-functions/post-functions.php */
4850
-                                do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post );
4849
+								/** This action is documented in geodirectory-functions/post-functions.php */
4850
+								do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post );
4851 4851
                                 
4852
-                                if (isset($is_featured)) {
4853
-                                    geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured);
4854
-                                }
4855
-                                if (isset($gd_post['expire_date'])) {
4856
-                                    geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']);
4857
-                                }
4858
-                            }
4852
+								if (isset($is_featured)) {
4853
+									geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured);
4854
+								}
4855
+								if (isset($gd_post['expire_date'])) {
4856
+									geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']);
4857
+								}
4858
+							}
4859 4859
                             
4860
-                            // WPML
4861
-                            if ($is_wpml && $language != '') {
4862
-                                $sitepress->switch_lang($active_lang, true);
4863
-                            }
4864
-                            // WPML
4865
-                        }
4866
-                    }
4867
-                }
4860
+							// WPML
4861
+							if ($is_wpml && $language != '') {
4862
+								$sitepress->switch_lang($active_lang, true);
4863
+							}
4864
+							// WPML
4865
+						}
4866
+					}
4867
+				}
4868 4868
 
4869
-                //undo some stuff to make the import quicker
4870
-                wp_defer_term_counting( false );
4871
-                wp_defer_comment_counting( false );
4872
-                $wpdb->query( 'COMMIT;' );
4873
-                $wpdb->query( 'SET autocommit = 1;' );
4874
-
4875
-                $json = array();
4876
-                $json['processed'] = $processed_actual;
4877
-                $json['created'] = $created;
4878
-                $json['updated'] = $updated;
4879
-                $json['skipped'] = $skipped;
4880
-                $json['invalid'] = $invalid;
4881
-                $json['invalid_addr'] = $invalid_addr;
4882
-                $json['images'] = $images;
4869
+				//undo some stuff to make the import quicker
4870
+				wp_defer_term_counting( false );
4871
+				wp_defer_comment_counting( false );
4872
+				$wpdb->query( 'COMMIT;' );
4873
+				$wpdb->query( 'SET autocommit = 1;' );
4874
+
4875
+				$json = array();
4876
+				$json['processed'] = $processed_actual;
4877
+				$json['created'] = $created;
4878
+				$json['updated'] = $updated;
4879
+				$json['skipped'] = $skipped;
4880
+				$json['invalid'] = $invalid;
4881
+				$json['invalid_addr'] = $invalid_addr;
4882
+				$json['images'] = $images;
4883 4883
                 
4884
-                wp_send_json( $json );
4885
-                exit;
4886
-            } else if ( $task == 'import_loc' ) {
4887
-                global $gd_post_types;
4888
-                $gd_post_types = $post_types;
4884
+				wp_send_json( $json );
4885
+				exit;
4886
+			} else if ( $task == 'import_loc' ) {
4887
+				global $gd_post_types;
4888
+				$gd_post_types = $post_types;
4889 4889
                 
4890
-                if (!empty($file)) {
4891
-                    $columns = isset($file[0]) ? $file[0] : NULL;
4890
+				if (!empty($file)) {
4891
+					$columns = isset($file[0]) ? $file[0] : NULL;
4892 4892
                     
4893
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4894
-                        $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4895
-                        wp_send_json( $json );
4896
-                    }
4893
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4894
+						$json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4895
+						wp_send_json( $json );
4896
+					}
4897 4897
                     
4898
-                    $gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory');
4899
-                    $gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' );
4900
-                    for ($i = 1; $i <= $limit; $i++) {
4901
-                        $index = $processed + $i;
4898
+					$gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory');
4899
+					$gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' );
4900
+					for ($i = 1; $i <= $limit; $i++) {
4901
+						$index = $processed + $i;
4902 4902
                         
4903
-                        if (isset($file[$index])) {
4904
-                            $row = $file[$index];
4905
-                            $row = array_map( 'trim', $row );
4906
-                            $data = array();
4903
+						if (isset($file[$index])) {
4904
+							$row = $file[$index];
4905
+							$row = array_map( 'trim', $row );
4906
+							$data = array();
4907 4907
                             
4908
-                            foreach ($columns as $c => $column ) {
4909
-                                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'))) {
4910
-                                    $data[$column] = $row[$c];
4911
-                                }
4912
-                            }
4908
+							foreach ($columns as $c => $column ) {
4909
+								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'))) {
4910
+									$data[$column] = $row[$c];
4911
+								}
4912
+							}
4913 4913
 
4914
-                            if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
4915
-                                $invalid++;
4916
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4917
-                                continue;
4918
-                            }
4914
+							if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
4915
+								$invalid++;
4916
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4917
+								continue;
4918
+							}
4919 4919
                             
4920
-                            $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0;
4920
+							$data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0;
4921 4921
                             
4922
-                            if ( $import_choice == 'update' ) {
4923
-                                if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4924
-                                    if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4925
-                                        $updated++;
4926
-                                    } else {
4927
-                                        $invalid++;
4928
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4929
-                                    }
4930
-                                } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4931
-                                    $data['location_id'] = (int)$location->location_id;
4922
+							if ( $import_choice == 'update' ) {
4923
+								if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4924
+									if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4925
+										$updated++;
4926
+									} else {
4927
+										$invalid++;
4928
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4929
+									}
4930
+								} else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4931
+									$data['location_id'] = (int)$location->location_id;
4932 4932
                                     
4933
-                                    if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
4934
-                                        $data['location_id'] = (int)$location->location_id;
4935
-                                    } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
4936
-                                        $data['location_id'] = (int)$location->location_id;
4937
-                                    } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
4938
-                                        $data['location_id'] = (int)$location->location_id;
4939
-                                    }
4933
+									if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
4934
+										$data['location_id'] = (int)$location->location_id;
4935
+									} else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
4936
+										$data['location_id'] = (int)$location->location_id;
4937
+									} else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
4938
+										$data['location_id'] = (int)$location->location_id;
4939
+									}
4940 4940
                                     
4941
-                                    if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4942
-                                        $updated++;
4943
-                                    } else {
4944
-                                        $invalid++;
4945
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4946
-                                    }
4947
-                                } else {
4948
-                                    if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4949
-                                        $created++;
4950
-                                    } else {
4951
-                                        $invalid++;
4952
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4953
-                                    }
4954
-                                }
4955
-                            } elseif ( $import_choice == 'skip' ) {
4956
-                                if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4957
-                                    $skipped++;
4958
-                                } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4959
-                                    $skipped++;
4960
-                                } else {
4961
-                                    if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4962
-                                        $created++;
4963
-                                    } else {
4964
-                                        $invalid++;
4965
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4966
-                                    }
4967
-                                }
4968
-                            } else {
4969
-                                $invalid++;
4970
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4971
-                            }
4972
-                        }
4973
-                    }
4974
-                }
4941
+									if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4942
+										$updated++;
4943
+									} else {
4944
+										$invalid++;
4945
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4946
+									}
4947
+								} else {
4948
+									if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4949
+										$created++;
4950
+									} else {
4951
+										$invalid++;
4952
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4953
+									}
4954
+								}
4955
+							} elseif ( $import_choice == 'skip' ) {
4956
+								if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4957
+									$skipped++;
4958
+								} else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4959
+									$skipped++;
4960
+								} else {
4961
+									if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4962
+										$created++;
4963
+									} else {
4964
+										$invalid++;
4965
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4966
+									}
4967
+								}
4968
+							} else {
4969
+								$invalid++;
4970
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4971
+							}
4972
+						}
4973
+					}
4974
+				}
4975 4975
                 
4976
-                $json = array();
4977
-                $json['processed'] = $limit;
4978
-                $json['created'] = $created;
4979
-                $json['updated'] = $updated;
4980
-                $json['skipped'] = $skipped;
4981
-                $json['invalid'] = $invalid;
4982
-                $json['images'] = $images;
4976
+				$json = array();
4977
+				$json['processed'] = $limit;
4978
+				$json['created'] = $created;
4979
+				$json['updated'] = $updated;
4980
+				$json['skipped'] = $skipped;
4981
+				$json['invalid'] = $invalid;
4982
+				$json['images'] = $images;
4983 4983
                 
4984
-                wp_send_json( $json );
4985
-            } else if ( $task == 'import_hood' ) {               
4986
-                if (!empty($file)) {
4987
-                    $columns = isset($file[0]) ? $file[0] : NULL;
4984
+				wp_send_json( $json );
4985
+			} else if ( $task == 'import_hood' ) {               
4986
+				if (!empty($file)) {
4987
+					$columns = isset($file[0]) ? $file[0] : NULL;
4988 4988
                     
4989
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4990
-                        $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4991
-                        wp_send_json( $json );
4992
-                    }
4989
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4990
+						$json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4991
+						wp_send_json( $json );
4992
+					}
4993 4993
                     
4994
-                    $gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory');
4995
-                    $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' );
4996
-                    for ($i = 1; $i <= $limit; $i++) {
4997
-                        $index = $processed + $i;
4994
+					$gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory');
4995
+					$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' );
4996
+					for ($i = 1; $i <= $limit; $i++) {
4997
+						$index = $processed + $i;
4998 4998
                         
4999
-                        if (isset($file[$index])) {
5000
-                            $row = $file[$index];
5001
-                            $row = array_map( 'trim', $row );
5002
-                            $data = array();
4999
+						if (isset($file[$index])) {
5000
+							$row = $file[$index];
5001
+							$row = array_map( 'trim', $row );
5002
+							$data = array();
5003 5003
                             
5004
-                            foreach ($columns as $c => $column) {
5005
-                                if (in_array($column, array('neighbourhood_id', 'neighbourhood_name', 'neighbourhood_slug', 'latitude', 'longitude', 'location_id', 'city', 'region', 'country'))) {
5006
-                                    $data[$column] = sanitize_text_field($row[$c]);
5007
-                                }
5008
-                            }
5004
+							foreach ($columns as $c => $column) {
5005
+								if (in_array($column, array('neighbourhood_id', 'neighbourhood_name', 'neighbourhood_slug', 'latitude', 'longitude', 'location_id', 'city', 'region', 'country'))) {
5006
+									$data[$column] = sanitize_text_field($row[$c]);
5007
+								}
5008
+							}
5009 5009
 
5010
-                            if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
5011
-                                $invalid++;
5012
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5013
-                                continue;
5014
-                            }
5010
+							if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
5011
+								$invalid++;
5012
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5013
+								continue;
5014
+							}
5015 5015
                             
5016
-                            $location_info = array();
5017
-                            if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
5018
-                                $location_info = geodir_get_location_by_id('', (int)$data['location_id']);
5019
-                            } else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
5020
-                                $location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
5021
-                            }
5016
+							$location_info = array();
5017
+							if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
5018
+								$location_info = geodir_get_location_by_id('', (int)$data['location_id']);
5019
+							} else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
5020
+								$location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
5021
+							}
5022 5022
 
5023
-                            if (empty($location_info)) {
5024
-                                $invalid++;
5025
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5026
-                                continue;
5027
-                            }
5023
+							if (empty($location_info)) {
5024
+								$invalid++;
5025
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5026
+								continue;
5027
+							}
5028 5028
                             
5029
-                            $location_id = $location_info->location_id;
5029
+							$location_id = $location_info->location_id;
5030 5030
 
5031
-                            $data['neighbourhood_id'] = isset($data['neighbourhood_id']) ? absint($data['neighbourhood_id']) : 0;
5031
+							$data['neighbourhood_id'] = isset($data['neighbourhood_id']) ? absint($data['neighbourhood_id']) : 0;
5032 5032
                             
5033
-                            $hood_data = array();
5034
-                            $hood_data['hood_name'] = $data['neighbourhood_name'];
5035
-                            $hood_data['hood_slug'] = $data['neighbourhood_slug'];
5036
-                            $hood_data['hood_latitude'] = $data['latitude'];
5037
-                            $hood_data['hood_longitude'] = $data['longitude'];
5038
-                            $hood_data['hood_location_id'] = $location_id;
5033
+							$hood_data = array();
5034
+							$hood_data['hood_name'] = $data['neighbourhood_name'];
5035
+							$hood_data['hood_slug'] = $data['neighbourhood_slug'];
5036
+							$hood_data['hood_latitude'] = $data['latitude'];
5037
+							$hood_data['hood_longitude'] = $data['longitude'];
5038
+							$hood_data['hood_location_id'] = $location_id;
5039 5039
                                     
5040
-                            if ( $import_choice == 'update' ) {
5041
-                                if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
5042
-                                    $hood_data['hood_id'] = (int)$data['neighbourhood_id'];
5040
+							if ( $import_choice == 'update' ) {
5041
+								if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
5042
+									$hood_data['hood_id'] = (int)$data['neighbourhood_id'];
5043 5043
                                     
5044
-                                    if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5045
-                                        $updated++;
5046
-                                    } else {
5047
-                                        $invalid++;
5048
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5049
-                                    }
5050
-                                } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
5051
-                                    $hood_data['hood_id'] = (int)$neighbourhood->hood_id;
5044
+									if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5045
+										$updated++;
5046
+									} else {
5047
+										$invalid++;
5048
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5049
+									}
5050
+								} else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
5051
+									$hood_data['hood_id'] = (int)$neighbourhood->hood_id;
5052 5052
                                     
5053
-                                    if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5054
-                                        $updated++;
5055
-                                    } else {
5056
-                                        $invalid++;
5057
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5058
-                                    }
5059
-                                } else {
5060
-                                    if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5061
-                                        $created++;
5062
-                                    } else {
5063
-                                        $invalid++;
5064
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5065
-                                    }
5066
-                                }
5067
-                            } elseif ( $import_choice == 'skip' ) {
5068
-                                if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
5069
-                                    $skipped++;
5070
-                                } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
5071
-                                    $skipped++;
5072
-                                } else {
5053
+									if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5054
+										$updated++;
5055
+									} else {
5056
+										$invalid++;
5057
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5058
+									}
5059
+								} else {
5060
+									if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5061
+										$created++;
5062
+									} else {
5063
+										$invalid++;
5064
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5065
+									}
5066
+								}
5067
+							} elseif ( $import_choice == 'skip' ) {
5068
+								if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
5069
+									$skipped++;
5070
+								} else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
5071
+									$skipped++;
5072
+								} else {
5073 5073
                                     
5074
-                                    if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5075
-                                        $created++;
5076
-                                    } else {
5077
-                                        $invalid++;
5078
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5079
-                                    }
5080
-                                }
5081
-                            } else {
5082
-                                $invalid++;
5083
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5084
-                            }
5085
-                        }
5086
-                    }
5087
-                }
5074
+									if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5075
+										$created++;
5076
+									} else {
5077
+										$invalid++;
5078
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5079
+									}
5080
+								}
5081
+							} else {
5082
+								$invalid++;
5083
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5084
+							}
5085
+						}
5086
+					}
5087
+				}
5088 5088
                 
5089
-                $json = array();
5090
-                $json['processed'] = $limit;
5091
-                $json['created'] = $created;
5092
-                $json['updated'] = $updated;
5093
-                $json['skipped'] = $skipped;
5094
-                $json['invalid'] = $invalid;
5095
-                $json['images'] = $images;
5089
+				$json = array();
5090
+				$json['processed'] = $limit;
5091
+				$json['created'] = $created;
5092
+				$json['updated'] = $updated;
5093
+				$json['skipped'] = $skipped;
5094
+				$json['invalid'] = $invalid;
5095
+				$json['images'] = $images;
5096 5096
                 
5097
-                wp_send_json( $json );
5098
-            }
5099
-        }
5100
-        break;
5101
-        case 'import_finish':{
5102
-            /**
5103
-             * Run an action when an import finishes.
5104
-             *
5105
-             * This action can be used to fire functions after an import ends.
5106
-             *
5107
-             * @since 1.5.3
5108
-             * @package GeoDirectory
5109
-             */
5110
-            do_action('geodir_import_finished');
5111
-        }
5112
-        break;
5097
+				wp_send_json( $json );
5098
+			}
5099
+		}
5100
+		break;
5101
+		case 'import_finish':{
5102
+			/**
5103
+			 * Run an action when an import finishes.
5104
+			 *
5105
+			 * This action can be used to fire functions after an import ends.
5106
+			 *
5107
+			 * @since 1.5.3
5108
+			 * @package GeoDirectory
5109
+			 */
5110
+			do_action('geodir_import_finished');
5111
+		}
5112
+		break;
5113 5113
 
5114
-    }
5115
-    echo '0';
5116
-    gd_die();
5114
+	}
5115
+	echo '0';
5116
+	gd_die();
5117 5117
 }
5118 5118
 
5119 5119
 /**
@@ -5157,12 +5157,12 @@  discard block
 block discarded – undo
5157 5157
 		$args['slug'] = wp_unique_term_slug( $args['slug'], (object)$term_args );
5158 5158
 	}
5159 5159
 	
5160
-    if( !empty( $term ) ) {
5160
+	if( !empty( $term ) ) {
5161 5161
 		$result = wp_insert_term( $term, $taxonomy, $args );
5162
-        if( !is_wp_error( $result ) ) {
5163
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5164
-        }
5165
-    }
5162
+		if( !is_wp_error( $result ) ) {
5163
+			return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5164
+		}
5165
+	}
5166 5166
 	
5167 5167
 	return false;
5168 5168
 }
@@ -5208,16 +5208,16 @@  discard block
 block discarded – undo
5208 5208
 		$result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
5209 5209
 		
5210 5210
 		if( !is_wp_error( $result ) ) {
5211
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5212
-        }
5211
+			return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5212
+		}
5213 5213
 	} else if ( $term_data['slug'] != '' && $term_info = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
5214 5214
 		$term_data['term_id'] = $term_info['term_id'];
5215 5215
 		
5216 5216
 		$result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
5217 5217
 		
5218 5218
 		if( !is_wp_error( $result ) ) {
5219
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5220
-        }
5219
+			return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5220
+		}
5221 5221
 	} else {
5222 5222
 		return geodir_imex_insert_term( $taxonomy, $term_data );
5223 5223
 	}
@@ -5238,37 +5238,37 @@  discard block
 block discarded – undo
5238 5238
  * @return int Posts count.
5239 5239
  */
5240 5240
 function geodir_get_posts_count( $post_type ) {
5241
-    global $wpdb, $plugin_prefix;
5241
+	global $wpdb, $plugin_prefix;
5242 5242
 
5243
-    if ( !post_type_exists( $post_type ) ) {
5244
-        return 0;
5245
-    }
5243
+	if ( !post_type_exists( $post_type ) ) {
5244
+		return 0;
5245
+	}
5246 5246
         
5247
-    $table = $plugin_prefix . $post_type . '_detail';
5247
+	$table = $plugin_prefix . $post_type . '_detail';
5248 5248
 
5249
-    // Skip listing with statuses trash, auto-draft etc...
5250
-    $skip_statuses = geodir_imex_export_skip_statuses();
5251
-    $where_statuses = '';
5252
-    if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5253
-        $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5254
-    }
5249
+	// Skip listing with statuses trash, auto-draft etc...
5250
+	$skip_statuses = geodir_imex_export_skip_statuses();
5251
+	$where_statuses = '';
5252
+	if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5253
+		$where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5254
+	}
5255 5255
 
5256
-    $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 );
5256
+	$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 );
5257 5257
 
5258
-    $posts_count = (int)$wpdb->get_var( $query );
5258
+	$posts_count = (int)$wpdb->get_var( $query );
5259 5259
     
5260
-    /**
5261
-     * Modify returned post counts for the current post type.
5262
-     *
5263
-     * @since 1.4.6
5264
-     * @package GeoDirectory
5265
-     *
5266
-     * @param int $posts_count Post counts.
5267
-     * @param string $post_type Post type.
5268
-     */
5269
-    $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type );
5270
-
5271
-    return $posts_count;
5260
+	/**
5261
+	 * Modify returned post counts for the current post type.
5262
+	 *
5263
+	 * @since 1.4.6
5264
+	 * @package GeoDirectory
5265
+	 *
5266
+	 * @param int $posts_count Post counts.
5267
+	 * @param string $post_type Post type.
5268
+	 */
5269
+	$posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type );
5270
+
5271
+	return $posts_count;
5272 5272
 }
5273 5273
 
5274 5274
 /**
@@ -5296,9 +5296,9 @@  discard block
 block discarded – undo
5296 5296
 	
5297 5297
 	if ( !empty( $posts ) ) {
5298 5298
 		$is_payment_plugin = is_plugin_active( 'geodir_payment_manager/geodir_payment_manager.php' );
5299
-        $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
5300
-        $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
5301
-        $neighbourhood_active = $location_manager && $location_allowed && get_option('location_neighbourhoods') ? true : false;
5299
+		$location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
5300
+		$location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
5301
+		$neighbourhood_active = $location_manager && $location_allowed && get_option('location_neighbourhoods') ? true : false;
5302 5302
 		
5303 5303
 		$csv_row = array();
5304 5304
 		$csv_row[] = 'post_id';
@@ -5342,11 +5342,11 @@  discard block
 block discarded – undo
5342 5342
 		$csv_row[] = 'post_zip';
5343 5343
 		$csv_row[] = 'post_latitude';
5344 5344
 		$csv_row[] = 'post_longitude';
5345
-        if ($neighbourhood_active) {
5346
-            $csv_row[] = 'post_neighbourhood';
5347
-            $csv_row[] = 'neighbourhood_latitude';
5348
-            $csv_row[] = 'neighbourhood_longitude';
5349
-        }
5345
+		if ($neighbourhood_active) {
5346
+			$csv_row[] = 'post_neighbourhood';
5347
+			$csv_row[] = 'neighbourhood_latitude';
5348
+			$csv_row[] = 'neighbourhood_longitude';
5349
+		}
5350 5350
 		$csv_row[] = 'geodir_timing';
5351 5351
 		$csv_row[] = 'geodir_contact';
5352 5352
 		$csv_row[] = 'geodir_email';
@@ -5381,7 +5381,7 @@  discard block
 block discarded – undo
5381 5381
 		$csv_rows[] = $csv_row;
5382 5382
 
5383 5383
 		$images_count = 5;
5384
-        $xx=0;
5384
+		$xx=0;
5385 5385
 		foreach ( $posts as $post ) {$xx++;
5386 5386
 			$post_id = $post['ID'];
5387 5387
 			
@@ -5524,21 +5524,21 @@  discard block
 block discarded – undo
5524 5524
 			$csv_row[] = $post_info['post_zip']; // post_zip
5525 5525
 			$csv_row[] = $post_info['post_latitude']; // post_latitude
5526 5526
 			$csv_row[] = $post_info['post_longitude']; // post_longitude
5527
-            if ($neighbourhood_active) {
5528
-                $post_neighbourhood = '';
5529
-                $neighbourhood_latitude = '';
5530
-                $neighbourhood_longitude = '';
5531
-                if (!empty($post_info['post_neighbourhood']) && ($hood_info = geodir_location_get_neighbourhood_by_id($post_info['post_neighbourhood'], true, $post_info['post_location_id']))) {
5532
-                    if (!empty($hood_info)) {
5533
-                        $post_neighbourhood = $hood_info->hood_name;
5534
-                        $neighbourhood_latitude = $hood_info->hood_latitude;
5535
-                        $neighbourhood_longitude = $hood_info->hood_longitude;
5536
-                    }
5537
-                }
5538
-                $csv_row[] = $post_neighbourhood; // post_neighbourhood
5539
-                $csv_row[] = $neighbourhood_latitude; // neighbourhood_latitude
5540
-                $csv_row[] = $neighbourhood_longitude; // neighbourhood_longitude
5541
-            }
5527
+			if ($neighbourhood_active) {
5528
+				$post_neighbourhood = '';
5529
+				$neighbourhood_latitude = '';
5530
+				$neighbourhood_longitude = '';
5531
+				if (!empty($post_info['post_neighbourhood']) && ($hood_info = geodir_location_get_neighbourhood_by_id($post_info['post_neighbourhood'], true, $post_info['post_location_id']))) {
5532
+					if (!empty($hood_info)) {
5533
+						$post_neighbourhood = $hood_info->hood_name;
5534
+						$neighbourhood_latitude = $hood_info->hood_latitude;
5535
+						$neighbourhood_longitude = $hood_info->hood_longitude;
5536
+					}
5537
+				}
5538
+				$csv_row[] = $post_neighbourhood; // post_neighbourhood
5539
+				$csv_row[] = $neighbourhood_latitude; // neighbourhood_latitude
5540
+				$csv_row[] = $neighbourhood_longitude; // neighbourhood_longitude
5541
+			}
5542 5542
 			$csv_row[] = $post_info['geodir_timing']; // geodir_timing
5543 5543
 			$csv_row[] = $post_info['geodir_contact']; // geodir_contact
5544 5544
 			$csv_row[] = $post_info['geodir_email']; // geodir_email
@@ -5609,55 +5609,55 @@  discard block
 block discarded – undo
5609 5609
  * @return array Array of posts data.
5610 5610
  */
5611 5611
 function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) {
5612
-    global $wpdb, $plugin_prefix;
5612
+	global $wpdb, $plugin_prefix;
5613 5613
 
5614
-    if ( ! post_type_exists( $post_type ) )
5615
-        return new stdClass;
5614
+	if ( ! post_type_exists( $post_type ) )
5615
+		return new stdClass;
5616 5616
         
5617
-    $table = $plugin_prefix . $post_type . '_detail';
5617
+	$table = $plugin_prefix . $post_type . '_detail';
5618 5618
 
5619
-    $limit = '';
5620
-    if ( $per_page > 0 && $page_no > 0 ) {
5621
-        $offset = ( $page_no - 1 ) * $per_page;
5619
+	$limit = '';
5620
+	if ( $per_page > 0 && $page_no > 0 ) {
5621
+		$offset = ( $page_no - 1 ) * $per_page;
5622 5622
         
5623
-        if ( $offset > 0 ) {
5624
-            $limit = " LIMIT " . $offset . "," . $per_page;
5625
-        } else {
5626
-            $limit = " LIMIT " . $per_page;
5627
-        }
5628
-    }
5623
+		if ( $offset > 0 ) {
5624
+			$limit = " LIMIT " . $offset . "," . $per_page;
5625
+		} else {
5626
+			$limit = " LIMIT " . $per_page;
5627
+		}
5628
+	}
5629 5629
 
5630
-    // Skip listing with statuses trash, auto-draft etc...
5631
-    $skip_statuses = geodir_imex_export_skip_statuses();
5632
-    $where_statuses = '';
5633
-    if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5634
-        $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5635
-    }
5630
+	// Skip listing with statuses trash, auto-draft etc...
5631
+	$skip_statuses = geodir_imex_export_skip_statuses();
5632
+	$where_statuses = '';
5633
+	if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5634
+		$where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5635
+	}
5636
+
5637
+	$query = "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;
5638
+	/**
5639
+	 * Modify returned posts SQL query for the current post type.
5640
+	 *
5641
+	 * @since 1.4.6
5642
+	 * @package GeoDirectory
5643
+	 *
5644
+	 * @param int $query The SQL query.
5645
+	 * @param string $post_type Post type.
5646
+	 */
5647
+	$query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type );
5648
+
5649
+	$results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A );
5636 5650
 
5637
-    $query = "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;
5638
-    /**
5639
-     * Modify returned posts SQL query for the current post type.
5640
-     *
5641
-     * @since 1.4.6
5642
-     * @package GeoDirectory
5643
-     *
5644
-     * @param int $query The SQL query.
5645
-     * @param string $post_type Post type.
5646
-     */
5647
-    $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type );
5648
-
5649
-    $results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A );
5650
-
5651
-    /**
5652
-     * Modify returned post results for the current post type.
5653
-     *
5654
-     * @since 1.4.6
5655
-     * @package GeoDirectory
5656
-     *
5657
-     * @param object $results An object containing all post ids.
5658
-     * @param string $post_type Post type.
5659
-     */
5660
-    return apply_filters( 'geodir_export_posts', $results, $post_type );
5651
+	/**
5652
+	 * Modify returned post results for the current post type.
5653
+	 *
5654
+	 * @since 1.4.6
5655
+	 * @package GeoDirectory
5656
+	 *
5657
+	 * @param object $results An object containing all post ids.
5658
+	 * @param string $post_type Post type.
5659
+	 */
5660
+	return apply_filters( 'geodir_export_posts', $results, $post_type );
5661 5661
 }
5662 5662
 
5663 5663
 /**
@@ -5675,23 +5675,23 @@  discard block
 block discarded – undo
5675 5675
  * @return string The SQL query.
5676 5676
  */
5677 5677
 function geodir_imex_get_events_query( $query, $post_type ) {
5678
-    if ( $post_type == 'gd_event' ) {
5679
-        global $wpdb, $plugin_prefix;
5678
+	if ( $post_type == 'gd_event' ) {
5679
+		global $wpdb, $plugin_prefix;
5680 5680
         
5681
-        $table = $plugin_prefix . $post_type . '_detail';
5682
-        $schedule_table = EVENT_SCHEDULE;
5681
+		$table = $plugin_prefix . $post_type . '_detail';
5682
+		$schedule_table = EVENT_SCHEDULE;
5683 5683
         
5684
-        // Skip listing with statuses trash, auto-draft etc...
5685
-        $skip_statuses = geodir_imex_export_skip_statuses();
5686
-        $where_statuses = '';
5687
-        if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5688
-            $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5689
-        }
5684
+		// Skip listing with statuses trash, auto-draft etc...
5685
+		$skip_statuses = geodir_imex_export_skip_statuses();
5686
+		$where_statuses = '';
5687
+		if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5688
+			$where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5689
+		}
5690 5690
 
5691
-        $query = "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";
5692
-    }
5691
+		$query = "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";
5692
+	}
5693 5693
 
5694
-    return $query;
5694
+	return $query;
5695 5695
 }
5696 5696
 
5697 5697
 /**
@@ -5713,36 +5713,36 @@  discard block
 block discarded – undo
5713 5713
  * @return int Total terms count.
5714 5714
  */
5715 5715
 function geodir_get_terms_count( $post_type ) {
5716
-    $args = array( 'hide_empty' => 0 );
5716
+	$args = array( 'hide_empty' => 0 );
5717 5717
 
5718
-    remove_all_filters( 'get_terms' );
5718
+	remove_all_filters( 'get_terms' );
5719 5719
 
5720
-    $taxonomy = $post_type . 'category';
5720
+	$taxonomy = $post_type . 'category';
5721 5721
 
5722
-    // WPML
5723
-    $is_wpml = geodir_is_wpml();
5724
-    $active_lang = 'all';
5725
-    if ( $is_wpml ) {
5726
-        global $sitepress;
5727
-        $active_lang = $sitepress->get_current_language();
5722
+	// WPML
5723
+	$is_wpml = geodir_is_wpml();
5724
+	$active_lang = 'all';
5725
+	if ( $is_wpml ) {
5726
+		global $sitepress;
5727
+		$active_lang = $sitepress->get_current_language();
5728 5728
         
5729
-        if ( $active_lang != 'all' ) {
5730
-            $sitepress->switch_lang( 'all', true );
5731
-        }
5732
-    }
5733
-    // WPML
5729
+		if ( $active_lang != 'all' ) {
5730
+			$sitepress->switch_lang( 'all', true );
5731
+		}
5732
+	}
5733
+	// WPML
5734 5734
             
5735
-    $count_terms = wp_count_terms( $taxonomy, $args );
5735
+	$count_terms = wp_count_terms( $taxonomy, $args );
5736 5736
 
5737
-    // WPML
5738
-    if ( $is_wpml && $active_lang !== 'all' ) {
5739
-        global $sitepress;
5740
-        $sitepress->switch_lang( $active_lang, true );
5741
-    }
5742
-    // WPML
5743
-    $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0;
5737
+	// WPML
5738
+	if ( $is_wpml && $active_lang !== 'all' ) {
5739
+		global $sitepress;
5740
+		$sitepress->switch_lang( $active_lang, true );
5741
+	}
5742
+	// WPML
5743
+	$count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0;
5744 5744
      
5745
-    return $count_terms;
5745
+	return $count_terms;
5746 5746
 }
5747 5747
 
5748 5748
 /**
@@ -5781,11 +5781,11 @@  discard block
 block discarded – undo
5781 5781
 		$csv_row[] = 'cat_posttype';
5782 5782
 		$csv_row[] = 'cat_parent';
5783 5783
 		$csv_row[] = 'cat_schema';
5784
-        // WPML
5784
+		// WPML
5785 5785
 		$is_wpml = geodir_is_wpml();
5786 5786
 		if ($is_wpml) {
5787 5787
 			$csv_row[] = 'cat_language';
5788
-            $csv_row[] = 'cat_id_original';
5788
+			$csv_row[] = 'cat_id_original';
5789 5789
 		}
5790 5790
 		// WPML
5791 5791
 		$csv_row[] = 'cat_description';
@@ -5815,10 +5815,10 @@  discard block
 block discarded – undo
5815 5815
 			$csv_row[] = $post_type;
5816 5816
 			$csv_row[] = $cat_parent;
5817 5817
 			$csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_schema', false, $post_type );
5818
-            // WPML
5818
+			// WPML
5819 5819
 			if ($is_wpml) {
5820 5820
 				$csv_row[] = geodir_get_language_for_element( $term->term_id, 'tax_' . $taxonomy );
5821
-                $csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy );
5821
+				$csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy );
5822 5822
 			}
5823 5823
 			// WPML
5824 5824
 			$csv_row[] = $term->description;
@@ -6414,43 +6414,43 @@  discard block
 block discarded – undo
6414 6414
  * @param string $status Post status.
6415 6415
  */
6416 6416
 function geodir_create_page($slug, $option, $page_title = '', $page_content = '', $post_parent = 0, $status = 'publish') {
6417
-    global $wpdb, $current_user;
6418
-
6419
-    $option_value = get_option($option);
6420
-
6421
-    if ($option_value > 0) :
6422
-        if (get_post($option_value)) :
6423
-            // Page exists
6424
-            return;
6425
-        endif;
6426
-    endif;
6427
-
6428
-    $page_found = $wpdb->get_var(
6429
-        $wpdb->prepare(
6430
-            "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
6431
-            array($slug)
6432
-        )
6433
-    );
6434
-
6435
-    if ($page_found) :
6436
-        // Page exists
6437
-        if (!$option_value) update_option($option, $page_found);
6438
-        return;
6439
-    endif;
6440
-
6441
-    $page_data = array(
6442
-        'post_status' => $status,
6443
-        'post_type' => 'page',
6444
-        'post_author' => $current_user->ID,
6445
-        'post_name' => $slug,
6446
-        'post_title' => $page_title,
6447
-        'post_content' => $page_content,
6448
-        'post_parent' => $post_parent,
6449
-        'comment_status' => 'closed'
6450
-    );
6451
-    $page_id = wp_insert_post($page_data);
6452
-
6453
-    add_option($option, $page_id);
6417
+	global $wpdb, $current_user;
6418
+
6419
+	$option_value = get_option($option);
6420
+
6421
+	if ($option_value > 0) :
6422
+		if (get_post($option_value)) :
6423
+			// Page exists
6424
+			return;
6425
+		endif;
6426
+	endif;
6427
+
6428
+	$page_found = $wpdb->get_var(
6429
+		$wpdb->prepare(
6430
+			"SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
6431
+			array($slug)
6432
+		)
6433
+	);
6434
+
6435
+	if ($page_found) :
6436
+		// Page exists
6437
+		if (!$option_value) update_option($option, $page_found);
6438
+		return;
6439
+	endif;
6440
+
6441
+	$page_data = array(
6442
+		'post_status' => $status,
6443
+		'post_type' => 'page',
6444
+		'post_author' => $current_user->ID,
6445
+		'post_name' => $slug,
6446
+		'post_title' => $page_title,
6447
+		'post_content' => $page_content,
6448
+		'post_parent' => $post_parent,
6449
+		'comment_status' => 'closed'
6450
+	);
6451
+	$page_id = wp_insert_post($page_data);
6452
+
6453
+	add_option($option, $page_id);
6454 6454
 
6455 6455
 }
6456 6456
 
@@ -6481,9 +6481,9 @@  discard block
 block discarded – undo
6481 6481
  * @package GeoDirectory
6482 6482
  */
6483 6483
 function geodir_admin_upgrade_notice() {
6484
-    $class = "error";
6485
-    $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
6486
-    echo"<div class=\"$class\"> <p>$message</p></div>";
6484
+	$class = "error";
6485
+	$message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
6486
+	echo"<div class=\"$class\"> <p>$message</p></div>";
6487 6487
 }
6488 6488
 
6489 6489
 /**
@@ -6496,18 +6496,18 @@  discard block
 block discarded – undo
6496 6496
  */
6497 6497
 function geodire_admin_upgrade_notice( $plugin_data, $r )
6498 6498
 {
6499
-    // readme contents
6500
-    $args = array(
6501
-        'timeout'     => 15,
6502
-        'redirection' => 5
6503
-    );
6504
-    $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt";
6505
-    $data       = wp_remote_get( $url, $args );
6499
+	// readme contents
6500
+	$args = array(
6501
+		'timeout'     => 15,
6502
+		'redirection' => 5
6503
+	);
6504
+	$url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt";
6505
+	$data       = wp_remote_get( $url, $args );
6506 6506
 
6507
-    if (!is_wp_error($data) && $data['response']['code'] == 200) {
6507
+	if (!is_wp_error($data) && $data['response']['code'] == 200) {
6508 6508
 
6509
-        geodir_in_plugin_update_message($data['body']);
6510
-    }
6509
+		geodir_in_plugin_update_message($data['body']);
6510
+	}
6511 6511
 }
6512 6512
 
6513 6513
 
@@ -6515,28 +6515,28 @@  discard block
 block discarded – undo
6515 6515
 * @param string $content http response body
6516 6516
 */
6517 6517
 function geodir_in_plugin_update_message($content) {
6518
-    // Output Upgrade Notice
6519
-    $matches        = null;
6520
-    $regexp         = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis';
6521
-    $upgrade_notice = '';
6522
-    if ( preg_match( $regexp, $content, $matches ) ) {
6523
-        if(empty($matches)){return;}
6524
-
6525
-        $version = trim( $matches[1] );
6526
-        if($version && $version>GEODIRECTORY_VERSION){
6527
-
6528
-
6529
-        $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
6530
-        if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
6531
-            $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">';
6532
-            foreach ( $notices as $index => $line ) {
6533
-                $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
6534
-            }
6535
-            $upgrade_notice .= '</div> ';
6536
-        }
6537
-        }
6538
-    }
6539
-    echo $upgrade_notice;
6518
+	// Output Upgrade Notice
6519
+	$matches        = null;
6520
+	$regexp         = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis';
6521
+	$upgrade_notice = '';
6522
+	if ( preg_match( $regexp, $content, $matches ) ) {
6523
+		if(empty($matches)){return;}
6524
+
6525
+		$version = trim( $matches[1] );
6526
+		if($version && $version>GEODIRECTORY_VERSION){
6527
+
6528
+
6529
+		$notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
6530
+		if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
6531
+			$upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">';
6532
+			foreach ( $notices as $index => $line ) {
6533
+				$upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
6534
+			}
6535
+			$upgrade_notice .= '</div> ';
6536
+		}
6537
+		}
6538
+	}
6539
+	echo $upgrade_notice;
6540 6540
 }
6541 6541
 
6542 6542
 /**
@@ -6569,19 +6569,19 @@  discard block
 block discarded – undo
6569 6569
  * @param array Listing statuses to be skipped.
6570 6570
  */
6571 6571
 function geodir_imex_export_skip_statuses() {
6572
-    $statuses = array( 'trash', 'auto-draft' );
6572
+	$statuses = array( 'trash', 'auto-draft' );
6573 6573
     
6574
-    /**
6575
-     * Filter the statuses to skip during GD export listings.
6576
-     *
6577
-     * @since 1.6.0
6578
-     * @package GeoDirectory
6579
-     *
6580
-     * @param array $statuses Listing statuses to be skipped.
6581
-     */
6582
-    $statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses );
6574
+	/**
6575
+	 * Filter the statuses to skip during GD export listings.
6576
+	 *
6577
+	 * @since 1.6.0
6578
+	 * @package GeoDirectory
6579
+	 *
6580
+	 * @param array $statuses Listing statuses to be skipped.
6581
+	 */
6582
+	$statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses );
6583 6583
      
6584
-    return $statuses;
6584
+	return $statuses;
6585 6585
 }
6586 6586
 
6587 6587
 /**
@@ -6593,15 +6593,15 @@  discard block
 block discarded – undo
6593 6593
  * @since 1.6.3
6594 6594
  */
6595 6595
 function geodir_admin_dequeue_scripts() {
6596
-    // EDD
6597
-    if (wp_script_is('jquery-chosen', 'enqueued')) {
6598
-        wp_dequeue_script('jquery-chosen');
6599
-    }
6596
+	// EDD
6597
+	if (wp_script_is('jquery-chosen', 'enqueued')) {
6598
+		wp_dequeue_script('jquery-chosen');
6599
+	}
6600 6600
     
6601
-    // Ultimate Addons for Visual Composer
6602
-    if (wp_script_is('ultimate-vc-backend-script', 'enqueued')) {
6603
-        wp_dequeue_script('ultimate-vc-backend-script');
6604
-    }
6601
+	// Ultimate Addons for Visual Composer
6602
+	if (wp_script_is('ultimate-vc-backend-script', 'enqueued')) {
6603
+		wp_dequeue_script('ultimate-vc-backend-script');
6604
+	}
6605 6605
 }
6606 6606
 
6607 6607
 /*
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.
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
 
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
         $category = array();
720 720
 
721 721
         if (isset($_REQUEST['backandedit'])) {
722
-            $post = (object)$gd_session->get('listing');
722
+            $post = (object) $gd_session->get('listing');
723 723
             $post_type = $post->listing_type;
724 724
             if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
725 725
                 $post_id = $_REQUEST['pid'];
@@ -734,13 +734,13 @@  discard block
 block discarded – undo
734 734
 
735 735
         if ($relate_to == 'category') {
736 736
 
737
-            $category_taxonomy = $post_type . $relate_to;
737
+            $category_taxonomy = $post_type.$relate_to;
738 738
             if (isset($post->{$category_taxonomy}) && $post->{$category_taxonomy} != '')
739 739
                 $category = explode(',', trim($post->{$category_taxonomy}, ','));
740 740
 
741 741
         } elseif ($relate_to == 'tags') {
742 742
 
743
-            $category_taxonomy = $post_type . '_' . $relate_to;
743
+            $category_taxonomy = $post_type.'_'.$relate_to;
744 744
             if ($post->post_tags != '')
745 745
                 $category = explode(',', trim($post->post_tags, ','));
746 746
             $tax_field = 'name';
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
             if ($add_location_filter != '0') {
797 797
                 $geodir_add_location_url = '1';
798 798
             }
799
-            $viewall_url = get_term_link((int)$category[0], $post_type . $category_taxonomy);
799
+            $viewall_url = get_term_link((int) $category[0], $post_type.$category_taxonomy);
800 800
             $geodir_add_location_url = NULL;
801 801
         }
802 802
         ob_start();
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
                 $after_title = isset($after_title) ? $after_title : apply_filters('geodir_after_title', '</h3>');
814 814
                 ?>
815 815
                 <div class="location_list_heading clearfix">
816
-                    <?php echo $before_title . $title . $after_title; ?>
816
+                    <?php echo $before_title.$title.$after_title; ?>
817 817
                 </div>
818 818
             <?php
819 819
             }
@@ -893,8 +893,8 @@  discard block
 block discarded – undo
893 893
         $geodir_post_category_str = serialize($geodir_post_category_str);
894 894
     }
895 895
 
896
-    $all_var['post_category_array'] = html_entity_decode((string)$geodir_post_category_str, ENT_QUOTES, 'UTF-8');
897
-    $script = "var post_category_array = " . json_encode($all_var) . ';';
896
+    $all_var['post_category_array'] = html_entity_decode((string) $geodir_post_category_str, ENT_QUOTES, 'UTF-8');
897
+    $script = "var post_category_array = ".json_encode($all_var).';';
898 898
     echo '<script>';
899 899
     echo $script;
900 900
     echo '</script>';
@@ -996,9 +996,9 @@  discard block
 block discarded – undo
996 996
         }
997 997
     } elseif ((is_category() || is_tag()) && isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
998 998
         if (is_category()) {
999
-            $meta_desc .= __("Posts related to Category:", 'geodirectory') . " " . ucfirst(single_cat_title("", FALSE));
999
+            $meta_desc .= __("Posts related to Category:", 'geodirectory')." ".ucfirst(single_cat_title("", FALSE));
1000 1000
         } elseif (is_tag()) {
1001
-            $meta_desc .= __("Posts related to Tag:", 'geodirectory') . " " . ucfirst(single_tag_title("", FALSE));
1001
+            $meta_desc .= __("Posts related to Tag:", 'geodirectory')." ".ucfirst(single_tag_title("", FALSE));
1002 1002
         }
1003 1003
     } elseif (isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
1004 1004
         $meta_desc .= isset($current_term->description) ? $current_term->description : '';
@@ -1025,8 +1025,8 @@  discard block
 block discarded – undo
1025 1025
     $replace_location = __('Everywhere', 'geodirectory');
1026 1026
     $location_id = NULL;
1027 1027
     if ($geodir_location_manager) {
1028
-        $sql = $wpdb->prepare("SELECT location_id FROM " . POST_LOCATION_TABLE . " WHERE city_slug=%s ORDER BY location_id ASC LIMIT 1", array($gd_city));
1029
-        $location_id = (int)$wpdb->get_var($sql);
1028
+        $sql = $wpdb->prepare("SELECT location_id FROM ".POST_LOCATION_TABLE." WHERE city_slug=%s ORDER BY location_id ASC LIMIT 1", array($gd_city));
1029
+        $location_id = (int) $wpdb->get_var($sql);
1030 1030
         $location_type = geodir_what_is_current_location();
1031 1031
         if ($location_type == 'city') {
1032 1032
             $replace_location = geodir_get_current_location(array('what' => 'city', 'echo' => false));
@@ -1067,65 +1067,65 @@  discard block
 block discarded – undo
1067 1067
                     $category_id = $category->term_id;
1068 1068
                     $category_desc = trim($category->description) != '' ? trim($category->description) : get_tax_meta($category_id, 'ct_cat_top_desc', false, $geodir_post_type);
1069 1069
                     if ($location_id) {
1070
-                        $option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id;
1070
+                        $option_name = 'geodir_cat_loc_'.$geodir_post_type.'_'.$category_id;
1071 1071
                         $cat_loc_option = get_option($option_name);
1072 1072
 
1073 1073
                         $gd_cat_loc_default = !empty($cat_loc_option) && isset($cat_loc_option['gd_cat_loc_default']) && $cat_loc_option['gd_cat_loc_default'] > 0 ? true : false;
1074 1074
                         if (!$gd_cat_loc_default) {
1075
-                            $option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id . '_' . $location_id;
1075
+                            $option_name = 'geodir_cat_loc_'.$geodir_post_type.'_'.$category_id.'_'.$location_id;
1076 1076
                             $option = get_option($option_name);
1077 1077
                             $category_desc = isset($option['gd_cat_loc_desc']) && trim($option['gd_cat_loc_desc']) != '' ? trim($option['gd_cat_loc_desc']) : $category_desc;
1078 1078
                         }
1079 1079
                     }
1080
-                    $geodir_meta_desc = __("Posts related to Category:", 'geodirectory') . " " . ucfirst(single_cat_title("", FALSE)) . '. ' . $category_desc;
1080
+                    $geodir_meta_desc = __("Posts related to Category:", 'geodirectory')." ".ucfirst(single_cat_title("", FALSE)).'. '.$category_desc;
1081 1081
                 }
1082 1082
             } else if ($geodir_is_tag) {
1083
-                $geodir_meta_desc = __("Posts related to Tag:", 'geodirectory') . " " . ucfirst(single_tag_title("", FALSE)) . '. ' . $geodir_meta_desc;
1083
+                $geodir_meta_desc = __("Posts related to Tag:", 'geodirectory')." ".ucfirst(single_tag_title("", FALSE)).'. '.$geodir_meta_desc;
1084 1084
             }
1085 1085
         }
1086 1086
     }
1087 1087
 
1088 1088
 
1089 1089
     $gd_page = '';
1090
-    if(geodir_is_page('home')){
1090
+    if (geodir_is_page('home')) {
1091 1091
         $gd_page = 'home';
1092 1092
         $meta_desc = (get_option('geodir_meta_desc_homepage')) ? get_option('geodir_meta_desc_homepage') : $meta_desc;
1093 1093
     }
1094
-    elseif(geodir_is_page('detail')){
1094
+    elseif (geodir_is_page('detail')) {
1095 1095
         $gd_page = 'detail';
1096 1096
         $meta_desc = (get_option('geodir_meta_desc_detail')) ? get_option('geodir_meta_desc_detail') : $meta_desc;
1097 1097
     }
1098
-    elseif(geodir_is_page('pt')){
1098
+    elseif (geodir_is_page('pt')) {
1099 1099
         $gd_page = 'pt';
1100 1100
         $meta_desc = (get_option('geodir_meta_desc_pt')) ? get_option('geodir_meta_desc_pt') : $meta_desc;
1101 1101
     }
1102
-    elseif(geodir_is_page('listing')){
1102
+    elseif (geodir_is_page('listing')) {
1103 1103
         $gd_page = 'listing';
1104 1104
         $meta_desc = (get_option('geodir_meta_desc_listing')) ? get_option('geodir_meta_desc_listing') : $meta_desc;
1105 1105
     }
1106
-    elseif(geodir_is_page('location')){
1106
+    elseif (geodir_is_page('location')) {
1107 1107
         $gd_page = 'location';
1108 1108
         $meta_desc = (get_option('geodir_meta_desc_location')) ? get_option('geodir_meta_desc_location') : $meta_desc;
1109 1109
         $meta_desc = apply_filters('geodir_seo_meta_location_description', $meta_desc);
1110 1110
 
1111 1111
     }
1112
-    elseif(geodir_is_page('search')){
1112
+    elseif (geodir_is_page('search')) {
1113 1113
         $gd_page = 'search';
1114 1114
         $meta_desc = (get_option('geodir_meta_desc_search')) ? get_option('geodir_meta_desc_search') : $meta_desc;
1115 1115
     }
1116
-    elseif(geodir_is_page('add-listing')){
1116
+    elseif (geodir_is_page('add-listing')) {
1117 1117
         $gd_page = 'add-listing';
1118 1118
         $meta_desc = (get_option('geodir_meta_desc_add-listing')) ? get_option('geodir_meta_desc_add-listing') : $meta_desc;
1119 1119
     }
1120
-    elseif(geodir_is_page('author')){
1120
+    elseif (geodir_is_page('author')) {
1121 1121
         $gd_page = 'author';
1122 1122
         $meta_desc = (get_option('geodir_meta_desc_author')) ? get_option('geodir_meta_desc_author') : $meta_desc;
1123 1123
     }
1124
-    elseif(geodir_is_page('login')){
1124
+    elseif (geodir_is_page('login')) {
1125 1125
         $gd_page = 'login';
1126 1126
         $meta_desc = (get_option('geodir_meta_desc_login')) ? get_option('geodir_meta_desc_login') : $meta_desc;
1127 1127
     }
1128
-    elseif(geodir_is_page('listing-success')){
1128
+    elseif (geodir_is_page('listing-success')) {
1129 1129
         $gd_page = 'listing-success';
1130 1130
         $meta_desc = (get_option('geodir_meta_desc_listing-success')) ? get_option('geodir_meta_desc_listing-success') : $meta_desc;
1131 1131
     }
@@ -1153,7 +1153,7 @@  discard block
 block discarded – undo
1153 1153
          * @param string $title The page description including variables.
1154 1154
          * @param string $gd_page The GeoDirectory page type if any.
1155 1155
          */
1156
-        $meta_desc = apply_filters('geodir_seo_meta_description_pre', __($meta_desc, 'geodirectory'),$gd_page,'');
1156
+        $meta_desc = apply_filters('geodir_seo_meta_description_pre', __($meta_desc, 'geodirectory'), $gd_page, '');
1157 1157
 
1158 1158
         /**
1159 1159
          * Filter SEO meta description.
@@ -1161,20 +1161,20 @@  discard block
 block discarded – undo
1161 1161
          * @since 1.0.0
1162 1162
          * @param string $meta_desc Meta description content.
1163 1163
          */
1164
-        echo apply_filters('geodir_seo_meta_description', '<meta name="description" content="' . $meta_desc . '" />', $meta_desc);
1164
+        echo apply_filters('geodir_seo_meta_description', '<meta name="description" content="'.$meta_desc.'" />', $meta_desc);
1165 1165
     }
1166 1166
 
1167 1167
     // meta keywords
1168 1168
     if (isset($post->post_type) && in_array($post->post_type, $all_postypes)) {
1169
-        $place_tags = wp_get_post_terms($post->ID, $post->post_type . '_tags', array("fields" => "names"));
1170
-        $place_cats = wp_get_post_terms($post->ID, $post->post_type . 'category', array("fields" => "names"));
1169
+        $place_tags = wp_get_post_terms($post->ID, $post->post_type.'_tags', array("fields" => "names"));
1170
+        $place_cats = wp_get_post_terms($post->ID, $post->post_type.'category', array("fields" => "names"));
1171 1171
 
1172
-        $meta_key .= implode(", ", array_merge((array)$place_cats, (array)$place_tags));
1172
+        $meta_key .= implode(", ", array_merge((array) $place_cats, (array) $place_tags));
1173 1173
     } else {
1174 1174
         $posttags = get_the_tags();
1175 1175
         if ($posttags) {
1176 1176
             foreach ($posttags as $tag) {
1177
-                $meta_key .= $tag->name . ' ';
1177
+                $meta_key .= $tag->name.' ';
1178 1178
             }
1179 1179
         } else {
1180 1180
             $tags = get_tags(array('orderby' => 'count', 'order' => 'DESC'));
@@ -1182,7 +1182,7 @@  discard block
 block discarded – undo
1182 1182
 
1183 1183
             foreach ($tags as $tag) {
1184 1184
                 if ($xt <= 20) {
1185
-                    $meta_key .= $tag->name . ", ";
1185
+                    $meta_key .= $tag->name.", ";
1186 1186
                 }
1187 1187
 
1188 1188
                 $xt++;
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
     }
1192 1192
 
1193 1193
     $meta_key = $meta_key != '' ? rtrim(trim($meta_key), ",") : $meta_key;
1194
-    $geodir_meta_keys = $geodir_meta_keys != '' ? ($meta_key != '' ? $meta_key . ', ' . $geodir_meta_keys : $geodir_meta_keys) : $meta_key;
1194
+    $geodir_meta_keys = $geodir_meta_keys != '' ? ($meta_key != '' ? $meta_key.', '.$geodir_meta_keys : $geodir_meta_keys) : $meta_key;
1195 1195
     if ($geodir_meta_keys != '') {
1196 1196
         $geodir_meta_keys = strip_tags($geodir_meta_keys);
1197 1197
         $geodir_meta_keys = esc_html($geodir_meta_keys);
@@ -1210,7 +1210,7 @@  discard block
 block discarded – undo
1210 1210
          * @since 1.0.0
1211 1211
          * @param string $meta_desc Meta keywords.
1212 1212
          */
1213
-        echo apply_filters('geodir_seo_meta_keywords', '<meta name="keywords" content="' . $meta_key . '" />', $meta_key);
1213
+        echo apply_filters('geodir_seo_meta_keywords', '<meta name="keywords" content="'.$meta_key.'" />', $meta_key);
1214 1214
     }
1215 1215
 
1216 1216
 }
@@ -1355,8 +1355,8 @@  discard block
 block discarded – undo
1355 1355
 {
1356 1356
     global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields;
1357 1357
 
1358
-    $post_id = !empty($post) && isset($post->ID) ? (int)$post->ID : 0;
1359
-    $request_post_id = !empty($_REQUEST['p']) ? (int)$_REQUEST['p'] : 0;
1358
+    $post_id = !empty($post) && isset($post->ID) ? (int) $post->ID : 0;
1359
+    $request_post_id = !empty($_REQUEST['p']) ? (int) $_REQUEST['p'] : 0;
1360 1360
     $is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend
1361 1361
 
1362 1362
     if ($is_backend_preview && !$post_id > 0 && $request_post_id > 0) {
@@ -1390,7 +1390,7 @@  discard block
 block discarded – undo
1390 1390
         if (!empty($post_images)) {
1391 1391
             foreach ($post_images as $image) {
1392 1392
                 $caption = (!empty($image->caption)) ? $image->caption : '';
1393
-                $thumb_image .= '<a href="' . $image->src . '" title="'.$caption.'">';
1393
+                $thumb_image .= '<a href="'.$image->src.'" title="'.$caption.'">';
1394 1394
                 $thumb_image .= geodir_show_image($image, 'thumbnail', true, false);
1395 1395
                 $thumb_image .= '</a>';
1396 1396
             }
@@ -1401,7 +1401,7 @@  discard block
 block discarded – undo
1401 1401
         $map_args['width'] = '600';
1402 1402
         $map_args['height'] = '300';
1403 1403
         if ($post->post_mapzoom) {
1404
-            $map_args['zoom'] = '' . $post->post_mapzoom . '';
1404
+            $map_args['zoom'] = ''.$post->post_mapzoom.'';
1405 1405
         }
1406 1406
         $map_args['autozoom'] = false;
1407 1407
         $map_args['child_collapse'] = '0';
@@ -1427,7 +1427,7 @@  discard block
 block discarded – undo
1427 1427
         if (!empty($post_images)) {
1428 1428
             foreach ($post_images as $image) {
1429 1429
                 if ($image != '') {
1430
-                    $thumb_image .= '<a href="' . $image . '">';
1430
+                    $thumb_image .= '<a href="'.$image.'">';
1431 1431
                     $thumb_image .= geodir_show_image(array('src' => $image), 'thumbnail', true, false);
1432 1432
                     $thumb_image .= '</a>';
1433 1433
                 }
@@ -1469,13 +1469,13 @@  discard block
 block discarded – undo
1469 1469
         $map_args['map_class_name'] = 'geodir-map-preview-page';
1470 1470
     }
1471 1471
 
1472
-    $arr_detail_page_tabs = geodir_detail_page_tabs_list();// get this sooner so we can get the active tab for the user
1472
+    $arr_detail_page_tabs = geodir_detail_page_tabs_list(); // get this sooner so we can get the active tab for the user
1473 1473
 
1474 1474
     $active_tab = '';
1475 1475
     $active_tab_name = '';
1476 1476
     $default_tab = '';
1477 1477
     $default_tab_name = '';
1478
-    foreach($arr_detail_page_tabs as $tab_index => $tabs){
1478
+    foreach ($arr_detail_page_tabs as $tab_index => $tabs) {
1479 1479
         if (isset($tabs['is_active_tab']) && $tabs['is_active_tab'] && !empty($tabs['is_display']) && isset($tabs['heading_text']) && $tabs['heading_text']) {
1480 1480
             $active_tab = $tab_index;
1481 1481
             $active_tab_name = __($tabs['heading_text'], 'geodirectory');
@@ -1496,10 +1496,10 @@  discard block
 block discarded – undo
1496 1496
         $active_tab = $default_tab;
1497 1497
         $active_tab_name = $default_tab_name;
1498 1498
     }
1499
-    $tab_list = (get_option('geodir_disable_tabs',false)) ? true : false;
1499
+    $tab_list = (get_option('geodir_disable_tabs', false)) ? true : false;
1500 1500
     ?>
1501 1501
     <div class="geodir-tabs" id="gd-tabs" style="position:relative;">
1502
-        <?php if(!$tab_list){ ?>
1502
+        <?php if (!$tab_list) { ?>
1503 1503
         <div id="geodir-tab-mobile-menu">
1504 1504
             <i class="fa fa-bars"></i>
1505 1505
             <span class="geodir-mobile-active-tab"><?php echo $active_tab_name; ?></span>
@@ -1520,10 +1520,10 @@  discard block
 block discarded – undo
1520 1520
             foreach ($arr_detail_page_tabs as $tab_index => $detail_page_tab) {
1521 1521
                 if ($detail_page_tab['is_display']) {
1522 1522
 
1523
-                    if(!$tab_list) {
1523
+                    if (!$tab_list) {
1524 1524
                         ?>
1525 1525
                         <dt></dt> <!-- added to comply with validation -->
1526
-                        <dd <?php if ($detail_page_tab['is_active_tab']){ ?>class="geodir-tab-active"<?php } ?> ><a
1526
+                        <dd <?php if ($detail_page_tab['is_active_tab']) { ?>class="geodir-tab-active"<?php } ?> ><a
1527 1527
                                 data-tab="#<?php echo $tab_index; ?>"
1528 1528
                                 data-status="enable"><?php _e($detail_page_tab['heading_text'], 'geodirectory'); ?></a>
1529 1529
                         </dd>
@@ -1531,9 +1531,9 @@  discard block
 block discarded – undo
1531 1531
                     }
1532 1532
                     ob_start() // start tab content buffering
1533 1533
                     ?>
1534
-                    <li id="<?php echo $tab_index;?>Tab">
1535
-                        <?php if($tab_list){
1536
-                            $tab_title = '<span class="gd-tab-list-title" ><a href="#'.$tab_index.'">'.__($detail_page_tab['heading_text'],'geodirectory').'</a></span><hr />';
1534
+                    <li id="<?php echo $tab_index; ?>Tab">
1535
+                        <?php if ($tab_list) {
1536
+                            $tab_title = '<span class="gd-tab-list-title" ><a href="#'.$tab_index.'">'.__($detail_page_tab['heading_text'], 'geodirectory').'</a></span><hr />';
1537 1537
                             /**
1538 1538
                              * Filter the tab list title html.
1539 1539
                              *
@@ -1542,9 +1542,9 @@  discard block
 block discarded – undo
1542 1542
                              * @param string $tab_index The tab index type.
1543 1543
                              * @param array $detail_page_tab The array of values including title text.
1544 1544
                              */
1545
-                            echo apply_filters('geodir_tab_list_title',$tab_title ,$tab_index ,$detail_page_tab);
1545
+                            echo apply_filters('geodir_tab_list_title', $tab_title, $tab_index, $detail_page_tab);
1546 1546
                         }?>
1547
-                        <div id="<?php echo $tab_index;?>" class="hash-offset"></div>
1547
+                        <div id="<?php echo $tab_index; ?>" class="hash-offset"></div>
1548 1548
                         <?php
1549 1549
                         /**
1550 1550
                          * Called before the details tab content is output per tab.
@@ -1562,7 +1562,7 @@  discard block
 block discarded – undo
1562 1562
                          * @since 1.0.0
1563 1563
                          * @todo do we need this if we have the hook above? 'geodir_before_tab_content'
1564 1564
                          */
1565
-                        do_action('geodir_before_' . $tab_index . '_tab_content');
1565
+                        do_action('geodir_before_'.$tab_index.'_tab_content');
1566 1566
                         /// write a code to generate content of each tab
1567 1567
                         switch ($tab_index) {
1568 1568
                             case 'post_profile':
@@ -1594,7 +1594,7 @@  discard block
 block discarded – undo
1594 1594
                                 break;
1595 1595
                             case 'post_video':
1596 1596
                                 /** This action is documented in geodirectory_template_actions.php */
1597
-                                echo apply_filters('the_content', stripslashes($video));// we apply the_content filter so oembed works also;
1597
+                                echo apply_filters('the_content', stripslashes($video)); // we apply the_content filter so oembed works also;
1598 1598
                                 break;
1599 1599
                             case 'special_offers':
1600 1600
                                 echo wpautop(stripslashes($special_offers));
@@ -1632,7 +1632,7 @@  discard block
 block discarded – undo
1632 1632
                          * @since 1.0.0
1633 1633
                          * @todo do we need this if we have the hook above? 'geodir_after_tab_content'
1634 1634
                          */
1635
-                        do_action('geodir_after_' . $tab_index . '_tab_content');
1635
+                        do_action('geodir_after_'.$tab_index.'_tab_content');
1636 1636
                         ?> </li>
1637 1637
                     <?php
1638 1638
                     /**
@@ -1640,7 +1640,7 @@  discard block
 block discarded – undo
1640 1640
                      *
1641 1641
                      * @since 1.0.0
1642 1642
                      */
1643
-                    $arr_detail_page_tabs[$tab_index]['tab_content'] = apply_filters("geodir_modify_" . $detail_page_tab['tab_content'] . "_tab_content", ob_get_clean());
1643
+                    $arr_detail_page_tabs[$tab_index]['tab_content'] = apply_filters("geodir_modify_".$detail_page_tab['tab_content']."_tab_content", ob_get_clean());
1644 1644
                 } // end of if for is_display
1645 1645
             }// end of foreach
1646 1646
 
@@ -1652,8 +1652,8 @@  discard block
 block discarded – undo
1652 1652
              */
1653 1653
             do_action('geodir_after_tab_list');
1654 1654
             ?>
1655
-            <?php if(!$tab_list){?></dl><?php }?>
1656
-        <ul class="geodir-tabs-content entry-content <?php if($tab_list){?>geodir-tabs-list<?php }?>" style="position:relative;">
1655
+            <?php if (!$tab_list) {?></dl><?php }?>
1656
+        <ul class="geodir-tabs-content entry-content <?php if ($tab_list) {?>geodir-tabs-list<?php }?>" style="position:relative;">
1657 1657
             <?php
1658 1658
             foreach ($arr_detail_page_tabs as $detail_page_tab) {
1659 1659
                 if ($detail_page_tab['is_display'] && !empty($detail_page_tab['tab_content'])) {
@@ -1670,7 +1670,7 @@  discard block
 block discarded – undo
1670 1670
         </ul>
1671 1671
         <!--gd-tabs-content ul end-->
1672 1672
     </div>
1673
-    <?php if(!$tab_list){ ?>
1673
+    <?php if (!$tab_list) { ?>
1674 1674
     <script>
1675 1675
         if (window.location.hash && window.location.hash.indexOf('&') === -1 && jQuery(window.location.hash + 'Tab').length) {
1676 1676
             hashVal = window.location.hash;
@@ -1725,7 +1725,7 @@  discard block
 block discarded – undo
1725 1725
     if ($mime_type == 'image/jpeg' && function_exists('exif_read_data')) {
1726 1726
         try {
1727 1727
             $exif = exif_read_data($file_path);
1728
-        } catch(Exception $e) {
1728
+        } catch (Exception $e) {
1729 1729
             $exif = array();
1730 1730
         }
1731 1731
     }
@@ -1735,7 +1735,7 @@  discard block
 block discarded – undo
1735 1735
     $modify = false;
1736 1736
     $orientation = 0;
1737 1737
     if (!empty($exif) && isset($exif['Orientation'])) {
1738
-        switch ((int)$exif['Orientation']) {
1738
+        switch ((int) $exif['Orientation']) {
1739 1739
             case 1:
1740 1740
                 // do nothing
1741 1741
                 break;
@@ -1811,7 +1811,7 @@  discard block
 block discarded – undo
1811 1811
         }
1812 1812
         
1813 1813
         if ($quality !== null) {
1814
-            $image->set_quality((int)$quality);
1814
+            $image->set_quality((int) $quality);
1815 1815
         }
1816 1816
         
1817 1817
        $result = $image->save($file_path);
@@ -1883,7 +1883,7 @@  discard block
 block discarded – undo
1883 1883
 
1884 1884
         $comment_content = preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_content);
1885 1885
 
1886
-        $permalink = get_permalink($comment->ID) . "#comment-" . $comment->comment_ID;
1886
+        $permalink = get_permalink($comment->ID)."#comment-".$comment->comment_ID;
1887 1887
         $comment_author_email = $comment->comment_author_email;
1888 1888
         $comment_post_ID = $comment->post_id;
1889 1889
 
@@ -1898,12 +1898,12 @@  discard block
 block discarded – undo
1898 1898
 
1899 1899
         $post_title = get_the_title($comment_post_ID);
1900 1900
         $permalink = get_permalink($comment_post_ID);
1901
-        $comment_permalink = $permalink . "#comment-" . $comment->comment_ID;
1902
-        $read_more = '<a class="comment_excerpt" href="' . $comment_permalink . '">' . __('Read more', 'geodirectory') . '</a>';
1901
+        $comment_permalink = $permalink."#comment-".$comment->comment_ID;
1902
+        $read_more = '<a class="comment_excerpt" href="'.$comment_permalink.'">'.__('Read more', 'geodirectory').'</a>';
1903 1903
 
1904 1904
         $comment_content_length = strlen($comment_content);
1905 1905
         if ($comment_content_length > $comment_lenth) {
1906
-            $comment_excerpt = mb_substr($comment_content, 0, $comment_lenth) . '... ' . $read_more;
1906
+            $comment_excerpt = mb_substr($comment_content, 0, $comment_lenth).'... '.$read_more;
1907 1907
         } else {
1908 1908
             $comment_excerpt = $comment_content;
1909 1909
         }
@@ -1916,37 +1916,37 @@  discard block
 block discarded – undo
1916 1916
 
1917 1917
         if ($comment_id && $na) {
1918 1918
             $comments_echo .= '<li class="clearfix">';
1919
-            $comments_echo .= "<span class=\"li" . $comment_id . " geodir_reviewer_image\">";
1919
+            $comments_echo .= "<span class=\"li".$comment_id." geodir_reviewer_image\">";
1920 1920
             if (function_exists('get_avatar')) {
1921 1921
                 if (!isset($comment->comment_type)) {
1922 1922
                     if ($user_profile_url) {
1923
-                        $comments_echo .= '<a href="' . $user_profile_url . '">';
1923
+                        $comments_echo .= '<a href="'.$user_profile_url.'">';
1924 1924
                     }
1925
-                    $comments_echo .= get_avatar($comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1925
+                    $comments_echo .= get_avatar($comment->comment_author_email, $g_size, geodir_plugin_url().'/geodirectory-assets/images/gravatar2.png');
1926 1926
                     if ($user_profile_url) {
1927 1927
                         $comments_echo .= '</a>';
1928 1928
                     }
1929 1929
                 } elseif ((isset($comment->comment_type) && $comment->comment_type == 'trackback') || (isset($comment->comment_type) && $comment->comment_type == 'pingback')) {
1930 1930
                     if ($user_profile_url) {
1931
-                        $comments_echo .= '<a href="' . $user_profile_url . '">';
1931
+                        $comments_echo .= '<a href="'.$user_profile_url.'">';
1932 1932
                     }
1933
-                    $comments_echo .= get_avatar($comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1933
+                    $comments_echo .= get_avatar($comment->comment_author_url, $g_size, geodir_plugin_url().'/geodirectory-assets/images/gravatar2.png');
1934 1934
                 }
1935 1935
             } elseif (function_exists('gravatar')) {
1936 1936
                 if ($user_profile_url) {
1937
-                    $comments_echo .= '<a href="' . $user_profile_url . '">';
1937
+                    $comments_echo .= '<a href="'.$user_profile_url.'">';
1938 1938
                 }
1939 1939
                 $comments_echo .= "<img src=\"";
1940 1940
                 if ('' == $comment->comment_type) {
1941
-                    $comments_echo .= gravatar($comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1941
+                    $comments_echo .= gravatar($comment->comment_author_email, $g_size, geodir_plugin_url().'/geodirectory-assets/images/gravatar2.png');
1942 1942
                     if ($user_profile_url) {
1943 1943
                         $comments_echo .= '</a>';
1944 1944
                     }
1945 1945
                 } elseif (('trackback' == $comment->comment_type) || ('pingback' == $comment->comment_type)) {
1946 1946
                     if ($user_profile_url) {
1947
-                        $comments_echo .= '<a href="' . $user_profile_url . '">';
1947
+                        $comments_echo .= '<a href="'.$user_profile_url.'">';
1948 1948
                     }
1949
-                    $comments_echo .= gravatar($comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1949
+                    $comments_echo .= gravatar($comment->comment_author_url, $g_size, geodir_plugin_url().'/geodirectory-assets/images/gravatar2.png');
1950 1950
                     if ($user_profile_url) {
1951 1951
                         $comments_echo .= '</a>';
1952 1952
                     }
@@ -1957,13 +1957,13 @@  discard block
 block discarded – undo
1957 1957
             $comments_echo .= "</span>\n";
1958 1958
 
1959 1959
             $comments_echo .= '<span class="geodir_reviewer_content">';
1960
-            if($comment->user_id){$comments_echo .= '<a href="'.get_author_posts_url( $comment->user_id ).'">';}
1961
-            $comments_echo .= '<span class="geodir_reviewer_author">' . $comment->comment_author . '</span> ';
1962
-            if($comment->user_id){$comments_echo .= '</a>';}
1963
-            $comments_echo .= '<span class="geodir_reviewer_reviewed">' . __('reviewed', 'geodirectory') . '</span> ';
1964
-            $comments_echo .= '<a href="' . $permalink . '" class="geodir_reviewer_title">' . $post_title . '</a>';
1960
+            if ($comment->user_id) {$comments_echo .= '<a href="'.get_author_posts_url($comment->user_id).'">'; }
1961
+            $comments_echo .= '<span class="geodir_reviewer_author">'.$comment->comment_author.'</span> ';
1962
+            if ($comment->user_id) {$comments_echo .= '</a>'; }
1963
+            $comments_echo .= '<span class="geodir_reviewer_reviewed">'.__('reviewed', 'geodirectory').'</span> ';
1964
+            $comments_echo .= '<a href="'.$permalink.'" class="geodir_reviewer_title">'.$post_title.'</a>';
1965 1965
             $comments_echo .= geodir_get_rating_stars($comment->overall_rating, $comment_post_ID);
1966
-            $comments_echo .= '<p class="geodir_reviewer_text">' . $comment_excerpt . '';
1966
+            $comments_echo .= '<p class="geodir_reviewer_text">'.$comment_excerpt.'';
1967 1967
             //echo preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_excerpt);
1968 1968
             $comments_echo .= '</p>';
1969 1969
 
@@ -1990,19 +1990,19 @@  discard block
 block discarded – undo
1990 1990
     if (!empty($post_types)) {
1991 1991
         foreach ($post_types as $key => $post_type) {
1992 1992
             $cpt_name = __($post_type->labels->singular_name, 'geodirectory');
1993
-            $post_type_name =   sprintf(__('%s Categories', 'geodirectory'),$cpt_name);
1993
+            $post_type_name = sprintf(__('%s Categories', 'geodirectory'), $cpt_name);
1994 1994
             $taxonomies = geodir_get_taxonomies($key);
1995 1995
             $cat_taxonomy = !empty($taxonomies[0]) ? $taxonomies[0] : NULL;
1996 1996
             $cat_terms = $cat_taxonomy ? get_terms($cat_taxonomy) : NULL;
1997 1997
 
1998 1998
             if (!empty($cat_terms)) {
1999
-                $return['optgroup_start-' . $key] = $post_type_name;
1999
+                $return['optgroup_start-'.$key] = $post_type_name;
2000 2000
 
2001 2001
                 foreach ($cat_terms as $cat_term) {
2002
-                    $return[$key . '_' . $cat_term->term_id] = $cat_term->name;
2002
+                    $return[$key.'_'.$cat_term->term_id] = $cat_term->name;
2003 2003
                 }
2004 2004
 
2005
-                $return['optgroup_end-' . $key] = $post_type_name;
2005
+                $return['optgroup_end-'.$key] = $post_type_name;
2006 2006
             }
2007 2007
         }
2008 2008
     }
@@ -2094,10 +2094,10 @@  discard block
 block discarded – undo
2094 2094
             stWidget.addEntry({
2095 2095
                 "service": "sharethis",
2096 2096
                 "element": document.getElementById('st_sharethis'),
2097
-                "url": "<?php echo geodir_curPageURL();?>",
2098
-                "title": "<?php echo $post->post_title;?>",
2097
+                "url": "<?php echo geodir_curPageURL(); ?>",
2098
+                "title": "<?php echo $post->post_title; ?>",
2099 2099
                 "type": "chicklet",
2100
-                "text": "<?php _e( 'Share', 'geodirectory' );?>"
2100
+                "text": "<?php _e('Share', 'geodirectory'); ?>"
2101 2101
             });
2102 2102
         </script>
2103 2103
     </div>
@@ -2105,7 +2105,7 @@  discard block
 block discarded – undo
2105 2105
 }
2106 2106
 
2107 2107
 function geodir_listing_bounce_map_pin_on_hover() {
2108
-    if(get_option('geodir_listing_hover_bounce_map_pin',true)) {
2108
+    if (get_option('geodir_listing_hover_bounce_map_pin', true)) {
2109 2109
         ?>
2110 2110
         <script>
2111 2111
             jQuery(function ($) {
@@ -2122,15 +2122,15 @@  discard block
 block discarded – undo
2122 2122
         <?php
2123 2123
     }
2124 2124
 }
2125
-add_action('geodir_after_listing_listview','geodir_listing_bounce_map_pin_on_hover',10);
2125
+add_action('geodir_after_listing_listview', 'geodir_listing_bounce_map_pin_on_hover', 10);
2126 2126
 
2127
-add_action('geodir_after_favorite_html','geodir_output_favourite_html_listings',1,1);
2128
-function geodir_output_favourite_html_listings( $post_id){
2127
+add_action('geodir_after_favorite_html', 'geodir_output_favourite_html_listings', 1, 1);
2128
+function geodir_output_favourite_html_listings($post_id) {
2129 2129
     geodir_favourite_html('', $post_id);
2130 2130
 }
2131 2131
 
2132
-add_action( 'geodir_listing_after_pinpoint', 'geodir_output_pinpoint_html_listings', 1, 2);
2133
-function geodir_output_pinpoint_html_listings( $post_id, $post){
2132
+add_action('geodir_listing_after_pinpoint', 'geodir_output_pinpoint_html_listings', 1, 2);
2133
+function geodir_output_pinpoint_html_listings($post_id, $post) {
2134 2134
     global $wp_query;
2135 2135
 
2136 2136
     $show_pin_point = $wp_query->is_main_query();
Please login to merge, or discard this patch.
Indentation   +1384 added lines, -1384 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,69 +697,69 @@  discard block
 block discarded – undo
697 697
  * @return string Returns related posts html.
698 698
  */
699 699
 function geodir_related_posts_display($request) {
700
-    if (!empty($request)) {
701
-        $before_title = (isset($request['before_title']) && !empty($request['before_title'])) ? $request['before_title'] : '';
702
-        $after_title = (isset($request['after_title']) && !empty($request['after_title'])) ? $request['after_title'] : '';
703
-
704
-        $title = (isset($request['title']) && !empty($request['title'])) ? $request['title'] : __('Related Listings', 'geodirectory');
705
-        $post_number = (isset($request['post_number']) && !empty($request['post_number'])) ? $request['post_number'] : '5';
706
-        $relate_to = (isset($request['relate_to']) && !empty($request['relate_to'])) ? $request['relate_to'] : 'category';
707
-        $layout = (isset($request['layout']) && !empty($request['layout'])) ? $request['layout'] : 'gridview_onehalf';
708
-        $add_location_filter = (isset($request['add_location_filter']) && !empty($request['add_location_filter'])) ? $request['add_location_filter'] : '0';
709
-        $listing_width = (isset($request['listing_width']) && !empty($request['listing_width'])) ? $request['listing_width'] : '';
710
-        $list_sort = (isset($request['list_sort']) && !empty($request['list_sort'])) ? $request['list_sort'] : 'latest';
711
-        $character_count = (isset($request['character_count']) && !empty($request['character_count'])) ? $request['character_count'] : '';
712
-
713
-        global $wpdb, $post, $gd_session;
714
-        $origi_post = $post;
715
-        $post_type = '';
716
-        $post_id = '';
717
-        $category_taxonomy = '';
718
-        $tax_field = 'id';
719
-        $category = array();
720
-
721
-        if (isset($_REQUEST['backandedit'])) {
722
-            $post = (object)$gd_session->get('listing');
723
-            $post_type = $post->listing_type;
724
-            if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
725
-                $post_id = $_REQUEST['pid'];
726
-        } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
727
-            $post = geodir_get_post_info($_REQUEST['pid']);
728
-            $post_type = $post->post_type;
729
-            $post_id = $_REQUEST['pid'];
730
-        } elseif (isset($post->post_type) && $post->post_type != '') {
731
-            $post_type = $post->post_type;
732
-            $post_id = $post->ID;
733
-        }
700
+	if (!empty($request)) {
701
+		$before_title = (isset($request['before_title']) && !empty($request['before_title'])) ? $request['before_title'] : '';
702
+		$after_title = (isset($request['after_title']) && !empty($request['after_title'])) ? $request['after_title'] : '';
703
+
704
+		$title = (isset($request['title']) && !empty($request['title'])) ? $request['title'] : __('Related Listings', 'geodirectory');
705
+		$post_number = (isset($request['post_number']) && !empty($request['post_number'])) ? $request['post_number'] : '5';
706
+		$relate_to = (isset($request['relate_to']) && !empty($request['relate_to'])) ? $request['relate_to'] : 'category';
707
+		$layout = (isset($request['layout']) && !empty($request['layout'])) ? $request['layout'] : 'gridview_onehalf';
708
+		$add_location_filter = (isset($request['add_location_filter']) && !empty($request['add_location_filter'])) ? $request['add_location_filter'] : '0';
709
+		$listing_width = (isset($request['listing_width']) && !empty($request['listing_width'])) ? $request['listing_width'] : '';
710
+		$list_sort = (isset($request['list_sort']) && !empty($request['list_sort'])) ? $request['list_sort'] : 'latest';
711
+		$character_count = (isset($request['character_count']) && !empty($request['character_count'])) ? $request['character_count'] : '';
712
+
713
+		global $wpdb, $post, $gd_session;
714
+		$origi_post = $post;
715
+		$post_type = '';
716
+		$post_id = '';
717
+		$category_taxonomy = '';
718
+		$tax_field = 'id';
719
+		$category = array();
720
+
721
+		if (isset($_REQUEST['backandedit'])) {
722
+			$post = (object)$gd_session->get('listing');
723
+			$post_type = $post->listing_type;
724
+			if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
725
+				$post_id = $_REQUEST['pid'];
726
+		} elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
727
+			$post = geodir_get_post_info($_REQUEST['pid']);
728
+			$post_type = $post->post_type;
729
+			$post_id = $_REQUEST['pid'];
730
+		} elseif (isset($post->post_type) && $post->post_type != '') {
731
+			$post_type = $post->post_type;
732
+			$post_id = $post->ID;
733
+		}
734 734
 
735
-        if ($relate_to == 'category') {
735
+		if ($relate_to == 'category') {
736 736
 
737
-            $category_taxonomy = $post_type . $relate_to;
738
-            if (isset($post->{$category_taxonomy}) && $post->{$category_taxonomy} != '')
739
-                $category = explode(',', trim($post->{$category_taxonomy}, ','));
737
+			$category_taxonomy = $post_type . $relate_to;
738
+			if (isset($post->{$category_taxonomy}) && $post->{$category_taxonomy} != '')
739
+				$category = explode(',', trim($post->{$category_taxonomy}, ','));
740 740
 
741
-        } elseif ($relate_to == 'tags') {
741
+		} elseif ($relate_to == 'tags') {
742 742
 
743
-            $category_taxonomy = $post_type . '_' . $relate_to;
744
-            if ($post->post_tags != '')
745
-                $category = explode(',', trim($post->post_tags, ','));
746
-            $tax_field = 'name';
747
-        }
743
+			$category_taxonomy = $post_type . '_' . $relate_to;
744
+			if ($post->post_tags != '')
745
+				$category = explode(',', trim($post->post_tags, ','));
746
+			$tax_field = 'name';
747
+		}
748 748
 
749
-        /* --- return false in invalid request --- */
750
-        if (empty($category))
751
-            return false;
749
+		/* --- return false in invalid request --- */
750
+		if (empty($category))
751
+			return false;
752 752
 
753
-        $all_postypes = geodir_get_posttypes();
753
+		$all_postypes = geodir_get_posttypes();
754 754
 
755
-        if (!in_array($post_type, $all_postypes))
756
-            return false;
755
+		if (!in_array($post_type, $all_postypes))
756
+			return false;
757 757
 
758
-        /* --- return false in invalid request --- */
758
+		/* --- return false in invalid request --- */
759 759
 
760
-       $location_url = '';
761
-        if ($add_location_filter != '0') {
762
-            $location_url = array();
760
+	   $location_url = '';
761
+		if ($add_location_filter != '0') {
762
+			$location_url = array();
763 763
 			$geodir_show_location_url = get_option('geodir_show_location_url');
764 764
 			
765 765
 			$gd_city = get_query_var('gd_city');
@@ -767,13 +767,13 @@  discard block
 block discarded – undo
767 767
 			if ($gd_city) {
768 768
 				$gd_country = get_query_var('gd_country');
769 769
 				$gd_region = get_query_var('gd_region');
770
-            } else {
771
-                $location = geodir_get_default_location();
770
+			} else {
771
+				$location = geodir_get_default_location();
772 772
 				
773 773
 				$gd_country = isset($location->country_slug) ? $location->country_slug : '';
774 774
 				$gd_region = isset($location->region_slug) ? $location->region_slug : '';
775 775
 				$gd_city = isset($location->city_slug) ? $location->city_slug : '';
776
-            }
776
+			}
777 777
 			
778 778
 			if ($geodir_show_location_url == 'all') {
779 779
 				$location_url[] = $gd_country;
@@ -786,92 +786,92 @@  discard block
 block discarded – undo
786 786
 			
787 787
 			$location_url[] = $gd_city;
788 788
 
789
-            $location_url = implode('/', $location_url);
790
-        }
789
+			$location_url = implode('/', $location_url);
790
+		}
791 791
 
792 792
 
793
-        if (!empty($category)) {
794
-            global $geodir_add_location_url;
795
-            $geodir_add_location_url = '0';
796
-            if ($add_location_filter != '0') {
797
-                $geodir_add_location_url = '1';
798
-            }
799
-            $viewall_url = get_term_link((int)$category[0], $post_type . $category_taxonomy);
800
-            $geodir_add_location_url = NULL;
801
-        }
802
-        ob_start();
803
-        ?>
793
+		if (!empty($category)) {
794
+			global $geodir_add_location_url;
795
+			$geodir_add_location_url = '0';
796
+			if ($add_location_filter != '0') {
797
+				$geodir_add_location_url = '1';
798
+			}
799
+			$viewall_url = get_term_link((int)$category[0], $post_type . $category_taxonomy);
800
+			$geodir_add_location_url = NULL;
801
+		}
802
+		ob_start();
803
+		?>
804 804
 
805 805
 
806 806
         <div class="geodir_locations geodir_location_listing">
807 807
 
808 808
             <?php
809
-            if (isset($request['is_widget']) && $request['is_widget'] == '1') {
810
-                /** geodir_before_title filter Documented in geodirectory_widgets.php */
811
-                $before_title = isset($before_title) ? $before_title : apply_filters('geodir_before_title', '<h3 class="widget-title">');
812
-                /** geodir_after_title filter Documented in geodirectory_widgets.php */
813
-                $after_title = isset($after_title) ? $after_title : apply_filters('geodir_after_title', '</h3>');
814
-                ?>
809
+			if (isset($request['is_widget']) && $request['is_widget'] == '1') {
810
+				/** geodir_before_title filter Documented in geodirectory_widgets.php */
811
+				$before_title = isset($before_title) ? $before_title : apply_filters('geodir_before_title', '<h3 class="widget-title">');
812
+				/** geodir_after_title filter Documented in geodirectory_widgets.php */
813
+				$after_title = isset($after_title) ? $after_title : apply_filters('geodir_after_title', '</h3>');
814
+				?>
815 815
                 <div class="location_list_heading clearfix">
816 816
                     <?php echo $before_title . $title . $after_title; ?>
817 817
                 </div>
818 818
             <?php
819
-            }
820
-            $query_args = array(
821
-                'posts_per_page' => $post_number,
822
-                'is_geodir_loop' => true,
823
-                'gd_location' => ($add_location_filter) ? true : false,
824
-                'post_type' => $post_type,
825
-                'order_by' => $list_sort,
826
-                'post__not_in' => array($post_id),
827
-                'excerpt_length' => $character_count,
828
-            );
819
+			}
820
+			$query_args = array(
821
+				'posts_per_page' => $post_number,
822
+				'is_geodir_loop' => true,
823
+				'gd_location' => ($add_location_filter) ? true : false,
824
+				'post_type' => $post_type,
825
+				'order_by' => $list_sort,
826
+				'post__not_in' => array($post_id),
827
+				'excerpt_length' => $character_count,
828
+			);
829 829
 
830
-            $tax_query = array('taxonomy' => $category_taxonomy,
831
-                'field' => $tax_field,
832
-                'terms' => $category
833
-            );
830
+			$tax_query = array('taxonomy' => $category_taxonomy,
831
+				'field' => $tax_field,
832
+				'terms' => $category
833
+			);
834 834
 
835
-            $query_args['tax_query'] = array($tax_query);
835
+			$query_args['tax_query'] = array($tax_query);
836 836
 
837 837
 
838
-            global $gridview_columns, $post;
838
+			global $gridview_columns, $post;
839 839
 
840 840
 
841
-            query_posts($query_args);
841
+			query_posts($query_args);
842 842
 
843
-            if (strstr($layout, 'gridview')) {
844
-                $listing_view_exp = explode('_', $layout);
845
-                $gridview_columns = $layout;
846
-                $layout = $listing_view_exp[0];
847
-            } else if ($layout == 'list') {
848
-                $gridview_columns = '';
849
-            }
850
-            $related_posts = true;
851
-
852
-            /**
853
-             * Filters related listing listview template.
854
-             *
855
-             * @since 1.0.0
856
-             */
857
-            $template = apply_filters("geodir_template_part-related-listing-listview", geodir_locate_template('listing-listview'));
858
-
859
-            /**
860
-             * Includes related listing listview template.
861
-             *
862
-             * @since 1.0.0
863
-             */
864
-            include($template);
865
-
866
-            wp_reset_query();
867
-            $post = $origi_post;
868
-            ?>
843
+			if (strstr($layout, 'gridview')) {
844
+				$listing_view_exp = explode('_', $layout);
845
+				$gridview_columns = $layout;
846
+				$layout = $listing_view_exp[0];
847
+			} else if ($layout == 'list') {
848
+				$gridview_columns = '';
849
+			}
850
+			$related_posts = true;
851
+
852
+			/**
853
+			 * Filters related listing listview template.
854
+			 *
855
+			 * @since 1.0.0
856
+			 */
857
+			$template = apply_filters("geodir_template_part-related-listing-listview", geodir_locate_template('listing-listview'));
858
+
859
+			/**
860
+			 * Includes related listing listview template.
861
+			 *
862
+			 * @since 1.0.0
863
+			 */
864
+			include($template);
865
+
866
+			wp_reset_query();
867
+			$post = $origi_post;
868
+			?>
869 869
 
870 870
         </div>
871 871
         <?php
872
-        return $html = ob_get_clean();
872
+		return $html = ob_get_clean();
873 873
 
874
-    }
874
+	}
875 875
 
876 876
 }
877 877
 
@@ -887,17 +887,17 @@  discard block
 block discarded – undo
887 887
  */
888 888
 function geodir_category_count_script()
889 889
 {
890
-    global $geodir_post_category_str;
890
+	global $geodir_post_category_str;
891 891
 
892
-    if (!empty($geodir_post_category_str)) {
893
-        $geodir_post_category_str = serialize($geodir_post_category_str);
894
-    }
892
+	if (!empty($geodir_post_category_str)) {
893
+		$geodir_post_category_str = serialize($geodir_post_category_str);
894
+	}
895 895
 
896
-    $all_var['post_category_array'] = html_entity_decode((string)$geodir_post_category_str, ENT_QUOTES, 'UTF-8');
897
-    $script = "var post_category_array = " . json_encode($all_var) . ';';
898
-    echo '<script>';
899
-    echo $script;
900
-    echo '</script>';
896
+	$all_var['post_category_array'] = html_entity_decode((string)$geodir_post_category_str, ENT_QUOTES, 'UTF-8');
897
+	$script = "var post_category_array = " . json_encode($all_var) . ';';
898
+	echo '<script>';
899
+	echo $script;
900
+	echo '</script>';
901 901
 
902 902
 }
903 903
 
@@ -910,16 +910,16 @@  discard block
 block discarded – undo
910 910
  */
911 911
 function geodir_get_map_default_language()
912 912
 {
913
-    $geodir_default_map_language = get_option('geodir_default_map_language');
914
-    if (empty($geodir_default_map_language))
915
-        $geodir_default_map_language = 'en';
916
-    /**
917
-     * Filter default map language.
918
-     *
919
-     * @since 1.0.0
920
-     * @param string $geodir_default_map_language Default map language.
921
-     */
922
-    return apply_filters('geodir_default_map_language', $geodir_default_map_language);
913
+	$geodir_default_map_language = get_option('geodir_default_map_language');
914
+	if (empty($geodir_default_map_language))
915
+		$geodir_default_map_language = 'en';
916
+	/**
917
+	 * Filter default map language.
918
+	 *
919
+	 * @since 1.0.0
920
+	 * @param string $geodir_default_map_language Default map language.
921
+	 */
922
+	return apply_filters('geodir_default_map_language', $geodir_default_map_language);
923 923
 }
924 924
 
925 925
 
@@ -936,12 +936,12 @@  discard block
 block discarded – undo
936 936
  */
937 937
 function geodir_add_meta_keywords()
938 938
 {
939
-    global $wp, $post, $wp_query, $wpdb, $geodir_addon_list;
939
+	global $wp, $post, $wp_query, $wpdb, $geodir_addon_list;
940 940
 
941
-    $is_geodir_page = geodir_is_geodir_page();
942
-    if (!$is_geodir_page) {
943
-        return;
944
-    }// if non GD page, bail
941
+	$is_geodir_page = geodir_is_geodir_page();
942
+	if (!$is_geodir_page) {
943
+		return;
944
+	}// if non GD page, bail
945 945
 
946 946
 	$use_gd_meta = true;
947 947
 	if (class_exists('WPSEO_Frontend') || class_exists('All_in_One_SEO_Pack')) {
@@ -956,182 +956,182 @@  discard block
 block discarded – undo
956 956
 		return;
957 957
 	}// bail if Yoast Wordpress SEO or All_in_One_SEO_Pack active.
958 958
 
959
-    $current_term = $wp_query->get_queried_object();
959
+	$current_term = $wp_query->get_queried_object();
960 960
 
961
-    $all_postypes = geodir_get_posttypes();
961
+	$all_postypes = geodir_get_posttypes();
962 962
 
963
-    $geodir_taxonomies = geodir_get_taxonomies('', true);
963
+	$geodir_taxonomies = geodir_get_taxonomies('', true);
964 964
 
965
-    $meta_desc = '';
966
-    $meta_key = '';
967
-    if (isset($current_term->ID) && $current_term->ID == geodir_location_page_id()) {
968
-        /**
969
-         * Filter SEO meta location description.
970
-         *
971
-         * @since 1.0.0
972
-         */
973
-        $meta_desc = apply_filters('geodir_seo_meta_location_description', '');
974
-        $meta_desc .= '';
975
-    }
976
-    if (have_posts() && is_single() OR is_page()) {
977
-        while (have_posts()) {
978
-            the_post();
979
-
980
-            if (has_excerpt()) {
981
-                $out_excerpt = strip_tags(strip_shortcodes(get_the_excerpt()));
982
-                if (empty($out_excerpt)) {
983
-                    $out_excerpt = strip_tags(do_shortcode(get_the_excerpt()));
984
-                }
985
-                $out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $out_excerpt);
986
-            } else {
987
-                $out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $post->post_content);
988
-                $out_excerpt = strip_tags(strip_shortcodes($out_excerpt));
989
-                if (empty($out_excerpt)) {
990
-                    $out_excerpt = strip_tags(do_shortcode($out_excerpt)); // parse short code from content
991
-                }
992
-                $out_excerpt = trim(wp_trim_words($out_excerpt, 35, ''), '.!?,;:-');
993
-            }
965
+	$meta_desc = '';
966
+	$meta_key = '';
967
+	if (isset($current_term->ID) && $current_term->ID == geodir_location_page_id()) {
968
+		/**
969
+		 * Filter SEO meta location description.
970
+		 *
971
+		 * @since 1.0.0
972
+		 */
973
+		$meta_desc = apply_filters('geodir_seo_meta_location_description', '');
974
+		$meta_desc .= '';
975
+	}
976
+	if (have_posts() && is_single() OR is_page()) {
977
+		while (have_posts()) {
978
+			the_post();
979
+
980
+			if (has_excerpt()) {
981
+				$out_excerpt = strip_tags(strip_shortcodes(get_the_excerpt()));
982
+				if (empty($out_excerpt)) {
983
+					$out_excerpt = strip_tags(do_shortcode(get_the_excerpt()));
984
+				}
985
+				$out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $out_excerpt);
986
+			} else {
987
+				$out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $post->post_content);
988
+				$out_excerpt = strip_tags(strip_shortcodes($out_excerpt));
989
+				if (empty($out_excerpt)) {
990
+					$out_excerpt = strip_tags(do_shortcode($out_excerpt)); // parse short code from content
991
+				}
992
+				$out_excerpt = trim(wp_trim_words($out_excerpt, 35, ''), '.!?,;:-');
993
+			}
994 994
 
995
-            $meta_desc .= $out_excerpt;
996
-        }
997
-    } elseif ((is_category() || is_tag()) && isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
998
-        if (is_category()) {
999
-            $meta_desc .= __("Posts related to Category:", 'geodirectory') . " " . ucfirst(single_cat_title("", FALSE));
1000
-        } elseif (is_tag()) {
1001
-            $meta_desc .= __("Posts related to Tag:", 'geodirectory') . " " . ucfirst(single_tag_title("", FALSE));
1002
-        }
1003
-    } elseif (isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
1004
-        $meta_desc .= isset($current_term->description) ? $current_term->description : '';
1005
-    }
995
+			$meta_desc .= $out_excerpt;
996
+		}
997
+	} elseif ((is_category() || is_tag()) && isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
998
+		if (is_category()) {
999
+			$meta_desc .= __("Posts related to Category:", 'geodirectory') . " " . ucfirst(single_cat_title("", FALSE));
1000
+		} elseif (is_tag()) {
1001
+			$meta_desc .= __("Posts related to Tag:", 'geodirectory') . " " . ucfirst(single_tag_title("", FALSE));
1002
+		}
1003
+	} elseif (isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
1004
+		$meta_desc .= isset($current_term->description) ? $current_term->description : '';
1005
+	}
1006 1006
 
1007 1007
 
1008
-    $geodir_post_type = geodir_get_current_posttype();
1009
-    $geodir_post_type_info = get_post_type_object($geodir_post_type);
1010
-    $geodir_is_page_listing = geodir_is_page('listing') ? true : false;
1011
-
1012
-    $category_taxonomy = geodir_get_taxonomies($geodir_post_type);
1013
-    $tag_taxonomy = geodir_get_taxonomies($geodir_post_type, true);
1014
-
1015
-    $geodir_is_category = isset($category_taxonomy[0]) && get_query_var($category_taxonomy[0]) ? get_query_var($category_taxonomy[0]) : false;
1016
-    $geodir_is_tag = isset($tag_taxonomy[0]) && get_query_var($tag_taxonomy[0]) ? true : false;
1017
-
1018
-    $geodir_is_search = geodir_is_page('search') ? true : false;
1019
-    $geodir_is_location = geodir_is_page('location') ? true : false;
1020
-    $geodir_location_manager = isset($geodir_addon_list['geodir_location_manager']) && $geodir_addon_list['geodir_location_manager'] = 'yes' ? true : false;
1021
-    $godir_location_terms = geodir_get_current_location_terms('query_vars');
1022
-    $gd_city = $geodir_location_manager && isset($godir_location_terms['gd_city']) ? $godir_location_terms['gd_city'] : NULL;
1023
-    $gd_region = $geodir_location_manager && isset($godir_location_terms['gd_region']) ? $godir_location_terms['gd_region'] : NULL;
1024
-    $gd_country = $geodir_location_manager && isset($godir_location_terms['gd_country']) ? $godir_location_terms['gd_country'] : NULL;
1025
-    $replace_location = __('Everywhere', 'geodirectory');
1026
-    $location_id = NULL;
1027
-    if ($geodir_location_manager) {
1028
-        $sql = $wpdb->prepare("SELECT location_id FROM " . POST_LOCATION_TABLE . " WHERE city_slug=%s ORDER BY location_id ASC LIMIT 1", array($gd_city));
1029
-        $location_id = (int)$wpdb->get_var($sql);
1030
-        $location_type = geodir_what_is_current_location();
1031
-        if ($location_type == 'city') {
1032
-            $replace_location = geodir_get_current_location(array('what' => 'city', 'echo' => false));
1033
-        } elseif ($location_type == 'region') {
1034
-            $replace_location = geodir_get_current_location(array('what' => 'region', 'echo' => false));
1035
-        } elseif ($location_type == 'country') {
1036
-            $replace_location = geodir_get_current_location(array('what' => 'country', 'echo' => false));
1037
-            $replace_location = __($replace_location, 'geodirectory');
1038
-        }
1039
-        $country = get_query_var('gd_country');
1040
-        $region = get_query_var('gd_region');
1041
-        $city = get_query_var('gd_city');
1042
-        $current_location = '';
1043
-        if ($country != '') {
1044
-            $current_location = get_actual_location_name('country', $country, true);
1045
-        }
1046
-        if ($region != '') {
1047
-            $current_location = get_actual_location_name('region', $region);
1048
-        }
1049
-        if ($city != '') {
1050
-            $current_location = get_actual_location_name('city', $city);
1051
-        }
1052
-        $replace_location = $current_location != '' ? $current_location : $replace_location;
1053
-    }
1008
+	$geodir_post_type = geodir_get_current_posttype();
1009
+	$geodir_post_type_info = get_post_type_object($geodir_post_type);
1010
+	$geodir_is_page_listing = geodir_is_page('listing') ? true : false;
1011
+
1012
+	$category_taxonomy = geodir_get_taxonomies($geodir_post_type);
1013
+	$tag_taxonomy = geodir_get_taxonomies($geodir_post_type, true);
1014
+
1015
+	$geodir_is_category = isset($category_taxonomy[0]) && get_query_var($category_taxonomy[0]) ? get_query_var($category_taxonomy[0]) : false;
1016
+	$geodir_is_tag = isset($tag_taxonomy[0]) && get_query_var($tag_taxonomy[0]) ? true : false;
1017
+
1018
+	$geodir_is_search = geodir_is_page('search') ? true : false;
1019
+	$geodir_is_location = geodir_is_page('location') ? true : false;
1020
+	$geodir_location_manager = isset($geodir_addon_list['geodir_location_manager']) && $geodir_addon_list['geodir_location_manager'] = 'yes' ? true : false;
1021
+	$godir_location_terms = geodir_get_current_location_terms('query_vars');
1022
+	$gd_city = $geodir_location_manager && isset($godir_location_terms['gd_city']) ? $godir_location_terms['gd_city'] : NULL;
1023
+	$gd_region = $geodir_location_manager && isset($godir_location_terms['gd_region']) ? $godir_location_terms['gd_region'] : NULL;
1024
+	$gd_country = $geodir_location_manager && isset($godir_location_terms['gd_country']) ? $godir_location_terms['gd_country'] : NULL;
1025
+	$replace_location = __('Everywhere', 'geodirectory');
1026
+	$location_id = NULL;
1027
+	if ($geodir_location_manager) {
1028
+		$sql = $wpdb->prepare("SELECT location_id FROM " . POST_LOCATION_TABLE . " WHERE city_slug=%s ORDER BY location_id ASC LIMIT 1", array($gd_city));
1029
+		$location_id = (int)$wpdb->get_var($sql);
1030
+		$location_type = geodir_what_is_current_location();
1031
+		if ($location_type == 'city') {
1032
+			$replace_location = geodir_get_current_location(array('what' => 'city', 'echo' => false));
1033
+		} elseif ($location_type == 'region') {
1034
+			$replace_location = geodir_get_current_location(array('what' => 'region', 'echo' => false));
1035
+		} elseif ($location_type == 'country') {
1036
+			$replace_location = geodir_get_current_location(array('what' => 'country', 'echo' => false));
1037
+			$replace_location = __($replace_location, 'geodirectory');
1038
+		}
1039
+		$country = get_query_var('gd_country');
1040
+		$region = get_query_var('gd_region');
1041
+		$city = get_query_var('gd_city');
1042
+		$current_location = '';
1043
+		if ($country != '') {
1044
+			$current_location = get_actual_location_name('country', $country, true);
1045
+		}
1046
+		if ($region != '') {
1047
+			$current_location = get_actual_location_name('region', $region);
1048
+		}
1049
+		if ($city != '') {
1050
+			$current_location = get_actual_location_name('city', $city);
1051
+		}
1052
+		$replace_location = $current_location != '' ? $current_location : $replace_location;
1053
+	}
1054 1054
 
1055
-    $geodir_meta_keys = '';
1056
-    $geodir_meta_desc = '';
1057
-    if ($is_geodir_page && !empty($geodir_post_type_info)) {
1058
-        if ($geodir_is_page_listing || $geodir_is_search || geodir_is_page('add-listing')) {
1059
-            $geodir_meta_keys = isset($geodir_post_type_info->seo['meta_keyword']) && $geodir_post_type_info->seo['meta_keyword'] != '' ? $geodir_post_type_info->seo['meta_keyword'] : $geodir_meta_keys;
1060
-
1061
-            $geodir_meta_desc = isset($geodir_post_type_info->description) ? $geodir_post_type_info->description : $geodir_meta_desc;
1062
-            $geodir_meta_desc = isset($geodir_post_type_info->seo['meta_description']) && $geodir_post_type_info->seo['meta_description'] != '' ? $geodir_post_type_info->seo['meta_description'] : $geodir_meta_desc;
1063
-
1064
-            if ($geodir_is_category) {
1065
-                $category = $geodir_is_category ? get_term_by('slug', $geodir_is_category, $category_taxonomy[0]) : NULL;
1066
-                if (isset($category->term_id) && !empty($category->term_id)) {
1067
-                    $category_id = $category->term_id;
1068
-                    $category_desc = trim($category->description) != '' ? trim($category->description) : get_tax_meta($category_id, 'ct_cat_top_desc', false, $geodir_post_type);
1069
-                    if ($location_id) {
1070
-                        $option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id;
1071
-                        $cat_loc_option = get_option($option_name);
1072
-
1073
-                        $gd_cat_loc_default = !empty($cat_loc_option) && isset($cat_loc_option['gd_cat_loc_default']) && $cat_loc_option['gd_cat_loc_default'] > 0 ? true : false;
1074
-                        if (!$gd_cat_loc_default) {
1075
-                            $option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id . '_' . $location_id;
1076
-                            $option = get_option($option_name);
1077
-                            $category_desc = isset($option['gd_cat_loc_desc']) && trim($option['gd_cat_loc_desc']) != '' ? trim($option['gd_cat_loc_desc']) : $category_desc;
1078
-                        }
1079
-                    }
1080
-                    $geodir_meta_desc = __("Posts related to Category:", 'geodirectory') . " " . ucfirst(single_cat_title("", FALSE)) . '. ' . $category_desc;
1081
-                }
1082
-            } else if ($geodir_is_tag) {
1083
-                $geodir_meta_desc = __("Posts related to Tag:", 'geodirectory') . " " . ucfirst(single_tag_title("", FALSE)) . '. ' . $geodir_meta_desc;
1084
-            }
1085
-        }
1086
-    }
1055
+	$geodir_meta_keys = '';
1056
+	$geodir_meta_desc = '';
1057
+	if ($is_geodir_page && !empty($geodir_post_type_info)) {
1058
+		if ($geodir_is_page_listing || $geodir_is_search || geodir_is_page('add-listing')) {
1059
+			$geodir_meta_keys = isset($geodir_post_type_info->seo['meta_keyword']) && $geodir_post_type_info->seo['meta_keyword'] != '' ? $geodir_post_type_info->seo['meta_keyword'] : $geodir_meta_keys;
1060
+
1061
+			$geodir_meta_desc = isset($geodir_post_type_info->description) ? $geodir_post_type_info->description : $geodir_meta_desc;
1062
+			$geodir_meta_desc = isset($geodir_post_type_info->seo['meta_description']) && $geodir_post_type_info->seo['meta_description'] != '' ? $geodir_post_type_info->seo['meta_description'] : $geodir_meta_desc;
1063
+
1064
+			if ($geodir_is_category) {
1065
+				$category = $geodir_is_category ? get_term_by('slug', $geodir_is_category, $category_taxonomy[0]) : NULL;
1066
+				if (isset($category->term_id) && !empty($category->term_id)) {
1067
+					$category_id = $category->term_id;
1068
+					$category_desc = trim($category->description) != '' ? trim($category->description) : get_tax_meta($category_id, 'ct_cat_top_desc', false, $geodir_post_type);
1069
+					if ($location_id) {
1070
+						$option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id;
1071
+						$cat_loc_option = get_option($option_name);
1072
+
1073
+						$gd_cat_loc_default = !empty($cat_loc_option) && isset($cat_loc_option['gd_cat_loc_default']) && $cat_loc_option['gd_cat_loc_default'] > 0 ? true : false;
1074
+						if (!$gd_cat_loc_default) {
1075
+							$option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id . '_' . $location_id;
1076
+							$option = get_option($option_name);
1077
+							$category_desc = isset($option['gd_cat_loc_desc']) && trim($option['gd_cat_loc_desc']) != '' ? trim($option['gd_cat_loc_desc']) : $category_desc;
1078
+						}
1079
+					}
1080
+					$geodir_meta_desc = __("Posts related to Category:", 'geodirectory') . " " . ucfirst(single_cat_title("", FALSE)) . '. ' . $category_desc;
1081
+				}
1082
+			} else if ($geodir_is_tag) {
1083
+				$geodir_meta_desc = __("Posts related to Tag:", 'geodirectory') . " " . ucfirst(single_tag_title("", FALSE)) . '. ' . $geodir_meta_desc;
1084
+			}
1085
+		}
1086
+	}
1087 1087
 
1088 1088
 
1089
-    $gd_page = '';
1090
-    if(geodir_is_page('home')){
1091
-        $gd_page = 'home';
1092
-        $meta_desc = (get_option('geodir_meta_desc_homepage')) ? get_option('geodir_meta_desc_homepage') : $meta_desc;
1093
-    }
1094
-    elseif(geodir_is_page('detail')){
1095
-        $gd_page = 'detail';
1096
-        $meta_desc = (get_option('geodir_meta_desc_detail')) ? get_option('geodir_meta_desc_detail') : $meta_desc;
1097
-    }
1098
-    elseif(geodir_is_page('pt')){
1099
-        $gd_page = 'pt';
1100
-        $meta_desc = (get_option('geodir_meta_desc_pt')) ? get_option('geodir_meta_desc_pt') : $meta_desc;
1101
-    }
1102
-    elseif(geodir_is_page('listing')){
1103
-        $gd_page = 'listing';
1104
-        $meta_desc = (get_option('geodir_meta_desc_listing')) ? get_option('geodir_meta_desc_listing') : $meta_desc;
1105
-    }
1106
-    elseif(geodir_is_page('location')){
1107
-        $gd_page = 'location';
1108
-        $meta_desc = (get_option('geodir_meta_desc_location')) ? get_option('geodir_meta_desc_location') : $meta_desc;
1109
-        $meta_desc = apply_filters('geodir_seo_meta_location_description', $meta_desc);
1089
+	$gd_page = '';
1090
+	if(geodir_is_page('home')){
1091
+		$gd_page = 'home';
1092
+		$meta_desc = (get_option('geodir_meta_desc_homepage')) ? get_option('geodir_meta_desc_homepage') : $meta_desc;
1093
+	}
1094
+	elseif(geodir_is_page('detail')){
1095
+		$gd_page = 'detail';
1096
+		$meta_desc = (get_option('geodir_meta_desc_detail')) ? get_option('geodir_meta_desc_detail') : $meta_desc;
1097
+	}
1098
+	elseif(geodir_is_page('pt')){
1099
+		$gd_page = 'pt';
1100
+		$meta_desc = (get_option('geodir_meta_desc_pt')) ? get_option('geodir_meta_desc_pt') : $meta_desc;
1101
+	}
1102
+	elseif(geodir_is_page('listing')){
1103
+		$gd_page = 'listing';
1104
+		$meta_desc = (get_option('geodir_meta_desc_listing')) ? get_option('geodir_meta_desc_listing') : $meta_desc;
1105
+	}
1106
+	elseif(geodir_is_page('location')){
1107
+		$gd_page = 'location';
1108
+		$meta_desc = (get_option('geodir_meta_desc_location')) ? get_option('geodir_meta_desc_location') : $meta_desc;
1109
+		$meta_desc = apply_filters('geodir_seo_meta_location_description', $meta_desc);
1110 1110
 
1111
-    }
1112
-    elseif(geodir_is_page('search')){
1113
-        $gd_page = 'search';
1114
-        $meta_desc = (get_option('geodir_meta_desc_search')) ? get_option('geodir_meta_desc_search') : $meta_desc;
1115
-    }
1116
-    elseif(geodir_is_page('add-listing')){
1117
-        $gd_page = 'add-listing';
1118
-        $meta_desc = (get_option('geodir_meta_desc_add-listing')) ? get_option('geodir_meta_desc_add-listing') : $meta_desc;
1119
-    }
1120
-    elseif(geodir_is_page('author')){
1121
-        $gd_page = 'author';
1122
-        $meta_desc = (get_option('geodir_meta_desc_author')) ? get_option('geodir_meta_desc_author') : $meta_desc;
1123
-    }
1124
-    elseif(geodir_is_page('login')){
1125
-        $gd_page = 'login';
1126
-        $meta_desc = (get_option('geodir_meta_desc_login')) ? get_option('geodir_meta_desc_login') : $meta_desc;
1127
-    }
1128
-    elseif(geodir_is_page('listing-success')){
1129
-        $gd_page = 'listing-success';
1130
-        $meta_desc = (get_option('geodir_meta_desc_listing-success')) ? get_option('geodir_meta_desc_listing-success') : $meta_desc;
1131
-    }
1111
+	}
1112
+	elseif(geodir_is_page('search')){
1113
+		$gd_page = 'search';
1114
+		$meta_desc = (get_option('geodir_meta_desc_search')) ? get_option('geodir_meta_desc_search') : $meta_desc;
1115
+	}
1116
+	elseif(geodir_is_page('add-listing')){
1117
+		$gd_page = 'add-listing';
1118
+		$meta_desc = (get_option('geodir_meta_desc_add-listing')) ? get_option('geodir_meta_desc_add-listing') : $meta_desc;
1119
+	}
1120
+	elseif(geodir_is_page('author')){
1121
+		$gd_page = 'author';
1122
+		$meta_desc = (get_option('geodir_meta_desc_author')) ? get_option('geodir_meta_desc_author') : $meta_desc;
1123
+	}
1124
+	elseif(geodir_is_page('login')){
1125
+		$gd_page = 'login';
1126
+		$meta_desc = (get_option('geodir_meta_desc_login')) ? get_option('geodir_meta_desc_login') : $meta_desc;
1127
+	}
1128
+	elseif(geodir_is_page('listing-success')){
1129
+		$gd_page = 'listing-success';
1130
+		$meta_desc = (get_option('geodir_meta_desc_listing-success')) ? get_option('geodir_meta_desc_listing-success') : $meta_desc;
1131
+	}
1132 1132
 
1133 1133
 
1134
-    /*
1134
+	/*
1135 1135
     $geodir_meta_desc = $geodir_meta_desc != '' ? $geodir_meta_desc : $meta_desc;
1136 1136
     if ($geodir_meta_desc != '') {
1137 1137
         $geodir_meta_desc = strip_tags($geodir_meta_desc);
@@ -1144,74 +1144,74 @@  discard block
 block discarded – undo
1144 1144
     */
1145 1145
 
1146 1146
 
1147
-    if ($meta_desc) {
1148
-        $meta_desc = stripslashes_deep($meta_desc);
1149
-        /**
1150
-         * Filter page description to replace variables.
1151
-         *
1152
-         * @since 1.5.4
1153
-         * @param string $title The page description including variables.
1154
-         * @param string $gd_page The GeoDirectory page type if any.
1155
-         */
1156
-        $meta_desc = apply_filters('geodir_seo_meta_description_pre', __($meta_desc, 'geodirectory'),$gd_page,'');
1157
-
1158
-        /**
1159
-         * Filter SEO meta description.
1160
-         *
1161
-         * @since 1.0.0
1162
-         * @param string $meta_desc Meta description content.
1163
-         */
1164
-        echo apply_filters('geodir_seo_meta_description', '<meta name="description" content="' . $meta_desc . '" />', $meta_desc);
1165
-    }
1147
+	if ($meta_desc) {
1148
+		$meta_desc = stripslashes_deep($meta_desc);
1149
+		/**
1150
+		 * Filter page description to replace variables.
1151
+		 *
1152
+		 * @since 1.5.4
1153
+		 * @param string $title The page description including variables.
1154
+		 * @param string $gd_page The GeoDirectory page type if any.
1155
+		 */
1156
+		$meta_desc = apply_filters('geodir_seo_meta_description_pre', __($meta_desc, 'geodirectory'),$gd_page,'');
1157
+
1158
+		/**
1159
+		 * Filter SEO meta description.
1160
+		 *
1161
+		 * @since 1.0.0
1162
+		 * @param string $meta_desc Meta description content.
1163
+		 */
1164
+		echo apply_filters('geodir_seo_meta_description', '<meta name="description" content="' . $meta_desc . '" />', $meta_desc);
1165
+	}
1166 1166
 
1167
-    // meta keywords
1168
-    if (isset($post->post_type) && in_array($post->post_type, $all_postypes)) {
1169
-        $place_tags = wp_get_post_terms($post->ID, $post->post_type . '_tags', array("fields" => "names"));
1170
-        $place_cats = wp_get_post_terms($post->ID, $post->post_type . 'category', array("fields" => "names"));
1171
-
1172
-        $meta_key .= implode(", ", array_merge((array)$place_cats, (array)$place_tags));
1173
-    } else {
1174
-        $posttags = get_the_tags();
1175
-        if ($posttags) {
1176
-            foreach ($posttags as $tag) {
1177
-                $meta_key .= $tag->name . ' ';
1178
-            }
1179
-        } else {
1180
-            $tags = get_tags(array('orderby' => 'count', 'order' => 'DESC'));
1181
-            $xt = 1;
1167
+	// meta keywords
1168
+	if (isset($post->post_type) && in_array($post->post_type, $all_postypes)) {
1169
+		$place_tags = wp_get_post_terms($post->ID, $post->post_type . '_tags', array("fields" => "names"));
1170
+		$place_cats = wp_get_post_terms($post->ID, $post->post_type . 'category', array("fields" => "names"));
1171
+
1172
+		$meta_key .= implode(", ", array_merge((array)$place_cats, (array)$place_tags));
1173
+	} else {
1174
+		$posttags = get_the_tags();
1175
+		if ($posttags) {
1176
+			foreach ($posttags as $tag) {
1177
+				$meta_key .= $tag->name . ' ';
1178
+			}
1179
+		} else {
1180
+			$tags = get_tags(array('orderby' => 'count', 'order' => 'DESC'));
1181
+			$xt = 1;
1182 1182
 
1183
-            foreach ($tags as $tag) {
1184
-                if ($xt <= 20) {
1185
-                    $meta_key .= $tag->name . ", ";
1186
-                }
1183
+			foreach ($tags as $tag) {
1184
+				if ($xt <= 20) {
1185
+					$meta_key .= $tag->name . ", ";
1186
+				}
1187 1187
 
1188
-                $xt++;
1189
-            }
1190
-        }
1191
-    }
1188
+				$xt++;
1189
+			}
1190
+		}
1191
+	}
1192 1192
 
1193
-    $meta_key = $meta_key != '' ? rtrim(trim($meta_key), ",") : $meta_key;
1194
-    $geodir_meta_keys = $geodir_meta_keys != '' ? ($meta_key != '' ? $meta_key . ', ' . $geodir_meta_keys : $geodir_meta_keys) : $meta_key;
1195
-    if ($geodir_meta_keys != '') {
1196
-        $geodir_meta_keys = strip_tags($geodir_meta_keys);
1197
-        $geodir_meta_keys = esc_html($geodir_meta_keys);
1198
-        $geodir_meta_keys = geodir_strtolower($geodir_meta_keys);
1199
-        $geodir_meta_keys = wp_html_excerpt($geodir_meta_keys, 1000, '');
1200
-        $geodir_meta_keys = str_replace('%location%', $replace_location, $geodir_meta_keys);
1193
+	$meta_key = $meta_key != '' ? rtrim(trim($meta_key), ",") : $meta_key;
1194
+	$geodir_meta_keys = $geodir_meta_keys != '' ? ($meta_key != '' ? $meta_key . ', ' . $geodir_meta_keys : $geodir_meta_keys) : $meta_key;
1195
+	if ($geodir_meta_keys != '') {
1196
+		$geodir_meta_keys = strip_tags($geodir_meta_keys);
1197
+		$geodir_meta_keys = esc_html($geodir_meta_keys);
1198
+		$geodir_meta_keys = geodir_strtolower($geodir_meta_keys);
1199
+		$geodir_meta_keys = wp_html_excerpt($geodir_meta_keys, 1000, '');
1200
+		$geodir_meta_keys = str_replace('%location%', $replace_location, $geodir_meta_keys);
1201 1201
 
1202
-        $meta_key = rtrim(trim($geodir_meta_keys), ",");
1203
-    }
1202
+		$meta_key = rtrim(trim($geodir_meta_keys), ",");
1203
+	}
1204 1204
 
1205
-    if ($meta_key) {
1206
-        $meta_key = stripslashes_deep($meta_key);
1207
-        /**
1208
-         * Filter SEO meta keywords.
1209
-         *
1210
-         * @since 1.0.0
1211
-         * @param string $meta_desc Meta keywords.
1212
-         */
1213
-        echo apply_filters('geodir_seo_meta_keywords', '<meta name="keywords" content="' . $meta_key . '" />', $meta_key);
1214
-    }
1205
+	if ($meta_key) {
1206
+		$meta_key = stripslashes_deep($meta_key);
1207
+		/**
1208
+		 * Filter SEO meta keywords.
1209
+		 *
1210
+		 * @since 1.0.0
1211
+		 * @param string $meta_desc Meta keywords.
1212
+		 */
1213
+		echo apply_filters('geodir_seo_meta_keywords', '<meta name="keywords" content="' . $meta_key . '" />', $meta_key);
1214
+	}
1215 1215
 
1216 1216
 }
1217 1217
 
@@ -1226,14 +1226,14 @@  discard block
 block discarded – undo
1226 1226
  */
1227 1227
 function geodir_detail_page_tabs_key_value_array()
1228 1228
 {
1229
-    $geodir_detail_page_tabs_key_value_array = array();
1229
+	$geodir_detail_page_tabs_key_value_array = array();
1230 1230
 
1231
-    $geodir_detail_page_tabs_array = geodir_detail_page_tabs_array();
1231
+	$geodir_detail_page_tabs_array = geodir_detail_page_tabs_array();
1232 1232
 
1233
-    foreach ($geodir_detail_page_tabs_array as $key => $tabs_obj) {
1234
-        $geodir_detail_page_tabs_key_value_array[$key] = $tabs_obj['heading_text'];
1235
-    }
1236
-    return $geodir_detail_page_tabs_key_value_array;
1233
+	foreach ($geodir_detail_page_tabs_array as $key => $tabs_obj) {
1234
+		$geodir_detail_page_tabs_key_value_array[$key] = $tabs_obj['heading_text'];
1235
+	}
1236
+	return $geodir_detail_page_tabs_key_value_array;
1237 1237
 }
1238 1238
 
1239 1239
 /**
@@ -1246,73 +1246,73 @@  discard block
 block discarded – undo
1246 1246
 function geodir_detail_page_tabs_array()
1247 1247
 {
1248 1248
 
1249
-    $arr_tabs = array();
1250
-    /**
1251
-     * Filter detail page tab display.
1252
-     *
1253
-     * @since 1.0.0
1254
-     */
1255
-    $arr_tabs['post_profile'] = array(
1256
-        'heading_text' => __('Profile', 'geodirectory'),
1257
-        'is_active_tab' => true,
1258
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_profile'),
1259
-        'tab_content' => ''
1260
-    );
1261
-    $arr_tabs['post_info'] = array(
1262
-        'heading_text' => __('More Info', 'geodirectory'),
1263
-        'is_active_tab' => false,
1264
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_info'),
1265
-        'tab_content' => ''
1266
-    );
1267
-
1268
-    $arr_tabs['post_images'] = array(
1269
-        'heading_text' => __('Photo', 'geodirectory'),
1270
-        'is_active_tab' => false,
1271
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_images'),
1272
-        'tab_content' => ''
1273
-    );
1274
-
1275
-    $arr_tabs['post_video'] = array(
1276
-        'heading_text' => __('Video', 'geodirectory'),
1277
-        'is_active_tab' => false,
1278
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_video'),
1279
-        'tab_content' => ''
1280
-    );
1281
-
1282
-    $arr_tabs['special_offers'] = array(
1283
-        'heading_text' => __('Special Offers', 'geodirectory'),
1284
-        'is_active_tab' => false,
1285
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'special_offers'),
1286
-        'tab_content' => ''
1287
-    );
1288
-
1289
-    $arr_tabs['post_map'] = array(
1290
-        'heading_text' => __('Map', 'geodirectory'),
1291
-        'is_active_tab' => false,
1292
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_map'),
1293
-        'tab_content' => ''
1294
-    );
1295
-
1296
-    $arr_tabs['reviews'] = array(
1297
-        'heading_text' => __('Reviews', 'geodirectory'),
1298
-        'is_active_tab' => false,
1299
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'reviews'),
1300
-        'tab_content' => 'review display'
1301
-    );
1302
-
1303
-    $arr_tabs['related_listing'] = array(
1304
-        'heading_text' => __('Related Listing', 'geodirectory'),
1305
-        'is_active_tab' => false,
1306
-        'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'related_listing'),
1307
-        'tab_content' => ''
1308
-    );
1309
-
1310
-    /**
1311
-     * Filter the tabs array.
1312
-     *
1313
-     * @since 1.0.0
1314
-     */
1315
-    return apply_filters('geodir_detail_page_tab_list_extend', $arr_tabs);
1249
+	$arr_tabs = array();
1250
+	/**
1251
+	 * Filter detail page tab display.
1252
+	 *
1253
+	 * @since 1.0.0
1254
+	 */
1255
+	$arr_tabs['post_profile'] = array(
1256
+		'heading_text' => __('Profile', 'geodirectory'),
1257
+		'is_active_tab' => true,
1258
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_profile'),
1259
+		'tab_content' => ''
1260
+	);
1261
+	$arr_tabs['post_info'] = array(
1262
+		'heading_text' => __('More Info', 'geodirectory'),
1263
+		'is_active_tab' => false,
1264
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_info'),
1265
+		'tab_content' => ''
1266
+	);
1267
+
1268
+	$arr_tabs['post_images'] = array(
1269
+		'heading_text' => __('Photo', 'geodirectory'),
1270
+		'is_active_tab' => false,
1271
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_images'),
1272
+		'tab_content' => ''
1273
+	);
1274
+
1275
+	$arr_tabs['post_video'] = array(
1276
+		'heading_text' => __('Video', 'geodirectory'),
1277
+		'is_active_tab' => false,
1278
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_video'),
1279
+		'tab_content' => ''
1280
+	);
1281
+
1282
+	$arr_tabs['special_offers'] = array(
1283
+		'heading_text' => __('Special Offers', 'geodirectory'),
1284
+		'is_active_tab' => false,
1285
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'special_offers'),
1286
+		'tab_content' => ''
1287
+	);
1288
+
1289
+	$arr_tabs['post_map'] = array(
1290
+		'heading_text' => __('Map', 'geodirectory'),
1291
+		'is_active_tab' => false,
1292
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_map'),
1293
+		'tab_content' => ''
1294
+	);
1295
+
1296
+	$arr_tabs['reviews'] = array(
1297
+		'heading_text' => __('Reviews', 'geodirectory'),
1298
+		'is_active_tab' => false,
1299
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'reviews'),
1300
+		'tab_content' => 'review display'
1301
+	);
1302
+
1303
+	$arr_tabs['related_listing'] = array(
1304
+		'heading_text' => __('Related Listing', 'geodirectory'),
1305
+		'is_active_tab' => false,
1306
+		'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'related_listing'),
1307
+		'tab_content' => ''
1308
+	);
1309
+
1310
+	/**
1311
+	 * Filter the tabs array.
1312
+	 *
1313
+	 * @since 1.0.0
1314
+	 */
1315
+	return apply_filters('geodir_detail_page_tab_list_extend', $arr_tabs);
1316 1316
 
1317 1317
 
1318 1318
 }
@@ -1327,15 +1327,15 @@  discard block
 block discarded – undo
1327 1327
  */
1328 1328
 function geodir_detail_page_tabs_list()
1329 1329
 {
1330
-    $tabs_excluded = get_option('geodir_detail_page_tabs_excluded');
1331
-    $tabs_array = geodir_detail_page_tabs_array();
1332
-    if (!empty($tabs_excluded)) {
1333
-        foreach ($tabs_excluded as $tab) {
1334
-            if (array_key_exists($tab, $tabs_array))
1335
-                unset($tabs_array[$tab]);
1336
-        }
1337
-    }
1338
-    return $tabs_array;
1330
+	$tabs_excluded = get_option('geodir_detail_page_tabs_excluded');
1331
+	$tabs_array = geodir_detail_page_tabs_array();
1332
+	if (!empty($tabs_excluded)) {
1333
+		foreach ($tabs_excluded as $tab) {
1334
+			if (array_key_exists($tab, $tabs_array))
1335
+				unset($tabs_array[$tab]);
1336
+		}
1337
+	}
1338
+	return $tabs_array;
1339 1339
 }
1340 1340
 
1341 1341
 
@@ -1353,156 +1353,156 @@  discard block
 block discarded – undo
1353 1353
  */
1354 1354
 function geodir_show_detail_page_tabs()
1355 1355
 {
1356
-    global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields;
1356
+	global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields;
1357 1357
 
1358
-    $post_id = !empty($post) && isset($post->ID) ? (int)$post->ID : 0;
1359
-    $request_post_id = !empty($_REQUEST['p']) ? (int)$_REQUEST['p'] : 0;
1360
-    $is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend
1358
+	$post_id = !empty($post) && isset($post->ID) ? (int)$post->ID : 0;
1359
+	$request_post_id = !empty($_REQUEST['p']) ? (int)$_REQUEST['p'] : 0;
1360
+	$is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend
1361 1361
 
1362
-    if ($is_backend_preview && !$post_id > 0 && $request_post_id > 0) {
1363
-        $post = geodir_get_post_info($request_post_id);
1364
-        setup_postdata($post);
1365
-    }
1362
+	if ($is_backend_preview && !$post_id > 0 && $request_post_id > 0) {
1363
+		$post = geodir_get_post_info($request_post_id);
1364
+		setup_postdata($post);
1365
+	}
1366 1366
 
1367
-    $geodir_post_detail_fields = geodir_show_listing_info('detail');
1368
-
1369
-    if (geodir_is_page('detail')) {
1370
-        $video = geodir_get_video($post->ID);
1371
-        $special_offers = geodir_get_special_offers($post->ID);
1372
-        $related_listing_array = array();
1373
-        if (get_option('geodir_add_related_listing_posttypes'))
1374
-            $related_listing_array = get_option('geodir_add_related_listing_posttypes');
1375
-
1376
-        $related_listing = '';
1377
-        if (in_array($post->post_type, $related_listing_array)) {
1378
-            $request = array('post_number' => get_option('geodir_related_post_count'),
1379
-                'relate_to' => get_option('geodir_related_post_relate_to'),
1380
-                'layout' => get_option('geodir_related_post_listing_view'),
1381
-                'add_location_filter' => get_option('geodir_related_post_location_filter'),
1382
-                'list_sort' => get_option('geodir_related_post_sortby'),
1383
-                'character_count' => get_option('geodir_related_post_excerpt'));
1384
-
1385
-            if ($post->post_type == 'gd_event' && defined('GDEVENTS_VERSION')) {
1386
-                $related_listing = geodir_get_detail_page_related_events($request);
1387
-            } else {
1388
-                $related_listing = geodir_related_posts_display($request);
1389
-            }
1367
+	$geodir_post_detail_fields = geodir_show_listing_info('detail');
1368
+
1369
+	if (geodir_is_page('detail')) {
1370
+		$video = geodir_get_video($post->ID);
1371
+		$special_offers = geodir_get_special_offers($post->ID);
1372
+		$related_listing_array = array();
1373
+		if (get_option('geodir_add_related_listing_posttypes'))
1374
+			$related_listing_array = get_option('geodir_add_related_listing_posttypes');
1375
+
1376
+		$related_listing = '';
1377
+		if (in_array($post->post_type, $related_listing_array)) {
1378
+			$request = array('post_number' => get_option('geodir_related_post_count'),
1379
+				'relate_to' => get_option('geodir_related_post_relate_to'),
1380
+				'layout' => get_option('geodir_related_post_listing_view'),
1381
+				'add_location_filter' => get_option('geodir_related_post_location_filter'),
1382
+				'list_sort' => get_option('geodir_related_post_sortby'),
1383
+				'character_count' => get_option('geodir_related_post_excerpt'));
1384
+
1385
+			if ($post->post_type == 'gd_event' && defined('GDEVENTS_VERSION')) {
1386
+				$related_listing = geodir_get_detail_page_related_events($request);
1387
+			} else {
1388
+				$related_listing = geodir_related_posts_display($request);
1389
+			}
1390 1390
 
1391
-        }
1391
+		}
1392 1392
 
1393
-        $post_images = geodir_get_images($post->ID, 'thumbnail');
1394
-        $thumb_image = '';
1395
-        if (!empty($post_images)) {
1396
-            foreach ($post_images as $image) {
1397
-                $caption = (!empty($image->caption)) ? $image->caption : '';
1398
-                $thumb_image .= '<a href="' . $image->src . '" title="'.$caption.'">';
1399
-                $thumb_image .= geodir_show_image($image, 'thumbnail', true, false);
1400
-                $thumb_image .= '</a>';
1401
-            }
1402
-        }
1393
+		$post_images = geodir_get_images($post->ID, 'thumbnail');
1394
+		$thumb_image = '';
1395
+		if (!empty($post_images)) {
1396
+			foreach ($post_images as $image) {
1397
+				$caption = (!empty($image->caption)) ? $image->caption : '';
1398
+				$thumb_image .= '<a href="' . $image->src . '" title="'.$caption.'">';
1399
+				$thumb_image .= geodir_show_image($image, 'thumbnail', true, false);
1400
+				$thumb_image .= '</a>';
1401
+			}
1402
+		}
1403 1403
 
1404
-        $map_args = array();
1405
-        $map_args['map_canvas_name'] = 'detail_page_map_canvas';
1406
-        $map_args['width'] = '600';
1407
-        $map_args['height'] = '300';
1408
-        if ($post->post_mapzoom) {
1409
-            $map_args['zoom'] = '' . $post->post_mapzoom . '';
1410
-        }
1411
-        $map_args['autozoom'] = false;
1412
-        $map_args['child_collapse'] = '0';
1413
-        $map_args['enable_cat_filters'] = false;
1414
-        $map_args['enable_text_search'] = false;
1415
-        $map_args['enable_post_type_filters'] = false;
1416
-        $map_args['enable_location_filters'] = false;
1417
-        $map_args['enable_jason_on_load'] = true;
1418
-        $map_args['enable_map_direction'] = true;
1419
-        $map_args['map_class_name'] = 'geodir-map-detail-page';
1420
-        $map_args['maptype'] = (!empty($post->post_mapview)) ? $post->post_mapview : 'ROADMAP';
1421
-    } else if (geodir_is_page('preview')) {
1422
-        $video = isset($post->geodir_video) ? $post->geodir_video : '';
1423
-        $special_offers = isset($post->geodir_special_offers) ? $post->geodir_special_offers : '';
1424
-
1425
-        if (isset($post->post_images))
1426
-            $post->post_images = trim($post->post_images, ",");
1427
-
1428
-        if (isset($post->post_images) && !empty($post->post_images))
1429
-            $post_images = explode(",", $post->post_images);
1430
-
1431
-        $thumb_image = '';
1432
-        if (!empty($post_images)) {
1433
-            foreach ($post_images as $image) {
1434
-                if ($image != '') {
1435
-                    $thumb_image .= '<a href="' . $image . '">';
1436
-                    $thumb_image .= geodir_show_image(array('src' => $image), 'thumbnail', true, false);
1437
-                    $thumb_image .= '</a>';
1438
-                }
1439
-            }
1440
-        }
1404
+		$map_args = array();
1405
+		$map_args['map_canvas_name'] = 'detail_page_map_canvas';
1406
+		$map_args['width'] = '600';
1407
+		$map_args['height'] = '300';
1408
+		if ($post->post_mapzoom) {
1409
+			$map_args['zoom'] = '' . $post->post_mapzoom . '';
1410
+		}
1411
+		$map_args['autozoom'] = false;
1412
+		$map_args['child_collapse'] = '0';
1413
+		$map_args['enable_cat_filters'] = false;
1414
+		$map_args['enable_text_search'] = false;
1415
+		$map_args['enable_post_type_filters'] = false;
1416
+		$map_args['enable_location_filters'] = false;
1417
+		$map_args['enable_jason_on_load'] = true;
1418
+		$map_args['enable_map_direction'] = true;
1419
+		$map_args['map_class_name'] = 'geodir-map-detail-page';
1420
+		$map_args['maptype'] = (!empty($post->post_mapview)) ? $post->post_mapview : 'ROADMAP';
1421
+	} else if (geodir_is_page('preview')) {
1422
+		$video = isset($post->geodir_video) ? $post->geodir_video : '';
1423
+		$special_offers = isset($post->geodir_special_offers) ? $post->geodir_special_offers : '';
1424
+
1425
+		if (isset($post->post_images))
1426
+			$post->post_images = trim($post->post_images, ",");
1427
+
1428
+		if (isset($post->post_images) && !empty($post->post_images))
1429
+			$post_images = explode(",", $post->post_images);
1430
+
1431
+		$thumb_image = '';
1432
+		if (!empty($post_images)) {
1433
+			foreach ($post_images as $image) {
1434
+				if ($image != '') {
1435
+					$thumb_image .= '<a href="' . $image . '">';
1436
+					$thumb_image .= geodir_show_image(array('src' => $image), 'thumbnail', true, false);
1437
+					$thumb_image .= '</a>';
1438
+				}
1439
+			}
1440
+		}
1441 1441
 
1442
-        global $map_jason;
1443
-        $marker_json = $post->marker_json != '' ? json_decode($post->marker_json, true) : array();
1444
-        $marker_icon = (!empty($marker_json) && !empty($marker_json['i'])) ? $marker_json['i'] : '';
1445
-        $icon_size = geodir_get_marker_size($marker_icon);
1446
-        $marker_json['w'] = $icon_size['w'];
1447
-        $marker_json['h'] = $icon_size['h'];
1448
-        $map_jason[] = json_encode($marker_json);
1449
-
1450
-        $address_latitude = isset($post->post_latitude) ? $post->post_latitude : '';
1451
-        $address_longitude = isset($post->post_longitude) ? $post->post_longitude : '';
1452
-        $mapview = isset($post->post_mapview) ? $post->post_mapview : '';
1453
-        $mapzoom = isset($post->post_mapzoom) ? $post->post_mapzoom : '';
1454
-        if (!$mapzoom) {
1455
-            $mapzoom = 12;
1456
-        }
1442
+		global $map_jason;
1443
+		$marker_json = $post->marker_json != '' ? json_decode($post->marker_json, true) : array();
1444
+		$marker_icon = (!empty($marker_json) && !empty($marker_json['i'])) ? $marker_json['i'] : '';
1445
+		$icon_size = geodir_get_marker_size($marker_icon);
1446
+		$marker_json['w'] = $icon_size['w'];
1447
+		$marker_json['h'] = $icon_size['h'];
1448
+		$map_jason[] = json_encode($marker_json);
1449
+
1450
+		$address_latitude = isset($post->post_latitude) ? $post->post_latitude : '';
1451
+		$address_longitude = isset($post->post_longitude) ? $post->post_longitude : '';
1452
+		$mapview = isset($post->post_mapview) ? $post->post_mapview : '';
1453
+		$mapzoom = isset($post->post_mapzoom) ? $post->post_mapzoom : '';
1454
+		if (!$mapzoom) {
1455
+			$mapzoom = 12;
1456
+		}
1457 1457
 
1458
-        $map_args = array();
1459
-        $map_args['map_canvas_name'] = 'preview_map_canvas';
1460
-        $map_args['width'] = '950';
1461
-        $map_args['height'] = '300';
1462
-        $map_args['child_collapse'] = '0';
1463
-        $map_args['maptype'] = $mapview;
1464
-        $map_args['autozoom'] = false;
1465
-        $map_args['zoom'] = "$mapzoom";
1466
-        $map_args['latitude'] = $address_latitude;
1467
-        $map_args['longitude'] = $address_longitude;
1468
-        $map_args['enable_cat_filters'] = false;
1469
-        $map_args['enable_text_search'] = false;
1470
-        $map_args['enable_post_type_filters'] = false;
1471
-        $map_args['enable_location_filters'] = false;
1472
-        $map_args['enable_jason_on_load'] = true;
1473
-        $map_args['enable_map_direction'] = true;
1474
-        $map_args['map_class_name'] = 'geodir-map-preview-page';
1475
-    }
1458
+		$map_args = array();
1459
+		$map_args['map_canvas_name'] = 'preview_map_canvas';
1460
+		$map_args['width'] = '950';
1461
+		$map_args['height'] = '300';
1462
+		$map_args['child_collapse'] = '0';
1463
+		$map_args['maptype'] = $mapview;
1464
+		$map_args['autozoom'] = false;
1465
+		$map_args['zoom'] = "$mapzoom";
1466
+		$map_args['latitude'] = $address_latitude;
1467
+		$map_args['longitude'] = $address_longitude;
1468
+		$map_args['enable_cat_filters'] = false;
1469
+		$map_args['enable_text_search'] = false;
1470
+		$map_args['enable_post_type_filters'] = false;
1471
+		$map_args['enable_location_filters'] = false;
1472
+		$map_args['enable_jason_on_load'] = true;
1473
+		$map_args['enable_map_direction'] = true;
1474
+		$map_args['map_class_name'] = 'geodir-map-preview-page';
1475
+	}
1476 1476
 
1477
-    $arr_detail_page_tabs = geodir_detail_page_tabs_list();// get this sooner so we can get the active tab for the user
1477
+	$arr_detail_page_tabs = geodir_detail_page_tabs_list();// get this sooner so we can get the active tab for the user
1478 1478
 
1479
-    $active_tab = '';
1480
-    $active_tab_name = '';
1481
-    $default_tab = '';
1482
-    $default_tab_name = '';
1483
-    foreach($arr_detail_page_tabs as $tab_index => $tabs){
1484
-        if (isset($tabs['is_active_tab']) && $tabs['is_active_tab'] && !empty($tabs['is_display']) && isset($tabs['heading_text']) && $tabs['heading_text']) {
1485
-            $active_tab = $tab_index;
1486
-            $active_tab_name = __($tabs['heading_text'], 'geodirectory');
1487
-        }
1479
+	$active_tab = '';
1480
+	$active_tab_name = '';
1481
+	$default_tab = '';
1482
+	$default_tab_name = '';
1483
+	foreach($arr_detail_page_tabs as $tab_index => $tabs){
1484
+		if (isset($tabs['is_active_tab']) && $tabs['is_active_tab'] && !empty($tabs['is_display']) && isset($tabs['heading_text']) && $tabs['heading_text']) {
1485
+			$active_tab = $tab_index;
1486
+			$active_tab_name = __($tabs['heading_text'], 'geodirectory');
1487
+		}
1488 1488
         
1489
-        if ($default_tab === '' && !empty($tabs['is_display']) && !empty($tabs['heading_text'])) {
1490
-            $default_tab = $tab_index;
1491
-            $default_tab_name = __($tabs['heading_text'], 'geodirectory');
1492
-        }
1493
-    }
1489
+		if ($default_tab === '' && !empty($tabs['is_display']) && !empty($tabs['heading_text'])) {
1490
+			$default_tab = $tab_index;
1491
+			$default_tab_name = __($tabs['heading_text'], 'geodirectory');
1492
+		}
1493
+	}
1494 1494
     
1495
-    if ($active_tab === '' && $default_tab !== '') { // Make first tab acs a active tab if not any tab is active.
1496
-        if (isset($arr_detail_page_tabs[$active_tab]) && isset($arr_detail_page_tabs[$active_tab]['is_active_tab'])) {
1497
-            $arr_detail_page_tabs[$active_tab]['is_active_tab'] = false;
1498
-        }
1495
+	if ($active_tab === '' && $default_tab !== '') { // Make first tab acs a active tab if not any tab is active.
1496
+		if (isset($arr_detail_page_tabs[$active_tab]) && isset($arr_detail_page_tabs[$active_tab]['is_active_tab'])) {
1497
+			$arr_detail_page_tabs[$active_tab]['is_active_tab'] = false;
1498
+		}
1499 1499
         
1500
-        $arr_detail_page_tabs[$default_tab]['is_active_tab'] = true;
1501
-        $active_tab = $default_tab;
1502
-        $active_tab_name = $default_tab_name;
1503
-    }
1504
-    $tab_list = (get_option('geodir_disable_tabs',false)) ? true : false;
1505
-    ?>
1500
+		$arr_detail_page_tabs[$default_tab]['is_active_tab'] = true;
1501
+		$active_tab = $default_tab;
1502
+		$active_tab_name = $default_tab_name;
1503
+	}
1504
+	$tab_list = (get_option('geodir_disable_tabs',false)) ? true : false;
1505
+	?>
1506 1506
     <div class="geodir-tabs" id="gd-tabs" style="position:relative;">
1507 1507
         <?php if(!$tab_list){ ?>
1508 1508
         <div id="geodir-tab-mobile-menu">
@@ -1512,166 +1512,166 @@  discard block
 block discarded – undo
1512 1512
         </div>
1513 1513
         <dl class="geodir-tab-head">
1514 1514
             <?php
1515
-            }
1516
-            /**
1517
-             * Called before the details page tab list headings, inside the `dl` tag.
1518
-             *
1519
-             * @since 1.0.0
1520
-             * @see 'geodir_after_tab_list'
1521
-             */
1522
-            do_action('geodir_before_tab_list'); ?>
1515
+			}
1516
+			/**
1517
+			 * Called before the details page tab list headings, inside the `dl` tag.
1518
+			 *
1519
+			 * @since 1.0.0
1520
+			 * @see 'geodir_after_tab_list'
1521
+			 */
1522
+			do_action('geodir_before_tab_list'); ?>
1523 1523
             <?php
1524 1524
 
1525
-            foreach ($arr_detail_page_tabs as $tab_index => $detail_page_tab) {
1526
-                if ($detail_page_tab['is_display']) {
1525
+			foreach ($arr_detail_page_tabs as $tab_index => $detail_page_tab) {
1526
+				if ($detail_page_tab['is_display']) {
1527 1527
 
1528
-                    if(!$tab_list) {
1529
-                        ?>
1528
+					if(!$tab_list) {
1529
+						?>
1530 1530
                         <dt></dt> <!-- added to comply with validation -->
1531 1531
                         <dd <?php if ($detail_page_tab['is_active_tab']){ ?>class="geodir-tab-active"<?php } ?> ><a
1532 1532
                                 data-tab="#<?php echo $tab_index; ?>"
1533 1533
                                 data-status="enable"><?php _e($detail_page_tab['heading_text'], 'geodirectory'); ?></a>
1534 1534
                         </dd>
1535 1535
                         <?php
1536
-                    }
1537
-                    ob_start() // start tab content buffering
1538
-                    ?>
1536
+					}
1537
+					ob_start() // start tab content buffering
1538
+					?>
1539 1539
                     <li id="<?php echo $tab_index;?>Tab">
1540 1540
                         <?php if($tab_list){
1541
-                            $tab_title = '<span class="gd-tab-list-title" ><a href="#'.$tab_index.'">'.__($detail_page_tab['heading_text'],'geodirectory').'</a></span><hr />';
1542
-                            /**
1543
-                             * Filter the tab list title html.
1544
-                             *
1545
-                             * @since 1.6.1
1546
-                             * @param string $tab_title The html for the tab title.
1547
-                             * @param string $tab_index The tab index type.
1548
-                             * @param array $detail_page_tab The array of values including title text.
1549
-                             */
1550
-                            echo apply_filters('geodir_tab_list_title',$tab_title ,$tab_index ,$detail_page_tab);
1551
-                        }?>
1541
+							$tab_title = '<span class="gd-tab-list-title" ><a href="#'.$tab_index.'">'.__($detail_page_tab['heading_text'],'geodirectory').'</a></span><hr />';
1542
+							/**
1543
+							 * Filter the tab list title html.
1544
+							 *
1545
+							 * @since 1.6.1
1546
+							 * @param string $tab_title The html for the tab title.
1547
+							 * @param string $tab_index The tab index type.
1548
+							 * @param array $detail_page_tab The array of values including title text.
1549
+							 */
1550
+							echo apply_filters('geodir_tab_list_title',$tab_title ,$tab_index ,$detail_page_tab);
1551
+						}?>
1552 1552
                         <div id="<?php echo $tab_index;?>" class="hash-offset"></div>
1553 1553
                         <?php
1554
-                        /**
1555
-                         * Called before the details tab content is output per tab.
1556
-                         *
1557
-                         * @since 1.0.0
1558
-                         * @param string $tab_index The tab name ID.
1559
-                         */
1560
-                        do_action('geodir_before_tab_content', $tab_index);
1561
-
1562
-                        /**
1563
-                         * Called before the details tab content is output per tab.
1564
-                         *
1565
-                         * Uses dynamic hook name: geodir_before_$tab_index_tab_content
1566
-                         *
1567
-                         * @since 1.0.0
1568
-                         * @todo do we need this if we have the hook above? 'geodir_before_tab_content'
1569
-                         */
1570
-                        do_action('geodir_before_' . $tab_index . '_tab_content');
1571
-                        /// write a code to generate content of each tab
1572
-                        switch ($tab_index) {
1573
-                            case 'post_profile':
1574
-                                /**
1575
-                                 * Called before the listing description content on the details page tab.
1576
-                                 *
1577
-                                 * @since 1.0.0
1578
-                                 */
1579
-                                do_action('geodir_before_description_on_listing_detail');
1580
-                                if (geodir_is_page('detail')) {
1581
-                                    the_content();
1582
-                                } else {
1583
-                                    /** This action is documented in geodirectory_template_actions.php */
1584
-                                    echo apply_filters('the_content', stripslashes($post->post_desc));
1585
-                                }
1586
-
1587
-                                /**
1588
-                                 * Called after the listing description content on the details page tab.
1589
-                                 *
1590
-                                 * @since 1.0.0
1591
-                                 */
1592
-                                do_action('geodir_after_description_on_listing_detail');
1593
-                                break;
1594
-                            case 'post_info':
1595
-                                echo $geodir_post_detail_fields;
1596
-                                break;
1597
-                            case 'post_images':
1598
-                                echo $thumb_image;
1599
-                                break;
1600
-                            case 'post_video':
1601
-                                /** This action is documented in geodirectory_template_actions.php */
1602
-                                echo apply_filters('the_content', stripslashes($video));// we apply the_content filter so oembed works also;
1603
-                                break;
1604
-                            case 'special_offers':
1605
-                                echo apply_filters('gd_special_offers_content', wpautop(stripslashes($special_offers)));
1606
-
1607
-                                break;
1608
-                            case 'post_map':
1609
-                                geodir_draw_map($map_args);
1610
-                                break;
1611
-                            case 'reviews':
1612
-                                comments_template();
1613
-                                break;
1614
-                            case 'related_listing':
1615
-                                echo $related_listing;
1616
-                                break;
1617
-                            default: {
1618
-                                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'])) {
1619
-                                    echo $detail_page_tab['tab_content'];
1620
-                                }
1621
-                            }
1622
-                                break;
1623
-                        }
1624
-
1625
-                        /**
1626
-                         * Called after the details tab content is output per tab.
1627
-                         *
1628
-                         * @since 1.0.0
1629
-                         */
1630
-                        do_action('geodir_after_tab_content', $tab_index);
1631
-
1632
-                        /**
1633
-                         * Called after the details tab content is output per tab.
1634
-                         *
1635
-                         * Uses dynamic hook name: geodir_after_$tab_index_tab_content
1636
-                         *
1637
-                         * @since 1.0.0
1638
-                         * @todo do we need this if we have the hook above? 'geodir_after_tab_content'
1639
-                         */
1640
-                        do_action('geodir_after_' . $tab_index . '_tab_content');
1641
-                        ?> </li>
1554
+						/**
1555
+						 * Called before the details tab content is output per tab.
1556
+						 *
1557
+						 * @since 1.0.0
1558
+						 * @param string $tab_index The tab name ID.
1559
+						 */
1560
+						do_action('geodir_before_tab_content', $tab_index);
1561
+
1562
+						/**
1563
+						 * Called before the details tab content is output per tab.
1564
+						 *
1565
+						 * Uses dynamic hook name: geodir_before_$tab_index_tab_content
1566
+						 *
1567
+						 * @since 1.0.0
1568
+						 * @todo do we need this if we have the hook above? 'geodir_before_tab_content'
1569
+						 */
1570
+						do_action('geodir_before_' . $tab_index . '_tab_content');
1571
+						/// write a code to generate content of each tab
1572
+						switch ($tab_index) {
1573
+							case 'post_profile':
1574
+								/**
1575
+								 * Called before the listing description content on the details page tab.
1576
+								 *
1577
+								 * @since 1.0.0
1578
+								 */
1579
+								do_action('geodir_before_description_on_listing_detail');
1580
+								if (geodir_is_page('detail')) {
1581
+									the_content();
1582
+								} else {
1583
+									/** This action is documented in geodirectory_template_actions.php */
1584
+									echo apply_filters('the_content', stripslashes($post->post_desc));
1585
+								}
1586
+
1587
+								/**
1588
+								 * Called after the listing description content on the details page tab.
1589
+								 *
1590
+								 * @since 1.0.0
1591
+								 */
1592
+								do_action('geodir_after_description_on_listing_detail');
1593
+								break;
1594
+							case 'post_info':
1595
+								echo $geodir_post_detail_fields;
1596
+								break;
1597
+							case 'post_images':
1598
+								echo $thumb_image;
1599
+								break;
1600
+							case 'post_video':
1601
+								/** This action is documented in geodirectory_template_actions.php */
1602
+								echo apply_filters('the_content', stripslashes($video));// we apply the_content filter so oembed works also;
1603
+								break;
1604
+							case 'special_offers':
1605
+								echo apply_filters('gd_special_offers_content', wpautop(stripslashes($special_offers)));
1606
+
1607
+								break;
1608
+							case 'post_map':
1609
+								geodir_draw_map($map_args);
1610
+								break;
1611
+							case 'reviews':
1612
+								comments_template();
1613
+								break;
1614
+							case 'related_listing':
1615
+								echo $related_listing;
1616
+								break;
1617
+							default: {
1618
+								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'])) {
1619
+									echo $detail_page_tab['tab_content'];
1620
+								}
1621
+							}
1622
+								break;
1623
+						}
1624
+
1625
+						/**
1626
+						 * Called after the details tab content is output per tab.
1627
+						 *
1628
+						 * @since 1.0.0
1629
+						 */
1630
+						do_action('geodir_after_tab_content', $tab_index);
1631
+
1632
+						/**
1633
+						 * Called after the details tab content is output per tab.
1634
+						 *
1635
+						 * Uses dynamic hook name: geodir_after_$tab_index_tab_content
1636
+						 *
1637
+						 * @since 1.0.0
1638
+						 * @todo do we need this if we have the hook above? 'geodir_after_tab_content'
1639
+						 */
1640
+						do_action('geodir_after_' . $tab_index . '_tab_content');
1641
+						?> </li>
1642 1642
                     <?php
1643
-                    /**
1644
-                     * Filter the current tab content.
1645
-                     *
1646
-                     * @since 1.0.0
1647
-                     */
1648
-                    $arr_detail_page_tabs[$tab_index]['tab_content'] = apply_filters("geodir_modify_" . $detail_page_tab['tab_content'] . "_tab_content", ob_get_clean());
1649
-                } // end of if for is_display
1650
-            }// end of foreach
1651
-
1652
-            /**
1653
-             * Called after the details page tab list headings, inside the `dl` tag.
1654
-             *
1655
-             * @since 1.0.0
1656
-             * @see 'geodir_before_tab_list'
1657
-             */
1658
-            do_action('geodir_after_tab_list');
1659
-            ?>
1643
+					/**
1644
+					 * Filter the current tab content.
1645
+					 *
1646
+					 * @since 1.0.0
1647
+					 */
1648
+					$arr_detail_page_tabs[$tab_index]['tab_content'] = apply_filters("geodir_modify_" . $detail_page_tab['tab_content'] . "_tab_content", ob_get_clean());
1649
+				} // end of if for is_display
1650
+			}// end of foreach
1651
+
1652
+			/**
1653
+			 * Called after the details page tab list headings, inside the `dl` tag.
1654
+			 *
1655
+			 * @since 1.0.0
1656
+			 * @see 'geodir_before_tab_list'
1657
+			 */
1658
+			do_action('geodir_after_tab_list');
1659
+			?>
1660 1660
             <?php if(!$tab_list){?></dl><?php }?>
1661 1661
         <ul class="geodir-tabs-content entry-content <?php if($tab_list){?>geodir-tabs-list<?php }?>" style="position:relative;">
1662 1662
             <?php
1663
-            foreach ($arr_detail_page_tabs as $detail_page_tab) {
1664
-                if ($detail_page_tab['is_display'] && !empty($detail_page_tab['tab_content'])) {
1665
-                    echo $detail_page_tab['tab_content'];
1666
-                }// end of if
1667
-            }// end of foreach
1668
-
1669
-            /**
1670
-             * Called after all the tab content is output in `li` tags, called before the closing `ul` tag.
1671
-             *
1672
-             * @since 1.0.0
1673
-             */
1674
-            do_action('geodir_add_tab_content'); ?>
1663
+			foreach ($arr_detail_page_tabs as $detail_page_tab) {
1664
+				if ($detail_page_tab['is_display'] && !empty($detail_page_tab['tab_content'])) {
1665
+					echo $detail_page_tab['tab_content'];
1666
+				}// end of if
1667
+			}// end of foreach
1668
+
1669
+			/**
1670
+			 * Called after all the tab content is output in `li` tags, called before the closing `ul` tag.
1671
+			 *
1672
+			 * @since 1.0.0
1673
+			 */
1674
+			do_action('geodir_add_tab_content'); ?>
1675 1675
         </ul>
1676 1676
         <!--gd-tabs-content ul end-->
1677 1677
     </div>
@@ -1694,7 +1694,7 @@  discard block
 block discarded – undo
1694 1694
         });
1695 1695
     </script>
1696 1696
     <?php
1697
-    }
1697
+	}
1698 1698
 }
1699 1699
 
1700 1700
 /**
@@ -1707,127 +1707,127 @@  discard block
 block discarded – undo
1707 1707
  */
1708 1708
 function geodir_exif($file)
1709 1709
 {
1710
-    if (empty($file) || !is_array($file)) {
1711
-        return $file;
1712
-    }
1710
+	if (empty($file) || !is_array($file)) {
1711
+		return $file;
1712
+	}
1713 1713
     
1714
-    $file_path = !empty($file['tmp_name']) ? sanitize_text_field($file['tmp_name']) : '';
1715
-    if (!($file_path && file_exists($file_path))) {
1716
-        return $file;
1717
-    }
1718
-    $file['file'] = $file_path;
1714
+	$file_path = !empty($file['tmp_name']) ? sanitize_text_field($file['tmp_name']) : '';
1715
+	if (!($file_path && file_exists($file_path))) {
1716
+		return $file;
1717
+	}
1718
+	$file['file'] = $file_path;
1719 1719
     
1720
-    if (!file_is_valid_image($file_path)) {
1721
-        return $file; // Bail if file is not an image.
1722
-    }
1720
+	if (!file_is_valid_image($file_path)) {
1721
+		return $file; // Bail if file is not an image.
1722
+	}
1723 1723
     
1724
-    if (!function_exists('wp_get_image_editor')) {
1725
-        return $file;
1726
-    }
1724
+	if (!function_exists('wp_get_image_editor')) {
1725
+		return $file;
1726
+	}
1727 1727
    
1728
-    $mime_type = $file['type'];
1729
-    $exif = array();
1730
-    if ($mime_type == 'image/jpeg' && function_exists('exif_read_data')) {
1731
-        try {
1732
-            $exif = exif_read_data($file_path);
1733
-        } catch(Exception $e) {
1734
-            $exif = array();
1735
-        }
1736
-    }
1728
+	$mime_type = $file['type'];
1729
+	$exif = array();
1730
+	if ($mime_type == 'image/jpeg' && function_exists('exif_read_data')) {
1731
+		try {
1732
+			$exif = exif_read_data($file_path);
1733
+		} catch(Exception $e) {
1734
+			$exif = array();
1735
+		}
1736
+	}
1737 1737
     
1738
-    $rotate = false;
1739
-    $flip = false;
1740
-    $modify = false;
1741
-    $orientation = 0;
1742
-    if (!empty($exif) && isset($exif['Orientation'])) {
1743
-        switch ((int)$exif['Orientation']) {
1744
-            case 1:
1745
-                // do nothing
1746
-                break;
1747
-            case 2:
1748
-                $flip = array(false, true);
1749
-                $modify = true;
1750
-                break;
1751
-            case 3:
1752
-                $orientation = -180;
1753
-                $rotate = true;
1754
-                $modify = true;
1755
-                break;
1756
-            case 4:
1757
-                $flip = array(true, false);
1758
-                $modify = true;
1759
-                break;
1760
-            case 5:
1761
-                $orientation = -90;
1762
-                $rotate = true;
1763
-                $flip = array(false, true);
1764
-                $modify = true;
1765
-                break;
1766
-            case 6:
1767
-                $orientation = -90;
1768
-                $rotate = true;
1769
-                $modify = true;
1770
-                break;
1771
-            case 7:
1772
-                $orientation = -270;
1773
-                $rotate = true;
1774
-                $flip = array(false, true);
1775
-                $modify = true;
1776
-                break;
1777
-            case 8:
1778
-            case 9:
1779
-                $orientation = -270;
1780
-                $rotate = true;
1781
-                $modify = true;
1782
-                break;
1783
-            default:
1784
-                $orientation = 0;
1785
-                $rotate = true;
1786
-                $modify = true;
1787
-                break;
1788
-        }
1789
-    }
1738
+	$rotate = false;
1739
+	$flip = false;
1740
+	$modify = false;
1741
+	$orientation = 0;
1742
+	if (!empty($exif) && isset($exif['Orientation'])) {
1743
+		switch ((int)$exif['Orientation']) {
1744
+			case 1:
1745
+				// do nothing
1746
+				break;
1747
+			case 2:
1748
+				$flip = array(false, true);
1749
+				$modify = true;
1750
+				break;
1751
+			case 3:
1752
+				$orientation = -180;
1753
+				$rotate = true;
1754
+				$modify = true;
1755
+				break;
1756
+			case 4:
1757
+				$flip = array(true, false);
1758
+				$modify = true;
1759
+				break;
1760
+			case 5:
1761
+				$orientation = -90;
1762
+				$rotate = true;
1763
+				$flip = array(false, true);
1764
+				$modify = true;
1765
+				break;
1766
+			case 6:
1767
+				$orientation = -90;
1768
+				$rotate = true;
1769
+				$modify = true;
1770
+				break;
1771
+			case 7:
1772
+				$orientation = -270;
1773
+				$rotate = true;
1774
+				$flip = array(false, true);
1775
+				$modify = true;
1776
+				break;
1777
+			case 8:
1778
+			case 9:
1779
+				$orientation = -270;
1780
+				$rotate = true;
1781
+				$modify = true;
1782
+				break;
1783
+			default:
1784
+				$orientation = 0;
1785
+				$rotate = true;
1786
+				$modify = true;
1787
+				break;
1788
+		}
1789
+	}
1790 1790
     
1791
-    $quality = null;
1792
-    /**
1793
-     * Filter the image quality.
1794
-     *
1795
-     * @since 1.5.7
1796
-     * @param int|null $quality Image Compression quality between 1-100% scale. Default null.
1797
-     * @param string $quality Image mime type.
1798
-     */
1799
-    $quality = apply_filters('geodir_image_upload_set_quality', $quality, $mime_type);
1800
-    if ($quality !== null) {
1801
-        $modify = true;
1802
-    }
1791
+	$quality = null;
1792
+	/**
1793
+	 * Filter the image quality.
1794
+	 *
1795
+	 * @since 1.5.7
1796
+	 * @param int|null $quality Image Compression quality between 1-100% scale. Default null.
1797
+	 * @param string $quality Image mime type.
1798
+	 */
1799
+	$quality = apply_filters('geodir_image_upload_set_quality', $quality, $mime_type);
1800
+	if ($quality !== null) {
1801
+		$modify = true;
1802
+	}
1803 1803
 
1804
-    if (!$modify) {
1805
-        return $file; // no change
1806
-    }
1804
+	if (!$modify) {
1805
+		return $file; // no change
1806
+	}
1807 1807
 
1808
-    $image = wp_get_image_editor($file_path);
1809
-    if (!is_wp_error($image)) {
1810
-        if ($rotate) {
1811
-            $image->rotate($orientation);
1812
-        }
1808
+	$image = wp_get_image_editor($file_path);
1809
+	if (!is_wp_error($image)) {
1810
+		if ($rotate) {
1811
+			$image->rotate($orientation);
1812
+		}
1813 1813
         
1814
-        if (!empty($flip)) {
1815
-            $image->flip($flip[0], $flip[1]);
1816
-        }
1814
+		if (!empty($flip)) {
1815
+			$image->flip($flip[0], $flip[1]);
1816
+		}
1817 1817
         
1818
-        if ($quality !== null) {
1819
-            $image->set_quality((int)$quality);
1820
-        }
1818
+		if ($quality !== null) {
1819
+			$image->set_quality((int)$quality);
1820
+		}
1821 1821
         
1822
-       $result = $image->save($file_path);
1823
-       if (!is_wp_error($result)) {
1824
-           $file['file'] = $result['path'];
1825
-           $file['tmp_name'] = $result['path'];
1826
-       }
1827
-    }
1822
+	   $result = $image->save($file_path);
1823
+	   if (!is_wp_error($result)) {
1824
+		   $file['file'] = $result['path'];
1825
+		   $file['tmp_name'] = $result['path'];
1826
+	   }
1827
+	}
1828 1828
     
1829
-    // The image orientation is fixed, pass it back for further processing
1830
-    return $file;
1829
+	// The image orientation is fixed, pass it back for further processing
1830
+	return $file;
1831 1831
 }
1832 1832
 
1833 1833
 /**
@@ -1846,138 +1846,138 @@  discard block
 block discarded – undo
1846 1846
  * @return string Returns the recent reviews html.
1847 1847
  */
1848 1848
 function geodir_get_recent_reviews($g_size = 60, $no_comments = 10, $comment_lenth = 60, $show_pass_post = false) {
1849
-    global $wpdb, $tablecomments, $tableposts, $rating_table_name, $gd_session;
1850
-    $tablecomments = $wpdb->comments;
1851
-    $tableposts = $wpdb->posts;
1852
-
1853
-    $comments_echo = '';
1854
-    $city_filter = '';
1855
-    $region_filter = '';
1856
-    $country_filter = '';
1857
-
1858
-    if ($gd_session->get('gd_multi_location')) {
1859
-        if ($gd_ses_country = $gd_session->get('gd_country')) {
1860
-            $country_filter = $wpdb->prepare(" AND r.post_country=%s ", str_replace("-", " ", $gd_ses_country));
1861
-        }
1849
+	global $wpdb, $tablecomments, $tableposts, $rating_table_name, $gd_session;
1850
+	$tablecomments = $wpdb->comments;
1851
+	$tableposts = $wpdb->posts;
1852
+
1853
+	$comments_echo = '';
1854
+	$city_filter = '';
1855
+	$region_filter = '';
1856
+	$country_filter = '';
1857
+
1858
+	if ($gd_session->get('gd_multi_location')) {
1859
+		if ($gd_ses_country = $gd_session->get('gd_country')) {
1860
+			$country_filter = $wpdb->prepare(" AND r.post_country=%s ", str_replace("-", " ", $gd_ses_country));
1861
+		}
1862 1862
 
1863
-        if ($gd_ses_region = $gd_session->get('gd_region')) {
1864
-            $region_filter = $wpdb->prepare(" AND r.post_region=%s ", str_replace("-", " ", $gd_ses_region));
1865
-        }
1863
+		if ($gd_ses_region = $gd_session->get('gd_region')) {
1864
+			$region_filter = $wpdb->prepare(" AND r.post_region=%s ", str_replace("-", " ", $gd_ses_region));
1865
+		}
1866 1866
 
1867
-        if ($gd_ses_city = $gd_session->get('gd_city')) {
1868
-            $city_filter = $wpdb->prepare(" AND r.post_city=%s ", str_replace("-", " ", $gd_ses_city));
1869
-        }
1870
-    }
1867
+		if ($gd_ses_city = $gd_session->get('gd_city')) {
1868
+			$city_filter = $wpdb->prepare(" AND r.post_city=%s ", str_replace("-", " ", $gd_ses_city));
1869
+		}
1870
+	}
1871 1871
 	
1872
-    $review_table = GEODIR_REVIEW_TABLE;
1873
-    $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";
1874
-
1875
-    $comments = $wpdb->get_results($request);
1876
-
1877
-    foreach ($comments as $comment) {
1878
-        // Set the extra comment info needed.
1879
-        $comment_extra = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID");
1880
-        //echo "SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID";
1881
-        $comment->comment_content = $comment_extra->comment_content;
1882
-        $comment->comment_author = $comment_extra->comment_author;
1883
-        $comment->comment_author_email = $comment_extra->comment_author_email;
1884
-
1885
-        $comment_id = '';
1886
-        $comment_id = $comment->comment_ID;
1887
-        $comment_content = strip_tags($comment->comment_content);
1888
-
1889
-        $comment_content = preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_content);
1890
-
1891
-        $permalink = get_permalink($comment->ID) . "#comment-" . $comment->comment_ID;
1892
-        $comment_author_email = $comment->comment_author_email;
1893
-        $comment_post_ID = $comment->post_id;
1894
-
1895
-        $na = true;
1896
-        if (function_exists('icl_object_id') && icl_object_id($comment_post_ID, $comment->post_type, true)) {
1897
-            $comment_post_ID2 = icl_object_id($comment_post_ID, $comment->post_type, false);
1898
-            if ($comment_post_ID == $comment_post_ID2) {
1899
-            } else {
1900
-                $na = false;
1901
-            }
1902
-        }
1872
+	$review_table = GEODIR_REVIEW_TABLE;
1873
+	$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";
1874
+
1875
+	$comments = $wpdb->get_results($request);
1876
+
1877
+	foreach ($comments as $comment) {
1878
+		// Set the extra comment info needed.
1879
+		$comment_extra = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID");
1880
+		//echo "SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID";
1881
+		$comment->comment_content = $comment_extra->comment_content;
1882
+		$comment->comment_author = $comment_extra->comment_author;
1883
+		$comment->comment_author_email = $comment_extra->comment_author_email;
1884
+
1885
+		$comment_id = '';
1886
+		$comment_id = $comment->comment_ID;
1887
+		$comment_content = strip_tags($comment->comment_content);
1888
+
1889
+		$comment_content = preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_content);
1890
+
1891
+		$permalink = get_permalink($comment->ID) . "#comment-" . $comment->comment_ID;
1892
+		$comment_author_email = $comment->comment_author_email;
1893
+		$comment_post_ID = $comment->post_id;
1894
+
1895
+		$na = true;
1896
+		if (function_exists('icl_object_id') && icl_object_id($comment_post_ID, $comment->post_type, true)) {
1897
+			$comment_post_ID2 = icl_object_id($comment_post_ID, $comment->post_type, false);
1898
+			if ($comment_post_ID == $comment_post_ID2) {
1899
+			} else {
1900
+				$na = false;
1901
+			}
1902
+		}
1903 1903
 
1904
-        $post_title = get_the_title($comment_post_ID);
1905
-        $permalink = get_permalink($comment_post_ID);
1906
-        $comment_permalink = $permalink . "#comment-" . $comment->comment_ID;
1907
-        $read_more = '<a class="comment_excerpt" href="' . $comment_permalink . '">' . __('Read more', 'geodirectory') . '</a>';
1904
+		$post_title = get_the_title($comment_post_ID);
1905
+		$permalink = get_permalink($comment_post_ID);
1906
+		$comment_permalink = $permalink . "#comment-" . $comment->comment_ID;
1907
+		$read_more = '<a class="comment_excerpt" href="' . $comment_permalink . '">' . __('Read more', 'geodirectory') . '</a>';
1908 1908
 
1909
-        $comment_content_length = strlen($comment_content);
1910
-        if ($comment_content_length > $comment_lenth) {
1911
-            $comment_excerpt = mb_substr($comment_content, 0, $comment_lenth) . '... ' . $read_more;
1912
-        } else {
1913
-            $comment_excerpt = $comment_content;
1914
-        }
1909
+		$comment_content_length = strlen($comment_content);
1910
+		if ($comment_content_length > $comment_lenth) {
1911
+			$comment_excerpt = mb_substr($comment_content, 0, $comment_lenth) . '... ' . $read_more;
1912
+		} else {
1913
+			$comment_excerpt = $comment_content;
1914
+		}
1915 1915
 
1916
-        if ($comment->user_id) {
1917
-            $user_profile_url = get_author_posts_url($comment->user_id);
1918
-        } else {
1919
-            $user_profile_url = '';
1920
-        }
1916
+		if ($comment->user_id) {
1917
+			$user_profile_url = get_author_posts_url($comment->user_id);
1918
+		} else {
1919
+			$user_profile_url = '';
1920
+		}
1921 1921
 
1922
-        if ($comment_id && $na) {
1923
-            $comments_echo .= '<li class="clearfix">';
1924
-            $comments_echo .= "<span class=\"li" . $comment_id . " geodir_reviewer_image\">";
1925
-            if (function_exists('get_avatar')) {
1926
-                if (!isset($comment->comment_type)) {
1927
-                    if ($user_profile_url) {
1928
-                        $comments_echo .= '<a href="' . $user_profile_url . '">';
1929
-                    }
1930
-                    $comments_echo .= get_avatar($comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1931
-                    if ($user_profile_url) {
1932
-                        $comments_echo .= '</a>';
1933
-                    }
1934
-                } elseif ((isset($comment->comment_type) && $comment->comment_type == 'trackback') || (isset($comment->comment_type) && $comment->comment_type == 'pingback')) {
1935
-                    if ($user_profile_url) {
1936
-                        $comments_echo .= '<a href="' . $user_profile_url . '">';
1937
-                    }
1938
-                    $comments_echo .= get_avatar($comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1939
-                }
1940
-            } elseif (function_exists('gravatar')) {
1941
-                if ($user_profile_url) {
1942
-                    $comments_echo .= '<a href="' . $user_profile_url . '">';
1943
-                }
1944
-                $comments_echo .= "<img src=\"";
1945
-                if ('' == $comment->comment_type) {
1946
-                    $comments_echo .= gravatar($comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1947
-                    if ($user_profile_url) {
1948
-                        $comments_echo .= '</a>';
1949
-                    }
1950
-                } elseif (('trackback' == $comment->comment_type) || ('pingback' == $comment->comment_type)) {
1951
-                    if ($user_profile_url) {
1952
-                        $comments_echo .= '<a href="' . $user_profile_url . '">';
1953
-                    }
1954
-                    $comments_echo .= gravatar($comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1955
-                    if ($user_profile_url) {
1956
-                        $comments_echo .= '</a>';
1957
-                    }
1958
-                }
1959
-                $comments_echo .= "\" alt=\"\" class=\"avatar\" />";
1960
-            }
1922
+		if ($comment_id && $na) {
1923
+			$comments_echo .= '<li class="clearfix">';
1924
+			$comments_echo .= "<span class=\"li" . $comment_id . " geodir_reviewer_image\">";
1925
+			if (function_exists('get_avatar')) {
1926
+				if (!isset($comment->comment_type)) {
1927
+					if ($user_profile_url) {
1928
+						$comments_echo .= '<a href="' . $user_profile_url . '">';
1929
+					}
1930
+					$comments_echo .= get_avatar($comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1931
+					if ($user_profile_url) {
1932
+						$comments_echo .= '</a>';
1933
+					}
1934
+				} elseif ((isset($comment->comment_type) && $comment->comment_type == 'trackback') || (isset($comment->comment_type) && $comment->comment_type == 'pingback')) {
1935
+					if ($user_profile_url) {
1936
+						$comments_echo .= '<a href="' . $user_profile_url . '">';
1937
+					}
1938
+					$comments_echo .= get_avatar($comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1939
+				}
1940
+			} elseif (function_exists('gravatar')) {
1941
+				if ($user_profile_url) {
1942
+					$comments_echo .= '<a href="' . $user_profile_url . '">';
1943
+				}
1944
+				$comments_echo .= "<img src=\"";
1945
+				if ('' == $comment->comment_type) {
1946
+					$comments_echo .= gravatar($comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1947
+					if ($user_profile_url) {
1948
+						$comments_echo .= '</a>';
1949
+					}
1950
+				} elseif (('trackback' == $comment->comment_type) || ('pingback' == $comment->comment_type)) {
1951
+					if ($user_profile_url) {
1952
+						$comments_echo .= '<a href="' . $user_profile_url . '">';
1953
+					}
1954
+					$comments_echo .= gravatar($comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1955
+					if ($user_profile_url) {
1956
+						$comments_echo .= '</a>';
1957
+					}
1958
+				}
1959
+				$comments_echo .= "\" alt=\"\" class=\"avatar\" />";
1960
+			}
1961 1961
 
1962
-            $comments_echo .= "</span>\n";
1963
-
1964
-            $comments_echo .= '<span class="geodir_reviewer_content">';
1965
-            if($comment->user_id){$comments_echo .= '<a href="'.get_author_posts_url( $comment->user_id ).'">';}
1966
-            $comments_echo .= '<span class="geodir_reviewer_author">' . $comment->comment_author . '</span> ';
1967
-            if($comment->user_id){$comments_echo .= '</a>';}
1968
-            $comments_echo .= '<span class="geodir_reviewer_reviewed">' . __('reviewed', 'geodirectory') . '</span> ';
1969
-            $comments_echo .= '<a href="' . $permalink . '" class="geodir_reviewer_title">' . $post_title . '</a>';
1970
-            $comments_echo .= geodir_get_rating_stars($comment->overall_rating, $comment_post_ID);
1971
-            $comments_echo .= '<p class="geodir_reviewer_text">' . $comment_excerpt . '';
1972
-            //echo preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_excerpt);
1973
-            $comments_echo .= '</p>';
1974
-
1975
-            $comments_echo .= "</span>\n";
1976
-            $comments_echo .= '</li>';
1977
-        }
1978
-    }
1962
+			$comments_echo .= "</span>\n";
1963
+
1964
+			$comments_echo .= '<span class="geodir_reviewer_content">';
1965
+			if($comment->user_id){$comments_echo .= '<a href="'.get_author_posts_url( $comment->user_id ).'">';}
1966
+			$comments_echo .= '<span class="geodir_reviewer_author">' . $comment->comment_author . '</span> ';
1967
+			if($comment->user_id){$comments_echo .= '</a>';}
1968
+			$comments_echo .= '<span class="geodir_reviewer_reviewed">' . __('reviewed', 'geodirectory') . '</span> ';
1969
+			$comments_echo .= '<a href="' . $permalink . '" class="geodir_reviewer_title">' . $post_title . '</a>';
1970
+			$comments_echo .= geodir_get_rating_stars($comment->overall_rating, $comment_post_ID);
1971
+			$comments_echo .= '<p class="geodir_reviewer_text">' . $comment_excerpt . '';
1972
+			//echo preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_excerpt);
1973
+			$comments_echo .= '</p>';
1974
+
1975
+			$comments_echo .= "</span>\n";
1976
+			$comments_echo .= '</li>';
1977
+		}
1978
+	}
1979 1979
 
1980
-    return $comments_echo;
1980
+	return $comments_echo;
1981 1981
 }
1982 1982
 
1983 1983
 /**
@@ -1989,29 +1989,29 @@  discard block
 block discarded – undo
1989 1989
  */
1990 1990
 function geodir_home_map_cats_key_value_array()
1991 1991
 {
1992
-    $post_types = geodir_get_posttypes('object');
1993
-
1994
-    $return = array();
1995
-    if (!empty($post_types)) {
1996
-        foreach ($post_types as $key => $post_type) {
1997
-            $cpt_name = __($post_type->labels->singular_name, 'geodirectory');
1998
-            $post_type_name =   sprintf(__('%s Categories', 'geodirectory'),$cpt_name);
1999
-            $taxonomies = geodir_get_taxonomies($key);
2000
-            $cat_taxonomy = !empty($taxonomies[0]) ? $taxonomies[0] : NULL;
2001
-            $cat_terms = $cat_taxonomy ? get_terms($cat_taxonomy) : NULL;
2002
-
2003
-            if (!empty($cat_terms)) {
2004
-                $return['optgroup_start-' . $key] = $post_type_name;
2005
-
2006
-                foreach ($cat_terms as $cat_term) {
2007
-                    $return[$key . '_' . $cat_term->term_id] = $cat_term->name;
2008
-                }
1992
+	$post_types = geodir_get_posttypes('object');
2009 1993
 
2010
-                $return['optgroup_end-' . $key] = $post_type_name;
2011
-            }
2012
-        }
2013
-    }
2014
-    return $return;
1994
+	$return = array();
1995
+	if (!empty($post_types)) {
1996
+		foreach ($post_types as $key => $post_type) {
1997
+			$cpt_name = __($post_type->labels->singular_name, 'geodirectory');
1998
+			$post_type_name =   sprintf(__('%s Categories', 'geodirectory'),$cpt_name);
1999
+			$taxonomies = geodir_get_taxonomies($key);
2000
+			$cat_taxonomy = !empty($taxonomies[0]) ? $taxonomies[0] : NULL;
2001
+			$cat_terms = $cat_taxonomy ? get_terms($cat_taxonomy) : NULL;
2002
+
2003
+			if (!empty($cat_terms)) {
2004
+				$return['optgroup_start-' . $key] = $post_type_name;
2005
+
2006
+				foreach ($cat_terms as $cat_term) {
2007
+					$return[$key . '_' . $cat_term->term_id] = $cat_term->name;
2008
+				}
2009
+
2010
+				$return['optgroup_end-' . $key] = $post_type_name;
2011
+			}
2012
+		}
2013
+	}
2014
+	return $return;
2015 2015
 }
2016 2016
 
2017 2017
 /**
@@ -2023,7 +2023,7 @@  discard block
 block discarded – undo
2023 2023
  */
2024 2024
 function geodir_twitter_tweet_button()
2025 2025
 {
2026
-    ?>
2026
+	?>
2027 2027
     <a href="http://twitter.com/share"
2028 2028
        class="twitter-share-button"><?php _e('Tweet', 'geodirectory'); ?></a>
2029 2029
     <script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
@@ -2040,11 +2040,11 @@  discard block
 block discarded – undo
2040 2040
  * @global object $post The current post object.
2041 2041
  */
2042 2042
 function geodir_fb_like_button() {
2043
-    global $post;
2044
-    ?>
2043
+	global $post;
2044
+	?>
2045 2045
     <iframe <?php if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) {
2046
-        echo 'allowtransparency="true"';
2047
-    } ?> class="facebook"
2046
+		echo 'allowtransparency="true"';
2047
+	} ?> class="facebook"
2048 2048
          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"
2049 2049
          style="border:none; overflow:hidden; width:100px; height:20px"></iframe>
2050 2050
     <?php
@@ -2059,7 +2059,7 @@  discard block
 block discarded – undo
2059 2059
  * @package GeoDirectory
2060 2060
  */
2061 2061
 function geodir_google_plus_button() {
2062
-    ?>
2062
+	?>
2063 2063
     <div id="plusone-div" class="g-plusone" data-size="medium"></div>
2064 2064
     <script type="text/javascript">
2065 2065
         (function () {
@@ -2084,8 +2084,8 @@  discard block
 block discarded – undo
2084 2084
  * @global object $post The current post object.
2085 2085
  */
2086 2086
 function geodir_share_this_button_code() {
2087
-    global $post;
2088
-    ?>
2087
+	global $post;
2088
+	?>
2089 2089
     <div class="addthis_toolbox addthis_default_style">
2090 2090
         <span id='st_sharethis'></span>
2091 2091
         <script type="text/javascript">var switchTo5x = false;</script>
@@ -2110,8 +2110,8 @@  discard block
 block discarded – undo
2110 2110
 }
2111 2111
 
2112 2112
 function geodir_listing_bounce_map_pin_on_hover() {
2113
-    if(get_option('geodir_listing_hover_bounce_map_pin',true)) {
2114
-        ?>
2113
+	if(get_option('geodir_listing_hover_bounce_map_pin',true)) {
2114
+		?>
2115 2115
         <script>
2116 2116
             jQuery(function ($) {
2117 2117
                 if (typeof(animate_marker) == 'function') {
@@ -2125,27 +2125,27 @@  discard block
 block discarded – undo
2125 2125
             });
2126 2126
         </script>
2127 2127
         <?php
2128
-    }
2128
+	}
2129 2129
 }
2130 2130
 add_action('geodir_after_listing_listview','geodir_listing_bounce_map_pin_on_hover',10);
2131 2131
 
2132 2132
 add_action('geodir_after_favorite_html','geodir_output_favourite_html_listings',1,1);
2133 2133
 function geodir_output_favourite_html_listings( $post_id){
2134
-    geodir_favourite_html('', $post_id);
2134
+	geodir_favourite_html('', $post_id);
2135 2135
 }
2136 2136
 
2137 2137
 add_action( 'geodir_listing_after_pinpoint', 'geodir_output_pinpoint_html_listings', 1, 2);
2138 2138
 function geodir_output_pinpoint_html_listings( $post_id, $post){
2139
-    global $wp_query;
2139
+	global $wp_query;
2140 2140
 
2141
-    $show_pin_point = $wp_query->is_main_query();
2141
+	$show_pin_point = $wp_query->is_main_query();
2142 2142
     
2143
-    if (!empty($show_pin_point) && is_active_widget(false, "", "geodir_map_v3_listing_map")) {
2144
-        $term_icon_url = get_tax_meta($post->default_category, 'ct_cat_icon', false, $post->post_type);
2145
-        $marker_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : get_option('geodir_default_marker_icon');
2146
-        ?>
2143
+	if (!empty($show_pin_point) && is_active_widget(false, "", "geodir_map_v3_listing_map")) {
2144
+		$term_icon_url = get_tax_meta($post->default_category, 'ct_cat_icon', false, $post->post_type);
2145
+		$marker_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : get_option('geodir_default_marker_icon');
2146
+		?>
2147 2147
         <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>
2148 2148
         <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>
2149 2149
         <?php
2150
-    }
2150
+	}
2151 2151
 }
2152 2152
\ No newline at end of file
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.
Indentation   +3388 added lines, -3388 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,365 +933,365 @@  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
-                $page_title = defined('GD_LOCATION') ? GD_LOCATION : __('Location', 'geodirectory');
1227
-            }
1228
-
1229
-            $breadcrumb .= '<li>' . $separator;
1230
-            $breadcrumb .= stripslashes_deep($page_title);
1231
-            $breadcrumb .= '</li>';
1232
-        } else if (is_tag()) {
1233
-            $breadcrumb .=  "<li> " . $separator . single_tag_title('',false) . '</li>';
1234
-        } else if (is_day()) {
1235
-            $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1236
-            the_time('F jS, Y');
1237
-            $breadcrumb .= '</li>';
1238
-        } else if (is_month()) {
1239
-            $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1240
-            the_time('F, Y');
1241
-            $breadcrumb .= '</li>';
1242
-        } else if (is_year()) {
1243
-            $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1244
-            the_time('Y');
1245
-            $breadcrumb .= '</li>';
1246
-        } else if (is_author()) {
1247
-            $breadcrumb .= "<li> " . $separator . __(" Author Archive", 'geodirectory');
1248
-            $breadcrumb .= '</li>';
1249
-        } else if (isset($_GET['paged']) && !empty($_GET['paged'])) {
1250
-            $breadcrumb .= "<li>" . $separator . __("Blog Archives", 'geodirectory');
1251
-            $breadcrumb .= '</li>';
1252
-        } else if (is_search()) {
1253
-            $breadcrumb .= "<li> " . $separator . __(" Search Results", 'geodirectory');
1254
-            $breadcrumb .= '</li>';
1255
-        }
1256
-        $breadcrumb .= '</ul></div>';
1257
-
1258
-        /**
1259
-         * Filter breadcrumb html output.
1260
-         *
1261
-         * @since 1.0.0
1262
-         * @param string $breadcrumb Breadcrumb HTML.
1263
-         * @param string $separator Breadcrumb separator.
1264
-         */
1265
-        echo $breadcrumb = apply_filters('geodir_breadcrumb', $breadcrumb, $separator);
1266
-    }
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
+				$page_title = defined('GD_LOCATION') ? GD_LOCATION : __('Location', 'geodirectory');
1227
+			}
1228
+
1229
+			$breadcrumb .= '<li>' . $separator;
1230
+			$breadcrumb .= stripslashes_deep($page_title);
1231
+			$breadcrumb .= '</li>';
1232
+		} else if (is_tag()) {
1233
+			$breadcrumb .=  "<li> " . $separator . single_tag_title('',false) . '</li>';
1234
+		} else if (is_day()) {
1235
+			$breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1236
+			the_time('F jS, Y');
1237
+			$breadcrumb .= '</li>';
1238
+		} else if (is_month()) {
1239
+			$breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1240
+			the_time('F, Y');
1241
+			$breadcrumb .= '</li>';
1242
+		} else if (is_year()) {
1243
+			$breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1244
+			the_time('Y');
1245
+			$breadcrumb .= '</li>';
1246
+		} else if (is_author()) {
1247
+			$breadcrumb .= "<li> " . $separator . __(" Author Archive", 'geodirectory');
1248
+			$breadcrumb .= '</li>';
1249
+		} else if (isset($_GET['paged']) && !empty($_GET['paged'])) {
1250
+			$breadcrumb .= "<li>" . $separator . __("Blog Archives", 'geodirectory');
1251
+			$breadcrumb .= '</li>';
1252
+		} else if (is_search()) {
1253
+			$breadcrumb .= "<li> " . $separator . __(" Search Results", 'geodirectory');
1254
+			$breadcrumb .= '</li>';
1255
+		}
1256
+		$breadcrumb .= '</ul></div>';
1257
+
1258
+		/**
1259
+		 * Filter breadcrumb html output.
1260
+		 *
1261
+		 * @since 1.0.0
1262
+		 * @param string $breadcrumb Breadcrumb HTML.
1263
+		 * @param string $separator Breadcrumb separator.
1264
+		 */
1265
+		echo $breadcrumb = apply_filters('geodir_breadcrumb', $breadcrumb, $separator);
1266
+	}
1267 1267
 }
1268 1268
 
1269 1269
 
1270 1270
 add_action("admin_init", "geodir_allow_wpadmin"); // check user is admin
1271 1271
 if (!function_exists('geodir_allow_wpadmin')) {
1272
-    /**
1273
-     * Allow only admins to access wp-admin.
1274
-     *
1275
-     * Normal users will be redirected to home page.
1276
-     *
1277
-     * @since 1.0.0
1278
-     * @package GeoDirectory
1279
-     * @global object $wpdb WordPress Database object.
1280
-     */
1281
-    function geodir_allow_wpadmin()
1282
-    {
1283
-        global $wpdb;
1284
-        if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) // checking action in request to allow ajax request go through
1285
-        {
1286
-            if (current_user_can('manage_options')) {
1287
-            } else {
1288
-
1289
-                wp_redirect(home_url());
1290
-                exit;
1291
-            }
1292
-
1293
-        }
1294
-    }
1272
+	/**
1273
+	 * Allow only admins to access wp-admin.
1274
+	 *
1275
+	 * Normal users will be redirected to home page.
1276
+	 *
1277
+	 * @since 1.0.0
1278
+	 * @package GeoDirectory
1279
+	 * @global object $wpdb WordPress Database object.
1280
+	 */
1281
+	function geodir_allow_wpadmin()
1282
+	{
1283
+		global $wpdb;
1284
+		if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) // checking action in request to allow ajax request go through
1285
+		{
1286
+			if (current_user_can('manage_options')) {
1287
+			} else {
1288
+
1289
+				wp_redirect(home_url());
1290
+				exit;
1291
+			}
1292
+
1293
+		}
1294
+	}
1295 1295
 }
1296 1296
 
1297 1297
 
@@ -1305,76 +1305,76 @@  discard block
 block discarded – undo
1305 1305
  */
1306 1306
 function fetch_remote_file($url)
1307 1307
 {
1308
-    // extract the file name and extension from the url
1309
-    require_once(ABSPATH . 'wp-includes/pluggable.php');
1310
-    $file_name = basename($url);
1311
-    if (strpos($file_name, '?') !== false) {
1312
-        list($file_name) = explode('?', $file_name);
1313
-    }
1314
-    $dummy = false;
1315
-    $add_to_cache = false;
1316
-    $key = null;
1317
-    if (strpos($url, '/dummy/') !== false) {
1318
-        $dummy = true;
1319
-        $key = "dummy_".str_replace('.', '_', $file_name);
1320
-        $value = get_transient('cached_dummy_images');
1321
-        if ($value) {
1322
-            if (isset($value[$key])) {
1323
-                return $value[$key];
1324
-            } else {
1325
-                $add_to_cache = true;
1326
-            }
1327
-        } else {
1328
-            $add_to_cache = true;
1329
-        }
1330
-    }
1331
-
1332
-    // get placeholder file in the upload dir with a unique, sanitized filename
1333
-
1334
-    $post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : '';
1335
-
1336
-    $upload = wp_upload_bits($file_name, 0, '', $post_upload_date);
1337
-    if ($upload['error'])
1338
-        return new WP_Error('upload_dir_error', $upload['error']);
1339
-
1340
-    // fetch the remote url and write it to the placeholder file
1341
-    $headers = wp_remote_get($url, array('stream' => true,'filename' => $upload['file']));
1342
-
1343
-    $log_message = '';
1344
-    $filesize = filesize($upload['file']);
1345
-    // request failed
1346
-    if (!$headers) {
1347
-        $log_message = __('Remote server did not respond', 'geodirectory');
1348
-    }
1349
-    // make sure the fetch was successful
1350
-    elseif ($headers['response']['code'] != '200') {
1351
-        $log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
1352
-    }
1353
-    elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
1354
-        $log_message =  __('Remote file is incorrect size', 'geodirectory');
1355
-    }
1356
-    elseif (0 == $filesize) {
1357
-        $log_message = __('Zero size file downloaded', 'geodirectory');
1358
-    }
1359
-
1360
-    if($log_message){
1361
-        $del = unlink($upload['file']);
1362
-        if(!$del){geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory'));}
1363
-        return new WP_Error('import_file_error',$log_message );
1364
-    }
1365
-
1366
-    if ($dummy && $add_to_cache && is_array($upload)) {
1367
-        $images = get_transient('cached_dummy_images');
1368
-        if(is_array($images))
1369
-            $images[$key] = $upload;
1370
-        else
1371
-            $images = array($key => $upload);
1372
-
1373
-        //setting the cache using the WP Transient API
1374
-        set_transient('cached_dummy_images', $images, 60 * 10); //10 minutes cache
1375
-    }
1376
-
1377
-    return $upload;
1308
+	// extract the file name and extension from the url
1309
+	require_once(ABSPATH . 'wp-includes/pluggable.php');
1310
+	$file_name = basename($url);
1311
+	if (strpos($file_name, '?') !== false) {
1312
+		list($file_name) = explode('?', $file_name);
1313
+	}
1314
+	$dummy = false;
1315
+	$add_to_cache = false;
1316
+	$key = null;
1317
+	if (strpos($url, '/dummy/') !== false) {
1318
+		$dummy = true;
1319
+		$key = "dummy_".str_replace('.', '_', $file_name);
1320
+		$value = get_transient('cached_dummy_images');
1321
+		if ($value) {
1322
+			if (isset($value[$key])) {
1323
+				return $value[$key];
1324
+			} else {
1325
+				$add_to_cache = true;
1326
+			}
1327
+		} else {
1328
+			$add_to_cache = true;
1329
+		}
1330
+	}
1331
+
1332
+	// get placeholder file in the upload dir with a unique, sanitized filename
1333
+
1334
+	$post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : '';
1335
+
1336
+	$upload = wp_upload_bits($file_name, 0, '', $post_upload_date);
1337
+	if ($upload['error'])
1338
+		return new WP_Error('upload_dir_error', $upload['error']);
1339
+
1340
+	// fetch the remote url and write it to the placeholder file
1341
+	$headers = wp_remote_get($url, array('stream' => true,'filename' => $upload['file']));
1342
+
1343
+	$log_message = '';
1344
+	$filesize = filesize($upload['file']);
1345
+	// request failed
1346
+	if (!$headers) {
1347
+		$log_message = __('Remote server did not respond', 'geodirectory');
1348
+	}
1349
+	// make sure the fetch was successful
1350
+	elseif ($headers['response']['code'] != '200') {
1351
+		$log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
1352
+	}
1353
+	elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
1354
+		$log_message =  __('Remote file is incorrect size', 'geodirectory');
1355
+	}
1356
+	elseif (0 == $filesize) {
1357
+		$log_message = __('Zero size file downloaded', 'geodirectory');
1358
+	}
1359
+
1360
+	if($log_message){
1361
+		$del = unlink($upload['file']);
1362
+		if(!$del){geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory'));}
1363
+		return new WP_Error('import_file_error',$log_message );
1364
+	}
1365
+
1366
+	if ($dummy && $add_to_cache && is_array($upload)) {
1367
+		$images = get_transient('cached_dummy_images');
1368
+		if(is_array($images))
1369
+			$images[$key] = $upload;
1370
+		else
1371
+			$images = array($key => $upload);
1372
+
1373
+		//setting the cache using the WP Transient API
1374
+		set_transient('cached_dummy_images', $images, 60 * 10); //10 minutes cache
1375
+	}
1376
+
1377
+	return $upload;
1378 1378
 }
1379 1379
 
1380 1380
 /**
@@ -1386,21 +1386,21 @@  discard block
 block discarded – undo
1386 1386
  */
1387 1387
 function geodir_max_upload_size()
1388 1388
 {
1389
-    $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
1390
-
1391
-    if ($max_filesize > 0 && $max_filesize < 1) {
1392
-        $max_filesize = (int)($max_filesize * 1024) . 'kb';
1393
-    } else {
1394
-        $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
1395
-    }
1396
-
1397
-    /**
1398
-     * Filter default image upload size limit.
1399
-     *
1400
-     * @since 1.0.0
1401
-     * @param string $max_filesize Max file upload size. Ex. 10mb, 512kb.
1402
-     */
1403
-    return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
1389
+	$max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
1390
+
1391
+	if ($max_filesize > 0 && $max_filesize < 1) {
1392
+		$max_filesize = (int)($max_filesize * 1024) . 'kb';
1393
+	} else {
1394
+		$max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
1395
+	}
1396
+
1397
+	/**
1398
+	 * Filter default image upload size limit.
1399
+	 *
1400
+	 * @since 1.0.0
1401
+	 * @param string $max_filesize Max file upload size. Ex. 10mb, 512kb.
1402
+	 */
1403
+	return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
1404 1404
 }
1405 1405
 
1406 1406
 /**
@@ -1414,11 +1414,11 @@  discard block
 block discarded – undo
1414 1414
  */
1415 1415
 function geodir_dummy_folder_exists()
1416 1416
 {
1417
-    $path = geodir_plugin_path() . '/geodirectory-admin/dummy/';
1418
-    if (!is_dir($path))
1419
-        return false;
1420
-    else
1421
-        return true;
1417
+	$path = geodir_plugin_path() . '/geodirectory-admin/dummy/';
1418
+	if (!is_dir($path))
1419
+		return false;
1420
+	else
1421
+		return true;
1422 1422
 
1423 1423
 }
1424 1424
 
@@ -1433,290 +1433,290 @@  discard block
 block discarded – undo
1433 1433
  */
1434 1434
 function  geodir_get_author_info($aid)
1435 1435
 {
1436
-    global $wpdb;
1437
-    /*$infosql = "select * from $wpdb->users where ID=$aid";*/
1438
-    $infosql = $wpdb->prepare("select * from $wpdb->users where ID=%d", array($aid));
1439
-    $info = $wpdb->get_results($infosql);
1440
-    if ($info) {
1441
-        return $info[0];
1442
-    }
1436
+	global $wpdb;
1437
+	/*$infosql = "select * from $wpdb->users where ID=$aid";*/
1438
+	$infosql = $wpdb->prepare("select * from $wpdb->users where ID=%d", array($aid));
1439
+	$info = $wpdb->get_results($infosql);
1440
+	if ($info) {
1441
+		return $info[0];
1442
+	}
1443 1443
 }
1444 1444
 
1445 1445
 if (!function_exists('adminEmail')) {
1446
-    /**
1447
-     * Send emails to client on post submission, renew etc.
1448
-     *
1449
-     * @since 1.0.0
1450
-     * @package GeoDirectory
1451
-     * @global object $wpdb WordPress Database object.
1452
-     * @param int|string $page_id Page ID.
1453
-     * @param int|string $user_id User ID.
1454
-     * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1455
-     * @param string $custom_1 Custom data to be sent.
1456
-     */
1457
-    function adminEmail($page_id, $user_id, $message_type, $custom_1 = '')
1458
-    {
1459
-        global $wpdb;
1460
-        if ($message_type == 'expiration') {
1461
-            $subject = stripslashes(__(get_option('renew_email_subject'),'geodirectory'));
1462
-            $client_message = stripslashes(__(get_option('renew_email_content'),'geodirectory'));
1463
-        } elseif ($message_type == 'post_submited') {
1464
-            $subject = __(get_option('post_submited_success_email_subject_admin'),'geodirectory');
1465
-            $client_message = __(get_option('post_submited_success_email_content_admin'),'geodirectory');
1466
-        } elseif ($message_type == 'renew') {
1467
-            $subject = __(get_option('post_renew_success_email_subject_admin'),'geodirectory');
1468
-            $client_message = __(get_option('post_renew_success_email_content_admin'),'geodirectory');
1469
-        } elseif ($message_type == 'upgrade') {
1470
-            $subject = __(get_option('post_upgrade_success_email_subject_admin'),'geodirectory');
1471
-            $client_message = __(get_option('post_upgrade_success_email_content_admin'),'geodirectory');
1472
-        } elseif ($message_type == 'claim_approved') {
1473
-            $subject = __(get_option('claim_approved_email_subject'),'geodirectory');
1474
-            $client_message = __(get_option('claim_approved_email_content'),'geodirectory');
1475
-        } elseif ($message_type == 'claim_rejected') {
1476
-            $subject = __(get_option('claim_rejected_email_subject'),'geodirectory');
1477
-            $client_message = __(get_option('claim_rejected_email_content'),'geodirectory');
1478
-        } elseif ($message_type == 'claim_requested') {
1479
-            $subject = __(get_option('claim_email_subject_admin'),'geodirectory');
1480
-            $client_message = __(get_option('claim_email_content_admin'),'geodirectory');
1481
-        } elseif ($message_type == 'auto_claim') {
1482
-            $subject = __(get_option('auto_claim_email_subject'),'geodirectory');
1483
-            $client_message = __(get_option('auto_claim_email_content'),'geodirectory');
1484
-        } elseif ($message_type == 'payment_success') {
1485
-            $subject = __(get_option('post_payment_success_admin_email_subject'),'geodirectory');
1486
-            $client_message = __(get_option('post_payment_success_admin_email_content'),'geodirectory');
1487
-        } elseif ($message_type == 'payment_fail') {
1488
-            $subject = __(get_option('post_payment_fail_admin_email_subject'),'geodirectory');
1489
-            $client_message = __(get_option('post_payment_fail_admin_email_content'),'geodirectory');
1490
-        }
1491
-        $transaction_details = $custom_1;
1492
-        $fromEmail = get_option('site_email');
1493
-        $fromEmailName = get_site_emailName();
1446
+	/**
1447
+	 * Send emails to client on post submission, renew etc.
1448
+	 *
1449
+	 * @since 1.0.0
1450
+	 * @package GeoDirectory
1451
+	 * @global object $wpdb WordPress Database object.
1452
+	 * @param int|string $page_id Page ID.
1453
+	 * @param int|string $user_id User ID.
1454
+	 * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1455
+	 * @param string $custom_1 Custom data to be sent.
1456
+	 */
1457
+	function adminEmail($page_id, $user_id, $message_type, $custom_1 = '')
1458
+	{
1459
+		global $wpdb;
1460
+		if ($message_type == 'expiration') {
1461
+			$subject = stripslashes(__(get_option('renew_email_subject'),'geodirectory'));
1462
+			$client_message = stripslashes(__(get_option('renew_email_content'),'geodirectory'));
1463
+		} elseif ($message_type == 'post_submited') {
1464
+			$subject = __(get_option('post_submited_success_email_subject_admin'),'geodirectory');
1465
+			$client_message = __(get_option('post_submited_success_email_content_admin'),'geodirectory');
1466
+		} elseif ($message_type == 'renew') {
1467
+			$subject = __(get_option('post_renew_success_email_subject_admin'),'geodirectory');
1468
+			$client_message = __(get_option('post_renew_success_email_content_admin'),'geodirectory');
1469
+		} elseif ($message_type == 'upgrade') {
1470
+			$subject = __(get_option('post_upgrade_success_email_subject_admin'),'geodirectory');
1471
+			$client_message = __(get_option('post_upgrade_success_email_content_admin'),'geodirectory');
1472
+		} elseif ($message_type == 'claim_approved') {
1473
+			$subject = __(get_option('claim_approved_email_subject'),'geodirectory');
1474
+			$client_message = __(get_option('claim_approved_email_content'),'geodirectory');
1475
+		} elseif ($message_type == 'claim_rejected') {
1476
+			$subject = __(get_option('claim_rejected_email_subject'),'geodirectory');
1477
+			$client_message = __(get_option('claim_rejected_email_content'),'geodirectory');
1478
+		} elseif ($message_type == 'claim_requested') {
1479
+			$subject = __(get_option('claim_email_subject_admin'),'geodirectory');
1480
+			$client_message = __(get_option('claim_email_content_admin'),'geodirectory');
1481
+		} elseif ($message_type == 'auto_claim') {
1482
+			$subject = __(get_option('auto_claim_email_subject'),'geodirectory');
1483
+			$client_message = __(get_option('auto_claim_email_content'),'geodirectory');
1484
+		} elseif ($message_type == 'payment_success') {
1485
+			$subject = __(get_option('post_payment_success_admin_email_subject'),'geodirectory');
1486
+			$client_message = __(get_option('post_payment_success_admin_email_content'),'geodirectory');
1487
+		} elseif ($message_type == 'payment_fail') {
1488
+			$subject = __(get_option('post_payment_fail_admin_email_subject'),'geodirectory');
1489
+			$client_message = __(get_option('post_payment_fail_admin_email_content'),'geodirectory');
1490
+		}
1491
+		$transaction_details = $custom_1;
1492
+		$fromEmail = get_option('site_email');
1493
+		$fromEmailName = get_site_emailName();
1494 1494
 //$alivedays = get_post_meta($page_id,'alive_days',true);
1495
-        $pkg_limit = get_property_price_info_listing($page_id);
1496
-        $alivedays = $pkg_limit['days'];
1497
-        $productlink = get_permalink($page_id);
1498
-        $post_info = get_post($page_id);
1499
-        $post_date = date('dS F,Y', strtotime($post_info->post_date));
1500
-        $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1501
-        $loginurl = geodir_login_url();
1502
-        $loginurl_link = '<a href="' . $loginurl . '">login</a>';
1503
-        $siteurl = home_url();
1504
-        $siteurl_link = '<a href="' . $siteurl . '">' . $fromEmailName . '</a>';
1505
-        $user_info = get_userdata($user_id);
1506
-        $user_email = $user_info->user_email;
1507
-        $display_name = geodir_get_client_name($user_id);
1508
-        $user_login = $user_info->user_login;
1509
-        $number_of_grace_days = get_option('ptthemes_listing_preexpiry_notice_days');
1510
-        if ($number_of_grace_days == '') {
1511
-            $number_of_grace_days = 1;
1512
-        }
1513
-        if ($post_info->post_type == 'event') {
1514
-            $post_type = 'event';
1515
-        } else {
1516
-            $post_type = 'listing';
1517
-        }
1518
-        $renew_link = '<a href="' . $siteurl . '?ptype=post_' . $post_type . '&renew=1&pid=' . $page_id . '">' . RENEW_LINK . '</a>';
1519
-        $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#]');
1520
-        $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);
1521
-        $client_message = str_replace($search_array, $replace_array, $client_message);
1522
-        $subject = str_replace($search_array, $replace_array, $subject);
1523
-        $headers = 'MIME-Version: 1.0' . "\r\n";
1524
-        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1525
-        $headers .= 'From: ' . $fromEmailName . ' <' . $fromEmail . '>' . "\r\n";
1526
-
1527
-        $to = $fromEmail;
1528
-        $message = $client_message;
1529
-
1530
-
1531
-        /**
1532
-         * Filter the admin email to address.
1533
-         *
1534
-         * @since 1.6.1
1535
-         * @package GeoDirectory
1536
-         * @param string $to The email address the email is being sent to.
1537
-         * @param int|string $page_id Page ID.
1538
-         * @param int|string $user_id User ID.
1539
-         * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1540
-         * @param string $custom_1 Custom data to be sent.
1541
-         */
1542
-        $to = apply_filters('geodir_adminEmail_to',$to,$page_id, $user_id, $message_type, $custom_1 );
1543
-        /**
1544
-         * Filter the admin email subject.
1545
-         *
1546
-         * @since 1.6.1
1547
-         * @package GeoDirectory_Payment_Manager
1548
-         * @param string $subject The email subject.
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
-        $subject = apply_filters('geodir_adminEmail_subject',$subject,$page_id, $user_id, $message_type, $custom_1);
1555
-        /**
1556
-         * Filter the admin email message.
1557
-         *
1558
-         * @since 1.6.1
1559
-         * @package GeoDirectory_Payment_Manager
1560
-         * @param string $message The email message text.
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
-        $message = apply_filters('geodir_adminEmail_message',$message,$page_id, $user_id, $message_type, $custom_1);
1567
-        /**
1568
-         * Filter the admin email headers.
1569
-         *
1570
-         * @since 1.6.1
1571
-         * @package GeoDirectory_Payment_Manager
1572
-         * @param string $headers The email headers.
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
-        $headers = apply_filters('geodir_adminEmail_headers',$headers,$page_id, $user_id, $message_type, $custom_1);
1579
-
1580
-
1581
-
1582
-        $sent = wp_mail($to, $subject, $message, $headers);
1583
-        if( ! $sent ) {
1584
-            if ( is_array( $to ) ) {
1585
-                $to = implode( ',', $to );
1586
-            }
1587
-            $log_message = sprintf(
1588
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1589
-                $message_type,
1590
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1591
-                $to,
1592
-                $subject
1593
-            );
1594
-            geodir_error_log( $log_message );
1595
-        }
1596
-    }
1495
+		$pkg_limit = get_property_price_info_listing($page_id);
1496
+		$alivedays = $pkg_limit['days'];
1497
+		$productlink = get_permalink($page_id);
1498
+		$post_info = get_post($page_id);
1499
+		$post_date = date('dS F,Y', strtotime($post_info->post_date));
1500
+		$listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1501
+		$loginurl = geodir_login_url();
1502
+		$loginurl_link = '<a href="' . $loginurl . '">login</a>';
1503
+		$siteurl = home_url();
1504
+		$siteurl_link = '<a href="' . $siteurl . '">' . $fromEmailName . '</a>';
1505
+		$user_info = get_userdata($user_id);
1506
+		$user_email = $user_info->user_email;
1507
+		$display_name = geodir_get_client_name($user_id);
1508
+		$user_login = $user_info->user_login;
1509
+		$number_of_grace_days = get_option('ptthemes_listing_preexpiry_notice_days');
1510
+		if ($number_of_grace_days == '') {
1511
+			$number_of_grace_days = 1;
1512
+		}
1513
+		if ($post_info->post_type == 'event') {
1514
+			$post_type = 'event';
1515
+		} else {
1516
+			$post_type = 'listing';
1517
+		}
1518
+		$renew_link = '<a href="' . $siteurl . '?ptype=post_' . $post_type . '&renew=1&pid=' . $page_id . '">' . RENEW_LINK . '</a>';
1519
+		$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#]');
1520
+		$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);
1521
+		$client_message = str_replace($search_array, $replace_array, $client_message);
1522
+		$subject = str_replace($search_array, $replace_array, $subject);
1523
+		$headers = 'MIME-Version: 1.0' . "\r\n";
1524
+		$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1525
+		$headers .= 'From: ' . $fromEmailName . ' <' . $fromEmail . '>' . "\r\n";
1526
+
1527
+		$to = $fromEmail;
1528
+		$message = $client_message;
1529
+
1530
+
1531
+		/**
1532
+		 * Filter the admin email to address.
1533
+		 *
1534
+		 * @since 1.6.1
1535
+		 * @package GeoDirectory
1536
+		 * @param string $to The email address the email is being sent to.
1537
+		 * @param int|string $page_id Page ID.
1538
+		 * @param int|string $user_id User ID.
1539
+		 * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1540
+		 * @param string $custom_1 Custom data to be sent.
1541
+		 */
1542
+		$to = apply_filters('geodir_adminEmail_to',$to,$page_id, $user_id, $message_type, $custom_1 );
1543
+		/**
1544
+		 * Filter the admin email subject.
1545
+		 *
1546
+		 * @since 1.6.1
1547
+		 * @package GeoDirectory_Payment_Manager
1548
+		 * @param string $subject The email subject.
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
+		$subject = apply_filters('geodir_adminEmail_subject',$subject,$page_id, $user_id, $message_type, $custom_1);
1555
+		/**
1556
+		 * Filter the admin email message.
1557
+		 *
1558
+		 * @since 1.6.1
1559
+		 * @package GeoDirectory_Payment_Manager
1560
+		 * @param string $message The email message text.
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
+		$message = apply_filters('geodir_adminEmail_message',$message,$page_id, $user_id, $message_type, $custom_1);
1567
+		/**
1568
+		 * Filter the admin email headers.
1569
+		 *
1570
+		 * @since 1.6.1
1571
+		 * @package GeoDirectory_Payment_Manager
1572
+		 * @param string $headers The email headers.
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
+		$headers = apply_filters('geodir_adminEmail_headers',$headers,$page_id, $user_id, $message_type, $custom_1);
1579
+
1580
+
1581
+
1582
+		$sent = wp_mail($to, $subject, $message, $headers);
1583
+		if( ! $sent ) {
1584
+			if ( is_array( $to ) ) {
1585
+				$to = implode( ',', $to );
1586
+			}
1587
+			$log_message = sprintf(
1588
+				__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1589
+				$message_type,
1590
+				date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1591
+				$to,
1592
+				$subject
1593
+			);
1594
+			geodir_error_log( $log_message );
1595
+		}
1596
+	}
1597 1597
 }
1598 1598
 
1599 1599
 if (!function_exists('sendEmail')) {
1600
-    /**
1601
-     * @todo could be a duplicate of geodir_sendEmail.
1602
-     *
1603
-     * @since 1.0.0
1604
-     * @package GeoDirectory
1605
-     * @param string $fromEmail Sender email address.
1606
-     * @param string $fromEmailName Sender name.
1607
-     * @param string $toEmail Receiver email address.
1608
-     * @param string $toEmailName Receiver name.
1609
-     * @param string $to_subject Email subject.
1610
-     * @param string $to_message Email content.
1611
-     * @param string $extra Not being used.
1612
-     * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration.
1613
-     * @param string $post_id The post ID.
1614
-     * @param string $user_id The user ID.
1615
-     */
1616
-    function sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '')
1617
-    {
1618
-        $login_details = '';
1619
-        if ($message_type == 'send_friend') {
1620
-            $subject = stripslashes(__(get_option('email_friend_subject'),'geodirectory'));
1621
-            $message = stripslashes(__(get_option('email_friend_content'),'geodirectory'));
1622
-        } elseif ($message_type == 'send_enquiry') {
1623
-            $subject = __(get_option('email_enquiry_subject'),'geodirectory');
1624
-            $message = __(get_option('email_enquiry_content'),'geodirectory');
1625
-        } elseif ($message_type == 'forgot_password') {
1626
-            $subject = __(get_option('forgot_password_subject'),'geodirectory');
1627
-            $message = __(get_option('forgot_password_content'),'geodirectory');
1628
-            $login_details = $to_message;
1629
-        } elseif ($message_type == 'registration') {
1630
-            $subject = __(get_option('registration_success_email_subject'),'geodirectory');
1631
-            $message = __(get_option('registration_success_email_content'),'geodirectory');
1632
-            $login_details = $to_message;
1633
-        }
1634
-        $to_message = nl2br($to_message);
1635
-        $sitefromEmail = get_option('site_email');
1636
-        $sitefromEmailName = get_site_emailName();
1637
-        $productlink = get_permalink($post_id);
1638
-        $post_info = get_post($post_id);
1639
-        $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1640
-        $siteurl = home_url();
1641
-        $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
1642
-        $loginurl = geodir_login_url();
1643
-        $loginurl_link = '<a href="' . $loginurl . '">login</a>';
1644
-        if ($fromEmail == '') {
1645
-            $fromEmail = get_option('site_email');
1646
-        }
1647
-        if ($fromEmailName == '') {
1648
-            $fromEmailName = get_option('site_email_name');
1649
-        }
1650
-        $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]');
1651
-        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName);
1652
-        $message = str_replace($search_array, $replace_array, $message);
1653
-
1654
-        $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]');
1655
-        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName);
1656
-        $subject = str_replace($search_array, $replace_array, $subject);
1657
-        $headers = 'MIME-Version: 1.0' . "\r\n";
1658
-        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1659
-        $headers .= "Reply-To: " . $fromEmail . "\r\n";
1660
-        $headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
1661
-
1662
-        $to = $toEmail;
1663
-
1664
-        $sent = wp_mail($to, $subject, $message, $headers);
1665
-        if( ! $sent ) {
1666
-            if ( is_array( $to ) ) {
1667
-                $to = implode( ',', $to );
1668
-            }
1669
-            $log_message = sprintf(
1670
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1671
-                $message_type,
1672
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1673
-                $to,
1674
-                $subject
1675
-            );
1676
-            geodir_error_log( $log_message );
1677
-        }
1678
-
1679
-        ///////// ADMIN BCC EMIALS
1680
-        $admin_bcc = false;
1681
-        if ($message_type == 'registration') {
1682
-            $message_raw = explode(__("Password:", 'geodirectory'), $message);
1683
-            $message_raw2 = explode("</p>", $message_raw[1], 2);
1684
-            $message = $message_raw[0] . __('Password:', 'geodirectory') . ' **********</p>' . $message_raw2[1];
1685
-        }
1686
-        $adminEmail = get_bloginfo('admin_email');
1687
-        $to = $adminEmail;
1688
-
1689
-        if ($message_type == 'registration' && get_option('bcc_new_user')) {
1690
-            $subject .= ' - ADMIN BCC COPY';
1691
-            $admin_bcc = true;
1692
-        }
1693
-        elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
1694
-            $subject .= ' - ADMIN BCC COPY';
1695
-            $admin_bcc = true;
1696
-        }
1697
-        elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
1698
-            $subject .= ' - ADMIN BCC COPY';
1699
-            $admin_bcc = true;
1700
-        }
1701
-
1702
-        if($admin_bcc === true){
1703
-            $sent = wp_mail($to, $subject, $message, $headers);
1704
-            if( ! $sent ) {
1705
-                if ( is_array( $to ) ) {
1706
-                    $to = implode( ',', $to );
1707
-                }
1708
-                $log_message = sprintf(
1709
-                    __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1710
-                    $message_type,
1711
-                    date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1712
-                    $to,
1713
-                    $subject
1714
-                );
1715
-                geodir_error_log( $log_message );
1716
-            }
1717
-        }
1718
-
1719
-    }
1600
+	/**
1601
+	 * @todo could be a duplicate of geodir_sendEmail.
1602
+	 *
1603
+	 * @since 1.0.0
1604
+	 * @package GeoDirectory
1605
+	 * @param string $fromEmail Sender email address.
1606
+	 * @param string $fromEmailName Sender name.
1607
+	 * @param string $toEmail Receiver email address.
1608
+	 * @param string $toEmailName Receiver name.
1609
+	 * @param string $to_subject Email subject.
1610
+	 * @param string $to_message Email content.
1611
+	 * @param string $extra Not being used.
1612
+	 * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration.
1613
+	 * @param string $post_id The post ID.
1614
+	 * @param string $user_id The user ID.
1615
+	 */
1616
+	function sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '')
1617
+	{
1618
+		$login_details = '';
1619
+		if ($message_type == 'send_friend') {
1620
+			$subject = stripslashes(__(get_option('email_friend_subject'),'geodirectory'));
1621
+			$message = stripslashes(__(get_option('email_friend_content'),'geodirectory'));
1622
+		} elseif ($message_type == 'send_enquiry') {
1623
+			$subject = __(get_option('email_enquiry_subject'),'geodirectory');
1624
+			$message = __(get_option('email_enquiry_content'),'geodirectory');
1625
+		} elseif ($message_type == 'forgot_password') {
1626
+			$subject = __(get_option('forgot_password_subject'),'geodirectory');
1627
+			$message = __(get_option('forgot_password_content'),'geodirectory');
1628
+			$login_details = $to_message;
1629
+		} elseif ($message_type == 'registration') {
1630
+			$subject = __(get_option('registration_success_email_subject'),'geodirectory');
1631
+			$message = __(get_option('registration_success_email_content'),'geodirectory');
1632
+			$login_details = $to_message;
1633
+		}
1634
+		$to_message = nl2br($to_message);
1635
+		$sitefromEmail = get_option('site_email');
1636
+		$sitefromEmailName = get_site_emailName();
1637
+		$productlink = get_permalink($post_id);
1638
+		$post_info = get_post($post_id);
1639
+		$listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1640
+		$siteurl = home_url();
1641
+		$siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
1642
+		$loginurl = geodir_login_url();
1643
+		$loginurl_link = '<a href="' . $loginurl . '">login</a>';
1644
+		if ($fromEmail == '') {
1645
+			$fromEmail = get_option('site_email');
1646
+		}
1647
+		if ($fromEmailName == '') {
1648
+			$fromEmailName = get_option('site_email_name');
1649
+		}
1650
+		$search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]');
1651
+		$replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName);
1652
+		$message = str_replace($search_array, $replace_array, $message);
1653
+
1654
+		$search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]');
1655
+		$replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName);
1656
+		$subject = str_replace($search_array, $replace_array, $subject);
1657
+		$headers = 'MIME-Version: 1.0' . "\r\n";
1658
+		$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1659
+		$headers .= "Reply-To: " . $fromEmail . "\r\n";
1660
+		$headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
1661
+
1662
+		$to = $toEmail;
1663
+
1664
+		$sent = wp_mail($to, $subject, $message, $headers);
1665
+		if( ! $sent ) {
1666
+			if ( is_array( $to ) ) {
1667
+				$to = implode( ',', $to );
1668
+			}
1669
+			$log_message = sprintf(
1670
+				__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1671
+				$message_type,
1672
+				date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1673
+				$to,
1674
+				$subject
1675
+			);
1676
+			geodir_error_log( $log_message );
1677
+		}
1678
+
1679
+		///////// ADMIN BCC EMIALS
1680
+		$admin_bcc = false;
1681
+		if ($message_type == 'registration') {
1682
+			$message_raw = explode(__("Password:", 'geodirectory'), $message);
1683
+			$message_raw2 = explode("</p>", $message_raw[1], 2);
1684
+			$message = $message_raw[0] . __('Password:', 'geodirectory') . ' **********</p>' . $message_raw2[1];
1685
+		}
1686
+		$adminEmail = get_bloginfo('admin_email');
1687
+		$to = $adminEmail;
1688
+
1689
+		if ($message_type == 'registration' && get_option('bcc_new_user')) {
1690
+			$subject .= ' - ADMIN BCC COPY';
1691
+			$admin_bcc = true;
1692
+		}
1693
+		elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
1694
+			$subject .= ' - ADMIN BCC COPY';
1695
+			$admin_bcc = true;
1696
+		}
1697
+		elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
1698
+			$subject .= ' - ADMIN BCC COPY';
1699
+			$admin_bcc = true;
1700
+		}
1701
+
1702
+		if($admin_bcc === true){
1703
+			$sent = wp_mail($to, $subject, $message, $headers);
1704
+			if( ! $sent ) {
1705
+				if ( is_array( $to ) ) {
1706
+					$to = implode( ',', $to );
1707
+				}
1708
+				$log_message = sprintf(
1709
+					__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1710
+					$message_type,
1711
+					date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1712
+					$to,
1713
+					$subject
1714
+				);
1715
+				geodir_error_log( $log_message );
1716
+			}
1717
+		}
1718
+
1719
+	}
1720 1720
 }
1721 1721
 
1722 1722
 /*
@@ -1734,16 +1734,16 @@  discard block
 block discarded – undo
1734 1734
  */
1735 1735
 function gd_lang_object_ids($ids_array, $type)
1736 1736
 {
1737
-    if (function_exists('icl_object_id')) {
1738
-        $res = array();
1739
-        foreach ($ids_array as $id) {
1740
-            $xlat = icl_object_id($id, $type, false);
1741
-            if (!is_null($xlat)) $res[] = $xlat;
1742
-        }
1743
-        return $res;
1744
-    } else {
1745
-        return $ids_array;
1746
-    }
1737
+	if (function_exists('icl_object_id')) {
1738
+		$res = array();
1739
+		foreach ($ids_array as $id) {
1740
+			$xlat = icl_object_id($id, $type, false);
1741
+			if (!is_null($xlat)) $res[] = $xlat;
1742
+		}
1743
+		return $res;
1744
+	} else {
1745
+		return $ids_array;
1746
+	}
1747 1747
 }
1748 1748
 
1749 1749
 
@@ -1758,31 +1758,31 @@  discard block
 block discarded – undo
1758 1758
  * @return array Modified Body CSS classes.
1759 1759
  */
1760 1760
 function geodir_custom_posts_body_class($classes) {
1761
-    global $wpdb, $wp;
1762
-    $post_types = geodir_get_posttypes('object');
1763
-    if (!empty($post_types) && count((array)$post_types) > 1) {
1764
-        $classes[] = 'geodir_custom_posts';
1765
-    }
1766
-
1767
-    // fix body class for signup page
1768
-    if (geodir_is_page('login')) {
1769
-        $new_classes = array();
1770
-        $new_classes[] = 'signup page-geodir-signup';
1771
-        if (!empty($classes)) {
1772
-            foreach ($classes as $class) {
1773
-                if ($class && $class != 'home' && $class != 'blog') {
1774
-                    $new_classes[] = $class;
1775
-                }
1776
-            }
1777
-        }
1778
-        $classes = $new_classes;
1779
-    }
1780
-
1781
-    if (geodir_is_geodir_page()) {
1782
-        $classes[] = 'geodir-page';
1783
-    }
1784
-
1785
-    return $classes;
1761
+	global $wpdb, $wp;
1762
+	$post_types = geodir_get_posttypes('object');
1763
+	if (!empty($post_types) && count((array)$post_types) > 1) {
1764
+		$classes[] = 'geodir_custom_posts';
1765
+	}
1766
+
1767
+	// fix body class for signup page
1768
+	if (geodir_is_page('login')) {
1769
+		$new_classes = array();
1770
+		$new_classes[] = 'signup page-geodir-signup';
1771
+		if (!empty($classes)) {
1772
+			foreach ($classes as $class) {
1773
+				if ($class && $class != 'home' && $class != 'blog') {
1774
+					$new_classes[] = $class;
1775
+				}
1776
+			}
1777
+		}
1778
+		$classes = $new_classes;
1779
+	}
1780
+
1781
+	if (geodir_is_geodir_page()) {
1782
+		$classes[] = 'geodir-page';
1783
+	}
1784
+
1785
+	return $classes;
1786 1786
 }
1787 1787
 
1788 1788
 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
@@ -1797,12 +1797,12 @@  discard block
 block discarded – undo
1797 1797
  */
1798 1798
 function geodir_map_zoom_level()
1799 1799
 {
1800
-    /**
1801
-     * Filter GD map zoom level.
1802
-     *
1803
-     * @since 1.0.0
1804
-     */
1805
-    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));
1800
+	/**
1801
+	 * Filter GD map zoom level.
1802
+	 *
1803
+	 * @since 1.0.0
1804
+	 */
1805
+	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));
1806 1806
 
1807 1807
 }
1808 1808
 
@@ -1816,12 +1816,12 @@  discard block
 block discarded – undo
1816 1816
  */
1817 1817
 function geodir_option_version_backup($geodir_option_name)
1818 1818
 {
1819
-    $version_date = time();
1820
-    $geodir_option = get_option($geodir_option_name);
1819
+	$version_date = time();
1820
+	$geodir_option = get_option($geodir_option_name);
1821 1821
 
1822
-    if (!empty($geodir_option)) {
1823
-        add_option($geodir_option_name . '_' . $version_date, $geodir_option);
1824
-    }
1822
+	if (!empty($geodir_option)) {
1823
+		add_option($geodir_option_name . '_' . $version_date, $geodir_option);
1824
+	}
1825 1825
 }
1826 1826
 
1827 1827
 /**
@@ -1834,11 +1834,11 @@  discard block
 block discarded – undo
1834 1834
  */
1835 1835
 function get_page_id_geodir_add_listing_page($page_id)
1836 1836
 {
1837
-    if (geodir_wpml_multilingual_status()) {
1838
-        $post_type = 'post_page';
1839
-        $page_id = geodir_get_wpml_element_id($page_id, $post_type);
1840
-    }
1841
-    return $page_id;
1837
+	if (geodir_wpml_multilingual_status()) {
1838
+		$post_type = 'post_page';
1839
+		$page_id = geodir_get_wpml_element_id($page_id, $post_type);
1840
+	}
1841
+	return $page_id;
1842 1842
 }
1843 1843
 
1844 1844
 /**
@@ -1850,10 +1850,10 @@  discard block
 block discarded – undo
1850 1850
  */
1851 1851
 function geodir_wpml_multilingual_status()
1852 1852
 {
1853
-    if (function_exists('icl_object_id')) {
1854
-        return true;
1855
-    }
1856
-    return false;
1853
+	if (function_exists('icl_object_id')) {
1854
+		return true;
1855
+	}
1856
+	return false;
1857 1857
 }
1858 1858
 
1859 1859
 /**
@@ -1867,22 +1867,22 @@  discard block
 block discarded – undo
1867 1867
  */
1868 1868
 function geodir_get_wpml_element_id($page_id, $post_type)
1869 1869
 {
1870
-    global $sitepress;
1871
-    if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
1872
-        $trid = $sitepress->get_element_trid($page_id, $post_type);
1873
-
1874
-        if ($trid > 0) {
1875
-            $translations = $sitepress->get_element_translations($trid, $post_type);
1876
-
1877
-            $lang = $sitepress->get_current_language();
1878
-            $lang = $lang ? $lang : $sitepress->get_default_language();
1879
-
1880
-            if (!empty($translations) && !empty($lang) && isset($translations[$lang]) && isset($translations[$lang]->element_id) && !empty($translations[$lang]->element_id)) {
1881
-                $page_id = $translations[$lang]->element_id;
1882
-            }
1883
-        }
1884
-    }
1885
-    return $page_id;
1870
+	global $sitepress;
1871
+	if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
1872
+		$trid = $sitepress->get_element_trid($page_id, $post_type);
1873
+
1874
+		if ($trid > 0) {
1875
+			$translations = $sitepress->get_element_translations($trid, $post_type);
1876
+
1877
+			$lang = $sitepress->get_current_language();
1878
+			$lang = $lang ? $lang : $sitepress->get_default_language();
1879
+
1880
+			if (!empty($translations) && !empty($lang) && isset($translations[$lang]) && isset($translations[$lang]->element_id) && !empty($translations[$lang]->element_id)) {
1881
+				$page_id = $translations[$lang]->element_id;
1882
+			}
1883
+		}
1884
+	}
1885
+	return $page_id;
1886 1886
 }
1887 1887
 
1888 1888
 /**
@@ -1894,20 +1894,20 @@  discard block
 block discarded – undo
1894 1894
  */
1895 1895
 function geodir_wpml_check_element_id()
1896 1896
 {
1897
-    global $sitepress;
1898
-    if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
1899
-        $el_type = 'post_page';
1900
-        $el_id = get_option('geodir_add_listing_page');
1901
-        $default_lang = $sitepress->get_default_language();
1902
-        $el_details = $sitepress->get_element_language_details($el_id, $el_type);
1903
-
1904
-        if (!($el_id > 0 && $default_lang && !empty($el_details) && isset($el_details->language_code) && $el_details->language_code == $default_lang)) {
1905
-            if (!$el_details->source_language_code) {
1906
-                $sitepress->set_element_language_details($el_id, $el_type, '', $default_lang);
1907
-                $sitepress->icl_translations_cache->clear();
1908
-            }
1909
-        }
1910
-    }
1897
+	global $sitepress;
1898
+	if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
1899
+		$el_type = 'post_page';
1900
+		$el_id = get_option('geodir_add_listing_page');
1901
+		$default_lang = $sitepress->get_default_language();
1902
+		$el_details = $sitepress->get_element_language_details($el_id, $el_type);
1903
+
1904
+		if (!($el_id > 0 && $default_lang && !empty($el_details) && isset($el_details->language_code) && $el_details->language_code == $default_lang)) {
1905
+			if (!$el_details->source_language_code) {
1906
+				$sitepress->set_element_language_details($el_id, $el_type, '', $default_lang);
1907
+				$sitepress->icl_translations_cache->clear();
1908
+			}
1909
+		}
1910
+	}
1911 1911
 }
1912 1912
 
1913 1913
 /**
@@ -1922,44 +1922,44 @@  discard block
 block discarded – undo
1922 1922
  */
1923 1923
 function geodir_widget_listings_get_order($query_args)
1924 1924
 {
1925
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
1926
-
1927
-    $query_args = $gd_query_args_widgets;
1928
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
1929
-        return $wpdb->posts . ".post_date DESC, ";
1930
-    }
1931
-
1932
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1933
-    $table = $plugin_prefix . $post_type . '_detail';
1934
-
1935
-    $sort_by = !empty($query_args['order_by']) ? $query_args['order_by'] : '';
1936
-
1937
-    switch ($sort_by) {
1938
-        case 'latest':
1939
-        case 'newest':
1940
-            $orderby = $wpdb->posts . ".post_date DESC, ";
1941
-            break;
1942
-        case 'featured':
1943
-            $orderby = $table . ".is_featured ASC, ";
1944
-            break;
1945
-        case 'az':
1946
-            $orderby = $wpdb->posts . ".post_title ASC, ";
1947
-            break;
1948
-        case 'high_review':
1949
-            $orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, ";
1950
-            break;
1951
-        case 'high_rating':
1952
-            $orderby = "( " . $table . ".overall_rating  ) DESC, ";
1953
-            break;
1954
-        case 'random':
1955
-            $orderby = "RAND(), ";
1956
-            break;
1957
-        default:
1958
-            $orderby = $wpdb->posts . ".post_title ASC, ";
1959
-            break;
1960
-    }
1961
-
1962
-    return $orderby;
1925
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
1926
+
1927
+	$query_args = $gd_query_args_widgets;
1928
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
1929
+		return $wpdb->posts . ".post_date DESC, ";
1930
+	}
1931
+
1932
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1933
+	$table = $plugin_prefix . $post_type . '_detail';
1934
+
1935
+	$sort_by = !empty($query_args['order_by']) ? $query_args['order_by'] : '';
1936
+
1937
+	switch ($sort_by) {
1938
+		case 'latest':
1939
+		case 'newest':
1940
+			$orderby = $wpdb->posts . ".post_date DESC, ";
1941
+			break;
1942
+		case 'featured':
1943
+			$orderby = $table . ".is_featured ASC, ";
1944
+			break;
1945
+		case 'az':
1946
+			$orderby = $wpdb->posts . ".post_title ASC, ";
1947
+			break;
1948
+		case 'high_review':
1949
+			$orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, ";
1950
+			break;
1951
+		case 'high_rating':
1952
+			$orderby = "( " . $table . ".overall_rating  ) DESC, ";
1953
+			break;
1954
+		case 'random':
1955
+			$orderby = "RAND(), ";
1956
+			break;
1957
+		default:
1958
+			$orderby = $wpdb->posts . ".post_title ASC, ";
1959
+			break;
1960
+	}
1961
+
1962
+	return $orderby;
1963 1963
 }
1964 1964
 
1965 1965
 /**
@@ -1977,126 +1977,126 @@  discard block
 block discarded – undo
1977 1977
  */
1978 1978
 function geodir_get_widget_listings($query_args = array(), $count_only = false)
1979 1979
 {
1980
-    global $wpdb, $plugin_prefix, $table_prefix;
1981
-    $GLOBALS['gd_query_args_widgets'] = $query_args;
1982
-    $gd_query_args_widgets = $query_args;
1983
-
1984
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1985
-    $table = $plugin_prefix . $post_type . '_detail';
1986
-
1987
-    $fields = $wpdb->posts . ".*, " . $table . ".*";
1988
-    /**
1989
-     * Filter widget listing fields string part that is being used for query.
1990
-     *
1991
-     * @since 1.0.0
1992
-     * @param string $fields Fields string.
1993
-     * @param string $table Table name.
1994
-     * @param string $post_type Post type.
1995
-     */
1996
-    $fields = apply_filters('geodir_filter_widget_listings_fields', $fields, $table, $post_type);
1997
-
1998
-    $join = "INNER JOIN " . $table . " ON (" . $table . ".post_id = " . $wpdb->posts . ".ID)";
1980
+	global $wpdb, $plugin_prefix, $table_prefix;
1981
+	$GLOBALS['gd_query_args_widgets'] = $query_args;
1982
+	$gd_query_args_widgets = $query_args;
1983
+
1984
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1985
+	$table = $plugin_prefix . $post_type . '_detail';
1986
+
1987
+	$fields = $wpdb->posts . ".*, " . $table . ".*";
1988
+	/**
1989
+	 * Filter widget listing fields string part that is being used for query.
1990
+	 *
1991
+	 * @since 1.0.0
1992
+	 * @param string $fields Fields string.
1993
+	 * @param string $table Table name.
1994
+	 * @param string $post_type Post type.
1995
+	 */
1996
+	$fields = apply_filters('geodir_filter_widget_listings_fields', $fields, $table, $post_type);
1997
+
1998
+	$join = "INNER JOIN " . $table . " ON (" . $table . ".post_id = " . $wpdb->posts . ".ID)";
1999
+
2000
+	########### WPML ###########
2001
+
2002
+	if (function_exists('icl_object_id')) {
2003
+		global $sitepress;
2004
+		$lang_code = ICL_LANGUAGE_CODE;
2005
+		if ($lang_code) {
2006
+			$join .= " JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID";
2007
+		}
2008
+	}
1999 2009
 
2000
-    ########### WPML ###########
2010
+	########### WPML ###########
2001 2011
 
2002
-    if (function_exists('icl_object_id')) {
2003
-        global $sitepress;
2004
-        $lang_code = ICL_LANGUAGE_CODE;
2005
-        if ($lang_code) {
2006
-            $join .= " JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID";
2007
-        }
2008
-    }
2012
+	/**
2013
+	 * Filter widget listing join clause string part that is being used for query.
2014
+	 *
2015
+	 * @since 1.0.0
2016
+	 * @param string $join Join clause string.
2017
+	 * @param string $post_type Post type.
2018
+	 */
2019
+	$join = apply_filters('geodir_filter_widget_listings_join', $join, $post_type);
2009 2020
 
2010
-    ########### WPML ###########
2021
+	$post_status = is_super_admin() ? " OR " . $wpdb->posts . ".post_status = 'private'" : '';
2011 2022
 
2012
-    /**
2013
-     * Filter widget listing join clause string part that is being used for query.
2014
-     *
2015
-     * @since 1.0.0
2016
-     * @param string $join Join clause string.
2017
-     * @param string $post_type Post type.
2018
-     */
2019
-    $join = apply_filters('geodir_filter_widget_listings_join', $join, $post_type);
2020
-
2021
-    $post_status = is_super_admin() ? " OR " . $wpdb->posts . ".post_status = 'private'" : '';
2022
-
2023
-    $where = " AND ( " . $wpdb->posts . ".post_status = 'publish' " . $post_status . " ) AND " . $wpdb->posts . ".post_type = '" . $post_type . "'";
2024
-
2025
-    ########### WPML ###########
2026
-    if (function_exists('icl_object_id')) {
2027
-        if ($lang_code) {
2028
-            $where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type = 'post_$post_type' ";
2029
-        }
2030
-    }
2031
-    ########### WPML ###########
2032
-    /**
2033
-     * Filter widget listing where clause string part that is being used for query.
2034
-     *
2035
-     * @since 1.0.0
2036
-     * @param string $where Where clause string.
2037
-     * @param string $post_type Post type.
2038
-     */
2039
-    $where = apply_filters('geodir_filter_widget_listings_where', $where, $post_type);
2040
-    $where = $where != '' ? " WHERE 1=1 " . $where : '';
2041
-
2042
-    $groupby = " GROUP BY $wpdb->posts.ID ";
2043
-    /**
2044
-     * Filter widget listing groupby clause string part that is being used for query.
2045
-     *
2046
-     * @since 1.0.0
2047
-     * @param string $groupby Group by clause string.
2048
-     * @param string $post_type Post type.
2049
-     */
2050
-    $groupby = apply_filters('geodir_filter_widget_listings_groupby', $groupby, $post_type);
2023
+	$where = " AND ( " . $wpdb->posts . ".post_status = 'publish' " . $post_status . " ) AND " . $wpdb->posts . ".post_type = '" . $post_type . "'";
2051 2024
 
2052
-    if ($count_only) {
2053
-        $sql = "SELECT COUNT(" . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . "
2025
+	########### WPML ###########
2026
+	if (function_exists('icl_object_id')) {
2027
+		if ($lang_code) {
2028
+			$where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type = 'post_$post_type' ";
2029
+		}
2030
+	}
2031
+	########### WPML ###########
2032
+	/**
2033
+	 * Filter widget listing where clause string part that is being used for query.
2034
+	 *
2035
+	 * @since 1.0.0
2036
+	 * @param string $where Where clause string.
2037
+	 * @param string $post_type Post type.
2038
+	 */
2039
+	$where = apply_filters('geodir_filter_widget_listings_where', $where, $post_type);
2040
+	$where = $where != '' ? " WHERE 1=1 " . $where : '';
2041
+
2042
+	$groupby = " GROUP BY $wpdb->posts.ID ";
2043
+	/**
2044
+	 * Filter widget listing groupby clause string part that is being used for query.
2045
+	 *
2046
+	 * @since 1.0.0
2047
+	 * @param string $groupby Group by clause string.
2048
+	 * @param string $post_type Post type.
2049
+	 */
2050
+	$groupby = apply_filters('geodir_filter_widget_listings_groupby', $groupby, $post_type);
2051
+
2052
+	if ($count_only) {
2053
+		$sql = "SELECT COUNT(" . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . "
2054 2054
 			" . $join . "
2055 2055
 			" . $where;
2056
-        $rows = (int)$wpdb->get_var($sql);
2057
-    } else {
2058
-        $orderby = geodir_widget_listings_get_order($query_args);
2059
-        /**
2060
-         * Filter widget listing orderby clause string part that is being used for query.
2061
-         *
2062
-         * @since 1.0.0
2063
-         * @param string $orderby Order by clause string.
2064
-         * @param string $table Table name.
2065
-         * @param string $post_type Post type.
2066
-         */
2067
-        $orderby = apply_filters('geodir_filter_widget_listings_orderby', $orderby, $table, $post_type);
2068
-        $orderby .= $wpdb->posts . ".post_title ASC";
2069
-        $orderby = $orderby != '' ? " ORDER BY " . $orderby : '';
2070
-
2071
-        $limit = !empty($query_args['posts_per_page']) ? $query_args['posts_per_page'] : 5;
2072
-        /**
2073
-         * Filter widget listing limit that is being used for query.
2074
-         *
2075
-         * @since 1.0.0
2076
-         * @param int $limit Query results limit.
2077
-         * @param string $post_type Post type.
2078
-         */
2079
-        $limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
2080
-
2081
-        $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1;
2082
-        if ( !$page )
2083
-            $page = 1;
2084
-
2085
-        $limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : "";
2086
-
2087
-        $sql = "SELECT SQL_CALC_FOUND_ROWS " . $fields . " FROM " . $wpdb->posts . "
2056
+		$rows = (int)$wpdb->get_var($sql);
2057
+	} else {
2058
+		$orderby = geodir_widget_listings_get_order($query_args);
2059
+		/**
2060
+		 * Filter widget listing orderby clause string part that is being used for query.
2061
+		 *
2062
+		 * @since 1.0.0
2063
+		 * @param string $orderby Order by clause string.
2064
+		 * @param string $table Table name.
2065
+		 * @param string $post_type Post type.
2066
+		 */
2067
+		$orderby = apply_filters('geodir_filter_widget_listings_orderby', $orderby, $table, $post_type);
2068
+		$orderby .= $wpdb->posts . ".post_title ASC";
2069
+		$orderby = $orderby != '' ? " ORDER BY " . $orderby : '';
2070
+
2071
+		$limit = !empty($query_args['posts_per_page']) ? $query_args['posts_per_page'] : 5;
2072
+		/**
2073
+		 * Filter widget listing limit that is being used for query.
2074
+		 *
2075
+		 * @since 1.0.0
2076
+		 * @param int $limit Query results limit.
2077
+		 * @param string $post_type Post type.
2078
+		 */
2079
+		$limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
2080
+
2081
+		$page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1;
2082
+		if ( !$page )
2083
+			$page = 1;
2084
+
2085
+		$limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : "";
2086
+
2087
+		$sql = "SELECT SQL_CALC_FOUND_ROWS " . $fields . " FROM " . $wpdb->posts . "
2088 2088
 			" . $join . "
2089 2089
 			" . $where . "
2090 2090
 			" . $groupby . "
2091 2091
 			" . $orderby . "
2092 2092
 			" . $limit;
2093
-        $rows = $wpdb->get_results($sql);
2094
-    }
2093
+		$rows = $wpdb->get_results($sql);
2094
+	}
2095 2095
 
2096
-    unset($GLOBALS['gd_query_args_widgets']);
2097
-    unset($gd_query_args_widgets);
2096
+	unset($GLOBALS['gd_query_args_widgets']);
2097
+	unset($gd_query_args_widgets);
2098 2098
 
2099
-    return $rows;
2099
+	return $rows;
2100 2100
 }
2101 2101
 
2102 2102
 /**
@@ -2111,14 +2111,14 @@  discard block
 block discarded – undo
2111 2111
  */
2112 2112
 function geodir_function_widget_listings_fields($fields)
2113 2113
 {
2114
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2114
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2115 2115
 
2116
-    $query_args = $gd_query_args_widgets;
2117
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2118
-        return $fields;
2119
-    }
2116
+	$query_args = $gd_query_args_widgets;
2117
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2118
+		return $fields;
2119
+	}
2120 2120
     
2121
-    return $fields;
2121
+	return $fields;
2122 2122
 }
2123 2123
 
2124 2124
 /**
@@ -2133,28 +2133,28 @@  discard block
 block discarded – undo
2133 2133
  */
2134 2134
 function geodir_function_widget_listings_join($join)
2135 2135
 {
2136
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2136
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2137 2137
 
2138
-    $query_args = $gd_query_args_widgets;
2139
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2140
-        return $join;
2141
-    }
2138
+	$query_args = $gd_query_args_widgets;
2139
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2140
+		return $join;
2141
+	}
2142 2142
 
2143
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2144
-    $table = $plugin_prefix . $post_type . '_detail';
2143
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2144
+	$table = $plugin_prefix . $post_type . '_detail';
2145 2145
 
2146
-    if (!empty($query_args['with_pics_only'])) {
2147
-        $join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )";
2148
-    }
2146
+	if (!empty($query_args['with_pics_only'])) {
2147
+		$join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )";
2148
+	}
2149 2149
 
2150
-    if (!empty($query_args['tax_query'])) {
2151
-        $tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
2152
-        if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
2153
-            $join .= $tax_queries['join'];
2154
-        }
2155
-    }
2150
+	if (!empty($query_args['tax_query'])) {
2151
+		$tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
2152
+		if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
2153
+			$join .= $tax_queries['join'];
2154
+		}
2155
+	}
2156 2156
 
2157
-    return $join;
2157
+	return $join;
2158 2158
 }
2159 2159
 
2160 2160
 /**
@@ -2169,54 +2169,54 @@  discard block
 block discarded – undo
2169 2169
  */
2170 2170
 function geodir_function_widget_listings_where($where)
2171 2171
 {
2172
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2173
-
2174
-    $query_args = $gd_query_args_widgets;
2175
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2176
-        return $where;
2177
-    }
2178
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2179
-    $table = $plugin_prefix . $post_type . '_detail';
2180
-
2181
-    if (!empty($query_args)) {
2182
-        if (!empty($query_args['gd_location']) && function_exists('geodir_default_location_where')) {
2183
-            $where = geodir_default_location_where($where, $table);
2184
-        }
2185
-
2186
-        if (!empty($query_args['post_author'])) {
2187
-            $where .= " AND " . $wpdb->posts . ".post_author = " . (int)$query_args['post_author'];
2188
-        }
2189
-        
2190
-        if (!empty($query_args['show_featured_only'])) {
2191
-            $where .= " AND " . $table . ".is_featured = '1'";
2192
-        }
2172
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2193 2173
 
2194
-        if (!empty($query_args['show_special_only'])) {
2195
-            $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )";
2196
-        }
2174
+	$query_args = $gd_query_args_widgets;
2175
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2176
+		return $where;
2177
+	}
2178
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2179
+	$table = $plugin_prefix . $post_type . '_detail';
2197 2180
 
2198
-        if (!empty($query_args['with_pics_only'])) {
2199
-            $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL ";
2200
-        }
2181
+	if (!empty($query_args)) {
2182
+		if (!empty($query_args['gd_location']) && function_exists('geodir_default_location_where')) {
2183
+			$where = geodir_default_location_where($where, $table);
2184
+		}
2201 2185
 
2202
-        if (!empty($query_args['featured_image_only'])) {
2203
-            $where .= " AND " . $table . ".featured_image IS NOT NULL AND " . $table . ".featured_image!='' ";
2204
-        }
2186
+		if (!empty($query_args['post_author'])) {
2187
+			$where .= " AND " . $wpdb->posts . ".post_author = " . (int)$query_args['post_author'];
2188
+		}
2189
+        
2190
+		if (!empty($query_args['show_featured_only'])) {
2191
+			$where .= " AND " . $table . ".is_featured = '1'";
2192
+		}
2205 2193
 
2206
-        if (!empty($query_args['with_videos_only'])) {
2207
-            $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )";
2208
-        }
2194
+		if (!empty($query_args['show_special_only'])) {
2195
+			$where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )";
2196
+		}
2209 2197
 
2210
-        if (!empty($query_args['tax_query'])) {
2211
-            $tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
2198
+		if (!empty($query_args['with_pics_only'])) {
2199
+			$where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL ";
2200
+		}
2212 2201
 
2213
-            if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
2214
-                $where .= $tax_queries['where'];
2215
-            }
2216
-        }
2217
-    }
2202
+		if (!empty($query_args['featured_image_only'])) {
2203
+			$where .= " AND " . $table . ".featured_image IS NOT NULL AND " . $table . ".featured_image!='' ";
2204
+		}
2218 2205
 
2219
-    return $where;
2206
+		if (!empty($query_args['with_videos_only'])) {
2207
+			$where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )";
2208
+		}
2209
+
2210
+		if (!empty($query_args['tax_query'])) {
2211
+			$tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
2212
+
2213
+			if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
2214
+				$where .= $tax_queries['where'];
2215
+			}
2216
+		}
2217
+	}
2218
+
2219
+	return $where;
2220 2220
 }
2221 2221
 
2222 2222
 /**
@@ -2231,14 +2231,14 @@  discard block
 block discarded – undo
2231 2231
  */
2232 2232
 function geodir_function_widget_listings_orderby($orderby)
2233 2233
 {
2234
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2234
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2235 2235
 
2236
-    $query_args = $gd_query_args_widgets;
2237
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2238
-        return $orderby;
2239
-    }
2236
+	$query_args = $gd_query_args_widgets;
2237
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2238
+		return $orderby;
2239
+	}
2240 2240
 
2241
-    return $orderby;
2241
+	return $orderby;
2242 2242
 }
2243 2243
 
2244 2244
 /**
@@ -2253,18 +2253,18 @@  discard block
 block discarded – undo
2253 2253
  */
2254 2254
 function geodir_function_widget_listings_limit($limit)
2255 2255
 {
2256
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2256
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2257 2257
 
2258
-    $query_args = $gd_query_args_widgets;
2259
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2260
-        return $limit;
2261
-    }
2258
+	$query_args = $gd_query_args_widgets;
2259
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2260
+		return $limit;
2261
+	}
2262 2262
 
2263
-    if (!empty($query_args) && !empty($query_args['posts_per_page'])) {
2264
-        $limit = (int)$query_args['posts_per_page'];
2265
-    }
2263
+	if (!empty($query_args) && !empty($query_args['posts_per_page'])) {
2264
+		$limit = (int)$query_args['posts_per_page'];
2265
+	}
2266 2266
 
2267
-    return $limit;
2267
+	return $limit;
2268 2268
 }
2269 2269
 
2270 2270
 /**
@@ -2278,24 +2278,24 @@  discard block
 block discarded – undo
2278 2278
  */
2279 2279
 function geodir_media_image_large_width($default = 800, $params = '')
2280 2280
 {
2281
-    $large_size_w = get_option('large_size_w');
2282
-    $large_size_w = $large_size_w > 0 ? $large_size_w : $default;
2283
-    $large_size_w = absint($large_size_w);
2284
-
2285
-    if (!get_option('geodir_use_wp_media_large_size')) {
2286
-        $large_size_w = 800;
2287
-    }
2288
-
2289
-    /**
2290
-     * Filter large image width.
2291
-     *
2292
-     * @since 1.0.0
2293
-     * @param int $large_size_w Large image width.
2294
-     * @param int $default Default width.
2295
-     * @param string|array $params Image parameters.
2296
-     */
2297
-    $large_size_w = apply_filters('geodir_filter_media_image_large_width', $large_size_w, $default, $params);
2298
-    return $large_size_w;
2281
+	$large_size_w = get_option('large_size_w');
2282
+	$large_size_w = $large_size_w > 0 ? $large_size_w : $default;
2283
+	$large_size_w = absint($large_size_w);
2284
+
2285
+	if (!get_option('geodir_use_wp_media_large_size')) {
2286
+		$large_size_w = 800;
2287
+	}
2288
+
2289
+	/**
2290
+	 * Filter large image width.
2291
+	 *
2292
+	 * @since 1.0.0
2293
+	 * @param int $large_size_w Large image width.
2294
+	 * @param int $default Default width.
2295
+	 * @param string|array $params Image parameters.
2296
+	 */
2297
+	$large_size_w = apply_filters('geodir_filter_media_image_large_width', $large_size_w, $default, $params);
2298
+	return $large_size_w;
2299 2299
 }
2300 2300
 
2301 2301
 /**
@@ -2309,25 +2309,25 @@  discard block
 block discarded – undo
2309 2309
  */
2310 2310
 function geodir_media_image_large_height($default = 800, $params = '')
2311 2311
 {
2312
-    $large_size_h = get_option('large_size_h');
2313
-    $large_size_h = $large_size_h > 0 ? $large_size_h : $default;
2314
-    $large_size_h = absint($large_size_h);
2315
-
2316
-    if (!get_option('geodir_use_wp_media_large_size')) {
2317
-        $large_size_h = 800;
2318
-    }
2319
-
2320
-    /**
2321
-     * Filter large image height.
2322
-     *
2323
-     * @since 1.0.0
2324
-     * @param int $large_size_h Large image height.
2325
-     * @param int $default Default height.
2326
-     * @param string|array $params Image parameters.
2327
-     */
2328
-    $large_size_h = apply_filters('geodir_filter_media_image_large_height', $large_size_h, $default, $params);
2312
+	$large_size_h = get_option('large_size_h');
2313
+	$large_size_h = $large_size_h > 0 ? $large_size_h : $default;
2314
+	$large_size_h = absint($large_size_h);
2315
+
2316
+	if (!get_option('geodir_use_wp_media_large_size')) {
2317
+		$large_size_h = 800;
2318
+	}
2329 2319
 
2330
-    return $large_size_h;
2320
+	/**
2321
+	 * Filter large image height.
2322
+	 *
2323
+	 * @since 1.0.0
2324
+	 * @param int $large_size_h Large image height.
2325
+	 * @param int $default Default height.
2326
+	 * @param string|array $params Image parameters.
2327
+	 */
2328
+	$large_size_h = apply_filters('geodir_filter_media_image_large_height', $large_size_h, $default, $params);
2329
+
2330
+	return $large_size_h;
2331 2331
 }
2332 2332
 
2333 2333
 /**
@@ -2342,25 +2342,25 @@  discard block
 block discarded – undo
2342 2342
  */
2343 2343
 function geodir_sanitize_location_name($type, $name, $translate = true)
2344 2344
 {
2345
-    if ($name == '') {
2346
-        return NULL;
2347
-    }
2348
-
2349
-    $type = $type == 'gd_country' ? 'country' : $type;
2350
-    $type = $type == 'gd_region' ? 'region' : $type;
2351
-    $type = $type == 'gd_city' ? 'city' : $type;
2352
-
2353
-    $return = $name;
2354
-    if (function_exists('get_actual_location_name')) {
2355
-        $return = get_actual_location_name($type, $name, $translate);
2356
-    } else {
2357
-        $return = preg_replace('/-(\d+)$/', '', $return);
2358
-        $return = preg_replace('/[_-]/', ' ', $return);
2359
-        $return = geodir_ucwords($return);
2360
-        $return = $translate ? __($return, 'geodirectory') : $return;
2361
-    }
2362
-
2363
-    return $return;
2345
+	if ($name == '') {
2346
+		return NULL;
2347
+	}
2348
+
2349
+	$type = $type == 'gd_country' ? 'country' : $type;
2350
+	$type = $type == 'gd_region' ? 'region' : $type;
2351
+	$type = $type == 'gd_city' ? 'city' : $type;
2352
+
2353
+	$return = $name;
2354
+	if (function_exists('get_actual_location_name')) {
2355
+		$return = get_actual_location_name($type, $name, $translate);
2356
+	} else {
2357
+		$return = preg_replace('/-(\d+)$/', '', $return);
2358
+		$return = preg_replace('/[_-]/', ' ', $return);
2359
+		$return = geodir_ucwords($return);
2360
+		$return = $translate ? __($return, 'geodirectory') : $return;
2361
+	}
2362
+
2363
+	return $return;
2364 2364
 }
2365 2365
 
2366 2366
 
@@ -2374,14 +2374,14 @@  discard block
 block discarded – undo
2374 2374
 function geodir_comments_number($number)
2375 2375
 {
2376 2376
 
2377
-    if ($number > 1) {
2378
-        $output = str_replace('%', number_format_i18n($number), __('% Reviews', 'geodirectory'));
2379
-    } elseif ($number == 0 || $number == '') {
2380
-        $output = __('No Reviews', 'geodirectory');
2381
-    } else { // must be one
2382
-        $output = __('1 Review', 'geodirectory');
2383
-    }
2384
-    echo $output;
2377
+	if ($number > 1) {
2378
+		$output = str_replace('%', number_format_i18n($number), __('% Reviews', 'geodirectory'));
2379
+	} elseif ($number == 0 || $number == '') {
2380
+		$output = __('No Reviews', 'geodirectory');
2381
+	} else { // must be one
2382
+		$output = __('1 Review', 'geodirectory');
2383
+	}
2384
+	echo $output;
2385 2385
 }
2386 2386
 
2387 2387
 /**
@@ -2394,23 +2394,23 @@  discard block
 block discarded – undo
2394 2394
  */
2395 2395
 function is_page_geodir_home()
2396 2396
 {
2397
-    global $wpdb;
2398
-    $cur_url = str_replace(array("https://", "http://", "www."), array('', '', ''), geodir_curPageURL());
2399
-    if (function_exists('geodir_location_geo_home_link')) {
2400
-        remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
2401
-    }
2402
-    $home_url = home_url('', 'http');
2403
-    if (function_exists('geodir_location_geo_home_link')) {
2404
-        add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
2405
-    }
2406
-    $home_url = str_replace("www.", "", $home_url);
2407
-    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')) ) {
2408
-        return true;
2409
-    }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')){
2410
-        return true;
2411
-    } else {
2412
-        return false;
2413
-    }
2397
+	global $wpdb;
2398
+	$cur_url = str_replace(array("https://", "http://", "www."), array('', '', ''), geodir_curPageURL());
2399
+	if (function_exists('geodir_location_geo_home_link')) {
2400
+		remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
2401
+	}
2402
+	$home_url = home_url('', 'http');
2403
+	if (function_exists('geodir_location_geo_home_link')) {
2404
+		add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
2405
+	}
2406
+	$home_url = str_replace("www.", "", $home_url);
2407
+	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')) ) {
2408
+		return true;
2409
+	}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')){
2410
+		return true;
2411
+	} else {
2412
+		return false;
2413
+	}
2414 2414
 
2415 2415
 }
2416 2416
 
@@ -2426,13 +2426,13 @@  discard block
 block discarded – undo
2426 2426
  */
2427 2427
 function geodir_wpseo_homepage_canonical($url)
2428 2428
 {
2429
-    global $post;
2429
+	global $post;
2430 2430
 
2431
-    if (is_page_geodir_home()) {
2432
-        return home_url();
2433
-    }
2431
+	if (is_page_geodir_home()) {
2432
+		return home_url();
2433
+	}
2434 2434
 
2435
-    return $url;
2435
+	return $url;
2436 2436
 }
2437 2437
 
2438 2438
 add_filter('wpseo_canonical', 'geodir_wpseo_homepage_canonical', 10);
@@ -2449,16 +2449,16 @@  discard block
 block discarded – undo
2449 2449
  */
2450 2450
 function geodir_googlemap_script_extra_details_page($extra)
2451 2451
 {
2452
-    global $post;
2453
-    $add_google_places_api = false;
2454
-    if (isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
2455
-        $add_google_places_api = true;
2456
-    }
2457
-    if (!str_replace('libraries=places', '', $extra) && (geodir_is_page('detail') || $add_google_places_api)) {
2458
-        $extra .= "&amp;libraries=places";
2459
-    }
2460
-
2461
-    return $extra;
2452
+	global $post;
2453
+	$add_google_places_api = false;
2454
+	if (isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
2455
+		$add_google_places_api = true;
2456
+	}
2457
+	if (!str_replace('libraries=places', '', $extra) && (geodir_is_page('detail') || $add_google_places_api)) {
2458
+		$extra .= "&amp;libraries=places";
2459
+	}
2460
+
2461
+	return $extra;
2462 2462
 }
2463 2463
 
2464 2464
 add_filter('geodir_googlemap_script_extra', 'geodir_googlemap_script_extra_details_page', 101, 1);
@@ -2478,98 +2478,98 @@  discard block
 block discarded – undo
2478 2478
  */
2479 2479
 function geodir_popular_post_category_output($args = '', $instance = '')
2480 2480
 {
2481
-    // prints the widget
2482
-    global $wpdb, $plugin_prefix, $geodir_post_category_str;
2483
-    extract($args, EXTR_SKIP);
2484
-
2485
-    echo $before_widget;
2486
-
2487
-    /** This filter is documented in geodirectory_widgets.php */
2488
-    $title = empty($instance['title']) ? __('Popular Categories', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2489
-
2490
-    $gd_post_type = geodir_get_current_posttype();
2491
-
2492
-    $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15;
2493
-    if(!empty($gd_post_type)){
2494
-        $default_post_type = $gd_post_type;
2495
-    }elseif(isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ){
2496
-        $default_post_type = $instance['default_post_type'];
2497
-    }else{
2498
-        $all_gd_post_type = geodir_get_posttypes();
2499
-        $default_post_type = (isset($all_gd_post_type[0])) ? $all_gd_post_type[0] : '';
2500
-    }
2501
-
2502
-    $taxonomy = array();
2503
-    if (!empty($gd_post_type)) {
2504
-        $taxonomy[] = $gd_post_type . "category";
2505
-    } else {
2506
-        $taxonomy = geodir_get_taxonomies($gd_post_type);
2507
-    }
2508
-
2509
-    $terms = get_terms($taxonomy);
2510
-    $a_terms = array();
2511
-    $b_terms = array();
2512
-
2513
-    foreach ($terms as $term) {
2514
-        if ($term->count > 0) {
2515
-            $a_terms[$term->taxonomy][] = $term;
2516
-        }
2517
-    }
2518
-
2519
-    if (!empty($a_terms)) {
2520
-        foreach ($a_terms as $b_key => $b_val) {
2521
-            $b_terms[$b_key] = geodir_sort_terms($b_val, 'count');
2522
-        }
2523
-
2524
-        $default_taxonomy = $default_post_type != '' && isset($b_terms[$default_post_type . 'category']) ? $default_post_type . 'category' : '';
2525
-
2526
-        $tax_change_output = '';
2527
-        if (count($b_terms) > 1) {
2528
-            $tax_change_output .= "<select data-limit='$category_limit' class='geodir-cat-list-tax'  onchange='geodir_get_post_term(this);'>";
2529
-            foreach ($b_terms as $key => $val) {
2530
-                $ptype = get_post_type_object(str_replace("category", "", $key));
2531
-                $cpt_name = __($ptype->labels->singular_name, 'geodirectory');
2532
-                $tax_change_output .= "<option value='$key' ". selected($key, $default_taxonomy, false) .">" . sprintf(__('%s Categories', 'geodirectory'),$cpt_name) . "</option>";
2533
-            }
2534
-            $tax_change_output .= "</select>";
2535
-        }
2536
-
2537
-        if (!empty($b_terms)) {
2538
-            $terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms);// get the first array
2539
-            global $cat_count;//make global so we can change via function
2540
-            $cat_count = 0;
2541
-            ?>
2481
+	// prints the widget
2482
+	global $wpdb, $plugin_prefix, $geodir_post_category_str;
2483
+	extract($args, EXTR_SKIP);
2484
+
2485
+	echo $before_widget;
2486
+
2487
+	/** This filter is documented in geodirectory_widgets.php */
2488
+	$title = empty($instance['title']) ? __('Popular Categories', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2489
+
2490
+	$gd_post_type = geodir_get_current_posttype();
2491
+
2492
+	$category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15;
2493
+	if(!empty($gd_post_type)){
2494
+		$default_post_type = $gd_post_type;
2495
+	}elseif(isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ){
2496
+		$default_post_type = $instance['default_post_type'];
2497
+	}else{
2498
+		$all_gd_post_type = geodir_get_posttypes();
2499
+		$default_post_type = (isset($all_gd_post_type[0])) ? $all_gd_post_type[0] : '';
2500
+	}
2501
+
2502
+	$taxonomy = array();
2503
+	if (!empty($gd_post_type)) {
2504
+		$taxonomy[] = $gd_post_type . "category";
2505
+	} else {
2506
+		$taxonomy = geodir_get_taxonomies($gd_post_type);
2507
+	}
2508
+
2509
+	$terms = get_terms($taxonomy);
2510
+	$a_terms = array();
2511
+	$b_terms = array();
2512
+
2513
+	foreach ($terms as $term) {
2514
+		if ($term->count > 0) {
2515
+			$a_terms[$term->taxonomy][] = $term;
2516
+		}
2517
+	}
2518
+
2519
+	if (!empty($a_terms)) {
2520
+		foreach ($a_terms as $b_key => $b_val) {
2521
+			$b_terms[$b_key] = geodir_sort_terms($b_val, 'count');
2522
+		}
2523
+
2524
+		$default_taxonomy = $default_post_type != '' && isset($b_terms[$default_post_type . 'category']) ? $default_post_type . 'category' : '';
2525
+
2526
+		$tax_change_output = '';
2527
+		if (count($b_terms) > 1) {
2528
+			$tax_change_output .= "<select data-limit='$category_limit' class='geodir-cat-list-tax'  onchange='geodir_get_post_term(this);'>";
2529
+			foreach ($b_terms as $key => $val) {
2530
+				$ptype = get_post_type_object(str_replace("category", "", $key));
2531
+				$cpt_name = __($ptype->labels->singular_name, 'geodirectory');
2532
+				$tax_change_output .= "<option value='$key' ". selected($key, $default_taxonomy, false) .">" . sprintf(__('%s Categories', 'geodirectory'),$cpt_name) . "</option>";
2533
+			}
2534
+			$tax_change_output .= "</select>";
2535
+		}
2536
+
2537
+		if (!empty($b_terms)) {
2538
+			$terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms);// get the first array
2539
+			global $cat_count;//make global so we can change via function
2540
+			$cat_count = 0;
2541
+			?>
2542 2542
             <div class="geodir-category-list-in clearfix">
2543 2543
                 <div class="geodir-cat-list clearfix">
2544 2544
                     <?php
2545
-                    echo $before_title . __($title) . $after_title;
2545
+					echo $before_title . __($title) . $after_title;
2546 2546
 
2547
-                    echo $tax_change_output;
2547
+					echo $tax_change_output;
2548 2548
 
2549
-                    echo '<ul class="geodir-popular-cat-list">';
2549
+					echo '<ul class="geodir-popular-cat-list">';
2550 2550
 
2551
-                    geodir_helper_cat_list_output($terms, $category_limit);
2551
+					geodir_helper_cat_list_output($terms, $category_limit);
2552 2552
 
2553
-                    echo '</ul>';
2554
-                    ?>
2553
+					echo '</ul>';
2554
+					?>
2555 2555
                 </div>
2556 2556
                 <?php
2557
-                $hide = '';
2558
-                if ($cat_count < $category_limit) {
2559
-                    $hide = 'style="display:none;"';
2560
-                }
2561
-                echo "<div class='geodir-cat-list-more' $hide >";
2562
-                echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">' . __('More Categories', 'geodirectory') . '</a>';
2563
-                echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">' . __('Less Categories', 'geodirectory') . '</a>';
2564
-                echo "</div>";
2565
-                /* add scripts */
2566
-                add_action('wp_footer', 'geodir_popular_category_add_scripts', 100);
2567
-                ?>
2557
+				$hide = '';
2558
+				if ($cat_count < $category_limit) {
2559
+					$hide = 'style="display:none;"';
2560
+				}
2561
+				echo "<div class='geodir-cat-list-more' $hide >";
2562
+				echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">' . __('More Categories', 'geodirectory') . '</a>';
2563
+				echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">' . __('Less Categories', 'geodirectory') . '</a>';
2564
+				echo "</div>";
2565
+				/* add scripts */
2566
+				add_action('wp_footer', 'geodir_popular_category_add_scripts', 100);
2567
+				?>
2568 2568
             </div>
2569 2569
         <?php
2570
-        }
2571
-    }
2572
-    echo $after_widget;
2570
+		}
2571
+	}
2572
+	echo $after_widget;
2573 2573
 }
2574 2574
 
2575 2575
 /**
@@ -2583,38 +2583,38 @@  discard block
 block discarded – undo
2583 2583
  */
2584 2584
 function geodir_helper_cat_list_output($terms, $category_limit)
2585 2585
 {
2586
-    global $geodir_post_category_str, $cat_count;
2587
-    $term_icons = geodir_get_term_icon();
2586
+	global $geodir_post_category_str, $cat_count;
2587
+	$term_icons = geodir_get_term_icon();
2588 2588
 
2589
-    $geodir_post_category_str = array();
2589
+	$geodir_post_category_str = array();
2590 2590
 
2591 2591
 
2592
-    foreach ($terms as $cat) {
2593
-        $post_type = str_replace("category", "", $cat->taxonomy);
2594
-        $term_icon_url = !empty($term_icons) && isset($term_icons[$cat->term_id]) ? $term_icons[$cat->term_id] : '';
2592
+	foreach ($terms as $cat) {
2593
+		$post_type = str_replace("category", "", $cat->taxonomy);
2594
+		$term_icon_url = !empty($term_icons) && isset($term_icons[$cat->term_id]) ? $term_icons[$cat->term_id] : '';
2595 2595
 
2596
-        $cat_count++;
2596
+		$cat_count++;
2597 2597
 
2598
-        $geodir_post_category_str[] = array('posttype' => $post_type, 'termid' => $cat->term_id);
2598
+		$geodir_post_category_str[] = array('posttype' => $post_type, 'termid' => $cat->term_id);
2599 2599
 
2600
-        $class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show';
2601
-        $total_post = $cat->count;
2600
+		$class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show';
2601
+		$total_post = $cat->count;
2602 2602
 
2603
-        $term_link = get_term_link( $cat, $cat->taxonomy );
2604
-        /**
2605
-         * Filer the category term link.
2606
-         *
2607
-         * @since 1.4.5
2608
-         * @param string $term_link The term permalink.
2609
-         * @param int    $cat->term_id The term id.
2610
-         * @param string $post_type Wordpress post type.
2611
-         */
2612
-        $term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type );
2603
+		$term_link = get_term_link( $cat, $cat->taxonomy );
2604
+		/**
2605
+		 * Filer the category term link.
2606
+		 *
2607
+		 * @since 1.4.5
2608
+		 * @param string $term_link The term permalink.
2609
+		 * @param int    $cat->term_id The term id.
2610
+		 * @param string $post_type Wordpress post type.
2611
+		 */
2612
+		$term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type );
2613 2613
 
2614
-        echo '<li class="' . $class_row . '"><a href="' . $term_link . '">';
2615
-        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> ';
2616
-        echo '</a></li>';
2617
-    }
2614
+		echo '<li class="' . $class_row . '"><a href="' . $term_link . '">';
2615
+		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> ';
2616
+		echo '</a></li>';
2617
+	}
2618 2618
 }
2619 2619
 
2620 2620
 /**
@@ -2628,108 +2628,108 @@  discard block
 block discarded – undo
2628 2628
  */
2629 2629
 function geodir_listing_slider_widget_output($args = '', $instance = '')
2630 2630
 {
2631
-    // prints the widget
2632
-    extract($args, EXTR_SKIP);
2633
-
2634
-    echo $before_widget;
2635
-
2636
-    /** This filter is documented in geodirectory_widgets.php */
2637
-    $title = empty($instance['title']) ? '' : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2638
-    /**
2639
-     * Filter the widget post type.
2640
-     *
2641
-     * @since 1.0.0
2642
-     * @param string $instance['post_type'] Post type of listing.
2643
-     */
2644
-    $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
2645
-    /**
2646
-     * Filter the widget's term.
2647
-     *
2648
-     * @since 1.0.0
2649
-     * @param string $instance['category'] Filter by term. Can be any valid term.
2650
-     */
2651
-    $category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
2652
-    /**
2653
-     * Filter the widget listings limit.
2654
-     *
2655
-     * @since 1.0.0
2656
-     * @param string $instance['post_number'] Number of listings to display.
2657
-     */
2658
-    $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
2659
-    /**
2660
-     * Filter the widget listings limit shown at one time.
2661
-     *
2662
-     * @since 1.5.0
2663
-     * @param string $instance['max_show'] Number of listings to display on screen.
2664
-     */
2665
-    $max_show = empty($instance['max_show']) ? '1' : apply_filters('widget_max_show', $instance['max_show']);
2666
-    /**
2667
-     * Filter the widget slide width.
2668
-     *
2669
-     * @since 1.5.0
2670
-     * @param string $instance['slide_width'] Width of the slides shown.
2671
-     */
2672
-    $slide_width = empty($instance['slide_width']) ? '' : apply_filters('widget_slide_width', $instance['slide_width']);
2673
-    /**
2674
-     * Filter widget's "show title" value.
2675
-     *
2676
-     * @since 1.0.0
2677
-     * @param string|bool $instance['show_title'] Do you want to display title? Can be 1 or 0.
2678
-     */
2679
-    $show_title = empty($instance['show_title']) ? '' : apply_filters('widget_show_title', $instance['show_title']);
2680
-    /**
2681
-     * Filter widget's "slideshow" value.
2682
-     *
2683
-     * @since 1.0.0
2684
-     * @param int $instance['slideshow'] Setup a slideshow for the slider to animate automatically.
2685
-     */
2686
-    $slideshow = empty($instance['slideshow']) ? 0 : apply_filters('widget_slideshow', $instance['slideshow']);
2687
-    /**
2688
-     * Filter widget's "animationLoop" value.
2689
-     *
2690
-     * @since 1.0.0
2691
-     * @param int $instance['animationLoop'] Gives the slider a seamless infinite loop.
2692
-     */
2693
-    $animationLoop = empty($instance['animationLoop']) ? 0 : apply_filters('widget_animationLoop', $instance['animationLoop']);
2694
-    /**
2695
-     * Filter widget's "directionNav" value.
2696
-     *
2697
-     * @since 1.0.0
2698
-     * @param int $instance['directionNav'] Enable previous/next arrow navigation?. Can be 1 or 0.
2699
-     */
2700
-    $directionNav = empty($instance['directionNav']) ? 0 : apply_filters('widget_directionNav', $instance['directionNav']);
2701
-    /**
2702
-     * Filter widget's "slideshowSpeed" value.
2703
-     *
2704
-     * @since 1.0.0
2705
-     * @param int $instance['slideshowSpeed'] Set the speed of the slideshow cycling, in milliseconds.
2706
-     */
2707
-    $slideshowSpeed = empty($instance['slideshowSpeed']) ? 5000 : apply_filters('widget_slideshowSpeed', $instance['slideshowSpeed']);
2708
-    /**
2709
-     * Filter widget's "animationSpeed" value.
2710
-     *
2711
-     * @since 1.0.0
2712
-     * @param int $instance['animationSpeed'] Set the speed of animations, in milliseconds.
2713
-     */
2714
-    $animationSpeed = empty($instance['animationSpeed']) ? 600 : apply_filters('widget_animationSpeed', $instance['animationSpeed']);
2715
-    /**
2716
-     * Filter widget's "animation" value.
2717
-     *
2718
-     * @since 1.0.0
2719
-     * @param string $instance['animation'] Controls the animation type, "fade" or "slide".
2720
-     */
2721
-    $animation = empty($instance['animation']) ? 'slide' : apply_filters('widget_animation', $instance['animation']);
2722
-    /**
2723
-     * Filter widget's "list_sort" type.
2724
-     *
2725
-     * @since 1.0.0
2726
-     * @param string $instance['list_sort'] Listing sort by type.
2727
-     */
2728
-    $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
2729
-    $show_featured_only = !empty($instance['show_featured_only']) ? 1 : NULL;
2730
-
2731
-    wp_enqueue_script('geodirectory-jquery-flexslider-js');
2732
-    ?>
2631
+	// prints the widget
2632
+	extract($args, EXTR_SKIP);
2633
+
2634
+	echo $before_widget;
2635
+
2636
+	/** This filter is documented in geodirectory_widgets.php */
2637
+	$title = empty($instance['title']) ? '' : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2638
+	/**
2639
+	 * Filter the widget post type.
2640
+	 *
2641
+	 * @since 1.0.0
2642
+	 * @param string $instance['post_type'] Post type of listing.
2643
+	 */
2644
+	$post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
2645
+	/**
2646
+	 * Filter the widget's term.
2647
+	 *
2648
+	 * @since 1.0.0
2649
+	 * @param string $instance['category'] Filter by term. Can be any valid term.
2650
+	 */
2651
+	$category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
2652
+	/**
2653
+	 * Filter the widget listings limit.
2654
+	 *
2655
+	 * @since 1.0.0
2656
+	 * @param string $instance['post_number'] Number of listings to display.
2657
+	 */
2658
+	$post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
2659
+	/**
2660
+	 * Filter the widget listings limit shown at one time.
2661
+	 *
2662
+	 * @since 1.5.0
2663
+	 * @param string $instance['max_show'] Number of listings to display on screen.
2664
+	 */
2665
+	$max_show = empty($instance['max_show']) ? '1' : apply_filters('widget_max_show', $instance['max_show']);
2666
+	/**
2667
+	 * Filter the widget slide width.
2668
+	 *
2669
+	 * @since 1.5.0
2670
+	 * @param string $instance['slide_width'] Width of the slides shown.
2671
+	 */
2672
+	$slide_width = empty($instance['slide_width']) ? '' : apply_filters('widget_slide_width', $instance['slide_width']);
2673
+	/**
2674
+	 * Filter widget's "show title" value.
2675
+	 *
2676
+	 * @since 1.0.0
2677
+	 * @param string|bool $instance['show_title'] Do you want to display title? Can be 1 or 0.
2678
+	 */
2679
+	$show_title = empty($instance['show_title']) ? '' : apply_filters('widget_show_title', $instance['show_title']);
2680
+	/**
2681
+	 * Filter widget's "slideshow" value.
2682
+	 *
2683
+	 * @since 1.0.0
2684
+	 * @param int $instance['slideshow'] Setup a slideshow for the slider to animate automatically.
2685
+	 */
2686
+	$slideshow = empty($instance['slideshow']) ? 0 : apply_filters('widget_slideshow', $instance['slideshow']);
2687
+	/**
2688
+	 * Filter widget's "animationLoop" value.
2689
+	 *
2690
+	 * @since 1.0.0
2691
+	 * @param int $instance['animationLoop'] Gives the slider a seamless infinite loop.
2692
+	 */
2693
+	$animationLoop = empty($instance['animationLoop']) ? 0 : apply_filters('widget_animationLoop', $instance['animationLoop']);
2694
+	/**
2695
+	 * Filter widget's "directionNav" value.
2696
+	 *
2697
+	 * @since 1.0.0
2698
+	 * @param int $instance['directionNav'] Enable previous/next arrow navigation?. Can be 1 or 0.
2699
+	 */
2700
+	$directionNav = empty($instance['directionNav']) ? 0 : apply_filters('widget_directionNav', $instance['directionNav']);
2701
+	/**
2702
+	 * Filter widget's "slideshowSpeed" value.
2703
+	 *
2704
+	 * @since 1.0.0
2705
+	 * @param int $instance['slideshowSpeed'] Set the speed of the slideshow cycling, in milliseconds.
2706
+	 */
2707
+	$slideshowSpeed = empty($instance['slideshowSpeed']) ? 5000 : apply_filters('widget_slideshowSpeed', $instance['slideshowSpeed']);
2708
+	/**
2709
+	 * Filter widget's "animationSpeed" value.
2710
+	 *
2711
+	 * @since 1.0.0
2712
+	 * @param int $instance['animationSpeed'] Set the speed of animations, in milliseconds.
2713
+	 */
2714
+	$animationSpeed = empty($instance['animationSpeed']) ? 600 : apply_filters('widget_animationSpeed', $instance['animationSpeed']);
2715
+	/**
2716
+	 * Filter widget's "animation" value.
2717
+	 *
2718
+	 * @since 1.0.0
2719
+	 * @param string $instance['animation'] Controls the animation type, "fade" or "slide".
2720
+	 */
2721
+	$animation = empty($instance['animation']) ? 'slide' : apply_filters('widget_animation', $instance['animation']);
2722
+	/**
2723
+	 * Filter widget's "list_sort" type.
2724
+	 *
2725
+	 * @since 1.0.0
2726
+	 * @param string $instance['list_sort'] Listing sort by type.
2727
+	 */
2728
+	$list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
2729
+	$show_featured_only = !empty($instance['show_featured_only']) ? 1 : NULL;
2730
+
2731
+	wp_enqueue_script('geodirectory-jquery-flexslider-js');
2732
+	?>
2733 2733
     <script type="text/javascript">
2734 2734
         jQuery(window).load(function () {
2735 2735
             jQuery('#geodir_widget_carousel').flexslider({
@@ -2770,86 +2770,86 @@  discard block
 block discarded – undo
2770 2770
         });
2771 2771
     </script>
2772 2772
     <?php
2773
-    $query_args = array(
2774
-        'posts_per_page' => $post_number,
2775
-        'is_geodir_loop' => true,
2776
-        'post_type' => $post_type,
2777
-        'order_by' => $list_sort
2778
-    );
2779
-    if ($show_featured_only) {
2780
-        $query_args['show_featured_only'] = 1;
2781
-    }
2782
-
2783
-    if ($category != 0 || $category != '') {
2784
-        $category_taxonomy = geodir_get_taxonomies($post_type);
2785
-        $tax_query = array(
2786
-            'taxonomy' => $category_taxonomy[0],
2787
-            'field' => 'id',
2788
-            'terms' => $category
2789
-        );
2790
-
2791
-        $query_args['tax_query'] = array($tax_query);
2792
-    }
2793
-
2794
-    // we want listings with featured image only
2795
-    $query_args['featured_image_only'] = 1;
2796
-
2797
-    if ($post_type == 'gd_event') {
2798
-        $query_args['gedir_event_listing_filter'] = 'upcoming';
2799
-    }// show only upcomming events
2800
-
2801
-    $widget_listings = geodir_get_widget_listings($query_args);
2802
-    if (!empty($widget_listings) || (isset($with_no_results) && $with_no_results)) {
2803
-        if ($title) {
2804
-            echo $before_title . $title . $after_title;
2805
-        }
2806
-
2807
-        global $post;
2808
-
2809
-        $current_post = $post;// keep current post info
2810
-
2811
-        $widget_main_slides = '';
2812
-        $nav_slides = '';
2813
-        $widget_slides = 0;
2814
-
2815
-        foreach ($widget_listings as $widget_listing) {
2816
-            global $gd_widget_listing_type;
2817
-            $post = $widget_listing;
2818
-            $widget_image = geodir_get_featured_image($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
2819
-
2820
-            if (!empty($widget_image)) {
2821
-                if ($widget_image->height >= 200) {
2822
-                    $widget_spacer_height = 0;
2823
-                } else {
2824
-                    $widget_spacer_height = ((200 - $widget_image->height) / 2);
2825
-                }
2826
-
2827
-                $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" />';
2828
-
2829
-                $title = '';
2830
-                if ($show_title) {
2831
-                    $title_html = '<div class="geodir-slider-title"><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a></div>';
2832
-                    $post_id = $post->ID;
2833
-                    $post_permalink = get_permalink($post->ID);
2834
-                    $post_title = get_the_title($post->ID);
2835
-                    /**
2836
-                     * Filter the listing slider widget title.
2837
-                     *
2838
-                     * @since 1.6.1
2839
-                     * @param string $title_html The html output of the title.
2840
-                     * @param int $post_id The post id.
2841
-                     * @param string $post_permalink The post permalink url.
2842
-                     * @param string $post_title The post title text.
2843
-                     */
2844
-                    $title = apply_filters('geodir_listing_slider_title',$title_html,$post_id,$post_permalink,$post_title);
2845
-                }
2846
-
2847
-                $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>';
2848
-                $nav_slides .= '<li><img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:48px;margin:0 auto;" /></li>';
2849
-                $widget_slides++;
2850
-            }
2851
-        }
2852
-        ?>
2773
+	$query_args = array(
2774
+		'posts_per_page' => $post_number,
2775
+		'is_geodir_loop' => true,
2776
+		'post_type' => $post_type,
2777
+		'order_by' => $list_sort
2778
+	);
2779
+	if ($show_featured_only) {
2780
+		$query_args['show_featured_only'] = 1;
2781
+	}
2782
+
2783
+	if ($category != 0 || $category != '') {
2784
+		$category_taxonomy = geodir_get_taxonomies($post_type);
2785
+		$tax_query = array(
2786
+			'taxonomy' => $category_taxonomy[0],
2787
+			'field' => 'id',
2788
+			'terms' => $category
2789
+		);
2790
+
2791
+		$query_args['tax_query'] = array($tax_query);
2792
+	}
2793
+
2794
+	// we want listings with featured image only
2795
+	$query_args['featured_image_only'] = 1;
2796
+
2797
+	if ($post_type == 'gd_event') {
2798
+		$query_args['gedir_event_listing_filter'] = 'upcoming';
2799
+	}// show only upcomming events
2800
+
2801
+	$widget_listings = geodir_get_widget_listings($query_args);
2802
+	if (!empty($widget_listings) || (isset($with_no_results) && $with_no_results)) {
2803
+		if ($title) {
2804
+			echo $before_title . $title . $after_title;
2805
+		}
2806
+
2807
+		global $post;
2808
+
2809
+		$current_post = $post;// keep current post info
2810
+
2811
+		$widget_main_slides = '';
2812
+		$nav_slides = '';
2813
+		$widget_slides = 0;
2814
+
2815
+		foreach ($widget_listings as $widget_listing) {
2816
+			global $gd_widget_listing_type;
2817
+			$post = $widget_listing;
2818
+			$widget_image = geodir_get_featured_image($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
2819
+
2820
+			if (!empty($widget_image)) {
2821
+				if ($widget_image->height >= 200) {
2822
+					$widget_spacer_height = 0;
2823
+				} else {
2824
+					$widget_spacer_height = ((200 - $widget_image->height) / 2);
2825
+				}
2826
+
2827
+				$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" />';
2828
+
2829
+				$title = '';
2830
+				if ($show_title) {
2831
+					$title_html = '<div class="geodir-slider-title"><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a></div>';
2832
+					$post_id = $post->ID;
2833
+					$post_permalink = get_permalink($post->ID);
2834
+					$post_title = get_the_title($post->ID);
2835
+					/**
2836
+					 * Filter the listing slider widget title.
2837
+					 *
2838
+					 * @since 1.6.1
2839
+					 * @param string $title_html The html output of the title.
2840
+					 * @param int $post_id The post id.
2841
+					 * @param string $post_permalink The post permalink url.
2842
+					 * @param string $post_title The post title text.
2843
+					 */
2844
+					$title = apply_filters('geodir_listing_slider_title',$title_html,$post_id,$post_permalink,$post_title);
2845
+				}
2846
+
2847
+				$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>';
2848
+				$nav_slides .= '<li><img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:48px;margin:0 auto;" /></li>';
2849
+				$widget_slides++;
2850
+			}
2851
+		}
2852
+		?>
2853 2853
         <div class="flex-container" style="min-height:200px;">
2854 2854
             <div class="geodir-listing-flex-loader"><i class="fa fa-refresh fa-spin"></i></div>
2855 2855
             <div id="geodir_widget_slider" class="geodir_flexslider">
@@ -2862,10 +2862,10 @@  discard block
 block discarded – undo
2862 2862
             <?php } ?>
2863 2863
         </div>
2864 2864
         <?php
2865
-        $GLOBALS['post'] = $current_post;
2866
-        setup_postdata($current_post);
2867
-    }
2868
-    echo $after_widget;
2865
+		$GLOBALS['post'] = $current_post;
2866
+		setup_postdata($current_post);
2867
+	}
2868
+	echo $after_widget;
2869 2869
 }
2870 2870
 
2871 2871
 
@@ -2880,65 +2880,65 @@  discard block
 block discarded – undo
2880 2880
  */
2881 2881
 function geodir_loginwidget_output($args = '', $instance = '')
2882 2882
 {
2883
-    //print_r($args);
2884
-    //print_r($instance);
2885
-    // prints the widget
2886
-    extract($args, EXTR_SKIP);
2883
+	//print_r($args);
2884
+	//print_r($instance);
2885
+	// prints the widget
2886
+	extract($args, EXTR_SKIP);
2887 2887
 
2888
-    /** This filter is documented in geodirectory_widgets.php */
2889
-    $title = empty($instance['title']) ? __('My Dashboard', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2888
+	/** This filter is documented in geodirectory_widgets.php */
2889
+	$title = empty($instance['title']) ? __('My Dashboard', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2890 2890
 
2891
-    echo $before_widget;
2892
-    echo $before_title . $title . $after_title;
2891
+	echo $before_widget;
2892
+	echo $before_title . $title . $after_title;
2893 2893
 
2894
-    if (is_user_logged_in()) {
2895
-        global $current_user;
2894
+	if (is_user_logged_in()) {
2895
+		global $current_user;
2896 2896
 
2897
-        $author_link = get_author_posts_url($current_user->data->ID);
2898
-        $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false);
2897
+		$author_link = get_author_posts_url($current_user->data->ID);
2898
+		$author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false);
2899 2899
 
2900
-        echo '<ul class="geodir-loginbox-list">';
2901
-        ob_start();
2902
-        ?>
2900
+		echo '<ul class="geodir-loginbox-list">';
2901
+		ob_start();
2902
+		?>
2903 2903
         <li><a class="signin"
2904 2904
                href="<?php echo wp_logout_url(home_url()); ?>"><?php _e('Logout', 'geodirectory'); ?></a></li>
2905 2905
         <?php
2906
-        $post_types = geodir_get_posttypes('object');
2907
-        $show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_user_dashboard');
2908
-        $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
2906
+		$post_types = geodir_get_posttypes('object');
2907
+		$show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_user_dashboard');
2908
+		$geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
2909 2909
 
2910
-        if (!empty($show_add_listing_post_types_main_nav)) {
2911
-            $addlisting_links = '';
2912
-            foreach ($post_types as $key => $postobj) {
2910
+		if (!empty($show_add_listing_post_types_main_nav)) {
2911
+			$addlisting_links = '';
2912
+			foreach ($post_types as $key => $postobj) {
2913 2913
 
2914
-                if (in_array($key, $show_add_listing_post_types_main_nav)) {
2914
+				if (in_array($key, $show_add_listing_post_types_main_nav)) {
2915 2915
 
2916
-                    if ($add_link = geodir_get_addlisting_link($key)) {
2916
+					if ($add_link = geodir_get_addlisting_link($key)) {
2917 2917
 
2918
-                        $name = $postobj->labels->name;
2918
+						$name = $postobj->labels->name;
2919 2919
 
2920
-                        $selected = '';
2921
-                        if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing'))
2922
-                            $selected = 'selected="selected"';
2920
+						$selected = '';
2921
+						if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing'))
2922
+							$selected = 'selected="selected"';
2923 2923
 
2924
-                        /**
2925
-                         * Filter add listing link.
2926
-                         *
2927
-                         * @since 1.0.0
2928
-                         * @param string $add_link Add listing link.
2929
-                         * @param string $key Add listing array key.
2930
-                         * @param int $current_user->ID Current user ID.
2931
-                         */
2932
-                        $add_link = apply_filters('geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID);
2924
+						/**
2925
+						 * Filter add listing link.
2926
+						 *
2927
+						 * @since 1.0.0
2928
+						 * @param string $add_link Add listing link.
2929
+						 * @param string $key Add listing array key.
2930
+						 * @param int $current_user->ID Current user ID.
2931
+						 */
2932
+						$add_link = apply_filters('geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID);
2933 2933
 
2934
-                        $addlisting_links .= '<option ' . $selected . ' value="' . $add_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2934
+						$addlisting_links .= '<option ' . $selected . ' value="' . $add_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2935 2935
 
2936
-                    }
2937
-                }
2936
+					}
2937
+				}
2938 2938
 
2939
-            }
2939
+			}
2940 2940
 
2941
-            if ($addlisting_links != '') { ?>
2941
+			if ($addlisting_links != '') { ?>
2942 2942
 
2943 2943
                 <li><select id="geodir_add_listing" class="chosen_select" onchange="window.location.href=this.value"
2944 2944
                             option-autoredirect="1" name="geodir_add_listing" option-ajaxchosen="false"
@@ -2947,42 +2947,42 @@  discard block
 block discarded – undo
2947 2947
                         <?php echo $addlisting_links; ?>
2948 2948
                     </select></li> <?php
2949 2949
 
2950
-            }
2951
-
2952
-        }
2953
-        // My Favourites in Dashboard
2954
-        $show_favorite_link_user_dashboard = get_option('geodir_favorite_link_user_dashboard');
2955
-        $user_favourite = geodir_user_favourite_listing_count();
2956
-
2957
-        if (!empty($show_favorite_link_user_dashboard) && !empty($user_favourite)) {
2958
-            $favourite_links = '';
2959
-
2960
-            foreach ($post_types as $key => $postobj) {
2961
-                if (in_array($key, $show_favorite_link_user_dashboard) && array_key_exists($key, $user_favourite)) {
2962
-                    $name = $postobj->labels->name;
2963
-                    $post_type_link = geodir_getlink($author_link, array('stype' => $key, 'list' => 'favourite'), false);
2964
-
2965
-                    $selected = '';
2966
-
2967
-                    if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key && isset($_REQUEST['geodir_dashbord'])) {
2968
-                        $selected = 'selected="selected"';
2969
-                    }
2970
-                    /**
2971
-                     * Filter favorite listing link.
2972
-                     *
2973
-                     * @since 1.0.0
2974
-                     * @param string $post_type_link Favorite listing link.
2975
-                     * @param string $key Favorite listing array key.
2976
-                     * @param int $current_user->ID Current user ID.
2977
-                     */
2978
-                    $post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID);
2979
-
2980
-                    $favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2981
-                }
2982
-            }
2983
-
2984
-            if ($favourite_links != '') {
2985
-                ?>
2950
+			}
2951
+
2952
+		}
2953
+		// My Favourites in Dashboard
2954
+		$show_favorite_link_user_dashboard = get_option('geodir_favorite_link_user_dashboard');
2955
+		$user_favourite = geodir_user_favourite_listing_count();
2956
+
2957
+		if (!empty($show_favorite_link_user_dashboard) && !empty($user_favourite)) {
2958
+			$favourite_links = '';
2959
+
2960
+			foreach ($post_types as $key => $postobj) {
2961
+				if (in_array($key, $show_favorite_link_user_dashboard) && array_key_exists($key, $user_favourite)) {
2962
+					$name = $postobj->labels->name;
2963
+					$post_type_link = geodir_getlink($author_link, array('stype' => $key, 'list' => 'favourite'), false);
2964
+
2965
+					$selected = '';
2966
+
2967
+					if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key && isset($_REQUEST['geodir_dashbord'])) {
2968
+						$selected = 'selected="selected"';
2969
+					}
2970
+					/**
2971
+					 * Filter favorite listing link.
2972
+					 *
2973
+					 * @since 1.0.0
2974
+					 * @param string $post_type_link Favorite listing link.
2975
+					 * @param string $key Favorite listing array key.
2976
+					 * @param int $current_user->ID Current user ID.
2977
+					 */
2978
+					$post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID);
2979
+
2980
+					$favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2981
+				}
2982
+			}
2983
+
2984
+			if ($favourite_links != '') {
2985
+				?>
2986 2986
                 <li>
2987 2987
                     <select id="geodir_my_favourites" class="chosen_select" onchange="window.location.href=this.value"
2988 2988
                             option-autoredirect="1" name="geodir_my_favourites" option-ajaxchosen="false"
@@ -2992,42 +2992,42 @@  discard block
 block discarded – undo
2992 2992
                     </select>
2993 2993
                 </li>
2994 2994
             <?php
2995
-            }
2996
-        }
2997
-
2998
-
2999
-        $show_listing_link_user_dashboard = get_option('geodir_listing_link_user_dashboard');
3000
-        $user_listing = geodir_user_post_listing_count();
3001
-
3002
-        if (!empty($show_listing_link_user_dashboard) && !empty($user_listing)) {
3003
-            $listing_links = '';
3004
-
3005
-            foreach ($post_types as $key => $postobj) {
3006
-                if (in_array($key, $show_listing_link_user_dashboard) && array_key_exists($key, $user_listing)) {
3007
-                    $name = $postobj->labels->name;
3008
-                    $listing_link = geodir_getlink($author_link, array('stype' => $key), false);
3009
-
3010
-                    $selected = '';
3011
-                    if (!isset($_REQUEST['list']) && isset($_REQUEST['geodir_dashbord']) && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key) {
3012
-                        $selected = 'selected="selected"';
3013
-                    }
3014
-
3015
-                    /**
3016
-                     * Filter my listing link.
3017
-                     *
3018
-                     * @since 1.0.0
3019
-                     * @param string $listing_link My listing link.
3020
-                     * @param string $key My listing array key.
3021
-                     * @param int $current_user->ID Current user ID.
3022
-                     */
3023
-                    $listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID);
3024
-
3025
-                    $listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
3026
-                }
3027
-            }
3028
-
3029
-            if ($listing_links != '') {
3030
-                ?>
2995
+			}
2996
+		}
2997
+
2998
+
2999
+		$show_listing_link_user_dashboard = get_option('geodir_listing_link_user_dashboard');
3000
+		$user_listing = geodir_user_post_listing_count();
3001
+
3002
+		if (!empty($show_listing_link_user_dashboard) && !empty($user_listing)) {
3003
+			$listing_links = '';
3004
+
3005
+			foreach ($post_types as $key => $postobj) {
3006
+				if (in_array($key, $show_listing_link_user_dashboard) && array_key_exists($key, $user_listing)) {
3007
+					$name = $postobj->labels->name;
3008
+					$listing_link = geodir_getlink($author_link, array('stype' => $key), false);
3009
+
3010
+					$selected = '';
3011
+					if (!isset($_REQUEST['list']) && isset($_REQUEST['geodir_dashbord']) && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key) {
3012
+						$selected = 'selected="selected"';
3013
+					}
3014
+
3015
+					/**
3016
+					 * Filter my listing link.
3017
+					 *
3018
+					 * @since 1.0.0
3019
+					 * @param string $listing_link My listing link.
3020
+					 * @param string $key My listing array key.
3021
+					 * @param int $current_user->ID Current user ID.
3022
+					 */
3023
+					$listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID);
3024
+
3025
+					$listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
3026
+				}
3027
+			}
3028
+
3029
+			if ($listing_links != '') {
3030
+				?>
3031 3031
                 <li>
3032 3032
                     <select id="geodir_my_listings" class="chosen_select" onchange="window.location.href=this.value"
3033 3033
                             option-autoredirect="1" name="geodir_my_listings" option-ajaxchosen="false"
@@ -3037,27 +3037,27 @@  discard block
 block discarded – undo
3037 3037
                     </select>
3038 3038
                 </li>
3039 3039
             <?php
3040
-            }
3041
-        }
3042
-
3043
-        $dashboard_link = ob_get_clean();
3044
-        /**
3045
-         * Filter dashboard links HTML.
3046
-         *
3047
-         * @since 1.0.0
3048
-         * @param string $dashboard_link Dashboard links HTML.
3049
-         */
3050
-        echo apply_filters('geodir_dashboard_links', $dashboard_link);
3051
-        echo '</ul>';
3052
-    } else {
3053
-        ?>
3040
+			}
3041
+		}
3042
+
3043
+		$dashboard_link = ob_get_clean();
3044
+		/**
3045
+		 * Filter dashboard links HTML.
3046
+		 *
3047
+		 * @since 1.0.0
3048
+		 * @param string $dashboard_link Dashboard links HTML.
3049
+		 */
3050
+		echo apply_filters('geodir_dashboard_links', $dashboard_link);
3051
+		echo '</ul>';
3052
+	} else {
3053
+		?>
3054 3054
         <?php
3055
-        /**
3056
-         * Filter signup form action link.
3057
-         *
3058
-         * @since 1.0.0
3059
-         */
3060
-        ?>
3055
+		/**
3056
+		 * Filter signup form action link.
3057
+		 *
3058
+		 * @since 1.0.0
3059
+		 */
3060
+		?>
3061 3061
         <form name="loginform" class="loginform1"
3062 3062
               action="<?php echo geodir_login_url(); ?>"
3063 3063
               method="post">
@@ -3077,28 +3077,28 @@  discard block
 block discarded – undo
3077 3077
 
3078 3078
                 <p class="geodir-new-forgot-link">
3079 3079
                     <?php
3080
-                    /**
3081
-                     * Filter signup page register form link.
3082
-                     *
3083
-                     * @since 1.0.0
3084
-                     */
3085
-                    ?>
3080
+					/**
3081
+					 * Filter signup page register form link.
3082
+					 *
3083
+					 * @since 1.0.0
3084
+					 */
3085
+					?>
3086 3086
                     <a href="<?php echo geodir_login_url(array('signup' => true)); ?>"
3087 3087
                        class="goedir-newuser-link"><?php echo NEW_USER_TEXT; ?></a>
3088 3088
 
3089 3089
                     <?php
3090
-                    /**
3091
-                     * Filter signup page forgot password form link.
3092
-                     *
3093
-                     * @since 1.0.0
3094
-                     */
3095
-                    ?>
3090
+					/**
3091
+					 * Filter signup page forgot password form link.
3092
+					 *
3093
+					 * @since 1.0.0
3094
+					 */
3095
+					?>
3096 3096
                     <a href="<?php echo geodir_login_url(array('forgot' => true)); ?>"
3097 3097
                        class="goedir-forgot-link"><?php echo FORGOT_PW_TEXT; ?></a></p></div>
3098 3098
         </form>
3099 3099
     <?php }
3100 3100
 
3101
-    echo $after_widget;
3101
+	echo $after_widget;
3102 3102
 }
3103 3103
 
3104 3104
 
@@ -3117,284 +3117,284 @@  discard block
 block discarded – undo
3117 3117
  * @param array|string $instance The settings for the particular instance of the widget.
3118 3118
  */
3119 3119
 function geodir_popular_postview_output($args = '', $instance = '') {
3120
-    global $gd_session;
3120
+	global $gd_session;
3121 3121
 	
3122
-    // prints the widget
3123
-    extract($args, EXTR_SKIP);
3124
-
3125
-    echo $before_widget;
3126
-
3127
-    /** This filter is documented in geodirectory_widgets.php */
3128
-    $title = empty($instance['title']) ? geodir_ucwords($instance['category_title']) : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
3129
-    /**
3130
-     * Filter the widget post type.
3131
-     *
3132
-     * @since 1.0.0
3133
-     * @param string $instance['post_type'] Post type of listing.
3134
-     */
3135
-    $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
3136
-    /**
3137
-     * Filter the widget's term.
3138
-     *
3139
-     * @since 1.0.0
3140
-     * @param string $instance['category'] Filter by term. Can be any valid term.
3141
-     */
3142
-    $category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
3143
-    /**
3144
-     * Filter the widget listings limit.
3145
-     *
3146
-     * @since 1.0.0
3147
-     * @param string $instance['post_number'] Number of listings to display.
3148
-     */
3149
-    $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
3150
-    /**
3151
-     * Filter widget's "layout" type.
3152
-     *
3153
-     * @since 1.0.0
3154
-     * @param string $instance['layout'] Widget layout type.
3155
-     */
3156
-    $layout = empty($instance['layout']) ? 'gridview_onehalf' : apply_filters('widget_layout', $instance['layout']);
3157
-    /**
3158
-     * Filter widget's "add_location_filter" value.
3159
-     *
3160
-     * @since 1.0.0
3161
-     * @param string|bool $instance['add_location_filter'] Do you want to add location filter? Can be 1 or 0.
3162
-     */
3163
-    $add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_add_location_filter', $instance['add_location_filter']);
3164
-    /**
3165
-     * Filter widget's listing width.
3166
-     *
3167
-     * @since 1.0.0
3168
-     * @param string $instance['listing_width'] Listing width.
3169
-     */
3170
-    $listing_width = empty($instance['listing_width']) ? '' : apply_filters('widget_listing_width', $instance['listing_width']);
3171
-    /**
3172
-     * Filter widget's "list_sort" type.
3173
-     *
3174
-     * @since 1.0.0
3175
-     * @param string $instance['list_sort'] Listing sort by type.
3176
-     */
3177
-    $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
3178
-    $use_viewing_post_type = !empty($instance['use_viewing_post_type']) ? true : false;
3179
-
3180
-    // set post type to current viewing post type
3181
-    if ($use_viewing_post_type) {
3182
-        $current_post_type = geodir_get_current_posttype();
3183
-        if ($current_post_type != '' && $current_post_type != $post_type) {
3184
-            $post_type = $current_post_type;
3185
-            $category = array(); // old post type category will not work for current changed post type
3186
-        }
3187
-    }
3188
-    // replace widget title dynamically
3189
-    $posttype_plural_label = __(get_post_type_plural_label($post_type), 'geodirectory');
3190
-    $posttype_singular_label = __(get_post_type_singular_label($post_type), 'geodirectory');
3191
-
3192
-    $title = str_replace("%posttype_plural_label%", $posttype_plural_label, $title);
3193
-    $title = str_replace("%posttype_singular_label%", $posttype_singular_label, $title);
3194
-
3195
-    if (isset($instance['character_count'])) {
3196
-        /**
3197
-         * Filter the widget's excerpt character count.
3198
-         *
3199
-         * @since 1.0.0
3200
-         * @param int $instance['character_count'] Excerpt character count.
3201
-         */
3202
-        $character_count = apply_filters('widget_list_character_count', $instance['character_count']);
3203
-    } else {
3204
-        $character_count = '';
3205
-    }
3206
-
3207
-    if (empty($title) || $title == 'All') {
3208
-        $title .= ' ' . __(get_post_type_plural_label($post_type), 'geodirectory');
3209
-    }
3210
-
3211
-    $location_url = array();
3212
-    $city = get_query_var('gd_city');
3213
-    if (!empty($city)) {
3214
-        $country = get_query_var('gd_country');
3215
-        $region = get_query_var('gd_region');
3216
-
3217
-        $geodir_show_location_url = get_option('geodir_show_location_url');
3218
-
3219
-        if ($geodir_show_location_url == 'all') {
3220
-            if ($country != '') {
3221
-                $location_url[] = $country;
3222
-            }
3223
-
3224
-            if ($region != '') {
3225
-                $location_url[] = $region;
3226
-            }
3227
-        } else if ($geodir_show_location_url == 'country_city') {
3228
-            if ($country != '') {
3229
-                $location_url[] = $country;
3230
-            }
3231
-        } else if ($geodir_show_location_url == 'region_city') {
3232
-            if ($region != '') {
3233
-                $location_url[] = $region;
3234
-            }
3235
-        }
3236
-
3237
-        $location_url[] = $city;
3238
-    }
3239
-
3240
-    $location_url = implode('/', $location_url);
3241
-    $skip_location = false;
3242
-    if (!$add_location_filter && $gd_session->get('gd_multi_location')) {
3243
-        $skip_location = true;
3244
-        $gd_session->un_set('gd_multi_location');
3245
-    }
3246
-
3247
-    if (get_option('permalink_structure')) {
3248
-        $viewall_url = get_post_type_archive_link($post_type);
3249
-    } else {
3250
-        $viewall_url = get_post_type_archive_link($post_type);
3251
-    }
3252
-
3253
-    if (!empty($category) && $category[0] != '0') {
3254
-        global $geodir_add_location_url;
3255
-
3256
-        $geodir_add_location_url = '0';
3257
-
3258
-        if ($add_location_filter != '0') {
3259
-            $geodir_add_location_url = '1';
3260
-        }
3261
-
3262
-        $viewall_url = get_term_link((int)$category[0], $post_type . 'category');
3263
-
3264
-        $geodir_add_location_url = NULL;
3265
-    }
3266
-    if ($skip_location) {
3267
-        $gd_session->set('gd_multi_location', 1);
3268
-    }
3269
-
3270
-    if(is_wp_error( $viewall_url  )){$viewall_url = '';}
3271
-
3272
-    $query_args = array(
3273
-        'posts_per_page' => $post_number,
3274
-        'is_geodir_loop' => true,
3275
-        'gd_location' => $add_location_filter ? true : false,
3276
-        'post_type' => $post_type,
3277
-        'order_by' => $list_sort
3278
-    );
3279
-
3280
-    if ($character_count) {
3281
-        $query_args['excerpt_length'] = $character_count;
3282
-    }
3283
-
3284
-    if (!empty($instance['show_featured_only'])) {
3285
-        $query_args['show_featured_only'] = 1;
3286
-    }
3287
-
3288
-    if (!empty($instance['show_special_only'])) {
3289
-        $query_args['show_special_only'] = 1;
3290
-    }
3291
-
3292
-    if (!empty($instance['with_pics_only'])) {
3293
-        $query_args['with_pics_only'] = 0;
3294
-        $query_args['featured_image_only'] = 1;
3295
-    }
3296
-
3297
-    if (!empty($instance['with_videos_only'])) {
3298
-        $query_args['with_videos_only'] = 1;
3299
-    }
3300
-    $with_no_results = !empty($instance['without_no_results']) ? false : true;
3301
-
3302
-    if (!empty($category) && $category[0] != '0') {
3303
-        $category_taxonomy = geodir_get_taxonomies($post_type);
3304
-
3305
-        ######### WPML #########
3306
-        if (function_exists('icl_object_id')) {
3307
-            $category = gd_lang_object_ids($category, $category_taxonomy[0]);
3308
-        }
3309
-        ######### WPML #########
3310
-
3311
-        $tax_query = array(
3312
-            'taxonomy' => $category_taxonomy[0],
3313
-            'field' => 'id',
3314
-            'terms' => $category
3315
-        );
3316
-
3317
-        $query_args['tax_query'] = array($tax_query);
3318
-    }
3319
-
3320
-    global $gridview_columns_widget, $geodir_is_widget_listing;
3321
-
3322
-    $widget_listings = geodir_get_widget_listings($query_args);
3323
-
3324
-    if (!empty($widget_listings) || $with_no_results) {
3325
-        ?>
3122
+	// prints the widget
3123
+	extract($args, EXTR_SKIP);
3124
+
3125
+	echo $before_widget;
3126
+
3127
+	/** This filter is documented in geodirectory_widgets.php */
3128
+	$title = empty($instance['title']) ? geodir_ucwords($instance['category_title']) : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
3129
+	/**
3130
+	 * Filter the widget post type.
3131
+	 *
3132
+	 * @since 1.0.0
3133
+	 * @param string $instance['post_type'] Post type of listing.
3134
+	 */
3135
+	$post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
3136
+	/**
3137
+	 * Filter the widget's term.
3138
+	 *
3139
+	 * @since 1.0.0
3140
+	 * @param string $instance['category'] Filter by term. Can be any valid term.
3141
+	 */
3142
+	$category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
3143
+	/**
3144
+	 * Filter the widget listings limit.
3145
+	 *
3146
+	 * @since 1.0.0
3147
+	 * @param string $instance['post_number'] Number of listings to display.
3148
+	 */
3149
+	$post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
3150
+	/**
3151
+	 * Filter widget's "layout" type.
3152
+	 *
3153
+	 * @since 1.0.0
3154
+	 * @param string $instance['layout'] Widget layout type.
3155
+	 */
3156
+	$layout = empty($instance['layout']) ? 'gridview_onehalf' : apply_filters('widget_layout', $instance['layout']);
3157
+	/**
3158
+	 * Filter widget's "add_location_filter" value.
3159
+	 *
3160
+	 * @since 1.0.0
3161
+	 * @param string|bool $instance['add_location_filter'] Do you want to add location filter? Can be 1 or 0.
3162
+	 */
3163
+	$add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_add_location_filter', $instance['add_location_filter']);
3164
+	/**
3165
+	 * Filter widget's listing width.
3166
+	 *
3167
+	 * @since 1.0.0
3168
+	 * @param string $instance['listing_width'] Listing width.
3169
+	 */
3170
+	$listing_width = empty($instance['listing_width']) ? '' : apply_filters('widget_listing_width', $instance['listing_width']);
3171
+	/**
3172
+	 * Filter widget's "list_sort" type.
3173
+	 *
3174
+	 * @since 1.0.0
3175
+	 * @param string $instance['list_sort'] Listing sort by type.
3176
+	 */
3177
+	$list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
3178
+	$use_viewing_post_type = !empty($instance['use_viewing_post_type']) ? true : false;
3179
+
3180
+	// set post type to current viewing post type
3181
+	if ($use_viewing_post_type) {
3182
+		$current_post_type = geodir_get_current_posttype();
3183
+		if ($current_post_type != '' && $current_post_type != $post_type) {
3184
+			$post_type = $current_post_type;
3185
+			$category = array(); // old post type category will not work for current changed post type
3186
+		}
3187
+	}
3188
+	// replace widget title dynamically
3189
+	$posttype_plural_label = __(get_post_type_plural_label($post_type), 'geodirectory');
3190
+	$posttype_singular_label = __(get_post_type_singular_label($post_type), 'geodirectory');
3191
+
3192
+	$title = str_replace("%posttype_plural_label%", $posttype_plural_label, $title);
3193
+	$title = str_replace("%posttype_singular_label%", $posttype_singular_label, $title);
3194
+
3195
+	if (isset($instance['character_count'])) {
3196
+		/**
3197
+		 * Filter the widget's excerpt character count.
3198
+		 *
3199
+		 * @since 1.0.0
3200
+		 * @param int $instance['character_count'] Excerpt character count.
3201
+		 */
3202
+		$character_count = apply_filters('widget_list_character_count', $instance['character_count']);
3203
+	} else {
3204
+		$character_count = '';
3205
+	}
3206
+
3207
+	if (empty($title) || $title == 'All') {
3208
+		$title .= ' ' . __(get_post_type_plural_label($post_type), 'geodirectory');
3209
+	}
3210
+
3211
+	$location_url = array();
3212
+	$city = get_query_var('gd_city');
3213
+	if (!empty($city)) {
3214
+		$country = get_query_var('gd_country');
3215
+		$region = get_query_var('gd_region');
3216
+
3217
+		$geodir_show_location_url = get_option('geodir_show_location_url');
3218
+
3219
+		if ($geodir_show_location_url == 'all') {
3220
+			if ($country != '') {
3221
+				$location_url[] = $country;
3222
+			}
3223
+
3224
+			if ($region != '') {
3225
+				$location_url[] = $region;
3226
+			}
3227
+		} else if ($geodir_show_location_url == 'country_city') {
3228
+			if ($country != '') {
3229
+				$location_url[] = $country;
3230
+			}
3231
+		} else if ($geodir_show_location_url == 'region_city') {
3232
+			if ($region != '') {
3233
+				$location_url[] = $region;
3234
+			}
3235
+		}
3236
+
3237
+		$location_url[] = $city;
3238
+	}
3239
+
3240
+	$location_url = implode('/', $location_url);
3241
+	$skip_location = false;
3242
+	if (!$add_location_filter && $gd_session->get('gd_multi_location')) {
3243
+		$skip_location = true;
3244
+		$gd_session->un_set('gd_multi_location');
3245
+	}
3246
+
3247
+	if (get_option('permalink_structure')) {
3248
+		$viewall_url = get_post_type_archive_link($post_type);
3249
+	} else {
3250
+		$viewall_url = get_post_type_archive_link($post_type);
3251
+	}
3252
+
3253
+	if (!empty($category) && $category[0] != '0') {
3254
+		global $geodir_add_location_url;
3255
+
3256
+		$geodir_add_location_url = '0';
3257
+
3258
+		if ($add_location_filter != '0') {
3259
+			$geodir_add_location_url = '1';
3260
+		}
3261
+
3262
+		$viewall_url = get_term_link((int)$category[0], $post_type . 'category');
3263
+
3264
+		$geodir_add_location_url = NULL;
3265
+	}
3266
+	if ($skip_location) {
3267
+		$gd_session->set('gd_multi_location', 1);
3268
+	}
3269
+
3270
+	if(is_wp_error( $viewall_url  )){$viewall_url = '';}
3271
+
3272
+	$query_args = array(
3273
+		'posts_per_page' => $post_number,
3274
+		'is_geodir_loop' => true,
3275
+		'gd_location' => $add_location_filter ? true : false,
3276
+		'post_type' => $post_type,
3277
+		'order_by' => $list_sort
3278
+	);
3279
+
3280
+	if ($character_count) {
3281
+		$query_args['excerpt_length'] = $character_count;
3282
+	}
3283
+
3284
+	if (!empty($instance['show_featured_only'])) {
3285
+		$query_args['show_featured_only'] = 1;
3286
+	}
3287
+
3288
+	if (!empty($instance['show_special_only'])) {
3289
+		$query_args['show_special_only'] = 1;
3290
+	}
3291
+
3292
+	if (!empty($instance['with_pics_only'])) {
3293
+		$query_args['with_pics_only'] = 0;
3294
+		$query_args['featured_image_only'] = 1;
3295
+	}
3296
+
3297
+	if (!empty($instance['with_videos_only'])) {
3298
+		$query_args['with_videos_only'] = 1;
3299
+	}
3300
+	$with_no_results = !empty($instance['without_no_results']) ? false : true;
3301
+
3302
+	if (!empty($category) && $category[0] != '0') {
3303
+		$category_taxonomy = geodir_get_taxonomies($post_type);
3304
+
3305
+		######### WPML #########
3306
+		if (function_exists('icl_object_id')) {
3307
+			$category = gd_lang_object_ids($category, $category_taxonomy[0]);
3308
+		}
3309
+		######### WPML #########
3310
+
3311
+		$tax_query = array(
3312
+			'taxonomy' => $category_taxonomy[0],
3313
+			'field' => 'id',
3314
+			'terms' => $category
3315
+		);
3316
+
3317
+		$query_args['tax_query'] = array($tax_query);
3318
+	}
3319
+
3320
+	global $gridview_columns_widget, $geodir_is_widget_listing;
3321
+
3322
+	$widget_listings = geodir_get_widget_listings($query_args);
3323
+
3324
+	if (!empty($widget_listings) || $with_no_results) {
3325
+		?>
3326 3326
         <div class="geodir_locations geodir_location_listing">
3327 3327
 
3328 3328
             <?php
3329
-            /**
3330
-             * Called before the div containing the title and view all link in popular post view widget.
3331
-             *
3332
-             * @since 1.0.0
3333
-             */
3334
-            do_action('geodir_before_view_all_link_in_widget'); ?>
3329
+			/**
3330
+			 * Called before the div containing the title and view all link in popular post view widget.
3331
+			 *
3332
+			 * @since 1.0.0
3333
+			 */
3334
+			do_action('geodir_before_view_all_link_in_widget'); ?>
3335 3335
             <div class="geodir_list_heading clearfix">
3336 3336
                 <?php echo $before_title . $title . $after_title; ?>
3337 3337
                 <a href="<?php echo $viewall_url; ?>"
3338 3338
                    class="geodir-viewall"><?php _e('View all', 'geodirectory'); ?></a>
3339 3339
             </div>
3340 3340
             <?php
3341
-            /**
3342
-             * Called after 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_after_view_all_link_in_widget'); ?>
3341
+			/**
3342
+			 * Called after 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_after_view_all_link_in_widget'); ?>
3347 3347
             <?php
3348
-            if (strstr($layout, 'gridview')) {
3349
-                $listing_view_exp = explode('_', $layout);
3350
-                $gridview_columns_widget = $layout;
3351
-                $layout = $listing_view_exp[0];
3352
-            } else {
3353
-                $gridview_columns_widget = '';
3354
-            }
3355
-
3356
-            /**
3357
-             * Filter the widget listing listview template path.
3358
-             *
3359
-             * @since 1.0.0
3360
-             */
3361
-            $template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview'));
3362
-            if (!isset($character_count)) {
3363
-                /**
3364
-                 * Filter the widget's excerpt character count.
3365
-                 *
3366
-                 * @since 1.0.0
3367
-                 * @param int $instance['character_count'] Excerpt character count.
3368
-                 */
3369
-                $character_count = $character_count == '' ? 50 : apply_filters('widget_character_count', $character_count);
3370
-            }
3371
-
3372
-            global $post, $map_jason, $map_canvas_arr;
3373
-
3374
-            $current_post = $post;
3375
-            $current_map_jason = $map_jason;
3376
-            $current_map_canvas_arr = $map_canvas_arr;
3377
-            $geodir_is_widget_listing = true;
3378
-
3379
-            /**
3380
-             * Includes related listing listview template.
3381
-             *
3382
-             * @since 1.0.0
3383
-             */
3384
-            include($template);
3385
-
3386
-            $geodir_is_widget_listing = false;
3387
-
3388
-            $GLOBALS['post'] = $current_post;
3389
-            if (!empty($current_post))
3390
-                setup_postdata($current_post);
3391
-            $map_jason = $current_map_jason;
3392
-            $map_canvas_arr = $current_map_canvas_arr;
3393
-            ?>
3348
+			if (strstr($layout, 'gridview')) {
3349
+				$listing_view_exp = explode('_', $layout);
3350
+				$gridview_columns_widget = $layout;
3351
+				$layout = $listing_view_exp[0];
3352
+			} else {
3353
+				$gridview_columns_widget = '';
3354
+			}
3355
+
3356
+			/**
3357
+			 * Filter the widget listing listview template path.
3358
+			 *
3359
+			 * @since 1.0.0
3360
+			 */
3361
+			$template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview'));
3362
+			if (!isset($character_count)) {
3363
+				/**
3364
+				 * Filter the widget's excerpt character count.
3365
+				 *
3366
+				 * @since 1.0.0
3367
+				 * @param int $instance['character_count'] Excerpt character count.
3368
+				 */
3369
+				$character_count = $character_count == '' ? 50 : apply_filters('widget_character_count', $character_count);
3370
+			}
3371
+
3372
+			global $post, $map_jason, $map_canvas_arr;
3373
+
3374
+			$current_post = $post;
3375
+			$current_map_jason = $map_jason;
3376
+			$current_map_canvas_arr = $map_canvas_arr;
3377
+			$geodir_is_widget_listing = true;
3378
+
3379
+			/**
3380
+			 * Includes related listing listview template.
3381
+			 *
3382
+			 * @since 1.0.0
3383
+			 */
3384
+			include($template);
3385
+
3386
+			$geodir_is_widget_listing = false;
3387
+
3388
+			$GLOBALS['post'] = $current_post;
3389
+			if (!empty($current_post))
3390
+				setup_postdata($current_post);
3391
+			$map_jason = $current_map_jason;
3392
+			$map_canvas_arr = $current_map_canvas_arr;
3393
+			?>
3394 3394
         </div>
3395 3395
     <?php
3396
-    }
3397
-    echo $after_widget;
3396
+	}
3397
+	echo $after_widget;
3398 3398
 
3399 3399
 }
3400 3400
 
@@ -3417,26 +3417,26 @@  discard block
 block discarded – undo
3417 3417
  */
3418 3418
 function geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type)
3419 3419
 {
3420
-    global $wpdb, $plugin_prefix;
3420
+	global $wpdb, $plugin_prefix;
3421 3421
 
3422
-    $detail_table = $plugin_prefix . $post_type . '_detail';
3422
+	$detail_table = $plugin_prefix . $post_type . '_detail';
3423 3423
 
3424
-    $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 . ")";
3424
+	$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 . ")";
3425 3425
 
3426
-    /**
3427
-     * Filter count review sql query.
3428
-     *
3429
-     * @since 1.5.1
3430
-     * @param string $sql Database sql query..
3431
-     * @param int $term_id The term ID.
3432
-     * @param int $taxonomy The taxonomy Id.
3433
-     * @param string $post_type The post type.
3434
-     */
3435
-    $sql = apply_filters('geodir_count_reviews_by_term_sql', $sql, $term_id, $taxonomy, $post_type);
3426
+	/**
3427
+	 * Filter count review sql query.
3428
+	 *
3429
+	 * @since 1.5.1
3430
+	 * @param string $sql Database sql query..
3431
+	 * @param int $term_id The term ID.
3432
+	 * @param int $taxonomy The taxonomy Id.
3433
+	 * @param string $post_type The post type.
3434
+	 */
3435
+	$sql = apply_filters('geodir_count_reviews_by_term_sql', $sql, $term_id, $taxonomy, $post_type);
3436 3436
 
3437
-    $count = $wpdb->get_var($sql);
3437
+	$count = $wpdb->get_var($sql);
3438 3438
 
3439
-    return $count;
3439
+	return $count;
3440 3440
 }
3441 3441
 
3442 3442
 /**
@@ -3452,90 +3452,90 @@  discard block
 block discarded – undo
3452 3452
  * @return array Term array data.
3453 3453
  */
3454 3454
 function geodir_count_reviews_by_terms($force_update = false, $post_ID = 0) {
3455
-    /**
3456
-     * Filter review count option data.
3457
-     *
3458
-     * @since 1.0.0
3459
-     * @since 1.6.1 Added $post_ID param.
3460
-     * @param bool $force_update Force update option value?. Default.false.
3461
-     * @param int $post_ID The post id to update if any.
3462
-     */
3463
-    $option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update,$post_ID);
3464
-    if (!empty($option_data)) {
3465
-        return $option_data;
3466
-    }
3467
-
3468
-    $option_data = get_option('geodir_global_review_count');
3469
-
3470
-    if (!$option_data || $force_update) {
3471
-        if ((int)$post_ID > 0) { // Update reviews count for specific post categories only.
3472
-            global $gd_session;
3473
-            $term_array = (array)$option_data;
3474
-            $post_type = get_post_type($post_ID);
3475
-            $taxonomy = $post_type . 'category';
3476
-            $terms = wp_get_object_terms($post_ID, $taxonomy, array('fields' => 'ids'));
3477
-
3478
-            if (!empty($terms) && !is_wp_error($terms)) {
3479
-                foreach ($terms as $term_id) {
3480
-                    $count = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type);
3481
-                    $children = get_term_children($term_id, $taxonomy);
3482
-                    $term_array[$term_id] = $count;
3483
-                }
3484
-            }
3455
+	/**
3456
+	 * Filter review count option data.
3457
+	 *
3458
+	 * @since 1.0.0
3459
+	 * @since 1.6.1 Added $post_ID param.
3460
+	 * @param bool $force_update Force update option value?. Default.false.
3461
+	 * @param int $post_ID The post id to update if any.
3462
+	 */
3463
+	$option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update,$post_ID);
3464
+	if (!empty($option_data)) {
3465
+		return $option_data;
3466
+	}
3467
+
3468
+	$option_data = get_option('geodir_global_review_count');
3469
+
3470
+	if (!$option_data || $force_update) {
3471
+		if ((int)$post_ID > 0) { // Update reviews count for specific post categories only.
3472
+			global $gd_session;
3473
+			$term_array = (array)$option_data;
3474
+			$post_type = get_post_type($post_ID);
3475
+			$taxonomy = $post_type . 'category';
3476
+			$terms = wp_get_object_terms($post_ID, $taxonomy, array('fields' => 'ids'));
3477
+
3478
+			if (!empty($terms) && !is_wp_error($terms)) {
3479
+				foreach ($terms as $term_id) {
3480
+					$count = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type);
3481
+					$children = get_term_children($term_id, $taxonomy);
3482
+					$term_array[$term_id] = $count;
3483
+				}
3484
+			}
3485 3485
             
3486
-            $session_listing = $gd_session->get('listing');
3486
+			$session_listing = $gd_session->get('listing');
3487 3487
             
3488
-            $terms = array();
3489
-            if (isset($_POST['post_category'][$taxonomy])) {
3490
-                $terms = (array)$_POST['post_category'][$taxonomy];
3491
-            } else if (!empty($session_listing) && isset($session_listing['post_category'][$taxonomy])) {
3492
-                $terms = (array)$session_listing['post_category'][$taxonomy];
3493
-            }
3488
+			$terms = array();
3489
+			if (isset($_POST['post_category'][$taxonomy])) {
3490
+				$terms = (array)$_POST['post_category'][$taxonomy];
3491
+			} else if (!empty($session_listing) && isset($session_listing['post_category'][$taxonomy])) {
3492
+				$terms = (array)$session_listing['post_category'][$taxonomy];
3493
+			}
3494 3494
             
3495
-            if (!empty($terms)) {
3496
-                foreach ($terms as $term_id) {
3497
-                    if ($term_id > 0) {
3498
-                        $count = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type);
3499
-                        $children = get_term_children($term_id, $taxonomy);
3500
-                        $term_array[$term_id] = $count;
3501
-                    }
3502
-                }
3503
-            }
3504
-        } else { // Update reviews count for all post categories.
3505
-            $term_array = array();
3506
-            $post_types = geodir_get_posttypes();
3507
-            foreach ($post_types as $post_type) {
3508
-
3509
-                $taxonomy = geodir_get_taxonomies($post_type);
3510
-                $taxonomy = $taxonomy[0];
3511
-
3512
-                $args = array(
3513
-                    'hide_empty' => false
3514
-                );
3515
-
3516
-                $terms = get_terms($taxonomy, $args);
3517
-
3518
-                foreach ($terms as $term) {
3519
-                    $count = geodir_count_reviews_by_term_id($term->term_id, $taxonomy, $post_type);
3520
-                    $children = get_term_children($term->term_id, $taxonomy);
3521
-                    /*if ( is_array( $children ) ) {
3495
+			if (!empty($terms)) {
3496
+				foreach ($terms as $term_id) {
3497
+					if ($term_id > 0) {
3498
+						$count = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type);
3499
+						$children = get_term_children($term_id, $taxonomy);
3500
+						$term_array[$term_id] = $count;
3501
+					}
3502
+				}
3503
+			}
3504
+		} else { // Update reviews count for all post categories.
3505
+			$term_array = array();
3506
+			$post_types = geodir_get_posttypes();
3507
+			foreach ($post_types as $post_type) {
3508
+
3509
+				$taxonomy = geodir_get_taxonomies($post_type);
3510
+				$taxonomy = $taxonomy[0];
3511
+
3512
+				$args = array(
3513
+					'hide_empty' => false
3514
+				);
3515
+
3516
+				$terms = get_terms($taxonomy, $args);
3517
+
3518
+				foreach ($terms as $term) {
3519
+					$count = geodir_count_reviews_by_term_id($term->term_id, $taxonomy, $post_type);
3520
+					$children = get_term_children($term->term_id, $taxonomy);
3521
+					/*if ( is_array( $children ) ) {
3522 3522
                         foreach ( $children as $child_id ) {
3523 3523
                             $child_count = geodir_count_reviews_by_term_id($child_id, $taxonomy, $post_type);
3524 3524
                             $count = $count + $child_count;
3525 3525
                         }
3526 3526
                     }*/
3527
-                    $term_array[$term->term_id] = $count;
3528
-                }
3529
-            }
3530
-        }
3531
-
3532
-        update_option('geodir_global_review_count', $term_array);
3533
-        //clear cache
3534
-        wp_cache_delete('geodir_global_review_count');
3535
-        return $term_array;
3536
-    } else {
3537
-        return $option_data;
3538
-    }
3527
+					$term_array[$term->term_id] = $count;
3528
+				}
3529
+			}
3530
+		}
3531
+
3532
+		update_option('geodir_global_review_count', $term_array);
3533
+		//clear cache
3534
+		wp_cache_delete('geodir_global_review_count');
3535
+		return $term_array;
3536
+	} else {
3537
+		return $option_data;
3538
+	}
3539 3539
 }
3540 3540
 
3541 3541
 /**
@@ -3547,38 +3547,38 @@  discard block
 block discarded – undo
3547 3547
  * @return bool
3548 3548
  */
3549 3549
 function geodir_term_review_count_force_update($new_status, $old_status = '', $post = '') {
3550
-    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'geodir_import_export') {
3551
-        return; // do not run if importing listings
3552
-    }
3550
+	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'geodir_import_export') {
3551
+		return; // do not run if importing listings
3552
+	}
3553 3553
     
3554
-    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
3555
-        return;
3556
-    }
3557
-
3558
-    $post_ID = 0;
3559
-    if (!empty($post)) {
3560
-        if (isset($post->post_type) && strpos($post->post_type, 'gd_') !== 0) {
3561
-            return;
3562
-        }
3554
+	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
3555
+		return;
3556
+	}
3557
+
3558
+	$post_ID = 0;
3559
+	if (!empty($post)) {
3560
+		if (isset($post->post_type) && strpos($post->post_type, 'gd_') !== 0) {
3561
+			return;
3562
+		}
3563 3563
         
3564
-        if ($new_status == 'auto-draft' && $old_status == 'new') {
3565
-            return;
3566
-        }
3564
+		if ($new_status == 'auto-draft' && $old_status == 'new') {
3565
+			return;
3566
+		}
3567 3567
         
3568
-        if (!empty($post->ID)) {
3569
-            $post_ID = $post->ID;
3570
-        }
3571
-    }
3568
+		if (!empty($post->ID)) {
3569
+			$post_ID = $post->ID;
3570
+		}
3571
+	}
3572 3572
 
3573
-    if ($new_status != $old_status) {
3574
-        geodir_count_reviews_by_terms(true, $post_ID);
3575
-    }
3573
+	if ($new_status != $old_status) {
3574
+		geodir_count_reviews_by_terms(true, $post_ID);
3575
+	}
3576 3576
 
3577
-    return true;
3577
+	return true;
3578 3578
 }
3579 3579
 
3580 3580
 function geodir_term_review_count_force_update_single_post($post_id){
3581
-    geodir_count_reviews_by_terms(true, $post_id); 
3581
+	geodir_count_reviews_by_terms(true, $post_id); 
3582 3582
 }
3583 3583
 
3584 3584
 /*-----------------------------------------------------------------------------------*/
@@ -3596,15 +3596,15 @@  discard block
 block discarded – undo
3596 3596
 function geodir_count_posts_by_term($data, $term)
3597 3597
 {
3598 3598
 
3599
-    if ($data) {
3600
-        if (isset($data[$term->term_id])) {
3601
-            return $data[$term->term_id];
3602
-        } else {
3603
-            return 0;
3604
-        }
3605
-    } else {
3606
-        return $term->count;
3607
-    }
3599
+	if ($data) {
3600
+		if (isset($data[$term->term_id])) {
3601
+			return $data[$term->term_id];
3602
+		} else {
3603
+			return 0;
3604
+		}
3605
+	} else {
3606
+		return $term->count;
3607
+	}
3608 3608
 }
3609 3609
 
3610 3610
 /**
@@ -3617,8 +3617,8 @@  discard block
 block discarded – undo
3617 3617
  */
3618 3618
 function geodir_sort_terms_by_count($terms)
3619 3619
 {
3620
-    usort($terms, "geodir_sort_by_count_obj");
3621
-    return $terms;
3620
+	usort($terms, "geodir_sort_by_count_obj");
3621
+	return $terms;
3622 3622
 }
3623 3623
 
3624 3624
 /**
@@ -3631,8 +3631,8 @@  discard block
 block discarded – undo
3631 3631
  */
3632 3632
 function geodir_sort_terms_by_review_count($terms)
3633 3633
 {
3634
-    usort($terms, "geodir_sort_by_review_count_obj");
3635
-    return $terms;
3634
+	usort($terms, "geodir_sort_by_review_count_obj");
3635
+	return $terms;
3636 3636
 }
3637 3637
 
3638 3638
 /**
@@ -3646,12 +3646,12 @@  discard block
 block discarded – undo
3646 3646
  */
3647 3647
 function geodir_sort_terms($terms, $sort = 'count')
3648 3648
 {
3649
-    if ($sort == 'count') {
3650
-        return geodir_sort_terms_by_count($terms);
3651
-    }
3652
-    if ($sort == 'review_count') {
3653
-        return geodir_sort_terms_by_review_count($terms);
3654
-    }
3649
+	if ($sort == 'count') {
3650
+		return geodir_sort_terms_by_count($terms);
3651
+	}
3652
+	if ($sort == 'review_count') {
3653
+		return geodir_sort_terms_by_review_count($terms);
3654
+	}
3655 3655
 }
3656 3656
 
3657 3657
 /*-----------------------------------------------------------------------------------*/
@@ -3668,7 +3668,7 @@  discard block
 block discarded – undo
3668 3668
  */
3669 3669
 function geodir_sort_by_count($a, $b)
3670 3670
 {
3671
-    return $a['count'] < $b['count'];
3671
+	return $a['count'] < $b['count'];
3672 3672
 }
3673 3673
 
3674 3674
 /**
@@ -3682,7 +3682,7 @@  discard block
 block discarded – undo
3682 3682
  */
3683 3683
 function geodir_sort_by_count_obj($a, $b)
3684 3684
 {
3685
-    return $a->count < $b->count;
3685
+	return $a->count < $b->count;
3686 3686
 }
3687 3687
 
3688 3688
 /**
@@ -3696,7 +3696,7 @@  discard block
 block discarded – undo
3696 3696
  */
3697 3697
 function geodir_sort_by_review_count_obj($a, $b)
3698 3698
 {
3699
-    return $a->review_count < $b->review_count;
3699
+	return $a->review_count < $b->review_count;
3700 3700
 }
3701 3701
 
3702 3702
 /**
@@ -3706,43 +3706,43 @@  discard block
 block discarded – undo
3706 3706
  * @package GeoDirectory
3707 3707
  */
3708 3708
 function geodir_load_textdomain() {
3709
-    /**
3710
-     * Filter the plugin locale.
3711
-     *
3712
-     * @since 1.4.2
3713
-     * @package GeoDirectory
3714
-     */
3715
-    $locale = apply_filters('plugin_locale', get_locale(), 'geodirectory');
3716
-
3717
-    load_textdomain('geodirectory', WP_LANG_DIR . '/' . 'geodirectory' . '/' . 'geodirectory' . '-' . $locale . '.mo');
3718
-    load_plugin_textdomain('geodirectory', false, plugin_basename(dirname(dirname(__FILE__))) . '/geodirectory-languages');
3709
+	/**
3710
+	 * Filter the plugin locale.
3711
+	 *
3712
+	 * @since 1.4.2
3713
+	 * @package GeoDirectory
3714
+	 */
3715
+	$locale = apply_filters('plugin_locale', get_locale(), 'geodirectory');
3716
+
3717
+	load_textdomain('geodirectory', WP_LANG_DIR . '/' . 'geodirectory' . '/' . 'geodirectory' . '-' . $locale . '.mo');
3718
+	load_plugin_textdomain('geodirectory', false, plugin_basename(dirname(dirname(__FILE__))) . '/geodirectory-languages');
3719
+
3720
+	/**
3721
+	 * Define language constants.
3722
+	 *
3723
+	 * @since 1.0.0
3724
+	 */
3725
+	require_once(geodir_plugin_path() . '/language.php');
3726
+
3727
+	$language_file = geodir_plugin_path() . '/db-language.php';
3728
+
3729
+	// Load language string file if not created yet
3730
+	if (!file_exists($language_file)) {
3731
+		geodirectory_load_db_language();
3732
+	}
3719 3733
 
3720
-    /**
3721
-     * Define language constants.
3722
-     *
3723
-     * @since 1.0.0
3724
-     */
3725
-    require_once(geodir_plugin_path() . '/language.php');
3726
-
3727
-    $language_file = geodir_plugin_path() . '/db-language.php';
3728
-
3729
-    // Load language string file if not created yet
3730
-    if (!file_exists($language_file)) {
3731
-        geodirectory_load_db_language();
3732
-    }
3733
-
3734
-    if (file_exists($language_file)) {
3735
-        /**
3736
-         * Language strings from database.
3737
-         *
3738
-         * @since 1.4.2
3739
-         */
3740
-        try {
3741
-            require_once($language_file);
3742
-        } catch(Exception $e) {
3743
-            error_log('Language Error: ' . $e->getMessage());
3744
-        }
3745
-    }
3734
+	if (file_exists($language_file)) {
3735
+		/**
3736
+		 * Language strings from database.
3737
+		 *
3738
+		 * @since 1.4.2
3739
+		 */
3740
+		try {
3741
+			require_once($language_file);
3742
+		} catch(Exception $e) {
3743
+			error_log('Language Error: ' . $e->getMessage());
3744
+		}
3745
+	}
3746 3746
 }
3747 3747
 
3748 3748
 /**
@@ -3756,66 +3756,66 @@  discard block
 block discarded – undo
3756 3756
  * @return bool True if file created otherwise false
3757 3757
  */
3758 3758
 function geodirectory_load_db_language() {
3759
-    global $wp_filesystem;
3760
-    if( empty( $wp_filesystem ) ) {
3761
-        require_once( ABSPATH .'/wp-admin/includes/file.php' );
3762
-        WP_Filesystem();
3763
-        global $wp_filesystem;
3764
-    }
3765
-
3766
-    $language_file = geodir_plugin_path() . '/db-language.php';
3759
+	global $wp_filesystem;
3760
+	if( empty( $wp_filesystem ) ) {
3761
+		require_once( ABSPATH .'/wp-admin/includes/file.php' );
3762
+		WP_Filesystem();
3763
+		global $wp_filesystem;
3764
+	}
3767 3765
 
3768
-    if(is_file($language_file) && !is_writable($language_file))
3769
-        return false; // Not possible to create.
3766
+	$language_file = geodir_plugin_path() . '/db-language.php';
3767
+
3768
+	if(is_file($language_file) && !is_writable($language_file))
3769
+		return false; // Not possible to create.
3770
+
3771
+	if(!is_file($language_file) && !is_writable(dirname($language_file)))
3772
+		return false; // Not possible to create.
3773
+
3774
+	$contents_strings = array();
3775
+
3776
+	/**
3777
+	 * Filter the language string from database to translate via po editor
3778
+	 *
3779
+	 * @since 1.4.2
3780
+	 *
3781
+	 * @param array $contents_strings Array of strings.
3782
+	 */
3783
+	$contents_strings = apply_filters('geodir_load_db_language', $contents_strings);
3784
+
3785
+	$contents_strings = array_unique($contents_strings);
3786
+
3787
+	$contents_head = array();
3788
+	$contents_head[] = "<?php";
3789
+	$contents_head[] = "/**";
3790
+	$contents_head[] = " * Translate language string stored in database. Ex: Custom Fields";
3791
+	$contents_head[] = " *";
3792
+	$contents_head[] = " * @package GeoDirectory";
3793
+	$contents_head[] = " * @since 1.4.2";
3794
+	$contents_head[] = " */";
3795
+	$contents_head[] = "";
3796
+	$contents_head[] = "// Language keys";
3797
+
3798
+	$contents_foot = array();
3799
+	$contents_foot[] = "";
3800
+	$contents_foot[] = "";
3801
+
3802
+	$contents = implode(PHP_EOL, $contents_head);
3803
+
3804
+	if (!empty($contents_strings)) {
3805
+		foreach ( $contents_strings as $string ) {
3806
+			if (is_scalar($string) && $string != '') {
3807
+				$string = str_replace("'", "\'", $string);
3808
+				$contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
3809
+			}
3810
+		}
3811
+	}
3770 3812
 
3771
-    if(!is_file($language_file) && !is_writable(dirname($language_file)))
3772
-        return false; // Not possible to create.
3813
+	$contents .= implode(PHP_EOL, $contents_foot);
3773 3814
 
3774
-    $contents_strings = array();
3815
+	if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE))
3816
+		return false; // Failure; could not write file.
3775 3817
 
3776
-    /**
3777
-     * Filter the language string from database to translate via po editor
3778
-     *
3779
-     * @since 1.4.2
3780
-     *
3781
-     * @param array $contents_strings Array of strings.
3782
-     */
3783
-    $contents_strings = apply_filters('geodir_load_db_language', $contents_strings);
3784
-
3785
-    $contents_strings = array_unique($contents_strings);
3786
-
3787
-    $contents_head = array();
3788
-    $contents_head[] = "<?php";
3789
-    $contents_head[] = "/**";
3790
-    $contents_head[] = " * Translate language string stored in database. Ex: Custom Fields";
3791
-    $contents_head[] = " *";
3792
-    $contents_head[] = " * @package GeoDirectory";
3793
-    $contents_head[] = " * @since 1.4.2";
3794
-    $contents_head[] = " */";
3795
-    $contents_head[] = "";
3796
-    $contents_head[] = "// Language keys";
3797
-
3798
-    $contents_foot = array();
3799
-    $contents_foot[] = "";
3800
-    $contents_foot[] = "";
3801
-
3802
-    $contents = implode(PHP_EOL, $contents_head);
3803
-
3804
-    if (!empty($contents_strings)) {
3805
-        foreach ( $contents_strings as $string ) {
3806
-            if (is_scalar($string) && $string != '') {
3807
-                $string = str_replace("'", "\'", $string);
3808
-                $contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
3809
-            }
3810
-        }
3811
-    }
3812
-
3813
-    $contents .= implode(PHP_EOL, $contents_foot);
3814
-
3815
-    if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE))
3816
-        return false; // Failure; could not write file.
3817
-
3818
-    return true;
3818
+	return true;
3819 3819
 }
3820 3820
 
3821 3821
 /**
@@ -3831,31 +3831,31 @@  discard block
 block discarded – undo
3831 3831
  * @return array Translation texts.
3832 3832
  */
3833 3833
 function geodir_load_custom_field_translation($translation_texts = array()) {
3834
-    global $wpdb;
3834
+	global $wpdb;
3835 3835
 
3836
-    // Custom fields table
3837
-    $sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM " . GEODIR_CUSTOM_FIELDS_TABLE;
3838
-    $rows = $wpdb->get_results($sql);
3836
+	// Custom fields table
3837
+	$sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM " . GEODIR_CUSTOM_FIELDS_TABLE;
3838
+	$rows = $wpdb->get_results($sql);
3839 3839
 
3840
-    if (!empty($rows)) {
3841
-        foreach($rows as $row) {
3842
-            if (!empty($row->admin_title))
3843
-                $translation_texts[] = stripslashes_deep($row->admin_title);
3840
+	if (!empty($rows)) {
3841
+		foreach($rows as $row) {
3842
+			if (!empty($row->admin_title))
3843
+				$translation_texts[] = stripslashes_deep($row->admin_title);
3844 3844
 			
3845
-            if (!empty($row->admin_desc))
3846
-                $translation_texts[] = stripslashes_deep($row->admin_desc);
3845
+			if (!empty($row->admin_desc))
3846
+				$translation_texts[] = stripslashes_deep($row->admin_desc);
3847 3847
 
3848
-            if (!empty($row->site_title))
3849
-                $translation_texts[] = stripslashes_deep($row->site_title);
3848
+			if (!empty($row->site_title))
3849
+				$translation_texts[] = stripslashes_deep($row->site_title);
3850 3850
 
3851
-            if (!empty($row->clabels))
3852
-                $translation_texts[] = stripslashes_deep($row->clabels);
3851
+			if (!empty($row->clabels))
3852
+				$translation_texts[] = stripslashes_deep($row->clabels);
3853 3853
 
3854
-            if (!empty($row->required_msg))
3855
-                $translation_texts[] = stripslashes_deep($row->required_msg);
3854
+			if (!empty($row->required_msg))
3855
+				$translation_texts[] = stripslashes_deep($row->required_msg);
3856 3856
 			
3857 3857
 			if (!empty($row->default_value))
3858
-                $translation_texts[] = stripslashes_deep($row->default_value);
3858
+				$translation_texts[] = stripslashes_deep($row->default_value);
3859 3859
 			
3860 3860
 			if (!empty($row->option_values)) {
3861 3861
 				$option_values = geodir_string_values_to_options(stripslashes_deep($row->option_values));
@@ -3868,25 +3868,25 @@  discard block
 block discarded – undo
3868 3868
 					}
3869 3869
 				}
3870 3870
 			}
3871
-        }
3872
-    }
3871
+		}
3872
+	}
3873 3873
 	
3874
-    // Custom sorting fields table
3875
-    $sql = "SELECT site_title, asc_title, desc_title FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE;
3876
-    $rows = $wpdb->get_results($sql);
3877
-
3878
-    if (!empty($rows)) {
3879
-        foreach($rows as $row) {
3880
-            if (!empty($row->site_title))
3881
-                $translation_texts[] = stripslashes_deep($row->site_title);
3882
-
3883
-            if (!empty($row->asc_title))
3884
-                $translation_texts[] = stripslashes_deep($row->asc_title);
3885
-
3886
-            if (!empty($row->desc_title))
3887
-                $translation_texts[] = stripslashes_deep($row->desc_title);
3888
-        }
3889
-    }
3874
+	// Custom sorting fields table
3875
+	$sql = "SELECT site_title, asc_title, desc_title FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE;
3876
+	$rows = $wpdb->get_results($sql);
3877
+
3878
+	if (!empty($rows)) {
3879
+		foreach($rows as $row) {
3880
+			if (!empty($row->site_title))
3881
+				$translation_texts[] = stripslashes_deep($row->site_title);
3882
+
3883
+			if (!empty($row->asc_title))
3884
+				$translation_texts[] = stripslashes_deep($row->asc_title);
3885
+
3886
+			if (!empty($row->desc_title))
3887
+				$translation_texts[] = stripslashes_deep($row->desc_title);
3888
+		}
3889
+	}
3890 3890
 	
3891 3891
 	// Advance search filter fields table
3892 3892
 	if (defined('GEODIR_ADVANCE_SEARCH_TABLE')) {
@@ -3907,9 +3907,9 @@  discard block
 block discarded – undo
3907 3907
 		}
3908 3908
 	}
3909 3909
 
3910
-    $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
3910
+	$translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
3911 3911
 
3912
-    return $translation_texts;
3912
+	return $translation_texts;
3913 3913
 }
3914 3914
 
3915 3915
 /**
@@ -3921,71 +3921,71 @@  discard block
 block discarded – undo
3921 3921
  * @return array Array of mime types.
3922 3922
  */
3923 3923
 function geodir_allowed_mime_types() {
3924
-    /**
3925
-     * Filter the list of mime types and file extensions allowed for file upload.
3926
-     *
3927
-     * @since 1.4.7
3928
-     * @package GeoDirectory
3929
-     *
3930
-     * @param array $geodir_allowed_mime_types and file extensions.
3931
-     */
3932
-    return apply_filters( 'geodir_allowed_mime_types', array(
3933
-            'Image' => array( // Image formats.
3934
-                'jpg' => 'image/jpeg',
3935
-                'jpe' => 'image/jpeg',
3936
-                'jpeg' => 'image/jpeg',
3937
-                'gif' => 'image/gif',
3938
-                'png' => 'image/png',
3939
-                'bmp' => 'image/bmp',
3940
-                'ico' => 'image/x-icon',
3941
-            ),
3942
-            'Video' => array( // Video formats.
3943
-                'asf' => 'video/x-ms-asf',
3944
-                'avi' => 'video/avi',
3945
-                'flv' => 'video/x-flv',
3946
-                'mkv' => 'video/x-matroska',
3947
-                'mp4' => 'video/mp4',
3948
-                'mpeg' => 'video/mpeg',
3949
-                'mpg' => 'video/mpeg',
3950
-                'wmv' => 'video/x-ms-wmv',
3951
-                '3gp' => 'video/3gpp',
3952
-            ),
3953
-            'Audio' => array( // Audio formats.
3954
-                'ogg' => 'audio/ogg',
3955
-                'mp3' => 'audio/mpeg',
3956
-                'wav' => 'audio/wav',
3957
-                'wma' => 'audio/x-ms-wma',
3958
-            ),
3959
-            'Text' => array( // Text formats.
3960
-                'css' => 'text/css',
3961
-                'csv' => 'text/csv',
3962
-                'htm' => 'text/html',
3963
-                'html' => 'text/html',
3964
-                'txt' => 'text/plain',
3965
-                'rtx' => 'text/richtext',
3966
-                'vtt' => 'text/vtt',
3967
-            ),
3968
-            'Application' => array( // Application formats.
3969
-                'doc' => 'application/msword',
3970
-                'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
3971
-                'exe' => 'application/x-msdownload',
3972
-                'js' => 'application/javascript',
3973
-                'odt' => 'application/vnd.oasis.opendocument.text',
3974
-                'pdf' => 'application/pdf',
3975
-                'pot' => 'application/vnd.ms-powerpoint',
3976
-                'ppt' => 'application/vnd.ms-powerpoint',
3977
-                'pptx' => 'application/vnd.ms-powerpoint',
3978
-                'psd' => 'application/octet-stream',
3979
-                'rar' => 'application/rar',
3980
-                'rtf' => 'application/rtf',
3981
-                'swf' => 'application/x-shockwave-flash',
3982
-                'tar' => 'application/x-tar',
3983
-                'xls' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
3984
-                'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
3985
-                'zip' => 'application/zip',
3986
-            )
3987
-        )
3988
-    );
3924
+	/**
3925
+	 * Filter the list of mime types and file extensions allowed for file upload.
3926
+	 *
3927
+	 * @since 1.4.7
3928
+	 * @package GeoDirectory
3929
+	 *
3930
+	 * @param array $geodir_allowed_mime_types and file extensions.
3931
+	 */
3932
+	return apply_filters( 'geodir_allowed_mime_types', array(
3933
+			'Image' => array( // Image formats.
3934
+				'jpg' => 'image/jpeg',
3935
+				'jpe' => 'image/jpeg',
3936
+				'jpeg' => 'image/jpeg',
3937
+				'gif' => 'image/gif',
3938
+				'png' => 'image/png',
3939
+				'bmp' => 'image/bmp',
3940
+				'ico' => 'image/x-icon',
3941
+			),
3942
+			'Video' => array( // Video formats.
3943
+				'asf' => 'video/x-ms-asf',
3944
+				'avi' => 'video/avi',
3945
+				'flv' => 'video/x-flv',
3946
+				'mkv' => 'video/x-matroska',
3947
+				'mp4' => 'video/mp4',
3948
+				'mpeg' => 'video/mpeg',
3949
+				'mpg' => 'video/mpeg',
3950
+				'wmv' => 'video/x-ms-wmv',
3951
+				'3gp' => 'video/3gpp',
3952
+			),
3953
+			'Audio' => array( // Audio formats.
3954
+				'ogg' => 'audio/ogg',
3955
+				'mp3' => 'audio/mpeg',
3956
+				'wav' => 'audio/wav',
3957
+				'wma' => 'audio/x-ms-wma',
3958
+			),
3959
+			'Text' => array( // Text formats.
3960
+				'css' => 'text/css',
3961
+				'csv' => 'text/csv',
3962
+				'htm' => 'text/html',
3963
+				'html' => 'text/html',
3964
+				'txt' => 'text/plain',
3965
+				'rtx' => 'text/richtext',
3966
+				'vtt' => 'text/vtt',
3967
+			),
3968
+			'Application' => array( // Application formats.
3969
+				'doc' => 'application/msword',
3970
+				'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
3971
+				'exe' => 'application/x-msdownload',
3972
+				'js' => 'application/javascript',
3973
+				'odt' => 'application/vnd.oasis.opendocument.text',
3974
+				'pdf' => 'application/pdf',
3975
+				'pot' => 'application/vnd.ms-powerpoint',
3976
+				'ppt' => 'application/vnd.ms-powerpoint',
3977
+				'pptx' => 'application/vnd.ms-powerpoint',
3978
+				'psd' => 'application/octet-stream',
3979
+				'rar' => 'application/rar',
3980
+				'rtf' => 'application/rtf',
3981
+				'swf' => 'application/x-shockwave-flash',
3982
+				'tar' => 'application/x-tar',
3983
+				'xls' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
3984
+				'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
3985
+				'zip' => 'application/zip',
3986
+			)
3987
+		)
3988
+	);
3989 3989
 }
3990 3990
 
3991 3991
 /**
@@ -3997,21 +3997,21 @@  discard block
 block discarded – undo
3997 3997
  * @return string User display name.
3998 3998
  */
3999 3999
 function geodir_get_client_name($user_id) {
4000
-    $client_name = '';
4000
+	$client_name = '';
4001 4001
 
4002
-    $user_data = get_userdata($user_id);
4002
+	$user_data = get_userdata($user_id);
4003 4003
 
4004
-    if (!empty($user_data)) {
4005
-        if (isset($user_data->display_name) && trim($user_data->display_name) != '') {
4006
-            $client_name = trim($user_data->display_name);
4007
-        } else if (isset($user_data->user_nicename) && trim($user_data->user_nicename) != '') {
4008
-            $client_name = trim($user_data->user_nicename);
4009
-        } else {
4010
-            $client_name = trim($user_data->user_login);
4011
-        }
4012
-    }
4004
+	if (!empty($user_data)) {
4005
+		if (isset($user_data->display_name) && trim($user_data->display_name) != '') {
4006
+			$client_name = trim($user_data->display_name);
4007
+		} else if (isset($user_data->user_nicename) && trim($user_data->user_nicename) != '') {
4008
+			$client_name = trim($user_data->user_nicename);
4009
+		} else {
4010
+			$client_name = trim($user_data->user_login);
4011
+		}
4012
+	}
4013 4013
 
4014
-    return $client_name;
4014
+	return $client_name;
4015 4015
 }
4016 4016
 
4017 4017
 
@@ -4026,125 +4026,125 @@  discard block
 block discarded – undo
4026 4026
  */
4027 4027
 function geodir_wpseo_replacements($vars){
4028 4028
 
4029
-    global $wp;
4030
-    $title = '';
4031
-    // location variables
4032
-    $gd_post_type = geodir_get_current_posttype();
4033
-    $location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
4034
-    /**
4035
-     * Filter the title variables location variables array
4036
-     *
4037
-     * @since 1.5.5
4038
-     * @package GeoDirectory
4039
-     * @param array $location_array The array of location variables.
4040
-     * @param array $vars The page title variables.
4041
-     */
4042
-    $location_array = apply_filters('geodir_filter_title_variables_location_arr_seo',$location_array, $vars);
4043
-    $location_titles = array();
4044
-    if(get_query_var( 'gd_country_full' )){
4045
-        if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4046
-        if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4047
-        if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4048
-    }
4049
-    $location_single = '';
4050
-    $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
4051
-    $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
4052
-    $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
4053
-
4054
-    $gd_country_actual = $gd_region_actual = $gd_city_actual = '';
4055
-
4056
-    if (function_exists('get_actual_location_name')) {
4057
-        $gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
4058
-        $gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
4059
-        $gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
4060
-    }
4061
-
4062
-    if ($gd_city != '') {
4063
-        if ($gd_city_actual != '') {
4064
-            $gd_city = $gd_city_actual;
4065
-        } else {
4066
-            $gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
4067
-            $gd_city = preg_replace('/[_-]/', ' ', $gd_city);
4068
-            $gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
4069
-        }
4070
-        $location_single = $gd_city;
4071
-
4072
-    } else if ($gd_region != '') {
4073
-        if ($gd_region_actual != '') {
4074
-            $gd_region = $gd_region_actual;
4075
-        } else {
4076
-            $gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
4077
-            $gd_region = preg_replace('/[_-]/', ' ', $gd_region);
4078
-            $gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
4079
-        }
4080
-
4081
-        $location_single = $gd_region;
4082
-    } else if ($gd_country != '') {
4083
-        if ($gd_country_actual != '') {
4084
-            $gd_country = $gd_country_actual;
4085
-        } else {
4086
-            $gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
4087
-            $gd_country = preg_replace('/[_-]/', ' ', $gd_country);
4088
-            $gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
4089
-        }
4090
-
4091
-        $location_single = $gd_country;
4092
-    }
4093
-
4094
-    if (!empty($location_array)) {
4095
-
4096
-        $actual_location_name = function_exists('get_actual_location_name') ? true : false;
4097
-        $location_array = array_reverse($location_array);
4098
-
4099
-        foreach ($location_array as $location_type => $location) {
4100
-            $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
4101
-            $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
4102
-
4103
-            $location_name = geodir_ucwords($gd_location_link_text);
4104
-            $location_name = __($location_name, 'geodirectory');
4105
-
4106
-            if ($actual_location_name) {
4107
-                $location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type;
4108
-                $location_name = get_actual_location_name($location_type, $location, true);
4109
-            }
4110
-
4111
-            $location_titles[] = $location_name;
4112
-        }
4113
-        if (!empty($location_titles)) {
4114
-            $location_titles = array_unique($location_titles);
4115
-        }
4116
-    }
4117
-
4118
-
4119
-    if(!empty($location_titles)) {
4120
-        $vars['%%location%%'] = implode(", ", $location_titles);
4121
-    }
4122
-
4123
-
4124
-    if(!empty($location_titles)) {
4125
-        $vars['%%in_location%%'] = __('in ', 'geodirectory') . implode(", ", $location_titles);
4126
-    }
4127
-
4128
-
4129
-
4130
-    if($location_single) {
4131
-        $vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' .$location_single;
4132
-    }
4133
-
4134
-
4135
-    if($location_single) {
4136
-        $vars['%%location_single%%'] = $location_single;
4137
-    }
4138
-
4139
-    /**
4140
-     * Filter the title variables after standard ones have been filtered for wpseo.
4141
-     *
4142
-     * @since 1.5.7
4143
-     * @package GeoDirectory
4144
-     * @param string $vars The title with variables.
4145
-     * @param array $location_array The array of location variables.
4146
-     */
4147
-    return apply_filters('geodir_wpseo_replacements_vars',$vars,$location_array);
4029
+	global $wp;
4030
+	$title = '';
4031
+	// location variables
4032
+	$gd_post_type = geodir_get_current_posttype();
4033
+	$location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
4034
+	/**
4035
+	 * Filter the title variables location variables array
4036
+	 *
4037
+	 * @since 1.5.5
4038
+	 * @package GeoDirectory
4039
+	 * @param array $location_array The array of location variables.
4040
+	 * @param array $vars The page title variables.
4041
+	 */
4042
+	$location_array = apply_filters('geodir_filter_title_variables_location_arr_seo',$location_array, $vars);
4043
+	$location_titles = array();
4044
+	if(get_query_var( 'gd_country_full' )){
4045
+		if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4046
+		if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4047
+		if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4048
+	}
4049
+	$location_single = '';
4050
+	$gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
4051
+	$gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
4052
+	$gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
4053
+
4054
+	$gd_country_actual = $gd_region_actual = $gd_city_actual = '';
4055
+
4056
+	if (function_exists('get_actual_location_name')) {
4057
+		$gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
4058
+		$gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
4059
+		$gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
4060
+	}
4061
+
4062
+	if ($gd_city != '') {
4063
+		if ($gd_city_actual != '') {
4064
+			$gd_city = $gd_city_actual;
4065
+		} else {
4066
+			$gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
4067
+			$gd_city = preg_replace('/[_-]/', ' ', $gd_city);
4068
+			$gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
4069
+		}
4070
+		$location_single = $gd_city;
4071
+
4072
+	} else if ($gd_region != '') {
4073
+		if ($gd_region_actual != '') {
4074
+			$gd_region = $gd_region_actual;
4075
+		} else {
4076
+			$gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
4077
+			$gd_region = preg_replace('/[_-]/', ' ', $gd_region);
4078
+			$gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
4079
+		}
4080
+
4081
+		$location_single = $gd_region;
4082
+	} else if ($gd_country != '') {
4083
+		if ($gd_country_actual != '') {
4084
+			$gd_country = $gd_country_actual;
4085
+		} else {
4086
+			$gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
4087
+			$gd_country = preg_replace('/[_-]/', ' ', $gd_country);
4088
+			$gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
4089
+		}
4090
+
4091
+		$location_single = $gd_country;
4092
+	}
4093
+
4094
+	if (!empty($location_array)) {
4095
+
4096
+		$actual_location_name = function_exists('get_actual_location_name') ? true : false;
4097
+		$location_array = array_reverse($location_array);
4098
+
4099
+		foreach ($location_array as $location_type => $location) {
4100
+			$gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
4101
+			$gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
4102
+
4103
+			$location_name = geodir_ucwords($gd_location_link_text);
4104
+			$location_name = __($location_name, 'geodirectory');
4105
+
4106
+			if ($actual_location_name) {
4107
+				$location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type;
4108
+				$location_name = get_actual_location_name($location_type, $location, true);
4109
+			}
4110
+
4111
+			$location_titles[] = $location_name;
4112
+		}
4113
+		if (!empty($location_titles)) {
4114
+			$location_titles = array_unique($location_titles);
4115
+		}
4116
+	}
4117
+
4118
+
4119
+	if(!empty($location_titles)) {
4120
+		$vars['%%location%%'] = implode(", ", $location_titles);
4121
+	}
4122
+
4123
+
4124
+	if(!empty($location_titles)) {
4125
+		$vars['%%in_location%%'] = __('in ', 'geodirectory') . implode(", ", $location_titles);
4126
+	}
4127
+
4128
+
4129
+
4130
+	if($location_single) {
4131
+		$vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' .$location_single;
4132
+	}
4133
+
4134
+
4135
+	if($location_single) {
4136
+		$vars['%%location_single%%'] = $location_single;
4137
+	}
4138
+
4139
+	/**
4140
+	 * Filter the title variables after standard ones have been filtered for wpseo.
4141
+	 *
4142
+	 * @since 1.5.7
4143
+	 * @package GeoDirectory
4144
+	 * @param string $vars The title with variables.
4145
+	 * @param array $location_array The array of location variables.
4146
+	 */
4147
+	return apply_filters('geodir_wpseo_replacements_vars',$vars,$location_array);
4148 4148
 }
4149 4149
 
4150 4150
 
@@ -4154,10 +4154,10 @@  discard block
 block discarded – undo
4154 4154
 function geodir_filter_title_variables($title, $gd_page, $sep=''){
4155 4155
 
4156 4156
 
4157
-    if(!$gd_page || !$title){return $title;}// if no a GD page then bail.
4158
-    global $post;
4159
-    //print_r($post);
4160
-    /*
4157
+	if(!$gd_page || !$title){return $title;}// if no a GD page then bail.
4158
+	global $post;
4159
+	//print_r($post);
4160
+	/*
4161 4161
     %%date%%	                Replaced with the date of the post/page
4162 4162
     %%title%%	                Replaced with the title of the post/page
4163 4163
     %%sitename%%	            The site's name
@@ -4184,314 +4184,314 @@  discard block
 block discarded – undo
4184 4184
     %%pagenumber%%	            Replaced with the current page number
4185 4185
      */
4186 4186
 
4187
-    if ($sep == '') {
4188
-        /**
4189
-         * Filter the page title separator.
4190
-         *
4191
-         * @since 1.0.0
4192
-         * @package GeoDirectory
4193
-         * @param string $sep The separator, default: `|`.
4194
-         */
4195
-        $sep = apply_filters('geodir_page_title_separator', '|');
4196
-    }
4197
-
4198
-
4199
-    if(strpos($title,'%%title%%') !== false){
4200
-        $title = str_replace("%%title%%",$post->post_title,$title);
4201
-    }
4202
-
4203
-    if(strpos($title,'%%sitename%%') !== false){
4204
-        $title = str_replace("%%sitename%%",get_bloginfo('name'),$title);
4205
-    }
4206
-
4207
-    if(strpos($title,'%%sitedesc%%') !== false){
4208
-        $title = str_replace("%%sitedesc%%",get_bloginfo('description'),$title);
4209
-    }
4210
-
4211
-    if(strpos($title,'%%excerpt%%') !== false){
4212
-        $title = str_replace("%%excerpt%%",strip_tags(get_the_excerpt()),$title);
4213
-    }
4214
-
4215
-    if(strpos($title,'%%pt_single%%') !== false){
4216
-        $single_name = '';
4217
-        if($gd_page=='search' || $gd_page=='author'){
4218
-            $geodir_post_types = get_option('geodir_post_types');
4219
-            $spt = esc_attr($_REQUEST['stype']);
4220
-            if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
4221
-                $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
4222
-            }
4223
-        }elseif($gd_page=='add-listing'){
4224
-            $geodir_post_types = get_option('geodir_post_types');
4225
-            $spt = isset($_REQUEST['listing_type']) ? esc_attr($_REQUEST['listing_type']) : '';
4226
-            if(!$spt && isset($_REQUEST['pid'])){
4227
-                $spt = get_post_type( $_REQUEST['pid'] );
4228
-            }
4229
-            if(!$spt){$spt='gd_place';}
4230
-            if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
4231
-                $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
4232
-            }
4233
-        }
4234
-        elseif($post->post_type){
4235
-            $geodir_post_types = get_option('geodir_post_types');
4236
-            if(isset($geodir_post_types[$post->post_type]['labels']['singular_name'])){
4237
-                $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'],'geodirectory');
4238
-            }
4239
-
4240
-
4241
-        }
4242
-        $title = str_replace("%%pt_single%%",$single_name,$title);
4243
-    }
4244
-
4245
-    if(strpos($title,'%%pt_plural%%') !== false){
4246
-        $plural_name = '';
4247
-        if($gd_page=='search' || $gd_page=='author'){
4248
-            $geodir_post_types = get_option('geodir_post_types');
4249
-            $spt = esc_attr($_REQUEST['stype']);
4250
-            if(isset($geodir_post_types[$spt]['labels']['name'])){
4251
-                $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4252
-            }
4253
-        }elseif($gd_page=='add-listing'){
4254
-            $geodir_post_types = get_option('geodir_post_types');
4255
-            $spt = sanitize_text_field($_REQUEST['listing_type']);
4256
-            if(!$spt){$spt='gd_place';}
4257
-            if(isset($geodir_post_types[$spt]['labels']['name'])){
4258
-                $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4259
-            }
4260
-        }
4261
-        elseif(isset($post->post_type) && $post->post_type){
4262
-            $geodir_post_types = get_option('geodir_post_types');
4263
-            if(isset($geodir_post_types[$post->post_type]['labels']['name'])){
4264
-                $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'],'geodirectory');
4265
-            }
4266
-
4267
-        }
4268
-        $title = str_replace("%%pt_plural%%",$plural_name,$title);
4269
-    }
4270
-
4271
-
4272
-
4273
-    if(strpos($title,'%%category%%') !== false){
4274
-        $cat_name = '';
4275
-
4276
-        if($gd_page=='detail') {
4277
-            if ($post->default_category) {
4278
-                $cat = get_term($post->default_category, $post->post_type . 'category');
4279
-                $cat_name = (isset($cat->name)) ? $cat->name : '';
4280
-            }
4281
-        }elseif($gd_page=='listing'){
4282
-            $queried_object = get_queried_object();
4283
-            if(isset($queried_object->name)){
4284
-                $cat_name = $queried_object->name;
4285
-            }
4286
-        }
4287
-        $title = str_replace("%%category%%",$cat_name,$title);
4288
-    }
4289
-
4290
-    if(strpos($title,'%%tag%%') !== false){
4291
-        $cat_name = '';
4292
-
4293
-        if($gd_page=='detail') {
4294
-            if ($post->default_category) {
4295
-                $cat = get_term($post->default_category, $post->post_type . 'category');
4296
-                $cat_name = (isset($cat->name)) ? $cat->name : '';
4297
-            }
4298
-        }elseif($gd_page=='listing'){
4299
-            $queried_object = get_queried_object();
4300
-            if(isset($queried_object->name)){
4301
-                $cat_name = $queried_object->name;
4302
-            }
4303
-        }
4304
-        $title = str_replace("%%tag%%",$cat_name,$title);
4305
-    }
4306
-
4307
-
4308
-
4309
-    if(strpos($title,'%%id%%') !== false){
4310
-        $ID = (isset($post->ID)) ? $post->ID : '';
4311
-        $title = str_replace("%%id%%",$ID,$title);
4312
-    }
4313
-
4314
-    if(strpos($title,'%%sep%%') !== false){
4315
-        $title = str_replace("%%sep%%",$sep,$title);
4316
-    }
4317
-
4318
-
4319
-    global $wp;
4320
-    // location variables
4321
-    $gd_post_type = geodir_get_current_posttype();
4322
-    $location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
4323
-    /**
4324
-     * Filter the title variables location variables array
4325
-     *
4326
-     * @since 1.5.5
4327
-     * @package GeoDirectory
4328
-     * @param array $location_array The array of location variables.
4329
-     * @param string $title The title with variables..
4330
-     * @param string $gd_page The page being filtered.
4331
-     * @param string $sep The separator, default: `|`.
4332
-     */
4333
-    $location_array = apply_filters('geodir_filter_title_variables_location_arr',$location_array,$title, $gd_page, $sep);
4334
-    $location_titles = array();
4335
-    if($gd_page=='location' && get_query_var( 'gd_country_full' )){
4336
-        if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4337
-        if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4338
-        if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4339
-    }
4340
-    $location_single = '';
4341
-    $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
4342
-    $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
4343
-    $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
4344
-
4345
-    $gd_country_actual = $gd_region_actual = $gd_city_actual = '';
4346
-
4347
-    if (function_exists('get_actual_location_name')) {
4348
-        $gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
4349
-        $gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
4350
-        $gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
4351
-    }
4352
-
4353
-    if ($gd_city != '') {
4354
-        if ($gd_city_actual != '') {
4355
-            $gd_city = $gd_city_actual;
4356
-        } else {
4357
-            $gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
4358
-            $gd_city = preg_replace('/[_-]/', ' ', $gd_city);
4359
-            $gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
4360
-        }
4361
-        $location_single = $gd_city;
4362
-
4363
-    } else if ($gd_region != '') {
4364
-        if ($gd_region_actual != '') {
4365
-            $gd_region = $gd_region_actual;
4366
-        } else {
4367
-            $gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
4368
-            $gd_region = preg_replace('/[_-]/', ' ', $gd_region);
4369
-            $gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
4370
-        }
4371
-
4372
-        $location_single = $gd_region;
4373
-    } else if ($gd_country != '') {
4374
-        if ($gd_country_actual != '') {
4375
-            $gd_country = $gd_country_actual;
4376
-        } else {
4377
-            $gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
4378
-            $gd_country = preg_replace('/[_-]/', ' ', $gd_country);
4379
-            $gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
4380
-        }
4381
-
4382
-        $location_single = $gd_country;
4383
-    }
4384
-
4385
-    if (!empty($location_array)) {
4386
-
4387
-        $actual_location_name = function_exists('get_actual_location_name') ? true : false;
4388
-        $location_array = array_reverse($location_array);
4389
-
4390
-        foreach ($location_array as $location_type => $location) {
4391
-            $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
4392
-            $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
4393
-
4394
-            $location_name = geodir_ucwords($gd_location_link_text);
4395
-            $location_name = __($location_name, 'geodirectory');
4396
-
4397
-            if ($actual_location_name) {
4398
-                $location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type;
4399
-                $location_name = get_actual_location_name($location_type, $location, true);
4400
-            }
4401
-
4402
-            $location_titles[] = $location_name;
4403
-        }
4404
-        if (!empty($location_titles)) {
4405
-            $location_titles = array_unique($location_titles);
4406
-        }
4407
-    }
4408
-
4409
-
4410
-    if(strpos($title,'%%location%%') !== false){
4411
-        $location = '';
4412
-        if($location_titles) {
4413
-            $location = implode(", ", $location_titles);
4414
-        }
4415
-        $title = str_replace("%%location%%",$location,$title);
4416
-    }
4417
-
4418
-    if(strpos($title,'%%in_location%%') !== false){
4419
-        $location = '';
4420
-        if($location_titles) {
4421
-            $location = __('in ', 'geodirectory') . implode(", ", $location_titles);
4422
-        }
4423
-        $title = str_replace("%%in_location%%",$location,$title);
4424
-    }
4425
-
4426
-    if(strpos($title,'%%in_location_single%%') !== false){
4427
-        if($location_single) {
4428
-            $location_single = __('in', 'geodirectory') . ' ' .$location_single;
4429
-        }
4430
-        $title = str_replace("%%in_location_single%%",$location_single,$title);
4431
-    }
4432
-
4433
-    if(strpos($title,'%%location_single%%') !== false){
4434
-        $title = str_replace("%%location_single%%",$location_single,$title);
4435
-    }
4436
-
4437
-
4438
-    if(strpos($title,'%%search_term%%') !== false){
4439
-        $search_term = '';
4440
-        if(isset($_REQUEST['s'])){
4441
-            $search_term = esc_attr($_REQUEST['s']);
4442
-        }
4443
-        $title = str_replace("%%search_term%%",$search_term,$title);
4444
-    }
4445
-
4446
-    if(strpos($title,'%%search_near%%') !== false){
4447
-        $search_term = '';
4448
-        if(isset($_REQUEST['snear'])){
4449
-            $search_term = esc_attr($_REQUEST['snear']);
4450
-        }
4451
-        $title = str_replace("%%search_near%%",$search_term,$title);
4452
-    }
4453
-
4454
-    if(strpos($title,'%%name%%') !== false){
4455
-        $author_name = get_the_author();
4456
-        if (!$author_name || $author_name === '') {
4457
-            $queried_object = get_queried_object();
4187
+	if ($sep == '') {
4188
+		/**
4189
+		 * Filter the page title separator.
4190
+		 *
4191
+		 * @since 1.0.0
4192
+		 * @package GeoDirectory
4193
+		 * @param string $sep The separator, default: `|`.
4194
+		 */
4195
+		$sep = apply_filters('geodir_page_title_separator', '|');
4196
+	}
4197
+
4198
+
4199
+	if(strpos($title,'%%title%%') !== false){
4200
+		$title = str_replace("%%title%%",$post->post_title,$title);
4201
+	}
4202
+
4203
+	if(strpos($title,'%%sitename%%') !== false){
4204
+		$title = str_replace("%%sitename%%",get_bloginfo('name'),$title);
4205
+	}
4206
+
4207
+	if(strpos($title,'%%sitedesc%%') !== false){
4208
+		$title = str_replace("%%sitedesc%%",get_bloginfo('description'),$title);
4209
+	}
4210
+
4211
+	if(strpos($title,'%%excerpt%%') !== false){
4212
+		$title = str_replace("%%excerpt%%",strip_tags(get_the_excerpt()),$title);
4213
+	}
4214
+
4215
+	if(strpos($title,'%%pt_single%%') !== false){
4216
+		$single_name = '';
4217
+		if($gd_page=='search' || $gd_page=='author'){
4218
+			$geodir_post_types = get_option('geodir_post_types');
4219
+			$spt = esc_attr($_REQUEST['stype']);
4220
+			if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
4221
+				$single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
4222
+			}
4223
+		}elseif($gd_page=='add-listing'){
4224
+			$geodir_post_types = get_option('geodir_post_types');
4225
+			$spt = isset($_REQUEST['listing_type']) ? esc_attr($_REQUEST['listing_type']) : '';
4226
+			if(!$spt && isset($_REQUEST['pid'])){
4227
+				$spt = get_post_type( $_REQUEST['pid'] );
4228
+			}
4229
+			if(!$spt){$spt='gd_place';}
4230
+			if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
4231
+				$single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
4232
+			}
4233
+		}
4234
+		elseif($post->post_type){
4235
+			$geodir_post_types = get_option('geodir_post_types');
4236
+			if(isset($geodir_post_types[$post->post_type]['labels']['singular_name'])){
4237
+				$single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'],'geodirectory');
4238
+			}
4239
+
4240
+
4241
+		}
4242
+		$title = str_replace("%%pt_single%%",$single_name,$title);
4243
+	}
4244
+
4245
+	if(strpos($title,'%%pt_plural%%') !== false){
4246
+		$plural_name = '';
4247
+		if($gd_page=='search' || $gd_page=='author'){
4248
+			$geodir_post_types = get_option('geodir_post_types');
4249
+			$spt = esc_attr($_REQUEST['stype']);
4250
+			if(isset($geodir_post_types[$spt]['labels']['name'])){
4251
+				$plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4252
+			}
4253
+		}elseif($gd_page=='add-listing'){
4254
+			$geodir_post_types = get_option('geodir_post_types');
4255
+			$spt = sanitize_text_field($_REQUEST['listing_type']);
4256
+			if(!$spt){$spt='gd_place';}
4257
+			if(isset($geodir_post_types[$spt]['labels']['name'])){
4258
+				$plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4259
+			}
4260
+		}
4261
+		elseif(isset($post->post_type) && $post->post_type){
4262
+			$geodir_post_types = get_option('geodir_post_types');
4263
+			if(isset($geodir_post_types[$post->post_type]['labels']['name'])){
4264
+				$plural_name = __($geodir_post_types[$post->post_type]['labels']['name'],'geodirectory');
4265
+			}
4266
+
4267
+		}
4268
+		$title = str_replace("%%pt_plural%%",$plural_name,$title);
4269
+	}
4270
+
4271
+
4272
+
4273
+	if(strpos($title,'%%category%%') !== false){
4274
+		$cat_name = '';
4275
+
4276
+		if($gd_page=='detail') {
4277
+			if ($post->default_category) {
4278
+				$cat = get_term($post->default_category, $post->post_type . 'category');
4279
+				$cat_name = (isset($cat->name)) ? $cat->name : '';
4280
+			}
4281
+		}elseif($gd_page=='listing'){
4282
+			$queried_object = get_queried_object();
4283
+			if(isset($queried_object->name)){
4284
+				$cat_name = $queried_object->name;
4285
+			}
4286
+		}
4287
+		$title = str_replace("%%category%%",$cat_name,$title);
4288
+	}
4289
+
4290
+	if(strpos($title,'%%tag%%') !== false){
4291
+		$cat_name = '';
4292
+
4293
+		if($gd_page=='detail') {
4294
+			if ($post->default_category) {
4295
+				$cat = get_term($post->default_category, $post->post_type . 'category');
4296
+				$cat_name = (isset($cat->name)) ? $cat->name : '';
4297
+			}
4298
+		}elseif($gd_page=='listing'){
4299
+			$queried_object = get_queried_object();
4300
+			if(isset($queried_object->name)){
4301
+				$cat_name = $queried_object->name;
4302
+			}
4303
+		}
4304
+		$title = str_replace("%%tag%%",$cat_name,$title);
4305
+	}
4306
+
4307
+
4308
+
4309
+	if(strpos($title,'%%id%%') !== false){
4310
+		$ID = (isset($post->ID)) ? $post->ID : '';
4311
+		$title = str_replace("%%id%%",$ID,$title);
4312
+	}
4313
+
4314
+	if(strpos($title,'%%sep%%') !== false){
4315
+		$title = str_replace("%%sep%%",$sep,$title);
4316
+	}
4317
+
4318
+
4319
+	global $wp;
4320
+	// location variables
4321
+	$gd_post_type = geodir_get_current_posttype();
4322
+	$location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
4323
+	/**
4324
+	 * Filter the title variables location variables array
4325
+	 *
4326
+	 * @since 1.5.5
4327
+	 * @package GeoDirectory
4328
+	 * @param array $location_array The array of location variables.
4329
+	 * @param string $title The title with variables..
4330
+	 * @param string $gd_page The page being filtered.
4331
+	 * @param string $sep The separator, default: `|`.
4332
+	 */
4333
+	$location_array = apply_filters('geodir_filter_title_variables_location_arr',$location_array,$title, $gd_page, $sep);
4334
+	$location_titles = array();
4335
+	if($gd_page=='location' && get_query_var( 'gd_country_full' )){
4336
+		if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4337
+		if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4338
+		if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4339
+	}
4340
+	$location_single = '';
4341
+	$gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
4342
+	$gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
4343
+	$gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
4344
+
4345
+	$gd_country_actual = $gd_region_actual = $gd_city_actual = '';
4346
+
4347
+	if (function_exists('get_actual_location_name')) {
4348
+		$gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
4349
+		$gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
4350
+		$gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
4351
+	}
4352
+
4353
+	if ($gd_city != '') {
4354
+		if ($gd_city_actual != '') {
4355
+			$gd_city = $gd_city_actual;
4356
+		} else {
4357
+			$gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
4358
+			$gd_city = preg_replace('/[_-]/', ' ', $gd_city);
4359
+			$gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
4360
+		}
4361
+		$location_single = $gd_city;
4362
+
4363
+	} else if ($gd_region != '') {
4364
+		if ($gd_region_actual != '') {
4365
+			$gd_region = $gd_region_actual;
4366
+		} else {
4367
+			$gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
4368
+			$gd_region = preg_replace('/[_-]/', ' ', $gd_region);
4369
+			$gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
4370
+		}
4371
+
4372
+		$location_single = $gd_region;
4373
+	} else if ($gd_country != '') {
4374
+		if ($gd_country_actual != '') {
4375
+			$gd_country = $gd_country_actual;
4376
+		} else {
4377
+			$gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
4378
+			$gd_country = preg_replace('/[_-]/', ' ', $gd_country);
4379
+			$gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
4380
+		}
4381
+
4382
+		$location_single = $gd_country;
4383
+	}
4384
+
4385
+	if (!empty($location_array)) {
4386
+
4387
+		$actual_location_name = function_exists('get_actual_location_name') ? true : false;
4388
+		$location_array = array_reverse($location_array);
4389
+
4390
+		foreach ($location_array as $location_type => $location) {
4391
+			$gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
4392
+			$gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
4393
+
4394
+			$location_name = geodir_ucwords($gd_location_link_text);
4395
+			$location_name = __($location_name, 'geodirectory');
4396
+
4397
+			if ($actual_location_name) {
4398
+				$location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type;
4399
+				$location_name = get_actual_location_name($location_type, $location, true);
4400
+			}
4401
+
4402
+			$location_titles[] = $location_name;
4403
+		}
4404
+		if (!empty($location_titles)) {
4405
+			$location_titles = array_unique($location_titles);
4406
+		}
4407
+	}
4408
+
4409
+
4410
+	if(strpos($title,'%%location%%') !== false){
4411
+		$location = '';
4412
+		if($location_titles) {
4413
+			$location = implode(", ", $location_titles);
4414
+		}
4415
+		$title = str_replace("%%location%%",$location,$title);
4416
+	}
4417
+
4418
+	if(strpos($title,'%%in_location%%') !== false){
4419
+		$location = '';
4420
+		if($location_titles) {
4421
+			$location = __('in ', 'geodirectory') . implode(", ", $location_titles);
4422
+		}
4423
+		$title = str_replace("%%in_location%%",$location,$title);
4424
+	}
4425
+
4426
+	if(strpos($title,'%%in_location_single%%') !== false){
4427
+		if($location_single) {
4428
+			$location_single = __('in', 'geodirectory') . ' ' .$location_single;
4429
+		}
4430
+		$title = str_replace("%%in_location_single%%",$location_single,$title);
4431
+	}
4432
+
4433
+	if(strpos($title,'%%location_single%%') !== false){
4434
+		$title = str_replace("%%location_single%%",$location_single,$title);
4435
+	}
4436
+
4437
+
4438
+	if(strpos($title,'%%search_term%%') !== false){
4439
+		$search_term = '';
4440
+		if(isset($_REQUEST['s'])){
4441
+			$search_term = esc_attr($_REQUEST['s']);
4442
+		}
4443
+		$title = str_replace("%%search_term%%",$search_term,$title);
4444
+	}
4445
+
4446
+	if(strpos($title,'%%search_near%%') !== false){
4447
+		$search_term = '';
4448
+		if(isset($_REQUEST['snear'])){
4449
+			$search_term = esc_attr($_REQUEST['snear']);
4450
+		}
4451
+		$title = str_replace("%%search_near%%",$search_term,$title);
4452
+	}
4453
+
4454
+	if(strpos($title,'%%name%%') !== false){
4455
+		$author_name = get_the_author();
4456
+		if (!$author_name || $author_name === '') {
4457
+			$queried_object = get_queried_object();
4458 4458
             
4459
-            if (isset($queried_object->data->user_nicename)) {
4460
-                $author_name = $queried_object->data->user_nicename;
4461
-            }
4462
-        }
4463
-        $title = str_replace("%%name%%", $author_name, $title);
4464
-    }
4459
+			if (isset($queried_object->data->user_nicename)) {
4460
+				$author_name = $queried_object->data->user_nicename;
4461
+			}
4462
+		}
4463
+		$title = str_replace("%%name%%", $author_name, $title);
4464
+	}
4465 4465
     
4466
-    if (strpos($title, '%%page%%') !== false) {
4467
-        $page = geodir_title_meta_page($sep);
4468
-        $title = str_replace("%%page%%", $page, $title);
4469
-    }
4470
-    if (strpos($title, '%%pagenumber%%') !== false) {
4471
-        $pagenumber = geodir_title_meta_pagenumber();
4472
-        $title = str_replace("%%pagenumber%%", $pagenumber, $title);
4473
-    }
4474
-    if (strpos($title, '%%pagetotal%%') !== false) {
4475
-        $pagetotal = geodir_title_meta_pagetotal();
4476
-        $title = str_replace("%%pagetotal%%", $pagetotal, $title);
4477
-    }
4478
-
4479
-    $title = wptexturize( $title );
4480
-    $title = convert_chars( $title );
4481
-    $title = esc_html( $title );
4482
-
4483
-    /**
4484
-     * Filter the title variables after standard ones have been filtered.
4485
-     *
4486
-     * @since 1.5.7
4487
-     * @package GeoDirectory
4488
-     * @param string $title The title with variables.
4489
-     * @param array $location_array The array of location variables.
4490
-     * @param string $gd_page The page being filtered.
4491
-     * @param string $sep The separator, default: `|`.
4492
-     */
4466
+	if (strpos($title, '%%page%%') !== false) {
4467
+		$page = geodir_title_meta_page($sep);
4468
+		$title = str_replace("%%page%%", $page, $title);
4469
+	}
4470
+	if (strpos($title, '%%pagenumber%%') !== false) {
4471
+		$pagenumber = geodir_title_meta_pagenumber();
4472
+		$title = str_replace("%%pagenumber%%", $pagenumber, $title);
4473
+	}
4474
+	if (strpos($title, '%%pagetotal%%') !== false) {
4475
+		$pagetotal = geodir_title_meta_pagetotal();
4476
+		$title = str_replace("%%pagetotal%%", $pagetotal, $title);
4477
+	}
4493 4478
 
4494
-    return apply_filters('geodir_filter_title_variables_vars',$title,$location_array, $gd_page, $sep);
4479
+	$title = wptexturize( $title );
4480
+	$title = convert_chars( $title );
4481
+	$title = esc_html( $title );
4482
+
4483
+	/**
4484
+	 * Filter the title variables after standard ones have been filtered.
4485
+	 *
4486
+	 * @since 1.5.7
4487
+	 * @package GeoDirectory
4488
+	 * @param string $title The title with variables.
4489
+	 * @param array $location_array The array of location variables.
4490
+	 * @param string $gd_page The page being filtered.
4491
+	 * @param string $sep The separator, default: `|`.
4492
+	 */
4493
+
4494
+	return apply_filters('geodir_filter_title_variables_vars',$title,$location_array, $gd_page, $sep);
4495 4495
 }
4496 4496
 
4497 4497
 /**
@@ -4504,65 +4504,65 @@  discard block
 block discarded – undo
4504 4504
  * @return array Translation texts.
4505 4505
  */
4506 4506
 function geodir_load_cpt_text_translation($translation_texts = array()) {
4507
-    $gd_post_types = geodir_get_posttypes('array');
4508
-
4509
-    if (!empty($gd_post_types)) {
4510
-        foreach ($gd_post_types as $post_type => $cpt_info) {
4511
-            $labels = isset($cpt_info['labels']) ? $cpt_info['labels'] : '';
4512
-            $description = isset($cpt_info['description']) ? $cpt_info['description'] : '';
4513
-            $seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : '';
4514
-
4515
-            if (!empty($labels)) {
4516
-                if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts))
4517
-                    $translation_texts[] = $labels['name'];
4518
-                if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts))
4519
-                    $translation_texts[] = $labels['singular_name'];
4520
-                if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts))
4521
-                    $translation_texts[] = $labels['add_new'];
4522
-                if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts))
4523
-                    $translation_texts[] = $labels['add_new_item'];
4524
-                if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts))
4525
-                    $translation_texts[] = $labels['edit_item'];
4526
-                if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts))
4527
-                    $translation_texts[] = $labels['new_item'];
4528
-                if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts))
4529
-                    $translation_texts[] = $labels['view_item'];
4530
-                if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts))
4531
-                    $translation_texts[] = $labels['search_items'];
4532
-                if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts))
4533
-                    $translation_texts[] = $labels['not_found'];
4534
-                if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts))
4535
-                    $translation_texts[] = $labels['not_found_in_trash'];
4536
-                if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts))
4537
-                    $translation_texts[] = $labels['label_post_profile'];
4538
-                if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts))
4539
-                    $translation_texts[] = $labels['label_post_info'];
4540
-                if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts))
4541
-                    $translation_texts[] = $labels['label_post_images'];
4542
-                if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts))
4543
-                    $translation_texts[] = $labels['label_post_map'];
4544
-                if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts))
4545
-                    $translation_texts[] = $labels['label_reviews'];
4546
-                if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts))
4547
-                    $translation_texts[] = $labels['label_related_listing'];
4548
-            }
4549
-
4550
-            if ($description != '' && !in_array($description, $translation_texts)) {
4551
-                $translation_texts[] = normalize_whitespace($description);
4552
-            }
4553
-
4554
-            if (!empty($seo)) {
4555
-                if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts))
4556
-                    $translation_texts[] = normalize_whitespace($seo['meta_keyword']);
4557
-
4558
-                if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts))
4559
-                    $translation_texts[] = normalize_whitespace($seo['meta_description']);
4560
-            }
4561
-        }
4562
-    }
4563
-    $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
4564
-
4565
-    return $translation_texts;
4507
+	$gd_post_types = geodir_get_posttypes('array');
4508
+
4509
+	if (!empty($gd_post_types)) {
4510
+		foreach ($gd_post_types as $post_type => $cpt_info) {
4511
+			$labels = isset($cpt_info['labels']) ? $cpt_info['labels'] : '';
4512
+			$description = isset($cpt_info['description']) ? $cpt_info['description'] : '';
4513
+			$seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : '';
4514
+
4515
+			if (!empty($labels)) {
4516
+				if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts))
4517
+					$translation_texts[] = $labels['name'];
4518
+				if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts))
4519
+					$translation_texts[] = $labels['singular_name'];
4520
+				if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts))
4521
+					$translation_texts[] = $labels['add_new'];
4522
+				if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts))
4523
+					$translation_texts[] = $labels['add_new_item'];
4524
+				if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts))
4525
+					$translation_texts[] = $labels['edit_item'];
4526
+				if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts))
4527
+					$translation_texts[] = $labels['new_item'];
4528
+				if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts))
4529
+					$translation_texts[] = $labels['view_item'];
4530
+				if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts))
4531
+					$translation_texts[] = $labels['search_items'];
4532
+				if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts))
4533
+					$translation_texts[] = $labels['not_found'];
4534
+				if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts))
4535
+					$translation_texts[] = $labels['not_found_in_trash'];
4536
+				if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts))
4537
+					$translation_texts[] = $labels['label_post_profile'];
4538
+				if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts))
4539
+					$translation_texts[] = $labels['label_post_info'];
4540
+				if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts))
4541
+					$translation_texts[] = $labels['label_post_images'];
4542
+				if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts))
4543
+					$translation_texts[] = $labels['label_post_map'];
4544
+				if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts))
4545
+					$translation_texts[] = $labels['label_reviews'];
4546
+				if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts))
4547
+					$translation_texts[] = $labels['label_related_listing'];
4548
+			}
4549
+
4550
+			if ($description != '' && !in_array($description, $translation_texts)) {
4551
+				$translation_texts[] = normalize_whitespace($description);
4552
+			}
4553
+
4554
+			if (!empty($seo)) {
4555
+				if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts))
4556
+					$translation_texts[] = normalize_whitespace($seo['meta_keyword']);
4557
+
4558
+				if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts))
4559
+					$translation_texts[] = normalize_whitespace($seo['meta_description']);
4560
+			}
4561
+		}
4562
+	}
4563
+	$translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
4564
+
4565
+	return $translation_texts;
4566 4566
 }
4567 4567
 
4568 4568
 /**
@@ -4575,27 +4575,27 @@  discard block
 block discarded – undo
4575 4575
  * @return array Location terms.
4576 4576
  */
4577 4577
 function geodir_remove_location_terms($location_terms = array()) {
4578
-    $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
4579
-
4580
-    if (!empty($location_terms) && $location_manager) {
4581
-        $hide_country_part = get_option('geodir_location_hide_country_part');
4582
-        $hide_region_part = get_option('geodir_location_hide_region_part');
4583
-
4584
-        if ($hide_region_part && $hide_country_part) {
4585
-            if (isset($location_terms['gd_country']))
4586
-                unset($location_terms['gd_country']);
4587
-            if (isset($location_terms['gd_region']))
4588
-                unset($location_terms['gd_region']);
4589
-        } else if ($hide_region_part && !$hide_country_part) {
4590
-            if (isset($location_terms['gd_region']))
4591
-                unset($location_terms['gd_region']);
4592
-        } else if (!$hide_region_part && $hide_country_part) {
4593
-            if (isset($location_terms['gd_country']))
4594
-                unset($location_terms['gd_country']);
4595
-        }
4596
-    }
4597
-
4598
-    return $location_terms;
4578
+	$location_manager = defined('POST_LOCATION_TABLE') ? true : false;
4579
+
4580
+	if (!empty($location_terms) && $location_manager) {
4581
+		$hide_country_part = get_option('geodir_location_hide_country_part');
4582
+		$hide_region_part = get_option('geodir_location_hide_region_part');
4583
+
4584
+		if ($hide_region_part && $hide_country_part) {
4585
+			if (isset($location_terms['gd_country']))
4586
+				unset($location_terms['gd_country']);
4587
+			if (isset($location_terms['gd_region']))
4588
+				unset($location_terms['gd_region']);
4589
+		} else if ($hide_region_part && !$hide_country_part) {
4590
+			if (isset($location_terms['gd_region']))
4591
+				unset($location_terms['gd_region']);
4592
+		} else if (!$hide_region_part && $hide_country_part) {
4593
+			if (isset($location_terms['gd_country']))
4594
+				unset($location_terms['gd_country']);
4595
+		}
4596
+	}
4597
+
4598
+	return $location_terms;
4599 4599
 }
4600 4600
 
4601 4601
 /**
@@ -4609,47 +4609,47 @@  discard block
 block discarded – undo
4609 4609
  * @param bool $update Whether this is an existing listing being updated or not.
4610 4610
  */
4611 4611
 function geodir_on_wp_insert_post($post_ID, $post, $update) {
4612
-    if (!$update) {
4613
-        return;
4614
-    }
4612
+	if (!$update) {
4613
+		return;
4614
+	}
4615 4615
     
4616
-    $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : '';
4617
-    $is_admin = is_admin() && ( !defined('DOING_AJAX' ) || ( defined('DOING_AJAX') && !DOING_AJAX ) )  ? true : false;
4618
-    $inline_save = $action == 'inline-save' ? true : false;
4616
+	$action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : '';
4617
+	$is_admin = is_admin() && ( !defined('DOING_AJAX' ) || ( defined('DOING_AJAX') && !DOING_AJAX ) )  ? true : false;
4618
+	$inline_save = $action == 'inline-save' ? true : false;
4619 4619
 
4620
-    if (empty($post->post_type) || $is_admin || $inline_save || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) {
4621
-        return;
4622
-    }
4620
+	if (empty($post->post_type) || $is_admin || $inline_save || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) {
4621
+		return;
4622
+	}
4623 4623
     
4624
-    if ($action != '' && in_array($action, array('geodir_import_export'))) {
4625
-        return;
4626
-    }
4624
+	if ($action != '' && in_array($action, array('geodir_import_export'))) {
4625
+		return;
4626
+	}
4627 4627
 
4628
-    $user_id = (int)get_current_user_id();
4628
+	$user_id = (int)get_current_user_id();
4629 4629
         
4630
-    if ($user_id > 0 && get_option('geodir_notify_post_edited') && !wp_is_post_revision($post_ID) && in_array($post->post_type, geodir_get_posttypes())) {
4631
-        $author_id = !empty($post->post_author) ? $post->post_author : 0;
4630
+	if ($user_id > 0 && get_option('geodir_notify_post_edited') && !wp_is_post_revision($post_ID) && in_array($post->post_type, geodir_get_posttypes())) {
4631
+		$author_id = !empty($post->post_author) ? $post->post_author : 0;
4632 4632
         
4633
-        if ($user_id == $author_id && !is_super_admin()) {
4634
-            $from_email = get_option('site_email');
4635
-            $from_name = get_site_emailName();
4636
-            $to_email = get_option('admin_email');
4637
-            $to_name = get_option('name');
4638
-            $message_type = 'listing_edited';
4633
+		if ($user_id == $author_id && !is_super_admin()) {
4634
+			$from_email = get_option('site_email');
4635
+			$from_name = get_site_emailName();
4636
+			$to_email = get_option('admin_email');
4637
+			$to_name = get_option('name');
4638
+			$message_type = 'listing_edited';
4639 4639
             
4640
-            $notify_edited = true;
4641
-            /**
4642
-             * Send notification when listing edited by author?
4643
-             *
4644
-             * @since 1.6.0
4645
-             * @param bool $notify_edited Notify on listing edited by author?
4646
-             * @param object $post The current post object.
4647
-             */
4648
-            $notify_edited = apply_filters('geodir_notify_on_listing_edited', $notify_edited, $post);
4640
+			$notify_edited = true;
4641
+			/**
4642
+			 * Send notification when listing edited by author?
4643
+			 *
4644
+			 * @since 1.6.0
4645
+			 * @param bool $notify_edited Notify on listing edited by author?
4646
+			 * @param object $post The current post object.
4647
+			 */
4648
+			$notify_edited = apply_filters('geodir_notify_on_listing_edited', $notify_edited, $post);
4649 4649
             
4650
-            geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID);
4651
-        }
4652
-    }
4650
+			geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID);
4651
+		}
4652
+	}
4653 4653
 }
4654 4654
 
4655 4655
 /**
@@ -4663,16 +4663,16 @@  discard block
 block discarded – undo
4663 4663
  * @return string|null The current page start & end numbering.
4664 4664
  */
4665 4665
 function geodir_title_meta_page($sep) {
4666
-    $replacement = null;
4666
+	$replacement = null;
4667 4667
 
4668
-    $max = geodir_title_meta_pagenumbering('max');
4669
-    $nr  = geodir_title_meta_pagenumbering('nr');
4668
+	$max = geodir_title_meta_pagenumbering('max');
4669
+	$nr  = geodir_title_meta_pagenumbering('nr');
4670 4670
 
4671
-    if ($max > 1 && $nr > 1) {
4672
-        $replacement = sprintf($sep . ' ' . __('Page %1$d of %2$d', 'geodirectory'), $nr, $max);
4673
-    }
4671
+	if ($max > 1 && $nr > 1) {
4672
+		$replacement = sprintf($sep . ' ' . __('Page %1$d of %2$d', 'geodirectory'), $nr, $max);
4673
+	}
4674 4674
 
4675
-    return $replacement;
4675
+	return $replacement;
4676 4676
 }
4677 4677
 
4678 4678
 /**
@@ -4684,14 +4684,14 @@  discard block
 block discarded – undo
4684 4684
  * @return string|null The current page number.
4685 4685
  */
4686 4686
 function geodir_title_meta_pagenumber() {
4687
-    $replacement = null;
4687
+	$replacement = null;
4688 4688
 
4689
-    $nr = geodir_title_meta_pagenumbering('nr');
4690
-    if (isset($nr) && $nr > 0) {
4691
-        $replacement = (string)$nr;
4692
-    }
4689
+	$nr = geodir_title_meta_pagenumbering('nr');
4690
+	if (isset($nr) && $nr > 0) {
4691
+		$replacement = (string)$nr;
4692
+	}
4693 4693
 
4694
-    return $replacement;
4694
+	return $replacement;
4695 4695
 }
4696 4696
 
4697 4697
 /**
@@ -4703,14 +4703,14 @@  discard block
 block discarded – undo
4703 4703
  * @return string|null The current page total.
4704 4704
  */
4705 4705
 function geodir_title_meta_pagetotal() {
4706
-    $replacement = null;
4706
+	$replacement = null;
4707 4707
 
4708
-    $max = geodir_title_meta_pagenumbering('max');
4709
-    if (isset($max) && $max > 0) {
4710
-        $replacement = (string)$max;
4711
-    }
4708
+	$max = geodir_title_meta_pagenumbering('max');
4709
+	if (isset($max) && $max > 0) {
4710
+		$replacement = (string)$max;
4711
+	}
4712 4712
 
4713
-    return $replacement;
4713
+	return $replacement;
4714 4714
 }
4715 4715
 
4716 4716
 /**
@@ -4727,44 +4727,44 @@  discard block
 block discarded – undo
4727 4727
  * @return int|null The current page numbering.
4728 4728
  */
4729 4729
 function geodir_title_meta_pagenumbering($request = 'nr') {
4730
-    global $wp_query, $post;
4731
-    $max_num_pages = null;
4732
-    $page_number   = null;
4733
-
4734
-    $max_num_pages = 1;
4735
-
4736
-    if (!is_singular()) {
4737
-        $page_number = get_query_var('paged');
4738
-        if ($page_number === 0 || $page_number === '') {
4739
-            $page_number = 1;
4740
-        }
4741
-
4742
-        if (isset($wp_query->max_num_pages) && ($wp_query->max_num_pages != '' && $wp_query->max_num_pages != 0)) {
4743
-            $max_num_pages = $wp_query->max_num_pages;
4744
-        }
4745
-    } else {
4746
-        $page_number = get_query_var('page');
4747
-        if ($page_number === 0 || $page_number === '') {
4748
-            $page_number = 1;
4749
-        }
4750
-
4751
-        if (isset($post->post_content)) {
4752
-            $max_num_pages = (substr_count($post->post_content, '<!--nextpage-->' ) + 1);
4753
-        }
4754
-    }
4755
-
4756
-    $return = null;
4757
-
4758
-    switch ($request) {
4759
-        case 'nr':
4760
-            $return = $page_number;
4761
-            break;
4762
-        case 'max':
4763
-            $return = $max_num_pages;
4764
-            break;
4765
-    }
4766
-
4767
-    return $return;
4730
+	global $wp_query, $post;
4731
+	$max_num_pages = null;
4732
+	$page_number   = null;
4733
+
4734
+	$max_num_pages = 1;
4735
+
4736
+	if (!is_singular()) {
4737
+		$page_number = get_query_var('paged');
4738
+		if ($page_number === 0 || $page_number === '') {
4739
+			$page_number = 1;
4740
+		}
4741
+
4742
+		if (isset($wp_query->max_num_pages) && ($wp_query->max_num_pages != '' && $wp_query->max_num_pages != 0)) {
4743
+			$max_num_pages = $wp_query->max_num_pages;
4744
+		}
4745
+	} else {
4746
+		$page_number = get_query_var('page');
4747
+		if ($page_number === 0 || $page_number === '') {
4748
+			$page_number = 1;
4749
+		}
4750
+
4751
+		if (isset($post->post_content)) {
4752
+			$max_num_pages = (substr_count($post->post_content, '<!--nextpage-->' ) + 1);
4753
+		}
4754
+	}
4755
+
4756
+	$return = null;
4757
+
4758
+	switch ($request) {
4759
+		case 'nr':
4760
+			$return = $page_number;
4761
+			break;
4762
+		case 'max':
4763
+			$return = $max_num_pages;
4764
+			break;
4765
+	}
4766
+
4767
+	return $return;
4768 4768
 }
4769 4769
 
4770 4770
 /**
@@ -4776,15 +4776,15 @@  discard block
 block discarded – undo
4776 4776
  * @return array Terms.
4777 4777
  */
4778 4778
 function geodir_filter_empty_terms($terms) {
4779
-    if (empty($terms)) {
4780
-        return $terms;
4781
-    }
4782
-
4783
-    $return = array();
4784
-    foreach ($terms as $term) {
4785
-        if (isset($term->count) && $term->count > 0) {
4786
-            $return[] = $term;
4787
-        }
4788
-    }
4789
-    return $return;
4779
+	if (empty($terms)) {
4780
+		return $terms;
4781
+	}
4782
+
4783
+	$return = array();
4784
+	foreach ($terms as $term) {
4785
+		if (isset($term->count) && $term->count > 0) {
4786
+			$return[] = $term;
4787
+		}
4788
+	}
4789
+	return $return;
4790 4790
 }
4791 4791
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +386 added lines, -386 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()) {
@@ -1226,31 +1226,31 @@  discard block
 block discarded – undo
1226 1226
                 $page_title = defined('GD_LOCATION') ? GD_LOCATION : __('Location', 'geodirectory');
1227 1227
             }
1228 1228
 
1229
-            $breadcrumb .= '<li>' . $separator;
1229
+            $breadcrumb .= '<li>'.$separator;
1230 1230
             $breadcrumb .= stripslashes_deep($page_title);
1231 1231
             $breadcrumb .= '</li>';
1232 1232
         } else if (is_tag()) {
1233
-            $breadcrumb .=  "<li> " . $separator . single_tag_title('',false) . '</li>';
1233
+            $breadcrumb .= "<li> ".$separator.single_tag_title('', false).'</li>';
1234 1234
         } else if (is_day()) {
1235
-            $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1235
+            $breadcrumb .= "<li> ".$separator.__(" Archive for", 'geodirectory')." ";
1236 1236
             the_time('F jS, Y');
1237 1237
             $breadcrumb .= '</li>';
1238 1238
         } else if (is_month()) {
1239
-            $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1239
+            $breadcrumb .= "<li> ".$separator.__(" Archive for", 'geodirectory')." ";
1240 1240
             the_time('F, Y');
1241 1241
             $breadcrumb .= '</li>';
1242 1242
         } else if (is_year()) {
1243
-            $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
1243
+            $breadcrumb .= "<li> ".$separator.__(" Archive for", 'geodirectory')." ";
1244 1244
             the_time('Y');
1245 1245
             $breadcrumb .= '</li>';
1246 1246
         } else if (is_author()) {
1247
-            $breadcrumb .= "<li> " . $separator . __(" Author Archive", 'geodirectory');
1247
+            $breadcrumb .= "<li> ".$separator.__(" Author Archive", 'geodirectory');
1248 1248
             $breadcrumb .= '</li>';
1249 1249
         } else if (isset($_GET['paged']) && !empty($_GET['paged'])) {
1250
-            $breadcrumb .= "<li>" . $separator . __("Blog Archives", 'geodirectory');
1250
+            $breadcrumb .= "<li>".$separator.__("Blog Archives", 'geodirectory');
1251 1251
             $breadcrumb .= '</li>';
1252 1252
         } else if (is_search()) {
1253
-            $breadcrumb .= "<li> " . $separator . __(" Search Results", 'geodirectory');
1253
+            $breadcrumb .= "<li> ".$separator.__(" Search Results", 'geodirectory');
1254 1254
             $breadcrumb .= '</li>';
1255 1255
         }
1256 1256
         $breadcrumb .= '</ul></div>';
@@ -1306,7 +1306,7 @@  discard block
 block discarded – undo
1306 1306
 function fetch_remote_file($url)
1307 1307
 {
1308 1308
     // extract the file name and extension from the url
1309
-    require_once(ABSPATH . 'wp-includes/pluggable.php');
1309
+    require_once(ABSPATH.'wp-includes/pluggable.php');
1310 1310
     $file_name = basename($url);
1311 1311
     if (strpos($file_name, '?') !== false) {
1312 1312
         list($file_name) = explode('?', $file_name);
@@ -1338,7 +1338,7 @@  discard block
 block discarded – undo
1338 1338
         return new WP_Error('upload_dir_error', $upload['error']);
1339 1339
 
1340 1340
     // fetch the remote url and write it to the placeholder file
1341
-    $headers = wp_remote_get($url, array('stream' => true,'filename' => $upload['file']));
1341
+    $headers = wp_remote_get($url, array('stream' => true, 'filename' => $upload['file']));
1342 1342
 
1343 1343
     $log_message = '';
1344 1344
     $filesize = filesize($upload['file']);
@@ -1351,21 +1351,21 @@  discard block
 block discarded – undo
1351 1351
         $log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
1352 1352
     }
1353 1353
     elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
1354
-        $log_message =  __('Remote file is incorrect size', 'geodirectory');
1354
+        $log_message = __('Remote file is incorrect size', 'geodirectory');
1355 1355
     }
1356 1356
     elseif (0 == $filesize) {
1357 1357
         $log_message = __('Zero size file downloaded', 'geodirectory');
1358 1358
     }
1359 1359
 
1360
-    if($log_message){
1360
+    if ($log_message) {
1361 1361
         $del = unlink($upload['file']);
1362
-        if(!$del){geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory'));}
1363
-        return new WP_Error('import_file_error',$log_message );
1362
+        if (!$del) {geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory')); }
1363
+        return new WP_Error('import_file_error', $log_message);
1364 1364
     }
1365 1365
 
1366 1366
     if ($dummy && $add_to_cache && is_array($upload)) {
1367 1367
         $images = get_transient('cached_dummy_images');
1368
-        if(is_array($images))
1368
+        if (is_array($images))
1369 1369
             $images[$key] = $upload;
1370 1370
         else
1371 1371
             $images = array($key => $upload);
@@ -1386,12 +1386,12 @@  discard block
 block discarded – undo
1386 1386
  */
1387 1387
 function geodir_max_upload_size()
1388 1388
 {
1389
-    $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
1389
+    $max_filesize = (float) get_option('geodir_upload_max_filesize', 2);
1390 1390
 
1391 1391
     if ($max_filesize > 0 && $max_filesize < 1) {
1392
-        $max_filesize = (int)($max_filesize * 1024) . 'kb';
1392
+        $max_filesize = (int) ($max_filesize * 1024).'kb';
1393 1393
     } else {
1394
-        $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
1394
+        $max_filesize = $max_filesize > 0 ? $max_filesize.'mb' : '2mb';
1395 1395
     }
1396 1396
 
1397 1397
     /**
@@ -1414,7 +1414,7 @@  discard block
 block discarded – undo
1414 1414
  */
1415 1415
 function geodir_dummy_folder_exists()
1416 1416
 {
1417
-    $path = geodir_plugin_path() . '/geodirectory-admin/dummy/';
1417
+    $path = geodir_plugin_path().'/geodirectory-admin/dummy/';
1418 1418
     if (!is_dir($path))
1419 1419
         return false;
1420 1420
     else
@@ -1458,35 +1458,35 @@  discard block
 block discarded – undo
1458 1458
     {
1459 1459
         global $wpdb;
1460 1460
         if ($message_type == 'expiration') {
1461
-            $subject = stripslashes(__(get_option('renew_email_subject'),'geodirectory'));
1462
-            $client_message = stripslashes(__(get_option('renew_email_content'),'geodirectory'));
1461
+            $subject = stripslashes(__(get_option('renew_email_subject'), 'geodirectory'));
1462
+            $client_message = stripslashes(__(get_option('renew_email_content'), 'geodirectory'));
1463 1463
         } elseif ($message_type == 'post_submited') {
1464
-            $subject = __(get_option('post_submited_success_email_subject_admin'),'geodirectory');
1465
-            $client_message = __(get_option('post_submited_success_email_content_admin'),'geodirectory');
1464
+            $subject = __(get_option('post_submited_success_email_subject_admin'), 'geodirectory');
1465
+            $client_message = __(get_option('post_submited_success_email_content_admin'), 'geodirectory');
1466 1466
         } elseif ($message_type == 'renew') {
1467
-            $subject = __(get_option('post_renew_success_email_subject_admin'),'geodirectory');
1468
-            $client_message = __(get_option('post_renew_success_email_content_admin'),'geodirectory');
1467
+            $subject = __(get_option('post_renew_success_email_subject_admin'), 'geodirectory');
1468
+            $client_message = __(get_option('post_renew_success_email_content_admin'), 'geodirectory');
1469 1469
         } elseif ($message_type == 'upgrade') {
1470
-            $subject = __(get_option('post_upgrade_success_email_subject_admin'),'geodirectory');
1471
-            $client_message = __(get_option('post_upgrade_success_email_content_admin'),'geodirectory');
1470
+            $subject = __(get_option('post_upgrade_success_email_subject_admin'), 'geodirectory');
1471
+            $client_message = __(get_option('post_upgrade_success_email_content_admin'), 'geodirectory');
1472 1472
         } elseif ($message_type == 'claim_approved') {
1473
-            $subject = __(get_option('claim_approved_email_subject'),'geodirectory');
1474
-            $client_message = __(get_option('claim_approved_email_content'),'geodirectory');
1473
+            $subject = __(get_option('claim_approved_email_subject'), 'geodirectory');
1474
+            $client_message = __(get_option('claim_approved_email_content'), 'geodirectory');
1475 1475
         } elseif ($message_type == 'claim_rejected') {
1476
-            $subject = __(get_option('claim_rejected_email_subject'),'geodirectory');
1477
-            $client_message = __(get_option('claim_rejected_email_content'),'geodirectory');
1476
+            $subject = __(get_option('claim_rejected_email_subject'), 'geodirectory');
1477
+            $client_message = __(get_option('claim_rejected_email_content'), 'geodirectory');
1478 1478
         } elseif ($message_type == 'claim_requested') {
1479
-            $subject = __(get_option('claim_email_subject_admin'),'geodirectory');
1480
-            $client_message = __(get_option('claim_email_content_admin'),'geodirectory');
1479
+            $subject = __(get_option('claim_email_subject_admin'), 'geodirectory');
1480
+            $client_message = __(get_option('claim_email_content_admin'), 'geodirectory');
1481 1481
         } elseif ($message_type == 'auto_claim') {
1482
-            $subject = __(get_option('auto_claim_email_subject'),'geodirectory');
1483
-            $client_message = __(get_option('auto_claim_email_content'),'geodirectory');
1482
+            $subject = __(get_option('auto_claim_email_subject'), 'geodirectory');
1483
+            $client_message = __(get_option('auto_claim_email_content'), 'geodirectory');
1484 1484
         } elseif ($message_type == 'payment_success') {
1485
-            $subject = __(get_option('post_payment_success_admin_email_subject'),'geodirectory');
1486
-            $client_message = __(get_option('post_payment_success_admin_email_content'),'geodirectory');
1485
+            $subject = __(get_option('post_payment_success_admin_email_subject'), 'geodirectory');
1486
+            $client_message = __(get_option('post_payment_success_admin_email_content'), 'geodirectory');
1487 1487
         } elseif ($message_type == 'payment_fail') {
1488
-            $subject = __(get_option('post_payment_fail_admin_email_subject'),'geodirectory');
1489
-            $client_message = __(get_option('post_payment_fail_admin_email_content'),'geodirectory');
1488
+            $subject = __(get_option('post_payment_fail_admin_email_subject'), 'geodirectory');
1489
+            $client_message = __(get_option('post_payment_fail_admin_email_content'), 'geodirectory');
1490 1490
         }
1491 1491
         $transaction_details = $custom_1;
1492 1492
         $fromEmail = get_option('site_email');
@@ -1497,11 +1497,11 @@  discard block
 block discarded – undo
1497 1497
         $productlink = get_permalink($page_id);
1498 1498
         $post_info = get_post($page_id);
1499 1499
         $post_date = date('dS F,Y', strtotime($post_info->post_date));
1500
-        $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1500
+        $listingLink = '<a href="'.$productlink.'"><b>'.$post_info->post_title.'</b></a>';
1501 1501
         $loginurl = geodir_login_url();
1502
-        $loginurl_link = '<a href="' . $loginurl . '">login</a>';
1502
+        $loginurl_link = '<a href="'.$loginurl.'">login</a>';
1503 1503
         $siteurl = home_url();
1504
-        $siteurl_link = '<a href="' . $siteurl . '">' . $fromEmailName . '</a>';
1504
+        $siteurl_link = '<a href="'.$siteurl.'">'.$fromEmailName.'</a>';
1505 1505
         $user_info = get_userdata($user_id);
1506 1506
         $user_email = $user_info->user_email;
1507 1507
         $display_name = geodir_get_client_name($user_id);
@@ -1515,14 +1515,14 @@  discard block
 block discarded – undo
1515 1515
         } else {
1516 1516
             $post_type = 'listing';
1517 1517
         }
1518
-        $renew_link = '<a href="' . $siteurl . '?ptype=post_' . $post_type . '&renew=1&pid=' . $page_id . '">' . RENEW_LINK . '</a>';
1518
+        $renew_link = '<a href="'.$siteurl.'?ptype=post_'.$post_type.'&renew=1&pid='.$page_id.'">'.RENEW_LINK.'</a>';
1519 1519
         $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#]');
1520 1520
         $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);
1521 1521
         $client_message = str_replace($search_array, $replace_array, $client_message);
1522 1522
         $subject = str_replace($search_array, $replace_array, $subject);
1523
-        $headers = 'MIME-Version: 1.0' . "\r\n";
1524
-        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1525
-        $headers .= 'From: ' . $fromEmailName . ' <' . $fromEmail . '>' . "\r\n";
1523
+        $headers = 'MIME-Version: 1.0'."\r\n";
1524
+        $headers .= 'Content-type: text/html; charset=UTF-8'."\r\n";
1525
+        $headers .= 'From: '.$fromEmailName.' <'.$fromEmail.'>'."\r\n";
1526 1526
 
1527 1527
         $to = $fromEmail;
1528 1528
         $message = $client_message;
@@ -1539,7 +1539,7 @@  discard block
 block discarded – undo
1539 1539
          * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1540 1540
          * @param string $custom_1 Custom data to be sent.
1541 1541
          */
1542
-        $to = apply_filters('geodir_adminEmail_to',$to,$page_id, $user_id, $message_type, $custom_1 );
1542
+        $to = apply_filters('geodir_adminEmail_to', $to, $page_id, $user_id, $message_type, $custom_1);
1543 1543
         /**
1544 1544
          * Filter the admin email subject.
1545 1545
          *
@@ -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
-        $subject = apply_filters('geodir_adminEmail_subject',$subject,$page_id, $user_id, $message_type, $custom_1);
1554
+        $subject = apply_filters('geodir_adminEmail_subject', $subject, $page_id, $user_id, $message_type, $custom_1);
1555 1555
         /**
1556 1556
          * Filter the admin email message.
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
-        $message = apply_filters('geodir_adminEmail_message',$message,$page_id, $user_id, $message_type, $custom_1);
1566
+        $message = apply_filters('geodir_adminEmail_message', $message, $page_id, $user_id, $message_type, $custom_1);
1567 1567
         /**
1568 1568
          * Filter the admin email headers.
1569 1569
          *
@@ -1575,23 +1575,23 @@  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
-        $headers = apply_filters('geodir_adminEmail_headers',$headers,$page_id, $user_id, $message_type, $custom_1);
1578
+        $headers = apply_filters('geodir_adminEmail_headers', $headers, $page_id, $user_id, $message_type, $custom_1);
1579 1579
 
1580 1580
 
1581 1581
 
1582 1582
         $sent = wp_mail($to, $subject, $message, $headers);
1583
-        if( ! $sent ) {
1584
-            if ( is_array( $to ) ) {
1585
-                $to = implode( ',', $to );
1583
+        if (!$sent) {
1584
+            if (is_array($to)) {
1585
+                $to = implode(',', $to);
1586 1586
             }
1587 1587
             $log_message = sprintf(
1588
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1588
+                __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
1589 1589
                 $message_type,
1590
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1590
+                date_i18n('F j Y H:i:s', current_time('timestamp')),
1591 1591
                 $to,
1592 1592
                 $subject
1593 1593
             );
1594
-            geodir_error_log( $log_message );
1594
+            geodir_error_log($log_message);
1595 1595
         }
1596 1596
     }
1597 1597
 }
@@ -1617,18 +1617,18 @@  discard block
 block discarded – undo
1617 1617
     {
1618 1618
         $login_details = '';
1619 1619
         if ($message_type == 'send_friend') {
1620
-            $subject = stripslashes(__(get_option('email_friend_subject'),'geodirectory'));
1621
-            $message = stripslashes(__(get_option('email_friend_content'),'geodirectory'));
1620
+            $subject = stripslashes(__(get_option('email_friend_subject'), 'geodirectory'));
1621
+            $message = stripslashes(__(get_option('email_friend_content'), 'geodirectory'));
1622 1622
         } elseif ($message_type == 'send_enquiry') {
1623
-            $subject = __(get_option('email_enquiry_subject'),'geodirectory');
1624
-            $message = __(get_option('email_enquiry_content'),'geodirectory');
1623
+            $subject = __(get_option('email_enquiry_subject'), 'geodirectory');
1624
+            $message = __(get_option('email_enquiry_content'), 'geodirectory');
1625 1625
         } elseif ($message_type == 'forgot_password') {
1626
-            $subject = __(get_option('forgot_password_subject'),'geodirectory');
1627
-            $message = __(get_option('forgot_password_content'),'geodirectory');
1626
+            $subject = __(get_option('forgot_password_subject'), 'geodirectory');
1627
+            $message = __(get_option('forgot_password_content'), 'geodirectory');
1628 1628
             $login_details = $to_message;
1629 1629
         } elseif ($message_type == 'registration') {
1630
-            $subject = __(get_option('registration_success_email_subject'),'geodirectory');
1631
-            $message = __(get_option('registration_success_email_content'),'geodirectory');
1630
+            $subject = __(get_option('registration_success_email_subject'), 'geodirectory');
1631
+            $message = __(get_option('registration_success_email_content'), 'geodirectory');
1632 1632
             $login_details = $to_message;
1633 1633
         }
1634 1634
         $to_message = nl2br($to_message);
@@ -1636,11 +1636,11 @@  discard block
 block discarded – undo
1636 1636
         $sitefromEmailName = get_site_emailName();
1637 1637
         $productlink = get_permalink($post_id);
1638 1638
         $post_info = get_post($post_id);
1639
-        $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1639
+        $listingLink = '<a href="'.$productlink.'"><b>'.$post_info->post_title.'</b></a>';
1640 1640
         $siteurl = home_url();
1641
-        $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
1641
+        $siteurl_link = '<a href="'.$siteurl.'">'.$siteurl.'</a>';
1642 1642
         $loginurl = geodir_login_url();
1643
-        $loginurl_link = '<a href="' . $loginurl . '">login</a>';
1643
+        $loginurl_link = '<a href="'.$loginurl.'">login</a>';
1644 1644
         if ($fromEmail == '') {
1645 1645
             $fromEmail = get_option('site_email');
1646 1646
         }
@@ -1654,26 +1654,26 @@  discard block
 block discarded – undo
1654 1654
         $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]');
1655 1655
         $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName);
1656 1656
         $subject = str_replace($search_array, $replace_array, $subject);
1657
-        $headers = 'MIME-Version: 1.0' . "\r\n";
1658
-        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1659
-        $headers .= "Reply-To: " . $fromEmail . "\r\n";
1660
-        $headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
1657
+        $headers = 'MIME-Version: 1.0'."\r\n";
1658
+        $headers .= 'Content-type: text/html; charset=UTF-8'."\r\n";
1659
+        $headers .= "Reply-To: ".$fromEmail."\r\n";
1660
+        $headers .= 'From: '.$sitefromEmailName.' <'.$sitefromEmail.'>'."\r\n";
1661 1661
 
1662 1662
         $to = $toEmail;
1663 1663
 
1664 1664
         $sent = wp_mail($to, $subject, $message, $headers);
1665
-        if( ! $sent ) {
1666
-            if ( is_array( $to ) ) {
1667
-                $to = implode( ',', $to );
1665
+        if (!$sent) {
1666
+            if (is_array($to)) {
1667
+                $to = implode(',', $to);
1668 1668
             }
1669 1669
             $log_message = sprintf(
1670
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1670
+                __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
1671 1671
                 $message_type,
1672
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1672
+                date_i18n('F j Y H:i:s', current_time('timestamp')),
1673 1673
                 $to,
1674 1674
                 $subject
1675 1675
             );
1676
-            geodir_error_log( $log_message );
1676
+            geodir_error_log($log_message);
1677 1677
         }
1678 1678
 
1679 1679
         ///////// ADMIN BCC EMIALS
@@ -1681,7 +1681,7 @@  discard block
 block discarded – undo
1681 1681
         if ($message_type == 'registration') {
1682 1682
             $message_raw = explode(__("Password:", 'geodirectory'), $message);
1683 1683
             $message_raw2 = explode("</p>", $message_raw[1], 2);
1684
-            $message = $message_raw[0] . __('Password:', 'geodirectory') . ' **********</p>' . $message_raw2[1];
1684
+            $message = $message_raw[0].__('Password:', 'geodirectory').' **********</p>'.$message_raw2[1];
1685 1685
         }
1686 1686
         $adminEmail = get_bloginfo('admin_email');
1687 1687
         $to = $adminEmail;
@@ -1699,20 +1699,20 @@  discard block
 block discarded – undo
1699 1699
             $admin_bcc = true;
1700 1700
         }
1701 1701
 
1702
-        if($admin_bcc === true){
1702
+        if ($admin_bcc === true) {
1703 1703
             $sent = wp_mail($to, $subject, $message, $headers);
1704
-            if( ! $sent ) {
1705
-                if ( is_array( $to ) ) {
1706
-                    $to = implode( ',', $to );
1704
+            if (!$sent) {
1705
+                if (is_array($to)) {
1706
+                    $to = implode(',', $to);
1707 1707
                 }
1708 1708
                 $log_message = sprintf(
1709
-                    __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1709
+                    __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
1710 1710
                     $message_type,
1711
-                    date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1711
+                    date_i18n('F j Y H:i:s', current_time('timestamp')),
1712 1712
                     $to,
1713 1713
                     $subject
1714 1714
                 );
1715
-                geodir_error_log( $log_message );
1715
+                geodir_error_log($log_message);
1716 1716
             }
1717 1717
         }
1718 1718
 
@@ -1760,7 +1760,7 @@  discard block
 block discarded – undo
1760 1760
 function geodir_custom_posts_body_class($classes) {
1761 1761
     global $wpdb, $wp;
1762 1762
     $post_types = geodir_get_posttypes('object');
1763
-    if (!empty($post_types) && count((array)$post_types) > 1) {
1763
+    if (!empty($post_types) && count((array) $post_types) > 1) {
1764 1764
         $classes[] = 'geodir_custom_posts';
1765 1765
     }
1766 1766
 
@@ -1820,7 +1820,7 @@  discard block
 block discarded – undo
1820 1820
     $geodir_option = get_option($geodir_option_name);
1821 1821
 
1822 1822
     if (!empty($geodir_option)) {
1823
-        add_option($geodir_option_name . '_' . $version_date, $geodir_option);
1823
+        add_option($geodir_option_name.'_'.$version_date, $geodir_option);
1824 1824
     }
1825 1825
 }
1826 1826
 
@@ -1926,36 +1926,36 @@  discard block
 block discarded – undo
1926 1926
 
1927 1927
     $query_args = $gd_query_args_widgets;
1928 1928
     if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
1929
-        return $wpdb->posts . ".post_date DESC, ";
1929
+        return $wpdb->posts.".post_date DESC, ";
1930 1930
     }
1931 1931
 
1932 1932
     $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1933
-    $table = $plugin_prefix . $post_type . '_detail';
1933
+    $table = $plugin_prefix.$post_type.'_detail';
1934 1934
 
1935 1935
     $sort_by = !empty($query_args['order_by']) ? $query_args['order_by'] : '';
1936 1936
 
1937 1937
     switch ($sort_by) {
1938 1938
         case 'latest':
1939 1939
         case 'newest':
1940
-            $orderby = $wpdb->posts . ".post_date DESC, ";
1940
+            $orderby = $wpdb->posts.".post_date DESC, ";
1941 1941
             break;
1942 1942
         case 'featured':
1943
-            $orderby = $table . ".is_featured ASC, ";
1943
+            $orderby = $table.".is_featured ASC, ";
1944 1944
             break;
1945 1945
         case 'az':
1946
-            $orderby = $wpdb->posts . ".post_title ASC, ";
1946
+            $orderby = $wpdb->posts.".post_title ASC, ";
1947 1947
             break;
1948 1948
         case 'high_review':
1949
-            $orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, ";
1949
+            $orderby = $table.".rating_count DESC, ".$table.".overall_rating DESC, ";
1950 1950
             break;
1951 1951
         case 'high_rating':
1952
-            $orderby = "( " . $table . ".overall_rating  ) DESC, ";
1952
+            $orderby = "( ".$table.".overall_rating  ) DESC, ";
1953 1953
             break;
1954 1954
         case 'random':
1955 1955
             $orderby = "RAND(), ";
1956 1956
             break;
1957 1957
         default:
1958
-            $orderby = $wpdb->posts . ".post_title ASC, ";
1958
+            $orderby = $wpdb->posts.".post_title ASC, ";
1959 1959
             break;
1960 1960
     }
1961 1961
 
@@ -1982,9 +1982,9 @@  discard block
 block discarded – undo
1982 1982
     $gd_query_args_widgets = $query_args;
1983 1983
 
1984 1984
     $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1985
-    $table = $plugin_prefix . $post_type . '_detail';
1985
+    $table = $plugin_prefix.$post_type.'_detail';
1986 1986
 
1987
-    $fields = $wpdb->posts . ".*, " . $table . ".*";
1987
+    $fields = $wpdb->posts.".*, ".$table.".*";
1988 1988
     /**
1989 1989
      * Filter widget listing fields string part that is being used for query.
1990 1990
      *
@@ -1995,7 +1995,7 @@  discard block
 block discarded – undo
1995 1995
      */
1996 1996
     $fields = apply_filters('geodir_filter_widget_listings_fields', $fields, $table, $post_type);
1997 1997
 
1998
-    $join = "INNER JOIN " . $table . " ON (" . $table . ".post_id = " . $wpdb->posts . ".ID)";
1998
+    $join = "INNER JOIN ".$table." ON (".$table.".post_id = ".$wpdb->posts.".ID)";
1999 1999
 
2000 2000
     ########### WPML ###########
2001 2001
 
@@ -2003,7 +2003,7 @@  discard block
 block discarded – undo
2003 2003
         global $sitepress;
2004 2004
         $lang_code = ICL_LANGUAGE_CODE;
2005 2005
         if ($lang_code) {
2006
-            $join .= " JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID";
2006
+            $join .= " JOIN ".$table_prefix."icl_translations icl_t ON icl_t.element_id = ".$table_prefix."posts.ID";
2007 2007
         }
2008 2008
     }
2009 2009
 
@@ -2018,9 +2018,9 @@  discard block
 block discarded – undo
2018 2018
      */
2019 2019
     $join = apply_filters('geodir_filter_widget_listings_join', $join, $post_type);
2020 2020
 
2021
-    $post_status = is_super_admin() ? " OR " . $wpdb->posts . ".post_status = 'private'" : '';
2021
+    $post_status = is_super_admin() ? " OR ".$wpdb->posts.".post_status = 'private'" : '';
2022 2022
 
2023
-    $where = " AND ( " . $wpdb->posts . ".post_status = 'publish' " . $post_status . " ) AND " . $wpdb->posts . ".post_type = '" . $post_type . "'";
2023
+    $where = " AND ( ".$wpdb->posts.".post_status = 'publish' ".$post_status." ) AND ".$wpdb->posts.".post_type = '".$post_type."'";
2024 2024
 
2025 2025
     ########### WPML ###########
2026 2026
     if (function_exists('icl_object_id')) {
@@ -2037,7 +2037,7 @@  discard block
 block discarded – undo
2037 2037
      * @param string $post_type Post type.
2038 2038
      */
2039 2039
     $where = apply_filters('geodir_filter_widget_listings_where', $where, $post_type);
2040
-    $where = $where != '' ? " WHERE 1=1 " . $where : '';
2040
+    $where = $where != '' ? " WHERE 1=1 ".$where : '';
2041 2041
 
2042 2042
     $groupby = " GROUP BY $wpdb->posts.ID ";
2043 2043
     /**
@@ -2050,10 +2050,10 @@  discard block
 block discarded – undo
2050 2050
     $groupby = apply_filters('geodir_filter_widget_listings_groupby', $groupby, $post_type);
2051 2051
 
2052 2052
     if ($count_only) {
2053
-        $sql = "SELECT COUNT(" . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . "
2054
-			" . $join . "
2053
+        $sql = "SELECT COUNT(".$wpdb->posts.".ID) AS total FROM ".$wpdb->posts."
2054
+			" . $join."
2055 2055
 			" . $where;
2056
-        $rows = (int)$wpdb->get_var($sql);
2056
+        $rows = (int) $wpdb->get_var($sql);
2057 2057
     } else {
2058 2058
         $orderby = geodir_widget_listings_get_order($query_args);
2059 2059
         /**
@@ -2065,8 +2065,8 @@  discard block
 block discarded – undo
2065 2065
          * @param string $post_type Post type.
2066 2066
          */
2067 2067
         $orderby = apply_filters('geodir_filter_widget_listings_orderby', $orderby, $table, $post_type);
2068
-        $orderby .= $wpdb->posts . ".post_title ASC";
2069
-        $orderby = $orderby != '' ? " ORDER BY " . $orderby : '';
2068
+        $orderby .= $wpdb->posts.".post_title ASC";
2069
+        $orderby = $orderby != '' ? " ORDER BY ".$orderby : '';
2070 2070
 
2071 2071
         $limit = !empty($query_args['posts_per_page']) ? $query_args['posts_per_page'] : 5;
2072 2072
         /**
@@ -2079,16 +2079,16 @@  discard block
 block discarded – undo
2079 2079
         $limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
2080 2080
 
2081 2081
         $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1;
2082
-        if ( !$page )
2082
+        if (!$page)
2083 2083
             $page = 1;
2084 2084
 
2085
-        $limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : "";
2085
+        $limit = (int) $limit > 0 ? " LIMIT ".absint(($page - 1) * (int) $limit).", ".(int) $limit : "";
2086 2086
 
2087
-        $sql = "SELECT SQL_CALC_FOUND_ROWS " . $fields . " FROM " . $wpdb->posts . "
2088
-			" . $join . "
2089
-			" . $where . "
2090
-			" . $groupby . "
2091
-			" . $orderby . "
2087
+        $sql = "SELECT SQL_CALC_FOUND_ROWS ".$fields." FROM ".$wpdb->posts."
2088
+			" . $join."
2089
+			" . $where."
2090
+			" . $groupby."
2091
+			" . $orderby."
2092 2092
 			" . $limit;
2093 2093
         $rows = $wpdb->get_results($sql);
2094 2094
     }
@@ -2141,10 +2141,10 @@  discard block
 block discarded – undo
2141 2141
     }
2142 2142
 
2143 2143
     $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2144
-    $table = $plugin_prefix . $post_type . '_detail';
2144
+    $table = $plugin_prefix.$post_type.'_detail';
2145 2145
 
2146 2146
     if (!empty($query_args['with_pics_only'])) {
2147
-        $join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )";
2147
+        $join .= " LEFT JOIN ".GEODIR_ATTACHMENT_TABLE." ON ( ".GEODIR_ATTACHMENT_TABLE.".post_id=".$table.".post_id AND ".GEODIR_ATTACHMENT_TABLE.".mime_type LIKE '%image%' )";
2148 2148
     }
2149 2149
 
2150 2150
     if (!empty($query_args['tax_query'])) {
@@ -2176,7 +2176,7 @@  discard block
 block discarded – undo
2176 2176
         return $where;
2177 2177
     }
2178 2178
     $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2179
-    $table = $plugin_prefix . $post_type . '_detail';
2179
+    $table = $plugin_prefix.$post_type.'_detail';
2180 2180
 
2181 2181
     if (!empty($query_args)) {
2182 2182
         if (!empty($query_args['gd_location']) && function_exists('geodir_default_location_where')) {
@@ -2184,27 +2184,27 @@  discard block
 block discarded – undo
2184 2184
         }
2185 2185
 
2186 2186
         if (!empty($query_args['post_author'])) {
2187
-            $where .= " AND " . $wpdb->posts . ".post_author = " . (int)$query_args['post_author'];
2187
+            $where .= " AND ".$wpdb->posts.".post_author = ".(int) $query_args['post_author'];
2188 2188
         }
2189 2189
         
2190 2190
         if (!empty($query_args['show_featured_only'])) {
2191
-            $where .= " AND " . $table . ".is_featured = '1'";
2191
+            $where .= " AND ".$table.".is_featured = '1'";
2192 2192
         }
2193 2193
 
2194 2194
         if (!empty($query_args['show_special_only'])) {
2195
-            $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )";
2195
+            $where .= " AND ( ".$table.".geodir_special_offers != '' AND ".$table.".geodir_special_offers IS NOT NULL )";
2196 2196
         }
2197 2197
 
2198 2198
         if (!empty($query_args['with_pics_only'])) {
2199
-            $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL ";
2199
+            $where .= " AND ".GEODIR_ATTACHMENT_TABLE.".ID IS NOT NULL ";
2200 2200
         }
2201 2201
 
2202 2202
         if (!empty($query_args['featured_image_only'])) {
2203
-            $where .= " AND " . $table . ".featured_image IS NOT NULL AND " . $table . ".featured_image!='' ";
2203
+            $where .= " AND ".$table.".featured_image IS NOT NULL AND ".$table.".featured_image!='' ";
2204 2204
         }
2205 2205
 
2206 2206
         if (!empty($query_args['with_videos_only'])) {
2207
-            $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )";
2207
+            $where .= " AND ( ".$table.".geodir_video != '' AND ".$table.".geodir_video IS NOT NULL )";
2208 2208
         }
2209 2209
 
2210 2210
         if (!empty($query_args['tax_query'])) {
@@ -2261,7 +2261,7 @@  discard block
 block discarded – undo
2261 2261
     }
2262 2262
 
2263 2263
     if (!empty($query_args) && !empty($query_args['posts_per_page'])) {
2264
-        $limit = (int)$query_args['posts_per_page'];
2264
+        $limit = (int) $query_args['posts_per_page'];
2265 2265
     }
2266 2266
 
2267 2267
     return $limit;
@@ -2404,9 +2404,9 @@  discard block
 block discarded – undo
2404 2404
         add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
2405 2405
     }
2406 2406
     $home_url = str_replace("www.", "", $home_url);
2407
-    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')) ) {
2407
+    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'))) {
2408 2408
         return true;
2409
-    }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')){
2409
+    }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')) {
2410 2410
         return true;
2411 2411
     } else {
2412 2412
         return false;
@@ -2489,19 +2489,19 @@  discard block
 block discarded – undo
2489 2489
 
2490 2490
     $gd_post_type = geodir_get_current_posttype();
2491 2491
 
2492
-    $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15;
2493
-    if(!empty($gd_post_type)){
2492
+    $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int) $instance['category_limit'] : 15;
2493
+    if (!empty($gd_post_type)) {
2494 2494
         $default_post_type = $gd_post_type;
2495
-    }elseif(isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ){
2495
+    }elseif (isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type'])) {
2496 2496
         $default_post_type = $instance['default_post_type'];
2497
-    }else{
2497
+    } else {
2498 2498
         $all_gd_post_type = geodir_get_posttypes();
2499 2499
         $default_post_type = (isset($all_gd_post_type[0])) ? $all_gd_post_type[0] : '';
2500 2500
     }
2501 2501
 
2502 2502
     $taxonomy = array();
2503 2503
     if (!empty($gd_post_type)) {
2504
-        $taxonomy[] = $gd_post_type . "category";
2504
+        $taxonomy[] = $gd_post_type."category";
2505 2505
     } else {
2506 2506
         $taxonomy = geodir_get_taxonomies($gd_post_type);
2507 2507
     }
@@ -2521,7 +2521,7 @@  discard block
 block discarded – undo
2521 2521
             $b_terms[$b_key] = geodir_sort_terms($b_val, 'count');
2522 2522
         }
2523 2523
 
2524
-        $default_taxonomy = $default_post_type != '' && isset($b_terms[$default_post_type . 'category']) ? $default_post_type . 'category' : '';
2524
+        $default_taxonomy = $default_post_type != '' && isset($b_terms[$default_post_type.'category']) ? $default_post_type.'category' : '';
2525 2525
 
2526 2526
         $tax_change_output = '';
2527 2527
         if (count($b_terms) > 1) {
@@ -2529,20 +2529,20 @@  discard block
 block discarded – undo
2529 2529
             foreach ($b_terms as $key => $val) {
2530 2530
                 $ptype = get_post_type_object(str_replace("category", "", $key));
2531 2531
                 $cpt_name = __($ptype->labels->singular_name, 'geodirectory');
2532
-                $tax_change_output .= "<option value='$key' ". selected($key, $default_taxonomy, false) .">" . sprintf(__('%s Categories', 'geodirectory'),$cpt_name) . "</option>";
2532
+                $tax_change_output .= "<option value='$key' ".selected($key, $default_taxonomy, false).">".sprintf(__('%s Categories', 'geodirectory'), $cpt_name)."</option>";
2533 2533
             }
2534 2534
             $tax_change_output .= "</select>";
2535 2535
         }
2536 2536
 
2537 2537
         if (!empty($b_terms)) {
2538
-            $terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms);// get the first array
2539
-            global $cat_count;//make global so we can change via function
2538
+            $terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms); // get the first array
2539
+            global $cat_count; //make global so we can change via function
2540 2540
             $cat_count = 0;
2541 2541
             ?>
2542 2542
             <div class="geodir-category-list-in clearfix">
2543 2543
                 <div class="geodir-cat-list clearfix">
2544 2544
                     <?php
2545
-                    echo $before_title . __($title) . $after_title;
2545
+                    echo $before_title.__($title).$after_title;
2546 2546
 
2547 2547
                     echo $tax_change_output;
2548 2548
 
@@ -2559,8 +2559,8 @@  discard block
 block discarded – undo
2559 2559
                     $hide = 'style="display:none;"';
2560 2560
                 }
2561 2561
                 echo "<div class='geodir-cat-list-more' $hide >";
2562
-                echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">' . __('More Categories', 'geodirectory') . '</a>';
2563
-                echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">' . __('Less Categories', 'geodirectory') . '</a>';
2562
+                echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">'.__('More Categories', 'geodirectory').'</a>';
2563
+                echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">'.__('Less Categories', 'geodirectory').'</a>';
2564 2564
                 echo "</div>";
2565 2565
                 /* add scripts */
2566 2566
                 add_action('wp_footer', 'geodir_popular_category_add_scripts', 100);
@@ -2600,7 +2600,7 @@  discard block
 block discarded – undo
2600 2600
         $class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show';
2601 2601
         $total_post = $cat->count;
2602 2602
 
2603
-        $term_link = get_term_link( $cat, $cat->taxonomy );
2603
+        $term_link = get_term_link($cat, $cat->taxonomy);
2604 2604
         /**
2605 2605
          * Filer the category term link.
2606 2606
          *
@@ -2609,10 +2609,10 @@  discard block
 block discarded – undo
2609 2609
          * @param int    $cat->term_id The term id.
2610 2610
          * @param string $post_type Wordpress post type.
2611 2611
          */
2612
-        $term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type );
2612
+        $term_link = apply_filters('geodir_category_term_link', $term_link, $cat->term_id, $post_type);
2613 2613
 
2614
-        echo '<li class="' . $class_row . '"><a href="' . $term_link . '">';
2615
-        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> ';
2614
+        echo '<li class="'.$class_row.'"><a href="'.$term_link.'">';
2615
+        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> ';
2616 2616
         echo '</a></li>';
2617 2617
     }
2618 2618
 }
@@ -2743,29 +2743,29 @@  discard block
 block discarded – undo
2743 2743
                 itemWidth: 75,
2744 2744
                 itemMargin: 5,
2745 2745
                 asNavFor: '#geodir_widget_slider',
2746
-                rtl: <?php echo ( is_rtl() ? 'true' : 'false' ); /* fix rtl issue */ ?>
2746
+                rtl: <?php echo (is_rtl() ? 'true' : 'false'); /* fix rtl issue */ ?>
2747 2747
             });
2748 2748
 
2749 2749
             jQuery('#geodir_widget_slider').flexslider({
2750
-                animation: "<?php echo $animation;?>",
2750
+                animation: "<?php echo $animation; ?>",
2751 2751
                 selector: ".geodir-slides > li",
2752 2752
                 namespace: "geodir-",
2753 2753
                 controlNav: true,
2754
-                animationLoop: <?php echo $animationLoop;?>,
2755
-                slideshow: <?php echo $slideshow;?>,
2756
-                slideshowSpeed: <?php echo $slideshowSpeed;?>,
2757
-                animationSpeed: <?php echo $animationSpeed;?>,
2758
-                directionNav: <?php echo $directionNav;?>,
2759
-                maxItems: <?php echo $max_show;?>,
2754
+                animationLoop: <?php echo $animationLoop; ?>,
2755
+                slideshow: <?php echo $slideshow; ?>,
2756
+                slideshowSpeed: <?php echo $slideshowSpeed; ?>,
2757
+                animationSpeed: <?php echo $animationSpeed; ?>,
2758
+                directionNav: <?php echo $directionNav; ?>,
2759
+                maxItems: <?php echo $max_show; ?>,
2760 2760
                 move: 1,
2761
-                <?php if($slide_width){ echo "itemWidth: ".$slide_width.",";}?>
2761
+                <?php if ($slide_width) { echo "itemWidth: ".$slide_width.","; }?>
2762 2762
                 sync: "#geodir_widget_carousel",
2763 2763
                 start: function (slider) {
2764 2764
                     jQuery('.geodir-listing-flex-loader').hide();
2765 2765
                     jQuery('#geodir_widget_slider').css({'visibility': 'visible'});
2766 2766
                     jQuery('#geodir_widget_carousel').css({'visibility': 'visible'});
2767 2767
                 },
2768
-                rtl: <?php echo ( is_rtl() ? 'true' : 'false' ); /* fix rtl issue */ ?>
2768
+                rtl: <?php echo (is_rtl() ? 'true' : 'false'); /* fix rtl issue */ ?>
2769 2769
             });
2770 2770
         });
2771 2771
     </script>
@@ -2801,12 +2801,12 @@  discard block
 block discarded – undo
2801 2801
     $widget_listings = geodir_get_widget_listings($query_args);
2802 2802
     if (!empty($widget_listings) || (isset($with_no_results) && $with_no_results)) {
2803 2803
         if ($title) {
2804
-            echo $before_title . $title . $after_title;
2804
+            echo $before_title.$title.$after_title;
2805 2805
         }
2806 2806
 
2807 2807
         global $post;
2808 2808
 
2809
-        $current_post = $post;// keep current post info
2809
+        $current_post = $post; // keep current post info
2810 2810
 
2811 2811
         $widget_main_slides = '';
2812 2812
         $nav_slides = '';
@@ -2824,11 +2824,11 @@  discard block
 block discarded – undo
2824 2824
                     $widget_spacer_height = ((200 - $widget_image->height) / 2);
2825 2825
                 }
2826 2826
 
2827
-                $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" />';
2827
+                $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" />';
2828 2828
 
2829 2829
                 $title = '';
2830 2830
                 if ($show_title) {
2831
-                    $title_html = '<div class="geodir-slider-title"><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a></div>';
2831
+                    $title_html = '<div class="geodir-slider-title"><a href="'.get_permalink($post->ID).'">'.get_the_title($post->ID).'</a></div>';
2832 2832
                     $post_id = $post->ID;
2833 2833
                     $post_permalink = get_permalink($post->ID);
2834 2834
                     $post_title = get_the_title($post->ID);
@@ -2841,11 +2841,11 @@  discard block
 block discarded – undo
2841 2841
                      * @param string $post_permalink The post permalink url.
2842 2842
                      * @param string $post_title The post title text.
2843 2843
                      */
2844
-                    $title = apply_filters('geodir_listing_slider_title',$title_html,$post_id,$post_permalink,$post_title);
2844
+                    $title = apply_filters('geodir_listing_slider_title', $title_html, $post_id, $post_permalink, $post_title);
2845 2845
                 }
2846 2846
 
2847
-                $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>';
2848
-                $nav_slides .= '<li><img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:48px;margin:0 auto;" /></li>';
2847
+                $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>';
2848
+                $nav_slides .= '<li><img src="'.$widget_image->src.'" alt="'.$widget_image->title.'" title="'.$widget_image->title.'" style="max-height:48px;margin:0 auto;" /></li>';
2849 2849
                 $widget_slides++;
2850 2850
             }
2851 2851
         }
@@ -2889,7 +2889,7 @@  discard block
 block discarded – undo
2889 2889
     $title = empty($instance['title']) ? __('My Dashboard', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2890 2890
 
2891 2891
     echo $before_widget;
2892
-    echo $before_title . $title . $after_title;
2892
+    echo $before_title.$title.$after_title;
2893 2893
 
2894 2894
     if (is_user_logged_in()) {
2895 2895
         global $current_user;
@@ -2931,7 +2931,7 @@  discard block
 block discarded – undo
2931 2931
                          */
2932 2932
                         $add_link = apply_filters('geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID);
2933 2933
 
2934
-                        $addlisting_links .= '<option ' . $selected . ' value="' . $add_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2934
+                        $addlisting_links .= '<option '.$selected.' value="'.$add_link.'">'.__(ucfirst($name), 'geodirectory').'</option>';
2935 2935
 
2936 2936
                     }
2937 2937
                 }
@@ -2977,7 +2977,7 @@  discard block
 block discarded – undo
2977 2977
                      */
2978 2978
                     $post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID);
2979 2979
 
2980
-                    $favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2980
+                    $favourite_links .= '<option '.$selected.' value="'.$post_type_link.'">'.__(ucfirst($name), 'geodirectory').'</option>';
2981 2981
                 }
2982 2982
             }
2983 2983
 
@@ -3022,7 +3022,7 @@  discard block
 block discarded – undo
3022 3022
                      */
3023 3023
                     $listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID);
3024 3024
 
3025
-                    $listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
3025
+                    $listing_links .= '<option '.$selected.' value="'.$listing_link.'">'.__(ucfirst($name), 'geodirectory').'</option>';
3026 3026
                 }
3027 3027
             }
3028 3028
 
@@ -3205,7 +3205,7 @@  discard block
 block discarded – undo
3205 3205
     }
3206 3206
 
3207 3207
     if (empty($title) || $title == 'All') {
3208
-        $title .= ' ' . __(get_post_type_plural_label($post_type), 'geodirectory');
3208
+        $title .= ' '.__(get_post_type_plural_label($post_type), 'geodirectory');
3209 3209
     }
3210 3210
 
3211 3211
     $location_url = array();
@@ -3259,7 +3259,7 @@  discard block
 block discarded – undo
3259 3259
             $geodir_add_location_url = '1';
3260 3260
         }
3261 3261
 
3262
-        $viewall_url = get_term_link((int)$category[0], $post_type . 'category');
3262
+        $viewall_url = get_term_link((int) $category[0], $post_type.'category');
3263 3263
 
3264 3264
         $geodir_add_location_url = NULL;
3265 3265
     }
@@ -3267,7 +3267,7 @@  discard block
 block discarded – undo
3267 3267
         $gd_session->set('gd_multi_location', 1);
3268 3268
     }
3269 3269
 
3270
-    if(is_wp_error( $viewall_url  )){$viewall_url = '';}
3270
+    if (is_wp_error($viewall_url)) {$viewall_url = ''; }
3271 3271
 
3272 3272
     $query_args = array(
3273 3273
         'posts_per_page' => $post_number,
@@ -3333,7 +3333,7 @@  discard block
 block discarded – undo
3333 3333
              */
3334 3334
             do_action('geodir_before_view_all_link_in_widget'); ?>
3335 3335
             <div class="geodir_list_heading clearfix">
3336
-                <?php echo $before_title . $title . $after_title; ?>
3336
+                <?php echo $before_title.$title.$after_title; ?>
3337 3337
                 <a href="<?php echo $viewall_url; ?>"
3338 3338
                    class="geodir-viewall"><?php _e('View all', 'geodirectory'); ?></a>
3339 3339
             </div>
@@ -3419,9 +3419,9 @@  discard block
 block discarded – undo
3419 3419
 {
3420 3420
     global $wpdb, $plugin_prefix;
3421 3421
 
3422
-    $detail_table = $plugin_prefix . $post_type . '_detail';
3422
+    $detail_table = $plugin_prefix.$post_type.'_detail';
3423 3423
 
3424
-    $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 . ")";
3424
+    $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.")";
3425 3425
 
3426 3426
     /**
3427 3427
      * Filter count review sql query.
@@ -3460,7 +3460,7 @@  discard block
 block discarded – undo
3460 3460
      * @param bool $force_update Force update option value?. Default.false.
3461 3461
      * @param int $post_ID The post id to update if any.
3462 3462
      */
3463
-    $option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update,$post_ID);
3463
+    $option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update, $post_ID);
3464 3464
     if (!empty($option_data)) {
3465 3465
         return $option_data;
3466 3466
     }
@@ -3468,11 +3468,11 @@  discard block
 block discarded – undo
3468 3468
     $option_data = get_option('geodir_global_review_count');
3469 3469
 
3470 3470
     if (!$option_data || $force_update) {
3471
-        if ((int)$post_ID > 0) { // Update reviews count for specific post categories only.
3471
+        if ((int) $post_ID > 0) { // Update reviews count for specific post categories only.
3472 3472
             global $gd_session;
3473
-            $term_array = (array)$option_data;
3473
+            $term_array = (array) $option_data;
3474 3474
             $post_type = get_post_type($post_ID);
3475
-            $taxonomy = $post_type . 'category';
3475
+            $taxonomy = $post_type.'category';
3476 3476
             $terms = wp_get_object_terms($post_ID, $taxonomy, array('fields' => 'ids'));
3477 3477
 
3478 3478
             if (!empty($terms) && !is_wp_error($terms)) {
@@ -3487,9 +3487,9 @@  discard block
 block discarded – undo
3487 3487
             
3488 3488
             $terms = array();
3489 3489
             if (isset($_POST['post_category'][$taxonomy])) {
3490
-                $terms = (array)$_POST['post_category'][$taxonomy];
3490
+                $terms = (array) $_POST['post_category'][$taxonomy];
3491 3491
             } else if (!empty($session_listing) && isset($session_listing['post_category'][$taxonomy])) {
3492
-                $terms = (array)$session_listing['post_category'][$taxonomy];
3492
+                $terms = (array) $session_listing['post_category'][$taxonomy];
3493 3493
             }
3494 3494
             
3495 3495
             if (!empty($terms)) {
@@ -3577,7 +3577,7 @@  discard block
 block discarded – undo
3577 3577
     return true;
3578 3578
 }
3579 3579
 
3580
-function geodir_term_review_count_force_update_single_post($post_id){
3580
+function geodir_term_review_count_force_update_single_post($post_id) {
3581 3581
     geodir_count_reviews_by_terms(true, $post_id); 
3582 3582
 }
3583 3583
 
@@ -3714,17 +3714,17 @@  discard block
 block discarded – undo
3714 3714
      */
3715 3715
     $locale = apply_filters('plugin_locale', get_locale(), 'geodirectory');
3716 3716
 
3717
-    load_textdomain('geodirectory', WP_LANG_DIR . '/' . 'geodirectory' . '/' . 'geodirectory' . '-' . $locale . '.mo');
3718
-    load_plugin_textdomain('geodirectory', false, plugin_basename(dirname(dirname(__FILE__))) . '/geodirectory-languages');
3717
+    load_textdomain('geodirectory', WP_LANG_DIR.'/'.'geodirectory'.'/'.'geodirectory'.'-'.$locale.'.mo');
3718
+    load_plugin_textdomain('geodirectory', false, plugin_basename(dirname(dirname(__FILE__))).'/geodirectory-languages');
3719 3719
 
3720 3720
     /**
3721 3721
      * Define language constants.
3722 3722
      *
3723 3723
      * @since 1.0.0
3724 3724
      */
3725
-    require_once(geodir_plugin_path() . '/language.php');
3725
+    require_once(geodir_plugin_path().'/language.php');
3726 3726
 
3727
-    $language_file = geodir_plugin_path() . '/db-language.php';
3727
+    $language_file = geodir_plugin_path().'/db-language.php';
3728 3728
 
3729 3729
     // Load language string file if not created yet
3730 3730
     if (!file_exists($language_file)) {
@@ -3739,8 +3739,8 @@  discard block
 block discarded – undo
3739 3739
          */
3740 3740
         try {
3741 3741
             require_once($language_file);
3742
-        } catch(Exception $e) {
3743
-            error_log('Language Error: ' . $e->getMessage());
3742
+        } catch (Exception $e) {
3743
+            error_log('Language Error: '.$e->getMessage());
3744 3744
         }
3745 3745
     }
3746 3746
 }
@@ -3757,18 +3757,18 @@  discard block
 block discarded – undo
3757 3757
  */
3758 3758
 function geodirectory_load_db_language() {
3759 3759
     global $wp_filesystem;
3760
-    if( empty( $wp_filesystem ) ) {
3761
-        require_once( ABSPATH .'/wp-admin/includes/file.php' );
3760
+    if (empty($wp_filesystem)) {
3761
+        require_once(ABSPATH.'/wp-admin/includes/file.php');
3762 3762
         WP_Filesystem();
3763 3763
         global $wp_filesystem;
3764 3764
     }
3765 3765
 
3766
-    $language_file = geodir_plugin_path() . '/db-language.php';
3766
+    $language_file = geodir_plugin_path().'/db-language.php';
3767 3767
 
3768
-    if(is_file($language_file) && !is_writable($language_file))
3768
+    if (is_file($language_file) && !is_writable($language_file))
3769 3769
         return false; // Not possible to create.
3770 3770
 
3771
-    if(!is_file($language_file) && !is_writable(dirname($language_file)))
3771
+    if (!is_file($language_file) && !is_writable(dirname($language_file)))
3772 3772
         return false; // Not possible to create.
3773 3773
 
3774 3774
     $contents_strings = array();
@@ -3802,17 +3802,17 @@  discard block
 block discarded – undo
3802 3802
     $contents = implode(PHP_EOL, $contents_head);
3803 3803
 
3804 3804
     if (!empty($contents_strings)) {
3805
-        foreach ( $contents_strings as $string ) {
3805
+        foreach ($contents_strings as $string) {
3806 3806
             if (is_scalar($string) && $string != '') {
3807 3807
                 $string = str_replace("'", "\'", $string);
3808
-                $contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
3808
+                $contents .= PHP_EOL."__('".$string."', 'geodirectory');";
3809 3809
             }
3810 3810
         }
3811 3811
     }
3812 3812
 
3813 3813
     $contents .= implode(PHP_EOL, $contents_foot);
3814 3814
 
3815
-    if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE))
3815
+    if ($wp_filesystem->put_contents($language_file, $contents, FS_CHMOD_FILE))
3816 3816
         return false; // Failure; could not write file.
3817 3817
 
3818 3818
     return true;
@@ -3834,11 +3834,11 @@  discard block
 block discarded – undo
3834 3834
     global $wpdb;
3835 3835
 
3836 3836
     // Custom fields table
3837
-    $sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM " . GEODIR_CUSTOM_FIELDS_TABLE;
3837
+    $sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM ".GEODIR_CUSTOM_FIELDS_TABLE;
3838 3838
     $rows = $wpdb->get_results($sql);
3839 3839
 
3840 3840
     if (!empty($rows)) {
3841
-        foreach($rows as $row) {
3841
+        foreach ($rows as $row) {
3842 3842
             if (!empty($row->admin_title))
3843 3843
                 $translation_texts[] = stripslashes_deep($row->admin_title);
3844 3844
 			
@@ -3872,11 +3872,11 @@  discard block
 block discarded – undo
3872 3872
     }
3873 3873
 	
3874 3874
     // Custom sorting fields table
3875
-    $sql = "SELECT site_title, asc_title, desc_title FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE;
3875
+    $sql = "SELECT site_title, asc_title, desc_title FROM ".GEODIR_CUSTOM_SORT_FIELDS_TABLE;
3876 3876
     $rows = $wpdb->get_results($sql);
3877 3877
 
3878 3878
     if (!empty($rows)) {
3879
-        foreach($rows as $row) {
3879
+        foreach ($rows as $row) {
3880 3880
             if (!empty($row->site_title))
3881 3881
                 $translation_texts[] = stripslashes_deep($row->site_title);
3882 3882
 
@@ -3890,11 +3890,11 @@  discard block
 block discarded – undo
3890 3890
 	
3891 3891
 	// Advance search filter fields table
3892 3892
 	if (defined('GEODIR_ADVANCE_SEARCH_TABLE')) {
3893
-		$sql = "SELECT field_site_name, front_search_title, field_desc FROM " . GEODIR_ADVANCE_SEARCH_TABLE;
3893
+		$sql = "SELECT field_site_name, front_search_title, field_desc FROM ".GEODIR_ADVANCE_SEARCH_TABLE;
3894 3894
 		$rows = $wpdb->get_results($sql);
3895 3895
 
3896 3896
 		if (!empty($rows)) {
3897
-			foreach($rows as $row) {
3897
+			foreach ($rows as $row) {
3898 3898
 				if (!empty($row->field_site_name))
3899 3899
 					$translation_texts[] = stripslashes_deep($row->field_site_name);
3900 3900
 
@@ -3929,7 +3929,7 @@  discard block
 block discarded – undo
3929 3929
      *
3930 3930
      * @param array $geodir_allowed_mime_types and file extensions.
3931 3931
      */
3932
-    return apply_filters( 'geodir_allowed_mime_types', array(
3932
+    return apply_filters('geodir_allowed_mime_types', array(
3933 3933
             'Image' => array( // Image formats.
3934 3934
                 'jpg' => 'image/jpeg',
3935 3935
                 'jpe' => 'image/jpeg',
@@ -4018,13 +4018,13 @@  discard block
 block discarded – undo
4018 4018
 
4019 4019
 
4020 4020
 
4021
-add_filter('wpseo_replacements','geodir_wpseo_replacements',10,1);
4021
+add_filter('wpseo_replacements', 'geodir_wpseo_replacements', 10, 1);
4022 4022
 /*
4023 4023
  * Add location variables to wpseo replacements.
4024 4024
  *
4025 4025
  * @since 1.5.4
4026 4026
  */
4027
-function geodir_wpseo_replacements($vars){
4027
+function geodir_wpseo_replacements($vars) {
4028 4028
 
4029 4029
     global $wp;
4030 4030
     $title = '';
@@ -4039,12 +4039,12 @@  discard block
 block discarded – undo
4039 4039
      * @param array $location_array The array of location variables.
4040 4040
      * @param array $vars The page title variables.
4041 4041
      */
4042
-    $location_array = apply_filters('geodir_filter_title_variables_location_arr_seo',$location_array, $vars);
4042
+    $location_array = apply_filters('geodir_filter_title_variables_location_arr_seo', $location_array, $vars);
4043 4043
     $location_titles = array();
4044
-    if(get_query_var( 'gd_country_full' )){
4045
-        if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4046
-        if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4047
-        if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4044
+    if (get_query_var('gd_country_full')) {
4045
+        if (get_query_var('gd_country_full')) {$location_array['gd_country'] = get_query_var('gd_country_full'); }
4046
+        if (get_query_var('gd_region_full')) {$location_array['gd_region'] = get_query_var('gd_region_full'); }
4047
+        if (get_query_var('gd_city_full')) {$location_array['gd_city'] = get_query_var('gd_city_full'); }
4048 4048
     }
4049 4049
     $location_single = '';
4050 4050
     $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
@@ -4116,23 +4116,23 @@  discard block
 block discarded – undo
4116 4116
     }
4117 4117
 
4118 4118
 
4119
-    if(!empty($location_titles)) {
4119
+    if (!empty($location_titles)) {
4120 4120
         $vars['%%location%%'] = implode(", ", $location_titles);
4121 4121
     }
4122 4122
 
4123 4123
 
4124
-    if(!empty($location_titles)) {
4125
-        $vars['%%in_location%%'] = __('in ', 'geodirectory') . implode(", ", $location_titles);
4124
+    if (!empty($location_titles)) {
4125
+        $vars['%%in_location%%'] = __('in ', 'geodirectory').implode(", ", $location_titles);
4126 4126
     }
4127 4127
 
4128 4128
 
4129 4129
 
4130
-    if($location_single) {
4131
-        $vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' .$location_single;
4130
+    if ($location_single) {
4131
+        $vars['%%in_location_single%%'] = __('in', 'geodirectory').' '.$location_single;
4132 4132
     }
4133 4133
 
4134 4134
 
4135
-    if($location_single) {
4135
+    if ($location_single) {
4136 4136
         $vars['%%location_single%%'] = $location_single;
4137 4137
     }
4138 4138
 
@@ -4144,17 +4144,17 @@  discard block
 block discarded – undo
4144 4144
      * @param string $vars The title with variables.
4145 4145
      * @param array $location_array The array of location variables.
4146 4146
      */
4147
-    return apply_filters('geodir_wpseo_replacements_vars',$vars,$location_array);
4147
+    return apply_filters('geodir_wpseo_replacements_vars', $vars, $location_array);
4148 4148
 }
4149 4149
 
4150 4150
 
4151
-add_filter('geodir_seo_meta_title','geodir_filter_title_variables',10,3);
4152
-add_filter('geodir_seo_page_title','geodir_filter_title_variables',10,2);
4153
-add_filter('geodir_seo_meta_description_pre','geodir_filter_title_variables',10,3);
4154
-function geodir_filter_title_variables($title, $gd_page, $sep=''){
4151
+add_filter('geodir_seo_meta_title', 'geodir_filter_title_variables', 10, 3);
4152
+add_filter('geodir_seo_page_title', 'geodir_filter_title_variables', 10, 2);
4153
+add_filter('geodir_seo_meta_description_pre', 'geodir_filter_title_variables', 10, 3);
4154
+function geodir_filter_title_variables($title, $gd_page, $sep = '') {
4155 4155
 
4156 4156
 
4157
-    if(!$gd_page || !$title){return $title;}// if no a GD page then bail.
4157
+    if (!$gd_page || !$title) {return $title; }// if no a GD page then bail.
4158 4158
     global $post;
4159 4159
     //print_r($post);
4160 4160
     /*
@@ -4196,123 +4196,123 @@  discard block
 block discarded – undo
4196 4196
     }
4197 4197
 
4198 4198
 
4199
-    if(strpos($title,'%%title%%') !== false){
4200
-        $title = str_replace("%%title%%",$post->post_title,$title);
4199
+    if (strpos($title, '%%title%%') !== false) {
4200
+        $title = str_replace("%%title%%", $post->post_title, $title);
4201 4201
     }
4202 4202
 
4203
-    if(strpos($title,'%%sitename%%') !== false){
4204
-        $title = str_replace("%%sitename%%",get_bloginfo('name'),$title);
4203
+    if (strpos($title, '%%sitename%%') !== false) {
4204
+        $title = str_replace("%%sitename%%", get_bloginfo('name'), $title);
4205 4205
     }
4206 4206
 
4207
-    if(strpos($title,'%%sitedesc%%') !== false){
4208
-        $title = str_replace("%%sitedesc%%",get_bloginfo('description'),$title);
4207
+    if (strpos($title, '%%sitedesc%%') !== false) {
4208
+        $title = str_replace("%%sitedesc%%", get_bloginfo('description'), $title);
4209 4209
     }
4210 4210
 
4211
-    if(strpos($title,'%%excerpt%%') !== false){
4212
-        $title = str_replace("%%excerpt%%",strip_tags(get_the_excerpt()),$title);
4211
+    if (strpos($title, '%%excerpt%%') !== false) {
4212
+        $title = str_replace("%%excerpt%%", strip_tags(get_the_excerpt()), $title);
4213 4213
     }
4214 4214
 
4215
-    if(strpos($title,'%%pt_single%%') !== false){
4215
+    if (strpos($title, '%%pt_single%%') !== false) {
4216 4216
         $single_name = '';
4217
-        if($gd_page=='search' || $gd_page=='author'){
4217
+        if ($gd_page == 'search' || $gd_page == 'author') {
4218 4218
             $geodir_post_types = get_option('geodir_post_types');
4219 4219
             $spt = esc_attr($_REQUEST['stype']);
4220
-            if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
4221
-                $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
4220
+            if (isset($geodir_post_types[$spt]['labels']['singular_name'])) {
4221
+                $single_name = __($geodir_post_types[$spt]['labels']['singular_name'], 'geodirectory');
4222 4222
             }
4223
-        }elseif($gd_page=='add-listing'){
4223
+        }elseif ($gd_page == 'add-listing') {
4224 4224
             $geodir_post_types = get_option('geodir_post_types');
4225 4225
             $spt = isset($_REQUEST['listing_type']) ? esc_attr($_REQUEST['listing_type']) : '';
4226
-            if(!$spt && isset($_REQUEST['pid'])){
4227
-                $spt = get_post_type( $_REQUEST['pid'] );
4226
+            if (!$spt && isset($_REQUEST['pid'])) {
4227
+                $spt = get_post_type($_REQUEST['pid']);
4228 4228
             }
4229
-            if(!$spt){$spt='gd_place';}
4230
-            if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
4231
-                $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
4229
+            if (!$spt) {$spt = 'gd_place'; }
4230
+            if (isset($geodir_post_types[$spt]['labels']['singular_name'])) {
4231
+                $single_name = __($geodir_post_types[$spt]['labels']['singular_name'], 'geodirectory');
4232 4232
             }
4233 4233
         }
4234
-        elseif($post->post_type){
4234
+        elseif ($post->post_type) {
4235 4235
             $geodir_post_types = get_option('geodir_post_types');
4236
-            if(isset($geodir_post_types[$post->post_type]['labels']['singular_name'])){
4237
-                $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'],'geodirectory');
4236
+            if (isset($geodir_post_types[$post->post_type]['labels']['singular_name'])) {
4237
+                $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'], 'geodirectory');
4238 4238
             }
4239 4239
 
4240 4240
 
4241 4241
         }
4242
-        $title = str_replace("%%pt_single%%",$single_name,$title);
4242
+        $title = str_replace("%%pt_single%%", $single_name, $title);
4243 4243
     }
4244 4244
 
4245
-    if(strpos($title,'%%pt_plural%%') !== false){
4245
+    if (strpos($title, '%%pt_plural%%') !== false) {
4246 4246
         $plural_name = '';
4247
-        if($gd_page=='search' || $gd_page=='author'){
4247
+        if ($gd_page == 'search' || $gd_page == 'author') {
4248 4248
             $geodir_post_types = get_option('geodir_post_types');
4249 4249
             $spt = esc_attr($_REQUEST['stype']);
4250
-            if(isset($geodir_post_types[$spt]['labels']['name'])){
4251
-                $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4250
+            if (isset($geodir_post_types[$spt]['labels']['name'])) {
4251
+                $plural_name = __($geodir_post_types[$spt]['labels']['name'], 'geodirectory');
4252 4252
             }
4253
-        }elseif($gd_page=='add-listing'){
4253
+        }elseif ($gd_page == 'add-listing') {
4254 4254
             $geodir_post_types = get_option('geodir_post_types');
4255 4255
             $spt = sanitize_text_field($_REQUEST['listing_type']);
4256
-            if(!$spt){$spt='gd_place';}
4257
-            if(isset($geodir_post_types[$spt]['labels']['name'])){
4258
-                $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4256
+            if (!$spt) {$spt = 'gd_place'; }
4257
+            if (isset($geodir_post_types[$spt]['labels']['name'])) {
4258
+                $plural_name = __($geodir_post_types[$spt]['labels']['name'], 'geodirectory');
4259 4259
             }
4260 4260
         }
4261
-        elseif(isset($post->post_type) && $post->post_type){
4261
+        elseif (isset($post->post_type) && $post->post_type) {
4262 4262
             $geodir_post_types = get_option('geodir_post_types');
4263
-            if(isset($geodir_post_types[$post->post_type]['labels']['name'])){
4264
-                $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'],'geodirectory');
4263
+            if (isset($geodir_post_types[$post->post_type]['labels']['name'])) {
4264
+                $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'], 'geodirectory');
4265 4265
             }
4266 4266
 
4267 4267
         }
4268
-        $title = str_replace("%%pt_plural%%",$plural_name,$title);
4268
+        $title = str_replace("%%pt_plural%%", $plural_name, $title);
4269 4269
     }
4270 4270
 
4271 4271
 
4272 4272
 
4273
-    if(strpos($title,'%%category%%') !== false){
4273
+    if (strpos($title, '%%category%%') !== false) {
4274 4274
         $cat_name = '';
4275 4275
 
4276
-        if($gd_page=='detail') {
4276
+        if ($gd_page == 'detail') {
4277 4277
             if ($post->default_category) {
4278
-                $cat = get_term($post->default_category, $post->post_type . 'category');
4278
+                $cat = get_term($post->default_category, $post->post_type.'category');
4279 4279
                 $cat_name = (isset($cat->name)) ? $cat->name : '';
4280 4280
             }
4281
-        }elseif($gd_page=='listing'){
4281
+        }elseif ($gd_page == 'listing') {
4282 4282
             $queried_object = get_queried_object();
4283
-            if(isset($queried_object->name)){
4283
+            if (isset($queried_object->name)) {
4284 4284
                 $cat_name = $queried_object->name;
4285 4285
             }
4286 4286
         }
4287
-        $title = str_replace("%%category%%",$cat_name,$title);
4287
+        $title = str_replace("%%category%%", $cat_name, $title);
4288 4288
     }
4289 4289
 
4290
-    if(strpos($title,'%%tag%%') !== false){
4290
+    if (strpos($title, '%%tag%%') !== false) {
4291 4291
         $cat_name = '';
4292 4292
 
4293
-        if($gd_page=='detail') {
4293
+        if ($gd_page == 'detail') {
4294 4294
             if ($post->default_category) {
4295
-                $cat = get_term($post->default_category, $post->post_type . 'category');
4295
+                $cat = get_term($post->default_category, $post->post_type.'category');
4296 4296
                 $cat_name = (isset($cat->name)) ? $cat->name : '';
4297 4297
             }
4298
-        }elseif($gd_page=='listing'){
4298
+        }elseif ($gd_page == 'listing') {
4299 4299
             $queried_object = get_queried_object();
4300
-            if(isset($queried_object->name)){
4300
+            if (isset($queried_object->name)) {
4301 4301
                 $cat_name = $queried_object->name;
4302 4302
             }
4303 4303
         }
4304
-        $title = str_replace("%%tag%%",$cat_name,$title);
4304
+        $title = str_replace("%%tag%%", $cat_name, $title);
4305 4305
     }
4306 4306
 
4307 4307
 
4308 4308
 
4309
-    if(strpos($title,'%%id%%') !== false){
4309
+    if (strpos($title, '%%id%%') !== false) {
4310 4310
         $ID = (isset($post->ID)) ? $post->ID : '';
4311
-        $title = str_replace("%%id%%",$ID,$title);
4311
+        $title = str_replace("%%id%%", $ID, $title);
4312 4312
     }
4313 4313
 
4314
-    if(strpos($title,'%%sep%%') !== false){
4315
-        $title = str_replace("%%sep%%",$sep,$title);
4314
+    if (strpos($title, '%%sep%%') !== false) {
4315
+        $title = str_replace("%%sep%%", $sep, $title);
4316 4316
     }
4317 4317
 
4318 4318
 
@@ -4330,12 +4330,12 @@  discard block
 block discarded – undo
4330 4330
      * @param string $gd_page The page being filtered.
4331 4331
      * @param string $sep The separator, default: `|`.
4332 4332
      */
4333
-    $location_array = apply_filters('geodir_filter_title_variables_location_arr',$location_array,$title, $gd_page, $sep);
4333
+    $location_array = apply_filters('geodir_filter_title_variables_location_arr', $location_array, $title, $gd_page, $sep);
4334 4334
     $location_titles = array();
4335
-    if($gd_page=='location' && get_query_var( 'gd_country_full' )){
4336
-        if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4337
-        if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4338
-        if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4335
+    if ($gd_page == 'location' && get_query_var('gd_country_full')) {
4336
+        if (get_query_var('gd_country_full')) {$location_array['gd_country'] = get_query_var('gd_country_full'); }
4337
+        if (get_query_var('gd_region_full')) {$location_array['gd_region'] = get_query_var('gd_region_full'); }
4338
+        if (get_query_var('gd_city_full')) {$location_array['gd_city'] = get_query_var('gd_city_full'); }
4339 4339
     }
4340 4340
     $location_single = '';
4341 4341
     $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
@@ -4407,51 +4407,51 @@  discard block
 block discarded – undo
4407 4407
     }
4408 4408
 
4409 4409
 
4410
-    if(strpos($title,'%%location%%') !== false){
4410
+    if (strpos($title, '%%location%%') !== false) {
4411 4411
         $location = '';
4412
-        if($location_titles) {
4412
+        if ($location_titles) {
4413 4413
             $location = implode(", ", $location_titles);
4414 4414
         }
4415
-        $title = str_replace("%%location%%",$location,$title);
4415
+        $title = str_replace("%%location%%", $location, $title);
4416 4416
     }
4417 4417
 
4418
-    if(strpos($title,'%%in_location%%') !== false){
4418
+    if (strpos($title, '%%in_location%%') !== false) {
4419 4419
         $location = '';
4420
-        if($location_titles) {
4421
-            $location = __('in ', 'geodirectory') . implode(", ", $location_titles);
4420
+        if ($location_titles) {
4421
+            $location = __('in ', 'geodirectory').implode(", ", $location_titles);
4422 4422
         }
4423
-        $title = str_replace("%%in_location%%",$location,$title);
4423
+        $title = str_replace("%%in_location%%", $location, $title);
4424 4424
     }
4425 4425
 
4426
-    if(strpos($title,'%%in_location_single%%') !== false){
4427
-        if($location_single) {
4428
-            $location_single = __('in', 'geodirectory') . ' ' .$location_single;
4426
+    if (strpos($title, '%%in_location_single%%') !== false) {
4427
+        if ($location_single) {
4428
+            $location_single = __('in', 'geodirectory').' '.$location_single;
4429 4429
         }
4430
-        $title = str_replace("%%in_location_single%%",$location_single,$title);
4430
+        $title = str_replace("%%in_location_single%%", $location_single, $title);
4431 4431
     }
4432 4432
 
4433
-    if(strpos($title,'%%location_single%%') !== false){
4434
-        $title = str_replace("%%location_single%%",$location_single,$title);
4433
+    if (strpos($title, '%%location_single%%') !== false) {
4434
+        $title = str_replace("%%location_single%%", $location_single, $title);
4435 4435
     }
4436 4436
 
4437 4437
 
4438
-    if(strpos($title,'%%search_term%%') !== false){
4438
+    if (strpos($title, '%%search_term%%') !== false) {
4439 4439
         $search_term = '';
4440
-        if(isset($_REQUEST['s'])){
4440
+        if (isset($_REQUEST['s'])) {
4441 4441
             $search_term = esc_attr($_REQUEST['s']);
4442 4442
         }
4443
-        $title = str_replace("%%search_term%%",$search_term,$title);
4443
+        $title = str_replace("%%search_term%%", $search_term, $title);
4444 4444
     }
4445 4445
 
4446
-    if(strpos($title,'%%search_near%%') !== false){
4446
+    if (strpos($title, '%%search_near%%') !== false) {
4447 4447
         $search_term = '';
4448
-        if(isset($_REQUEST['snear'])){
4448
+        if (isset($_REQUEST['snear'])) {
4449 4449
             $search_term = esc_attr($_REQUEST['snear']);
4450 4450
         }
4451
-        $title = str_replace("%%search_near%%",$search_term,$title);
4451
+        $title = str_replace("%%search_near%%", $search_term, $title);
4452 4452
     }
4453 4453
 
4454
-    if(strpos($title,'%%name%%') !== false){
4454
+    if (strpos($title, '%%name%%') !== false) {
4455 4455
         $author_name = get_the_author();
4456 4456
         if (!$author_name || $author_name === '') {
4457 4457
             $queried_object = get_queried_object();
@@ -4476,9 +4476,9 @@  discard block
 block discarded – undo
4476 4476
         $title = str_replace("%%pagetotal%%", $pagetotal, $title);
4477 4477
     }
4478 4478
 
4479
-    $title = wptexturize( $title );
4480
-    $title = convert_chars( $title );
4481
-    $title = esc_html( $title );
4479
+    $title = wptexturize($title);
4480
+    $title = convert_chars($title);
4481
+    $title = esc_html($title);
4482 4482
 
4483 4483
     /**
4484 4484
      * Filter the title variables after standard ones have been filtered.
@@ -4491,7 +4491,7 @@  discard block
 block discarded – undo
4491 4491
      * @param string $sep The separator, default: `|`.
4492 4492
      */
4493 4493
 
4494
-    return apply_filters('geodir_filter_title_variables_vars',$title,$location_array, $gd_page, $sep);
4494
+    return apply_filters('geodir_filter_title_variables_vars', $title, $location_array, $gd_page, $sep);
4495 4495
 }
4496 4496
 
4497 4497
 /**
@@ -4614,7 +4614,7 @@  discard block
 block discarded – undo
4614 4614
     }
4615 4615
     
4616 4616
     $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : '';
4617
-    $is_admin = is_admin() && ( !defined('DOING_AJAX' ) || ( defined('DOING_AJAX') && !DOING_AJAX ) )  ? true : false;
4617
+    $is_admin = is_admin() && (!defined('DOING_AJAX') || (defined('DOING_AJAX') && !DOING_AJAX)) ? true : false;
4618 4618
     $inline_save = $action == 'inline-save' ? true : false;
4619 4619
 
4620 4620
     if (empty($post->post_type) || $is_admin || $inline_save || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) {
@@ -4625,7 +4625,7 @@  discard block
 block discarded – undo
4625 4625
         return;
4626 4626
     }
4627 4627
 
4628
-    $user_id = (int)get_current_user_id();
4628
+    $user_id = (int) get_current_user_id();
4629 4629
         
4630 4630
     if ($user_id > 0 && get_option('geodir_notify_post_edited') && !wp_is_post_revision($post_ID) && in_array($post->post_type, geodir_get_posttypes())) {
4631 4631
         $author_id = !empty($post->post_author) ? $post->post_author : 0;
@@ -4669,7 +4669,7 @@  discard block
 block discarded – undo
4669 4669
     $nr  = geodir_title_meta_pagenumbering('nr');
4670 4670
 
4671 4671
     if ($max > 1 && $nr > 1) {
4672
-        $replacement = sprintf($sep . ' ' . __('Page %1$d of %2$d', 'geodirectory'), $nr, $max);
4672
+        $replacement = sprintf($sep.' '.__('Page %1$d of %2$d', 'geodirectory'), $nr, $max);
4673 4673
     }
4674 4674
 
4675 4675
     return $replacement;
@@ -4688,7 +4688,7 @@  discard block
 block discarded – undo
4688 4688
 
4689 4689
     $nr = geodir_title_meta_pagenumbering('nr');
4690 4690
     if (isset($nr) && $nr > 0) {
4691
-        $replacement = (string)$nr;
4691
+        $replacement = (string) $nr;
4692 4692
     }
4693 4693
 
4694 4694
     return $replacement;
@@ -4707,7 +4707,7 @@  discard block
 block discarded – undo
4707 4707
 
4708 4708
     $max = geodir_title_meta_pagenumbering('max');
4709 4709
     if (isset($max) && $max > 0) {
4710
-        $replacement = (string)$max;
4710
+        $replacement = (string) $max;
4711 4711
     }
4712 4712
 
4713 4713
     return $replacement;
@@ -4749,7 +4749,7 @@  discard block
 block discarded – undo
4749 4749
         }
4750 4750
 
4751 4751
         if (isset($post->post_content)) {
4752
-            $max_num_pages = (substr_count($post->post_content, '<!--nextpage-->' ) + 1);
4752
+            $max_num_pages = (substr_count($post->post_content, '<!--nextpage-->') + 1);
4753 4753
         }
4754 4754
     }
4755 4755
 
Please login to merge, or discard this patch.
Braces   +277 added lines, -194 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()) {
@@ -1281,12 +1320,14 @@  discard block
 block discarded – undo
1281 1320
     function geodir_allow_wpadmin()
1282 1321
     {
1283 1322
         global $wpdb;
1284
-        if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) // checking action in request to allow ajax request go through
1323
+        if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) {
1324
+        	// checking action in request to allow ajax request go through
1285 1325
         {
1286 1326
             if (current_user_can('manage_options')) {
1287 1327
             } else {
1288 1328
 
1289
-                wp_redirect(home_url());
1329
+                wp_redirect(home_url());
1330
+        }
1290 1331
                 exit;
1291 1332
             }
1292 1333
 
@@ -1334,8 +1375,9 @@  discard block
 block discarded – undo
1334 1375
     $post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : '';
1335 1376
 
1336 1377
     $upload = wp_upload_bits($file_name, 0, '', $post_upload_date);
1337
-    if ($upload['error'])
1338
-        return new WP_Error('upload_dir_error', $upload['error']);
1378
+    if ($upload['error']) {
1379
+            return new WP_Error('upload_dir_error', $upload['error']);
1380
+    }
1339 1381
 
1340 1382
     // fetch the remote url and write it to the placeholder file
1341 1383
     $headers = wp_remote_get($url, array('stream' => true,'filename' => $upload['file']));
@@ -1349,11 +1391,9 @@  discard block
 block discarded – undo
1349 1391
     // make sure the fetch was successful
1350 1392
     elseif ($headers['response']['code'] != '200') {
1351 1393
         $log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
1352
-    }
1353
-    elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
1394
+    } elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
1354 1395
         $log_message =  __('Remote file is incorrect size', 'geodirectory');
1355
-    }
1356
-    elseif (0 == $filesize) {
1396
+    } elseif (0 == $filesize) {
1357 1397
         $log_message = __('Zero size file downloaded', 'geodirectory');
1358 1398
     }
1359 1399
 
@@ -1365,10 +1405,11 @@  discard block
 block discarded – undo
1365 1405
 
1366 1406
     if ($dummy && $add_to_cache && is_array($upload)) {
1367 1407
         $images = get_transient('cached_dummy_images');
1368
-        if(is_array($images))
1369
-            $images[$key] = $upload;
1370
-        else
1371
-            $images = array($key => $upload);
1408
+        if(is_array($images)) {
1409
+                    $images[$key] = $upload;
1410
+        } else {
1411
+                    $images = array($key => $upload);
1412
+        }
1372 1413
 
1373 1414
         //setting the cache using the WP Transient API
1374 1415
         set_transient('cached_dummy_images', $images, 60 * 10); //10 minutes cache
@@ -1415,10 +1456,11 @@  discard block
 block discarded – undo
1415 1456
 function geodir_dummy_folder_exists()
1416 1457
 {
1417 1458
     $path = geodir_plugin_path() . '/geodirectory-admin/dummy/';
1418
-    if (!is_dir($path))
1419
-        return false;
1420
-    else
1421
-        return true;
1459
+    if (!is_dir($path)) {
1460
+            return false;
1461
+    } else {
1462
+            return true;
1463
+    }
1422 1464
 
1423 1465
 }
1424 1466
 
@@ -1689,12 +1731,10 @@  discard block
 block discarded – undo
1689 1731
         if ($message_type == 'registration' && get_option('bcc_new_user')) {
1690 1732
             $subject .= ' - ADMIN BCC COPY';
1691 1733
             $admin_bcc = true;
1692
-        }
1693
-        elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
1734
+        } elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
1694 1735
             $subject .= ' - ADMIN BCC COPY';
1695 1736
             $admin_bcc = true;
1696
-        }
1697
-        elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
1737
+        } elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
1698 1738
             $subject .= ' - ADMIN BCC COPY';
1699 1739
             $admin_bcc = true;
1700 1740
         }
@@ -1738,7 +1778,9 @@  discard block
 block discarded – undo
1738 1778
         $res = array();
1739 1779
         foreach ($ids_array as $id) {
1740 1780
             $xlat = icl_object_id($id, $type, false);
1741
-            if (!is_null($xlat)) $res[] = $xlat;
1781
+            if (!is_null($xlat)) {
1782
+            	$res[] = $xlat;
1783
+            }
1742 1784
         }
1743 1785
         return $res;
1744 1786
     } else {
@@ -2079,8 +2121,9 @@  discard block
 block discarded – undo
2079 2121
         $limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
2080 2122
 
2081 2123
         $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1;
2082
-        if ( !$page )
2083
-            $page = 1;
2124
+        if ( !$page ) {
2125
+                    $page = 1;
2126
+        }
2084 2127
 
2085 2128
         $limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : "";
2086 2129
 
@@ -2406,7 +2449,7 @@  discard block
 block discarded – undo
2406 2449
     $home_url = str_replace("www.", "", $home_url);
2407 2450
     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')) ) {
2408 2451
         return true;
2409
-    }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')){
2452
+    } 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')){
2410 2453
         return true;
2411 2454
     } else {
2412 2455
         return false;
@@ -2492,9 +2535,9 @@  discard block
 block discarded – undo
2492 2535
     $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15;
2493 2536
     if(!empty($gd_post_type)){
2494 2537
         $default_post_type = $gd_post_type;
2495
-    }elseif(isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ){
2538
+    } elseif(isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ){
2496 2539
         $default_post_type = $instance['default_post_type'];
2497
-    }else{
2540
+    } else{
2498 2541
         $all_gd_post_type = geodir_get_posttypes();
2499 2542
         $default_post_type = (isset($all_gd_post_type[0])) ? $all_gd_post_type[0] : '';
2500 2543
     }
@@ -2918,8 +2961,9 @@  discard block
 block discarded – undo
2918 2961
                         $name = $postobj->labels->name;
2919 2962
 
2920 2963
                         $selected = '';
2921
-                        if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing'))
2922
-                            $selected = 'selected="selected"';
2964
+                        if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing')) {
2965
+                                                    $selected = 'selected="selected"';
2966
+                        }
2923 2967
 
2924 2968
                         /**
2925 2969
                          * Filter add listing link.
@@ -3386,8 +3430,9 @@  discard block
 block discarded – undo
3386 3430
             $geodir_is_widget_listing = false;
3387 3431
 
3388 3432
             $GLOBALS['post'] = $current_post;
3389
-            if (!empty($current_post))
3390
-                setup_postdata($current_post);
3433
+            if (!empty($current_post)) {
3434
+                            setup_postdata($current_post);
3435
+            }
3391 3436
             $map_jason = $current_map_jason;
3392 3437
             $map_canvas_arr = $current_map_canvas_arr;
3393 3438
             ?>
@@ -3765,11 +3810,15 @@  discard block
 block discarded – undo
3765 3810
 
3766 3811
     $language_file = geodir_plugin_path() . '/db-language.php';
3767 3812
 
3768
-    if(is_file($language_file) && !is_writable($language_file))
3769
-        return false; // Not possible to create.
3813
+    if(is_file($language_file) && !is_writable($language_file)) {
3814
+            return false;
3815
+    }
3816
+    // Not possible to create.
3770 3817
 
3771
-    if(!is_file($language_file) && !is_writable(dirname($language_file)))
3772
-        return false; // Not possible to create.
3818
+    if(!is_file($language_file) && !is_writable(dirname($language_file))) {
3819
+            return false;
3820
+    }
3821
+    // Not possible to create.
3773 3822
 
3774 3823
     $contents_strings = array();
3775 3824
 
@@ -3812,8 +3861,10 @@  discard block
 block discarded – undo
3812 3861
 
3813 3862
     $contents .= implode(PHP_EOL, $contents_foot);
3814 3863
 
3815
-    if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE))
3816
-        return false; // Failure; could not write file.
3864
+    if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE)) {
3865
+            return false;
3866
+    }
3867
+    // Failure; could not write file.
3817 3868
 
3818 3869
     return true;
3819 3870
 }
@@ -3839,23 +3890,29 @@  discard block
 block discarded – undo
3839 3890
 
3840 3891
     if (!empty($rows)) {
3841 3892
         foreach($rows as $row) {
3842
-            if (!empty($row->admin_title))
3843
-                $translation_texts[] = stripslashes_deep($row->admin_title);
3893
+            if (!empty($row->admin_title)) {
3894
+                            $translation_texts[] = stripslashes_deep($row->admin_title);
3895
+            }
3844 3896
 			
3845
-            if (!empty($row->admin_desc))
3846
-                $translation_texts[] = stripslashes_deep($row->admin_desc);
3897
+            if (!empty($row->admin_desc)) {
3898
+                            $translation_texts[] = stripslashes_deep($row->admin_desc);
3899
+            }
3847 3900
 
3848
-            if (!empty($row->site_title))
3849
-                $translation_texts[] = stripslashes_deep($row->site_title);
3901
+            if (!empty($row->site_title)) {
3902
+                            $translation_texts[] = stripslashes_deep($row->site_title);
3903
+            }
3850 3904
 
3851
-            if (!empty($row->clabels))
3852
-                $translation_texts[] = stripslashes_deep($row->clabels);
3905
+            if (!empty($row->clabels)) {
3906
+                            $translation_texts[] = stripslashes_deep($row->clabels);
3907
+            }
3853 3908
 
3854
-            if (!empty($row->required_msg))
3855
-                $translation_texts[] = stripslashes_deep($row->required_msg);
3909
+            if (!empty($row->required_msg)) {
3910
+                            $translation_texts[] = stripslashes_deep($row->required_msg);
3911
+            }
3856 3912
 			
3857
-			if (!empty($row->default_value))
3858
-                $translation_texts[] = stripslashes_deep($row->default_value);
3913
+			if (!empty($row->default_value)) {
3914
+			                $translation_texts[] = stripslashes_deep($row->default_value);
3915
+			}
3859 3916
 			
3860 3917
 			if (!empty($row->option_values)) {
3861 3918
 				$option_values = geodir_string_values_to_options(stripslashes_deep($row->option_values));
@@ -3877,14 +3934,17 @@  discard block
 block discarded – undo
3877 3934
 
3878 3935
     if (!empty($rows)) {
3879 3936
         foreach($rows as $row) {
3880
-            if (!empty($row->site_title))
3881
-                $translation_texts[] = stripslashes_deep($row->site_title);
3937
+            if (!empty($row->site_title)) {
3938
+                            $translation_texts[] = stripslashes_deep($row->site_title);
3939
+            }
3882 3940
 
3883
-            if (!empty($row->asc_title))
3884
-                $translation_texts[] = stripslashes_deep($row->asc_title);
3941
+            if (!empty($row->asc_title)) {
3942
+                            $translation_texts[] = stripslashes_deep($row->asc_title);
3943
+            }
3885 3944
 
3886
-            if (!empty($row->desc_title))
3887
-                $translation_texts[] = stripslashes_deep($row->desc_title);
3945
+            if (!empty($row->desc_title)) {
3946
+                            $translation_texts[] = stripslashes_deep($row->desc_title);
3947
+            }
3888 3948
         }
3889 3949
     }
3890 3950
 	
@@ -3895,14 +3955,17 @@  discard block
 block discarded – undo
3895 3955
 
3896 3956
 		if (!empty($rows)) {
3897 3957
 			foreach($rows as $row) {
3898
-				if (!empty($row->field_site_name))
3899
-					$translation_texts[] = stripslashes_deep($row->field_site_name);
3958
+				if (!empty($row->field_site_name)) {
3959
+									$translation_texts[] = stripslashes_deep($row->field_site_name);
3960
+				}
3900 3961
 
3901
-				if (!empty($row->front_search_title))
3902
-					$translation_texts[] = stripslashes_deep($row->front_search_title);
3962
+				if (!empty($row->front_search_title)) {
3963
+									$translation_texts[] = stripslashes_deep($row->front_search_title);
3964
+				}
3903 3965
 
3904
-				if (!empty($row->field_desc))
3905
-					$translation_texts[] = stripslashes_deep($row->field_desc);
3966
+				if (!empty($row->field_desc)) {
3967
+									$translation_texts[] = stripslashes_deep($row->field_desc);
3968
+				}
3906 3969
 			}
3907 3970
 		}
3908 3971
 	}
@@ -4220,7 +4283,7 @@  discard block
 block discarded – undo
4220 4283
             if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
4221 4284
                 $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
4222 4285
             }
4223
-        }elseif($gd_page=='add-listing'){
4286
+        } elseif($gd_page=='add-listing'){
4224 4287
             $geodir_post_types = get_option('geodir_post_types');
4225 4288
             $spt = isset($_REQUEST['listing_type']) ? esc_attr($_REQUEST['listing_type']) : '';
4226 4289
             if(!$spt && isset($_REQUEST['pid'])){
@@ -4230,8 +4293,7 @@  discard block
 block discarded – undo
4230 4293
             if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
4231 4294
                 $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
4232 4295
             }
4233
-        }
4234
-        elseif($post->post_type){
4296
+        } elseif($post->post_type){
4235 4297
             $geodir_post_types = get_option('geodir_post_types');
4236 4298
             if(isset($geodir_post_types[$post->post_type]['labels']['singular_name'])){
4237 4299
                 $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'],'geodirectory');
@@ -4250,15 +4312,14 @@  discard block
 block discarded – undo
4250 4312
             if(isset($geodir_post_types[$spt]['labels']['name'])){
4251 4313
                 $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4252 4314
             }
4253
-        }elseif($gd_page=='add-listing'){
4315
+        } elseif($gd_page=='add-listing'){
4254 4316
             $geodir_post_types = get_option('geodir_post_types');
4255 4317
             $spt = sanitize_text_field($_REQUEST['listing_type']);
4256 4318
             if(!$spt){$spt='gd_place';}
4257 4319
             if(isset($geodir_post_types[$spt]['labels']['name'])){
4258 4320
                 $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4259 4321
             }
4260
-        }
4261
-        elseif(isset($post->post_type) && $post->post_type){
4322
+        } elseif(isset($post->post_type) && $post->post_type){
4262 4323
             $geodir_post_types = get_option('geodir_post_types');
4263 4324
             if(isset($geodir_post_types[$post->post_type]['labels']['name'])){
4264 4325
                 $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'],'geodirectory');
@@ -4278,7 +4339,7 @@  discard block
 block discarded – undo
4278 4339
                 $cat = get_term($post->default_category, $post->post_type . 'category');
4279 4340
                 $cat_name = (isset($cat->name)) ? $cat->name : '';
4280 4341
             }
4281
-        }elseif($gd_page=='listing'){
4342
+        } elseif($gd_page=='listing'){
4282 4343
             $queried_object = get_queried_object();
4283 4344
             if(isset($queried_object->name)){
4284 4345
                 $cat_name = $queried_object->name;
@@ -4295,7 +4356,7 @@  discard block
 block discarded – undo
4295 4356
                 $cat = get_term($post->default_category, $post->post_type . 'category');
4296 4357
                 $cat_name = (isset($cat->name)) ? $cat->name : '';
4297 4358
             }
4298
-        }elseif($gd_page=='listing'){
4359
+        } elseif($gd_page=='listing'){
4299 4360
             $queried_object = get_queried_object();
4300 4361
             if(isset($queried_object->name)){
4301 4362
                 $cat_name = $queried_object->name;
@@ -4513,38 +4574,54 @@  discard block
 block discarded – undo
4513 4574
             $seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : '';
4514 4575
 
4515 4576
             if (!empty($labels)) {
4516
-                if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts))
4517
-                    $translation_texts[] = $labels['name'];
4518
-                if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts))
4519
-                    $translation_texts[] = $labels['singular_name'];
4520
-                if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts))
4521
-                    $translation_texts[] = $labels['add_new'];
4522
-                if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts))
4523
-                    $translation_texts[] = $labels['add_new_item'];
4524
-                if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts))
4525
-                    $translation_texts[] = $labels['edit_item'];
4526
-                if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts))
4527
-                    $translation_texts[] = $labels['new_item'];
4528
-                if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts))
4529
-                    $translation_texts[] = $labels['view_item'];
4530
-                if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts))
4531
-                    $translation_texts[] = $labels['search_items'];
4532
-                if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts))
4533
-                    $translation_texts[] = $labels['not_found'];
4534
-                if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts))
4535
-                    $translation_texts[] = $labels['not_found_in_trash'];
4536
-                if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts))
4537
-                    $translation_texts[] = $labels['label_post_profile'];
4538
-                if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts))
4539
-                    $translation_texts[] = $labels['label_post_info'];
4540
-                if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts))
4541
-                    $translation_texts[] = $labels['label_post_images'];
4542
-                if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts))
4543
-                    $translation_texts[] = $labels['label_post_map'];
4544
-                if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts))
4545
-                    $translation_texts[] = $labels['label_reviews'];
4546
-                if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts))
4547
-                    $translation_texts[] = $labels['label_related_listing'];
4577
+                if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts)) {
4578
+                                    $translation_texts[] = $labels['name'];
4579
+                }
4580
+                if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts)) {
4581
+                                    $translation_texts[] = $labels['singular_name'];
4582
+                }
4583
+                if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts)) {
4584
+                                    $translation_texts[] = $labels['add_new'];
4585
+                }
4586
+                if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts)) {
4587
+                                    $translation_texts[] = $labels['add_new_item'];
4588
+                }
4589
+                if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts)) {
4590
+                                    $translation_texts[] = $labels['edit_item'];
4591
+                }
4592
+                if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts)) {
4593
+                                    $translation_texts[] = $labels['new_item'];
4594
+                }
4595
+                if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts)) {
4596
+                                    $translation_texts[] = $labels['view_item'];
4597
+                }
4598
+                if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts)) {
4599
+                                    $translation_texts[] = $labels['search_items'];
4600
+                }
4601
+                if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts)) {
4602
+                                    $translation_texts[] = $labels['not_found'];
4603
+                }
4604
+                if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts)) {
4605
+                                    $translation_texts[] = $labels['not_found_in_trash'];
4606
+                }
4607
+                if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts)) {
4608
+                                    $translation_texts[] = $labels['label_post_profile'];
4609
+                }
4610
+                if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts)) {
4611
+                                    $translation_texts[] = $labels['label_post_info'];
4612
+                }
4613
+                if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts)) {
4614
+                                    $translation_texts[] = $labels['label_post_images'];
4615
+                }
4616
+                if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts)) {
4617
+                                    $translation_texts[] = $labels['label_post_map'];
4618
+                }
4619
+                if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts)) {
4620
+                                    $translation_texts[] = $labels['label_reviews'];
4621
+                }
4622
+                if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts)) {
4623
+                                    $translation_texts[] = $labels['label_related_listing'];
4624
+                }
4548 4625
             }
4549 4626
 
4550 4627
             if ($description != '' && !in_array($description, $translation_texts)) {
@@ -4552,11 +4629,13 @@  discard block
 block discarded – undo
4552 4629
             }
4553 4630
 
4554 4631
             if (!empty($seo)) {
4555
-                if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts))
4556
-                    $translation_texts[] = normalize_whitespace($seo['meta_keyword']);
4632
+                if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts)) {
4633
+                                    $translation_texts[] = normalize_whitespace($seo['meta_keyword']);
4634
+                }
4557 4635
 
4558
-                if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts))
4559
-                    $translation_texts[] = normalize_whitespace($seo['meta_description']);
4636
+                if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts)) {
4637
+                                    $translation_texts[] = normalize_whitespace($seo['meta_description']);
4638
+                }
4560 4639
             }
4561 4640
         }
4562 4641
     }
@@ -4582,16 +4661,20 @@  discard block
 block discarded – undo
4582 4661
         $hide_region_part = get_option('geodir_location_hide_region_part');
4583 4662
 
4584 4663
         if ($hide_region_part && $hide_country_part) {
4585
-            if (isset($location_terms['gd_country']))
4586
-                unset($location_terms['gd_country']);
4587
-            if (isset($location_terms['gd_region']))
4588
-                unset($location_terms['gd_region']);
4664
+            if (isset($location_terms['gd_country'])) {
4665
+                            unset($location_terms['gd_country']);
4666
+            }
4667
+            if (isset($location_terms['gd_region'])) {
4668
+                            unset($location_terms['gd_region']);
4669
+            }
4589 4670
         } else if ($hide_region_part && !$hide_country_part) {
4590
-            if (isset($location_terms['gd_region']))
4591
-                unset($location_terms['gd_region']);
4671
+            if (isset($location_terms['gd_region'])) {
4672
+                            unset($location_terms['gd_region']);
4673
+            }
4592 4674
         } else if (!$hide_region_part && $hide_country_part) {
4593
-            if (isset($location_terms['gd_country']))
4594
-                unset($location_terms['gd_country']);
4675
+            if (isset($location_terms['gd_country'])) {
4676
+                            unset($location_terms['gd_country']);
4677
+            }
4595 4678
         }
4596 4679
     }
4597 4680
 
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.
Indentation   +195 added lines, -195 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
 
@@ -403,31 +403,31 @@  discard block
 block discarded – undo
403 403
 function geodir_get_location_link($which_location = 'current')
404 404
 {
405 405
 
406
-    $location_link = get_permalink(geodir_location_page_id());
406
+	$location_link = get_permalink(geodir_location_page_id());
407 407
 
408
-    if (get_option('permalink_structure') != '') {
408
+	if (get_option('permalink_structure') != '') {
409 409
 
410
-        //$location_prefix = get_option('geodir_location_prefix');
411
-        //$location_link = substr_replace($location_link, $location_prefix, strpos($location_link, 'location'), strlen('location'));
410
+		//$location_prefix = get_option('geodir_location_prefix');
411
+		//$location_link = substr_replace($location_link, $location_prefix, strpos($location_link, 'location'), strlen('location'));
412 412
 
413
-    }
413
+	}
414 414
 
415
-    if ($which_location == 'base') {
416
-        return $location_link;
417
-    } else {
418
-        $location_terms = geodir_get_current_location_terms();
415
+	if ($which_location == 'base') {
416
+		return $location_link;
417
+	} else {
418
+		$location_terms = geodir_get_current_location_terms();
419 419
 
420
-        if (!empty($location_terms)) {
421
-            if (get_option('permalink_structure') != '') {
422
-                $location_terms = implode("/", $location_terms);
423
-                $location_terms = rtrim($location_terms, '/');
424
-                $location_link .= $location_terms;
425
-            } else {
426
-                $location_link = geodir_getlink($location_link, $location_terms);
427
-            }
428
-        }
429
-    }
430
-    return $location_link;
420
+		if (!empty($location_terms)) {
421
+			if (get_option('permalink_structure') != '') {
422
+				$location_terms = implode("/", $location_terms);
423
+				$location_terms = rtrim($location_terms, '/');
424
+				$location_link .= $location_terms;
425
+			} else {
426
+				$location_link = geodir_getlink($location_link, $location_terms);
427
+			}
428
+		}
429
+	}
430
+	return $location_link;
431 431
 }
432 432
 
433 433
 
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.