Test Failed
Pull Request — master (#239)
by Viruthagiri
14:39
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
@@ -183,8 +183,9 @@  discard block
 block discarded – undo
183 183
 
184 184
         $thumb_img_arr = array();
185 185
 
186
-        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
187
-            $thumb_img_arr = geodir_get_images($_REQUEST['pid']);
186
+        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
187
+                    $thumb_img_arr = geodir_get_images($_REQUEST['pid']);
188
+        }
188 189
 
189 190
         $totImg = '';
190 191
         $image_limit = '';
@@ -235,7 +236,9 @@  discard block
 block discarded – undo
235 236
     {
236 237
         global $menu, $geodirectory;
237 238
 
238
-        if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
239
+        if (current_user_can('manage_options')) {
240
+        	$menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
241
+        }
239 242
 
240 243
         add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
241 244
 
@@ -299,7 +302,9 @@  discard block
 block discarded – undo
299 302
      */
300 303
     function geodir_admin_custom_menu_order()
301 304
     {
302
-        if (!current_user_can('manage_options')) return false;
305
+        if (!current_user_can('manage_options')) {
306
+        	return false;
307
+        }
303 308
         return true;
304 309
     }
305 310
 }
@@ -330,10 +335,11 @@  discard block
 block discarded – undo
330 335
 			case 'fail':
331 336
 				$gderr = isset($_REQUEST['gderr']) ? $_REQUEST['gderr'] : '';
332 337
 				
333
-				if ($gderr == 21)
334
-			    	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>';
335
-				else
336
-					echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>';
338
+				if ($gderr == 21) {
339
+							    	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>';
340
+				} else {
341
+									echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>';
342
+				}
337 343
                 break;
338 344
         }
339 345
     }
@@ -370,8 +376,12 @@  discard block
 block discarded – undo
370 376
         include_once('option-pages/' . $current_tab . '_array.php');
371 377
     }
372 378
     if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') :
373
-        if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
374
-        if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
379
+        if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) {
380
+        	die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
381
+        }
382
+        if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) {
383
+        	die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
384
+        }
375 385
 		
376 386
 		/**
377 387
 		 * Fires before updating geodirectory admin settings.
@@ -383,8 +393,9 @@  discard block
 block discarded – undo
383 393
 		 */
384 394
 		do_action('geodir_before_update_options', $current_tab, $geodir_settings);		
385 395
 		
386
-        if (!empty($geodir_settings[$current_tab]))
387
-            geodir_update_options($geodir_settings[$current_tab]);
396
+        if (!empty($geodir_settings[$current_tab])) {
397
+                    geodir_update_options($geodir_settings[$current_tab]);
398
+        }
388 399
 
389 400
         /**
390 401
          * Called after GeoDirectory options settings are updated.
@@ -452,8 +463,9 @@  discard block
 block discarded – undo
452 463
                 $options_list = '';
453 464
                 for ($option = 1; $option <= 30; $option++) {
454 465
                     $selected = '';
455
-                    if ($option == 10)
456
-                        $selected = 'selected="selected"';
466
+                    if ($option == 10) {
467
+                                            $selected = 'selected="selected"';
468
+                    }
457 469
 
458 470
                     $options_list .= '<option ' . $selected . ' value="' . $option . '">' . $option . '</option>';
459 471
                 }
@@ -649,10 +661,11 @@  discard block
 block discarded – undo
649 661
                     }
650 662
 
651 663
 
652
-                    if (geodir_dummy_folder_exists())
653
-                        $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
654
-                    else
655
-                        $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
664
+                    if (geodir_dummy_folder_exists()) {
665
+                                            $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
666
+                    } else {
667
+                                            $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
668
+                    }
656 669
 
657 670
                     $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
658 671
 
@@ -693,10 +706,11 @@  discard block
 block discarded – undo
693 706
             if (!term_exists($catname, 'gd_placecategory')) {
694 707
                 $last_catid = wp_insert_term($catname, 'gd_placecategory');
695 708
 
696
-                if (geodir_dummy_folder_exists())
697
-                    $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
698
-                else
699
-                    $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
709
+                if (geodir_dummy_folder_exists()) {
710
+                                    $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
711
+                } else {
712
+                                    $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
713
+                }
700 714
 
701 715
                 $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
702 716
 
@@ -748,11 +762,14 @@  discard block
 block discarded – undo
748 762
  * @return bool Returns true if saved.
749 763
  */
750 764
 function geodir_update_options($options, $dummy = false) {
751
-    if ((!isset($_POST) || !$_POST) && !$dummy) return false;
765
+    if ((!isset($_POST) || !$_POST) && !$dummy) {
766
+    	return false;
767
+    }
752 768
 
753 769
     foreach ($options as $value) {
754
-        if ($dummy && isset($value['std']))
755
-            $_POST[$value['id']] = $value['std'];
770
+        if ($dummy && isset($value['std'])) {
771
+                    $_POST[$value['id']] = $value['std'];
772
+        }
756 773
 
757 774
 
758 775
         if (isset($value['type']) && $value['type'] == 'checkbox') :
@@ -761,25 +778,23 @@  discard block
 block discarded – undo
761 778
                 update_option($value['id'], $_POST[$value['id']]);
762 779
             } else {
763 780
                 update_option($value['id'], 0);
764
-            }
765
-
766
-        elseif (isset($value['type']) && $value['type'] == 'image_width') :
781
+            } elseif (isset($value['type']) && $value['type'] == 'image_width') :
767 782
 
768 783
             if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
769 784
                 update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']);
770 785
                 update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']);
771 786
                 if (isset($_POST[$value['id'] . '_crop'])) :
772 787
                     update_option($value['id'] . '_crop', 1);
773
-                else :
774
-                    update_option($value['id'] . '_crop', 0);
788
+                else {
789
+                	:
790
+                    update_option($value['id'] . '_crop', 0);
791
+                }
775 792
                 endif;
776 793
             } else {
777 794
                 update_option($value['id'] . '_width', $value['std']);
778 795
                 update_option($value['id'] . '_height', $value['std']);
779 796
                 update_option($value['id'] . '_crop', 1);
780
-            }
781
-
782
-        elseif (isset($value['type']) && $value['type'] == 'map') :
797
+            } elseif (isset($value['type']) && $value['type'] == 'map') :
783 798
             $post_types = array();
784 799
             $categories = array();
785 800
 
@@ -824,8 +839,9 @@  discard block
 block discarded – undo
824 839
                     $image_name_arr = explode('/', get_option($value['id']));
825 840
                     $noimg_name = end($image_name_arr);
826 841
                     $img_path = $uploads['path'] . '/' . $noimg_name;
827
-                    if (file_exists($img_path))
828
-                        unlink($img_path);
842
+                    if (file_exists($img_path)) {
843
+                                            unlink($img_path);
844
+                    }
829 845
                 }
830 846
 
831 847
                 update_option($value['id'], '');
@@ -841,8 +857,10 @@  discard block
 block discarded – undo
841 857
                 foreach ($uploadedfile as $key => $uplaod):
842 858
                     if ($key == 'name'):
843 859
                         $uplaods[$key] = $filename;
844
-                    else :
845
-                        $uplaods[$key] = $uplaod;
860
+                    else {
861
+                    	:
862
+                        $uplaods[$key] = $uplaod;
863
+                    }
846 864
                     endif;
847 865
                 endforeach;
848 866
 
@@ -852,8 +870,9 @@  discard block
 block discarded – undo
852 870
                     $image_name_arr = explode('/', get_option($value['id']));
853 871
                     $noimg_name = end($image_name_arr);
854 872
                     $img_path = $uploads['path'] . '/' . $noimg_name;
855
-                    if (file_exists($img_path))
856
-                        unlink($img_path);
873
+                    if (file_exists($img_path)) {
874
+                                            unlink($img_path);
875
+                    }
857 876
                 }
858 877
 
859 878
                 $upload_overrides = array('test_form' => false);
@@ -868,10 +887,12 @@  discard block
 block discarded – undo
868 887
             endif;
869 888
 
870 889
 
871
-        else :
890
+        else {
891
+        	:
872 892
             // same menu setting per theme.
873 893
             if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
874
-                $theme = wp_get_theme();
894
+                $theme = wp_get_theme();
895
+        }
875 896
                 update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
876 897
             }
877 898
 
@@ -883,8 +904,9 @@  discard block
 block discarded – undo
883 904
 
884 905
         endif;
885 906
     }
886
-    if ($dummy)
887
-        $_POST = array();
907
+    if ($dummy) {
908
+            $_POST = array();
909
+    }
888 910
     return true;
889 911
 
890 912
 }
@@ -1029,9 +1051,12 @@  discard block
 block discarded – undo
1029 1051
         $new_columns = array('location' => __('Location (ID)', 'geodirectory'),
1030 1052
             'categorys' => __('Categories', 'geodirectory'));
1031 1053
 
1032
-        if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
1054
+        if (($offset = array_search('author', array_keys($columns))) === false) {
1055
+        	// if the key doesn't exist
1033 1056
         {
1034
-            $offset = 0; // should we prepend $array with $data?
1057
+            $offset = 0;
1058
+        }
1059
+        // should we prepend $array with $data?
1035 1060
             $offset = count($columns); // or should we append $array with $data? lets pick this one...
1036 1061
         }
1037 1062
 
@@ -1091,11 +1116,13 @@  discard block
 block discarded – undo
1091 1116
                     $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
1092 1117
                 }
1093 1118
                 /* If no expire_date is found, output a default message. */
1094
-                if (empty($expire_date))
1095
-                    echo __('Unknown', 'geodirectory');
1119
+                if (empty($expire_date)) {
1120
+                                    echo __('Unknown', 'geodirectory');
1121
+                }
1096 1122
                 /* If there is a expire_date, append 'days left' to the text string. */
1097
-                else
1098
-                    echo $expire_date . $date_diff_text;
1123
+                else {
1124
+                                    echo $expire_date . $date_diff_text;
1125
+                }
1099 1126
                 break;
1100 1127
 
1101 1128
             /* If displaying the 'categorys' column. */
@@ -1168,21 +1195,26 @@  discard block
 block discarded – undo
1168 1195
 
1169 1196
     $geodir_posttypes = geodir_get_posttypes();
1170 1197
 
1171
-    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
1172
-        return;
1198
+    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
1199
+            return;
1200
+    }
1173 1201
 
1174 1202
     if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
1175
-        if (isset($_REQUEST['_status']))
1176
-            geodir_change_post_status($post_id, $_REQUEST['_status']);
1203
+        if (isset($_REQUEST['_status'])) {
1204
+                    geodir_change_post_status($post_id, $_REQUEST['_status']);
1205
+        }
1177 1206
 
1178
-        if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash'))
1179
-            return;
1207
+        if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash')) {
1208
+                    return;
1209
+        }
1180 1210
 
1181
-        if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__)))
1182
-            return;
1211
+        if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__))) {
1212
+                    return;
1213
+        }
1183 1214
 
1184
-        if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__)))
1185
-            return;
1215
+        if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__))) {
1216
+                    return;
1217
+        }
1186 1218
 
1187 1219
         geodir_save_listing($_REQUEST);
1188 1220
     }
@@ -1207,10 +1239,18 @@  discard block
 block discarded – undo
1207 1239
     $tab_id = '';
1208 1240
     $i = 0;
1209 1241
     foreach ($options as $value) :
1210
-        if (!isset($value['name'])) $value['name'] = '';
1211
-        if (!isset($value['class'])) $value['class'] = '';
1212
-        if (!isset($value['css'])) $value['css'] = '';
1213
-        if (!isset($value['std'])) $value['std'] = '';
1242
+        if (!isset($value['name'])) {
1243
+        	$value['name'] = '';
1244
+        }
1245
+        if (!isset($value['class'])) {
1246
+        	$value['class'] = '';
1247
+        }
1248
+        if (!isset($value['css'])) {
1249
+        	$value['css'] = '';
1250
+        }
1251
+        if (!isset($value['std'])) {
1252
+        	$value['std'] = '';
1253
+        }
1214 1254
         $desc = '';
1215 1255
         switch ($value['type']) :
1216 1256
             case 'dummy_installer':
@@ -1226,11 +1266,13 @@  discard block
 block discarded – undo
1226 1266
 
1227 1267
                 $i++;
1228 1268
 
1229
-                if (isset($value['id']) && $value['id'])
1230
-                    $tab_id = $value['id'];
1269
+                if (isset($value['id']) && $value['id']) {
1270
+                                    $tab_id = $value['id'];
1271
+                }
1231 1272
 
1232
-                if (isset($value['desc']) && $value['desc'])
1233
-                    $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>';
1273
+                if (isset($value['desc']) && $value['desc']) {
1274
+                                    $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>';
1275
+                }
1234 1276
 
1235 1277
                 if (isset($value['name']) && $value['name']) {
1236 1278
                     if ($first_title === true) {
@@ -1261,10 +1303,12 @@  discard block
 block discarded – undo
1261 1303
                 break;
1262 1304
 
1263 1305
             case 'sectionstart':
1264
-                if (isset($value['desc']) && $value['desc'])
1265
-                    $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>';
1266
-                if (isset($value['name']) && $value['name'])
1267
-                    echo '<h3>' . $value['name'] . $desc . '</h3>';
1306
+                if (isset($value['desc']) && $value['desc']) {
1307
+                                    $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>';
1308
+                }
1309
+                if (isset($value['name']) && $value['name']) {
1310
+                                    echo '<h3>' . $value['name'] . $desc . '</h3>';
1311
+                }
1268 1312
                 /**
1269 1313
                  * Called after a GeoDirectory settings sectionstart is output in the GD settings page.
1270 1314
                  *
@@ -1272,7 +1316,9 @@  discard block
 block discarded – undo
1272 1316
                  *
1273 1317
                  * @since 1.0.0
1274 1318
                  */
1275
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
1319
+                if (isset($value['id']) && $value['id']) {
1320
+                	do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
1321
+                }
1276 1322
                 echo '<table class="form-table">' . "\n\n";
1277 1323
 
1278 1324
                 break;
@@ -1284,7 +1330,9 @@  discard block
 block discarded – undo
1284 1330
                  *
1285 1331
                  * @since 1.0.0
1286 1332
                  */
1287
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
1333
+                if (isset($value['id']) && $value['id']) {
1334
+                	do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
1335
+                }
1288 1336
                 echo '</table>';
1289 1337
                 /**
1290 1338
                  * Called after a GeoDirectory settings sectionend is output in the GD settings page.
@@ -1293,7 +1341,9 @@  discard block
 block discarded – undo
1293 1341
                  *
1294 1342
                  * @since 1.0.0
1295 1343
                  */
1296
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
1344
+                if (isset($value['id']) && $value['id']) {
1345
+                	do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
1346
+                }
1297 1347
                 break;
1298 1348
             case 'text':
1299 1349
                 ?>
@@ -1365,17 +1415,32 @@  discard block
 block discarded – undo
1365 1415
                     <?php _e('Width', 'geodirectory'); ?> <input
1366 1416
                         name="<?php echo esc_attr($value['id']); ?>_width"
1367 1417
                         id="<?php echo esc_attr($value['id']); ?>_width" type="text" size="3"
1368
-                        value="<?php if ($size = get_option($value['id'] . '_width')) echo stripslashes($size); else echo $value['std']; ?>"/>
1418
+                        value="<?php if ($size = get_option($value['id'] . '_width')) {
1419
+	echo stripslashes($size);
1420
+} else {
1421
+	echo $value['std'];
1422
+}
1423
+?>"/>
1369 1424
 
1370 1425
                     <?php _e('Height', 'geodirectory'); ?> <input
1371 1426
                         name="<?php echo esc_attr($value['id']); ?>_height"
1372 1427
                         id="<?php echo esc_attr($value['id']); ?>_height" type="text" size="3"
1373
-                        value="<?php if ($size = get_option($value['id'] . '_height')) echo stripslashes($size); else echo $value['std']; ?>"/>
1428
+                        value="<?php if ($size = get_option($value['id'] . '_height')) {
1429
+	echo stripslashes($size);
1430
+} else {
1431
+	echo $value['std'];
1432
+}
1433
+?>"/>
1374 1434
 
1375 1435
                     <label><?php _e('Hard Crop', 'geodirectory'); ?> <input
1376 1436
                             name="<?php echo esc_attr($value['id']); ?>_crop"
1377 1437
                             id="<?php echo esc_attr($value['id']); ?>_crop"
1378
-                            type="checkbox" <?php if (get_option($value['id'] . '_crop') != '') checked(get_option($value['id'] . '_crop'), 1); else checked(1); ?> /></label>
1438
+                            type="checkbox" <?php if (get_option($value['id'] . '_crop') != '') {
1439
+	checked(get_option($value['id'] . '_crop'), 1);
1440
+} else {
1441
+	checked(1);
1442
+}
1443
+?> /></label>
1379 1444
 
1380 1445
                     <span class="description"><?php echo $value['desc'] ?></span></td>
1381 1446
                 </tr><?php
@@ -1389,17 +1454,22 @@  discard block
 block discarded – undo
1389 1454
                 <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>"
1390 1455
                                             id="<?php echo esc_attr($value['id']); ?>"
1391 1456
                                             style="<?php echo esc_attr($value['css']); ?>"
1392
-                                            class="<?php if (isset($value['class'])) echo $value['class']; ?>"
1457
+                                            class="<?php if (isset($value['class'])) {
1458
+	echo $value['class'];
1459
+}
1460
+?>"
1393 1461
                                             option-ajaxchosen="false">
1394 1462
                         <?php
1395 1463
                         foreach ($value['options'] as $key => $val) {
1396 1464
                             $geodir_select_value = '';
1397 1465
                             if ($option_value != '') {
1398
-                                if ($option_value != '' && $option_value == $key)
1399
-                                    $geodir_select_value = ' selected="selected" ';
1466
+                                if ($option_value != '' && $option_value == $key) {
1467
+                                                                    $geodir_select_value = ' selected="selected" ';
1468
+                                }
1400 1469
                             } else {
1401
-                                if ($value['std'] == $key)
1402
-                                    $geodir_select_value = ' selected="selected" ';
1470
+                                if ($value['std'] == $key) {
1471
+                                                                    $geodir_select_value = ' selected="selected" ';
1472
+                                }
1403 1473
                             }
1404 1474
                             ?>
1405 1475
                             <option
@@ -1424,8 +1494,14 @@  discard block
 block discarded – undo
1424 1494
                 <td class="forminp"><select multiple="multiple" name="<?php echo esc_attr($value['id']); ?>[]"
1425 1495
                                             id="<?php echo esc_attr($value['id']); ?>"
1426 1496
                                             style="<?php echo esc_attr($value['css']); ?>"
1427
-                                            class="<?php if (isset($value['class'])) echo $value['class']; ?>"
1428
-                                            data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>"
1497
+                                            class="<?php if (isset($value['class'])) {
1498
+	echo $value['class'];
1499
+}
1500
+?>"
1501
+                                            data-placeholder="<?php if (isset($value['placeholder_text'])) {
1502
+	echo $value['placeholder_text'];
1503
+}
1504
+?>"
1429 1505
                                             option-ajaxchosen="false">
1430 1506
                         <?php
1431 1507
                         foreach ($value['options'] as $key => $val) {
@@ -1452,7 +1528,10 @@  discard block
 block discarded – undo
1452 1528
                 <td class="forminp">
1453 1529
                     <input type="file" name="<?php echo esc_attr($value['id']); ?>"
1454 1530
                            id="<?php echo esc_attr($value['id']); ?>" style="<?php echo esc_attr($value['css']); ?>"
1455
-                           class="<?php if (isset($value['class'])) echo $value['class']; ?>"/>
1531
+                           class="<?php if (isset($value['class'])) {
1532
+	echo $value['class'];
1533
+}
1534
+?>"/>
1456 1535
                     <?php if (get_option($value['id'])) { ?>
1457 1536
                         <input type="hidden" name="<?php echo esc_attr($value['id']); ?>_remove"
1458 1537
                                id="<?php echo esc_attr($value['id']); ?>_remove" value="0">
@@ -1533,13 +1612,15 @@  discard block
 block discarded – undo
1533 1612
                                 'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
1534 1613
                             );
1535 1614
                             $geodir_default_map_language = get_option('geodir_default_map_language');
1536
-                            if (empty($geodir_default_map_language))
1537
-                                $geodir_default_map_language = 'en';
1615
+                            if (empty($geodir_default_map_language)) {
1616
+                                                            $geodir_default_map_language = 'en';
1617
+                            }
1538 1618
                             foreach ($arr_map_langages as $language_key => $language_txt) {
1539
-                                if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language)
1540
-                                    $geodir_default_language_selected = "selected='selected'";
1541
-                                else
1542
-                                    $geodir_default_language_selected = '';
1619
+                                if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language) {
1620
+                                                                    $geodir_default_language_selected = "selected='selected'";
1621
+                                } else {
1622
+                                                                    $geodir_default_language_selected = '';
1623
+                                }
1543 1624
 
1544 1625
                                 ?>
1545 1626
                                 <option
@@ -1559,14 +1640,16 @@  discard block
 block discarded – undo
1559 1640
                             <?php
1560 1641
                             $post_types = geodir_get_posttypes('array');
1561 1642
                             $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
1562
-                            if (empty($geodir_default_map_search_pt))
1563
-                                $geodir_default_map_search_pt = 'gd_place';
1643
+                            if (empty($geodir_default_map_search_pt)) {
1644
+                                                            $geodir_default_map_search_pt = 'gd_place';
1645
+                            }
1564 1646
                             if (is_array($post_types)) {
1565 1647
                                 foreach ($post_types as $key => $post_types_obj) {
1566
-                                    if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt)
1567
-                                        $geodir_search_pt_selected = "selected='selected'";
1568
-                                    else
1569
-                                        $geodir_search_pt_selected = '';
1648
+                                    if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt) {
1649
+                                                                            $geodir_search_pt_selected = "selected='selected'";
1650
+                                    } else {
1651
+                                                                            $geodir_search_pt_selected = '';
1652
+                                    }
1570 1653
 
1571 1654
                                     ?>
1572 1655
                                     <option
@@ -1686,7 +1769,7 @@  discard block
 block discarded – undo
1686 1769
                                id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio"
1687 1770
                                value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) {
1688 1771
                             echo 'checked="checked"';
1689
-                        }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
1772
+                        } elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
1690 1773
                         <?php echo $value['desc']; ?></label><br>
1691 1774
                 </fieldset>
1692 1775
                 <?php
@@ -1706,10 +1789,18 @@  discard block
 block discarded – undo
1706 1789
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1707 1790
                 <td class="forminp">
1708 1791
                     <textarea
1709
-                        <?php if (isset($value['args'])) echo $value['args'] . ' '; ?>name="<?php echo esc_attr($value['id']); ?>"
1792
+                        <?php if (isset($value['args'])) {
1793
+	echo $value['args'] . ' ';
1794
+}
1795
+?>name="<?php echo esc_attr($value['id']); ?>"
1710 1796
                         id="<?php echo esc_attr($value['id']); ?>"
1711 1797
                         <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1712
-                        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
1798
+                        style="<?php echo esc_attr($value['css']); ?>"><?php if (get_option($value['id'])) {
1799
+	echo esc_textarea(stripslashes(get_option($value['id'])));
1800
+} else {
1801
+	echo esc_textarea($value['std']);
1802
+}
1803
+?></textarea><span
1713 1804
                         class="description"><?php echo $value['desc'] ?></span>
1714 1805
 
1715 1806
                 </td>
@@ -1721,10 +1812,11 @@  discard block
 block discarded – undo
1721 1812
                 <tr valign="top">
1722 1813
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1723 1814
                 <td class="forminp"><?php
1724
-                    if (get_option($value['id']))
1725
-                        $content = stripslashes(get_option($value['id']));
1726
-                    else
1727
-                        $content = $value['std'];
1815
+                    if (get_option($value['id'])) {
1816
+                                            $content = stripslashes(get_option($value['id']));
1817
+                    } else {
1818
+                                            $content = $value['std'];
1819
+                    }
1728 1820
 
1729 1821
                     $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
1730 1822
 
@@ -1764,7 +1856,9 @@  discard block
 block discarded – undo
1764 1856
                     'echo' => false,
1765 1857
                     'selected' => $page_setting);
1766 1858
 
1767
-                if (isset($value['args'])) $args = wp_parse_args($value['args'], $args);
1859
+                if (isset($value['args'])) {
1860
+                	$args = wp_parse_args($value['args'], $args);
1861
+                }
1768 1862
 
1769 1863
                 ?>
1770 1864
                 <tr valign="top" class="single_select_page">
@@ -1783,8 +1877,10 @@  discard block
 block discarded – undo
1783 1877
                 if (strstr($country_setting, ':')) :
1784 1878
                     $country = current(explode(':', $country_setting));
1785 1879
                     $state = end(explode(':', $country_setting));
1786
-                else :
1787
-                    $country = $country_setting;
1880
+                else {
1881
+                	:
1882
+                    $country = $country_setting;
1883
+                }
1788 1884
                     $state = '*';
1789 1885
                 endif;
1790 1886
                 ?>
@@ -1811,8 +1907,10 @@  discard block
 block discarded – undo
1811 1907
                             data-placeholder="<?php _e('Choose countries&hellip;', 'geodirectory'); ?>"
1812 1908
                             title="Country" class="chosen_select">
1813 1909
                         <?php
1814
-                        if ($countries) foreach ($countries as $key => $val) :
1815
-                            echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>';
1910
+                        if ($countries) {
1911
+                        	foreach ($countries as $key => $val) :
1912
+                            echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>';
1913
+                        }
1816 1914
                         endforeach;
1817 1915
                         ?>
1818 1916
                     </select>
@@ -2063,8 +2161,9 @@  discard block
 block discarded – undo
2063 2161
         endforeach;
2064 2162
     endif;
2065 2163
 
2066
-    if (!empty($place_img_array))
2067
-        $curImages = implode(',', $place_img_array);
2164
+    if (!empty($place_img_array)) {
2165
+            $curImages = implode(',', $place_img_array);
2166
+    }
2068 2167
 
2069 2168
 
2070 2169
     // adjust values here
@@ -2411,16 +2510,17 @@  discard block
 block discarded – undo
2411 2510
 	
2412 2511
 	$post_type = NULL;
2413 2512
 	
2414
-	if ($post && isset($post->post_type))
2415
-		$post_type = $post->post_type;
2416
-	elseif ($typenow)
2417
-		$post_type = $typenow;
2418
-	elseif ($current_screen && isset($current_screen->post_type))
2419
-		$post_type = $current_screen->post_type;
2420
-	elseif (isset($_REQUEST['post_type']))
2421
-		$post_type = sanitize_key($_REQUEST['post_type']);
2422
-	elseif (isset($_REQUEST['post']) && get_post_type($_REQUEST['post']))
2423
-		$post_type = get_post_type($_REQUEST['post']);
2513
+	if ($post && isset($post->post_type)) {
2514
+			$post_type = $post->post_type;
2515
+	} elseif ($typenow) {
2516
+			$post_type = $typenow;
2517
+	} elseif ($current_screen && isset($current_screen->post_type)) {
2518
+			$post_type = $current_screen->post_type;
2519
+	} elseif (isset($_REQUEST['post_type'])) {
2520
+			$post_type = sanitize_key($_REQUEST['post_type']);
2521
+	} elseif (isset($_REQUEST['post']) && get_post_type($_REQUEST['post'])) {
2522
+			$post_type = get_post_type($_REQUEST['post']);
2523
+	}
2424 2524
 
2425 2525
 	return $post_type;
2426 2526
 }
@@ -2479,9 +2579,10 @@  discard block
 block discarded – undo
2479 2579
 function geodir_hide_admin_preview_button() {
2480 2580
     global $post_type;
2481 2581
     $post_types = geodir_get_posttypes();
2482
-    if(in_array($post_type, $post_types))
2483
-        echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
2484
-}
2582
+    if(in_array($post_type, $post_types)) {
2583
+            echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
2584
+    }
2585
+    }
2485 2586
 add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' );
2486 2587
 add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' );
2487 2588
 
@@ -5522,8 +5623,9 @@  discard block
 block discarded – undo
5522 5623
 function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) {
5523 5624
     global $wpdb, $plugin_prefix;
5524 5625
 
5525
-    if ( ! post_type_exists( $post_type ) )
5526
-        return new stdClass;
5626
+    if ( ! post_type_exists( $post_type ) ) {
5627
+            return new stdClass;
5628
+    }
5527 5629
         
5528 5630
     $table = $plugin_prefix . $post_type . '_detail';
5529 5631
 
@@ -6314,7 +6416,9 @@  discard block
 block discarded – undo
6314 6416
 
6315 6417
     if ($page_found) :
6316 6418
         // Page exists
6317
-        if (!$option_value) update_option($option, $page_found);
6419
+        if (!$option_value) {
6420
+        	update_option($option, $page_found);
6421
+        }
6318 6422
         return;
6319 6423
     endif;
6320 6424
 
Please login to merge, or discard this patch.
Indentation   +2814 added lines, -2814 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('geodirectory-font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION);
90
-        wp_enqueue_style('geodirectory-font-awesome');
89
+		wp_register_style('geodirectory-font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION);
90
+		wp_enqueue_style('geodirectory-font-awesome');
91 91
 
92
-        wp_register_script('geodirectory-admin', geodir_plugin_url() . '/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION);
93
-        wp_enqueue_script('geodirectory-admin');
92
+		wp_register_script('geodirectory-admin', geodir_plugin_url() . '/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION);
93
+		wp_enqueue_script('geodirectory-admin');
94 94
 
95
-    }
95
+	}
96 96
 }
97 97
 
98 98
 if (!function_exists('geodir_admin_scripts')) {
99
-    /**
100
-     * Enqueue Admin Scripts.
101
-     *
102
-     * @since 1.0.0
103
-     * @package GeoDirectory
104
-     */
105
-    function geodir_admin_scripts()
106
-    {
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(), GEODIRECTORY_VERSION);
114
-        wp_enqueue_script('chosen');
113
+		wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.js', array(), 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')) {
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,19 +598,19 @@  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');
607
+	/**
608
+	 * Contains dummy post content.
609
+	 *
610
+	 * @since 1.0.0
611
+	 * @package GeoDirectory
612
+	 */
613
+	include_once('place_dummy_post.php');
614 614
 
615 615
 }
616 616
 
@@ -624,18 +624,18 @@  discard block
 block discarded – undo
624 624
  */
625 625
 function geodir_delete_dummy_posts()
626 626
 {
627
-    global $wpdb, $plugin_prefix;
627
+	global $wpdb, $plugin_prefix;
628 628
 
629 629
 
630
-    $post_ids = $wpdb->get_results("SELECT post_id FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
630
+	$post_ids = $wpdb->get_results("SELECT post_id FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
631 631
 
632 632
 
633
-    foreach ($post_ids as $post_ids_obj) {
634
-        wp_delete_post($post_ids_obj->post_id);
635
-    }
633
+	foreach ($post_ids as $post_ids_obj) {
634
+		wp_delete_post($post_ids_obj->post_id);
635
+	}
636 636
 
637
-    //double check posts are deleted
638
-    $wpdb->get_results("DELETE FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
637
+	//double check posts are deleted
638
+	$wpdb->get_results("DELETE FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
639 639
 }
640 640
 
641 641
 /**
@@ -649,114 +649,114 @@  discard block
 block discarded – undo
649 649
  * @global string $dummy_image_path The dummy image path.
650 650
  */
651 651
 function geodir_default_taxonomies() {
652
-    global $wpdb, $dummy_image_path;
652
+	global $wpdb, $dummy_image_path;
653 653
 
654
-    $category_array = array('Attractions', 'Hotels', 'Restaurants', 'Food Nightlife', 'Festival', 'Videos', 'Feature');
654
+	$category_array = array('Attractions', 'Hotels', 'Restaurants', 'Food Nightlife', 'Festival', 'Videos', 'Feature');
655 655
 
656
-    $last_catid = '';
656
+	$last_catid = '';
657 657
 
658
-    $uploads = wp_upload_dir(); // Array of key => value pairs
658
+	$uploads = wp_upload_dir(); // Array of key => value pairs
659 659
 
660
-    for ($i = 0; $i < count($category_array); $i++) {
661
-        $parent_catid = 0;
662
-        if (is_array($category_array[$i])) {
663
-            $cat_name_arr = $category_array[$i];
664
-            for ($j = 0; $j < count($cat_name_arr); $j++) {
665
-                $catname = $cat_name_arr[$j];
660
+	for ($i = 0; $i < count($category_array); $i++) {
661
+		$parent_catid = 0;
662
+		if (is_array($category_array[$i])) {
663
+			$cat_name_arr = $category_array[$i];
664
+			for ($j = 0; $j < count($cat_name_arr); $j++) {
665
+				$catname = $cat_name_arr[$j];
666 666
 
667
-                if (!term_exists($catname, 'gd_placecategory')) {
668
-                    $last_catid = wp_insert_term($catname, 'gd_placecategory', $args = array('parent' => $parent_catid));
667
+				if (!term_exists($catname, 'gd_placecategory')) {
668
+					$last_catid = wp_insert_term($catname, 'gd_placecategory', $args = array('parent' => $parent_catid));
669 669
 
670
-                    if ($j == 0) {
671
-                        $parent_catid = $last_catid;
672
-                    }
670
+					if ($j == 0) {
671
+						$parent_catid = $last_catid;
672
+					}
673 673
 
674 674
 
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';
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';
679 679
 
680
-                    $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
680
+					$dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
681 681
 
682
-                    $catname = str_replace(' ', '_', $catname);
683
-                    $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
682
+					$catname = str_replace(' ', '_', $catname);
683
+					$uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
684 684
 
685
-                    if (empty($uploaded['error'])) {
686
-                        $new_path = $uploaded['file'];
687
-                        $new_url = $uploaded['url'];
688
-                    }
685
+					if (empty($uploaded['error'])) {
686
+						$new_path = $uploaded['file'];
687
+						$new_url = $uploaded['url'];
688
+					}
689 689
 
690
-                    $wp_filetype = wp_check_filetype(basename($new_path), null);
691
-
692
-                    $attachment = array(
693
-                        'guid' => $uploads['baseurl'] . '/' . basename($new_path),
694
-                        'post_mime_type' => $wp_filetype['type'],
695
-                        'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
696
-                        'post_content' => '',
697
-                        'post_status' => 'inherit'
698
-                    );
699
-                    $attach_id = wp_insert_attachment($attachment, $new_path);
700
-
701
-                    // you must first include the image.php file
702
-                    // for the function wp_generate_attachment_metadata() to work
703
-                    require_once(ABSPATH . 'wp-admin/includes/image.php');
704
-                    $attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
705
-                    wp_update_attachment_metadata($attach_id, $attach_data);
706
-
707
-                    if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
708
-                        update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => 'icon', 'src' => $new_url), 'gd_place');
709
-                    }
710
-                }
711
-            }
690
+					$wp_filetype = wp_check_filetype(basename($new_path), null);
691
+
692
+					$attachment = array(
693
+						'guid' => $uploads['baseurl'] . '/' . basename($new_path),
694
+						'post_mime_type' => $wp_filetype['type'],
695
+						'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
696
+						'post_content' => '',
697
+						'post_status' => 'inherit'
698
+					);
699
+					$attach_id = wp_insert_attachment($attachment, $new_path);
700
+
701
+					// you must first include the image.php file
702
+					// for the function wp_generate_attachment_metadata() to work
703
+					require_once(ABSPATH . 'wp-admin/includes/image.php');
704
+					$attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
705
+					wp_update_attachment_metadata($attach_id, $attach_data);
706
+
707
+					if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
708
+						update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => 'icon', 'src' => $new_url), 'gd_place');
709
+					}
710
+				}
711
+			}
712 712
 
713
-        } else {
714
-            $catname = $category_array[$i];
713
+		} else {
714
+			$catname = $category_array[$i];
715 715
 
716
-            if (!term_exists($catname, 'gd_placecategory')) {
717
-                $last_catid = wp_insert_term($catname, 'gd_placecategory');
716
+			if (!term_exists($catname, 'gd_placecategory')) {
717
+				$last_catid = wp_insert_term($catname, 'gd_placecategory');
718 718
 
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';
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';
723 723
 
724
-                $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
724
+				$dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
725 725
 
726
-                $catname = str_replace(' ', '_', $catname);
727
-                $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
726
+				$catname = str_replace(' ', '_', $catname);
727
+				$uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
728 728
 
729
-                if (empty($uploaded['error'])) {
730
-                    $new_path = $uploaded['file'];
731
-                    $new_url = $uploaded['url'];
732
-                }
729
+				if (empty($uploaded['error'])) {
730
+					$new_path = $uploaded['file'];
731
+					$new_url = $uploaded['url'];
732
+				}
733 733
 
734
-                $wp_filetype = wp_check_filetype(basename($new_path), null);
734
+				$wp_filetype = wp_check_filetype(basename($new_path), null);
735 735
 
736
-                $attachment = array(
737
-                    'guid' => $uploads['baseurl'] . '/' . basename($new_path),
738
-                    'post_mime_type' => $wp_filetype['type'],
739
-                    'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
740
-                    'post_content' => '',
741
-                    'post_status' => 'inherit'
742
-                );
736
+				$attachment = array(
737
+					'guid' => $uploads['baseurl'] . '/' . basename($new_path),
738
+					'post_mime_type' => $wp_filetype['type'],
739
+					'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
740
+					'post_content' => '',
741
+					'post_status' => 'inherit'
742
+				);
743 743
 
744
-                $attach_id = wp_insert_attachment($attachment, $new_path);
744
+				$attach_id = wp_insert_attachment($attachment, $new_path);
745 745
 
746 746
 
747
-                // you must first include the image.php file
748
-                // for the function wp_generate_attachment_metadata() to work
749
-                require_once(ABSPATH . 'wp-admin/includes/image.php');
750
-                $attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
751
-                wp_update_attachment_metadata($attach_id, $attach_data);
747
+				// you must first include the image.php file
748
+				// for the function wp_generate_attachment_metadata() to work
749
+				require_once(ABSPATH . 'wp-admin/includes/image.php');
750
+				$attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
751
+				wp_update_attachment_metadata($attach_id, $attach_data);
752 752
 
753
-                if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
754
-                    update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => $attach_id, 'src' => $new_url), 'gd_place');
755
-                }
756
-            }
757
-        }
753
+				if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
754
+					update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => $attach_id, 'src' => $new_url), 'gd_place');
755
+				}
756
+			}
757
+		}
758 758
 
759
-    }
759
+	}
760 760
 }
761 761
 
762 762
 /**
@@ -771,144 +771,144 @@  discard block
 block discarded – undo
771 771
  * @return bool Returns true if saved.
772 772
  */
773 773
 function geodir_update_options($options, $dummy = false) {
774
-    if ((!isset($_POST) || !$_POST) && !$dummy) return false;
774
+	if ((!isset($_POST) || !$_POST) && !$dummy) return false;
775 775
 
776
-    foreach ($options as $value) {
777
-        if ($dummy && isset($value['std']))
778
-            $_POST[$value['id']] = $value['std'];
776
+	foreach ($options as $value) {
777
+		if ($dummy && isset($value['std']))
778
+			$_POST[$value['id']] = $value['std'];
779 779
 
780 780
 
781
-        if (isset($value['type']) && $value['type'] == 'checkbox') :
781
+		if (isset($value['type']) && $value['type'] == 'checkbox') :
782 782
 
783
-            if (isset($value['id']) && isset($_POST[$value['id']])) {
784
-                update_option($value['id'], $_POST[$value['id']]);
785
-            } else {
786
-                update_option($value['id'], 0);
787
-            }
783
+			if (isset($value['id']) && isset($_POST[$value['id']])) {
784
+				update_option($value['id'], $_POST[$value['id']]);
785
+			} else {
786
+				update_option($value['id'], 0);
787
+			}
788 788
 
789
-        elseif (isset($value['type']) && $value['type'] == 'image_width') :
789
+		elseif (isset($value['type']) && $value['type'] == 'image_width') :
790 790
 
791
-            if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
792
-                update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']);
793
-                update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']);
794
-                if (isset($_POST[$value['id'] . '_crop'])) :
795
-                    update_option($value['id'] . '_crop', 1);
796
-                else :
797
-                    update_option($value['id'] . '_crop', 0);
798
-                endif;
799
-            } else {
800
-                update_option($value['id'] . '_width', $value['std']);
801
-                update_option($value['id'] . '_height', $value['std']);
802
-                update_option($value['id'] . '_crop', 1);
803
-            }
791
+			if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
792
+				update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']);
793
+				update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']);
794
+				if (isset($_POST[$value['id'] . '_crop'])) :
795
+					update_option($value['id'] . '_crop', 1);
796
+				else :
797
+					update_option($value['id'] . '_crop', 0);
798
+				endif;
799
+			} else {
800
+				update_option($value['id'] . '_width', $value['std']);
801
+				update_option($value['id'] . '_height', $value['std']);
802
+				update_option($value['id'] . '_crop', 1);
803
+			}
804 804
 
805
-        elseif (isset($value['type']) && $value['type'] == 'map') :
806
-            $post_types = array();
807
-            $categories = array();
805
+		elseif (isset($value['type']) && $value['type'] == 'map') :
806
+			$post_types = array();
807
+			$categories = array();
808 808
 
809
-            if (!empty($_POST['home_map_post_types'])) :
810
-                foreach ($_POST['home_map_post_types'] as $post_type) :
811
-                    $post_types[] = $post_type;
812
-                endforeach;
813
-            endif;
809
+			if (!empty($_POST['home_map_post_types'])) :
810
+				foreach ($_POST['home_map_post_types'] as $post_type) :
811
+					$post_types[] = $post_type;
812
+				endforeach;
813
+			endif;
814 814
 
815
-            update_option('geodir_exclude_post_type_on_map', $post_types);
815
+			update_option('geodir_exclude_post_type_on_map', $post_types);
816 816
 
817
-            if (!empty($_POST['post_category'])) :
818
-                foreach ($_POST['post_category'] as $texonomy => $cat_arr) :
819
-                    $categories[$texonomy] = array();
820
-                    foreach ($cat_arr as $category) :
821
-                        $categories[$texonomy][] = $category;
822
-                    endforeach;
823
-                    $categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array();
824
-                endforeach;
825
-            endif;
826
-            update_option('geodir_exclude_cat_on_map', $categories);
827
-            update_option('geodir_exclude_cat_on_map_upgrade', 1);
828
-        elseif (isset($value['type']) && $value['type'] == 'map_default_settings') :
817
+			if (!empty($_POST['post_category'])) :
818
+				foreach ($_POST['post_category'] as $texonomy => $cat_arr) :
819
+					$categories[$texonomy] = array();
820
+					foreach ($cat_arr as $category) :
821
+						$categories[$texonomy][] = $category;
822
+					endforeach;
823
+					$categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array();
824
+				endforeach;
825
+			endif;
826
+			update_option('geodir_exclude_cat_on_map', $categories);
827
+			update_option('geodir_exclude_cat_on_map_upgrade', 1);
828
+		elseif (isset($value['type']) && $value['type'] == 'map_default_settings') :
829 829
 
830 830
 
831
-            if (!empty($_POST['geodir_default_map_language'])):
832
-                update_option('geodir_default_map_language', $_POST['geodir_default_map_language']);
833
-            endif;
831
+			if (!empty($_POST['geodir_default_map_language'])):
832
+				update_option('geodir_default_map_language', $_POST['geodir_default_map_language']);
833
+			endif;
834 834
 
835 835
 
836
-            if (!empty($_POST['geodir_default_map_search_pt'])):
837
-                update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']);
838
-            endif;
836
+			if (!empty($_POST['geodir_default_map_search_pt'])):
837
+				update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']);
838
+			endif;
839 839
 
840 840
 
841
-        elseif (isset($value['type']) && $value['type'] == 'file') :
841
+		elseif (isset($value['type']) && $value['type'] == 'file') :
842 842
 
843 843
 
844
-            if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
844
+			if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
845 845
 
846
-                if (get_option($value['id'])) {
847
-                    $image_name_arr = explode('/', get_option($value['id']));
848
-                    $noimg_name = end($image_name_arr);
849
-                    $img_path = $uploads['path'] . '/' . $noimg_name;
850
-                    if (file_exists($img_path))
851
-                        unlink($img_path);
852
-                }
846
+				if (get_option($value['id'])) {
847
+					$image_name_arr = explode('/', get_option($value['id']));
848
+					$noimg_name = end($image_name_arr);
849
+					$img_path = $uploads['path'] . '/' . $noimg_name;
850
+					if (file_exists($img_path))
851
+						unlink($img_path);
852
+				}
853 853
 
854
-                update_option($value['id'], '');
855
-            }
854
+				update_option($value['id'], '');
855
+			}
856 856
 
857
-            $uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : '';
858
-            $filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : '';
859
-
860
-            if (!empty($filename)):
861
-                $ext = pathinfo($filename, PATHINFO_EXTENSION);
862
-                $uplaods = array();
863
-
864
-                foreach ($uploadedfile as $key => $uplaod):
865
-                    if ($key == 'name'):
866
-                        $uplaods[$key] = $filename;
867
-                    else :
868
-                        $uplaods[$key] = $uplaod;
869
-                    endif;
870
-                endforeach;
871
-
872
-                $uploads = wp_upload_dir();
873
-
874
-                if (get_option($value['id'])) {
875
-                    $image_name_arr = explode('/', get_option($value['id']));
876
-                    $noimg_name = end($image_name_arr);
877
-                    $img_path = $uploads['path'] . '/' . $noimg_name;
878
-                    if (file_exists($img_path))
879
-                        unlink($img_path);
880
-                }
857
+			$uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : '';
858
+			$filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : '';
859
+
860
+			if (!empty($filename)):
861
+				$ext = pathinfo($filename, PATHINFO_EXTENSION);
862
+				$uplaods = array();
863
+
864
+				foreach ($uploadedfile as $key => $uplaod):
865
+					if ($key == 'name'):
866
+						$uplaods[$key] = $filename;
867
+					else :
868
+						$uplaods[$key] = $uplaod;
869
+					endif;
870
+				endforeach;
871
+
872
+				$uploads = wp_upload_dir();
873
+
874
+				if (get_option($value['id'])) {
875
+					$image_name_arr = explode('/', get_option($value['id']));
876
+					$noimg_name = end($image_name_arr);
877
+					$img_path = $uploads['path'] . '/' . $noimg_name;
878
+					if (file_exists($img_path))
879
+						unlink($img_path);
880
+				}
881 881
 
882
-                $upload_overrides = array('test_form' => false);
883
-                $movefile = wp_handle_upload($uplaods, $upload_overrides);
882
+				$upload_overrides = array('test_form' => false);
883
+				$movefile = wp_handle_upload($uplaods, $upload_overrides);
884 884
 
885
-                update_option($value['id'], $movefile['url']);
885
+				update_option($value['id'], $movefile['url']);
886 886
 
887
-            endif;
887
+			endif;
888 888
 
889
-            if (!get_option($value['id']) && isset($value['value'])):
890
-                update_option($value['id'], $value['value']);
891
-            endif;
889
+			if (!get_option($value['id']) && isset($value['value'])):
890
+				update_option($value['id'], $value['value']);
891
+			endif;
892 892
 
893 893
 
894
-        else :
895
-            // same menu setting per theme.
896
-            if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
897
-                $theme = wp_get_theme();
898
-                update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
899
-            }
894
+		else :
895
+			// same menu setting per theme.
896
+			if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
897
+				$theme = wp_get_theme();
898
+				update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
899
+			}
900 900
 
901
-            if (isset($value['id']) && isset($_POST[$value['id']])) {
902
-                update_option($value['id'], $_POST[$value['id']]);
903
-            } else {
904
-                delete_option($value['id']);
905
-            }
901
+			if (isset($value['id']) && isset($_POST[$value['id']])) {
902
+				update_option($value['id'], $_POST[$value['id']]);
903
+			} else {
904
+				delete_option($value['id']);
905
+			}
906 906
 
907
-        endif;
908
-    }
909
-    if ($dummy)
910
-        $_POST = array();
911
-    return true;
907
+		endif;
908
+	}
909
+	if ($dummy)
910
+		$_POST = array();
911
+	return true;
912 912
 
913 913
 }
914 914
 
@@ -957,33 +957,33 @@  discard block
 block discarded – undo
957 957
 function places_custom_fields_tab($tabs)
958 958
 {
959 959
 
960
-    $geodir_post_types = get_option('geodir_post_types');
960
+	$geodir_post_types = get_option('geodir_post_types');
961 961
 
962
-    if (!empty($geodir_post_types)) {
962
+	if (!empty($geodir_post_types)) {
963 963
 
964
-        foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info):
964
+		foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info):
965 965
 
966
-            $listing_slug = $geodir_posttype_info['labels']['singular_name'];
966
+			$listing_slug = $geodir_posttype_info['labels']['singular_name'];
967 967
 
968
-            $tabs[$geodir_post_type . '_fields_settings'] = array(
969
-                'label' => __(ucfirst($listing_slug) . ' Settings', 'geodirectory'),
970
-                'subtabs' => array(
971
-                    array('subtab' => 'custom_fields',
972
-                        'label' => __('Custom Fields', 'geodirectory'),
973
-                        'request' => array('listing_type' => $geodir_post_type)),
974
-                    array('subtab' => 'sorting_options',
975
-                        'label' => __('Sorting Options', 'geodirectory'),
976
-                        'request' => array('listing_type' => $geodir_post_type)),
977
-                ),
978
-                'tab_index' => 9,
979
-                'request' => array('listing_type' => $geodir_post_type)
980
-            );
968
+			$tabs[$geodir_post_type . '_fields_settings'] = array(
969
+				'label' => __(ucfirst($listing_slug) . ' Settings', 'geodirectory'),
970
+				'subtabs' => array(
971
+					array('subtab' => 'custom_fields',
972
+						'label' => __('Custom Fields', 'geodirectory'),
973
+						'request' => array('listing_type' => $geodir_post_type)),
974
+					array('subtab' => 'sorting_options',
975
+						'label' => __('Sorting Options', 'geodirectory'),
976
+						'request' => array('listing_type' => $geodir_post_type)),
977
+				),
978
+				'tab_index' => 9,
979
+				'request' => array('listing_type' => $geodir_post_type)
980
+			);
981 981
 
982
-        endforeach;
982
+		endforeach;
983 983
 
984
-    }
984
+	}
985 985
 
986
-    return $tabs;
986
+	return $tabs;
987 987
 }
988 988
 
989 989
 
@@ -999,8 +999,8 @@  discard block
 block discarded – undo
999 999
  */
1000 1000
 function geodir_tools_setting_tab($tabs)
1001 1001
 {
1002
-    $tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
1003
-    return $tabs;
1002
+	$tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
1003
+	return $tabs;
1004 1004
 }
1005 1005
 
1006 1006
 /**
@@ -1015,8 +1015,8 @@  discard block
 block discarded – undo
1015 1015
  */
1016 1016
 function geodir_compatibility_setting_tab($tabs)
1017 1017
 {
1018
-    $tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory'));
1019
-    return $tabs;
1018
+	$tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory'));
1019
+	return $tabs;
1020 1020
 }
1021 1021
 
1022 1022
 
@@ -1032,144 +1032,144 @@  discard block
 block discarded – undo
1032 1032
  */
1033 1033
 function geodir_extend_geodirectory_setting_tab($tabs)
1034 1034
 {
1035
-    $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
1036
-    return $tabs;
1035
+	$tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
1036
+	return $tabs;
1037 1037
 }
1038 1038
 
1039 1039
 
1040 1040
 if (!function_exists('geodir_edit_post_columns')) {
1041
-    /**
1042
-     * Modify admin post listing page columns.
1043
-     *
1044
-     * @since 1.0.0
1045
-     * @package GeoDirectory
1046
-     * @param array $columns The column array.
1047
-     * @return array Altered column array.
1048
-     */
1049
-    function geodir_edit_post_columns($columns)
1050
-    {
1051
-
1052
-        $new_columns = array('location' => __('Location (ID)', 'geodirectory'),
1053
-            'categorys' => __('Categories', 'geodirectory'));
1054
-
1055
-        if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
1056
-        {
1057
-            $offset = 0; // should we prepend $array with $data?
1058
-            $offset = count($columns); // or should we append $array with $data? lets pick this one...
1059
-        }
1041
+	/**
1042
+	 * Modify admin post listing page columns.
1043
+	 *
1044
+	 * @since 1.0.0
1045
+	 * @package GeoDirectory
1046
+	 * @param array $columns The column array.
1047
+	 * @return array Altered column array.
1048
+	 */
1049
+	function geodir_edit_post_columns($columns)
1050
+	{
1060 1051
 
1061
-        $columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset));
1052
+		$new_columns = array('location' => __('Location (ID)', 'geodirectory'),
1053
+			'categorys' => __('Categories', 'geodirectory'));
1062 1054
 
1063
-        $columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory')));
1055
+		if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
1056
+		{
1057
+			$offset = 0; // should we prepend $array with $data?
1058
+			$offset = count($columns); // or should we append $array with $data? lets pick this one...
1059
+		}
1064 1060
 
1065
-        return $columns;
1066
-    }
1061
+		$columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset));
1062
+
1063
+		$columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory')));
1064
+
1065
+		return $columns;
1066
+	}
1067 1067
 }
1068 1068
 
1069 1069
 
1070 1070
 if (!function_exists('geodir_manage_post_columns')) {
1071
-    /**
1072
-     * Adds content to our custom post listing page columns.
1073
-     *
1074
-     * @since 1.0.0
1075
-     * @package GeoDirectory
1076
-     * @global object $wpdb WordPress Database object.
1077
-     * @global object $post WordPress Post object.
1078
-     * @param string $column The column name.
1079
-     * @param int $post_id The post ID.
1080
-     */
1081
-    function geodir_manage_post_columns($column, $post_id)
1082
-    {
1083
-        global $post, $wpdb;
1084
-
1085
-        switch ($column):
1086
-            /* If displaying the 'city' column. */
1087
-            case 'location' :
1088
-                $location_id = geodir_get_post_meta($post->ID, 'post_location_id', true);
1089
-                $location = geodir_get_location($location_id);
1090
-                /* If no city is found, output a default message. */
1091
-                if (empty($location)) {
1092
-                    _e('Unknown', 'geodirectory');
1093
-                } else {
1094
-                    /* If there is a city id, append 'city name' to the text string. */
1095
-                    $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
1096
-                    echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id);
1097
-                }
1098
-                break;
1099
-
1100
-            /* If displaying the 'expire' column. */
1101
-            case 'expire' :
1102
-                $expire_date = geodir_get_post_meta($post->ID, 'expire_date', true);
1103
-                $d1 = $expire_date; // get expire_date
1104
-                $d2 = date('Y-m-d'); // get current date
1105
-                $state = __('days left', 'geodirectory');
1106
-                $date_diff_text = '';
1107
-                $expire_class = 'expire_left';
1108
-                if ($expire_date != 'Never') {
1109
-                    if (strtotime($d1) < strtotime($d2)) {
1110
-                        $state = __('days overdue', 'geodirectory');
1111
-                        $expire_class = 'expire_over';
1112
-                    }
1113
-                    $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days
1114
-                    $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
1115
-                }
1116
-                /* If no expire_date is found, output a default message. */
1117
-                if (empty($expire_date))
1118
-                    echo __('Unknown', 'geodirectory');
1119
-                /* If there is a expire_date, append 'days left' to the text string. */
1120
-                else
1121
-                    echo $expire_date . $date_diff_text;
1122
-                break;
1123
-
1124
-            /* If displaying the 'categorys' column. */
1125
-            case 'categorys' :
1126
-
1127
-                /* Get the categorys for the post. */
1128
-
1129
-
1130
-                $terms = wp_get_object_terms($post_id, get_object_taxonomies($post));
1131
-
1132
-                /* If terms were found. */
1133
-                if (!empty($terms)) {
1134
-                    $out = array();
1135
-                    /* Loop through each term, linking to the 'edit posts' page for the specific term. */
1136
-                    foreach ($terms as $term) {
1137
-                        if (!strstr($term->taxonomy, 'tag')) {
1138
-                            $out[] = sprintf('<a href="%s">%s</a>',
1139
-                                esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')),
1140
-                                esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display'))
1141
-                            );
1142
-                        }
1143
-                    }
1144
-                    /* Join the terms, separating them with a comma. */
1145
-                    echo(join(', ', $out));
1146
-                } /* If no terms were found, output a default message. */
1147
-                else {
1148
-                    _e('No Categories', 'geodirectory');
1149
-                }
1150
-                break;
1071
+	/**
1072
+	 * Adds content to our custom post listing page columns.
1073
+	 *
1074
+	 * @since 1.0.0
1075
+	 * @package GeoDirectory
1076
+	 * @global object $wpdb WordPress Database object.
1077
+	 * @global object $post WordPress Post object.
1078
+	 * @param string $column The column name.
1079
+	 * @param int $post_id The post ID.
1080
+	 */
1081
+	function geodir_manage_post_columns($column, $post_id)
1082
+	{
1083
+		global $post, $wpdb;
1084
+
1085
+		switch ($column):
1086
+			/* If displaying the 'city' column. */
1087
+			case 'location' :
1088
+				$location_id = geodir_get_post_meta($post->ID, 'post_location_id', true);
1089
+				$location = geodir_get_location($location_id);
1090
+				/* If no city is found, output a default message. */
1091
+				if (empty($location)) {
1092
+					_e('Unknown', 'geodirectory');
1093
+				} else {
1094
+					/* If there is a city id, append 'city name' to the text string. */
1095
+					$add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
1096
+					echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id);
1097
+				}
1098
+				break;
1099
+
1100
+			/* If displaying the 'expire' column. */
1101
+			case 'expire' :
1102
+				$expire_date = geodir_get_post_meta($post->ID, 'expire_date', true);
1103
+				$d1 = $expire_date; // get expire_date
1104
+				$d2 = date('Y-m-d'); // get current date
1105
+				$state = __('days left', 'geodirectory');
1106
+				$date_diff_text = '';
1107
+				$expire_class = 'expire_left';
1108
+				if ($expire_date != 'Never') {
1109
+					if (strtotime($d1) < strtotime($d2)) {
1110
+						$state = __('days overdue', 'geodirectory');
1111
+						$expire_class = 'expire_over';
1112
+					}
1113
+					$date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days
1114
+					$date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
1115
+				}
1116
+				/* If no expire_date is found, output a default message. */
1117
+				if (empty($expire_date))
1118
+					echo __('Unknown', 'geodirectory');
1119
+				/* If there is a expire_date, append 'days left' to the text string. */
1120
+				else
1121
+					echo $expire_date . $date_diff_text;
1122
+				break;
1151 1123
 
1152
-        endswitch;
1153
-    }
1124
+			/* If displaying the 'categorys' column. */
1125
+			case 'categorys' :
1126
+
1127
+				/* Get the categorys for the post. */
1128
+
1129
+
1130
+				$terms = wp_get_object_terms($post_id, get_object_taxonomies($post));
1131
+
1132
+				/* If terms were found. */
1133
+				if (!empty($terms)) {
1134
+					$out = array();
1135
+					/* Loop through each term, linking to the 'edit posts' page for the specific term. */
1136
+					foreach ($terms as $term) {
1137
+						if (!strstr($term->taxonomy, 'tag')) {
1138
+							$out[] = sprintf('<a href="%s">%s</a>',
1139
+								esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')),
1140
+								esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display'))
1141
+							);
1142
+						}
1143
+					}
1144
+					/* Join the terms, separating them with a comma. */
1145
+					echo(join(', ', $out));
1146
+				} /* If no terms were found, output a default message. */
1147
+				else {
1148
+					_e('No Categories', 'geodirectory');
1149
+				}
1150
+				break;
1151
+
1152
+		endswitch;
1153
+	}
1154 1154
 }
1155 1155
 
1156 1156
 
1157 1157
 if (!function_exists('geodir_post_sortable_columns')) {
1158
-    /**
1159
-     * Makes admin post listing page columns sortable.
1160
-     *
1161
-     * @since 1.0.0
1162
-     * @package GeoDirectory
1163
-     * @param array $columns The column array.
1164
-     * @return array Altered column array.
1165
-     */
1166
-    function geodir_post_sortable_columns($columns)
1167
-    {
1168
-
1169
-        $columns['expire'] = 'expire';
1170
-
1171
-        return $columns;
1172
-    }
1158
+	/**
1159
+	 * Makes admin post listing page columns sortable.
1160
+	 *
1161
+	 * @since 1.0.0
1162
+	 * @package GeoDirectory
1163
+	 * @param array $columns The column array.
1164
+	 * @return array Altered column array.
1165
+	 */
1166
+	function geodir_post_sortable_columns($columns)
1167
+	{
1168
+
1169
+		$columns['expire'] = 'expire';
1170
+
1171
+		return $columns;
1172
+	}
1173 1173
 }
1174 1174
 
1175 1175
 /**
@@ -1183,32 +1183,32 @@  discard block
 block discarded – undo
1183 1183
  * @param int $post_id The post ID.
1184 1184
  */
1185 1185
 function geodir_post_information_save($post_id, $post) {
1186
-    global $wpdb, $current_user;
1186
+	global $wpdb, $current_user;
1187 1187
 
1188
-    if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
1189
-        return;
1190
-    }
1188
+	if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
1189
+		return;
1190
+	}
1191 1191
 
1192
-    $geodir_posttypes = geodir_get_posttypes();
1192
+	$geodir_posttypes = geodir_get_posttypes();
1193 1193
 
1194
-    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
1195
-        return;
1194
+	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
1195
+		return;
1196 1196
 
1197
-    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']);
1197
+	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']);
1200 1200
 
1201
-        if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash'))
1202
-            return;
1201
+		if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash'))
1202
+			return;
1203 1203
 
1204
-        if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__)))
1205
-            return;
1204
+		if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__)))
1205
+			return;
1206 1206
 
1207
-        if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__)))
1208
-            return;
1207
+		if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__)))
1208
+			return;
1209 1209
 
1210
-        geodir_save_listing($_REQUEST);
1211
-    }
1210
+		geodir_save_listing($_REQUEST);
1211
+	}
1212 1212
 }
1213 1213
 
1214 1214
 /**
@@ -1224,102 +1224,102 @@  discard block
 block discarded – undo
1224 1224
  */
1225 1225
 function geodir_admin_fields($options)
1226 1226
 {
1227
-    global $geodirectory;
1228
-
1229
-    $first_title = true;
1230
-    $tab_id = '';
1231
-    $i = 0;
1232
-    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'] = '';
1237
-        $desc = '';
1238
-        switch ($value['type']) :
1239
-            case 'dummy_installer':
1240
-                $post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place';
1241
-                geodir_autoinstall_admin_header($post_type);
1242
-                break;
1243
-            case 'title':
1244
-
1245
-                if ($i == 0) {
1246
-                    echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>';
1247
-                    echo '<div class="inner_content_tab_main">';
1248
-                }
1227
+	global $geodirectory;
1228
+
1229
+	$first_title = true;
1230
+	$tab_id = '';
1231
+	$i = 0;
1232
+	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'] = '';
1237
+		$desc = '';
1238
+		switch ($value['type']) :
1239
+			case 'dummy_installer':
1240
+				$post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place';
1241
+				geodir_autoinstall_admin_header($post_type);
1242
+				break;
1243
+			case 'title':
1244
+
1245
+				if ($i == 0) {
1246
+					echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>';
1247
+					echo '<div class="inner_content_tab_main">';
1248
+				}
1249 1249
 
1250
-                $i++;
1250
+				$i++;
1251 1251
 
1252
-                if (isset($value['id']) && $value['id'])
1253
-                    $tab_id = $value['id'];
1252
+				if (isset($value['id']) && $value['id'])
1253
+					$tab_id = $value['id'];
1254 1254
 
1255
-                if (isset($value['desc']) && $value['desc'])
1256
-                    $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>';
1255
+				if (isset($value['desc']) && $value['desc'])
1256
+					$desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>';
1257 1257
 
1258
-                if (isset($value['name']) && $value['name']) {
1259
-                    if ($first_title === true) {
1260
-                        $first_title = false;
1261
-                    } else {
1262
-                        echo '</div>';
1263
-                    }
1264
-                    echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>';
1258
+				if (isset($value['name']) && $value['name']) {
1259
+					if ($first_title === true) {
1260
+						$first_title = false;
1261
+					} else {
1262
+						echo '</div>';
1263
+					}
1264
+					echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>';
1265 1265
 
1266
-                    echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
1267
-                }
1266
+					echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
1267
+				}
1268 1268
 
1269
-                /**
1270
-                 * Called after a GeoDirectory settings title is output in the GD settings page.
1271
-                 *
1272
-                 * The action is called dynamically geodir_settings_$value['id'].
1273
-                 *
1274
-                 * @since 1.0.0
1275
-                 */
1276
-                do_action('geodir_settings_' . sanitize_title($value['id']));
1277
-                break;
1278
-
1279
-            case 'no_tabs':
1280
-
1281
-                echo '<div class="inner_content_tab_main">';
1282
-                echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
1283
-
1284
-                break;
1285
-
1286
-            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>';
1291
-                /**
1292
-                 * Called after a GeoDirectory settings sectionstart is output in the GD settings page.
1293
-                 *
1294
-                 * The action is called dynamically geodir_settings_$value['id']_start.
1295
-                 *
1296
-                 * @since 1.0.0
1297
-                 */
1298
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
1299
-                echo '<table class="form-table">' . "\n\n";
1300
-
1301
-                break;
1302
-            case 'sectionend':
1303
-                /**
1304
-                 * Called before a GeoDirectory settings sectionend is output in the GD settings page.
1305
-                 *
1306
-                 * The action is called dynamically geodir_settings_$value['id']_end.
1307
-                 *
1308
-                 * @since 1.0.0
1309
-                 */
1310
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
1311
-                echo '</table>';
1312
-                /**
1313
-                 * Called after a GeoDirectory settings sectionend is output in the GD settings page.
1314
-                 *
1315
-                 * The action is called dynamically geodir_settings_$value['id']_end.
1316
-                 *
1317
-                 * @since 1.0.0
1318
-                 */
1319
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
1320
-                break;
1321
-            case 'text':
1322
-                ?>
1269
+				/**
1270
+				 * Called after a GeoDirectory settings title is output in the GD settings page.
1271
+				 *
1272
+				 * The action is called dynamically geodir_settings_$value['id'].
1273
+				 *
1274
+				 * @since 1.0.0
1275
+				 */
1276
+				do_action('geodir_settings_' . sanitize_title($value['id']));
1277
+				break;
1278
+
1279
+			case 'no_tabs':
1280
+
1281
+				echo '<div class="inner_content_tab_main">';
1282
+				echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
1283
+
1284
+				break;
1285
+
1286
+			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>';
1291
+				/**
1292
+				 * Called after a GeoDirectory settings sectionstart is output in the GD settings page.
1293
+				 *
1294
+				 * The action is called dynamically geodir_settings_$value['id']_start.
1295
+				 *
1296
+				 * @since 1.0.0
1297
+				 */
1298
+				if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
1299
+				echo '<table class="form-table">' . "\n\n";
1300
+
1301
+				break;
1302
+			case 'sectionend':
1303
+				/**
1304
+				 * Called before a GeoDirectory settings sectionend is output in the GD settings page.
1305
+				 *
1306
+				 * The action is called dynamically geodir_settings_$value['id']_end.
1307
+				 *
1308
+				 * @since 1.0.0
1309
+				 */
1310
+				if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
1311
+				echo '</table>';
1312
+				/**
1313
+				 * Called after a GeoDirectory settings sectionend is output in the GD settings page.
1314
+				 *
1315
+				 * The action is called dynamically geodir_settings_$value['id']_end.
1316
+				 *
1317
+				 * @since 1.0.0
1318
+				 */
1319
+				if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
1320
+				break;
1321
+			case 'text':
1322
+				?>
1323 1323
                 <tr valign="top">
1324 1324
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1325 1325
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
@@ -1328,15 +1328,15 @@  discard block
 block discarded – undo
1328 1328
                                            <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1329 1329
                                            style=" <?php echo esc_attr($value['css']); ?>"
1330 1330
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1331
-                                               echo esc_attr(stripslashes(get_option($value['id'])));
1332
-                                           } else {
1333
-                                               echo esc_attr($value['std']);
1334
-                                           } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
1331
+											   echo esc_attr(stripslashes(get_option($value['id'])));
1332
+										   } else {
1333
+											   echo esc_attr($value['std']);
1334
+										   } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
1335 1335
                 </tr><?php
1336
-                break;
1336
+				break;
1337 1337
 
1338
-            case 'password':
1339
-                ?>
1338
+			case 'password':
1339
+				?>
1340 1340
                 <tr valign="top">
1341 1341
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1342 1342
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
@@ -1345,42 +1345,42 @@  discard block
 block discarded – undo
1345 1345
                                            <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1346 1346
                                            style="<?php echo esc_attr($value['css']); ?>"
1347 1347
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1348
-                                               echo esc_attr(stripslashes(get_option($value['id'])));
1349
-                                           } else {
1350
-                                               echo esc_attr($value['std']);
1351
-                                           } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
1348
+											   echo esc_attr(stripslashes(get_option($value['id'])));
1349
+										   } else {
1350
+											   echo esc_attr($value['std']);
1351
+										   } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td>
1352 1352
                 </tr><?php
1353
-                break;
1353
+				break;
1354 1354
 
1355
-            case 'html_content':
1356
-                ?>
1355
+			case 'html_content':
1356
+				?>
1357 1357
                 <tr valign="top">
1358 1358
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1359 1359
                 <td class="forminp"><span class="description"><?php echo $value['desc']; ?></span></td>
1360 1360
                 </tr><?php
1361
-                break;
1361
+				break;
1362 1362
 
1363
-            case 'color' :
1364
-                ?>
1363
+			case 'color' :
1364
+				?>
1365 1365
                 <tr valign="top">
1366 1366
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1367 1367
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
1368 1368
                                            id="<?php echo esc_attr($value['id']); ?>" type="text"
1369 1369
                                            style="<?php echo esc_attr($value['css']); ?>"
1370 1370
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1371
-                                               echo esc_attr(stripslashes(get_option($value['id'])));
1372
-                                           } else {
1373
-                                               echo esc_attr($value['std']);
1374
-                                           } ?>" class="colorpick"/> <span
1371
+											   echo esc_attr(stripslashes(get_option($value['id'])));
1372
+										   } else {
1373
+											   echo esc_attr($value['std']);
1374
+										   } ?>" class="colorpick"/> <span
1375 1375
                         class="description"><?php echo $value['desc']; ?></span>
1376 1376
 
1377 1377
                     <div id="colorPickerDiv_<?php echo esc_attr($value['id']); ?>" class="colorpickdiv"
1378 1378
                          style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div>
1379 1379
                 </td>
1380 1380
                 </tr><?php
1381
-                break;
1382
-            case 'image_width' :
1383
-                ?>
1381
+				break;
1382
+			case 'image_width' :
1383
+				?>
1384 1384
                 <tr valign="top">
1385 1385
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1386 1386
                 <td class="forminp">
@@ -1402,11 +1402,11 @@  discard block
 block discarded – undo
1402 1402
 
1403 1403
                     <span class="description"><?php echo $value['desc'] ?></span></td>
1404 1404
                 </tr><?php
1405
-                break;
1406
-            case 'select':
1407
-                $option_value = get_option($value['id']);
1408
-                $option_value = !empty($option_value) ? stripslashes_deep($option_value) : $option_value;
1409
-                ?>
1405
+				break;
1406
+			case 'select':
1407
+				$option_value = get_option($value['id']);
1408
+				$option_value = !empty($option_value) ? stripslashes_deep($option_value) : $option_value;
1409
+				?>
1410 1410
                 <tr valign="top">
1411 1411
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1412 1412
                 <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>"
@@ -1415,33 +1415,33 @@  discard block
 block discarded – undo
1415 1415
                                             class="<?php if (isset($value['class'])) echo $value['class']; ?>"
1416 1416
                                             option-ajaxchosen="false">
1417 1417
                         <?php
1418
-                        foreach ($value['options'] as $key => $val) {
1419
-                            $geodir_select_value = '';
1420
-                            if ($option_value != '') {
1421
-                                if ($option_value != '' && $option_value == $key)
1422
-                                    $geodir_select_value = ' selected="selected" ';
1423
-                            } else {
1424
-                                if ($value['std'] == $key)
1425
-                                    $geodir_select_value = ' selected="selected" ';
1426
-                            }
1427
-                            ?>
1418
+						foreach ($value['options'] as $key => $val) {
1419
+							$geodir_select_value = '';
1420
+							if ($option_value != '') {
1421
+								if ($option_value != '' && $option_value == $key)
1422
+									$geodir_select_value = ' selected="selected" ';
1423
+							} else {
1424
+								if ($value['std'] == $key)
1425
+									$geodir_select_value = ' selected="selected" ';
1426
+							}
1427
+							?>
1428 1428
                             <option
1429 1429
                                 value="<?php echo esc_attr($key); ?>" <?php echo $geodir_select_value; ?> ><?php echo ucfirst($val) ?></option>
1430 1430
                         <?php
1431
-                        }
1432
-                        ?>
1431
+						}
1432
+						?>
1433 1433
                     </select> <span class="description"><?php echo $value['desc'] ?></span>
1434 1434
                 </td>
1435 1435
                 </tr><?php
1436
-                break;
1436
+				break;
1437 1437
 
1438
-            case 'multiselect':
1439
-                $option_values = get_option($value['id']);
1440
-                if ($option_values === '' && !empty($value['std']) && is_array($value['std'])) {
1441
-                   $option_values = $value['std'];
1442
-                }
1443
-                $option_values = !empty($option_values) ? stripslashes_deep($option_values) : $option_values;
1444
-                ?>
1438
+			case 'multiselect':
1439
+				$option_values = get_option($value['id']);
1440
+				if ($option_values === '' && !empty($value['std']) && is_array($value['std'])) {
1441
+				   $option_values = $value['std'];
1442
+				}
1443
+				$option_values = !empty($option_values) ? stripslashes_deep($option_values) : $option_values;
1444
+				?>
1445 1445
                 <tr valign="top">
1446 1446
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1447 1447
                 <td class="forminp"><select multiple="multiple" name="<?php echo esc_attr($value['id']); ?>[]"
@@ -1451,25 +1451,25 @@  discard block
 block discarded – undo
1451 1451
                                             data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>"
1452 1452
                                             option-ajaxchosen="false">
1453 1453
                         <?php
1454
-                        foreach ($value['options'] as $key => $val) {
1455
-                            if (strpos($key, 'optgroup_start-') === 0) {
1456
-                                ?><optgroup label="<?php echo ucfirst($val); ?>"><?php
1457
-                            } else if (strpos($key, 'optgroup_end-') === 0) {
1458
-                                ?></optgroup><?php
1459
-                            } else {
1460
-                                ?>
1454
+						foreach ($value['options'] as $key => $val) {
1455
+							if (strpos($key, 'optgroup_start-') === 0) {
1456
+								?><optgroup label="<?php echo ucfirst($val); ?>"><?php
1457
+							} else if (strpos($key, 'optgroup_end-') === 0) {
1458
+								?></optgroup><?php
1459
+							} else {
1460
+								?>
1461 1461
                                 <option
1462 1462
                                     value="<?php echo esc_attr($key); ?>" <?php selected(true, (is_array($option_values) && in_array($key, $option_values)));?>><?php echo ucfirst($val) ?></option>
1463 1463
                             <?php
1464
-                            }
1465
-                        }
1466
-                        ?>
1464
+							}
1465
+						}
1466
+						?>
1467 1467
                     </select> <span class="description"><?php echo $value['desc'] ?></span>
1468 1468
                 </td>
1469 1469
                 </tr><?php
1470
-                break;
1471
-            case 'file':
1472
-                ?>
1470
+				break;
1471
+			case 'file':
1472
+				?>
1473 1473
                 <tr valign="top">
1474 1474
                 <th scope="row" class="titledesc"><?php echo $value['name']; ?></th>
1475 1475
                 <td class="forminp">
@@ -1489,87 +1489,87 @@  discard block
 block discarded – undo
1489 1489
                     <?php } ?>
1490 1490
                 </td>
1491 1491
                 </tr><?php
1492
-                break;
1493
-            case 'map_default_settings' :
1494
-                ?>
1492
+				break;
1493
+			case 'map_default_settings' :
1494
+				?>
1495 1495
 
1496 1496
                 <tr valign="top">
1497 1497
                     <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory');?></th>
1498 1498
                     <td width="60%">
1499 1499
                         <select name="geodir_default_map_language" style="width:60%">
1500 1500
                             <?php
1501
-                            $arr_map_langages = array(
1502
-                                'ar' => __('ARABIC', 'geodirectory'),
1503
-                                'eu' => __('BASQUE', 'geodirectory'),
1504
-                                'bg' => __('BULGARIAN', 'geodirectory'),
1505
-                                'bn' => __('BENGALI', 'geodirectory'),
1506
-                                'ca' => __('CATALAN', 'geodirectory'),
1507
-                                'cs' => __('CZECH', 'geodirectory'),
1508
-                                'da' => __('DANISH', 'geodirectory'),
1509
-                                'de' => __('GERMAN', 'geodirectory'),
1510
-                                'el' => __('GREEK', 'geodirectory'),
1511
-                                'en' => __('ENGLISH', 'geodirectory'),
1512
-                                'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'),
1513
-                                'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'),
1514
-                                'es' => __('SPANISH', 'geodirectory'),
1515
-                                'eu' => __('BASQUE', 'geodirectory'),
1516
-                                'fa' => __('FARSI', 'geodirectory'),
1517
-                                'fi' => __('FINNISH', 'geodirectory'),
1518
-                                'fil' => __('FILIPINO', 'geodirectory'),
1519
-                                'fr' => __('FRENCH', 'geodirectory'),
1520
-                                'gl' => __('GALICIAN', 'geodirectory'),
1521
-                                'gu' => __('GUJARATI', 'geodirectory'),
1522
-                                'hi' => __('HINDI', 'geodirectory'),
1523
-                                'hr' => __('CROATIAN', 'geodirectory'),
1524
-                                'hu' => __('HUNGARIAN', 'geodirectory'),
1525
-                                'id' => __('INDONESIAN', 'geodirectory'),
1526
-                                'it' => __('ITALIAN', 'geodirectory'),
1527
-                                'iw' => __('HEBREW', 'geodirectory'),
1528
-                                'ja' => __('JAPANESE', 'geodirectory'),
1529
-                                'kn' => __('KANNADA', 'geodirectory'),
1530
-                                'ko' => __('KOREAN', 'geodirectory'),
1531
-                                'lt' => __('LITHUANIAN', 'geodirectory'),
1532
-                                'lv' => __('LATVIAN', 'geodirectory'),
1533
-                                'ml' => __('MALAYALAM', 'geodirectory'),
1534
-                                'mr' => __('MARATHI', 'geodirectory'),
1535
-                                'nl' => __('DUTCH', 'geodirectory'),
1536
-                                'no' => __('NORWEGIAN', 'geodirectory'),
1537
-                                'pl' => __('POLISH', 'geodirectory'),
1538
-                                'pt' => __('PORTUGUESE', 'geodirectory'),
1539
-                                'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'),
1540
-                                'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'),
1541
-                                'ro' => __('ROMANIAN', 'geodirectory'),
1542
-                                'ru' => __('RUSSIAN', 'geodirectory'),
1543
-                                'ru' => __('RUSSIAN', 'geodirectory'),
1544
-                                'sk' => __('SLOVAK', 'geodirectory'),
1545
-                                'sl' => __('SLOVENIAN', 'geodirectory'),
1546
-                                'sr' => __('SERBIAN', 'geodirectory'),
1547
-                                'sv' => __('	SWEDISH', 'geodirectory'),
1548
-                                'tl' => __('TAGALOG', 'geodirectory'),
1549
-                                'ta' => __('TAMIL', 'geodirectory'),
1550
-                                'te' => __('TELUGU', 'geodirectory'),
1551
-                                'th' => __('THAI', 'geodirectory'),
1552
-                                'tr' => __('TURKISH', 'geodirectory'),
1553
-                                'uk' => __('UKRAINIAN', 'geodirectory'),
1554
-                                'vi' => __('VIETNAMESE', 'geodirectory'),
1555
-                                'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'),
1556
-                                'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
1557
-                            );
1558
-                            $geodir_default_map_language = get_option('geodir_default_map_language');
1559
-                            if (empty($geodir_default_map_language))
1560
-                                $geodir_default_map_language = 'en';
1561
-                            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 = '';
1566
-
1567
-                                ?>
1501
+							$arr_map_langages = array(
1502
+								'ar' => __('ARABIC', 'geodirectory'),
1503
+								'eu' => __('BASQUE', 'geodirectory'),
1504
+								'bg' => __('BULGARIAN', 'geodirectory'),
1505
+								'bn' => __('BENGALI', 'geodirectory'),
1506
+								'ca' => __('CATALAN', 'geodirectory'),
1507
+								'cs' => __('CZECH', 'geodirectory'),
1508
+								'da' => __('DANISH', 'geodirectory'),
1509
+								'de' => __('GERMAN', 'geodirectory'),
1510
+								'el' => __('GREEK', 'geodirectory'),
1511
+								'en' => __('ENGLISH', 'geodirectory'),
1512
+								'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'),
1513
+								'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'),
1514
+								'es' => __('SPANISH', 'geodirectory'),
1515
+								'eu' => __('BASQUE', 'geodirectory'),
1516
+								'fa' => __('FARSI', 'geodirectory'),
1517
+								'fi' => __('FINNISH', 'geodirectory'),
1518
+								'fil' => __('FILIPINO', 'geodirectory'),
1519
+								'fr' => __('FRENCH', 'geodirectory'),
1520
+								'gl' => __('GALICIAN', 'geodirectory'),
1521
+								'gu' => __('GUJARATI', 'geodirectory'),
1522
+								'hi' => __('HINDI', 'geodirectory'),
1523
+								'hr' => __('CROATIAN', 'geodirectory'),
1524
+								'hu' => __('HUNGARIAN', 'geodirectory'),
1525
+								'id' => __('INDONESIAN', 'geodirectory'),
1526
+								'it' => __('ITALIAN', 'geodirectory'),
1527
+								'iw' => __('HEBREW', 'geodirectory'),
1528
+								'ja' => __('JAPANESE', 'geodirectory'),
1529
+								'kn' => __('KANNADA', 'geodirectory'),
1530
+								'ko' => __('KOREAN', 'geodirectory'),
1531
+								'lt' => __('LITHUANIAN', 'geodirectory'),
1532
+								'lv' => __('LATVIAN', 'geodirectory'),
1533
+								'ml' => __('MALAYALAM', 'geodirectory'),
1534
+								'mr' => __('MARATHI', 'geodirectory'),
1535
+								'nl' => __('DUTCH', 'geodirectory'),
1536
+								'no' => __('NORWEGIAN', 'geodirectory'),
1537
+								'pl' => __('POLISH', 'geodirectory'),
1538
+								'pt' => __('PORTUGUESE', 'geodirectory'),
1539
+								'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'),
1540
+								'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'),
1541
+								'ro' => __('ROMANIAN', 'geodirectory'),
1542
+								'ru' => __('RUSSIAN', 'geodirectory'),
1543
+								'ru' => __('RUSSIAN', 'geodirectory'),
1544
+								'sk' => __('SLOVAK', 'geodirectory'),
1545
+								'sl' => __('SLOVENIAN', 'geodirectory'),
1546
+								'sr' => __('SERBIAN', 'geodirectory'),
1547
+								'sv' => __('	SWEDISH', 'geodirectory'),
1548
+								'tl' => __('TAGALOG', 'geodirectory'),
1549
+								'ta' => __('TAMIL', 'geodirectory'),
1550
+								'te' => __('TELUGU', 'geodirectory'),
1551
+								'th' => __('THAI', 'geodirectory'),
1552
+								'tr' => __('TURKISH', 'geodirectory'),
1553
+								'uk' => __('UKRAINIAN', 'geodirectory'),
1554
+								'vi' => __('VIETNAMESE', 'geodirectory'),
1555
+								'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'),
1556
+								'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
1557
+							);
1558
+							$geodir_default_map_language = get_option('geodir_default_map_language');
1559
+							if (empty($geodir_default_map_language))
1560
+								$geodir_default_map_language = 'en';
1561
+							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 = '';
1566
+
1567
+								?>
1568 1568
                                 <option
1569 1569
                                     value="<?php echo $language_key?>" <?php echo $geodir_default_language_selected; ?>><?php echo $language_txt; ?></option>
1570 1570
 
1571 1571
                             <?php }
1572
-                            ?>
1572
+							?>
1573 1573
                         </select>
1574 1574
                     </td>
1575 1575
                 </tr>
@@ -1580,46 +1580,46 @@  discard block
 block discarded – undo
1580 1580
                     <td width="60%">
1581 1581
                         <select name="geodir_default_map_search_pt" style="width:60%">
1582 1582
                             <?php
1583
-                            $post_types = geodir_get_posttypes('array');
1584
-                            $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';
1587
-                            if (is_array($post_types)) {
1588
-                                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 = '';
1593
-
1594
-                                    ?>
1583
+							$post_types = geodir_get_posttypes('array');
1584
+							$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';
1587
+							if (is_array($post_types)) {
1588
+								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 = '';
1593
+
1594
+									?>
1595 1595
                                     <option
1596 1596
                                         value="<?php echo $key?>" <?php echo $geodir_search_pt_selected; ?>><?php echo $post_types_obj['labels']['singular_name']; ?></option>
1597 1597
 
1598 1598
                                 <?php }
1599 1599
 
1600
-                            }
1600
+							}
1601 1601
 
1602
-                            ?>
1602
+							?>
1603 1603
                         </select>
1604 1604
                     </td>
1605 1605
                 </tr>
1606 1606
 
1607 1607
                 <?php
1608
-                break;
1608
+				break;
1609 1609
 
1610
-            case 'map':
1611
-                ?>
1610
+			case 'map':
1611
+				?>
1612 1612
                 <tr valign="top">
1613 1613
                     <td class="forminp">
1614 1614
                         <?php
1615
-                        global $post_cat, $cat_display;
1616
-                        $post_types = geodir_get_posttypes('object');
1617
-                        $cat_display = 'checkbox';
1618
-                        $gd_post_types = get_option('geodir_exclude_post_type_on_map');
1619
-                        $gd_cats = get_option('geodir_exclude_cat_on_map');
1620
-                        $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
1621
-                        $count = 1;
1622
-                        ?>
1615
+						global $post_cat, $cat_display;
1616
+						$post_types = geodir_get_posttypes('object');
1617
+						$cat_display = 'checkbox';
1618
+						$gd_post_types = get_option('geodir_exclude_post_type_on_map');
1619
+						$gd_cats = get_option('geodir_exclude_cat_on_map');
1620
+						$gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
1621
+						$count = 1;
1622
+						?>
1623 1623
                         <table width="70%" class="widefat">
1624 1624
                             <thead>
1625 1625
                             <tr>
@@ -1628,18 +1628,18 @@  discard block
 block discarded – undo
1628 1628
                                 <th><b><?php echo DESIGN_POST_TYPE_CAT; ?></b></th>
1629 1629
                             </tr>
1630 1630
                             <?php
1631
-                            $gd_categs = $gd_cats;
1632
-                            foreach ($post_types as $key => $post_types_obj) :
1633
-                                $checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : '';
1634
-                                $gd_taxonomy = geodir_get_taxonomies($key);
1635
-                                if ($gd_cats_upgrade) {
1636
-                                    $gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : '';
1637
-                                    $gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array();
1638
-                                    $gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array();
1639
-                                }
1640
-                                $post_cat = implode(',', $gd_cats);
1641
-                                $gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy);
1642
-                                ?>
1631
+							$gd_categs = $gd_cats;
1632
+							foreach ($post_types as $key => $post_types_obj) :
1633
+								$checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : '';
1634
+								$gd_taxonomy = geodir_get_taxonomies($key);
1635
+								if ($gd_cats_upgrade) {
1636
+									$gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : '';
1637
+									$gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array();
1638
+									$gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array();
1639
+								}
1640
+								$post_cat = implode(',', $gd_cats);
1641
+								$gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy);
1642
+								?>
1643 1643
                                 <tr>
1644 1644
                                     <td valign="top" width="5%"><?php echo $count; ?></td>
1645 1645
                                     <td valign="top" width="25%" id="td_post_types"><input type="checkbox"
@@ -1660,19 +1660,19 @@  discard block
 block discarded – undo
1660 1660
                     </td>
1661 1661
                 </tr>
1662 1662
                 <?php
1663
-                break;
1663
+				break;
1664 1664
 
1665
-            case 'checkbox' :
1665
+			case 'checkbox' :
1666 1666
 
1667
-                if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) :
1668
-                    ?>
1667
+				if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) :
1668
+					?>
1669 1669
                     <tr valign="top">
1670 1670
                     <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1671 1671
                     <td class="forminp">
1672 1672
                 <?php
1673
-                endif;
1673
+				endif;
1674 1674
 
1675
-                ?>
1675
+				?>
1676 1676
                 <fieldset>
1677 1677
                     <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend>
1678 1678
                     <label for="<?php echo $value['id'] ?>">
@@ -1682,49 +1682,49 @@  discard block
 block discarded – undo
1682 1682
                 </fieldset>
1683 1683
                 <?php
1684 1684
 
1685
-                if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) :
1686
-                    ?>
1685
+				if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) :
1686
+					?>
1687 1687
                     </td>
1688 1688
                     </tr>
1689 1689
                 <?php
1690
-                endif;
1690
+				endif;
1691 1691
 
1692
-                break;
1692
+				break;
1693 1693
 
1694
-            case 'radio' :
1694
+			case 'radio' :
1695 1695
 
1696
-                if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) :
1697
-                    ?>
1696
+				if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) :
1697
+					?>
1698 1698
                     <tr valign="top">
1699 1699
                     <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1700 1700
                     <td class="forminp">
1701 1701
                 <?php
1702
-                endif;
1702
+				endif;
1703 1703
 
1704
-                ?>
1704
+				?>
1705 1705
                 <fieldset>
1706 1706
                     <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend>
1707 1707
                     <label for="<?php echo $value['id'];?>">
1708 1708
                         <input name="<?php echo esc_attr($value['id']); ?>"
1709 1709
                                id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio"
1710 1710
                                value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) {
1711
-                            echo 'checked="checked"';
1712
-                        }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
1711
+							echo 'checked="checked"';
1712
+						}elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
1713 1713
                         <?php echo $value['desc']; ?></label><br>
1714 1714
                 </fieldset>
1715 1715
                 <?php
1716 1716
 
1717
-                if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) :
1718
-                    ?>
1717
+				if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) :
1718
+					?>
1719 1719
                     </td>
1720 1720
                     </tr>
1721 1721
                 <?php
1722
-                endif;
1722
+				endif;
1723 1723
 
1724
-                break;
1724
+				break;
1725 1725
 
1726
-            case 'textarea':
1727
-                ?>
1726
+			case 'textarea':
1727
+				?>
1728 1728
                 <tr valign="top">
1729 1729
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1730 1730
                 <td class="forminp">
@@ -1737,30 +1737,30 @@  discard block
 block discarded – undo
1737 1737
 
1738 1738
                 </td>
1739 1739
                 </tr><?php
1740
-                break;
1740
+				break;
1741 1741
 
1742
-            case 'editor':
1743
-                ?>
1742
+			case 'editor':
1743
+				?>
1744 1744
                 <tr valign="top">
1745 1745
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1746 1746
                 <td class="forminp"><?php
1747
-                    if (get_option($value['id']))
1748
-                        $content = stripslashes(get_option($value['id']));
1749
-                    else
1750
-                        $content = $value['std'];
1747
+					if (get_option($value['id']))
1748
+						$content = stripslashes(get_option($value['id']));
1749
+					else
1750
+						$content = $value['std'];
1751 1751
 
1752
-                    $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
1752
+					$editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
1753 1753
 
1754
-                    wp_editor($content, esc_attr($value['id']), $editor_settings);
1754
+					wp_editor($content, esc_attr($value['id']), $editor_settings);
1755 1755
 
1756
-                    ?> <span class="description"><?php echo $value['desc'] ?></span>
1756
+					?> <span class="description"><?php echo $value['desc'] ?></span>
1757 1757
 
1758 1758
                 </td>
1759 1759
                 </tr><?php
1760
-                break;
1760
+				break;
1761 1761
 
1762
-            case 'single_select_page' :
1763
-                // WPML
1762
+			case 'single_select_page' :
1763
+				// WPML
1764 1764
 				$switch_lang = false;
1765 1765
 				$disabled = '';
1766 1766
 				if (geodir_is_wpml() && isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') {
@@ -1778,18 +1778,18 @@  discard block
 block discarded – undo
1778 1778
 				//
1779 1779
 				$page_setting = (int)get_option($value['id']);
1780 1780
 
1781
-                $args = array('name' => $value['id'],
1782
-                    'id' => $value['id'],
1783
-                    'sort_column' => 'menu_order',
1784
-                    'sort_order' => 'ASC',
1785
-                    'show_option_none' => ' ',
1786
-                    'class' => $value['class'],
1787
-                    'echo' => false,
1788
-                    'selected' => $page_setting);
1781
+				$args = array('name' => $value['id'],
1782
+					'id' => $value['id'],
1783
+					'sort_column' => 'menu_order',
1784
+					'sort_order' => 'ASC',
1785
+					'show_option_none' => ' ',
1786
+					'class' => $value['class'],
1787
+					'echo' => false,
1788
+					'selected' => $page_setting);
1789 1789
 
1790
-                if (isset($value['args'])) $args = wp_parse_args($value['args'], $args);
1790
+				if (isset($value['args'])) $args = wp_parse_args($value['args'], $args);
1791 1791
 
1792
-                ?>
1792
+				?>
1793 1793
                 <tr valign="top" class="single_select_page">
1794 1794
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1795 1795
                 <td class="forminp">
@@ -1800,17 +1800,17 @@  discard block
 block discarded – undo
1800 1800
 				if ($switch_lang) {
1801 1801
 					$sitepress->switch_lang($switch_lang, true);
1802 1802
 				}
1803
-                break;
1804
-            case 'single_select_country' :
1805
-                $country_setting = (string)get_option($value['id']);
1806
-                if (strstr($country_setting, ':')) :
1807
-                    $country = current(explode(':', $country_setting));
1808
-                    $state = end(explode(':', $country_setting));
1809
-                else :
1810
-                    $country = $country_setting;
1811
-                    $state = '*';
1812
-                endif;
1813
-                ?>
1803
+				break;
1804
+			case 'single_select_country' :
1805
+				$country_setting = (string)get_option($value['id']);
1806
+				if (strstr($country_setting, ':')) :
1807
+					$country = current(explode(':', $country_setting));
1808
+					$state = end(explode(':', $country_setting));
1809
+				else :
1810
+					$country = $country_setting;
1811
+					$state = '*';
1812
+				endif;
1813
+				?>
1814 1814
                 <tr valign="top">
1815 1815
                 <th scope="rpw" class="titledesc"><?php echo $value['name'] ?></th>
1816 1816
                 <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>"
@@ -1821,12 +1821,12 @@  discard block
 block discarded – undo
1821 1821
                     </select> <span class="description"><?php echo $value['desc'] ?></span>
1822 1822
                 </td>
1823 1823
                 </tr><?php
1824
-                break;
1825
-            case 'multi_select_countries' :
1826
-                $countries = $geodirectory->countries->countries;
1827
-                asort($countries);
1828
-                $selections = (array)get_option($value['id']);
1829
-                ?>
1824
+				break;
1825
+			case 'multi_select_countries' :
1826
+				$countries = $geodirectory->countries->countries;
1827
+				asort($countries);
1828
+				$selections = (array)get_option($value['id']);
1829
+				?>
1830 1830
                 <tr valign="top">
1831 1831
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1832 1832
                 <td class="forminp">
@@ -1834,22 +1834,22 @@  discard block
 block discarded – undo
1834 1834
                             data-placeholder="<?php _e('Choose countries&hellip;', 'geodirectory'); ?>"
1835 1835
                             title="Country" class="chosen_select">
1836 1836
                         <?php
1837
-                        if ($countries) foreach ($countries as $key => $val) :
1838
-                            echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>';
1839
-                        endforeach;
1840
-                        ?>
1837
+						if ($countries) foreach ($countries as $key => $val) :
1838
+							echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>';
1839
+						endforeach;
1840
+						?>
1841 1841
                     </select>
1842 1842
                 </td>
1843 1843
                 </tr>
1844 1844
 
1845 1845
                 <?php
1846 1846
 
1847
-                break;
1847
+				break;
1848 1848
 
1849
-            case 'google_analytics' :
1850
-                $selections = (array)get_option($value['id']);
1851
-                if(get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret') ) {
1852
-                    ?>
1849
+			case 'google_analytics' :
1850
+				$selections = (array)get_option($value['id']);
1851
+				if(get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret') ) {
1852
+					?>
1853 1853
                     <tr valign="top">
1854 1854
                         <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1855 1855
                         <td class="forminp">
@@ -1857,19 +1857,19 @@  discard block
 block discarded – undo
1857 1857
 
1858 1858
                             <?php
1859 1859
 
1860
-                            $oAuthURL = "https://accounts.google.com/o/oauth2/auth?";
1861
-                            $scope = "scope=https://www.googleapis.com/auth/analytics.readonly";
1862
-                            $state = "&state=123";//any string
1863
-                            $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
1864
-                            $response_type = "&response_type=code";
1865
-                            $client_id = "&client_id=".get_option('geodir_ga_client_id');
1866
-                            $access_type = "&access_type=offline";
1867
-                            $approval_prompt = "&approval_prompt=force";
1860
+							$oAuthURL = "https://accounts.google.com/o/oauth2/auth?";
1861
+							$scope = "scope=https://www.googleapis.com/auth/analytics.readonly";
1862
+							$state = "&state=123";//any string
1863
+							$redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
1864
+							$response_type = "&response_type=code";
1865
+							$client_id = "&client_id=".get_option('geodir_ga_client_id');
1866
+							$access_type = "&access_type=offline";
1867
+							$approval_prompt = "&approval_prompt=force";
1868 1868
 
1869
-                            $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt;
1869
+							$auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt;
1870 1870
 
1871 1871
 
1872
-                            ?>
1872
+							?>
1873 1873
                             <script>
1874 1874
                                 function gd_ga_popup() {
1875 1875
                                     var win = window.open("<?php echo $auth_url;?>", "Google Analytics", "");
@@ -1884,47 +1884,47 @@  discard block
 block discarded – undo
1884 1884
                             </script>
1885 1885
 
1886 1886
                             <?php
1887
-                            if (get_option('gd_ga_refresh_token')) {
1888
-                                ?>
1887
+							if (get_option('gd_ga_refresh_token')) {
1888
+								?>
1889 1889
                                 <span class="button-primary"
1890 1890
                                       onclick="gd_ga_popup();"><?php _e('Re-authorize', 'geodirectory'); ?></span>
1891 1891
                                 <span
1892 1892
                                     style="color: green; font-weight: bold;"><?php _e('Authorized', 'geodirectory'); ?></span>
1893 1893
                             <?php
1894
-                            } else {
1895
-                                ?>
1894
+							} else {
1895
+								?>
1896 1896
                                 <span class="button-primary"
1897 1897
                                       onclick="gd_ga_popup();"><?php _e('Authorize', 'geodirectory');?></span>
1898 1898
                             <?php
1899
-                            }
1900
-                            ?>
1899
+							}
1900
+							?>
1901 1901
                         </td>
1902 1902
                     </tr>
1903 1903
 
1904 1904
                 <?php
1905
-                }
1905
+				}
1906 1906
 
1907
-                break;
1907
+				break;
1908 1908
 
1909
-            case 'field_seperator' :
1909
+			case 'field_seperator' :
1910 1910
 
1911
-                ?>
1911
+				?>
1912 1912
                 <tr valign="top">
1913 1913
                     <td colspan="2" class="forminp geodir_line_seperator"></td>
1914 1914
                 </tr>
1915 1915
                 <?php
1916 1916
 
1917
-                break;
1917
+				break;
1918 1918
 
1919
-        endswitch;
1919
+		endswitch;
1920 1920
 
1921
-    endforeach;
1921
+	endforeach;
1922 1922
 
1923
-    if ($first_title === false) {
1924
-        echo "</div>";
1925
-    }
1923
+	if ($first_title === false) {
1924
+		echo "</div>";
1925
+	}
1926 1926
 
1927
-    ?>
1927
+	?>
1928 1928
 
1929 1929
     <script type="text/javascript">
1930 1930
 
@@ -1984,33 +1984,33 @@  discard block
 block discarded – undo
1984 1984
  */
1985 1985
 function geodir_post_info_setting()
1986 1986
 {
1987
-    global $post, $post_id;
1988
-
1989
-    $post_type = get_post_type();
1990
-
1991
-    $package_info = array();
1992
-
1993
-    $package_info = geodir_post_package_info($package_info, $post, $post_type);
1994
-    wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename');
1995
-    echo '<div id="geodir_wrapper">';
1996
-    /**
1997
-     * Called before the GD custom fields are output in the wp-admin area.
1998
-     *
1999
-     * @since 1.0.0
2000
-     * @see 'geodir_after_default_field_in_meta_box'
2001
-     */
2002
-    do_action('geodir_before_default_field_in_meta_box');
2003
-    //geodir_get_custom_fields_html($package_info->pid,'default',$post_type);
2004
-    // to display all fields in one information box
2005
-    geodir_get_custom_fields_html($package_info->pid, 'all', $post_type);
2006
-    /**
2007
-     * Called after the GD custom fields are output in the wp-admin area.
2008
-     *
2009
-     * @since 1.0.0
2010
-     * @see 'geodir_before_default_field_in_meta_box'
2011
-     */
2012
-    do_action('geodir_after_default_field_in_meta_box');
2013
-    echo '</div>';
1987
+	global $post, $post_id;
1988
+
1989
+	$post_type = get_post_type();
1990
+
1991
+	$package_info = array();
1992
+
1993
+	$package_info = geodir_post_package_info($package_info, $post, $post_type);
1994
+	wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename');
1995
+	echo '<div id="geodir_wrapper">';
1996
+	/**
1997
+	 * Called before the GD custom fields are output in the wp-admin area.
1998
+	 *
1999
+	 * @since 1.0.0
2000
+	 * @see 'geodir_after_default_field_in_meta_box'
2001
+	 */
2002
+	do_action('geodir_before_default_field_in_meta_box');
2003
+	//geodir_get_custom_fields_html($package_info->pid,'default',$post_type);
2004
+	// to display all fields in one information box
2005
+	geodir_get_custom_fields_html($package_info->pid, 'all', $post_type);
2006
+	/**
2007
+	 * Called after the GD custom fields are output in the wp-admin area.
2008
+	 *
2009
+	 * @since 1.0.0
2010
+	 * @see 'geodir_before_default_field_in_meta_box'
2011
+	 */
2012
+	do_action('geodir_after_default_field_in_meta_box');
2013
+	echo '</div>';
2014 2014
 }
2015 2015
 
2016 2016
 /**
@@ -2023,18 +2023,18 @@  discard block
 block discarded – undo
2023 2023
  */
2024 2024
 function geodir_post_addinfo_setting()
2025 2025
 {
2026
-    global $post, $post_id;
2026
+	global $post, $post_id;
2027 2027
 
2028
-    $post_type = get_post_type();
2028
+	$post_type = get_post_type();
2029 2029
 
2030
-    $package_info = array();
2030
+	$package_info = array();
2031 2031
 
2032
-    $package_info = geodir_post_package_info($package_info, $post, $post_type);
2032
+	$package_info = geodir_post_package_info($package_info, $post, $post_type);
2033 2033
 
2034
-    wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename');
2035
-    echo '<div id="geodir_wrapper">';
2036
-    geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type);
2037
-    echo '</div>';
2034
+	wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename');
2035
+	echo '<div id="geodir_wrapper">';
2036
+	geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type);
2037
+	echo '</div>';
2038 2038
 
2039 2039
 }
2040 2040
 
@@ -2048,60 +2048,60 @@  discard block
 block discarded – undo
2048 2048
  */
2049 2049
 function geodir_post_attachments()
2050 2050
 {
2051
-    global $post, $post_id;
2051
+	global $post, $post_id;
2052 2052
 
2053
-    wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename');
2053
+	wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename');
2054 2054
 
2055
-    if (geodir_get_featured_image($post_id, 'thumbnail')) {
2056
-        echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
2057
-        geodir_show_featured_image($post_id, 'thumbnail');
2058
-    }
2055
+	if (geodir_get_featured_image($post_id, 'thumbnail')) {
2056
+		echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
2057
+		geodir_show_featured_image($post_id, 'thumbnail');
2058
+	}
2059 2059
 
2060
-    $image_limit = 0;
2060
+	$image_limit = 0;
2061 2061
 
2062
-    ?>
2062
+	?>
2063 2063
 
2064 2064
 
2065 2065
     <h5 class="form_title">
2066 2066
         <?php if ($image_limit != 0 && $image_limit == 1) {
2067
-            echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
2068
-        } ?>
2067
+			echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
2068
+		} ?>
2069 2069
         <?php if ($image_limit != 0 && $image_limit > 1) {
2070
-            echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
2071
-        } ?>
2070
+			echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
2071
+		} ?>
2072 2072
         <?php if ($image_limit == 0) {
2073
-            echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
2074
-        } ?>
2073
+			echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
2074
+		} ?>
2075 2075
     </h5>
2076 2076
 
2077 2077
 
2078 2078
     <?php
2079 2079
 
2080
-    $curImages = geodir_get_images($post_id);
2081
-    $place_img_array = array();
2080
+	$curImages = geodir_get_images($post_id);
2081
+	$place_img_array = array();
2082 2082
 
2083
-    if (!empty($curImages)):
2084
-        foreach ($curImages as $p_img):
2085
-            $place_img_array[] = $p_img->src;
2086
-        endforeach;
2087
-    endif;
2083
+	if (!empty($curImages)):
2084
+		foreach ($curImages as $p_img):
2085
+			$place_img_array[] = $p_img->src;
2086
+		endforeach;
2087
+	endif;
2088 2088
 
2089
-    if (!empty($place_img_array))
2090
-        $curImages = implode(',', $place_img_array);
2089
+	if (!empty($place_img_array))
2090
+		$curImages = implode(',', $place_img_array);
2091 2091
 
2092 2092
 
2093
-    // adjust values here
2094
-    $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
2093
+	// adjust values here
2094
+	$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 2095
 
2096
-    $svalue = $curImages; // this will be initial value of the above form field. Image urls.
2096
+	$svalue = $curImages; // this will be initial value of the above form field. Image urls.
2097 2097
 
2098
-    $multiple = true; // allow multiple files upload
2098
+	$multiple = true; // allow multiple files upload
2099 2099
 
2100
-    $width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels)
2100
+	$width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels)
2101 2101
 
2102
-    $height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels)
2102
+	$height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels)
2103 2103
 
2104
-    ?>
2104
+	?>
2105 2105
 
2106 2106
     <div class="gtd-form_row clearfix" id="<?php echo $id; ?>dropbox" style="border:1px solid #999999;padding:5px;text-align:center;">
2107 2107
         <input type="hidden" name="<?php echo $id; ?>" id="<?php echo $id; ?>" value="<?php echo $svalue; ?>"/>
@@ -2143,13 +2143,13 @@  discard block
 block discarded – undo
2143 2143
  */
2144 2144
 function geodir_action_post_updated($post_ID, $post_after, $post_before)
2145 2145
 {
2146
-    $post_type = get_post_type($post_ID);
2146
+	$post_type = get_post_type($post_ID);
2147 2147
 
2148
-    if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
2149
-        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) {
2150
-            geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title);
2151
-        }
2152
-    }
2148
+	if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
2149
+		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) {
2150
+			geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title);
2151
+		}
2152
+	}
2153 2153
 }
2154 2154
 
2155 2155
 /**
@@ -2164,39 +2164,39 @@  discard block
 block discarded – undo
2164 2164
  */
2165 2165
 function geodir_notification_add_bcc_option($settings)
2166 2166
 {
2167
-    if (!empty($settings)) {
2168
-        $new_settings = array();
2169
-        foreach ($settings as $setting) {
2170
-            if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') {
2171
-                $geodir_bcc_listing_published_yes = array(
2172
-                    'name' => __('Listing published', 'geodirectory'),
2173
-                    'desc' => __('Yes', 'geodirectory'),
2174
-                    'id' => 'geodir_bcc_listing_published',
2175
-                    'std' => 'yes',
2176
-                    'type' => 'radio',
2177
-                    'value' => '1',
2178
-                    'radiogroup' => 'start'
2179
-                );
2180
-
2181
-                $geodir_bcc_listing_published_no = array(
2182
-                    'name' => __('Listing published', 'geodirectory'),
2183
-                    'desc' => __('No', 'geodirectory'),
2184
-                    'id' => 'geodir_bcc_listing_published',
2185
-                    'std' => 'yes',
2186
-                    'type' => 'radio',
2187
-                    'value' => '0',
2188
-                    'radiogroup' => 'end'
2189
-                );
2190
-
2191
-                $new_settings[] = $geodir_bcc_listing_published_yes;
2192
-                $new_settings[] = $geodir_bcc_listing_published_no;
2193
-            }
2194
-            $new_settings[] = $setting;
2195
-        }
2196
-        $settings = $new_settings;
2197
-    }
2167
+	if (!empty($settings)) {
2168
+		$new_settings = array();
2169
+		foreach ($settings as $setting) {
2170
+			if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') {
2171
+				$geodir_bcc_listing_published_yes = array(
2172
+					'name' => __('Listing published', 'geodirectory'),
2173
+					'desc' => __('Yes', 'geodirectory'),
2174
+					'id' => 'geodir_bcc_listing_published',
2175
+					'std' => 'yes',
2176
+					'type' => 'radio',
2177
+					'value' => '1',
2178
+					'radiogroup' => 'start'
2179
+				);
2180
+
2181
+				$geodir_bcc_listing_published_no = array(
2182
+					'name' => __('Listing published', 'geodirectory'),
2183
+					'desc' => __('No', 'geodirectory'),
2184
+					'id' => 'geodir_bcc_listing_published',
2185
+					'std' => 'yes',
2186
+					'type' => 'radio',
2187
+					'value' => '0',
2188
+					'radiogroup' => 'end'
2189
+				);
2190
+
2191
+				$new_settings[] = $geodir_bcc_listing_published_yes;
2192
+				$new_settings[] = $geodir_bcc_listing_published_no;
2193
+			}
2194
+			$new_settings[] = $setting;
2195
+		}
2196
+		$settings = $new_settings;
2197
+	}
2198 2198
 
2199
-    return $settings;
2199
+	return $settings;
2200 2200
 }
2201 2201
 
2202 2202
 
@@ -2211,19 +2211,19 @@  discard block
 block discarded – undo
2211 2211
  */
2212 2212
 function get_gd_theme_compat_callback()
2213 2213
 {
2214
-    global $wpdb;
2215
-    $themes = get_option('gd_theme_compats');
2216
-
2217
-    if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) {
2218
-        if (isset($_POST['export'])) {
2219
-            echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']]));
2220
-        } else {
2221
-            echo json_encode($themes[$_POST['theme']]);
2222
-        }
2214
+	global $wpdb;
2215
+	$themes = get_option('gd_theme_compats');
2223 2216
 
2224
-    }
2217
+	if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) {
2218
+		if (isset($_POST['export'])) {
2219
+			echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']]));
2220
+		} else {
2221
+			echo json_encode($themes[$_POST['theme']]);
2222
+		}
2225 2223
 
2226
-    die();
2224
+	}
2225
+
2226
+	die();
2227 2227
 }
2228 2228
 
2229 2229
 add_action('wp_ajax_get_gd_theme_compat_import_callback', 'get_gd_theme_compat_import_callback');
@@ -2237,20 +2237,20 @@  discard block
 block discarded – undo
2237 2237
  */
2238 2238
 function get_gd_theme_compat_import_callback()
2239 2239
 {
2240
-    global $wpdb;
2241
-    $themes = get_option('gd_theme_compats');
2242
-    if (isset($_POST['theme']) && !empty($_POST['theme'])) {
2243
-        $json = json_decode(stripslashes($_POST['theme']), true);
2244
-        if (!empty($json) && is_array($json)) {
2245
-            $key = sanitize_text_field(key($json));
2246
-            $themes[$key] = $json[$key];
2247
-            update_option('gd_theme_compats', $themes);
2248
-            echo $key;
2249
-            die();
2250
-        }
2251
-    }
2252
-    echo '0';
2253
-    die();
2240
+	global $wpdb;
2241
+	$themes = get_option('gd_theme_compats');
2242
+	if (isset($_POST['theme']) && !empty($_POST['theme'])) {
2243
+		$json = json_decode(stripslashes($_POST['theme']), true);
2244
+		if (!empty($json) && is_array($json)) {
2245
+			$key = sanitize_text_field(key($json));
2246
+			$themes[$key] = $json[$key];
2247
+			update_option('gd_theme_compats', $themes);
2248
+			echo $key;
2249
+			die();
2250
+		}
2251
+	}
2252
+	echo '0';
2253
+	die();
2254 2254
 }
2255 2255
 
2256 2256
 
@@ -2263,39 +2263,39 @@  discard block
 block discarded – undo
2263 2263
  */
2264 2264
 function gd_set_theme_compat()
2265 2265
 {
2266
-    global $wpdb;
2267
-    $theme = wp_get_theme();
2266
+	global $wpdb;
2267
+	$theme = wp_get_theme();
2268 2268
 
2269
-    if ($theme->parent()) {
2270
-        $theme_name = str_replace(" ", "_", $theme->parent()->get('Name'));
2271
-    } else {
2272
-        $theme_name = str_replace(" ", "_", $theme->get('Name'));
2273
-    }
2269
+	if ($theme->parent()) {
2270
+		$theme_name = str_replace(" ", "_", $theme->parent()->get('Name'));
2271
+	} else {
2272
+		$theme_name = str_replace(" ", "_", $theme->get('Name'));
2273
+	}
2274 2274
 
2275
-    $theme_compats = get_option('gd_theme_compats');
2276
-    $current_compat = get_option('gd_theme_compat');
2277
-    $current_compat = str_replace("_custom", "", $current_compat);
2275
+	$theme_compats = get_option('gd_theme_compats');
2276
+	$current_compat = get_option('gd_theme_compat');
2277
+	$current_compat = str_replace("_custom", "", $current_compat);
2278 2278
 
2279
-    if ($current_compat == $theme_name && strpos("_custom", get_option('gd_theme_compat')) !== false) {
2280
-        return;
2281
-    }// if already running correct compat then bail
2279
+	if ($current_compat == $theme_name && strpos("_custom", get_option('gd_theme_compat')) !== false) {
2280
+		return;
2281
+	}// if already running correct compat then bail
2282 2282
 
2283
-    if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it
2284
-        update_option('gd_theme_compat', $theme_name);
2285
-        update_option('theme_compatibility_setting', $theme_compats[$theme_name]);
2283
+	if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it
2284
+		update_option('gd_theme_compat', $theme_name);
2285
+		update_option('theme_compatibility_setting', $theme_compats[$theme_name]);
2286 2286
 
2287
-        // if there are default options to set then set them
2288
-        if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) {
2287
+		// if there are default options to set then set them
2288
+		if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) {
2289 2289
 
2290
-            foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) {
2291
-                update_option($key, $val);
2292
-            }
2293
-        }
2290
+			foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) {
2291
+				update_option($key, $val);
2292
+			}
2293
+		}
2294 2294
 
2295
-    } else {
2296
-        update_option('gd_theme_compat', '');
2297
-        update_option('theme_compatibility_setting', '');
2298
-    }
2295
+	} else {
2296
+		update_option('gd_theme_compat', '');
2297
+		update_option('theme_compatibility_setting', '');
2298
+	}
2299 2299
 
2300 2300
 
2301 2301
 }
@@ -2310,9 +2310,9 @@  discard block
 block discarded – undo
2310 2310
  */
2311 2311
 function gd_check_avada_compat()
2312 2312
 {
2313
-    if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) {
2314
-        add_action('admin_notices', 'gd_avada_compat_warning');
2315
-    }
2313
+	if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) {
2314
+		add_action('admin_notices', 'gd_avada_compat_warning');
2315
+	}
2316 2316
 }
2317 2317
 
2318 2318
 
@@ -2325,22 +2325,22 @@  discard block
 block discarded – undo
2325 2325
 function gd_avada_compat_warning()
2326 2326
 {
2327 2327
 
2328
-    /*
2328
+	/*
2329 2329
     $msg_type = error
2330 2330
     $msg_type = updated fade
2331 2331
     $msg_type = update-nag
2332 2332
     */
2333 2333
 
2334
-    $plugin = 'avada-nag';
2335
-    $timestamp = 'avada-nag1234';
2336
-    $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');
2337
-    echo '<div id="' . $timestamp . '"  class="error">';
2338
-    echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>';
2339
-    echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
2340
-    echo "<p>$message</p>";
2341
-    echo "</div>";
2334
+	$plugin = 'avada-nag';
2335
+	$timestamp = 'avada-nag1234';
2336
+	$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');
2337
+	echo '<div id="' . $timestamp . '"  class="error">';
2338
+	echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>';
2339
+	echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
2340
+	echo "<p>$message</p>";
2341
+	echo "</div>";
2342 2342
 
2343
-    ?>
2343
+	?>
2344 2344
     <script>
2345 2345
         function gdRemoveANotification($plugin, $timestamp) {
2346 2346
 
@@ -2408,10 +2408,10 @@  discard block
 block discarded – undo
2408 2408
  */
2409 2409
 function geodir_avada_remove_notification()
2410 2410
 {
2411
-    update_option('avada_nag', TRUE);
2411
+	update_option('avada_nag', TRUE);
2412 2412
 
2413
-    // Always die in functions echoing ajax content
2414
-    die();
2413
+	// Always die in functions echoing ajax content
2414
+	die();
2415 2415
 }
2416 2416
 
2417 2417
 
@@ -2470,7 +2470,7 @@  discard block
 block discarded – undo
2470 2470
 		// Don't allow same slug url for listing and location
2471 2471
 		if (geodir_strtolower($listing_prefix) == geodir_strtolower($location_prefix)) {
2472 2472
 			$redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab . '&msg=fail&gderr=21');
2473
-        	wp_redirect($redirect_url);
2473
+			wp_redirect($redirect_url);
2474 2474
 			exit;
2475 2475
 		}
2476 2476
 		
@@ -2500,10 +2500,10 @@  discard block
 block discarded – undo
2500 2500
  * @package GeoDirectory
2501 2501
  */
2502 2502
 function geodir_hide_admin_preview_button() {
2503
-    global $post_type;
2504
-    $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>';
2503
+	global $post_type;
2504
+	$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 2507
 }
2508 2508
 add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' );
2509 2509
 add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' );
@@ -2518,7 +2518,7 @@  discard block
 block discarded – undo
2518 2518
  */
2519 2519
 function geodir_import_export_tab( $tabs ) {
2520 2520
 	$tabs['import_export'] = array( 'label' => __( 'Import & Export', 'geodirectory' ) );
2521
-    return $tabs;
2521
+	return $tabs;
2522 2522
 }
2523 2523
 
2524 2524
 /**
@@ -2533,26 +2533,26 @@  discard block
 block discarded – undo
2533 2533
 function geodir_import_export_page() {
2534 2534
 	$nonce = wp_create_nonce( 'geodir_import_export_nonce' );
2535 2535
 	$gd_cats_sample_csv = geodir_plugin_url() . '/geodirectory-assets/gd_sample_categories.csv';
2536
-    /**
2537
-     * Filter sample category data csv file url.
2538
-     *
2539
-     * @since 1.0.0
2540
-     * @package GeoDirectory
2541
-     *
2542
-     * @param string $gd_cats_sample_csv Sample category data csv file url.
2543
-     */
2536
+	/**
2537
+	 * Filter sample category data csv file url.
2538
+	 *
2539
+	 * @since 1.0.0
2540
+	 * @package GeoDirectory
2541
+	 *
2542
+	 * @param string $gd_cats_sample_csv Sample category data csv file url.
2543
+	 */
2544 2544
 	$gd_cats_sample_csv = apply_filters( 'geodir_export_cats_sample_csv', $gd_cats_sample_csv );
2545 2545
 	
2546 2546
 	$gd_posts_sample_csv = geodir_plugin_url() . '/geodirectory-assets/place_listing.csv';
2547
-    /**
2548
-     * Filter sample post data csv file url.
2549
-     *
2550
-     * @since 1.0.0
2551
-     * @package GeoDirectory
2552
-     *
2553
-     * @param string $gd_posts_sample_csv Sample post data csv file url.
2554
-     */
2555
-    $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv );
2547
+	/**
2548
+	 * Filter sample post data csv file url.
2549
+	 *
2550
+	 * @since 1.0.0
2551
+	 * @package GeoDirectory
2552
+	 *
2553
+	 * @param string $gd_posts_sample_csv Sample post data csv file url.
2554
+	 */
2555
+	$gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv );
2556 2556
 	
2557 2557
 	$gd_posttypes = geodir_get_posttypes( 'array' );
2558 2558
 	
@@ -2575,14 +2575,14 @@  discard block
 block discarded – undo
2575 2575
 	$gd_chunksize_options[100000] = 100000;
2576 2576
 	 
2577 2577
 	 /**
2578
-     * Filter max entries per export csv file.
2579
-     *
2580
-     * @since 1.5.6
2581
-     * @package GeoDirectory
2582
-     *
2583
-     * @param string $gd_chunksize_options Entries options.
2584
-     */
2585
-    $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options );
2578
+	  * Filter max entries per export csv file.
2579
+	  *
2580
+	  * @since 1.5.6
2581
+	  * @package GeoDirectory
2582
+	  *
2583
+	  * @param string $gd_chunksize_options Entries options.
2584
+	  */
2585
+	$gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options );
2586 2586
 	
2587 2587
 	$gd_chunksize_option = '';
2588 2588
 	foreach ($gd_chunksize_options as $value => $title) {
@@ -2598,12 +2598,12 @@  discard block
 block discarded – undo
2598 2598
   <div class="gd-content-heading">
2599 2599
 
2600 2600
   <?php
2601
-    ini_set('max_execution_time', 999999);
2602
-    $ini_max_execution_time_check = @ini_get( 'max_execution_time' );
2603
-    ini_restore('max_execution_time');
2601
+	ini_set('max_execution_time', 999999);
2602
+	$ini_max_execution_time_check = @ini_get( 'max_execution_time' );
2603
+	ini_restore('max_execution_time');
2604 2604
 
2605
-    if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
2606
-        ?>
2605
+	if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
2606
+		?>
2607 2607
 	<div id="gd_ie_reqs" class="metabox-holder">
2608 2608
       <div class="meta-box-sortables ui-sortable">
2609 2609
         <div class="postbox">
@@ -2772,7 +2772,7 @@  discard block
 block discarded – undo
2772 2772
 						 * Called just after the sample CSV download link.
2773 2773
 						 *
2774 2774
 						 * @since 1.0.0
2775
-                         * @package GeoDirectory
2775
+						 * @package GeoDirectory
2776 2776
 						 */
2777 2777
 						do_action('geodir_sample_cats_csv_download_link');
2778 2778
 						?>
@@ -2857,11 +2857,11 @@  discard block
 block discarded – undo
2857 2857
 	 *
2858 2858
 	 * Called after the last setting on the GD > Import & Export page.
2859 2859
 	 * @since 1.4.6
2860
-     * @package GeoDirectory
2860
+	 * @package GeoDirectory
2861 2861
 	 *
2862 2862
 	 * @param array $gd_posttypes GD post types.
2863
-     * @param array $gd_chunksize_options File chunk size options.
2864
-     * @param string $nonce Wordpress security token for GD import & export.
2863
+	 * @param array $gd_chunksize_options File chunk size options.
2864
+	 * @param string $nonce Wordpress security token for GD import & export.
2865 2865
 	 */
2866 2866
 	do_action( 'geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce );
2867 2867
 	?>
@@ -3526,44 +3526,44 @@  discard block
 block discarded – undo
3526 3526
 function geodir_init_filesystem()
3527 3527
 {
3528 3528
 
3529
-    if(!function_exists('get_filesystem_method')){
3530
-        require_once(ABSPATH."/wp-admin/includes/file.php");
3531
-    }
3532
-    $access_type = get_filesystem_method();
3533
-    if ($access_type === 'direct') {
3534
-        /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
3535
-        $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3536
-
3537
-        /* initialize the API */
3538
-        if (!WP_Filesystem($creds)) {
3539
-            /* any problems and we exit */
3540
-            //return '@@@3';
3541
-            return false;
3542
-        }
3543
-
3544
-        global $wp_filesystem;
3545
-        return $wp_filesystem;
3546
-        /* do our file manipulations below */
3547
-    } elseif (defined('FTP_USER')) {
3548
-        $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3529
+	if(!function_exists('get_filesystem_method')){
3530
+		require_once(ABSPATH."/wp-admin/includes/file.php");
3531
+	}
3532
+	$access_type = get_filesystem_method();
3533
+	if ($access_type === 'direct') {
3534
+		/* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
3535
+		$creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3536
+
3537
+		/* initialize the API */
3538
+		if (!WP_Filesystem($creds)) {
3539
+			/* any problems and we exit */
3540
+			//return '@@@3';
3541
+			return false;
3542
+		}
3549 3543
 
3550
-        /* initialize the API */
3551
-        if (!WP_Filesystem($creds)) {
3552
-            /* any problems and we exit */
3553
-            //return '@@@33';
3554
-            return false;
3555
-        }
3544
+		global $wp_filesystem;
3545
+		return $wp_filesystem;
3546
+		/* do our file manipulations below */
3547
+	} elseif (defined('FTP_USER')) {
3548
+		$creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3549
+
3550
+		/* initialize the API */
3551
+		if (!WP_Filesystem($creds)) {
3552
+			/* any problems and we exit */
3553
+			//return '@@@33';
3554
+			return false;
3555
+		}
3556 3556
 
3557
-        global $wp_filesystem;
3558
-        //return '@@@1';
3559
-        return $wp_filesystem;
3557
+		global $wp_filesystem;
3558
+		//return '@@@1';
3559
+		return $wp_filesystem;
3560 3560
 
3561
-    } else {
3562
-        //return '@@@2';
3563
-        /* don't have direct write access. Prompt user with our notice */
3564
-        add_action('admin_notice', 'geodir_filesystem_notice');
3565
-        return false;
3566
-    }
3561
+	} else {
3562
+		//return '@@@2';
3563
+		/* don't have direct write access. Prompt user with our notice */
3564
+		add_action('admin_notice', 'geodir_filesystem_notice');
3565
+		return false;
3566
+	}
3567 3567
 
3568 3568
 }
3569 3569
 
@@ -3581,10 +3581,10 @@  discard block
 block discarded – undo
3581 3581
  */
3582 3582
 function geodir_filesystem_notice()
3583 3583
 {   if ( defined( 'DOING_AJAX' ) ){return;}
3584
-    $access_type = get_filesystem_method();
3585
-    if ($access_type === 'direct') {
3586
-    } elseif (!defined('FTP_USER')) {
3587
-        ?>
3584
+	$access_type = get_filesystem_method();
3585
+	if ($access_type === 'direct') {
3586
+	} elseif (!defined('FTP_USER')) {
3587
+		?>
3588 3588
         <div class="error">
3589 3589
             <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'); ?>
3590 3590
                 <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>
@@ -3610,1514 +3610,1514 @@  discard block
 block discarded – undo
3610 3610
  * @return string Json data.
3611 3611
  */
3612 3612
 function geodir_ajax_import_export() {
3613
-    global $wpdb, $plugin_prefix, $current_user, $wp_filesystem;
3613
+	global $wpdb, $plugin_prefix, $current_user, $wp_filesystem;
3614 3614
     
3615
-    error_reporting(0);
3615
+	error_reporting(0);
3616 3616
 
3617
-    // try to set higher limits for import
3618
-    $max_input_time = ini_get('max_input_time');
3619
-    $max_execution_time = ini_get('max_execution_time');
3620
-    $memory_limit= ini_get('memory_limit');
3617
+	// try to set higher limits for import
3618
+	$max_input_time = ini_get('max_input_time');
3619
+	$max_execution_time = ini_get('max_execution_time');
3620
+	$memory_limit= ini_get('memory_limit');
3621 3621
 
3622
-    if(!$max_input_time || $max_input_time<3000){
3623
-        ini_set('max_input_time', 3000);
3624
-    }
3622
+	if(!$max_input_time || $max_input_time<3000){
3623
+		ini_set('max_input_time', 3000);
3624
+	}
3625 3625
 
3626
-    if(!$max_execution_time || $max_execution_time<3000){
3627
-        ini_set('max_execution_time', 3000);
3628
-    }
3626
+	if(!$max_execution_time || $max_execution_time<3000){
3627
+		ini_set('max_execution_time', 3000);
3628
+	}
3629 3629
 
3630
-    if($memory_limit && str_replace('M','',$memory_limit)){
3631
-        if(str_replace('M','',$memory_limit)<256){
3632
-            ini_set('memory_limit', '256M');
3633
-        }
3634
-    }
3630
+	if($memory_limit && str_replace('M','',$memory_limit)){
3631
+		if(str_replace('M','',$memory_limit)<256){
3632
+			ini_set('memory_limit', '256M');
3633
+		}
3634
+	}
3635 3635
 
3636
-    $json = array();
3636
+	$json = array();
3637 3637
 
3638
-    if ( !current_user_can( 'manage_options' ) ) {
3639
-        wp_send_json( $json );
3640
-    }
3638
+	if ( !current_user_can( 'manage_options' ) ) {
3639
+		wp_send_json( $json );
3640
+	}
3641 3641
 
3642
-    $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL;
3643
-    $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL;
3644
-    $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false;
3642
+	$task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL;
3643
+	$nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL;
3644
+	$stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false;
3645 3645
 
3646
-    if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
3647
-        wp_send_json( $json );
3648
-    }
3646
+	if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
3647
+		wp_send_json( $json );
3648
+	}
3649 3649
 
3650
-    $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL;
3651
-    $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL;
3652
-    $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page;
3653
-    $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1;
3650
+	$post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL;
3651
+	$chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL;
3652
+	$chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page;
3653
+	$chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1;
3654 3654
 
3655
-    $wp_filesystem = geodir_init_filesystem();
3656
-    if (!$wp_filesystem) {
3657
-        $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' );
3658
-        wp_send_json( $json );
3659
-    }
3655
+	$wp_filesystem = geodir_init_filesystem();
3656
+	if (!$wp_filesystem) {
3657
+		$json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' );
3658
+		wp_send_json( $json );
3659
+	}
3660 3660
 
3661
-    if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
3662
-        $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' );
3663
-        wp_send_json( $json );
3664
-    }
3661
+	if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
3662
+		$json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' );
3663
+		wp_send_json( $json );
3664
+	}
3665 3665
 
3666
-    $csv_file_dir = geodir_path_import_export( false );
3667
-    if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
3668
-        if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
3669
-            $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' );
3670
-            wp_send_json( $json );
3671
-        }
3672
-    }
3666
+	$csv_file_dir = geodir_path_import_export( false );
3667
+	if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
3668
+		if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
3669
+			$json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' );
3670
+			wp_send_json( $json );
3671
+		}
3672
+	}
3673 3673
     
3674
-    $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
3675
-    $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
3676
-
3677
-    switch ( $task ) {
3678
-        case 'export_posts': {
3679
-            // WPML
3680
-            $is_wpml = geodir_is_wpml();
3681
-            if ($is_wpml) {
3682
-                global $sitepress;
3683
-                $active_lang = ICL_LANGUAGE_CODE;
3674
+	$location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
3675
+	$neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
3676
+
3677
+	switch ( $task ) {
3678
+		case 'export_posts': {
3679
+			// WPML
3680
+			$is_wpml = geodir_is_wpml();
3681
+			if ($is_wpml) {
3682
+				global $sitepress;
3683
+				$active_lang = ICL_LANGUAGE_CODE;
3684 3684
                 
3685
-                $sitepress->switch_lang('all', true);
3686
-            }
3687
-            // WPML
3688
-            if ( $post_type == 'gd_event' ) {
3689
-                add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 );
3690
-            }
3691
-            $file_name = $post_type . '_' . date( 'dmyHi' );
3692
-            $posts_count = geodir_get_posts_count( $post_type );
3693
-            $file_url_base = geodir_path_import_export() . '/';
3694
-            $file_url = $file_url_base . $file_name . '.csv';
3695
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3696
-            $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv';
3685
+				$sitepress->switch_lang('all', true);
3686
+			}
3687
+			// WPML
3688
+			if ( $post_type == 'gd_event' ) {
3689
+				add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 );
3690
+			}
3691
+			$file_name = $post_type . '_' . date( 'dmyHi' );
3692
+			$posts_count = geodir_get_posts_count( $post_type );
3693
+			$file_url_base = geodir_path_import_export() . '/';
3694
+			$file_url = $file_url_base . $file_name . '.csv';
3695
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
3696
+			$file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv';
3697 3697
             
3698
-            $chunk_file_paths = array();
3698
+			$chunk_file_paths = array();
3699 3699
 
3700
-            if ( isset( $_REQUEST['_st'] ) ) {
3701
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3702
-                $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0;
3703
-                $percentage = min( $percentage, 100 );
3700
+			if ( isset( $_REQUEST['_st'] ) ) {
3701
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
3702
+				$percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0;
3703
+				$percentage = min( $percentage, 100 );
3704 3704
                 
3705
-                $json['percentage'] = $percentage;
3706
-                // WPML
3707
-                if ($is_wpml) {
3708
-                    $sitepress->switch_lang($active_lang, true);
3709
-                }
3710
-                // WPML
3711
-                wp_send_json( $json );
3712
-                gd_die();
3713
-            } else {
3714
-                if ( !$posts_count > 0 ) {
3715
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3716
-                } else {
3717
-                    $total_posts = $posts_count;
3718
-                    if ($chunk_per_page > $total_posts) {
3719
-                        $chunk_per_page = $total_posts;
3720
-                    }
3721
-                    $chunk_total_pages = ceil( $total_posts / $chunk_per_page );
3705
+				$json['percentage'] = $percentage;
3706
+				// WPML
3707
+				if ($is_wpml) {
3708
+					$sitepress->switch_lang($active_lang, true);
3709
+				}
3710
+				// WPML
3711
+				wp_send_json( $json );
3712
+				gd_die();
3713
+			} else {
3714
+				if ( !$posts_count > 0 ) {
3715
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
3716
+				} else {
3717
+					$total_posts = $posts_count;
3718
+					if ($chunk_per_page > $total_posts) {
3719
+						$chunk_per_page = $total_posts;
3720
+					}
3721
+					$chunk_total_pages = ceil( $total_posts / $chunk_per_page );
3722 3722
                     
3723
-                    $j = $chunk_page_no;
3724
-                    $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j );
3723
+					$j = $chunk_page_no;
3724
+					$chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j );
3725 3725
                     
3726
-                    $per_page = 500;
3727
-                    if ($per_page > $chunk_per_page) {
3728
-                        $per_page = $chunk_per_page;
3729
-                    }
3730
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3726
+					$per_page = 500;
3727
+					if ($per_page > $chunk_per_page) {
3728
+						$per_page = $chunk_per_page;
3729
+					}
3730
+					$total_pages = ceil( $chunk_per_page / $per_page );
3731 3731
                     
3732
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3733
-                        $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page );
3732
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
3733
+						$save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page );
3734 3734
                         
3735
-                        $clear = $i == 0 ? true : false;
3736
-                        geodir_save_csv_data( $file_path_temp, $save_posts, $clear );
3737
-                    }
3735
+						$clear = $i == 0 ? true : false;
3736
+						geodir_save_csv_data( $file_path_temp, $save_posts, $clear );
3737
+					}
3738 3738
                         
3739
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3740
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3741
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3742
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3743
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3739
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
3740
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3741
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
3742
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
3743
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
3744 3744
                         
3745
-                        $file_url = $file_url_base . $chunk_file_name;
3746
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3747
-                    }
3745
+						$file_url = $file_url_base . $chunk_file_name;
3746
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3747
+					}
3748 3748
                     
3749
-                    if ( !empty($chunk_file_paths) ) {
3750
-                        $json['total'] = $posts_count;
3751
-                        $json['files'] = $chunk_file_paths;
3752
-                    } else {
3753
-                        if ($j > 1) {
3754
-                            $json['total'] = $posts_count;
3755
-                            $json['files'] = array();
3756
-                        } else {
3757
-                            $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3758
-                        }
3759
-                    }
3760
-                }
3761
-                // WPML
3762
-                if ($is_wpml) {
3763
-                    $sitepress->switch_lang($active_lang, true);
3764
-                }
3765
-                // WPML
3766
-                wp_send_json( $json );
3767
-            }
3768
-        }
3769
-        break;
3770
-        case 'export_cats': {
3771
-            // WPML
3772
-            $is_wpml = geodir_is_wpml();
3773
-            if ($is_wpml) {
3774
-                global $sitepress;
3775
-                $active_lang = ICL_LANGUAGE_CODE;
3749
+					if ( !empty($chunk_file_paths) ) {
3750
+						$json['total'] = $posts_count;
3751
+						$json['files'] = $chunk_file_paths;
3752
+					} else {
3753
+						if ($j > 1) {
3754
+							$json['total'] = $posts_count;
3755
+							$json['files'] = array();
3756
+						} else {
3757
+							$json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3758
+						}
3759
+					}
3760
+				}
3761
+				// WPML
3762
+				if ($is_wpml) {
3763
+					$sitepress->switch_lang($active_lang, true);
3764
+				}
3765
+				// WPML
3766
+				wp_send_json( $json );
3767
+			}
3768
+		}
3769
+		break;
3770
+		case 'export_cats': {
3771
+			// WPML
3772
+			$is_wpml = geodir_is_wpml();
3773
+			if ($is_wpml) {
3774
+				global $sitepress;
3775
+				$active_lang = ICL_LANGUAGE_CODE;
3776 3776
                 
3777
-                $sitepress->switch_lang('all', true);
3778
-            }
3779
-            // WPML
3780
-            $file_name = $post_type . 'category_' . date( 'dmyHi' );
3777
+				$sitepress->switch_lang('all', true);
3778
+			}
3779
+			// WPML
3780
+			$file_name = $post_type . 'category_' . date( 'dmyHi' );
3781 3781
             
3782
-            $terms_count = geodir_get_terms_count( $post_type );
3783
-            $file_url_base = geodir_path_import_export() . '/';
3784
-            $file_url = $file_url_base . $file_name . '.csv';
3785
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3786
-            $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv';
3782
+			$terms_count = geodir_get_terms_count( $post_type );
3783
+			$file_url_base = geodir_path_import_export() . '/';
3784
+			$file_url = $file_url_base . $file_name . '.csv';
3785
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
3786
+			$file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv';
3787 3787
             
3788
-            $chunk_file_paths = array();
3788
+			$chunk_file_paths = array();
3789 3789
             
3790
-            if ( isset( $_REQUEST['_st'] ) ) {
3791
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3792
-                $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0;
3793
-                $percentage = min( $percentage, 100 );
3790
+			if ( isset( $_REQUEST['_st'] ) ) {
3791
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
3792
+				$percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0;
3793
+				$percentage = min( $percentage, 100 );
3794 3794
                 
3795
-                $json['percentage'] = $percentage;
3796
-                // WPML
3797
-                if ($is_wpml) {
3798
-                    $sitepress->switch_lang($active_lang, true);
3799
-                }
3800
-                // WPML
3801
-                wp_send_json( $json );
3802
-            } else {
3803
-                if ( !$terms_count > 0 ) {
3804
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3805
-                } else {
3806
-                    $total_terms = $terms_count;
3807
-                    if ($chunk_per_page > $terms_count) {
3808
-                        $chunk_per_page = $terms_count;
3809
-                    }
3810
-                    $chunk_total_pages = ceil( $total_terms / $chunk_per_page );
3795
+				$json['percentage'] = $percentage;
3796
+				// WPML
3797
+				if ($is_wpml) {
3798
+					$sitepress->switch_lang($active_lang, true);
3799
+				}
3800
+				// WPML
3801
+				wp_send_json( $json );
3802
+			} else {
3803
+				if ( !$terms_count > 0 ) {
3804
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
3805
+				} else {
3806
+					$total_terms = $terms_count;
3807
+					if ($chunk_per_page > $terms_count) {
3808
+						$chunk_per_page = $terms_count;
3809
+					}
3810
+					$chunk_total_pages = ceil( $total_terms / $chunk_per_page );
3811 3811
                     
3812
-                    $j = $chunk_page_no;
3813
-                    $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j );
3812
+					$j = $chunk_page_no;
3813
+					$chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j );
3814 3814
                     
3815
-                    $per_page = 500;
3816
-                    if ($per_page > $chunk_per_page) {
3817
-                        $per_page = $chunk_per_page;
3818
-                    }
3819
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3815
+					$per_page = 500;
3816
+					if ($per_page > $chunk_per_page) {
3817
+						$per_page = $chunk_per_page;
3818
+					}
3819
+					$total_pages = ceil( $chunk_per_page / $per_page );
3820 3820
                     
3821
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3822
-                        $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page );
3821
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
3822
+						$save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page );
3823 3823
                         
3824
-                        $clear = $i == 0 ? true : false;
3825
-                        geodir_save_csv_data( $file_path_temp, $save_terms, $clear );
3826
-                    }
3824
+						$clear = $i == 0 ? true : false;
3825
+						geodir_save_csv_data( $file_path_temp, $save_terms, $clear );
3826
+					}
3827 3827
                     
3828
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3829
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3830
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3831
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3832
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3828
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
3829
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3830
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
3831
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
3832
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
3833 3833
                         
3834
-                        $file_url = $file_url_base . $chunk_file_name;
3835
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3836
-                    }
3834
+						$file_url = $file_url_base . $chunk_file_name;
3835
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3836
+					}
3837 3837
                     
3838
-                    if ( !empty($chunk_file_paths) ) {
3839
-                        $json['total'] = $terms_count;
3840
-                        $json['files'] = $chunk_file_paths;
3841
-                    } else {
3842
-                        $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3843
-                    }
3844
-                }
3845
-                // WPML
3846
-                if ($is_wpml) {
3847
-                    $sitepress->switch_lang($active_lang, true);
3848
-                }
3849
-                // WPML
3850
-                wp_send_json( $json );
3851
-            }
3852
-        }
3853
-        break;
3854
-        case 'export_locations': {
3855
-            $file_url_base = geodir_path_import_export() . '/';
3856
-            $file_name = 'gd_locations_' . date( 'dmyHi' );
3857
-            $file_url = $file_url_base . $file_name . '.csv';
3858
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3859
-            $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv';
3838
+					if ( !empty($chunk_file_paths) ) {
3839
+						$json['total'] = $terms_count;
3840
+						$json['files'] = $chunk_file_paths;
3841
+					} else {
3842
+						$json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3843
+					}
3844
+				}
3845
+				// WPML
3846
+				if ($is_wpml) {
3847
+					$sitepress->switch_lang($active_lang, true);
3848
+				}
3849
+				// WPML
3850
+				wp_send_json( $json );
3851
+			}
3852
+		}
3853
+		break;
3854
+		case 'export_locations': {
3855
+			$file_url_base = geodir_path_import_export() . '/';
3856
+			$file_name = 'gd_locations_' . date( 'dmyHi' );
3857
+			$file_url = $file_url_base . $file_name . '.csv';
3858
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
3859
+			$file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv';
3860 3860
             
3861
-            $items_count = (int)geodir_location_imex_count_locations();
3861
+			$items_count = (int)geodir_location_imex_count_locations();
3862 3862
             
3863
-            if ( isset( $_REQUEST['_st'] ) ) {
3864
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3865
-                $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3866
-                $percentage = min( $percentage, 100 );
3863
+			if ( isset( $_REQUEST['_st'] ) ) {
3864
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
3865
+				$percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3866
+				$percentage = min( $percentage, 100 );
3867 3867
                 
3868
-                $json['percentage'] = $percentage;
3869
-                wp_send_json( $json );
3870
-            } else {
3871
-                $chunk_file_paths = array();
3868
+				$json['percentage'] = $percentage;
3869
+				wp_send_json( $json );
3870
+			} else {
3871
+				$chunk_file_paths = array();
3872 3872
                 
3873
-                if ( !$items_count > 0 ) {
3874
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3875
-                } else {
3876
-                    $chunk_per_page = min( $chunk_per_page, $items_count );
3877
-                    $chunk_total_pages = ceil( $items_count / $chunk_per_page );
3873
+				if ( !$items_count > 0 ) {
3874
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
3875
+				} else {
3876
+					$chunk_per_page = min( $chunk_per_page, $items_count );
3877
+					$chunk_total_pages = ceil( $items_count / $chunk_per_page );
3878 3878
                     
3879
-                    $j = $chunk_page_no;
3880
-                    $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j );
3879
+					$j = $chunk_page_no;
3880
+					$chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j );
3881 3881
                     
3882
-                    $per_page = 500;
3883
-                    $per_page = min( $per_page, $chunk_per_page );
3884
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3882
+					$per_page = 500;
3883
+					$per_page = min( $per_page, $chunk_per_page );
3884
+					$total_pages = ceil( $chunk_per_page / $per_page );
3885 3885
                     
3886
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3887
-                        $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3886
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
3887
+						$save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3888 3888
                         
3889
-                        $clear = $i == 0 ? true : false;
3890
-                        geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3891
-                    }
3889
+						$clear = $i == 0 ? true : false;
3890
+						geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3891
+					}
3892 3892
                     
3893
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3894
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3895
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3896
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3897
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3893
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
3894
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3895
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
3896
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
3897
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
3898 3898
                         
3899
-                        $file_url = $file_url_base . $chunk_file_name;
3900
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3901
-                    }
3899
+						$file_url = $file_url_base . $chunk_file_name;
3900
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3901
+					}
3902 3902
                     
3903
-                    if ( !empty($chunk_file_paths) ) {
3904
-                        $json['total'] = $items_count;
3905
-                        $json['files'] = $chunk_file_paths;
3906
-                    } else {
3907
-                        $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3908
-                    }
3909
-                }
3910
-                wp_send_json( $json );
3911
-            }
3912
-        }
3913
-        break;
3914
-        case 'export_hoods': {
3915
-            $file_url_base = geodir_path_import_export() . '/';
3916
-            $file_name = 'gd_neighbourhoods_' . date( 'dmyHi' );
3917
-            $file_url = $file_url_base . $file_name . '.csv';
3918
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3919
-            $file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv';
3903
+					if ( !empty($chunk_file_paths) ) {
3904
+						$json['total'] = $items_count;
3905
+						$json['files'] = $chunk_file_paths;
3906
+					} else {
3907
+						$json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3908
+					}
3909
+				}
3910
+				wp_send_json( $json );
3911
+			}
3912
+		}
3913
+		break;
3914
+		case 'export_hoods': {
3915
+			$file_url_base = geodir_path_import_export() . '/';
3916
+			$file_name = 'gd_neighbourhoods_' . date( 'dmyHi' );
3917
+			$file_url = $file_url_base . $file_name . '.csv';
3918
+			$file_path = $csv_file_dir . '/' . $file_name . '.csv';
3919
+			$file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv';
3920 3920
             
3921
-            $items_count = (int)geodir_location_imex_count_neighbourhoods();
3921
+			$items_count = (int)geodir_location_imex_count_neighbourhoods();
3922 3922
             
3923
-            if ( isset( $_REQUEST['_st'] ) ) {
3924
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3925
-                $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3926
-                $percentage = min( $percentage, 100 );
3923
+			if ( isset( $_REQUEST['_st'] ) ) {
3924
+				$line_count = (int)geodir_import_export_line_count( $file_path_temp );
3925
+				$percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3926
+				$percentage = min( $percentage, 100 );
3927 3927
                 
3928
-                $json['percentage'] = $percentage;
3929
-                wp_send_json( $json );
3930
-            } else {
3931
-                $chunk_file_paths = array();
3928
+				$json['percentage'] = $percentage;
3929
+				wp_send_json( $json );
3930
+			} else {
3931
+				$chunk_file_paths = array();
3932 3932
                 
3933
-                if ( !$items_count > 0 ) {
3934
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3935
-                } else {
3936
-                    $chunk_per_page = min( $chunk_per_page, $items_count );
3937
-                    $chunk_total_pages = ceil( $items_count / $chunk_per_page );
3933
+				if ( !$items_count > 0 ) {
3934
+					$json['error'] = __( 'No records to export.', 'geodirectory' );
3935
+				} else {
3936
+					$chunk_per_page = min( $chunk_per_page, $items_count );
3937
+					$chunk_total_pages = ceil( $items_count / $chunk_per_page );
3938 3938
                     
3939
-                    $j = $chunk_page_no;
3940
-                    $chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j );
3939
+					$j = $chunk_page_no;
3940
+					$chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j );
3941 3941
                     
3942
-                    $per_page = 500;
3943
-                    $per_page = min( $per_page, $chunk_per_page );
3944
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3942
+					$per_page = 500;
3943
+					$per_page = min( $per_page, $chunk_per_page );
3944
+					$total_pages = ceil( $chunk_per_page / $per_page );
3945 3945
                     
3946
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3947
-                        $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3946
+					for ( $i = 0; $i <= $total_pages; $i++ ) {
3947
+						$save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3948 3948
                         
3949
-                        $clear = $i == 0 ? true : false;
3950
-                        geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3951
-                    }
3949
+						$clear = $i == 0 ? true : false;
3950
+						geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3951
+					}
3952 3952
                     
3953
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3954
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3955
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3956
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3957
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3953
+					if ( $wp_filesystem->exists( $file_path_temp ) ) {
3954
+						$chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3955
+						$chunk_file_name = $file_name . $chunk_page_no . '.csv';
3956
+						$file_path = $csv_file_dir . '/' . $chunk_file_name;
3957
+						$wp_filesystem->move( $file_path_temp, $file_path, true );
3958 3958
                         
3959
-                        $file_url = $file_url_base . $chunk_file_name;
3960
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3961
-                    }
3959
+						$file_url = $file_url_base . $chunk_file_name;
3960
+						$chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3961
+					}
3962 3962
                     
3963
-                    if ( !empty($chunk_file_paths) ) {
3964
-                        $json['total'] = $items_count;
3965
-                        $json['files'] = $chunk_file_paths;
3966
-                    } else {
3967
-                        $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3968
-                    }
3969
-                }
3970
-                wp_send_json( $json );
3971
-            }
3972
-        }
3973
-        break;
3974
-        case 'prepare_import':
3975
-        case 'import_cat':
3976
-        case 'import_post':
3977
-        case 'import_loc':
3978
-        case 'import_hood': {
3979
-            // WPML
3980
-            $is_wpml = geodir_is_wpml();
3981
-            if ($is_wpml) {
3982
-                global $sitepress;
3983
-                $active_lang = ICL_LANGUAGE_CODE;
3984
-            }
3985
-            // WPML
3963
+					if ( !empty($chunk_file_paths) ) {
3964
+						$json['total'] = $items_count;
3965
+						$json['files'] = $chunk_file_paths;
3966
+					} else {
3967
+						$json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3968
+					}
3969
+				}
3970
+				wp_send_json( $json );
3971
+			}
3972
+		}
3973
+		break;
3974
+		case 'prepare_import':
3975
+		case 'import_cat':
3976
+		case 'import_post':
3977
+		case 'import_loc':
3978
+		case 'import_hood': {
3979
+			// WPML
3980
+			$is_wpml = geodir_is_wpml();
3981
+			if ($is_wpml) {
3982
+				global $sitepress;
3983
+				$active_lang = ICL_LANGUAGE_CODE;
3984
+			}
3985
+			// WPML
3986 3986
             
3987
-            ini_set( 'auto_detect_line_endings', true );
3987
+			ini_set( 'auto_detect_line_endings', true );
3988 3988
             
3989
-            $uploads = wp_upload_dir();
3990
-            $uploads_dir = $uploads['path'];
3991
-            $uploads_subdir = $uploads['subdir'];
3989
+			$uploads = wp_upload_dir();
3990
+			$uploads_dir = $uploads['path'];
3991
+			$uploads_subdir = $uploads['subdir'];
3992 3992
             
3993
-            $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL;
3994
-            $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip';
3993
+			$csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL;
3994
+			$import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip';
3995 3995
             
3996
-            $csv_file_arr = explode( '/', $csv_file );
3997
-            $csv_filename = end( $csv_file_arr );
3998
-            $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename;
3996
+			$csv_file_arr = explode( '/', $csv_file );
3997
+			$csv_filename = end( $csv_file_arr );
3998
+			$target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename;
3999 3999
             
4000
-            $json['file'] = $csv_file;
4001
-            $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' );
4002
-            $file = array();
4000
+			$json['file'] = $csv_file;
4001
+			$json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' );
4002
+			$file = array();
4003 4003
 
4004
-            if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
4005
-                $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename );
4004
+			if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
4005
+				$wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename );
4006 4006
                 
4007
-                if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
4008
-                    $json['error'] = NULL;
4009
-                    $json['rows'] = 0;
4007
+				if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
4008
+					$json['error'] = NULL;
4009
+					$json['rows'] = 0;
4010 4010
                     
4011
-                    if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
4012
-                        while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
4013
-                            if ( !empty( $data ) ) {
4014
-                                $file[] = $data;
4015
-                            }
4016
-                        }
4017
-                        fclose($handle);
4018
-                    }
4011
+					if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
4012
+						while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
4013
+							if ( !empty( $data ) ) {
4014
+								$file[] = $data;
4015
+							}
4016
+						}
4017
+						fclose($handle);
4018
+					}
4019 4019
 
4020
-                    $json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
4020
+					$json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
4021 4021
                     
4022
-                    if (!$json['rows'] > 0) {
4023
-                        $json['error'] = __('No data found in csv file.', 'geodirectory');
4024
-                    }
4025
-                } else {
4026
-                    wp_send_json( $json );
4027
-                }
4028
-            } else {
4029
-                wp_send_json( $json );
4030
-            }
4022
+					if (!$json['rows'] > 0) {
4023
+						$json['error'] = __('No data found in csv file.', 'geodirectory');
4024
+					}
4025
+				} else {
4026
+					wp_send_json( $json );
4027
+				}
4028
+			} else {
4029
+				wp_send_json( $json );
4030
+			}
4031 4031
             
4032
-            if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
4033
-                wp_send_json( $json );
4034
-            }
4032
+			if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
4033
+				wp_send_json( $json );
4034
+			}
4035 4035
             
4036
-            $total = $json['rows'];
4037
-            $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1;
4038
-            $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0;
4036
+			$total = $json['rows'];
4037
+			$limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1;
4038
+			$processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0;
4039 4039
             
4040
-            $count = $limit;
4040
+			$count = $limit;
4041 4041
             
4042
-            if ($count < $total) {
4043
-                $count = $processed + $count;
4044
-                if ($count > $total) {
4045
-                    $count = $total;
4046
-                }
4047
-            } else {
4048
-                $count = $total;
4049
-            }
4042
+			if ($count < $total) {
4043
+				$count = $processed + $count;
4044
+				if ($count > $total) {
4045
+					$count = $total;
4046
+				}
4047
+			} else {
4048
+				$count = $total;
4049
+			}
4050 4050
             
4051
-            $created = 0;
4052
-            $updated = 0;
4053
-            $skipped = 0;
4054
-            $invalid = 0;
4055
-            $invalid_addr = 0;
4056
-            $images = 0;
4051
+			$created = 0;
4052
+			$updated = 0;
4053
+			$skipped = 0;
4054
+			$invalid = 0;
4055
+			$invalid_addr = 0;
4056
+			$images = 0;
4057 4057
             
4058
-            $gd_post_info = array();
4059
-            $countpost = 0;
4058
+			$gd_post_info = array();
4059
+			$countpost = 0;
4060 4060
             
4061
-            $post_types = geodir_get_posttypes();
4061
+			$post_types = geodir_get_posttypes();
4062 4062
 
4063
-            if ( $task == 'import_cat' ) {
4064
-                if (!empty($file)) {
4065
-                    $columns = isset($file[0]) ? $file[0] : NULL;
4063
+			if ( $task == 'import_cat' ) {
4064
+				if (!empty($file)) {
4065
+					$columns = isset($file[0]) ? $file[0] : NULL;
4066 4066
                     
4067
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4068
-                        $json['error'] = CSV_INVAILD_FILE;
4069
-                        wp_send_json( $json );
4070
-                        exit;
4071
-                    }
4067
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4068
+						$json['error'] = CSV_INVAILD_FILE;
4069
+						wp_send_json( $json );
4070
+						exit;
4071
+					}
4072 4072
                     
4073
-                    $gd_error_log = __('GD IMPORT CATEGORIES [ROW %d]:', 'geodirectory');
4073
+					$gd_error_log = __('GD IMPORT CATEGORIES [ROW %d]:', 'geodirectory');
4074 4074
                     
4075
-                    for ($i = 1; $i <= $limit; $i++) {
4076
-                        $index = $processed + $i;
4075
+					for ($i = 1; $i <= $limit; $i++) {
4076
+						$index = $processed + $i;
4077 4077
                         
4078
-                        if (isset($file[$index])) {
4079
-                            $row = $file[$index];
4080
-                            $row = array_map( 'trim', $row );
4081
-                            //$row = array_map( 'utf8_encode', $row );
4078
+						if (isset($file[$index])) {
4079
+							$row = $file[$index];
4080
+							$row = array_map( 'trim', $row );
4081
+							//$row = array_map( 'utf8_encode', $row );
4082 4082
                             
4083
-                            $cat_id = '';
4084
-                            $cat_name = '';
4085
-                            $cat_slug = '';
4086
-                            $cat_posttype = '';
4087
-                            $cat_parent = '';
4088
-                            $cat_description = '';
4089
-                            $cat_schema = '';
4090
-                            $cat_top_description = '';
4091
-                            $cat_image = '';
4092
-                            $cat_icon = '';
4093
-                            $cat_language = '';
4094
-                            $cat_id_original = '';
4083
+							$cat_id = '';
4084
+							$cat_name = '';
4085
+							$cat_slug = '';
4086
+							$cat_posttype = '';
4087
+							$cat_parent = '';
4088
+							$cat_description = '';
4089
+							$cat_schema = '';
4090
+							$cat_top_description = '';
4091
+							$cat_image = '';
4092
+							$cat_icon = '';
4093
+							$cat_language = '';
4094
+							$cat_id_original = '';
4095 4095
                             
4096
-                            $c = 0;
4097
-                            foreach ($columns as $column ) {
4098
-                                if ( $column == 'cat_id' ) {
4099
-                                    $cat_id = (int)$row[$c];
4100
-                                } else if ( $column == 'cat_name' ) {
4101
-                                    $cat_name = $row[$c];
4102
-                                } else if ( $column == 'cat_slug' ) {
4103
-                                    $cat_slug = $row[$c];
4104
-                                } else if ( $column == 'cat_posttype' ) {
4105
-                                    $cat_posttype = $row[$c];
4106
-                                } else if ( $column == 'cat_parent' ) {
4107
-                                    $cat_parent = trim($row[$c]);
4108
-                                } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
4109
-                                    $cat_schema = $row[$c];
4110
-                                } else if ( $column == 'cat_description' ) {
4111
-                                    $cat_description = $row[$c];
4112
-                                } else if ( $column == 'cat_top_description' ) {
4113
-                                    $cat_top_description = $row[$c];
4114
-                                } else if ( $column == 'cat_image' ) {
4115
-                                    $cat_image = $row[$c];
4116
-                                } else if ( $column == 'cat_icon' ) {
4117
-                                    $cat_icon = $row[$c];
4118
-                                }
4119
-                                // WPML
4120
-                                if ( $is_wpml ) {
4121
-                                    if ( $column == 'cat_language' ) {
4122
-                                        $cat_language = geodir_strtolower( trim( $row[$c] ) );
4123
-                                    } else if ( $column == 'cat_id_original' ) {
4124
-                                        $cat_id_original = (int)$row[$c];
4125
-                                    }
4126
-                                }
4127
-                                // WPML
4128
-                                $c++;
4129
-                            }
4096
+							$c = 0;
4097
+							foreach ($columns as $column ) {
4098
+								if ( $column == 'cat_id' ) {
4099
+									$cat_id = (int)$row[$c];
4100
+								} else if ( $column == 'cat_name' ) {
4101
+									$cat_name = $row[$c];
4102
+								} else if ( $column == 'cat_slug' ) {
4103
+									$cat_slug = $row[$c];
4104
+								} else if ( $column == 'cat_posttype' ) {
4105
+									$cat_posttype = $row[$c];
4106
+								} else if ( $column == 'cat_parent' ) {
4107
+									$cat_parent = trim($row[$c]);
4108
+								} else if ( $column == 'cat_schema' && $row[$c] != '' ) {
4109
+									$cat_schema = $row[$c];
4110
+								} else if ( $column == 'cat_description' ) {
4111
+									$cat_description = $row[$c];
4112
+								} else if ( $column == 'cat_top_description' ) {
4113
+									$cat_top_description = $row[$c];
4114
+								} else if ( $column == 'cat_image' ) {
4115
+									$cat_image = $row[$c];
4116
+								} else if ( $column == 'cat_icon' ) {
4117
+									$cat_icon = $row[$c];
4118
+								}
4119
+								// WPML
4120
+								if ( $is_wpml ) {
4121
+									if ( $column == 'cat_language' ) {
4122
+										$cat_language = geodir_strtolower( trim( $row[$c] ) );
4123
+									} else if ( $column == 'cat_id_original' ) {
4124
+										$cat_id_original = (int)$row[$c];
4125
+									}
4126
+								}
4127
+								// WPML
4128
+								$c++;
4129
+							}
4130 4130
                             
4131
-                            if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
4132
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
4131
+							if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
4132
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
4133 4133
                                 
4134
-                                $invalid++;
4135
-                                continue;
4136
-                            }
4134
+								$invalid++;
4135
+								continue;
4136
+							}
4137 4137
                             
4138
-                            // WPML
4139
-                            if ($is_wpml && $cat_language != '') {
4140
-                                $sitepress->switch_lang($cat_language, true);
4141
-                            }
4142
-                            // WPML
4138
+							// WPML
4139
+							if ($is_wpml && $cat_language != '') {
4140
+								$sitepress->switch_lang($cat_language, true);
4141
+							}
4142
+							// WPML
4143 4143
                                                         
4144
-                            $term_data = array();
4145
-                            $term_data['name'] = $cat_name;
4146
-                            $term_data['slug'] = $cat_slug;
4147
-                            $term_data['description'] = $cat_description;
4148
-                            $term_data['cat_schema'] = $cat_schema;
4149
-                            $term_data['top_description'] = $cat_top_description;
4150
-                            $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : '';
4151
-                            $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : '';
4144
+							$term_data = array();
4145
+							$term_data['name'] = $cat_name;
4146
+							$term_data['slug'] = $cat_slug;
4147
+							$term_data['description'] = $cat_description;
4148
+							$term_data['cat_schema'] = $cat_schema;
4149
+							$term_data['top_description'] = $cat_top_description;
4150
+							$term_data['image'] = $cat_image != '' ? basename( $cat_image ) : '';
4151
+							$term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : '';
4152 4152
                             
4153
-                            //$term_data = array_map( 'utf8_encode', $term_data );
4153
+							//$term_data = array_map( 'utf8_encode', $term_data );
4154 4154
                             
4155
-                            $taxonomy = $cat_posttype . 'category';
4155
+							$taxonomy = $cat_posttype . 'category';
4156 4156
                             
4157
-                            $term_data['taxonomy'] = $taxonomy;
4157
+							$term_data['taxonomy'] = $taxonomy;
4158 4158
 
4159
-                            $term_parent_id = 0;
4160
-                            if ($cat_parent != "" || (int)$cat_parent > 0) {
4161
-                                $term_parent = '';
4159
+							$term_parent_id = 0;
4160
+							if ($cat_parent != "" || (int)$cat_parent > 0) {
4161
+								$term_parent = '';
4162 4162
                                 
4163
-                                if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
4164
-                                    //
4165
-                                } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
4166
-                                    //
4167
-                                } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
4168
-                                    //
4169
-                                } else {
4170
-                                    $term_parent_data = array();
4171
-                                    $term_parent_data['name'] = $cat_parent;
4172
-                                    //$term_parent_data = array_map( 'utf8_encode', $term_parent_data );
4173
-                                    $term_parent_data['taxonomy'] = $taxonomy;
4163
+								if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
4164
+									//
4165
+								} else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
4166
+									//
4167
+								} else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
4168
+									//
4169
+								} else {
4170
+									$term_parent_data = array();
4171
+									$term_parent_data['name'] = $cat_parent;
4172
+									//$term_parent_data = array_map( 'utf8_encode', $term_parent_data );
4173
+									$term_parent_data['taxonomy'] = $taxonomy;
4174 4174
                                     
4175
-                                    $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data );
4176
-                                }
4175
+									$term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data );
4176
+								}
4177 4177
                                 
4178
-                                if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
4179
-                                    $term_parent_id = (int)$term_parent->term_id;
4180
-                                }
4181
-                            }
4182
-                            $term_data['parent'] = (int)$term_parent_id;
4178
+								if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
4179
+									$term_parent_id = (int)$term_parent->term_id;
4180
+								}
4181
+							}
4182
+							$term_data['parent'] = (int)$term_parent_id;
4183 4183
 
4184
-                            $term_id = NULL;
4185
-                            if ( $import_choice == 'update' ) {
4186
-                                if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
4187
-                                    $term_data['term_id'] = $term['term_id'];
4184
+							$term_id = NULL;
4185
+							if ( $import_choice == 'update' ) {
4186
+								if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
4187
+									$term_data['term_id'] = $term['term_id'];
4188 4188
                                     
4189
-                                    if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
4190
-                                        $updated++;
4191
-                                    } else {
4192
-                                        $invalid++;
4193
-                                        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' ) );
4194
-                                    }
4195
-                                } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4196
-                                    $term_data['term_id'] = $term['term_id'];
4189
+									if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
4190
+										$updated++;
4191
+									} else {
4192
+										$invalid++;
4193
+										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' ) );
4194
+									}
4195
+								} else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4196
+									$term_data['term_id'] = $term['term_id'];
4197 4197
                                     
4198
-                                    if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
4199
-                                        $updated++;
4200
-                                    } else {
4201
-                                        $invalid++;
4202
-                                        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' ) );
4203
-                                    }
4204
-                                } else {
4205
-                                    if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
4206
-                                        $created++;
4207
-                                    } else {
4208
-                                        $invalid++;
4209
-                                        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' ) );
4210
-                                    }
4211
-                                }
4212
-                            } else if ( $import_choice == 'skip' ) {
4213
-                                if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
4214
-                                    $skipped++;
4215
-                                } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4216
-                                    $skipped++;
4217
-                                } else {
4218
-                                    if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
4219
-                                        $created++;
4220
-                                    } else {
4221
-                                        $invalid++;
4222
-                                        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' ) );
4223
-                                    }
4224
-                                }
4225
-                            } else {
4226
-                                $invalid++;
4227
-                                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' ) );
4228
-                            }
4198
+									if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
4199
+										$updated++;
4200
+									} else {
4201
+										$invalid++;
4202
+										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' ) );
4203
+									}
4204
+								} else {
4205
+									if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
4206
+										$created++;
4207
+									} else {
4208
+										$invalid++;
4209
+										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' ) );
4210
+									}
4211
+								}
4212
+							} else if ( $import_choice == 'skip' ) {
4213
+								if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
4214
+									$skipped++;
4215
+								} else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4216
+									$skipped++;
4217
+								} else {
4218
+									if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
4219
+										$created++;
4220
+									} else {
4221
+										$invalid++;
4222
+										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' ) );
4223
+									}
4224
+								}
4225
+							} else {
4226
+								$invalid++;
4227
+								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' ) );
4228
+							}
4229 4229
                             
4230
-                            if ( $term_id ) {
4231
-                                // WPML
4232
-                                if ($is_wpml && $cat_id_original > 0 && $cat_language != '') {
4233
-                                    $wpml_element_type = 'tax_' . $taxonomy;
4234
-                                    $source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type );
4235
-                                    $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4236
-
4237
-                                    $trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type );
4230
+							if ( $term_id ) {
4231
+								// WPML
4232
+								if ($is_wpml && $cat_id_original > 0 && $cat_language != '') {
4233
+									$wpml_element_type = 'tax_' . $taxonomy;
4234
+									$source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type );
4235
+									$source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4236
+
4237
+									$trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type );
4238 4238
                                     
4239
-                                    $sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language );
4240
-                                }
4241
-                                // WPML
4239
+									$sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language );
4240
+								}
4241
+								// WPML
4242 4242
                                 
4243
-                                if ( isset( $term_data['top_description'] ) ) {
4244
-                                    update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype );
4245
-                                }
4243
+								if ( isset( $term_data['top_description'] ) ) {
4244
+									update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype );
4245
+								}
4246 4246
                                 
4247
-                                if ( isset( $term_data['cat_schema'] ) ) {
4248
-                                    update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype );
4249
-                                }
4247
+								if ( isset( $term_data['cat_schema'] ) ) {
4248
+									update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype );
4249
+								}
4250 4250
             
4251
-                                $attachment = false;
4252
-                                if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
4253
-                                    $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype );
4254
-                                    $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : '';
4251
+								$attachment = false;
4252
+								if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
4253
+									$cat_image = geodir_get_default_catimage( $term_id, $cat_posttype );
4254
+									$cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : '';
4255 4255
                                     
4256
-                                    if ( basename($cat_image) != $term_data['image'] ) {
4257
-                                        $attachment = true;
4258
-                                        update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype );
4259
-                                    }
4260
-                                }
4256
+									if ( basename($cat_image) != $term_data['image'] ) {
4257
+										$attachment = true;
4258
+										update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype );
4259
+									}
4260
+								}
4261 4261
                                 
4262
-                                if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
4263
-                                    $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype );
4264
-                                    $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : '';
4262
+								if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
4263
+									$cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype );
4264
+									$cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : '';
4265 4265
                                         
4266
-                                    if ( basename($cat_icon) != $term_data['icon'] ) {
4267
-                                        $attachment = true;
4268
-                                        update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype );
4269
-                                    }
4270
-                                }
4266
+									if ( basename($cat_icon) != $term_data['icon'] ) {
4267
+										$attachment = true;
4268
+										update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype );
4269
+									}
4270
+								}
4271 4271
                                 
4272
-                                if ( $attachment ) {
4273
-                                    $images++;
4274
-                                }
4275
-                            }
4272
+								if ( $attachment ) {
4273
+									$images++;
4274
+								}
4275
+							}
4276 4276
                             
4277
-                            // WPML
4278
-                            if ($is_wpml && $cat_language != '') {
4279
-                                $sitepress->switch_lang($active_lang, true);
4280
-                            }
4281
-                            // WPML
4282
-                        }
4283
-                    }
4284
-                }
4277
+							// WPML
4278
+							if ($is_wpml && $cat_language != '') {
4279
+								$sitepress->switch_lang($active_lang, true);
4280
+							}
4281
+							// WPML
4282
+						}
4283
+					}
4284
+				}
4285 4285
                 
4286
-                $json = array();
4287
-                $json['processed'] = $limit;
4288
-                $json['created'] = $created;
4289
-                $json['updated'] = $updated;
4290
-                $json['skipped'] = $skipped;
4291
-                $json['invalid'] = $invalid;
4292
-                $json['images'] = $images;
4286
+				$json = array();
4287
+				$json['processed'] = $limit;
4288
+				$json['created'] = $created;
4289
+				$json['updated'] = $updated;
4290
+				$json['skipped'] = $skipped;
4291
+				$json['invalid'] = $invalid;
4292
+				$json['images'] = $images;
4293 4293
                 
4294
-                wp_send_json( $json );
4295
-                exit;
4296
-            } else if ( $task == 'import_post' ) {
4297
-                //run some stuff to make the import quicker
4298
-                wp_defer_term_counting( true );
4299
-                wp_defer_comment_counting( true );
4300
-                $wpdb->query( 'SET autocommit = 0;' );
4301
-
4302
-                //remove_all_actions('publish_post');
4303
-                //remove_all_actions('transition_post_status');
4304
-                //remove_all_actions('publish_future_post');
4305
-
4306
-                if (!empty($file)) {
4307
-                    $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
4308
-                    $default_status = 'publish';
4309
-                    $current_date = date_i18n( 'Y-m-d', time() );
4294
+				wp_send_json( $json );
4295
+				exit;
4296
+			} else if ( $task == 'import_post' ) {
4297
+				//run some stuff to make the import quicker
4298
+				wp_defer_term_counting( true );
4299
+				wp_defer_comment_counting( true );
4300
+				$wpdb->query( 'SET autocommit = 0;' );
4301
+
4302
+				//remove_all_actions('publish_post');
4303
+				//remove_all_actions('transition_post_status');
4304
+				//remove_all_actions('publish_future_post');
4305
+
4306
+				if (!empty($file)) {
4307
+					$wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
4308
+					$default_status = 'publish';
4309
+					$current_date = date_i18n( 'Y-m-d', time() );
4310 4310
                     
4311
-                    $columns = isset($file[0]) ? $file[0] : NULL;
4311
+					$columns = isset($file[0]) ? $file[0] : NULL;
4312 4312
                     
4313
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4314
-                        $json['error'] = CSV_INVAILD_FILE;
4315
-                        wp_send_json( $json );
4316
-                        exit;
4317
-                    }
4313
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4314
+						$json['error'] = CSV_INVAILD_FILE;
4315
+						wp_send_json( $json );
4316
+						exit;
4317
+					}
4318 4318
 
4319
-                    $gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory');
4320
-                    $wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' );
4321
-                    $processed_actual = 0;
4322
-                    for ($i = 1; $i <= $limit; $i++) {
4323
-                        $index = $processed + $i;
4324
-                        $gd_post = array();
4319
+					$gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory');
4320
+					$wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' );
4321
+					$processed_actual = 0;
4322
+					for ($i = 1; $i <= $limit; $i++) {
4323
+						$index = $processed + $i;
4324
+						$gd_post = array();
4325 4325
                         
4326
-                        if (isset($file[$index])) {
4327
-                            $processed_actual++;
4328
-                            $row = $file[$index];
4329
-                            $row = array_map( 'trim', $row );
4330
-                            //$row = array_map( 'utf8_encode', $row );
4331
-                            $row = array_map( 'addslashes_gpc', $row );
4326
+						if (isset($file[$index])) {
4327
+							$processed_actual++;
4328
+							$row = $file[$index];
4329
+							$row = array_map( 'trim', $row );
4330
+							//$row = array_map( 'utf8_encode', $row );
4331
+							$row = array_map( 'addslashes_gpc', $row );
4332 4332
                             
4333
-                            $post_id = '';
4334
-                            $post_title = '';
4335
-                            $post_author = '';
4336
-                            $post_content = '';
4337
-                            $post_category_arr = array();
4338
-                            $default_category = '';
4339
-                            $post_tags = array();
4340
-                            $post_type = '';
4341
-                            $post_status = '';
4342
-                            $geodir_video = '';
4343
-                            $post_address = '';
4344
-                            $post_city = '';
4345
-                            $post_region = '';
4346
-                            $post_country = '';
4347
-                            $post_zip = '';
4348
-                            $post_latitude = '';
4349
-                            $post_longitude = '';
4350
-                            $post_neighbourhood = '';
4351
-                            $neighbourhood_latitude = '';
4352
-                            $neighbourhood_longitude = '';
4353
-                            $geodir_timing = '';
4354
-                            $geodir_contact = '';
4355
-                            $geodir_email = '';
4356
-                            $geodir_website = '';
4357
-                            $geodir_twitter = '';
4358
-                            $geodir_facebook = '';
4359
-                            $geodir_twitter = '';
4360
-                            $post_images = array();
4333
+							$post_id = '';
4334
+							$post_title = '';
4335
+							$post_author = '';
4336
+							$post_content = '';
4337
+							$post_category_arr = array();
4338
+							$default_category = '';
4339
+							$post_tags = array();
4340
+							$post_type = '';
4341
+							$post_status = '';
4342
+							$geodir_video = '';
4343
+							$post_address = '';
4344
+							$post_city = '';
4345
+							$post_region = '';
4346
+							$post_country = '';
4347
+							$post_zip = '';
4348
+							$post_latitude = '';
4349
+							$post_longitude = '';
4350
+							$post_neighbourhood = '';
4351
+							$neighbourhood_latitude = '';
4352
+							$neighbourhood_longitude = '';
4353
+							$geodir_timing = '';
4354
+							$geodir_contact = '';
4355
+							$geodir_email = '';
4356
+							$geodir_website = '';
4357
+							$geodir_twitter = '';
4358
+							$geodir_facebook = '';
4359
+							$geodir_twitter = '';
4360
+							$post_images = array();
4361 4361
                             
4362
-                            $expire_date = 'Never';
4362
+							$expire_date = 'Never';
4363 4363
                             
4364
-                            $language = '';
4365
-                            $original_post_id = '';
4364
+							$language = '';
4365
+							$original_post_id = '';
4366 4366
                                                         
4367
-                            $c = 0;
4368
-                            foreach ($columns as $column ) {
4369
-                                $gd_post[$column] = $row[$c];
4367
+							$c = 0;
4368
+							foreach ($columns as $column ) {
4369
+								$gd_post[$column] = $row[$c];
4370 4370
                                 
4371
-                                if ( $column == 'post_id' ) {
4372
-                                    $post_id = $row[$c];
4373
-                                } else if ( $column == 'post_title' ) {
4374
-                                    $post_title = sanitize_text_field($row[$c]);
4375
-                                } else if ( $column == 'post_author' ) {
4376
-                                    $post_author = $row[$c];
4377
-                                } else if ( $column == 'post_content' ) {
4378
-                                    $post_content = $row[$c];
4379
-                                } else if ( $column == 'post_category' && $row[$c] != '' ) {
4380
-                                    $post_category_arr = explode( ',', $row[$c] );
4381
-                                } else if ( $column == 'default_category' ) {
4382
-                                    $default_category = wp_kses_normalize_entities($row[$c]);
4383
-                                } else if ( $column == 'post_tags' && $row[$c] != '' ) {
4384
-                                    $post_tags = explode( ',', sanitize_text_field($row[$c]) );
4385
-                                } else if ( $column == 'post_type' ) {
4386
-                                    $post_type = $row[$c];
4387
-                                } else if ( $column == 'post_status' ) {
4388
-                                    $post_status = sanitize_key( $row[$c] );
4389
-                                } else if ( $column == 'is_featured' ) {
4390
-                                    $is_featured = (int)$row[$c];
4391
-                                } else if ( $column == 'geodir_video' ) {
4392
-                                    $geodir_video = $row[$c];
4393
-                                } else if ( $column == 'post_address' ) {
4394
-                                    $post_address = sanitize_text_field($row[$c]);
4395
-                                } else if ( $column == 'post_city' ) {
4396
-                                    $post_city = sanitize_text_field($row[$c]);
4397
-                                } else if ( $column == 'post_region' ) {
4398
-                                    $post_region = sanitize_text_field($row[$c]);
4399
-                                } else if ( $column == 'post_country' ) {
4400
-                                    $post_country = sanitize_text_field($row[$c]);
4401
-                                } else if ( $column == 'post_zip' ) {
4402
-                                    $post_zip = sanitize_text_field($row[$c]);
4403
-                                } else if ( $column == 'post_latitude' ) {
4404
-                                    $post_latitude = sanitize_text_field($row[$c]);
4405
-                                } else if ( $column == 'post_longitude' ) {
4406
-                                    $post_longitude = sanitize_text_field($row[$c]);
4407
-                                } else if ( $column == 'post_neighbourhood' ) {
4408
-                                    $post_neighbourhood = sanitize_text_field($row[$c]);
4409
-                                    unset($gd_post[$column]);
4410
-                                } else if ( $column == 'neighbourhood_latitude' ) {
4411
-                                    $neighbourhood_latitude = sanitize_text_field($row[$c]);
4412
-                                } else if ( $column == 'neighbourhood_longitude' ) {
4413
-                                    $neighbourhood_longitude = sanitize_text_field($row[$c]);
4414
-                                } else if ( $column == 'geodir_timing' ) {
4415
-                                    $geodir_timing = sanitize_text_field($row[$c]);
4416
-                                } else if ( $column == 'geodir_contact' ) {
4417
-                                    $geodir_contact = sanitize_text_field($row[$c]);
4418
-                                } else if ( $column == 'geodir_email' ) {
4419
-                                    $geodir_email = sanitize_email($row[$c]);
4420
-                                } else if ( $column == 'geodir_website' ) {
4421
-                                    $geodir_website = sanitize_text_field($row[$c]);
4422
-                                } else if ( $column == 'geodir_twitter' ) {
4423
-                                    $geodir_twitter = sanitize_text_field($row[$c]);
4424
-                                } else if ( $column == 'geodir_facebook' ) {
4425
-                                    $geodir_facebook = sanitize_text_field($row[$c]);
4426
-                                } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
4427
-                                    $post_images[] = $row[$c];
4428
-                                } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
4429
-                                    $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) );
4430
-                                } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
4431
-                                    $row[$c] = str_replace('/', '-', $row[$c]);
4432
-                                    $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) );
4433
-                                }
4434
-                                // WPML
4435
-                                if ($is_wpml) {
4436
-                                    if ($column == 'language') {
4437
-                                        $language = geodir_strtolower(trim($row[$c]));
4438
-                                    } else if ($column == 'original_post_id') {
4439
-                                        $original_post_id = (int)$row[$c];
4440
-                                    }
4441
-                                }
4442
-                                // WPML
4443
-                                $c++;
4444
-                            }
4371
+								if ( $column == 'post_id' ) {
4372
+									$post_id = $row[$c];
4373
+								} else if ( $column == 'post_title' ) {
4374
+									$post_title = sanitize_text_field($row[$c]);
4375
+								} else if ( $column == 'post_author' ) {
4376
+									$post_author = $row[$c];
4377
+								} else if ( $column == 'post_content' ) {
4378
+									$post_content = $row[$c];
4379
+								} else if ( $column == 'post_category' && $row[$c] != '' ) {
4380
+									$post_category_arr = explode( ',', $row[$c] );
4381
+								} else if ( $column == 'default_category' ) {
4382
+									$default_category = wp_kses_normalize_entities($row[$c]);
4383
+								} else if ( $column == 'post_tags' && $row[$c] != '' ) {
4384
+									$post_tags = explode( ',', sanitize_text_field($row[$c]) );
4385
+								} else if ( $column == 'post_type' ) {
4386
+									$post_type = $row[$c];
4387
+								} else if ( $column == 'post_status' ) {
4388
+									$post_status = sanitize_key( $row[$c] );
4389
+								} else if ( $column == 'is_featured' ) {
4390
+									$is_featured = (int)$row[$c];
4391
+								} else if ( $column == 'geodir_video' ) {
4392
+									$geodir_video = $row[$c];
4393
+								} else if ( $column == 'post_address' ) {
4394
+									$post_address = sanitize_text_field($row[$c]);
4395
+								} else if ( $column == 'post_city' ) {
4396
+									$post_city = sanitize_text_field($row[$c]);
4397
+								} else if ( $column == 'post_region' ) {
4398
+									$post_region = sanitize_text_field($row[$c]);
4399
+								} else if ( $column == 'post_country' ) {
4400
+									$post_country = sanitize_text_field($row[$c]);
4401
+								} else if ( $column == 'post_zip' ) {
4402
+									$post_zip = sanitize_text_field($row[$c]);
4403
+								} else if ( $column == 'post_latitude' ) {
4404
+									$post_latitude = sanitize_text_field($row[$c]);
4405
+								} else if ( $column == 'post_longitude' ) {
4406
+									$post_longitude = sanitize_text_field($row[$c]);
4407
+								} else if ( $column == 'post_neighbourhood' ) {
4408
+									$post_neighbourhood = sanitize_text_field($row[$c]);
4409
+									unset($gd_post[$column]);
4410
+								} else if ( $column == 'neighbourhood_latitude' ) {
4411
+									$neighbourhood_latitude = sanitize_text_field($row[$c]);
4412
+								} else if ( $column == 'neighbourhood_longitude' ) {
4413
+									$neighbourhood_longitude = sanitize_text_field($row[$c]);
4414
+								} else if ( $column == 'geodir_timing' ) {
4415
+									$geodir_timing = sanitize_text_field($row[$c]);
4416
+								} else if ( $column == 'geodir_contact' ) {
4417
+									$geodir_contact = sanitize_text_field($row[$c]);
4418
+								} else if ( $column == 'geodir_email' ) {
4419
+									$geodir_email = sanitize_email($row[$c]);
4420
+								} else if ( $column == 'geodir_website' ) {
4421
+									$geodir_website = sanitize_text_field($row[$c]);
4422
+								} else if ( $column == 'geodir_twitter' ) {
4423
+									$geodir_twitter = sanitize_text_field($row[$c]);
4424
+								} else if ( $column == 'geodir_facebook' ) {
4425
+									$geodir_facebook = sanitize_text_field($row[$c]);
4426
+								} else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
4427
+									$post_images[] = $row[$c];
4428
+								} else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
4429
+									$expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) );
4430
+								} else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
4431
+									$row[$c] = str_replace('/', '-', $row[$c]);
4432
+									$expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) );
4433
+								}
4434
+								// WPML
4435
+								if ($is_wpml) {
4436
+									if ($column == 'language') {
4437
+										$language = geodir_strtolower(trim($row[$c]));
4438
+									} else if ($column == 'original_post_id') {
4439
+										$original_post_id = (int)$row[$c];
4440
+									}
4441
+								}
4442
+								// WPML
4443
+								$c++;
4444
+							}
4445 4445
                             
4446
-                            // WPML
4447
-                            if ($is_wpml && $language != '') {
4448
-                                $sitepress->switch_lang($language, true);
4449
-                            }
4450
-                            // WPML
4446
+							// WPML
4447
+							if ($is_wpml && $language != '') {
4448
+								$sitepress->switch_lang($language, true);
4449
+							}
4450
+							// WPML
4451 4451
 
4452
-                            $gd_post['IMAGE'] = $post_images;
4452
+							$gd_post['IMAGE'] = $post_images;
4453 4453
                             
4454
-                            $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
4455
-                            $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
4454
+							$post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
4455
+							$post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
4456 4456
                                                                                                                 
4457
-                            $valid = true;
4458
-                            
4459
-                            if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
4460
-                                $invalid++;
4461
-                                $valid = false;
4462
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
4463
-                            }
4457
+							$valid = true;
4464 4458
                             
4465
-                            $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
4466
-                            if ( $location_allowed ) {
4467
-                                $location_result = geodir_get_default_location();
4468
-                                if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
4469
-                                    $invalid_addr++;
4470
-                                    $valid = false;
4471
-                                    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' ) );
4472
-                                } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
4473
-                                    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 ) ) ) {
4474
-                                        $invalid_addr++;
4475
-                                        $valid = false;
4476
-                                        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' ) );
4477
-                                    } else {
4478
-                                        if (!$location_manager) {
4479
-                                            $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.
4480
-                                        }
4481
-                                    }
4482
-                                }
4483
-                            }
4459
+							if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
4460
+								$invalid++;
4461
+								$valid = false;
4462
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
4463
+							}
4484 4464
                             
4485
-                            if ( !$valid ) {
4486
-                                continue;
4487
-                            }
4465
+							$location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
4466
+							if ( $location_allowed ) {
4467
+								$location_result = geodir_get_default_location();
4468
+								if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
4469
+									$invalid_addr++;
4470
+									$valid = false;
4471
+									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' ) );
4472
+								} else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
4473
+									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 ) ) ) {
4474
+										$invalid_addr++;
4475
+										$valid = false;
4476
+										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' ) );
4477
+									} else {
4478
+										if (!$location_manager) {
4479
+											$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.
4480
+										}
4481
+									}
4482
+								}
4483
+							}
4484
+                            
4485
+							if ( !$valid ) {
4486
+								continue;
4487
+							}
4488 4488
 
4489
-                            $cat_taxonomy = $post_type . 'category';
4490
-                            $tags_taxonomy = $post_type . '_tags';
4489
+							$cat_taxonomy = $post_type . 'category';
4490
+							$tags_taxonomy = $post_type . '_tags';
4491 4491
                             
4492
-                            if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
4493
-                                $post_category_arr = array_merge(array($default_category), $post_category_arr);
4494
-                            }
4492
+							if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
4493
+								$post_category_arr = array_merge(array($default_category), $post_category_arr);
4494
+							}
4495 4495
 
4496
-                            $post_category = array();
4497
-                            $default_category_id = NULL;
4498
-                            if ( !empty( $post_category_arr ) ) {
4499
-                                foreach ( $post_category_arr as $value ) {
4500
-                                    $category_name = wp_kses_normalize_entities( trim( $value ) );
4496
+							$post_category = array();
4497
+							$default_category_id = NULL;
4498
+							if ( !empty( $post_category_arr ) ) {
4499
+								foreach ( $post_category_arr as $value ) {
4500
+									$category_name = wp_kses_normalize_entities( trim( $value ) );
4501 4501
                                     
4502
-                                    if ( $category_name != '' ) {
4503
-                                        $term_category = array();
4502
+									if ( $category_name != '' ) {
4503
+										$term_category = array();
4504 4504
                                         
4505
-                                        if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
4506
-                                            $term_category = $term;
4507
-                                        } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
4508
-                                            $term_category = $term;
4509
-                                        } else {
4510
-                                            $term_data = array();
4511
-                                            $term_data['name'] = $category_name;
4512
-                                            $term_data['taxonomy'] = $cat_taxonomy;
4505
+										if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
4506
+											$term_category = $term;
4507
+										} else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
4508
+											$term_category = $term;
4509
+										} else {
4510
+											$term_data = array();
4511
+											$term_data['name'] = $category_name;
4512
+											$term_data['taxonomy'] = $cat_taxonomy;
4513 4513
                                             
4514
-                                            $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data );
4515
-                                            if ( $term_id ) {
4516
-                                                $term_category = get_term( $term_id, $cat_taxonomy );
4517
-                                            }
4518
-                                        }
4514
+											$term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data );
4515
+											if ( $term_id ) {
4516
+												$term_category = get_term( $term_id, $cat_taxonomy );
4517
+											}
4518
+										}
4519 4519
                                         
4520
-                                        if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
4521
-                                            $post_category[] = intval($term_category->term_id);
4520
+										if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
4521
+											$post_category[] = intval($term_category->term_id);
4522 4522
                                             
4523
-                                            if ($category_name == $default_category) {
4524
-                                                $default_category_id = intval($term_category->term_id);
4525
-                                            }
4526
-                                        }
4527
-                                    }
4528
-                                }
4529
-                            }
4523
+											if ($category_name == $default_category) {
4524
+												$default_category_id = intval($term_category->term_id);
4525
+											}
4526
+										}
4527
+									}
4528
+								}
4529
+							}
4530 4530
 
4531
-                            $save_post = array();
4532
-                            $save_post['post_title'] = $post_title;
4533
-                            $save_post['post_content'] = $post_content;
4534
-                            $save_post['post_type'] = $post_type;
4535
-                            $save_post['post_author'] = $post_author;
4536
-                            $save_post['post_status'] = $post_status;
4537
-                            $save_post['post_category'] = $post_category;
4538
-                            $save_post['post_tags'] = $post_tags;
4539
-
4540
-                            $saved_post_id = NULL;
4541
-                            if ( $import_choice == 'update' ) {
4542
-                                $gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' );
4531
+							$save_post = array();
4532
+							$save_post['post_title'] = $post_title;
4533
+							$save_post['post_content'] = $post_content;
4534
+							$save_post['post_type'] = $post_type;
4535
+							$save_post['post_author'] = $post_author;
4536
+							$save_post['post_status'] = $post_status;
4537
+							$save_post['post_category'] = $post_category;
4538
+							$save_post['post_tags'] = $post_tags;
4539
+
4540
+							$saved_post_id = NULL;
4541
+							if ( $import_choice == 'update' ) {
4542
+								$gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' );
4543 4543
                                 
4544
-                                if ( $post_id > 0 && get_post( $post_id ) ) {
4545
-                                    $save_post['ID'] = $post_id;
4544
+								if ( $post_id > 0 && get_post( $post_id ) ) {
4545
+									$save_post['ID'] = $post_id;
4546 4546
                                     
4547
-                                    if ( $saved_post_id = wp_update_post( $save_post, true ) ) {
4548
-                                        if ( is_wp_error( $saved_post_id ) ) {
4549
-                                            $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4550
-                                            $saved_post_id = 0;
4551
-                                        } else {
4552
-                                            $saved_post_id = $post_id;
4553
-                                            $updated++;
4554
-                                        }
4555
-                                    }
4556
-                                } else {
4557
-                                    if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4558
-                                        if ( is_wp_error( $saved_post_id ) ) {
4559
-                                            $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4560
-                                            $saved_post_id = 0;
4561
-                                        } else {
4562
-                                            $created++;
4563
-                                        }
4564
-                                    }
4565
-                                }
4547
+									if ( $saved_post_id = wp_update_post( $save_post, true ) ) {
4548
+										if ( is_wp_error( $saved_post_id ) ) {
4549
+											$gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4550
+											$saved_post_id = 0;
4551
+										} else {
4552
+											$saved_post_id = $post_id;
4553
+											$updated++;
4554
+										}
4555
+									}
4556
+								} else {
4557
+									if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4558
+										if ( is_wp_error( $saved_post_id ) ) {
4559
+											$gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4560
+											$saved_post_id = 0;
4561
+										} else {
4562
+											$created++;
4563
+										}
4564
+									}
4565
+								}
4566 4566
                                 
4567
-                                if ( !$saved_post_id > 0 ) {
4568
-                                    $invalid++;
4569
-                                    geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error );
4570
-                                }
4571
-                            } else if ( $import_choice == 'skip' ) {
4572
-                                if ( $post_id > 0 && get_post( $post_id ) ) {
4573
-                                    $skipped++;	
4574
-                                } else {
4575
-                                    if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4576
-                                        if ( is_wp_error( $saved_post_id ) ) {
4577
-                                            $invalid++;
4567
+								if ( !$saved_post_id > 0 ) {
4568
+									$invalid++;
4569
+									geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error );
4570
+								}
4571
+							} else if ( $import_choice == 'skip' ) {
4572
+								if ( $post_id > 0 && get_post( $post_id ) ) {
4573
+									$skipped++;	
4574
+								} else {
4575
+									if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4576
+										if ( is_wp_error( $saved_post_id ) ) {
4577
+											$invalid++;
4578 4578
                                             
4579
-                                            geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error );
4580
-                                            $saved_post_id = 0;
4581
-                                        } else {
4582
-                                            $created++;
4583
-                                        }
4584
-                                    } else {
4585
-                                        $invalid++;
4579
+											geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error );
4580
+											$saved_post_id = 0;
4581
+										} else {
4582
+											$created++;
4583
+										}
4584
+									} else {
4585
+										$invalid++;
4586 4586
                                         
4587
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4588
-                                    }
4589
-                                }
4590
-                            } else {
4591
-                                $invalid++;
4587
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4588
+									}
4589
+								}
4590
+							} else {
4591
+								$invalid++;
4592 4592
                                 
4593
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4594
-                            }
4593
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4594
+							}
4595 4595
 
4596
-                            if ( (int)$saved_post_id > 0 ) {
4597
-                                // WPML
4598
-                                if ($is_wpml && $original_post_id > 0 && $language != '') {
4599
-                                    $wpml_post_type = 'post_' . $post_type;
4600
-                                    $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type );
4601
-                                    $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4596
+							if ( (int)$saved_post_id > 0 ) {
4597
+								// WPML
4598
+								if ($is_wpml && $original_post_id > 0 && $language != '') {
4599
+									$wpml_post_type = 'post_' . $post_type;
4600
+									$source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type );
4601
+									$source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4602 4602
 
4603
-                                    $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type );
4603
+									$trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type );
4604 4604
                                     
4605
-                                    $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language );
4606
-                                }
4607
-                                // WPML
4608
-                                $gd_post_info = geodir_get_post_info( $saved_post_id );
4605
+									$sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language );
4606
+								}
4607
+								// WPML
4608
+								$gd_post_info = geodir_get_post_info( $saved_post_id );
4609 4609
                                 
4610
-                                $gd_post['post_id'] = $saved_post_id;
4611
-                                $gd_post['ID'] = $saved_post_id;
4612
-                                $gd_post['post_tags'] = $post_tags;
4613
-                                $gd_post['post_title'] = $post_title;
4614
-                                $gd_post['post_status'] = $post_status;
4615
-                                $gd_post['submit_time'] = time();
4616
-                                $gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR'];
4610
+								$gd_post['post_id'] = $saved_post_id;
4611
+								$gd_post['ID'] = $saved_post_id;
4612
+								$gd_post['post_tags'] = $post_tags;
4613
+								$gd_post['post_title'] = $post_title;
4614
+								$gd_post['post_status'] = $post_status;
4615
+								$gd_post['submit_time'] = time();
4616
+								$gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR'];
4617 4617
                                                     
4618
-                                // post location
4619
-                                $post_location_id = 0;
4620
-                                if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
4621
-                                    $gd_post['post_neighbourhood'] = '';
4618
+								// post location
4619
+								$post_location_id = 0;
4620
+								if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
4621
+									$gd_post['post_neighbourhood'] = '';
4622 4622
                                     
4623
-                                    $post_location_info = array(
4624
-                                                                'city' => $post_city,
4625
-                                                                'region' => $post_region,
4626
-                                                                'country' => $post_country,
4627
-                                                                'geo_lat' => $post_latitude,
4628
-                                                                'geo_lng' => $post_longitude
4629
-                                                            );
4630
-                                    if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
4631
-                                        $post_location_id = $location_id;
4632
-                                    }
4623
+									$post_location_info = array(
4624
+																'city' => $post_city,
4625
+																'region' => $post_region,
4626
+																'country' => $post_country,
4627
+																'geo_lat' => $post_latitude,
4628
+																'geo_lng' => $post_longitude
4629
+															);
4630
+									if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
4631
+										$post_location_id = $location_id;
4632
+									}
4633 4633
                                     
4634
-                                    if ($post_location_id > 0 && $neighbourhood_active && !empty($post_neighbourhood)) {
4635
-                                        $neighbourhood_info = geodir_location_neighbourhood_by_name_loc_id($post_neighbourhood, $post_location_id);
4634
+									if ($post_location_id > 0 && $neighbourhood_active && !empty($post_neighbourhood)) {
4635
+										$neighbourhood_info = geodir_location_neighbourhood_by_name_loc_id($post_neighbourhood, $post_location_id);
4636 4636
 
4637
-                                        $hood_data = array();
4638
-                                        $hood_data['hood_location_id'] = $post_location_id;
4639
-                                        $hood_data['hood_name'] = $post_neighbourhood;
4637
+										$hood_data = array();
4638
+										$hood_data['hood_location_id'] = $post_location_id;
4639
+										$hood_data['hood_name'] = $post_neighbourhood;
4640 4640
                                         
4641
-                                        if (!empty($neighbourhood_info)) {
4642
-                                            $hood_data['hood_id'] = $neighbourhood_info->hood_id;
4643
-                                            $hood_data['hood_slug'] = $neighbourhood_info->hood_slug;
4641
+										if (!empty($neighbourhood_info)) {
4642
+											$hood_data['hood_id'] = $neighbourhood_info->hood_id;
4643
+											$hood_data['hood_slug'] = $neighbourhood_info->hood_slug;
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
-                                            }
4649
-                                        }
4645
+											if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
4646
+												$neighbourhood_latitude = $neighbourhood_info->hood_latitude;
4647
+												$neighbourhood_longitude = $neighbourhood_info->hood_longitude;
4648
+											}
4649
+										}
4650 4650
                                         
4651
-                                        if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
4652
-                                            $neighbourhood_latitude = $neighbourhood_info->hood_latitude;
4653
-                                            $neighbourhood_longitude = $neighbourhood_info->hood_longitude;
4654
-                                        }
4651
+										if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
4652
+											$neighbourhood_latitude = $neighbourhood_info->hood_latitude;
4653
+											$neighbourhood_longitude = $neighbourhood_info->hood_longitude;
4654
+										}
4655 4655
                                         
4656
-                                        $hood_data['hood_latitude'] = $post_latitude;
4657
-                                        $hood_data['hood_longitude'] = $post_longitude;
4656
+										$hood_data['hood_latitude'] = $post_latitude;
4657
+										$hood_data['hood_longitude'] = $post_longitude;
4658 4658
 
4659
-                                        $neighbourhood_info = geodir_location_insert_update_neighbourhood($hood_data);
4660
-                                        if (!empty($neighbourhood_info) && isset($neighbourhood_info->hood_slug)) {
4661
-                                            $gd_post['post_neighbourhood'] = $neighbourhood_info->hood_slug;
4662
-                                        }
4663
-                                    }
4664
-                                }
4665
-                                $gd_post['post_location_id'] = $post_location_id;
4659
+										$neighbourhood_info = geodir_location_insert_update_neighbourhood($hood_data);
4660
+										if (!empty($neighbourhood_info) && isset($neighbourhood_info->hood_slug)) {
4661
+											$gd_post['post_neighbourhood'] = $neighbourhood_info->hood_slug;
4662
+										}
4663
+									}
4664
+								}
4665
+								$gd_post['post_location_id'] = $post_location_id;
4666 4666
                                 
4667
-                                // post package info
4668
-                                $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0;
4669
-                                if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
4670
-                                    $package_id = $gd_post_info->package_id;
4671
-                                }
4667
+								// post package info
4668
+								$package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0;
4669
+								if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
4670
+									$package_id = $gd_post_info->package_id;
4671
+								}
4672 4672
                                 
4673
-                                $package_info = array();
4674
-                                if ($package_id && function_exists('geodir_get_package_info_by_id')) {
4675
-                                    $package_info = (array)geodir_get_package_info_by_id($package_id);
4673
+								$package_info = array();
4674
+								if ($package_id && function_exists('geodir_get_package_info_by_id')) {
4675
+									$package_info = (array)geodir_get_package_info_by_id($package_id);
4676 4676
                                     
4677
-                                    if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
4678
-                                        $package_info = array();
4679
-                                    }
4680
-                                }
4677
+									if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
4678
+										$package_info = array();
4679
+									}
4680
+								}
4681 4681
                                 
4682
-                                if (empty($package_info)) {
4683
-                                    $package_info = (array)geodir_post_package_info( array(), '', $post_type );
4684
-                                }
4682
+								if (empty($package_info)) {
4683
+									$package_info = (array)geodir_post_package_info( array(), '', $post_type );
4684
+								}
4685 4685
                                  
4686
-                                if (!empty($package_info))	 {
4687
-                                    $package_id = $package_info['pid'];
4686
+								if (!empty($package_info))	 {
4687
+									$package_id = $package_info['pid'];
4688 4688
                                     
4689
-                                    if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
4690
-                                        $gd_post['expire_date'] = $expire_date;
4691
-                                    } else {
4692
-                                        if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
4693
-                                            $gd_post['alive_days'] = (int)$package_info['days'];
4694
-                                            $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) );
4695
-                                        } else {
4696
-                                            $gd_post['expire_date'] = 'Never';
4697
-                                        }
4698
-                                    }
4689
+									if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
4690
+										$gd_post['expire_date'] = $expire_date;
4691
+									} else {
4692
+										if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
4693
+											$gd_post['alive_days'] = (int)$package_info['days'];
4694
+											$gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) );
4695
+										} else {
4696
+											$gd_post['expire_date'] = 'Never';
4697
+										}
4698
+									}
4699 4699
                                     
4700
-                                    $gd_post['package_id'] = $package_id;
4701
-                                }
4700
+									$gd_post['package_id'] = $package_id;
4701
+								}
4702 4702
 
4703
-                                $table = $plugin_prefix . $post_type . '_detail';
4703
+								$table = $plugin_prefix . $post_type . '_detail';
4704 4704
                                 
4705
-                                if ($post_type == 'gd_event') {
4706
-                                    $gd_post = geodir_imex_process_event_data($gd_post);
4707
-                                }
4705
+								if ($post_type == 'gd_event') {
4706
+									$gd_post = geodir_imex_process_event_data($gd_post);
4707
+								}
4708 4708
                                 
4709
-                                if (isset($gd_post['post_id'])) {
4710
-                                    unset($gd_post['post_id']);
4711
-                                }
4709
+								if (isset($gd_post['post_id'])) {
4710
+									unset($gd_post['post_id']);
4711
+								}
4712 4712
 
4713
-                                // Export franchise fields
4714
-                                $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false;
4715
-                                if ($is_franchise_active) {
4716
-                                    if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
4717
-                                        $gd_franchise_lock = array();
4713
+								// Export franchise fields
4714
+								$is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false;
4715
+								if ($is_franchise_active) {
4716
+									if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
4717
+										$gd_franchise_lock = array();
4718 4718
                                         
4719
-                                        if ( isset( $gd_post['gd_franchise_lock'] ) ) {
4720
-                                            $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
4721
-                                            $gd_franchise_lock = trim( $gd_franchise_lock );
4722
-                                            $gd_franchise_lock = explode( ",", $gd_franchise_lock );
4723
-                                        }
4719
+										if ( isset( $gd_post['gd_franchise_lock'] ) ) {
4720
+											$gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
4721
+											$gd_franchise_lock = trim( $gd_franchise_lock );
4722
+											$gd_franchise_lock = explode( ",", $gd_franchise_lock );
4723
+										}
4724 4724
                                         
4725
-                                        update_post_meta( $saved_post_id, 'gd_is_franchise', 1 );
4726
-                                        update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock );
4727
-                                    } else {
4728
-                                        if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
4729
-                                            geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] );
4730
-                                        }
4731
-                                    }
4732
-                                }
4725
+										update_post_meta( $saved_post_id, 'gd_is_franchise', 1 );
4726
+										update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock );
4727
+									} else {
4728
+										if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
4729
+											geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] );
4730
+										}
4731
+									}
4732
+								}
4733 4733
                                 
4734
-                                if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
4735
-                                    $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) );
4736
-                                    if ($default_category_id) {
4737
-                                        $save_post['post_default_category'] = $default_category_id;
4738
-                                        $gd_post['default_category'] = $default_category_id;
4739
-                                    }
4740
-                                    $gd_post[$cat_taxonomy] = $save_post['post_category'];
4741
-                                }
4734
+								if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
4735
+									$save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) );
4736
+									if ($default_category_id) {
4737
+										$save_post['post_default_category'] = $default_category_id;
4738
+										$gd_post['default_category'] = $default_category_id;
4739
+									}
4740
+									$gd_post[$cat_taxonomy] = $save_post['post_category'];
4741
+								}
4742 4742
                                 
4743
-                                // Save post info
4744
-                                geodir_save_post_info( $saved_post_id, $gd_post );
4745
-                                // post taxonomies
4746
-                                if ( !empty( $save_post['post_category'] ) ) {
4747
-                                    wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy );
4743
+								// Save post info
4744
+								geodir_save_post_info( $saved_post_id, $gd_post );
4745
+								// post taxonomies
4746
+								if ( !empty( $save_post['post_category'] ) ) {
4747
+									wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy );
4748 4748
                                     
4749
-                                    $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : '';
4750
-                                    if ($default_category_id) {
4751
-                                        $post_default_category = $default_category_id;
4752
-                                    }
4753
-                                    $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy);
4754
-                                    $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
4755
-                                    $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
4749
+									$post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : '';
4750
+									if ($default_category_id) {
4751
+										$post_default_category = $default_category_id;
4752
+									}
4753
+									$post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy);
4754
+									$save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
4755
+									$post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
4756 4756
                                     
4757
-                                    if ($post_category_str != '' && $post_default_category) {
4758
-                                        $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str);
4759
-                                    }
4757
+									if ($post_category_str != '' && $post_default_category) {
4758
+										$post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str);
4759
+									}
4760 4760
                                     
4761
-                                    $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : '';
4761
+									$post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : '';
4762 4762
                                     
4763
-                                    geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str );
4764
-                                }
4763
+									geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str );
4764
+								}
4765 4765
 
4766
-                                if ( !empty( $save_post['post_tags'] ) ) {
4767
-                                    wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy );
4768
-                                }
4766
+								if ( !empty( $save_post['post_tags'] ) ) {
4767
+									wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy );
4768
+								}
4769 4769
 
4770
-                                // Post images
4771
-                                if ( !empty( $post_images ) ) {
4772
-                                    $post_images = array_unique($post_images);
4770
+								// Post images
4771
+								if ( !empty( $post_images ) ) {
4772
+									$post_images = array_unique($post_images);
4773 4773
                                     
4774
-                                    $old_post_images_arr = array();
4775
-                                    $saved_post_images_arr = array();
4774
+									$old_post_images_arr = array();
4775
+									$saved_post_images_arr = array();
4776 4776
                                     
4777
-                                    $order = 1;
4777
+									$order = 1;
4778 4778
                                     
4779
-                                    $old_post_images = geodir_get_images( $saved_post_id );
4780
-                                    if (!empty($old_post_images)) {
4781
-                                        foreach( $old_post_images as $old_post_image ) {
4782
-                                            if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
4783
-                                                $old_post_images_arr[] = $old_post_image->file;
4784
-                                            }
4785
-                                        }
4786
-                                    }
4779
+									$old_post_images = geodir_get_images( $saved_post_id );
4780
+									if (!empty($old_post_images)) {
4781
+										foreach( $old_post_images as $old_post_image ) {
4782
+											if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
4783
+												$old_post_images_arr[] = $old_post_image->file;
4784
+											}
4785
+										}
4786
+									}
4787 4787
                                     
4788
-                                    foreach ( $post_images as $post_image ) {
4789
-                                        $image_name = basename( $post_image );
4790
-                                        $saved_post_images_arr[] = $image_name;
4788
+									foreach ( $post_images as $post_image ) {
4789
+										$image_name = basename( $post_image );
4790
+										$saved_post_images_arr[] = $image_name;
4791 4791
                                         
4792
-                                        if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
4793
-                                            continue; // Skip if image already exists.
4794
-                                        }
4792
+										if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
4793
+											continue; // Skip if image already exists.
4794
+										}
4795 4795
                                         
4796
-                                        $image_name_parts = explode( '.', $image_name );
4797
-                                        array_pop( $image_name_parts );
4798
-                                        $proper_image_name = implode( '.', $image_name_parts );
4796
+										$image_name_parts = explode( '.', $image_name );
4797
+										array_pop( $image_name_parts );
4798
+										$proper_image_name = implode( '.', $image_name_parts );
4799 4799
                                         
4800
-                                        $arr_file_type = wp_check_filetype( $image_name );
4800
+										$arr_file_type = wp_check_filetype( $image_name );
4801 4801
                                         
4802
-                                        if ( !empty( $arr_file_type ) ) {
4803
-                                            $uploaded_file_type = $arr_file_type['type'];
4802
+										if ( !empty( $arr_file_type ) ) {
4803
+											$uploaded_file_type = $arr_file_type['type'];
4804 4804
                                             
4805
-                                            $attachment = array();
4806
-                                            $attachment['post_id'] = $saved_post_id;
4807
-                                            $attachment['title'] = $proper_image_name;
4808
-                                            $attachment['content'] = '';
4809
-                                            $attachment['file'] = $uploads_subdir . '/' . $image_name;
4810
-                                            $attachment['mime_type'] = $uploaded_file_type;
4811
-                                            $attachment['menu_order'] = $order;
4812
-                                            $attachment['is_featured'] = 0;
4813
-
4814
-                                            $attachment_set = '';
4815
-                                            foreach ( $attachment as $key => $val ) {
4816
-                                                if ( $val != '' ) {
4817
-                                                    $attachment_set .= $key . " = '" . $val . "', ";
4818
-                                                }
4819
-                                            }
4820
-                                            $attachment_set = trim( $attachment_set, ", " );
4805
+											$attachment = array();
4806
+											$attachment['post_id'] = $saved_post_id;
4807
+											$attachment['title'] = $proper_image_name;
4808
+											$attachment['content'] = '';
4809
+											$attachment['file'] = $uploads_subdir . '/' . $image_name;
4810
+											$attachment['mime_type'] = $uploaded_file_type;
4811
+											$attachment['menu_order'] = $order;
4812
+											$attachment['is_featured'] = 0;
4813
+
4814
+											$attachment_set = '';
4815
+											foreach ( $attachment as $key => $val ) {
4816
+												if ( $val != '' ) {
4817
+													$attachment_set .= $key . " = '" . $val . "', ";
4818
+												}
4819
+											}
4820
+											$attachment_set = trim( $attachment_set, ", " );
4821 4821
                                                                                         
4822
-                                            // Add new attachment
4823
-                                            $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set );
4822
+											// Add new attachment
4823
+											$wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set );
4824 4824
                                                                                         
4825
-                                            $order++;
4826
-                                        }
4827
-                                    }
4825
+											$order++;
4826
+										}
4827
+									}
4828 4828
 
4829
-                                    $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/",  $saved_post_images_arr) . "' )" : '';
4830
-                                    // Remove previous attachment
4831
-                                    $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql );
4829
+									$saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/",  $saved_post_images_arr) . "' )" : '';
4830
+									// Remove previous attachment
4831
+									$wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql );
4832 4832
                                     
4833
-                                    if ( !empty( $saved_post_images_arr ) ) {
4834
-                                        $menu_order = 1;
4833
+									if ( !empty( $saved_post_images_arr ) ) {
4834
+										$menu_order = 1;
4835 4835
                                         
4836
-                                        foreach ( $saved_post_images_arr as $img_name ) {
4837
-                                            $wpdb->query( $wpdb->prepare( "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d WHERE post_id =%d AND file LIKE %s", array( $menu_order, $saved_post_id, '%/' . $img_name ) ) );
4836
+										foreach ( $saved_post_images_arr as $img_name ) {
4837
+											$wpdb->query( $wpdb->prepare( "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d WHERE post_id =%d AND file LIKE %s", array( $menu_order, $saved_post_id, '%/' . $img_name ) ) );
4838 4838
                                             
4839
-                                            if( $menu_order == 1 ) {
4840
-                                                if ( $featured_image = $wpdb->get_var( $wpdb->prepare( "SELECT file FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =%d AND file LIKE %s", array( $saved_post_id, '%/' . $img_name ) ) ) ) {
4841
-                                                    $wpdb->query( $wpdb->prepare( "UPDATE " . $table . " SET featured_image = %s WHERE post_id =%d", array( $featured_image, $saved_post_id ) ) );
4842
-                                                }
4843
-                                            }
4844
-                                            $menu_order++;
4845
-                                        }
4846
-                                    }
4839
+											if( $menu_order == 1 ) {
4840
+												if ( $featured_image = $wpdb->get_var( $wpdb->prepare( "SELECT file FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =%d AND file LIKE %s", array( $saved_post_id, '%/' . $img_name ) ) ) ) {
4841
+													$wpdb->query( $wpdb->prepare( "UPDATE " . $table . " SET featured_image = %s WHERE post_id =%d", array( $featured_image, $saved_post_id ) ) );
4842
+												}
4843
+											}
4844
+											$menu_order++;
4845
+										}
4846
+									}
4847 4847
                                     
4848
-                                    if ( $order > 1 ) {
4849
-                                        $images++;
4850
-                                    }
4851
-                                }
4848
+									if ( $order > 1 ) {
4849
+										$images++;
4850
+									}
4851
+								}
4852 4852
 
4853
-                                /** This action is documented in geodirectory-functions/post-functions.php */
4854
-                                do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post );
4853
+								/** This action is documented in geodirectory-functions/post-functions.php */
4854
+								do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post );
4855 4855
                                 
4856
-                                if (isset($is_featured)) {
4857
-                                    geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured);
4858
-                                }
4859
-                                if (isset($gd_post['expire_date'])) {
4860
-                                    geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']);
4861
-                                }
4862
-                            }
4856
+								if (isset($is_featured)) {
4857
+									geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured);
4858
+								}
4859
+								if (isset($gd_post['expire_date'])) {
4860
+									geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']);
4861
+								}
4862
+							}
4863 4863
                             
4864
-                            // WPML
4865
-                            if ($is_wpml && $language != '') {
4866
-                                $sitepress->switch_lang($active_lang, true);
4867
-                            }
4868
-                            // WPML
4869
-                        }
4870
-                    }
4871
-                }
4864
+							// WPML
4865
+							if ($is_wpml && $language != '') {
4866
+								$sitepress->switch_lang($active_lang, true);
4867
+							}
4868
+							// WPML
4869
+						}
4870
+					}
4871
+				}
4872 4872
 
4873
-                //undo some stuff to make the import quicker
4874
-                wp_defer_term_counting( false );
4875
-                wp_defer_comment_counting( false );
4876
-                $wpdb->query( 'COMMIT;' );
4877
-                $wpdb->query( 'SET autocommit = 1;' );
4878
-
4879
-                $json = array();
4880
-                $json['processed'] = $processed_actual;
4881
-                $json['created'] = $created;
4882
-                $json['updated'] = $updated;
4883
-                $json['skipped'] = $skipped;
4884
-                $json['invalid'] = $invalid;
4885
-                $json['invalid_addr'] = $invalid_addr;
4886
-                $json['images'] = $images;
4873
+				//undo some stuff to make the import quicker
4874
+				wp_defer_term_counting( false );
4875
+				wp_defer_comment_counting( false );
4876
+				$wpdb->query( 'COMMIT;' );
4877
+				$wpdb->query( 'SET autocommit = 1;' );
4878
+
4879
+				$json = array();
4880
+				$json['processed'] = $processed_actual;
4881
+				$json['created'] = $created;
4882
+				$json['updated'] = $updated;
4883
+				$json['skipped'] = $skipped;
4884
+				$json['invalid'] = $invalid;
4885
+				$json['invalid_addr'] = $invalid_addr;
4886
+				$json['images'] = $images;
4887 4887
                 
4888
-                wp_send_json( $json );
4889
-                exit;
4890
-            } else if ( $task == 'import_loc' ) {
4891
-                global $gd_post_types;
4892
-                $gd_post_types = $post_types;
4888
+				wp_send_json( $json );
4889
+				exit;
4890
+			} else if ( $task == 'import_loc' ) {
4891
+				global $gd_post_types;
4892
+				$gd_post_types = $post_types;
4893 4893
                 
4894
-                if (!empty($file)) {
4895
-                    $columns = isset($file[0]) ? $file[0] : NULL;
4894
+				if (!empty($file)) {
4895
+					$columns = isset($file[0]) ? $file[0] : NULL;
4896 4896
                     
4897
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4898
-                        $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4899
-                        wp_send_json( $json );
4900
-                    }
4897
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4898
+						$json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4899
+						wp_send_json( $json );
4900
+					}
4901 4901
                     
4902
-                    $gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory');
4903
-                    $gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' );
4904
-                    for ($i = 1; $i <= $limit; $i++) {
4905
-                        $index = $processed + $i;
4902
+					$gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory');
4903
+					$gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' );
4904
+					for ($i = 1; $i <= $limit; $i++) {
4905
+						$index = $processed + $i;
4906 4906
                         
4907
-                        if (isset($file[$index])) {
4908
-                            $row = $file[$index];
4909
-                            $row = array_map( 'trim', $row );
4910
-                            $data = array();
4907
+						if (isset($file[$index])) {
4908
+							$row = $file[$index];
4909
+							$row = array_map( 'trim', $row );
4910
+							$data = array();
4911 4911
                             
4912
-                            foreach ($columns as $c => $column ) {
4913
-                                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'))) {
4914
-                                    $data[$column] = $row[$c];
4915
-                                }
4916
-                            }
4912
+							foreach ($columns as $c => $column ) {
4913
+								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'))) {
4914
+									$data[$column] = $row[$c];
4915
+								}
4916
+							}
4917 4917
 
4918
-                            if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
4919
-                                $invalid++;
4920
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4921
-                                continue;
4922
-                            }
4918
+							if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
4919
+								$invalid++;
4920
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4921
+								continue;
4922
+							}
4923 4923
                             
4924
-                            $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0;
4924
+							$data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0;
4925 4925
                             
4926
-                            if ( $import_choice == 'update' ) {
4927
-                                if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4928
-                                    if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4929
-                                        $updated++;
4930
-                                    } else {
4931
-                                        $invalid++;
4932
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4933
-                                    }
4934
-                                } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4935
-                                    $data['location_id'] = (int)$location->location_id;
4926
+							if ( $import_choice == 'update' ) {
4927
+								if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4928
+									if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4929
+										$updated++;
4930
+									} else {
4931
+										$invalid++;
4932
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4933
+									}
4934
+								} else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4935
+									$data['location_id'] = (int)$location->location_id;
4936 4936
                                     
4937
-                                    if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
4938
-                                        $data['location_id'] = (int)$location->location_id;
4939
-                                    } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
4940
-                                        $data['location_id'] = (int)$location->location_id;
4941
-                                    } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
4942
-                                        $data['location_id'] = (int)$location->location_id;
4943
-                                    }
4937
+									if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
4938
+										$data['location_id'] = (int)$location->location_id;
4939
+									} else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
4940
+										$data['location_id'] = (int)$location->location_id;
4941
+									} else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
4942
+										$data['location_id'] = (int)$location->location_id;
4943
+									}
4944 4944
                                     
4945
-                                    if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4946
-                                        $updated++;
4947
-                                    } else {
4948
-                                        $invalid++;
4949
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4950
-                                    }
4951
-                                } else {
4952
-                                    if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4953
-                                        $created++;
4954
-                                    } else {
4955
-                                        $invalid++;
4956
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4957
-                                    }
4958
-                                }
4959
-                            } elseif ( $import_choice == 'skip' ) {
4960
-                                if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4961
-                                    $skipped++;
4962
-                                } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4963
-                                    $skipped++;
4964
-                                } else {
4965
-                                    if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4966
-                                        $created++;
4967
-                                    } else {
4968
-                                        $invalid++;
4969
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4970
-                                    }
4971
-                                }
4972
-                            } else {
4973
-                                $invalid++;
4974
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4975
-                            }
4976
-                        }
4977
-                    }
4978
-                }
4945
+									if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4946
+										$updated++;
4947
+									} else {
4948
+										$invalid++;
4949
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4950
+									}
4951
+								} else {
4952
+									if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4953
+										$created++;
4954
+									} else {
4955
+										$invalid++;
4956
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4957
+									}
4958
+								}
4959
+							} elseif ( $import_choice == 'skip' ) {
4960
+								if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4961
+									$skipped++;
4962
+								} else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4963
+									$skipped++;
4964
+								} else {
4965
+									if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4966
+										$created++;
4967
+									} else {
4968
+										$invalid++;
4969
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4970
+									}
4971
+								}
4972
+							} else {
4973
+								$invalid++;
4974
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4975
+							}
4976
+						}
4977
+					}
4978
+				}
4979 4979
                 
4980
-                $json = array();
4981
-                $json['processed'] = $limit;
4982
-                $json['created'] = $created;
4983
-                $json['updated'] = $updated;
4984
-                $json['skipped'] = $skipped;
4985
-                $json['invalid'] = $invalid;
4986
-                $json['images'] = $images;
4980
+				$json = array();
4981
+				$json['processed'] = $limit;
4982
+				$json['created'] = $created;
4983
+				$json['updated'] = $updated;
4984
+				$json['skipped'] = $skipped;
4985
+				$json['invalid'] = $invalid;
4986
+				$json['images'] = $images;
4987 4987
                 
4988
-                wp_send_json( $json );
4989
-            } else if ( $task == 'import_hood' ) {               
4990
-                if (!empty($file)) {
4991
-                    $columns = isset($file[0]) ? $file[0] : NULL;
4988
+				wp_send_json( $json );
4989
+			} else if ( $task == 'import_hood' ) {               
4990
+				if (!empty($file)) {
4991
+					$columns = isset($file[0]) ? $file[0] : NULL;
4992 4992
                     
4993
-                    if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4994
-                        $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4995
-                        wp_send_json( $json );
4996
-                    }
4993
+					if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4994
+						$json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4995
+						wp_send_json( $json );
4996
+					}
4997 4997
                     
4998
-                    $gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory');
4999
-                    $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' );
5000
-                    for ($i = 1; $i <= $limit; $i++) {
5001
-                        $index = $processed + $i;
4998
+					$gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory');
4999
+					$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' );
5000
+					for ($i = 1; $i <= $limit; $i++) {
5001
+						$index = $processed + $i;
5002 5002
                         
5003
-                        if (isset($file[$index])) {
5004
-                            $row = $file[$index];
5005
-                            $row = array_map( 'trim', $row );
5006
-                            $data = array();
5003
+						if (isset($file[$index])) {
5004
+							$row = $file[$index];
5005
+							$row = array_map( 'trim', $row );
5006
+							$data = array();
5007 5007
                             
5008
-                            foreach ($columns as $c => $column) {
5009
-                                if (in_array($column, array('neighbourhood_id', 'neighbourhood_name', 'neighbourhood_slug', 'latitude', 'longitude', 'location_id', 'city', 'region', 'country'))) {
5010
-                                    $data[$column] = sanitize_text_field($row[$c]);
5011
-                                }
5012
-                            }
5008
+							foreach ($columns as $c => $column) {
5009
+								if (in_array($column, array('neighbourhood_id', 'neighbourhood_name', 'neighbourhood_slug', 'latitude', 'longitude', 'location_id', 'city', 'region', 'country'))) {
5010
+									$data[$column] = sanitize_text_field($row[$c]);
5011
+								}
5012
+							}
5013 5013
 
5014
-                            if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
5015
-                                $invalid++;
5016
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5017
-                                continue;
5018
-                            }
5014
+							if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
5015
+								$invalid++;
5016
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5017
+								continue;
5018
+							}
5019 5019
                             
5020
-                            $location_info = array();
5021
-                            if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
5022
-                                $location_info = geodir_get_location_by_id('', (int)$data['location_id']);
5023
-                            } else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
5024
-                                $location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
5025
-                            }
5020
+							$location_info = array();
5021
+							if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
5022
+								$location_info = geodir_get_location_by_id('', (int)$data['location_id']);
5023
+							} else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
5024
+								$location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
5025
+							}
5026 5026
 
5027
-                            if (empty($location_info)) {
5028
-                                $invalid++;
5029
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5030
-                                continue;
5031
-                            }
5027
+							if (empty($location_info)) {
5028
+								$invalid++;
5029
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5030
+								continue;
5031
+							}
5032 5032
                             
5033
-                            $location_id = $location_info->location_id;
5033
+							$location_id = $location_info->location_id;
5034 5034
 
5035
-                            $data['neighbourhood_id'] = isset($data['neighbourhood_id']) ? absint($data['neighbourhood_id']) : 0;
5035
+							$data['neighbourhood_id'] = isset($data['neighbourhood_id']) ? absint($data['neighbourhood_id']) : 0;
5036 5036
                             
5037
-                            $hood_data = array();
5038
-                            $hood_data['hood_name'] = $data['neighbourhood_name'];
5039
-                            $hood_data['hood_slug'] = $data['neighbourhood_slug'];
5040
-                            $hood_data['hood_latitude'] = $data['latitude'];
5041
-                            $hood_data['hood_longitude'] = $data['longitude'];
5042
-                            $hood_data['hood_location_id'] = $location_id;
5037
+							$hood_data = array();
5038
+							$hood_data['hood_name'] = $data['neighbourhood_name'];
5039
+							$hood_data['hood_slug'] = $data['neighbourhood_slug'];
5040
+							$hood_data['hood_latitude'] = $data['latitude'];
5041
+							$hood_data['hood_longitude'] = $data['longitude'];
5042
+							$hood_data['hood_location_id'] = $location_id;
5043 5043
                                     
5044
-                            if ( $import_choice == 'update' ) {
5045
-                                if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
5046
-                                    $hood_data['hood_id'] = (int)$data['neighbourhood_id'];
5044
+							if ( $import_choice == 'update' ) {
5045
+								if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
5046
+									$hood_data['hood_id'] = (int)$data['neighbourhood_id'];
5047 5047
                                     
5048
-                                    if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5049
-                                        $updated++;
5050
-                                    } else {
5051
-                                        $invalid++;
5052
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5053
-                                    }
5054
-                                } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
5055
-                                    $hood_data['hood_id'] = (int)$neighbourhood->hood_id;
5048
+									if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5049
+										$updated++;
5050
+									} else {
5051
+										$invalid++;
5052
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5053
+									}
5054
+								} else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
5055
+									$hood_data['hood_id'] = (int)$neighbourhood->hood_id;
5056 5056
                                     
5057
-                                    if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5058
-                                        $updated++;
5059
-                                    } else {
5060
-                                        $invalid++;
5061
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5062
-                                    }
5063
-                                } else {
5064
-                                    if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5065
-                                        $created++;
5066
-                                    } else {
5067
-                                        $invalid++;
5068
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5069
-                                    }
5070
-                                }
5071
-                            } elseif ( $import_choice == 'skip' ) {
5072
-                                if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
5073
-                                    $skipped++;
5074
-                                } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
5075
-                                    $skipped++;
5076
-                                } else {
5057
+									if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5058
+										$updated++;
5059
+									} else {
5060
+										$invalid++;
5061
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5062
+									}
5063
+								} else {
5064
+									if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5065
+										$created++;
5066
+									} else {
5067
+										$invalid++;
5068
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5069
+									}
5070
+								}
5071
+							} elseif ( $import_choice == 'skip' ) {
5072
+								if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
5073
+									$skipped++;
5074
+								} else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
5075
+									$skipped++;
5076
+								} else {
5077 5077
                                     
5078
-                                    if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5079
-                                        $created++;
5080
-                                    } else {
5081
-                                        $invalid++;
5082
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5083
-                                    }
5084
-                                }
5085
-                            } else {
5086
-                                $invalid++;
5087
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5088
-                            }
5089
-                        }
5090
-                    }
5091
-                }
5078
+									if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5079
+										$created++;
5080
+									} else {
5081
+										$invalid++;
5082
+										geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5083
+									}
5084
+								}
5085
+							} else {
5086
+								$invalid++;
5087
+								geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5088
+							}
5089
+						}
5090
+					}
5091
+				}
5092 5092
                 
5093
-                $json = array();
5094
-                $json['processed'] = $limit;
5095
-                $json['created'] = $created;
5096
-                $json['updated'] = $updated;
5097
-                $json['skipped'] = $skipped;
5098
-                $json['invalid'] = $invalid;
5099
-                $json['images'] = $images;
5093
+				$json = array();
5094
+				$json['processed'] = $limit;
5095
+				$json['created'] = $created;
5096
+				$json['updated'] = $updated;
5097
+				$json['skipped'] = $skipped;
5098
+				$json['invalid'] = $invalid;
5099
+				$json['images'] = $images;
5100 5100
                 
5101
-                wp_send_json( $json );
5102
-            }
5103
-        }
5104
-        break;
5105
-        case 'import_finish':{
5106
-            /**
5107
-             * Run an action when an import finishes.
5108
-             *
5109
-             * This action can be used to fire functions after an import ends.
5110
-             *
5111
-             * @since 1.5.3
5112
-             * @package GeoDirectory
5113
-             */
5114
-            do_action('geodir_import_finished');
5115
-        }
5116
-        break;
5101
+				wp_send_json( $json );
5102
+			}
5103
+		}
5104
+		break;
5105
+		case 'import_finish':{
5106
+			/**
5107
+			 * Run an action when an import finishes.
5108
+			 *
5109
+			 * This action can be used to fire functions after an import ends.
5110
+			 *
5111
+			 * @since 1.5.3
5112
+			 * @package GeoDirectory
5113
+			 */
5114
+			do_action('geodir_import_finished');
5115
+		}
5116
+		break;
5117 5117
 
5118
-    }
5119
-    echo '0';
5120
-    gd_die();
5118
+	}
5119
+	echo '0';
5120
+	gd_die();
5121 5121
 }
5122 5122
 
5123 5123
 /**
@@ -5161,12 +5161,12 @@  discard block
 block discarded – undo
5161 5161
 		$args['slug'] = wp_unique_term_slug( $args['slug'], (object)$term_args );
5162 5162
 	}
5163 5163
 	
5164
-    if( !empty( $term ) ) {
5164
+	if( !empty( $term ) ) {
5165 5165
 		$result = wp_insert_term( $term, $taxonomy, $args );
5166
-        if( !is_wp_error( $result ) ) {
5167
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5168
-        }
5169
-    }
5166
+		if( !is_wp_error( $result ) ) {
5167
+			return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5168
+		}
5169
+	}
5170 5170
 	
5171 5171
 	return false;
5172 5172
 }
@@ -5212,16 +5212,16 @@  discard block
 block discarded – undo
5212 5212
 		$result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
5213 5213
 		
5214 5214
 		if( !is_wp_error( $result ) ) {
5215
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5216
-        }
5215
+			return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5216
+		}
5217 5217
 	} else if ( $term_data['slug'] != '' && $term_info = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
5218 5218
 		$term_data['term_id'] = $term_info['term_id'];
5219 5219
 		
5220 5220
 		$result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
5221 5221
 		
5222 5222
 		if( !is_wp_error( $result ) ) {
5223
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5224
-        }
5223
+			return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5224
+		}
5225 5225
 	} else {
5226 5226
 		return geodir_imex_insert_term( $taxonomy, $term_data );
5227 5227
 	}
@@ -5242,37 +5242,37 @@  discard block
 block discarded – undo
5242 5242
  * @return int Posts count.
5243 5243
  */
5244 5244
 function geodir_get_posts_count( $post_type ) {
5245
-    global $wpdb, $plugin_prefix;
5245
+	global $wpdb, $plugin_prefix;
5246 5246
 
5247
-    if ( !post_type_exists( $post_type ) ) {
5248
-        return 0;
5249
-    }
5247
+	if ( !post_type_exists( $post_type ) ) {
5248
+		return 0;
5249
+	}
5250 5250
         
5251
-    $table = $plugin_prefix . $post_type . '_detail';
5251
+	$table = $plugin_prefix . $post_type . '_detail';
5252 5252
 
5253
-    // Skip listing with statuses trash, auto-draft etc...
5254
-    $skip_statuses = geodir_imex_export_skip_statuses();
5255
-    $where_statuses = '';
5256
-    if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5257
-        $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5258
-    }
5253
+	// Skip listing with statuses trash, auto-draft etc...
5254
+	$skip_statuses = geodir_imex_export_skip_statuses();
5255
+	$where_statuses = '';
5256
+	if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5257
+		$where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5258
+	}
5259 5259
 
5260
-    $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 );
5260
+	$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 );
5261 5261
 
5262
-    $posts_count = (int)$wpdb->get_var( $query );
5262
+	$posts_count = (int)$wpdb->get_var( $query );
5263 5263
     
5264
-    /**
5265
-     * Modify returned post counts for the current post type.
5266
-     *
5267
-     * @since 1.4.6
5268
-     * @package GeoDirectory
5269
-     *
5270
-     * @param int $posts_count Post counts.
5271
-     * @param string $post_type Post type.
5272
-     */
5273
-    $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type );
5274
-
5275
-    return $posts_count;
5264
+	/**
5265
+	 * Modify returned post counts for the current post type.
5266
+	 *
5267
+	 * @since 1.4.6
5268
+	 * @package GeoDirectory
5269
+	 *
5270
+	 * @param int $posts_count Post counts.
5271
+	 * @param string $post_type Post type.
5272
+	 */
5273
+	$posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type );
5274
+
5275
+	return $posts_count;
5276 5276
 }
5277 5277
 
5278 5278
 /**
@@ -5300,9 +5300,9 @@  discard block
 block discarded – undo
5300 5300
 	
5301 5301
 	if ( !empty( $posts ) ) {
5302 5302
 		$is_payment_plugin = is_plugin_active( 'geodir_payment_manager/geodir_payment_manager.php' );
5303
-        $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
5304
-        $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
5305
-        $neighbourhood_active = $location_manager && $location_allowed && get_option('location_neighbourhoods') ? true : false;
5303
+		$location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
5304
+		$location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
5305
+		$neighbourhood_active = $location_manager && $location_allowed && get_option('location_neighbourhoods') ? true : false;
5306 5306
 		
5307 5307
 		$csv_row = array();
5308 5308
 		$csv_row[] = 'post_id';
@@ -5346,11 +5346,11 @@  discard block
 block discarded – undo
5346 5346
 		$csv_row[] = 'post_zip';
5347 5347
 		$csv_row[] = 'post_latitude';
5348 5348
 		$csv_row[] = 'post_longitude';
5349
-        if ($neighbourhood_active) {
5350
-            $csv_row[] = 'post_neighbourhood';
5351
-            $csv_row[] = 'neighbourhood_latitude';
5352
-            $csv_row[] = 'neighbourhood_longitude';
5353
-        }
5349
+		if ($neighbourhood_active) {
5350
+			$csv_row[] = 'post_neighbourhood';
5351
+			$csv_row[] = 'neighbourhood_latitude';
5352
+			$csv_row[] = 'neighbourhood_longitude';
5353
+		}
5354 5354
 		$csv_row[] = 'geodir_timing';
5355 5355
 		$csv_row[] = 'geodir_contact';
5356 5356
 		$csv_row[] = 'geodir_email';
@@ -5385,7 +5385,7 @@  discard block
 block discarded – undo
5385 5385
 		$csv_rows[] = $csv_row;
5386 5386
 
5387 5387
 		$images_count = 5;
5388
-        $xx=0;
5388
+		$xx=0;
5389 5389
 		foreach ( $posts as $post ) {$xx++;
5390 5390
 			$post_id = $post['ID'];
5391 5391
 			
@@ -5528,21 +5528,21 @@  discard block
 block discarded – undo
5528 5528
 			$csv_row[] = $post_info['post_zip']; // post_zip
5529 5529
 			$csv_row[] = $post_info['post_latitude']; // post_latitude
5530 5530
 			$csv_row[] = $post_info['post_longitude']; // post_longitude
5531
-            if ($neighbourhood_active) {
5532
-                $post_neighbourhood = '';
5533
-                $neighbourhood_latitude = '';
5534
-                $neighbourhood_longitude = '';
5535
-                if (!empty($post_info['post_neighbourhood']) && ($hood_info = geodir_location_get_neighbourhood_by_id($post_info['post_neighbourhood'], true, $post_info['post_location_id']))) {
5536
-                    if (!empty($hood_info)) {
5537
-                        $post_neighbourhood = $hood_info->hood_name;
5538
-                        $neighbourhood_latitude = $hood_info->hood_latitude;
5539
-                        $neighbourhood_longitude = $hood_info->hood_longitude;
5540
-                    }
5541
-                }
5542
-                $csv_row[] = $post_neighbourhood; // post_neighbourhood
5543
-                $csv_row[] = $neighbourhood_latitude; // neighbourhood_latitude
5544
-                $csv_row[] = $neighbourhood_longitude; // neighbourhood_longitude
5545
-            }
5531
+			if ($neighbourhood_active) {
5532
+				$post_neighbourhood = '';
5533
+				$neighbourhood_latitude = '';
5534
+				$neighbourhood_longitude = '';
5535
+				if (!empty($post_info['post_neighbourhood']) && ($hood_info = geodir_location_get_neighbourhood_by_id($post_info['post_neighbourhood'], true, $post_info['post_location_id']))) {
5536
+					if (!empty($hood_info)) {
5537
+						$post_neighbourhood = $hood_info->hood_name;
5538
+						$neighbourhood_latitude = $hood_info->hood_latitude;
5539
+						$neighbourhood_longitude = $hood_info->hood_longitude;
5540
+					}
5541
+				}
5542
+				$csv_row[] = $post_neighbourhood; // post_neighbourhood
5543
+				$csv_row[] = $neighbourhood_latitude; // neighbourhood_latitude
5544
+				$csv_row[] = $neighbourhood_longitude; // neighbourhood_longitude
5545
+			}
5546 5546
 			$csv_row[] = $post_info['geodir_timing']; // geodir_timing
5547 5547
 			$csv_row[] = $post_info['geodir_contact']; // geodir_contact
5548 5548
 			$csv_row[] = $post_info['geodir_email']; // geodir_email
@@ -5613,55 +5613,55 @@  discard block
 block discarded – undo
5613 5613
  * @return array Array of posts data.
5614 5614
  */
5615 5615
 function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) {
5616
-    global $wpdb, $plugin_prefix;
5616
+	global $wpdb, $plugin_prefix;
5617 5617
 
5618
-    if ( ! post_type_exists( $post_type ) )
5619
-        return new stdClass;
5618
+	if ( ! post_type_exists( $post_type ) )
5619
+		return new stdClass;
5620 5620
         
5621
-    $table = $plugin_prefix . $post_type . '_detail';
5621
+	$table = $plugin_prefix . $post_type . '_detail';
5622 5622
 
5623
-    $limit = '';
5624
-    if ( $per_page > 0 && $page_no > 0 ) {
5625
-        $offset = ( $page_no - 1 ) * $per_page;
5623
+	$limit = '';
5624
+	if ( $per_page > 0 && $page_no > 0 ) {
5625
+		$offset = ( $page_no - 1 ) * $per_page;
5626 5626
         
5627
-        if ( $offset > 0 ) {
5628
-            $limit = " LIMIT " . $offset . "," . $per_page;
5629
-        } else {
5630
-            $limit = " LIMIT " . $per_page;
5631
-        }
5632
-    }
5627
+		if ( $offset > 0 ) {
5628
+			$limit = " LIMIT " . $offset . "," . $per_page;
5629
+		} else {
5630
+			$limit = " LIMIT " . $per_page;
5631
+		}
5632
+	}
5633 5633
 
5634
-    // Skip listing with statuses trash, auto-draft etc...
5635
-    $skip_statuses = geodir_imex_export_skip_statuses();
5636
-    $where_statuses = '';
5637
-    if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5638
-        $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5639
-    }
5634
+	// Skip listing with statuses trash, auto-draft etc...
5635
+	$skip_statuses = geodir_imex_export_skip_statuses();
5636
+	$where_statuses = '';
5637
+	if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5638
+		$where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5639
+	}
5640
+
5641
+	$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;
5642
+	/**
5643
+	 * Modify returned posts SQL query for the current post type.
5644
+	 *
5645
+	 * @since 1.4.6
5646
+	 * @package GeoDirectory
5647
+	 *
5648
+	 * @param int $query The SQL query.
5649
+	 * @param string $post_type Post type.
5650
+	 */
5651
+	$query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type );
5652
+
5653
+	$results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A );
5640 5654
 
5641
-    $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;
5642
-    /**
5643
-     * Modify returned posts SQL query for the current post type.
5644
-     *
5645
-     * @since 1.4.6
5646
-     * @package GeoDirectory
5647
-     *
5648
-     * @param int $query The SQL query.
5649
-     * @param string $post_type Post type.
5650
-     */
5651
-    $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type );
5652
-
5653
-    $results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A );
5654
-
5655
-    /**
5656
-     * Modify returned post results for the current post type.
5657
-     *
5658
-     * @since 1.4.6
5659
-     * @package GeoDirectory
5660
-     *
5661
-     * @param object $results An object containing all post ids.
5662
-     * @param string $post_type Post type.
5663
-     */
5664
-    return apply_filters( 'geodir_export_posts', $results, $post_type );
5655
+	/**
5656
+	 * Modify returned post results for the current post type.
5657
+	 *
5658
+	 * @since 1.4.6
5659
+	 * @package GeoDirectory
5660
+	 *
5661
+	 * @param object $results An object containing all post ids.
5662
+	 * @param string $post_type Post type.
5663
+	 */
5664
+	return apply_filters( 'geodir_export_posts', $results, $post_type );
5665 5665
 }
5666 5666
 
5667 5667
 /**
@@ -5679,23 +5679,23 @@  discard block
 block discarded – undo
5679 5679
  * @return string The SQL query.
5680 5680
  */
5681 5681
 function geodir_imex_get_events_query( $query, $post_type ) {
5682
-    if ( $post_type == 'gd_event' ) {
5683
-        global $wpdb, $plugin_prefix;
5682
+	if ( $post_type == 'gd_event' ) {
5683
+		global $wpdb, $plugin_prefix;
5684 5684
         
5685
-        $table = $plugin_prefix . $post_type . '_detail';
5686
-        $schedule_table = EVENT_SCHEDULE;
5685
+		$table = $plugin_prefix . $post_type . '_detail';
5686
+		$schedule_table = EVENT_SCHEDULE;
5687 5687
         
5688
-        // Skip listing with statuses trash, auto-draft etc...
5689
-        $skip_statuses = geodir_imex_export_skip_statuses();
5690
-        $where_statuses = '';
5691
-        if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5692
-            $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5693
-        }
5688
+		// Skip listing with statuses trash, auto-draft etc...
5689
+		$skip_statuses = geodir_imex_export_skip_statuses();
5690
+		$where_statuses = '';
5691
+		if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5692
+			$where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5693
+		}
5694 5694
 
5695
-        $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";
5696
-    }
5695
+		$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";
5696
+	}
5697 5697
 
5698
-    return $query;
5698
+	return $query;
5699 5699
 }
5700 5700
 
5701 5701
 /**
@@ -5717,36 +5717,36 @@  discard block
 block discarded – undo
5717 5717
  * @return int Total terms count.
5718 5718
  */
5719 5719
 function geodir_get_terms_count( $post_type ) {
5720
-    $args = array( 'hide_empty' => 0 );
5720
+	$args = array( 'hide_empty' => 0 );
5721 5721
 
5722
-    remove_all_filters( 'get_terms' );
5722
+	remove_all_filters( 'get_terms' );
5723 5723
 
5724
-    $taxonomy = $post_type . 'category';
5724
+	$taxonomy = $post_type . 'category';
5725 5725
 
5726
-    // WPML
5727
-    $is_wpml = geodir_is_wpml();
5728
-    $active_lang = 'all';
5729
-    if ( $is_wpml ) {
5730
-        global $sitepress;
5731
-        $active_lang = $sitepress->get_current_language();
5726
+	// WPML
5727
+	$is_wpml = geodir_is_wpml();
5728
+	$active_lang = 'all';
5729
+	if ( $is_wpml ) {
5730
+		global $sitepress;
5731
+		$active_lang = $sitepress->get_current_language();
5732 5732
         
5733
-        if ( $active_lang != 'all' ) {
5734
-            $sitepress->switch_lang( 'all', true );
5735
-        }
5736
-    }
5737
-    // WPML
5733
+		if ( $active_lang != 'all' ) {
5734
+			$sitepress->switch_lang( 'all', true );
5735
+		}
5736
+	}
5737
+	// WPML
5738 5738
             
5739
-    $count_terms = wp_count_terms( $taxonomy, $args );
5739
+	$count_terms = wp_count_terms( $taxonomy, $args );
5740 5740
 
5741
-    // WPML
5742
-    if ( $is_wpml && $active_lang !== 'all' ) {
5743
-        global $sitepress;
5744
-        $sitepress->switch_lang( $active_lang, true );
5745
-    }
5746
-    // WPML
5747
-    $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0;
5741
+	// WPML
5742
+	if ( $is_wpml && $active_lang !== 'all' ) {
5743
+		global $sitepress;
5744
+		$sitepress->switch_lang( $active_lang, true );
5745
+	}
5746
+	// WPML
5747
+	$count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0;
5748 5748
      
5749
-    return $count_terms;
5749
+	return $count_terms;
5750 5750
 }
5751 5751
 
5752 5752
 /**
@@ -5785,11 +5785,11 @@  discard block
 block discarded – undo
5785 5785
 		$csv_row[] = 'cat_posttype';
5786 5786
 		$csv_row[] = 'cat_parent';
5787 5787
 		$csv_row[] = 'cat_schema';
5788
-        // WPML
5788
+		// WPML
5789 5789
 		$is_wpml = geodir_is_wpml();
5790 5790
 		if ($is_wpml) {
5791 5791
 			$csv_row[] = 'cat_language';
5792
-            $csv_row[] = 'cat_id_original';
5792
+			$csv_row[] = 'cat_id_original';
5793 5793
 		}
5794 5794
 		// WPML
5795 5795
 		$csv_row[] = 'cat_description';
@@ -5819,10 +5819,10 @@  discard block
 block discarded – undo
5819 5819
 			$csv_row[] = $post_type;
5820 5820
 			$csv_row[] = $cat_parent;
5821 5821
 			$csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_schema', false, $post_type );
5822
-            // WPML
5822
+			// WPML
5823 5823
 			if ($is_wpml) {
5824 5824
 				$csv_row[] = geodir_get_language_for_element( $term->term_id, 'tax_' . $taxonomy );
5825
-                $csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy );
5825
+				$csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy );
5826 5826
 			}
5827 5827
 			// WPML
5828 5828
 			$csv_row[] = $term->description;
@@ -6418,43 +6418,43 @@  discard block
 block discarded – undo
6418 6418
  * @param string $status Post status.
6419 6419
  */
6420 6420
 function geodir_create_page($slug, $option, $page_title = '', $page_content = '', $post_parent = 0, $status = 'publish') {
6421
-    global $wpdb, $current_user;
6422
-
6423
-    $option_value = get_option($option);
6424
-
6425
-    if ($option_value > 0) :
6426
-        if (get_post($option_value)) :
6427
-            // Page exists
6428
-            return;
6429
-        endif;
6430
-    endif;
6431
-
6432
-    $page_found = $wpdb->get_var(
6433
-        $wpdb->prepare(
6434
-            "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
6435
-            array($slug)
6436
-        )
6437
-    );
6438
-
6439
-    if ($page_found) :
6440
-        // Page exists
6441
-        if (!$option_value) update_option($option, $page_found);
6442
-        return;
6443
-    endif;
6444
-
6445
-    $page_data = array(
6446
-        'post_status' => $status,
6447
-        'post_type' => 'page',
6448
-        'post_author' => $current_user->ID,
6449
-        'post_name' => $slug,
6450
-        'post_title' => $page_title,
6451
-        'post_content' => $page_content,
6452
-        'post_parent' => $post_parent,
6453
-        'comment_status' => 'closed'
6454
-    );
6455
-    $page_id = wp_insert_post($page_data);
6456
-
6457
-    add_option($option, $page_id);
6421
+	global $wpdb, $current_user;
6422
+
6423
+	$option_value = get_option($option);
6424
+
6425
+	if ($option_value > 0) :
6426
+		if (get_post($option_value)) :
6427
+			// Page exists
6428
+			return;
6429
+		endif;
6430
+	endif;
6431
+
6432
+	$page_found = $wpdb->get_var(
6433
+		$wpdb->prepare(
6434
+			"SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
6435
+			array($slug)
6436
+		)
6437
+	);
6438
+
6439
+	if ($page_found) :
6440
+		// Page exists
6441
+		if (!$option_value) update_option($option, $page_found);
6442
+		return;
6443
+	endif;
6444
+
6445
+	$page_data = array(
6446
+		'post_status' => $status,
6447
+		'post_type' => 'page',
6448
+		'post_author' => $current_user->ID,
6449
+		'post_name' => $slug,
6450
+		'post_title' => $page_title,
6451
+		'post_content' => $page_content,
6452
+		'post_parent' => $post_parent,
6453
+		'comment_status' => 'closed'
6454
+	);
6455
+	$page_id = wp_insert_post($page_data);
6456
+
6457
+	add_option($option, $page_id);
6458 6458
 
6459 6459
 }
6460 6460
 
@@ -6485,9 +6485,9 @@  discard block
 block discarded – undo
6485 6485
  * @package GeoDirectory
6486 6486
  */
6487 6487
 function geodir_admin_upgrade_notice() {
6488
-    $class = "error";
6489
-    $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
6490
-    echo"<div class=\"$class\"> <p>$message</p></div>";
6488
+	$class = "error";
6489
+	$message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
6490
+	echo"<div class=\"$class\"> <p>$message</p></div>";
6491 6491
 }
6492 6492
 
6493 6493
 /**
@@ -6500,18 +6500,18 @@  discard block
 block discarded – undo
6500 6500
  */
6501 6501
 function geodire_admin_upgrade_notice( $plugin_data, $r )
6502 6502
 {
6503
-    // readme contents
6504
-    $args = array(
6505
-        'timeout'     => 15,
6506
-        'redirection' => 5
6507
-    );
6508
-    $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt";
6509
-    $data       = wp_remote_get( $url, $args );
6503
+	// readme contents
6504
+	$args = array(
6505
+		'timeout'     => 15,
6506
+		'redirection' => 5
6507
+	);
6508
+	$url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt";
6509
+	$data       = wp_remote_get( $url, $args );
6510 6510
 
6511
-    if (!is_wp_error($data) && $data['response']['code'] == 200) {
6511
+	if (!is_wp_error($data) && $data['response']['code'] == 200) {
6512 6512
 
6513
-        geodir_in_plugin_update_message($data['body']);
6514
-    }
6513
+		geodir_in_plugin_update_message($data['body']);
6514
+	}
6515 6515
 }
6516 6516
 
6517 6517
 
@@ -6519,28 +6519,28 @@  discard block
 block discarded – undo
6519 6519
 * @param string $content http response body
6520 6520
 */
6521 6521
 function geodir_in_plugin_update_message($content) {
6522
-    // Output Upgrade Notice
6523
-    $matches        = null;
6524
-    $regexp         = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis';
6525
-    $upgrade_notice = '';
6526
-    if ( preg_match( $regexp, $content, $matches ) ) {
6527
-        if(empty($matches)){return;}
6528
-
6529
-        $version = trim( $matches[1] );
6530
-        if($version && $version>GEODIRECTORY_VERSION){
6531
-
6532
-
6533
-        $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
6534
-        if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
6535
-            $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">';
6536
-            foreach ( $notices as $index => $line ) {
6537
-                $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
6538
-            }
6539
-            $upgrade_notice .= '</div> ';
6540
-        }
6541
-        }
6542
-    }
6543
-    echo $upgrade_notice;
6522
+	// Output Upgrade Notice
6523
+	$matches        = null;
6524
+	$regexp         = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis';
6525
+	$upgrade_notice = '';
6526
+	if ( preg_match( $regexp, $content, $matches ) ) {
6527
+		if(empty($matches)){return;}
6528
+
6529
+		$version = trim( $matches[1] );
6530
+		if($version && $version>GEODIRECTORY_VERSION){
6531
+
6532
+
6533
+		$notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
6534
+		if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
6535
+			$upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">';
6536
+			foreach ( $notices as $index => $line ) {
6537
+				$upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
6538
+			}
6539
+			$upgrade_notice .= '</div> ';
6540
+		}
6541
+		}
6542
+	}
6543
+	echo $upgrade_notice;
6544 6544
 }
6545 6545
 
6546 6546
 /**
@@ -6573,19 +6573,19 @@  discard block
 block discarded – undo
6573 6573
  * @param array Listing statuses to be skipped.
6574 6574
  */
6575 6575
 function geodir_imex_export_skip_statuses() {
6576
-    $statuses = array( 'trash', 'auto-draft' );
6576
+	$statuses = array( 'trash', 'auto-draft' );
6577 6577
     
6578
-    /**
6579
-     * Filter the statuses to skip during GD export listings.
6580
-     *
6581
-     * @since 1.6.0
6582
-     * @package GeoDirectory
6583
-     *
6584
-     * @param array $statuses Listing statuses to be skipped.
6585
-     */
6586
-    $statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses );
6578
+	/**
6579
+	 * Filter the statuses to skip during GD export listings.
6580
+	 *
6581
+	 * @since 1.6.0
6582
+	 * @package GeoDirectory
6583
+	 *
6584
+	 * @param array $statuses Listing statuses to be skipped.
6585
+	 */
6586
+	$statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses );
6587 6587
      
6588
-    return $statuses;
6588
+	return $statuses;
6589 6589
 }
6590 6590
 
6591 6591
 /*
Please login to merge, or discard this patch.
Spacing   +901 added lines, -901 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(), GEODIRECTORY_VERSION);
113
+        wp_register_script('chosen', geodir_plugin_url().'/geodirectory-assets/js/chosen.jquery.js', array(), 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();
@@ -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);
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
     global $wpdb, $plugin_prefix;
628 628
 
629 629
 
630
-    $post_ids = $wpdb->get_results("SELECT post_id FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
630
+    $post_ids = $wpdb->get_results("SELECT post_id FROM ".$plugin_prefix."gd_place_detail WHERE post_dummy='1'");
631 631
 
632 632
 
633 633
     foreach ($post_ids as $post_ids_obj) {
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
     }
636 636
 
637 637
     //double check posts are deleted
638
-    $wpdb->get_results("DELETE FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
638
+    $wpdb->get_results("DELETE FROM ".$plugin_prefix."gd_place_detail WHERE post_dummy='1'");
639 639
 }
640 640
 
641 641
 /**
@@ -673,14 +673,14 @@  discard block
 block discarded – undo
673 673
 
674 674
 
675 675
                     if (geodir_dummy_folder_exists())
676
-                        $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
676
+                        $dummy_image_url = geodir_plugin_url()."/geodirectory-admin/dummy/cat_icon";
677 677
                     else
678 678
                         $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
679 679
 
680 680
                     $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
681 681
 
682 682
                     $catname = str_replace(' ', '_', $catname);
683
-                    $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
683
+                    $uploaded = (array) fetch_remote_file("$dummy_image_url/".$catname.".png");
684 684
 
685 685
                     if (empty($uploaded['error'])) {
686 686
                         $new_path = $uploaded['file'];
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
                     $wp_filetype = wp_check_filetype(basename($new_path), null);
691 691
 
692 692
                     $attachment = array(
693
-                        'guid' => $uploads['baseurl'] . '/' . basename($new_path),
693
+                        'guid' => $uploads['baseurl'].'/'.basename($new_path),
694 694
                         'post_mime_type' => $wp_filetype['type'],
695 695
                         'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
696 696
                         'post_content' => '',
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 
701 701
                     // you must first include the image.php file
702 702
                     // for the function wp_generate_attachment_metadata() to work
703
-                    require_once(ABSPATH . 'wp-admin/includes/image.php');
703
+                    require_once(ABSPATH.'wp-admin/includes/image.php');
704 704
                     $attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
705 705
                     wp_update_attachment_metadata($attach_id, $attach_data);
706 706
 
@@ -717,14 +717,14 @@  discard block
 block discarded – undo
717 717
                 $last_catid = wp_insert_term($catname, 'gd_placecategory');
718 718
 
719 719
                 if (geodir_dummy_folder_exists())
720
-                    $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon";
720
+                    $dummy_image_url = geodir_plugin_url()."/geodirectory-admin/dummy/cat_icon";
721 721
                 else
722 722
                     $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon';
723 723
 
724 724
                 $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
725 725
 
726 726
                 $catname = str_replace(' ', '_', $catname);
727
-                $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
727
+                $uploaded = (array) fetch_remote_file("$dummy_image_url/".$catname.".png");
728 728
 
729 729
                 if (empty($uploaded['error'])) {
730 730
                     $new_path = $uploaded['file'];
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
                 $wp_filetype = wp_check_filetype(basename($new_path), null);
735 735
 
736 736
                 $attachment = array(
737
-                    'guid' => $uploads['baseurl'] . '/' . basename($new_path),
737
+                    'guid' => $uploads['baseurl'].'/'.basename($new_path),
738 738
                     'post_mime_type' => $wp_filetype['type'],
739 739
                     'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
740 740
                     'post_content' => '',
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
 
747 747
                 // you must first include the image.php file
748 748
                 // for the function wp_generate_attachment_metadata() to work
749
-                require_once(ABSPATH . 'wp-admin/includes/image.php');
749
+                require_once(ABSPATH.'wp-admin/includes/image.php');
750 750
                 $attach_data = wp_generate_attachment_metadata($attach_id, $new_path);
751 751
                 wp_update_attachment_metadata($attach_id, $attach_data);
752 752
 
@@ -788,18 +788,18 @@  discard block
 block discarded – undo
788 788
 
789 789
         elseif (isset($value['type']) && $value['type'] == 'image_width') :
790 790
 
791
-            if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
792
-                update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']);
793
-                update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']);
794
-                if (isset($_POST[$value['id'] . '_crop'])) :
795
-                    update_option($value['id'] . '_crop', 1);
791
+            if (isset($value['id']) && isset($_POST[$value['id'].'_width'])) {
792
+                update_option($value['id'].'_width', $_POST[$value['id'].'_width']);
793
+                update_option($value['id'].'_height', $_POST[$value['id'].'_height']);
794
+                if (isset($_POST[$value['id'].'_crop'])) :
795
+                    update_option($value['id'].'_crop', 1);
796 796
                 else :
797
-                    update_option($value['id'] . '_crop', 0);
797
+                    update_option($value['id'].'_crop', 0);
798 798
                 endif;
799 799
             } else {
800
-                update_option($value['id'] . '_width', $value['std']);
801
-                update_option($value['id'] . '_height', $value['std']);
802
-                update_option($value['id'] . '_crop', 1);
800
+                update_option($value['id'].'_width', $value['std']);
801
+                update_option($value['id'].'_height', $value['std']);
802
+                update_option($value['id'].'_crop', 1);
803 803
             }
804 804
 
805 805
         elseif (isset($value['type']) && $value['type'] == 'map') :
@@ -841,12 +841,12 @@  discard block
 block discarded – undo
841 841
         elseif (isset($value['type']) && $value['type'] == 'file') :
842 842
 
843 843
 
844
-            if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
844
+            if (isset($_POST[$value['id'].'_remove']) && $_POST[$value['id'].'_remove']) {// if remove is set then remove the file
845 845
 
846 846
                 if (get_option($value['id'])) {
847 847
                     $image_name_arr = explode('/', get_option($value['id']));
848 848
                     $noimg_name = end($image_name_arr);
849
-                    $img_path = $uploads['path'] . '/' . $noimg_name;
849
+                    $img_path = $uploads['path'].'/'.$noimg_name;
850 850
                     if (file_exists($img_path))
851 851
                         unlink($img_path);
852 852
                 }
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
                 if (get_option($value['id'])) {
875 875
                     $image_name_arr = explode('/', get_option($value['id']));
876 876
                     $noimg_name = end($image_name_arr);
877
-                    $img_path = $uploads['path'] . '/' . $noimg_name;
877
+                    $img_path = $uploads['path'].'/'.$noimg_name;
878 878
                     if (file_exists($img_path))
879 879
                         unlink($img_path);
880 880
                 }
@@ -895,7 +895,7 @@  discard block
 block discarded – undo
895 895
             // same menu setting per theme.
896 896
             if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
897 897
                 $theme = wp_get_theme();
898
-                update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
898
+                update_option('geodir_theme_location_nav_'.$theme->name, $_POST[$value['id']]);
899 899
             }
900 900
 
901 901
             if (isset($value['id']) && isset($_POST[$value['id']])) {
@@ -965,8 +965,8 @@  discard block
 block discarded – undo
965 965
 
966 966
             $listing_slug = $geodir_posttype_info['labels']['singular_name'];
967 967
 
968
-            $tabs[$geodir_post_type . '_fields_settings'] = array(
969
-                'label' => __(ucfirst($listing_slug) . ' Settings', 'geodirectory'),
968
+            $tabs[$geodir_post_type.'_fields_settings'] = array(
969
+                'label' => __(ucfirst($listing_slug).' Settings', 'geodirectory'),
970 970
                 'subtabs' => array(
971 971
                     array('subtab' => 'custom_fields',
972 972
                         'label' => __('Custom Fields', 'geodirectory'),
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
  */
1033 1033
 function geodir_extend_geodirectory_setting_tab($tabs)
1034 1034
 {
1035
-    $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
1035
+    $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory').' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
1036 1036
     return $tabs;
1037 1037
 }
1038 1038
 
@@ -1092,8 +1092,8 @@  discard block
 block discarded – undo
1092 1092
                     _e('Unknown', 'geodirectory');
1093 1093
                 } else {
1094 1094
                     /* If there is a city id, append 'city name' to the text string. */
1095
-                    $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
1096
-                    echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id);
1095
+                    $add_location_id = $location_id > 0 ? ' ('.$location_id.')' : '';
1096
+                    echo(__($location->country, 'geodirectory').'-'.$location->region.'-'.$location->city.$add_location_id);
1097 1097
                 }
1098 1098
                 break;
1099 1099
 
@@ -1111,14 +1111,14 @@  discard block
 block discarded – undo
1111 1111
                         $expire_class = 'expire_over';
1112 1112
                     }
1113 1113
                     $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days
1114
-                    $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
1114
+                    $date_diff_text = '<br /><span class="'.$expire_class.'">('.$date_diff.' '.$state.')</span>';
1115 1115
                 }
1116 1116
                 /* If no expire_date is found, output a default message. */
1117 1117
                 if (empty($expire_date))
1118 1118
                     echo __('Unknown', 'geodirectory');
1119 1119
                 /* If there is a expire_date, append 'days left' to the text string. */
1120 1120
                 else
1121
-                    echo $expire_date . $date_diff_text;
1121
+                    echo $expire_date.$date_diff_text;
1122 1122
                 break;
1123 1123
 
1124 1124
             /* If displaying the 'categorys' column. */
@@ -1185,7 +1185,7 @@  discard block
 block discarded – undo
1185 1185
 function geodir_post_information_save($post_id, $post) {
1186 1186
     global $wpdb, $current_user;
1187 1187
 
1188
-    if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
1188
+    if (isset($post->post_type) && ($post->post_type == 'nav_menu_item' || $post->post_type == 'page' || $post->post_type == 'post')) {
1189 1189
         return;
1190 1190
     }
1191 1191
 
@@ -1253,7 +1253,7 @@  discard block
 block discarded – undo
1253 1253
                     $tab_id = $value['id'];
1254 1254
 
1255 1255
                 if (isset($value['desc']) && $value['desc'])
1256
-                    $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>';
1256
+                    $desc = '<span style=" text-transform:none;">:- '.$value['desc'].'</span>';
1257 1257
 
1258 1258
                 if (isset($value['name']) && $value['name']) {
1259 1259
                     if ($first_title === true) {
@@ -1261,9 +1261,9 @@  discard block
 block discarded – undo
1261 1261
                     } else {
1262 1262
                         echo '</div>';
1263 1263
                     }
1264
-                    echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>';
1264
+                    echo '<dd id="'.trim($tab_id).'" class="geodir_option_tabs" ><a href="javascript:void(0);">'.$value['name'].'</a></dd>';
1265 1265
 
1266
-                    echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
1266
+                    echo '<div id="sub_'.trim($tab_id).'" class="gd-content-heading" style=" margin-bottom:10px;" >';
1267 1267
                 }
1268 1268
 
1269 1269
                 /**
@@ -1273,21 +1273,21 @@  discard block
 block discarded – undo
1273 1273
                  *
1274 1274
                  * @since 1.0.0
1275 1275
                  */
1276
-                do_action('geodir_settings_' . sanitize_title($value['id']));
1276
+                do_action('geodir_settings_'.sanitize_title($value['id']));
1277 1277
                 break;
1278 1278
 
1279 1279
             case 'no_tabs':
1280 1280
 
1281 1281
                 echo '<div class="inner_content_tab_main">';
1282
-                echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >';
1282
+                echo '<div id="sub_'.trim($tab_id).'" class="gd-content-heading" style=" margin-bottom:10px;" >';
1283 1283
 
1284 1284
                 break;
1285 1285
 
1286 1286
             case 'sectionstart':
1287 1287
                 if (isset($value['desc']) && $value['desc'])
1288
-                    $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>';
1288
+                    $desc = '<span style=" text-transform:none;"> - '.$value['desc'].'</span>';
1289 1289
                 if (isset($value['name']) && $value['name'])
1290
-                    echo '<h3>' . $value['name'] . $desc . '</h3>';
1290
+                    echo '<h3>'.$value['name'].$desc.'</h3>';
1291 1291
                 /**
1292 1292
                  * Called after a GeoDirectory settings sectionstart is output in the GD settings page.
1293 1293
                  *
@@ -1295,8 +1295,8 @@  discard block
 block discarded – undo
1295 1295
                  *
1296 1296
                  * @since 1.0.0
1297 1297
                  */
1298
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
1299
-                echo '<table class="form-table">' . "\n\n";
1298
+                if (isset($value['id']) && $value['id']) do_action('geodir_settings_'.sanitize_title($value['id']).'_start');
1299
+                echo '<table class="form-table">'."\n\n";
1300 1300
 
1301 1301
                 break;
1302 1302
             case 'sectionend':
@@ -1307,7 +1307,7 @@  discard block
 block discarded – undo
1307 1307
                  *
1308 1308
                  * @since 1.0.0
1309 1309
                  */
1310
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
1310
+                if (isset($value['id']) && $value['id']) do_action('geodir_settings_'.sanitize_title($value['id']).'_end');
1311 1311
                 echo '</table>';
1312 1312
                 /**
1313 1313
                  * Called after a GeoDirectory settings sectionend is output in the GD settings page.
@@ -1316,7 +1316,7 @@  discard block
 block discarded – undo
1316 1316
                  *
1317 1317
                  * @since 1.0.0
1318 1318
                  */
1319
-                if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
1319
+                if (isset($value['id']) && $value['id']) do_action('geodir_settings_'.sanitize_title($value['id']).'_after');
1320 1320
                 break;
1321 1321
             case 'text':
1322 1322
                 ?>
@@ -1325,7 +1325,7 @@  discard block
 block discarded – undo
1325 1325
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
1326 1326
                                            id="<?php echo esc_attr($value['id']); ?>"
1327 1327
                                            type="<?php echo esc_attr($value['type']); ?>"
1328
-                                           <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1328
+                                           <?php if (isset($value['placeholder'])) {?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1329 1329
                                            style=" <?php echo esc_attr($value['css']); ?>"
1330 1330
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1331 1331
                                                echo esc_attr(stripslashes(get_option($value['id'])));
@@ -1342,7 +1342,7 @@  discard block
 block discarded – undo
1342 1342
                 <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>"
1343 1343
                                            id="<?php echo esc_attr($value['id']); ?>"
1344 1344
                                            type="<?php echo esc_attr($value['type']); ?>"
1345
-                                           <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1345
+                                           <?php if (isset($value['placeholder'])) {?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1346 1346
                                            style="<?php echo esc_attr($value['css']); ?>"
1347 1347
                                            value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
1348 1348
                                                echo esc_attr(stripslashes(get_option($value['id'])));
@@ -1388,17 +1388,17 @@  discard block
 block discarded – undo
1388 1388
                     <?php _e('Width', 'geodirectory'); ?> <input
1389 1389
                         name="<?php echo esc_attr($value['id']); ?>_width"
1390 1390
                         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']; ?>"/>
1391
+                        value="<?php if ($size = get_option($value['id'].'_width')) echo stripslashes($size); else echo $value['std']; ?>"/>
1392 1392
 
1393 1393
                     <?php _e('Height', 'geodirectory'); ?> <input
1394 1394
                         name="<?php echo esc_attr($value['id']); ?>_height"
1395 1395
                         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']; ?>"/>
1396
+                        value="<?php if ($size = get_option($value['id'].'_height')) echo stripslashes($size); else echo $value['std']; ?>"/>
1397 1397
 
1398 1398
                     <label><?php _e('Hard Crop', 'geodirectory'); ?> <input
1399 1399
                             name="<?php echo esc_attr($value['id']); ?>_crop"
1400 1400
                             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>
1401
+                            type="checkbox" <?php if (get_option($value['id'].'_crop') != '') checked(get_option($value['id'].'_crop'), 1); else checked(1); ?> /></label>
1402 1402
 
1403 1403
                     <span class="description"><?php echo $value['desc'] ?></span></td>
1404 1404
                 </tr><?php
@@ -1448,7 +1448,7 @@  discard block
 block discarded – undo
1448 1448
                                             id="<?php echo esc_attr($value['id']); ?>"
1449 1449
                                             style="<?php echo esc_attr($value['css']); ?>"
1450 1450
                                             class="<?php if (isset($value['class'])) echo $value['class']; ?>"
1451
-                                            data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>"
1451
+                                            data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text']; ?>"
1452 1452
                                             option-ajaxchosen="false">
1453 1453
                         <?php
1454 1454
                         foreach ($value['options'] as $key => $val) {
@@ -1459,7 +1459,7 @@  discard block
 block discarded – undo
1459 1459
                             } else {
1460 1460
                                 ?>
1461 1461
                                 <option
1462
-                                    value="<?php echo esc_attr($key); ?>" <?php selected(true, (is_array($option_values) && in_array($key, $option_values)));?>><?php echo ucfirst($val) ?></option>
1462
+                                    value="<?php echo esc_attr($key); ?>" <?php selected(true, (is_array($option_values) && in_array($key, $option_values))); ?>><?php echo ucfirst($val) ?></option>
1463 1463
                             <?php
1464 1464
                             }
1465 1465
                         }
@@ -1494,7 +1494,7 @@  discard block
 block discarded – undo
1494 1494
                 ?>
1495 1495
 
1496 1496
                 <tr valign="top">
1497
-                    <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory');?></th>
1497
+                    <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory'); ?></th>
1498 1498
                     <td width="60%">
1499 1499
                         <select name="geodir_default_map_language" style="width:60%">
1500 1500
                             <?php
@@ -1576,7 +1576,7 @@  discard block
 block discarded – undo
1576 1576
 
1577 1577
                 <tr valign="top">
1578 1578
                     <th class="titledesc"
1579
-                        width="40%"><?php _e('Default post type search on map', 'geodirectory');?></th>
1579
+                        width="40%"><?php _e('Default post type search on map', 'geodirectory'); ?></th>
1580 1580
                     <td width="60%">
1581 1581
                         <select name="geodir_default_map_search_pt" style="width:60%">
1582 1582
                             <?php
@@ -1617,7 +1617,7 @@  discard block
 block discarded – undo
1617 1617
                         $cat_display = 'checkbox';
1618 1618
                         $gd_post_types = get_option('geodir_exclude_post_type_on_map');
1619 1619
                         $gd_cats = get_option('geodir_exclude_cat_on_map');
1620
-                        $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
1620
+                        $gd_cats_upgrade = (int) get_option('geodir_exclude_cat_on_map_upgrade');
1621 1621
                         $count = 1;
1622 1622
                         ?>
1623 1623
                         <table width="70%" class="widefat">
@@ -1646,7 +1646,7 @@  discard block
 block discarded – undo
1646 1646
                                                                                            name="home_map_post_types[]"
1647 1647
                                                                                            id="<?php echo esc_attr($value['id']); ?>"
1648 1648
                                                                                            value="<?php echo $key; ?>"
1649
-                                                                                           class="map_post_type" <?php echo $checked;?> />
1649
+                                                                                           class="map_post_type" <?php echo $checked; ?> />
1650 1650
                                         <?php echo $post_types_obj->labels->singular_name; ?></td>
1651 1651
                                     <td width="40%">
1652 1652
                                         <div class="home_map_category" style="overflow:auto;width:200px;height:100px;"
@@ -1704,12 +1704,12 @@  discard block
 block discarded – undo
1704 1704
                 ?>
1705 1705
                 <fieldset>
1706 1706
                     <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend>
1707
-                    <label for="<?php echo $value['id'];?>">
1707
+                    <label for="<?php echo $value['id']; ?>">
1708 1708
                         <input name="<?php echo esc_attr($value['id']); ?>"
1709
-                               id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio"
1709
+                               id="<?php echo esc_attr($value['id'].$value['value']); ?>" type="radio"
1710 1710
                                value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) {
1711 1711
                             echo 'checked="checked"';
1712
-                        }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
1712
+                        }elseif (get_option($value['id']) == '' && $value['std'] == $value['value']) {echo 'checked="checked"'; } ?> />
1713 1713
                         <?php echo $value['desc']; ?></label><br>
1714 1714
                 </fieldset>
1715 1715
                 <?php
@@ -1729,9 +1729,9 @@  discard block
 block discarded – undo
1729 1729
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1730 1730
                 <td class="forminp">
1731 1731
                     <textarea
1732
-                        <?php if (isset($value['args'])) echo $value['args'] . ' '; ?>name="<?php echo esc_attr($value['id']); ?>"
1732
+                        <?php if (isset($value['args'])) echo $value['args'].' '; ?>name="<?php echo esc_attr($value['id']); ?>"
1733 1733
                         id="<?php echo esc_attr($value['id']); ?>"
1734
-                        <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1734
+                        <?php if (isset($value['placeholder'])) {?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
1735 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
1736 1736
                         class="description"><?php echo $value['desc'] ?></span>
1737 1737
 
@@ -1776,7 +1776,7 @@  discard block
 block discarded – undo
1776 1776
 					}
1777 1777
 				}
1778 1778
 				//
1779
-				$page_setting = (int)get_option($value['id']);
1779
+				$page_setting = (int) get_option($value['id']);
1780 1780
 
1781 1781
                 $args = array('name' => $value['id'],
1782 1782
                     'id' => $value['id'],
@@ -1793,7 +1793,7 @@  discard block
 block discarded – undo
1793 1793
                 <tr valign="top" class="single_select_page">
1794 1794
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
1795 1795
                 <td class="forminp">
1796
-                    <?php echo str_replace(' id=', " data-placeholder='" . __('Select a page...', 'geodirectory') . "' style='" . $value['css'] . "' class='" . $value['class'] . "' " . $disabled . " id=", wp_dropdown_pages($args)); ?>
1796
+                    <?php echo str_replace(' id=', " data-placeholder='".__('Select a page...', 'geodirectory')."' style='".$value['css']."' class='".$value['class']."' ".$disabled." id=", wp_dropdown_pages($args)); ?>
1797 1797
                     <span class="description"><?php echo $value['desc'] ?></span>
1798 1798
                 </td>
1799 1799
                 </tr><?php
@@ -1802,7 +1802,7 @@  discard block
 block discarded – undo
1802 1802
 				}
1803 1803
                 break;
1804 1804
             case 'single_select_country' :
1805
-                $country_setting = (string)get_option($value['id']);
1805
+                $country_setting = (string) get_option($value['id']);
1806 1806
                 if (strstr($country_setting, ':')) :
1807 1807
                     $country = current(explode(':', $country_setting));
1808 1808
                     $state = end(explode(':', $country_setting));
@@ -1825,7 +1825,7 @@  discard block
 block discarded – undo
1825 1825
             case 'multi_select_countries' :
1826 1826
                 $countries = $geodirectory->countries->countries;
1827 1827
                 asort($countries);
1828
-                $selections = (array)get_option($value['id']);
1828
+                $selections = (array) get_option($value['id']);
1829 1829
                 ?>
1830 1830
                 <tr valign="top">
1831 1831
                 <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
@@ -1835,7 +1835,7 @@  discard block
 block discarded – undo
1835 1835
                             title="Country" class="chosen_select">
1836 1836
                         <?php
1837 1837
                         if ($countries) foreach ($countries as $key => $val) :
1838
-                            echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>';
1838
+                            echo '<option value="'.$key.'" '.selected(in_array($key, $selections), true, false).'>'.$val.'</option>';
1839 1839
                         endforeach;
1840 1840
                         ?>
1841 1841
                     </select>
@@ -1847,8 +1847,8 @@  discard block
 block discarded – undo
1847 1847
                 break;
1848 1848
 
1849 1849
             case 'google_analytics' :
1850
-                $selections = (array)get_option($value['id']);
1851
-                if(get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret') ) {
1850
+                $selections = (array) get_option($value['id']);
1851
+                if (get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret')) {
1852 1852
                     ?>
1853 1853
                     <tr valign="top">
1854 1854
                         <th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
@@ -1859,20 +1859,20 @@  discard block
 block discarded – undo
1859 1859
 
1860 1860
                             $oAuthURL = "https://accounts.google.com/o/oauth2/auth?";
1861 1861
                             $scope = "scope=https://www.googleapis.com/auth/analytics.readonly";
1862
-                            $state = "&state=123";//any string
1863
-                            $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
1862
+                            $state = "&state=123"; //any string
1863
+                            $redirect_uri = "&redirect_uri=".admin_url('admin-ajax.php')."?action=geodir_ga_callback";
1864 1864
                             $response_type = "&response_type=code";
1865 1865
                             $client_id = "&client_id=".get_option('geodir_ga_client_id');
1866 1866
                             $access_type = "&access_type=offline";
1867 1867
                             $approval_prompt = "&approval_prompt=force";
1868 1868
 
1869
-                            $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt;
1869
+                            $auth_url = $oAuthURL.$scope.$state.$redirect_uri.$response_type.$client_id.$access_type.$approval_prompt;
1870 1870
 
1871 1871
 
1872 1872
                             ?>
1873 1873
                             <script>
1874 1874
                                 function gd_ga_popup() {
1875
-                                    var win = window.open("<?php echo $auth_url;?>", "Google Analytics", "");
1875
+                                    var win = window.open("<?php echo $auth_url; ?>", "Google Analytics", "");
1876 1876
                                     var pollTimer = window.setInterval(function () {
1877 1877
                                         if (win.closed !== false) { // !== is required for compatibility with Opera
1878 1878
                                             window.clearInterval(pollTimer);
@@ -1894,7 +1894,7 @@  discard block
 block discarded – undo
1894 1894
                             } else {
1895 1895
                                 ?>
1896 1896
                                 <span class="button-primary"
1897
-                                      onclick="gd_ga_popup();"><?php _e('Authorize', 'geodirectory');?></span>
1897
+                                      onclick="gd_ga_popup();"><?php _e('Authorize', 'geodirectory'); ?></span>
1898 1898
                             <?php
1899 1899
                             }
1900 1900
                             ?>
@@ -1965,9 +1965,9 @@  discard block
 block discarded – undo
1965 1965
 
1966 1966
             <?php if (isset($_REQUEST['active_tab']) && $_REQUEST['active_tab'] != '') { ?>
1967 1967
             jQuery('.geodir_option_tabs').removeClass('gd-tab-active');
1968
-            jQuery('#<?php echo sanitize_text_field($_REQUEST['active_tab']);?>').addClass('gd-tab-active');
1968
+            jQuery('#<?php echo sanitize_text_field($_REQUEST['active_tab']); ?>').addClass('gd-tab-active');
1969 1969
             jQuery('.gd-content-heading').hide();
1970
-            jQuery('#sub_<?php echo sanitize_text_field($_REQUEST['active_tab']);?>').show();
1970
+            jQuery('#sub_<?php echo sanitize_text_field($_REQUEST['active_tab']); ?>').show();
1971 1971
             <?php } ?>
1972 1972
         });
1973 1973
     </script>
@@ -2053,7 +2053,7 @@  discard block
 block discarded – undo
2053 2053
     wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename');
2054 2054
 
2055 2055
     if (geodir_get_featured_image($post_id, 'thumbnail')) {
2056
-        echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
2056
+        echo '<h4>'.__('Featured Image', 'geodirectory').'</h4>';
2057 2057
         geodir_show_featured_image($post_id, 'thumbnail');
2058 2058
     }
2059 2059
 
@@ -2064,13 +2064,13 @@  discard block
 block discarded – undo
2064 2064
 
2065 2065
     <h5 class="form_title">
2066 2066
         <?php if ($image_limit != 0 && $image_limit == 1) {
2067
-            echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
2067
+            echo '<br /><small>('.__('You can upload', 'geodirectory').' '.$image_limit.' '.__('image with this package', 'geodirectory').')</small>';
2068 2068
         } ?>
2069 2069
         <?php if ($image_limit != 0 && $image_limit > 1) {
2070
-            echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
2070
+            echo '<br /><small>('.__('You can upload', 'geodirectory').' '.$image_limit.' '.__('images with this package', 'geodirectory').')</small>';
2071 2071
         } ?>
2072 2072
         <?php if ($image_limit == 0) {
2073
-            echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
2073
+            echo '<br /><small>('.__('You can upload unlimited images with this package', 'geodirectory').')</small>';
2074 2074
         } ?>
2075 2075
     </h5>
2076 2076
 
@@ -2109,10 +2109,10 @@  discard block
 block discarded – undo
2109 2109
         <div
2110 2110
             class="plupload-upload-uic hide-if-no-js <?php if ($multiple): ?>plupload-upload-uic-multiple<?php endif; ?>"
2111 2111
             id="<?php echo $id; ?>plupload-upload-ui">
2112
-            <h4><?php _e('Drop files to upload', 'geodirectory');?></h4>
2112
+            <h4><?php _e('Drop files to upload', 'geodirectory'); ?></h4>
2113 2113
             <input id="<?php echo $id; ?>plupload-browse-button" type="button"
2114 2114
                    value="<?php _e('Select Files', 'geodirectory'); ?>" class="button"/>
2115
-            <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce($id . 'pluploadan'); ?>"></span>
2115
+            <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce($id.'pluploadan'); ?>"></span>
2116 2116
             <?php if ($width && $height): ?>
2117 2117
                 <span class="plupload-resize"></span>
2118 2118
                 <span class="plupload-width" id="plupload-width<?php echo $width; ?>"></span>
@@ -2124,7 +2124,7 @@  discard block
 block discarded – undo
2124 2124
              id="<?php echo $id; ?>plupload-thumbs" style="border-top:1px solid #ccc; padding-top:10px;">
2125 2125
         </div>
2126 2126
         <span
2127
-            id="upload-msg"><?php _e('Please drag &amp; drop the images to rearrange the order', 'geodirectory');?></span>
2127
+            id="upload-msg"><?php _e('Please drag &amp; drop the images to rearrange the order', 'geodirectory'); ?></span>
2128 2128
         <span id="<?php echo $id; ?>upload-error" style="display:none"></span>
2129 2129
     </div>
2130 2130
 
@@ -2334,9 +2334,9 @@  discard block
 block discarded – undo
2334 2334
     $plugin = 'avada-nag';
2335 2335
     $timestamp = 'avada-nag1234';
2336 2336
     $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');
2337
-    echo '<div id="' . $timestamp . '"  class="error">';
2338
-    echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>';
2339
-    echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
2337
+    echo '<div id="'.$timestamp.'"  class="error">';
2338
+    echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\''.$plugin.'\',\''.$timestamp.'\');" ><i class="fa fa-times"></i></span>';
2339
+    echo "<img class='gd-icon-noti' src='".plugin_dir_url('')."geodirectory/geodirectory-assets/images/favicon.ico' > ";
2340 2340
     echo "<p>$message</p>";
2341 2341
     echo "</div>";
2342 2342
 
@@ -2469,7 +2469,7 @@  discard block
 block discarded – undo
2469 2469
 		
2470 2470
 		// Don't allow same slug url for listing and location
2471 2471
 		if (geodir_strtolower($listing_prefix) == geodir_strtolower($location_prefix)) {
2472
-			$redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab . '&msg=fail&gderr=21');
2472
+			$redirect_url = admin_url('admin.php?page=geodirectory&tab='.$current_tab.'&active_tab='.$active_tab.'&msg=fail&gderr=21');
2473 2473
         	wp_redirect($redirect_url);
2474 2474
 			exit;
2475 2475
 		}
@@ -2481,7 +2481,7 @@  discard block
 block discarded – undo
2481 2481
 			$default_language = $sitepress->get_default_language();
2482 2482
 			
2483 2483
 			if ($current_language != 'all' && $current_language != $default_language) {
2484
-				$redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab);
2484
+				$redirect_url = admin_url('admin.php?page=geodirectory&tab='.$current_tab.'&active_tab='.$active_tab);
2485 2485
 				wp_redirect($redirect_url);
2486 2486
 				exit;
2487 2487
 			}
@@ -2502,11 +2502,11 @@  discard block
 block discarded – undo
2502 2502
 function geodir_hide_admin_preview_button() {
2503 2503
     global $post_type;
2504 2504
     $post_types = geodir_get_posttypes();
2505
-    if(in_array($post_type, $post_types))
2505
+    if (in_array($post_type, $post_types))
2506 2506
         echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
2507 2507
 }
2508
-add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' );
2509
-add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' );
2508
+add_action('admin_head-post-new.php', 'geodir_hide_admin_preview_button');
2509
+add_action('admin_head-post.php', 'geodir_hide_admin_preview_button');
2510 2510
 
2511 2511
 /**
2512 2512
  * Add the tab in left sidebar menu fro import & export page.
@@ -2516,8 +2516,8 @@  discard block
 block discarded – undo
2516 2516
  *
2517 2517
  * @return array Array of tab data.
2518 2518
  */
2519
-function geodir_import_export_tab( $tabs ) {
2520
-	$tabs['import_export'] = array( 'label' => __( 'Import & Export', 'geodirectory' ) );
2519
+function geodir_import_export_tab($tabs) {
2520
+	$tabs['import_export'] = array('label' => __('Import & Export', 'geodirectory'));
2521 2521
     return $tabs;
2522 2522
 }
2523 2523
 
@@ -2531,8 +2531,8 @@  discard block
 block discarded – undo
2531 2531
  * @return string Html content.
2532 2532
  */
2533 2533
 function geodir_import_export_page() {
2534
-	$nonce = wp_create_nonce( 'geodir_import_export_nonce' );
2535
-	$gd_cats_sample_csv = geodir_plugin_url() . '/geodirectory-assets/gd_sample_categories.csv';
2534
+	$nonce = wp_create_nonce('geodir_import_export_nonce');
2535
+	$gd_cats_sample_csv = geodir_plugin_url().'/geodirectory-assets/gd_sample_categories.csv';
2536 2536
     /**
2537 2537
      * Filter sample category data csv file url.
2538 2538
      *
@@ -2541,9 +2541,9 @@  discard block
 block discarded – undo
2541 2541
      *
2542 2542
      * @param string $gd_cats_sample_csv Sample category data csv file url.
2543 2543
      */
2544
-	$gd_cats_sample_csv = apply_filters( 'geodir_export_cats_sample_csv', $gd_cats_sample_csv );
2544
+	$gd_cats_sample_csv = apply_filters('geodir_export_cats_sample_csv', $gd_cats_sample_csv);
2545 2545
 	
2546
-	$gd_posts_sample_csv = geodir_plugin_url() . '/geodirectory-assets/place_listing.csv';
2546
+	$gd_posts_sample_csv = geodir_plugin_url().'/geodirectory-assets/place_listing.csv';
2547 2547
     /**
2548 2548
      * Filter sample post data csv file url.
2549 2549
      *
@@ -2552,15 +2552,15 @@  discard block
 block discarded – undo
2552 2552
      *
2553 2553
      * @param string $gd_posts_sample_csv Sample post data csv file url.
2554 2554
      */
2555
-    $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv );
2555
+    $gd_posts_sample_csv = apply_filters('geodir_export_posts_sample_csv', $gd_posts_sample_csv);
2556 2556
 	
2557
-	$gd_posttypes = geodir_get_posttypes( 'array' );
2557
+	$gd_posttypes = geodir_get_posttypes('array');
2558 2558
 	
2559 2559
 	$gd_posttypes_option = '';
2560
-	foreach ( $gd_posttypes as $gd_posttype => $row ) {
2561
-		$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>';
2560
+	foreach ($gd_posttypes as $gd_posttype => $row) {
2561
+		$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 2562
 	}
2563
-	wp_enqueue_script( 'jquery-ui-progressbar' );
2563
+	wp_enqueue_script('jquery-ui-progressbar');
2564 2564
 	
2565 2565
 	$gd_chunksize_options = array();
2566 2566
 	$gd_chunksize_options[100] = 100;
@@ -2582,49 +2582,49 @@  discard block
 block discarded – undo
2582 2582
      *
2583 2583
      * @param string $gd_chunksize_options Entries options.
2584 2584
      */
2585
-    $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options );
2585
+    $gd_chunksize_options = apply_filters('geodir_export_csv_chunksize_options', $gd_chunksize_options);
2586 2586
 	
2587 2587
 	$gd_chunksize_option = '';
2588 2588
 	foreach ($gd_chunksize_options as $value => $title) {
2589
-		$gd_chunksize_option .= '<option value="' . $value . '" ' . selected($value, 5000, false) . '>' . $title . '</option>';
2589
+		$gd_chunksize_option .= '<option value="'.$value.'" '.selected($value, 5000, false).'>'.$title.'</option>';
2590 2590
 	}
2591 2591
 	
2592 2592
 	$uploads = wp_upload_dir();
2593 2593
 ?>
2594 2594
 </form>
2595 2595
 <div class="inner_content_tab_main gd-import-export">
2596
-  <h3><?php _e( 'GD Import & Export CSV', 'geodirectory' ) ;?></h3>
2597
-  <span class="description"><?php _e( 'Import & export csv for GD listings & categories.', 'geodirectory' ) ;?></span>
2596
+  <h3><?php _e('GD Import & Export CSV', 'geodirectory'); ?></h3>
2597
+  <span class="description"><?php _e('Import & export csv for GD listings & categories.', 'geodirectory'); ?></span>
2598 2598
   <div class="gd-content-heading">
2599 2599
 
2600 2600
   <?php
2601 2601
     ini_set('max_execution_time', 999999);
2602
-    $ini_max_execution_time_check = @ini_get( 'max_execution_time' );
2602
+    $ini_max_execution_time_check = @ini_get('max_execution_time');
2603 2603
     ini_restore('max_execution_time');
2604 2604
 
2605
-    if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
2605
+    if ($ini_max_execution_time_check != 999999) { // only show these setting to the user if we can't change the ini setting
2606 2606
         ?>
2607 2607
 	<div id="gd_ie_reqs" class="metabox-holder">
2608 2608
       <div class="meta-box-sortables ui-sortable">
2609 2609
         <div class="postbox">
2610
-          <h3 class="hndle"><span style='vertical-align:top;'><?php echo __( 'PHP Requirements for GD Import & Export CSV', 'geodirectory' );?></span></h3>
2610
+          <h3 class="hndle"><span style='vertical-align:top;'><?php echo __('PHP Requirements for GD Import & Export CSV', 'geodirectory'); ?></span></h3>
2611 2611
           <div class="inside">
2612
-            <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>
2612
+            <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>
2613 2613
 			<table class="form-table">
2614 2614
 				<thead>
2615 2615
 				  <tr>
2616
-				  	<th><?php _e( 'PHP Settings', 'geodirectory' );?></th><th><?php _e( 'Current Value', 'geodirectory' );?></th><th><?php _e( 'Recommended Value', 'geodirectory' );?></th>
2616
+				  	<th><?php _e('PHP Settings', 'geodirectory'); ?></th><th><?php _e('Current Value', 'geodirectory'); ?></th><th><?php _e('Recommended Value', 'geodirectory'); ?></th>
2617 2617
 				  </tr>
2618 2618
 				</thead>
2619 2619
 				<tbody>
2620 2620
 				  <tr>
2621
-				  	<td>max_input_time</td><td><?php echo @ini_get( 'max_input_time' );?></td><td>3000</td>
2621
+				  	<td>max_input_time</td><td><?php echo @ini_get('max_input_time'); ?></td><td>3000</td>
2622 2622
 				  </tr>
2623 2623
 				  <tr>
2624
-				  	<td>max_execution_time</td><td><?php  echo @ini_get( 'max_execution_time' );?></td><td>3000</td>
2624
+				  	<td>max_execution_time</td><td><?php  echo @ini_get('max_execution_time'); ?></td><td>3000</td>
2625 2625
 				  </tr>
2626 2626
 				  <tr>
2627
-				  	<td>memory_limit</td><td><?php echo @ini_get( 'memory_limit' );?></td><td>256M</td>
2627
+				  	<td>memory_limit</td><td><?php echo @ini_get('memory_limit'); ?></td><td>256M</td>
2628 2628
 				  </tr>
2629 2629
 				</tbody>
2630 2630
 		    </table>
@@ -2636,21 +2636,21 @@  discard block
 block discarded – undo
2636 2636
 	<div id="gd_ie_imposts" class="metabox-holder">
2637 2637
       <div class="meta-box-sortables ui-sortable">
2638 2638
         <div id="gd_ie_im_posts" class="postbox gd-hndle-pbox">
2639
-          <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>
2640
-          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __( 'GD Listings: Import CSV', 'geodirectory' );?></span></h3>
2639
+          <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>
2640
+          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __('GD Listings: Import CSV', 'geodirectory'); ?></span></h3>
2641 2641
           <div class="inside">
2642 2642
             <table class="form-table">
2643 2643
 				<tbody>
2644 2644
 				  <tr>
2645 2645
 					<td class="gd-imex-box">
2646 2646
 						<div class="gd-im-choices">
2647
-						<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>
2648
-						<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>
2647
+						<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>
2648
+						<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 2649
 						</div>
2650 2650
 						<div class="plupload-upload-uic hide-if-no-js" id="gd_im_postplupload-upload-ui">
2651 2651
 							<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');" />
2652
-							<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">
2653
-						<input type="hidden" id="gd_ie_imposts_csv" value="<?php echo $gd_posts_sample_csv;?>" />
2652
+							<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">
2653
+						<input type="hidden" id="gd_ie_imposts_csv" value="<?php echo $gd_posts_sample_csv; ?>" />
2654 2654
 							<?php
2655 2655
 							/**
2656 2656
 							 * Called just after the sample CSV download link.
@@ -2659,7 +2659,7 @@  discard block
 block discarded – undo
2659 2659
 							 */
2660 2660
 							do_action('geodir_sample_csv_download_link');
2661 2661
 							?>
2662
-							<span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce( 'gd_im_postpluploadan' ); ?>"></span>
2662
+							<span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce('gd_im_postpluploadan'); ?>"></span>
2663 2663
 							<div class="filelist"></div>
2664 2664
 						</div>
2665 2665
 						<span id="gd_im_catupload-error" style="display:none"></span>
@@ -2677,7 +2677,7 @@  discard block
 block discarded – undo
2677 2677
 							<input type="hidden" id="gd_terminateaction" value="continue"/>
2678 2678
 						</div>
2679 2679
 						<div class="gd-import-progress" id="gd-import-progress" style="display:none">
2680
-							<div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory');?> </b><font
2680
+							<div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory'); ?> </b><font
2681 2681
 									id="gd-import-done">0</font> / <font id="gd-import-total">0</font>&nbsp;( <font
2682 2682
 									id="gd-import-perc">0%</font> )
2683 2683
 								<div class="gd-fileprogress"></div>
@@ -2689,10 +2689,10 @@  discard block
 block discarded – undo
2689 2689
                     	<div class="gd-imex-btns" style="display:none;">
2690 2690
                         	<input type="hidden" class="geodir_import_file" name="geodir_import_file" value="save"/>
2691 2691
                         	<input onclick="gd_imex_PrepareImport(this, 'post')" type="button" value="<?php echo CSV_IMPORT_DATA; ?>" id="gd_import_data" class="button-primary" />
2692
-                        	<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"/>
2693
-                        	<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')"/>
2692
+                        	<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"/>
2693
+                        	<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 2694
 							<div id="gd_process_data" style="display:none">
2695
-								<span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory');?>
2695
+								<span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory'); ?>
2696 2696
 							</div>
2697 2697
 						</div>
2698 2698
 					</td>
@@ -2706,26 +2706,26 @@  discard block
 block discarded – undo
2706 2706
 	<div id="gd_ie_excategs" class="metabox-holder">
2707 2707
 	  <div class="meta-box-sortables ui-sortable">
2708 2708
 		<div id="gd_ie_ex_posts" class="postbox gd-hndle-pbox">
2709
-		  <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>
2710
-          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __( 'GD Listings: Export CSV', 'geodirectory' );?></span></h3>
2709
+		  <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>
2710
+          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __('GD Listings: Export CSV', 'geodirectory'); ?></span></h3>
2711 2711
 		  <div class="inside">
2712 2712
 			<table class="form-table">
2713 2713
 			  <tbody>
2714 2714
 				<tr>
2715 2715
 				  <td class="fld"><label for="gd_post_type">
2716
-					<?php _e( 'Post Type:', 'geodirectory' );?>
2716
+					<?php _e('Post Type:', 'geodirectory'); ?>
2717 2717
 					</label></td>
2718 2718
 				  <td><select name="gd_post_type" id="gd_post_type" style="min-width:140px">
2719
-					  <?php echo $gd_posttypes_option;?>
2719
+					  <?php echo $gd_posttypes_option; ?>
2720 2720
 					</select></td>
2721 2721
 				</tr>
2722 2722
 				<tr>
2723
-					<td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e( 'Max entries per csv file:', 'geodirectory' );?></label></td>
2724
-					<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>
2723
+					<td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e('Max entries per csv file:', 'geodirectory'); ?></label></td>
2724
+					<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 2725
 				  </tr>
2726 2726
 				<tr>
2727 2727
 				  <td class="fld" style="vertical-align:top"><label>
2728
-					<?php _e( 'Progress:', 'geodirectory' );?>
2728
+					<?php _e('Progress:', 'geodirectory'); ?>
2729 2729
 					</label></td>
2730 2730
 				  <td><div id='gd_progressbar_box'>
2731 2731
 					  <div id="gd_progressbar" class="gd_progressbar">
@@ -2733,13 +2733,13 @@  discard block
 block discarded – undo
2733 2733
 					  </div>
2734 2734
 					</div>
2735 2735
 					<p style="display:inline-block">
2736
-					  <?php _e( 'Elapsed Time:', 'geodirectory' );?>
2736
+					  <?php _e('Elapsed Time:', 'geodirectory'); ?>
2737 2737
 					</p>
2738 2738
 					  
2739 2739
 					<p id="gd_timer" class="gd_timer">00:00:00</p></td>
2740 2740
 				</tr>
2741 2741
 				<tr class="gd-ie-actions">
2742
-				  <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">
2742
+				  <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">
2743 2743
 				  </td>
2744 2744
 				  <td id="gd_ie_ex_files" class="gd-ie-files"></td>
2745 2745
 				</tr>
@@ -2752,21 +2752,21 @@  discard block
 block discarded – undo
2752 2752
 	<div id="gd_ie_imcategs" class="metabox-holder">
2753 2753
       <div class="meta-box-sortables ui-sortable">
2754 2754
         <div id="gd_ie_imcats" class="postbox gd-hndle-pbox">
2755
-          <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>
2756
-          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __( 'GD Categories: Import CSV', 'geodirectory' );?></span></h3>
2755
+          <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>
2756
+          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __('GD Categories: Import CSV', 'geodirectory'); ?></span></h3>
2757 2757
           <div class="inside">
2758 2758
             <table class="form-table">
2759 2759
 				<tbody>
2760 2760
 				  <tr>
2761 2761
 					<td class="gd-imex-box">
2762 2762
 						<div class="gd-im-choices">
2763
-						<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>
2764
-						<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>
2763
+						<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>
2764
+						<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 2765
 						</div>
2766 2766
 						<div class="plupload-upload-uic hide-if-no-js" id="gd_im_catplupload-upload-ui">
2767 2767
 							<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');" />
2768
-							<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">
2769
-						<input type="hidden" id="gd_ie_imcats_csv" value="<?php echo $gd_cats_sample_csv;?>" />
2768
+							<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">
2769
+						<input type="hidden" id="gd_ie_imcats_csv" value="<?php echo $gd_cats_sample_csv; ?>" />
2770 2770
 						<?php
2771 2771
 						/**
2772 2772
 						 * Called just after the sample CSV download link.
@@ -2776,7 +2776,7 @@  discard block
 block discarded – undo
2776 2776
 						 */
2777 2777
 						do_action('geodir_sample_cats_csv_download_link');
2778 2778
 						?>
2779
-							<span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce( 'gd_im_catpluploadan' ); ?>"></span>
2779
+							<span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce('gd_im_catpluploadan'); ?>"></span>
2780 2780
 							<div class="filelist"></div>
2781 2781
 						</div>
2782 2782
 						<span id="gd_im_catupload-error" style="display:none"></span>
@@ -2793,7 +2793,7 @@  discard block
 block discarded – undo
2793 2793
 							<input type="hidden" id="gd_terminateaction" value="continue"/>
2794 2794
 						</div>
2795 2795
 						<div class="gd-import-progress" id="gd-import-progress" style="display:none">
2796
-							<div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory');?> </b><font
2796
+							<div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory'); ?> </b><font
2797 2797
 									id="gd-import-done">0</font> / <font id="gd-import-total">0</font>&nbsp;( <font
2798 2798
 									id="gd-import-perc">0%</font> )
2799 2799
 								<div class="gd-fileprogress"></div>
@@ -2805,10 +2805,10 @@  discard block
 block discarded – undo
2805 2805
                     	<div class="gd-imex-btns" style="display:none;">
2806 2806
                         	<input type="hidden" class="geodir_import_file" name="geodir_import_file" value="save"/>
2807 2807
                         	<input onclick="gd_imex_PrepareImport(this, 'cat')" type="button" value="<?php echo CSV_IMPORT_DATA; ?>" id="gd_import_data" class="button-primary" />
2808
-                        	<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"/>
2809
-                        	<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')"/>
2808
+                        	<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"/>
2809
+                        	<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 2810
 							<div id="gd_process_data" style="display:none">
2811
-								<span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory');?>
2811
+								<span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory'); ?>
2812 2812
 							</div>
2813 2813
 						</div>
2814 2814
 					</td>
@@ -2822,26 +2822,26 @@  discard block
 block discarded – undo
2822 2822
 	<div id="gd_ie_excategs" class="metabox-holder">
2823 2823
       <div class="meta-box-sortables ui-sortable">
2824 2824
         <div id="gd_ie_ex_cats" class="postbox gd-hndle-pbox">
2825
-          <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>
2826
-          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __( 'GD Categories: Export CSV', 'geodirectory' );?></span></h3>
2825
+          <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>
2826
+          <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __('GD Categories: Export CSV', 'geodirectory'); ?></span></h3>
2827 2827
           <div class="inside">
2828 2828
             <table class="form-table">
2829 2829
 				<tbody>
2830 2830
 				  <tr>
2831
-					<td class="fld"><label for="gd_post_type"><?php _e( 'Post Type:', 'geodirectory' );?></label></td>
2832
-					<td><select name="gd_post_type" id="gd_post_type" style="min-width:140px"><?php echo $gd_posttypes_option;?></select></td>
2831
+					<td class="fld"><label for="gd_post_type"><?php _e('Post Type:', 'geodirectory'); ?></label></td>
2832
+					<td><select name="gd_post_type" id="gd_post_type" style="min-width:140px"><?php echo $gd_posttypes_option; ?></select></td>
2833 2833
 				  </tr>
2834 2834
 				   <tr>
2835
-					<td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e( 'Max entries per csv file:', 'geodirectory' );?></label></td>
2836
-					<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>
2835
+					<td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e('Max entries per csv file:', 'geodirectory'); ?></label></td>
2836
+					<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 2837
 				  </tr>
2838 2838
 				  <tr>
2839
-					<td class="fld" style="vertical-align:top"><label><?php _e( 'Progress:', 'geodirectory' );?></label></td>
2840
-					<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>
2839
+					<td class="fld" style="vertical-align:top"><label><?php _e('Progress:', 'geodirectory'); ?></label></td>
2840
+					<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 2841
 				  </tr>
2842 2842
 				  <tr class="gd-ie-actions">
2843 2843
 					<td style="vertical-align:top">
2844
-						<input type="submit" value="<?php echo esc_attr( __( 'Export CSV', 'geodirectory' ) );?>" class="button-primary" name="gd_ie_excats_submit" id="gd_ie_excats_submit">
2844
+						<input type="submit" value="<?php echo esc_attr(__('Export CSV', 'geodirectory')); ?>" class="button-primary" name="gd_ie_excats_submit" id="gd_ie_excats_submit">
2845 2845
 					</td>
2846 2846
 					<td id="gd_ie_ex_files" class="gd-ie-files"></td>
2847 2847
 				  </tr>
@@ -2863,7 +2863,7 @@  discard block
 block discarded – undo
2863 2863
      * @param array $gd_chunksize_options File chunk size options.
2864 2864
      * @param string $nonce Wordpress security token for GD import & export.
2865 2865
 	 */
2866
-	do_action( 'geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce );
2866
+	do_action('geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce);
2867 2867
 	?>
2868 2868
   </div>
2869 2869
 </div>
@@ -2882,7 +2882,7 @@  discard block
 block discarded – undo
2882 2882
         jQuery.ajax({
2883 2883
             url: ajaxurl,
2884 2884
             type: "POST",
2885
-            data: 'action=geodir_import_export&task=prepare_import&_pt=' + type + '&_file=' + uploadedFile + '&_nonce=<?php echo $nonce;?>',
2885
+            data: 'action=geodir_import_export&task=prepare_import&_pt=' + type + '&_file=' + uploadedFile + '&_nonce=<?php echo $nonce; ?>',
2886 2886
             dataType: 'json',
2887 2887
             cache: false,
2888 2888
             success: function(data) {
@@ -2934,7 +2934,7 @@  discard block
 block discarded – undo
2934 2934
 
2935 2935
         jQuery(cont).find('.filelist .file').remove();
2936 2936
         
2937
-        jQuery('#gd-import-msg', cont).find('#message').removeClass('updated').addClass('error').html("<p><?php echo esc_attr( PLZ_SELECT_CSV_FILE );?></p>");
2937
+        jQuery('#gd-import-msg', cont).find('#message').removeClass('updated').addClass('error').html("<p><?php echo esc_attr(PLZ_SELECT_CSV_FILE); ?></p>");
2938 2938
         jQuery('#gd-import-msg', cont).show();
2939 2939
         
2940 2940
         return false;
@@ -2993,7 +2993,7 @@  discard block
 block discarded – undo
2993 2993
     jQuery.ajax({
2994 2994
         url: ajaxurl,
2995 2995
         type: "POST",
2996
-        data: 'action=geodir_import_export&task=import_' + type + '&_pt=' + type + '&_file=' + uploadedFile + gddata + '&_ch=' + choice + '&_nonce=<?php echo $nonce;?>',
2996
+        data: 'action=geodir_import_export&task=import_' + type + '&_pt=' + type + '&_file=' + uploadedFile + gddata + '&_ch=' + choice + '&_nonce=<?php echo $nonce; ?>',
2997 2997
         dataType : 'json',
2998 2998
         cache: false,
2999 2999
         success: function (data) {
@@ -3182,27 +3182,27 @@  discard block
 block discarded – undo
3182 3182
 
3183 3183
     var gdMsg = '<p></p>';
3184 3184
     if ( processed > 0 ) {
3185
-        var msgParse = '<p><?php echo addslashes( sprintf( __( 'Total %s item(s) found.', 'geodirectory' ), '%s' ) );?></p>';
3185
+        var msgParse = '<p><?php echo addslashes(sprintf(__('Total %s item(s) found.', 'geodirectory'), '%s')); ?></p>';
3186 3186
         msgParse = msgParse.replace("%s", processed);
3187 3187
         gdMsg += msgParse;
3188 3188
     }
3189 3189
 
3190 3190
     if ( updated > 0 ) {
3191
-        var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) updated.', 'geodirectory' ), '%s', '%d' ) );?></p>';
3191
+        var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) updated.', 'geodirectory'), '%s', '%d')); ?></p>';
3192 3192
         msgParse = msgParse.replace("%s", updated);
3193 3193
         msgParse = msgParse.replace("%d", processed);
3194 3194
         gdMsg += msgParse;
3195 3195
     }
3196 3196
 
3197 3197
     if ( created > 0 ) {
3198
-        var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) added.', 'geodirectory' ), '%s', '%d' ) );?></p>';
3198
+        var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) added.', 'geodirectory'), '%s', '%d')); ?></p>';
3199 3199
         msgParse = msgParse.replace("%s", created);
3200 3200
         msgParse = msgParse.replace("%d", processed);
3201 3201
         gdMsg += msgParse;
3202 3202
     }
3203 3203
 
3204 3204
     if ( skipped > 0 ) {
3205
-        var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) ignored due to already exists.', 'geodirectory' ), '%s', '%d' ) );?></p>';
3205
+        var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) ignored due to already exists.', 'geodirectory'), '%s', '%d')); ?></p>';
3206 3206
         msgParse = msgParse.replace("%s", skipped);
3207 3207
         msgParse = msgParse.replace("%d", processed);
3208 3208
         gdMsg += msgParse;
@@ -3212,17 +3212,17 @@  discard block
 block discarded – undo
3212 3212
         if (type=='loc') {
3213 3213
             invalid_addr = invalid;
3214 3214
         }
3215
-        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>';
3215
+        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>';
3216 3216
         msgParse = msgParse.replace("%s", invalid_addr);
3217 3217
         msgParse = msgParse.replace("%d", total);
3218 3218
         gdMsg += msgParse;
3219 3219
     }
3220 3220
 
3221 3221
     if (invalid > 0 && type!='loc') {
3222
-        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>';
3222
+        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>';
3223 3223
         
3224 3224
         if (type=='hood') {
3225
-            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>';
3225
+            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>';
3226 3226
         }
3227 3227
         msgParse = msgParse.replace("%s", invalid);
3228 3228
         msgParse = msgParse.replace("%d", total);
@@ -3230,7 +3230,7 @@  discard block
 block discarded – undo
3230 3230
     }
3231 3231
 
3232 3232
     if (images > 0) {
3233
-        gdMsg += '<p><?php echo addslashes( sprintf( CSV_TRANSFER_IMG_FOLDER, $uploads['subdir'] ) );?></p>';
3233
+        gdMsg += '<p><?php echo addslashes(sprintf(CSV_TRANSFER_IMG_FOLDER, $uploads['subdir'])); ?></p>';
3234 3234
     }
3235 3235
     gdMsg += '<p></p>';
3236 3236
     jQuery('#gd-import-msg', cont).find('#message').removeClass('error').addClass('updated').html(gdMsg);
@@ -3387,7 +3387,7 @@  discard block
 block discarded – undo
3387 3387
         
3388 3388
     function gd_process_export_posts(el, post_type, total_posts, chunk_size, pages, page) {
3389 3389
         if (page < 2) {
3390
-            gd_progressbar(el, 0, '0% (0 / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr( __( 'Exporting...', 'geodirectory' ) );?>');
3390
+            gd_progressbar(el, 0, '0% (0 / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Exporting...', 'geodirectory')); ?>');
3391 3391
             jQuery(el).find('#gd_timer').text('00:00:01');
3392 3392
             jQuery('#gd_ie_ex_files', el).html('');
3393 3393
         }
@@ -3395,7 +3395,7 @@  discard block
 block discarded – undo
3395 3395
         jQuery.ajax({
3396 3396
             url: ajaxurl,
3397 3397
             type: "POST",
3398
-            data: 'action=geodir_import_export&task=export_posts&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce;?>&_p=' + page,
3398
+            data: 'action=geodir_import_export&task=export_posts&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce; ?>&_p=' + page,
3399 3399
             dataType : 'json',
3400 3400
             cache: false,
3401 3401
             beforeSend: function (jqXHR, settings) {},
@@ -3409,11 +3409,11 @@  discard block
 block discarded – undo
3409 3409
                     } else {
3410 3410
                         if (pages < page || pages == page) {
3411 3411
                             window.clearInterval(timer_posts);
3412
-                            gd_progressbar(el, 100, '100% (' + total_posts + ' / ' + total_posts + ') <i class="fa fa-check"></i><?php echo esc_attr( __( 'Complete!', 'geodirectory' ) );?>');
3412
+                            gd_progressbar(el, 100, '100% (' + total_posts + ' / ' + total_posts + ') <i class="fa fa-check"></i><?php echo esc_attr(__('Complete!', 'geodirectory')); ?>');
3413 3413
                         } else {
3414 3414
                             var percentage = Math.round(((page * chunk_size) / total_posts) * 100);
3415 3415
                             percentage = percentage > 100 ? 100 : percentage;
3416
-                            gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr( __( 'Exporting...', 'geodirectory' ) );?>');
3416
+                            gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Exporting...', 'geodirectory')); ?>');
3417 3417
                         }
3418 3418
                         if (typeof data.files != 'undefined' && jQuery(data.files).length ) {
3419 3419
                             var obj_files = data.files;
@@ -3443,7 +3443,7 @@  discard block
 block discarded – undo
3443 3443
 
3444 3444
     function gd_process_export_cats(el, post_type, total_cats, chunk_size, pages, page) {
3445 3445
         if (page < 2) {
3446
-            gd_progressbar(el, 0, '0% (0 / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr( __( 'Exporting...', 'geodirectory' ) );?>');
3446
+            gd_progressbar(el, 0, '0% (0 / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Exporting...', 'geodirectory')); ?>');
3447 3447
             jQuery(el).find('#gd_timer').text('00:00:01');
3448 3448
             jQuery('#gd_ie_ex_files', el).html('');
3449 3449
         }
@@ -3451,7 +3451,7 @@  discard block
 block discarded – undo
3451 3451
         jQuery.ajax({
3452 3452
             url: ajaxurl,
3453 3453
             type: "POST",
3454
-            data: 'action=geodir_import_export&task=export_cats&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce;?>&_p=' + page,
3454
+            data: 'action=geodir_import_export&task=export_cats&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce; ?>&_p=' + page,
3455 3455
             dataType : 'json',
3456 3456
             cache: false,
3457 3457
             beforeSend: function (jqXHR, settings) {},
@@ -3465,11 +3465,11 @@  discard block
 block discarded – undo
3465 3465
                     } else {
3466 3466
                         if (pages < page || pages == page) {
3467 3467
                             window.clearInterval(timer_cats);
3468
-                            gd_progressbar(el, 100, '100% (' + total_cats + ' / ' + total_cats + ') <i class="fa fa-check"></i><?php echo esc_attr( __( 'Complete!', 'geodirectory' ) );?>');
3468
+                            gd_progressbar(el, 100, '100% (' + total_cats + ' / ' + total_cats + ') <i class="fa fa-check"></i><?php echo esc_attr(__('Complete!', 'geodirectory')); ?>');
3469 3469
                         } else {
3470 3470
                             var percentage = Math.round(((page * chunk_size) / total_cats) * 100);
3471 3471
                             percentage = percentage > 100 ? 100 : percentage;
3472
-                            gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php esc_attr_e( 'Exporting...', 'geodirectory' );?>');
3472
+                            gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php esc_attr_e('Exporting...', 'geodirectory'); ?>');
3473 3473
                         }
3474 3474
                         if (typeof data.files != 'undefined' && jQuery(data.files).length ) {
3475 3475
                             var obj_files = data.files;
@@ -3526,13 +3526,13 @@  discard block
 block discarded – undo
3526 3526
 function geodir_init_filesystem()
3527 3527
 {
3528 3528
 
3529
-    if(!function_exists('get_filesystem_method')){
3529
+    if (!function_exists('get_filesystem_method')) {
3530 3530
         require_once(ABSPATH."/wp-admin/includes/file.php");
3531 3531
     }
3532 3532
     $access_type = get_filesystem_method();
3533 3533
     if ($access_type === 'direct') {
3534 3534
         /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
3535
-        $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3535
+        $creds = request_filesystem_credentials(trailingslashit(site_url()).'wp-admin/', '', false, false, array());
3536 3536
 
3537 3537
         /* initialize the API */
3538 3538
         if (!WP_Filesystem($creds)) {
@@ -3545,7 +3545,7 @@  discard block
 block discarded – undo
3545 3545
         return $wp_filesystem;
3546 3546
         /* do our file manipulations below */
3547 3547
     } elseif (defined('FTP_USER')) {
3548
-        $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
3548
+        $creds = request_filesystem_credentials(trailingslashit(site_url()).'wp-admin/', '', false, false, array());
3549 3549
 
3550 3550
         /* initialize the API */
3551 3551
         if (!WP_Filesystem($creds)) {
@@ -3580,7 +3580,7 @@  discard block
 block discarded – undo
3580 3580
  * @package GeoDirectory
3581 3581
  */
3582 3582
 function geodir_filesystem_notice()
3583
-{   if ( defined( 'DOING_AJAX' ) ){return;}
3583
+{   if (defined('DOING_AJAX')) {return; }
3584 3584
     $access_type = get_filesystem_method();
3585 3585
     if ($access_type === 'direct') {
3586 3586
     } elseif (!defined('FTP_USER')) {
@@ -3617,64 +3617,64 @@  discard block
 block discarded – undo
3617 3617
     // try to set higher limits for import
3618 3618
     $max_input_time = ini_get('max_input_time');
3619 3619
     $max_execution_time = ini_get('max_execution_time');
3620
-    $memory_limit= ini_get('memory_limit');
3620
+    $memory_limit = ini_get('memory_limit');
3621 3621
 
3622
-    if(!$max_input_time || $max_input_time<3000){
3622
+    if (!$max_input_time || $max_input_time < 3000) {
3623 3623
         ini_set('max_input_time', 3000);
3624 3624
     }
3625 3625
 
3626
-    if(!$max_execution_time || $max_execution_time<3000){
3626
+    if (!$max_execution_time || $max_execution_time < 3000) {
3627 3627
         ini_set('max_execution_time', 3000);
3628 3628
     }
3629 3629
 
3630
-    if($memory_limit && str_replace('M','',$memory_limit)){
3631
-        if(str_replace('M','',$memory_limit)<256){
3630
+    if ($memory_limit && str_replace('M', '', $memory_limit)) {
3631
+        if (str_replace('M', '', $memory_limit) < 256) {
3632 3632
             ini_set('memory_limit', '256M');
3633 3633
         }
3634 3634
     }
3635 3635
 
3636 3636
     $json = array();
3637 3637
 
3638
-    if ( !current_user_can( 'manage_options' ) ) {
3639
-        wp_send_json( $json );
3638
+    if (!current_user_can('manage_options')) {
3639
+        wp_send_json($json);
3640 3640
     }
3641 3641
 
3642
-    $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL;
3643
-    $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL;
3644
-    $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false;
3642
+    $task = isset($_REQUEST['task']) ? $_REQUEST['task'] : NULL;
3643
+    $nonce = isset($_REQUEST['_nonce']) ? $_REQUEST['_nonce'] : NULL;
3644
+    $stat = isset($_REQUEST['_st']) ? $_REQUEST['_st'] : false;
3645 3645
 
3646
-    if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
3647
-        wp_send_json( $json );
3646
+    if (!wp_verify_nonce($nonce, 'geodir_import_export_nonce')) {
3647
+        wp_send_json($json);
3648 3648
     }
3649 3649
 
3650
-    $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL;
3651
-    $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL;
3650
+    $post_type = isset($_REQUEST['_pt']) ? $_REQUEST['_pt'] : NULL;
3651
+    $chunk_per_page = isset($_REQUEST['_n']) ? absint($_REQUEST['_n']) : NULL;
3652 3652
     $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page;
3653
-    $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1;
3653
+    $chunk_page_no = isset($_REQUEST['_p']) ? absint($_REQUEST['_p']) : 1;
3654 3654
 
3655 3655
     $wp_filesystem = geodir_init_filesystem();
3656 3656
     if (!$wp_filesystem) {
3657
-        $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' );
3658
-        wp_send_json( $json );
3657
+        $json['error'] = __('Filesystem ERROR: Could not access filesystem.', 'geodirectory');
3658
+        wp_send_json($json);
3659 3659
     }
3660 3660
 
3661 3661
     if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
3662
-        $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' );
3663
-        wp_send_json( $json );
3662
+        $json['error'] = __('Filesystem ERROR: '.$wp_filesystem->errors->get_error_message(), 'geodirectory');
3663
+        wp_send_json($json);
3664 3664
     }
3665 3665
 
3666
-    $csv_file_dir = geodir_path_import_export( false );
3667
-    if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
3668
-        if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
3669
-            $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' );
3670
-            wp_send_json( $json );
3666
+    $csv_file_dir = geodir_path_import_export(false);
3667
+    if (!$wp_filesystem->is_dir($csv_file_dir)) {
3668
+        if (!$wp_filesystem->mkdir($csv_file_dir, FS_CHMOD_DIR)) {
3669
+            $json['error'] = __('ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory');
3670
+            wp_send_json($json);
3671 3671
         }
3672 3672
     }
3673 3673
     
3674 3674
     $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
3675 3675
     $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
3676 3676
 
3677
-    switch ( $task ) {
3677
+    switch ($task) {
3678 3678
         case 'export_posts': {
3679 3679
             // WPML
3680 3680
             $is_wpml = geodir_is_wpml();
@@ -3685,22 +3685,22 @@  discard block
 block discarded – undo
3685 3685
                 $sitepress->switch_lang('all', true);
3686 3686
             }
3687 3687
             // WPML
3688
-            if ( $post_type == 'gd_event' ) {
3689
-                add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 );
3688
+            if ($post_type == 'gd_event') {
3689
+                add_filter('geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2);
3690 3690
             }
3691
-            $file_name = $post_type . '_' . date( 'dmyHi' );
3692
-            $posts_count = geodir_get_posts_count( $post_type );
3693
-            $file_url_base = geodir_path_import_export() . '/';
3694
-            $file_url = $file_url_base . $file_name . '.csv';
3695
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3696
-            $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv';
3691
+            $file_name = $post_type.'_'.date('dmyHi');
3692
+            $posts_count = geodir_get_posts_count($post_type);
3693
+            $file_url_base = geodir_path_import_export().'/';
3694
+            $file_url = $file_url_base.$file_name.'.csv';
3695
+            $file_path = $csv_file_dir.'/'.$file_name.'.csv';
3696
+            $file_path_temp = $csv_file_dir.'/'.$post_type.'_'.$nonce.'.csv';
3697 3697
             
3698 3698
             $chunk_file_paths = array();
3699 3699
 
3700
-            if ( isset( $_REQUEST['_st'] ) ) {
3701
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3702
-                $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0;
3703
-                $percentage = min( $percentage, 100 );
3700
+            if (isset($_REQUEST['_st'])) {
3701
+                $line_count = (int) geodir_import_export_line_count($file_path_temp);
3702
+                $percentage = count($posts_count) > 0 && $line_count > 0 ? ceil($line_count / $posts_count) * 100 : 0;
3703
+                $percentage = min($percentage, 100);
3704 3704
                 
3705 3705
                 $json['percentage'] = $percentage;
3706 3706
                 // WPML
@@ -3708,45 +3708,45 @@  discard block
 block discarded – undo
3708 3708
                     $sitepress->switch_lang($active_lang, true);
3709 3709
                 }
3710 3710
                 // WPML
3711
-                wp_send_json( $json );
3711
+                wp_send_json($json);
3712 3712
                 gd_die();
3713 3713
             } else {
3714
-                if ( !$posts_count > 0 ) {
3715
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3714
+                if (!$posts_count > 0) {
3715
+                    $json['error'] = __('No records to export.', 'geodirectory');
3716 3716
                 } else {
3717 3717
                     $total_posts = $posts_count;
3718 3718
                     if ($chunk_per_page > $total_posts) {
3719 3719
                         $chunk_per_page = $total_posts;
3720 3720
                     }
3721
-                    $chunk_total_pages = ceil( $total_posts / $chunk_per_page );
3721
+                    $chunk_total_pages = ceil($total_posts / $chunk_per_page);
3722 3722
                     
3723 3723
                     $j = $chunk_page_no;
3724
-                    $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j );
3724
+                    $chunk_save_posts = geodir_imex_get_posts($post_type, $chunk_per_page, $j);
3725 3725
                     
3726 3726
                     $per_page = 500;
3727 3727
                     if ($per_page > $chunk_per_page) {
3728 3728
                         $per_page = $chunk_per_page;
3729 3729
                     }
3730
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3730
+                    $total_pages = ceil($chunk_per_page / $per_page);
3731 3731
                     
3732
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3733
-                        $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page );
3732
+                    for ($i = 0; $i <= $total_pages; $i++) {
3733
+                        $save_posts = array_slice($chunk_save_posts, ($i * $per_page), $per_page);
3734 3734
                         
3735 3735
                         $clear = $i == 0 ? true : false;
3736
-                        geodir_save_csv_data( $file_path_temp, $save_posts, $clear );
3736
+                        geodir_save_csv_data($file_path_temp, $save_posts, $clear);
3737 3737
                     }
3738 3738
                         
3739
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3740
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3741
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3742
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3743
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3739
+                    if ($wp_filesystem->exists($file_path_temp)) {
3740
+                        $chunk_page_no = $chunk_total_pages > 1 ? '-'.$j : '';
3741
+                        $chunk_file_name = $file_name.$chunk_page_no.'.csv';
3742
+                        $file_path = $csv_file_dir.'/'.$chunk_file_name;
3743
+                        $wp_filesystem->move($file_path_temp, $file_path, true);
3744 3744
                         
3745
-                        $file_url = $file_url_base . $chunk_file_name;
3746
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3745
+                        $file_url = $file_url_base.$chunk_file_name;
3746
+                        $chunk_file_paths[] = array('i' => $j.'.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3747 3747
                     }
3748 3748
                     
3749
-                    if ( !empty($chunk_file_paths) ) {
3749
+                    if (!empty($chunk_file_paths)) {
3750 3750
                         $json['total'] = $posts_count;
3751 3751
                         $json['files'] = $chunk_file_paths;
3752 3752
                     } else {
@@ -3754,7 +3754,7 @@  discard block
 block discarded – undo
3754 3754
                             $json['total'] = $posts_count;
3755 3755
                             $json['files'] = array();
3756 3756
                         } else {
3757
-                            $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3757
+                            $json['error'] = __('ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory');
3758 3758
                         }
3759 3759
                     }
3760 3760
                 }
@@ -3763,7 +3763,7 @@  discard block
 block discarded – undo
3763 3763
                     $sitepress->switch_lang($active_lang, true);
3764 3764
                 }
3765 3765
                 // WPML
3766
-                wp_send_json( $json );
3766
+                wp_send_json($json);
3767 3767
             }
3768 3768
         }
3769 3769
         break;
@@ -3777,20 +3777,20 @@  discard block
 block discarded – undo
3777 3777
                 $sitepress->switch_lang('all', true);
3778 3778
             }
3779 3779
             // WPML
3780
-            $file_name = $post_type . 'category_' . date( 'dmyHi' );
3780
+            $file_name = $post_type.'category_'.date('dmyHi');
3781 3781
             
3782
-            $terms_count = geodir_get_terms_count( $post_type );
3783
-            $file_url_base = geodir_path_import_export() . '/';
3784
-            $file_url = $file_url_base . $file_name . '.csv';
3785
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3786
-            $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv';
3782
+            $terms_count = geodir_get_terms_count($post_type);
3783
+            $file_url_base = geodir_path_import_export().'/';
3784
+            $file_url = $file_url_base.$file_name.'.csv';
3785
+            $file_path = $csv_file_dir.'/'.$file_name.'.csv';
3786
+            $file_path_temp = $csv_file_dir.'/'.$post_type.'category_'.$nonce.'.csv';
3787 3787
             
3788 3788
             $chunk_file_paths = array();
3789 3789
             
3790
-            if ( isset( $_REQUEST['_st'] ) ) {
3791
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3792
-                $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0;
3793
-                $percentage = min( $percentage, 100 );
3790
+            if (isset($_REQUEST['_st'])) {
3791
+                $line_count = (int) geodir_import_export_line_count($file_path_temp);
3792
+                $percentage = count($terms_count) > 0 && $line_count > 0 ? ceil($line_count / $terms_count) * 100 : 0;
3793
+                $percentage = min($percentage, 100);
3794 3794
                 
3795 3795
                 $json['percentage'] = $percentage;
3796 3796
                 // WPML
@@ -3798,48 +3798,48 @@  discard block
 block discarded – undo
3798 3798
                     $sitepress->switch_lang($active_lang, true);
3799 3799
                 }
3800 3800
                 // WPML
3801
-                wp_send_json( $json );
3801
+                wp_send_json($json);
3802 3802
             } else {
3803
-                if ( !$terms_count > 0 ) {
3804
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3803
+                if (!$terms_count > 0) {
3804
+                    $json['error'] = __('No records to export.', 'geodirectory');
3805 3805
                 } else {
3806 3806
                     $total_terms = $terms_count;
3807 3807
                     if ($chunk_per_page > $terms_count) {
3808 3808
                         $chunk_per_page = $terms_count;
3809 3809
                     }
3810
-                    $chunk_total_pages = ceil( $total_terms / $chunk_per_page );
3810
+                    $chunk_total_pages = ceil($total_terms / $chunk_per_page);
3811 3811
                     
3812 3812
                     $j = $chunk_page_no;
3813
-                    $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j );
3813
+                    $chunk_save_terms = geodir_imex_get_terms($post_type, $chunk_per_page, $j);
3814 3814
                     
3815 3815
                     $per_page = 500;
3816 3816
                     if ($per_page > $chunk_per_page) {
3817 3817
                         $per_page = $chunk_per_page;
3818 3818
                     }
3819
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3819
+                    $total_pages = ceil($chunk_per_page / $per_page);
3820 3820
                     
3821
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3822
-                        $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page );
3821
+                    for ($i = 0; $i <= $total_pages; $i++) {
3822
+                        $save_terms = array_slice($chunk_save_terms, ($i * $per_page), $per_page);
3823 3823
                         
3824 3824
                         $clear = $i == 0 ? true : false;
3825
-                        geodir_save_csv_data( $file_path_temp, $save_terms, $clear );
3825
+                        geodir_save_csv_data($file_path_temp, $save_terms, $clear);
3826 3826
                     }
3827 3827
                     
3828
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3829
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3830
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3831
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3832
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3828
+                    if ($wp_filesystem->exists($file_path_temp)) {
3829
+                        $chunk_page_no = $chunk_total_pages > 1 ? '-'.$j : '';
3830
+                        $chunk_file_name = $file_name.$chunk_page_no.'.csv';
3831
+                        $file_path = $csv_file_dir.'/'.$chunk_file_name;
3832
+                        $wp_filesystem->move($file_path_temp, $file_path, true);
3833 3833
                         
3834
-                        $file_url = $file_url_base . $chunk_file_name;
3835
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3834
+                        $file_url = $file_url_base.$chunk_file_name;
3835
+                        $chunk_file_paths[] = array('i' => $j.'.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3836 3836
                     }
3837 3837
                     
3838
-                    if ( !empty($chunk_file_paths) ) {
3838
+                    if (!empty($chunk_file_paths)) {
3839 3839
                         $json['total'] = $terms_count;
3840 3840
                         $json['files'] = $chunk_file_paths;
3841 3841
                     } else {
3842
-                        $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' );
3842
+                        $json['error'] = __('ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory');
3843 3843
                     }
3844 3844
                 }
3845 3845
                 // WPML
@@ -3847,127 +3847,127 @@  discard block
 block discarded – undo
3847 3847
                     $sitepress->switch_lang($active_lang, true);
3848 3848
                 }
3849 3849
                 // WPML
3850
-                wp_send_json( $json );
3850
+                wp_send_json($json);
3851 3851
             }
3852 3852
         }
3853 3853
         break;
3854 3854
         case 'export_locations': {
3855
-            $file_url_base = geodir_path_import_export() . '/';
3856
-            $file_name = 'gd_locations_' . date( 'dmyHi' );
3857
-            $file_url = $file_url_base . $file_name . '.csv';
3858
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3859
-            $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv';
3855
+            $file_url_base = geodir_path_import_export().'/';
3856
+            $file_name = 'gd_locations_'.date('dmyHi');
3857
+            $file_url = $file_url_base.$file_name.'.csv';
3858
+            $file_path = $csv_file_dir.'/'.$file_name.'.csv';
3859
+            $file_path_temp = $csv_file_dir.'/gd_locations_'.$nonce.'.csv';
3860 3860
             
3861
-            $items_count = (int)geodir_location_imex_count_locations();
3861
+            $items_count = (int) geodir_location_imex_count_locations();
3862 3862
             
3863
-            if ( isset( $_REQUEST['_st'] ) ) {
3864
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3865
-                $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3866
-                $percentage = min( $percentage, 100 );
3863
+            if (isset($_REQUEST['_st'])) {
3864
+                $line_count = (int) geodir_import_export_line_count($file_path_temp);
3865
+                $percentage = count($items_count) > 0 && $line_count > 0 ? ceil($line_count / $items_count) * 100 : 0;
3866
+                $percentage = min($percentage, 100);
3867 3867
                 
3868 3868
                 $json['percentage'] = $percentage;
3869
-                wp_send_json( $json );
3869
+                wp_send_json($json);
3870 3870
             } else {
3871 3871
                 $chunk_file_paths = array();
3872 3872
                 
3873
-                if ( !$items_count > 0 ) {
3874
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3873
+                if (!$items_count > 0) {
3874
+                    $json['error'] = __('No records to export.', 'geodirectory');
3875 3875
                 } else {
3876
-                    $chunk_per_page = min( $chunk_per_page, $items_count );
3877
-                    $chunk_total_pages = ceil( $items_count / $chunk_per_page );
3876
+                    $chunk_per_page = min($chunk_per_page, $items_count);
3877
+                    $chunk_total_pages = ceil($items_count / $chunk_per_page);
3878 3878
                     
3879 3879
                     $j = $chunk_page_no;
3880
-                    $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j );
3880
+                    $chunk_save_items = geodir_location_imex_locations_data($chunk_per_page, $j);
3881 3881
                     
3882 3882
                     $per_page = 500;
3883
-                    $per_page = min( $per_page, $chunk_per_page );
3884
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3883
+                    $per_page = min($per_page, $chunk_per_page);
3884
+                    $total_pages = ceil($chunk_per_page / $per_page);
3885 3885
                     
3886
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3887
-                        $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3886
+                    for ($i = 0; $i <= $total_pages; $i++) {
3887
+                        $save_items = array_slice($chunk_save_items, ($i * $per_page), $per_page);
3888 3888
                         
3889 3889
                         $clear = $i == 0 ? true : false;
3890
-                        geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3890
+                        geodir_save_csv_data($file_path_temp, $save_items, $clear);
3891 3891
                     }
3892 3892
                     
3893
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3894
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3895
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3896
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3897
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3893
+                    if ($wp_filesystem->exists($file_path_temp)) {
3894
+                        $chunk_page_no = $chunk_total_pages > 1 ? '-'.$j : '';
3895
+                        $chunk_file_name = $file_name.$chunk_page_no.'.csv';
3896
+                        $file_path = $csv_file_dir.'/'.$chunk_file_name;
3897
+                        $wp_filesystem->move($file_path_temp, $file_path, true);
3898 3898
                         
3899
-                        $file_url = $file_url_base . $chunk_file_name;
3900
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3899
+                        $file_url = $file_url_base.$chunk_file_name;
3900
+                        $chunk_file_paths[] = array('i' => $j.'.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3901 3901
                     }
3902 3902
                     
3903
-                    if ( !empty($chunk_file_paths) ) {
3903
+                    if (!empty($chunk_file_paths)) {
3904 3904
                         $json['total'] = $items_count;
3905 3905
                         $json['files'] = $chunk_file_paths;
3906 3906
                     } else {
3907
-                        $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3907
+                        $json['error'] = __('Fail, something wrong to create csv file.', 'geodirectory');
3908 3908
                     }
3909 3909
                 }
3910
-                wp_send_json( $json );
3910
+                wp_send_json($json);
3911 3911
             }
3912 3912
         }
3913 3913
         break;
3914 3914
         case 'export_hoods': {
3915
-            $file_url_base = geodir_path_import_export() . '/';
3916
-            $file_name = 'gd_neighbourhoods_' . date( 'dmyHi' );
3917
-            $file_url = $file_url_base . $file_name . '.csv';
3918
-            $file_path = $csv_file_dir . '/' . $file_name . '.csv';
3919
-            $file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv';
3915
+            $file_url_base = geodir_path_import_export().'/';
3916
+            $file_name = 'gd_neighbourhoods_'.date('dmyHi');
3917
+            $file_url = $file_url_base.$file_name.'.csv';
3918
+            $file_path = $csv_file_dir.'/'.$file_name.'.csv';
3919
+            $file_path_temp = $csv_file_dir.'/gd_neighbourhoods_'.$nonce.'.csv';
3920 3920
             
3921
-            $items_count = (int)geodir_location_imex_count_neighbourhoods();
3921
+            $items_count = (int) geodir_location_imex_count_neighbourhoods();
3922 3922
             
3923
-            if ( isset( $_REQUEST['_st'] ) ) {
3924
-                $line_count = (int)geodir_import_export_line_count( $file_path_temp );
3925
-                $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0;
3926
-                $percentage = min( $percentage, 100 );
3923
+            if (isset($_REQUEST['_st'])) {
3924
+                $line_count = (int) geodir_import_export_line_count($file_path_temp);
3925
+                $percentage = count($items_count) > 0 && $line_count > 0 ? ceil($line_count / $items_count) * 100 : 0;
3926
+                $percentage = min($percentage, 100);
3927 3927
                 
3928 3928
                 $json['percentage'] = $percentage;
3929
-                wp_send_json( $json );
3929
+                wp_send_json($json);
3930 3930
             } else {
3931 3931
                 $chunk_file_paths = array();
3932 3932
                 
3933
-                if ( !$items_count > 0 ) {
3934
-                    $json['error'] = __( 'No records to export.', 'geodirectory' );
3933
+                if (!$items_count > 0) {
3934
+                    $json['error'] = __('No records to export.', 'geodirectory');
3935 3935
                 } else {
3936
-                    $chunk_per_page = min( $chunk_per_page, $items_count );
3937
-                    $chunk_total_pages = ceil( $items_count / $chunk_per_page );
3936
+                    $chunk_per_page = min($chunk_per_page, $items_count);
3937
+                    $chunk_total_pages = ceil($items_count / $chunk_per_page);
3938 3938
                     
3939 3939
                     $j = $chunk_page_no;
3940
-                    $chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j );
3940
+                    $chunk_save_items = geodir_location_imex_neighbourhoods_data($chunk_per_page, $j);
3941 3941
                     
3942 3942
                     $per_page = 500;
3943
-                    $per_page = min( $per_page, $chunk_per_page );
3944
-                    $total_pages = ceil( $chunk_per_page / $per_page );
3943
+                    $per_page = min($per_page, $chunk_per_page);
3944
+                    $total_pages = ceil($chunk_per_page / $per_page);
3945 3945
                     
3946
-                    for ( $i = 0; $i <= $total_pages; $i++ ) {
3947
-                        $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page );
3946
+                    for ($i = 0; $i <= $total_pages; $i++) {
3947
+                        $save_items = array_slice($chunk_save_items, ($i * $per_page), $per_page);
3948 3948
                         
3949 3949
                         $clear = $i == 0 ? true : false;
3950
-                        geodir_save_csv_data( $file_path_temp, $save_items, $clear );
3950
+                        geodir_save_csv_data($file_path_temp, $save_items, $clear);
3951 3951
                     }
3952 3952
                     
3953
-                    if ( $wp_filesystem->exists( $file_path_temp ) ) {
3954
-                        $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : '';
3955
-                        $chunk_file_name = $file_name . $chunk_page_no . '.csv';
3956
-                        $file_path = $csv_file_dir . '/' . $chunk_file_name;
3957
-                        $wp_filesystem->move( $file_path_temp, $file_path, true );
3953
+                    if ($wp_filesystem->exists($file_path_temp)) {
3954
+                        $chunk_page_no = $chunk_total_pages > 1 ? '-'.$j : '';
3955
+                        $chunk_file_name = $file_name.$chunk_page_no.'.csv';
3956
+                        $file_path = $csv_file_dir.'/'.$chunk_file_name;
3957
+                        $wp_filesystem->move($file_path_temp, $file_path, true);
3958 3958
                         
3959
-                        $file_url = $file_url_base . $chunk_file_name;
3960
-                        $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3959
+                        $file_url = $file_url_base.$chunk_file_name;
3960
+                        $chunk_file_paths[] = array('i' => $j.'.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
3961 3961
                     }
3962 3962
                     
3963
-                    if ( !empty($chunk_file_paths) ) {
3963
+                    if (!empty($chunk_file_paths)) {
3964 3964
                         $json['total'] = $items_count;
3965 3965
                         $json['files'] = $chunk_file_paths;
3966 3966
                     } else {
3967
-                        $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' );
3967
+                        $json['error'] = __('Fail, something wrong to create csv file.', 'geodirectory');
3968 3968
                     }
3969 3969
                 }
3970
-                wp_send_json( $json );
3970
+                wp_send_json($json);
3971 3971
             }
3972 3972
         }
3973 3973
         break;
@@ -3984,33 +3984,33 @@  discard block
 block discarded – undo
3984 3984
             }
3985 3985
             // WPML
3986 3986
             
3987
-            ini_set( 'auto_detect_line_endings', true );
3987
+            ini_set('auto_detect_line_endings', true);
3988 3988
             
3989 3989
             $uploads = wp_upload_dir();
3990 3990
             $uploads_dir = $uploads['path'];
3991 3991
             $uploads_subdir = $uploads['subdir'];
3992 3992
             
3993
-            $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL;
3994
-            $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip';
3993
+            $csv_file = isset($_POST['_file']) ? $_POST['_file'] : NULL;
3994
+            $import_choice = isset($_REQUEST['_ch']) ? $_REQUEST['_ch'] : 'skip';
3995 3995
             
3996
-            $csv_file_arr = explode( '/', $csv_file );
3997
-            $csv_filename = end( $csv_file_arr );
3998
-            $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename;
3996
+            $csv_file_arr = explode('/', $csv_file);
3997
+            $csv_filename = end($csv_file_arr);
3998
+            $target_path = $uploads_dir.'/temp_'.$current_user->data->ID.'/'.$csv_filename;
3999 3999
             
4000 4000
             $json['file'] = $csv_file;
4001
-            $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' );
4001
+            $json['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
4002 4002
             $file = array();
4003 4003
 
4004
-            if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
4005
-                $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename );
4004
+            if ($csv_file && $wp_filesystem->is_file($target_path) && $wp_filesystem->exists($target_path)) {
4005
+                $wp_filetype = wp_check_filetype_and_ext($target_path, $csv_filename);
4006 4006
                 
4007 4007
                 if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
4008 4008
                     $json['error'] = NULL;
4009 4009
                     $json['rows'] = 0;
4010 4010
                     
4011
-                    if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
4012
-                        while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
4013
-                            if ( !empty( $data ) ) {
4011
+                    if (($handle = fopen($target_path, "r")) !== FALSE) {
4012
+                        while (($data = fgetcsv($handle, 100000, ",")) !== FALSE) {
4013
+                            if (!empty($data)) {
4014 4014
                                 $file[] = $data;
4015 4015
                             }
4016 4016
                         }
@@ -4023,19 +4023,19 @@  discard block
 block discarded – undo
4023 4023
                         $json['error'] = __('No data found in csv file.', 'geodirectory');
4024 4024
                     }
4025 4025
                 } else {
4026
-                    wp_send_json( $json );
4026
+                    wp_send_json($json);
4027 4027
                 }
4028 4028
             } else {
4029
-                wp_send_json( $json );
4029
+                wp_send_json($json);
4030 4030
             }
4031 4031
             
4032
-            if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
4033
-                wp_send_json( $json );
4032
+            if ($task == 'prepare_import' || !empty($json['error'])) {
4033
+                wp_send_json($json);
4034 4034
             }
4035 4035
             
4036 4036
             $total = $json['rows'];
4037
-            $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1;
4038
-            $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0;
4037
+            $limit = isset($_POST['limit']) ? (int) $_POST['limit'] : 1;
4038
+            $processed = isset($_POST['processed']) ? (int) $_POST['processed'] : 0;
4039 4039
             
4040 4040
             $count = $limit;
4041 4041
             
@@ -4060,13 +4060,13 @@  discard block
 block discarded – undo
4060 4060
             
4061 4061
             $post_types = geodir_get_posttypes();
4062 4062
 
4063
-            if ( $task == 'import_cat' ) {
4063
+            if ($task == 'import_cat') {
4064 4064
                 if (!empty($file)) {
4065 4065
                     $columns = isset($file[0]) ? $file[0] : NULL;
4066 4066
                     
4067 4067
                     if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4068 4068
                         $json['error'] = CSV_INVAILD_FILE;
4069
-                        wp_send_json( $json );
4069
+                        wp_send_json($json);
4070 4070
                         exit;
4071 4071
                     }
4072 4072
                     
@@ -4077,7 +4077,7 @@  discard block
 block discarded – undo
4077 4077
                         
4078 4078
                         if (isset($file[$index])) {
4079 4079
                             $row = $file[$index];
4080
-                            $row = array_map( 'trim', $row );
4080
+                            $row = array_map('trim', $row);
4081 4081
                             //$row = array_map( 'utf8_encode', $row );
4082 4082
                             
4083 4083
                             $cat_id = '';
@@ -4094,42 +4094,42 @@  discard block
 block discarded – undo
4094 4094
                             $cat_id_original = '';
4095 4095
                             
4096 4096
                             $c = 0;
4097
-                            foreach ($columns as $column ) {
4098
-                                if ( $column == 'cat_id' ) {
4099
-                                    $cat_id = (int)$row[$c];
4100
-                                } else if ( $column == 'cat_name' ) {
4097
+                            foreach ($columns as $column) {
4098
+                                if ($column == 'cat_id') {
4099
+                                    $cat_id = (int) $row[$c];
4100
+                                } else if ($column == 'cat_name') {
4101 4101
                                     $cat_name = $row[$c];
4102
-                                } else if ( $column == 'cat_slug' ) {
4102
+                                } else if ($column == 'cat_slug') {
4103 4103
                                     $cat_slug = $row[$c];
4104
-                                } else if ( $column == 'cat_posttype' ) {
4104
+                                } else if ($column == 'cat_posttype') {
4105 4105
                                     $cat_posttype = $row[$c];
4106
-                                } else if ( $column == 'cat_parent' ) {
4106
+                                } else if ($column == 'cat_parent') {
4107 4107
                                     $cat_parent = trim($row[$c]);
4108
-                                } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
4108
+                                } else if ($column == 'cat_schema' && $row[$c] != '') {
4109 4109
                                     $cat_schema = $row[$c];
4110
-                                } else if ( $column == 'cat_description' ) {
4110
+                                } else if ($column == 'cat_description') {
4111 4111
                                     $cat_description = $row[$c];
4112
-                                } else if ( $column == 'cat_top_description' ) {
4112
+                                } else if ($column == 'cat_top_description') {
4113 4113
                                     $cat_top_description = $row[$c];
4114
-                                } else if ( $column == 'cat_image' ) {
4114
+                                } else if ($column == 'cat_image') {
4115 4115
                                     $cat_image = $row[$c];
4116
-                                } else if ( $column == 'cat_icon' ) {
4116
+                                } else if ($column == 'cat_icon') {
4117 4117
                                     $cat_icon = $row[$c];
4118 4118
                                 }
4119 4119
                                 // WPML
4120
-                                if ( $is_wpml ) {
4121
-                                    if ( $column == 'cat_language' ) {
4122
-                                        $cat_language = geodir_strtolower( trim( $row[$c] ) );
4123
-                                    } else if ( $column == 'cat_id_original' ) {
4124
-                                        $cat_id_original = (int)$row[$c];
4120
+                                if ($is_wpml) {
4121
+                                    if ($column == 'cat_language') {
4122
+                                        $cat_language = geodir_strtolower(trim($row[$c]));
4123
+                                    } else if ($column == 'cat_id_original') {
4124
+                                        $cat_id_original = (int) $row[$c];
4125 4125
                                     }
4126 4126
                                 }
4127 4127
                                 // WPML
4128 4128
                                 $c++;
4129 4129
                             }
4130 4130
                             
4131
-                            if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
4132
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
4131
+                            if ($cat_name == '' || !in_array($cat_posttype, $post_types)) {
4132
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be added due to blank title/invalid post type', 'geodirectory'));
4133 4133
                                 
4134 4134
                                 $invalid++;
4135 4135
                                 continue;
@@ -4147,24 +4147,24 @@  discard block
 block discarded – undo
4147 4147
                             $term_data['description'] = $cat_description;
4148 4148
                             $term_data['cat_schema'] = $cat_schema;
4149 4149
                             $term_data['top_description'] = $cat_top_description;
4150
-                            $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : '';
4151
-                            $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : '';
4150
+                            $term_data['image'] = $cat_image != '' ? basename($cat_image) : '';
4151
+                            $term_data['icon'] = $cat_icon != '' ? basename($cat_icon) : '';
4152 4152
                             
4153 4153
                             //$term_data = array_map( 'utf8_encode', $term_data );
4154 4154
                             
4155
-                            $taxonomy = $cat_posttype . 'category';
4155
+                            $taxonomy = $cat_posttype.'category';
4156 4156
                             
4157 4157
                             $term_data['taxonomy'] = $taxonomy;
4158 4158
 
4159 4159
                             $term_parent_id = 0;
4160
-                            if ($cat_parent != "" || (int)$cat_parent > 0) {
4160
+                            if ($cat_parent != "" || (int) $cat_parent > 0) {
4161 4161
                                 $term_parent = '';
4162 4162
                                 
4163
-                                if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
4163
+                                if ($term_parent = get_term_by('name', $cat_parent, $taxonomy)) {
4164 4164
                                     //
4165
-                                } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
4165
+                                } else if ($term_parent = get_term_by('slug', $cat_parent, $taxonomy)) {
4166 4166
                                     //
4167
-                                } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
4167
+                                } else if ($term_parent = get_term_by('id', $cat_parent, $taxonomy)) {
4168 4168
                                     //
4169 4169
                                 } else {
4170 4170
                                     $term_parent_data = array();
@@ -4172,104 +4172,104 @@  discard block
 block discarded – undo
4172 4172
                                     //$term_parent_data = array_map( 'utf8_encode', $term_parent_data );
4173 4173
                                     $term_parent_data['taxonomy'] = $taxonomy;
4174 4174
                                     
4175
-                                    $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data );
4175
+                                    $term_parent_id = (int) geodir_imex_insert_term($taxonomy, $term_parent_data);
4176 4176
                                 }
4177 4177
                                 
4178
-                                if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
4179
-                                    $term_parent_id = (int)$term_parent->term_id;
4178
+                                if (!empty($term_parent) && !is_wp_error($term_parent)) {
4179
+                                    $term_parent_id = (int) $term_parent->term_id;
4180 4180
                                 }
4181 4181
                             }
4182
-                            $term_data['parent'] = (int)$term_parent_id;
4182
+                            $term_data['parent'] = (int) $term_parent_id;
4183 4183
 
4184 4184
                             $term_id = NULL;
4185
-                            if ( $import_choice == 'update' ) {
4186
-                                if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
4185
+                            if ($import_choice == 'update') {
4186
+                                if ($cat_id > 0 && $term = (array) term_exists($cat_id, $taxonomy)) {
4187 4187
                                     $term_data['term_id'] = $term['term_id'];
4188 4188
                                     
4189
-                                    if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
4189
+                                    if ($term_id = geodir_imex_update_term($taxonomy, $term_data)) {
4190 4190
                                         $updated++;
4191 4191
                                     } else {
4192 4192
                                         $invalid++;
4193
-                                        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' ) );
4193
+                                        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'));
4194 4194
                                     }
4195
-                                } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4195
+                                } else if ($term_data['slug'] != '' && $term = (array) term_exists($term_data['slug'], $taxonomy)) {
4196 4196
                                     $term_data['term_id'] = $term['term_id'];
4197 4197
                                     
4198
-                                    if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
4198
+                                    if ($term_id = geodir_imex_update_term($taxonomy, $term_data)) {
4199 4199
                                         $updated++;
4200 4200
                                     } else {
4201 4201
                                         $invalid++;
4202
-                                        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' ) );
4202
+                                        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'));
4203 4203
                                     }
4204 4204
                                 } else {
4205
-                                    if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
4205
+                                    if ($term_id = geodir_imex_insert_term($taxonomy, $term_data)) {
4206 4206
                                         $created++;
4207 4207
                                     } else {
4208 4208
                                         $invalid++;
4209
-                                        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' ) );
4209
+                                        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'));
4210 4210
                                     }
4211 4211
                                 }
4212
-                            } else if ( $import_choice == 'skip' ) {
4213
-                                if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
4212
+                            } else if ($import_choice == 'skip') {
4213
+                                if ($cat_id > 0 && $term = (array) term_exists($cat_id, $taxonomy)) {
4214 4214
                                     $skipped++;
4215
-                                } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
4215
+                                } else if ($term_data['slug'] != '' && $term = (array) term_exists($term_data['slug'], $taxonomy)) {
4216 4216
                                     $skipped++;
4217 4217
                                 } else {
4218
-                                    if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
4218
+                                    if ($term_id = geodir_imex_insert_term($taxonomy, $term_data)) {
4219 4219
                                         $created++;
4220 4220
                                     } else {
4221 4221
                                         $invalid++;
4222
-                                        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' ) );
4222
+                                        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'));
4223 4223
                                     }
4224 4224
                                 }
4225 4225
                             } else {
4226 4226
                                 $invalid++;
4227
-                                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' ) );
4227
+                                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'));
4228 4228
                             }
4229 4229
                             
4230
-                            if ( $term_id ) {
4230
+                            if ($term_id) {
4231 4231
                                 // WPML
4232 4232
                                 if ($is_wpml && $cat_id_original > 0 && $cat_language != '') {
4233
-                                    $wpml_element_type = 'tax_' . $taxonomy;
4234
-                                    $source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type );
4233
+                                    $wpml_element_type = 'tax_'.$taxonomy;
4234
+                                    $source_language = geodir_get_language_for_element($cat_id_original, $wpml_element_type);
4235 4235
                                     $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4236 4236
 
4237
-                                    $trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type );
4237
+                                    $trid = $sitepress->get_element_trid($cat_id_original, $wpml_element_type);
4238 4238
                                     
4239
-                                    $sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language );
4239
+                                    $sitepress->set_element_language_details($term_id, $wpml_element_type, $trid, $cat_language, $source_language);
4240 4240
                                 }
4241 4241
                                 // WPML
4242 4242
                                 
4243
-                                if ( isset( $term_data['top_description'] ) ) {
4244
-                                    update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype );
4243
+                                if (isset($term_data['top_description'])) {
4244
+                                    update_tax_meta($term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype);
4245 4245
                                 }
4246 4246
                                 
4247
-                                if ( isset( $term_data['cat_schema'] ) ) {
4248
-                                    update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype );
4247
+                                if (isset($term_data['cat_schema'])) {
4248
+                                    update_tax_meta($term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype);
4249 4249
                                 }
4250 4250
             
4251 4251
                                 $attachment = false;
4252
-                                if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
4253
-                                    $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype );
4254
-                                    $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : '';
4252
+                                if (isset($term_data['image']) && $term_data['image'] != '') {
4253
+                                    $cat_image = geodir_get_default_catimage($term_id, $cat_posttype);
4254
+                                    $cat_image = !empty($cat_image) && isset($cat_image['src']) ? $cat_image['src'] : '';
4255 4255
                                     
4256
-                                    if ( basename($cat_image) != $term_data['image'] ) {
4256
+                                    if (basename($cat_image) != $term_data['image']) {
4257 4257
                                         $attachment = true;
4258
-                                        update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype );
4258
+                                        update_tax_meta($term_id, 'ct_cat_default_img', array('id' => 'image', 'src' => $uploads['url'].'/'.$term_data['image']), $cat_posttype);
4259 4259
                                     }
4260 4260
                                 }
4261 4261
                                 
4262
-                                if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
4263
-                                    $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype );
4264
-                                    $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : '';
4262
+                                if (isset($term_data['icon']) && $term_data['icon'] != '') {
4263
+                                    $cat_icon = get_tax_meta($term_id, 'ct_cat_icon', false, $cat_posttype);
4264
+                                    $cat_icon = !empty($cat_icon) && isset($cat_icon['src']) ? $cat_icon['src'] : '';
4265 4265
                                         
4266
-                                    if ( basename($cat_icon) != $term_data['icon'] ) {
4266
+                                    if (basename($cat_icon) != $term_data['icon']) {
4267 4267
                                         $attachment = true;
4268
-                                        update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype );
4268
+                                        update_tax_meta($term_id, 'ct_cat_icon', array('id' => 'icon', 'src' => $uploads['url'].'/'.$term_data['icon']), $cat_posttype);
4269 4269
                                     }
4270 4270
                                 }
4271 4271
                                 
4272
-                                if ( $attachment ) {
4272
+                                if ($attachment) {
4273 4273
                                     $images++;
4274 4274
                                 }
4275 4275
                             }
@@ -4291,13 +4291,13 @@  discard block
 block discarded – undo
4291 4291
                 $json['invalid'] = $invalid;
4292 4292
                 $json['images'] = $images;
4293 4293
                 
4294
-                wp_send_json( $json );
4294
+                wp_send_json($json);
4295 4295
                 exit;
4296
-            } else if ( $task == 'import_post' ) {
4296
+            } else if ($task == 'import_post') {
4297 4297
                 //run some stuff to make the import quicker
4298
-                wp_defer_term_counting( true );
4299
-                wp_defer_comment_counting( true );
4300
-                $wpdb->query( 'SET autocommit = 0;' );
4298
+                wp_defer_term_counting(true);
4299
+                wp_defer_comment_counting(true);
4300
+                $wpdb->query('SET autocommit = 0;');
4301 4301
 
4302 4302
                 //remove_all_actions('publish_post');
4303 4303
                 //remove_all_actions('transition_post_status');
@@ -4306,18 +4306,18 @@  discard block
 block discarded – undo
4306 4306
                 if (!empty($file)) {
4307 4307
                     $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
4308 4308
                     $default_status = 'publish';
4309
-                    $current_date = date_i18n( 'Y-m-d', time() );
4309
+                    $current_date = date_i18n('Y-m-d', time());
4310 4310
                     
4311 4311
                     $columns = isset($file[0]) ? $file[0] : NULL;
4312 4312
                     
4313 4313
                     if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4314 4314
                         $json['error'] = CSV_INVAILD_FILE;
4315
-                        wp_send_json( $json );
4315
+                        wp_send_json($json);
4316 4316
                         exit;
4317 4317
                     }
4318 4318
 
4319 4319
                     $gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory');
4320
-                    $wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' );
4320
+                    $wp_chars_error = __('(check & remove if any invalid characters used in data)', 'geodirectory');
4321 4321
                     $processed_actual = 0;
4322 4322
                     for ($i = 1; $i <= $limit; $i++) {
4323 4323
                         $index = $processed + $i;
@@ -4326,9 +4326,9 @@  discard block
 block discarded – undo
4326 4326
                         if (isset($file[$index])) {
4327 4327
                             $processed_actual++;
4328 4328
                             $row = $file[$index];
4329
-                            $row = array_map( 'trim', $row );
4329
+                            $row = array_map('trim', $row);
4330 4330
                             //$row = array_map( 'utf8_encode', $row );
4331
-                            $row = array_map( 'addslashes_gpc', $row );
4331
+                            $row = array_map('addslashes_gpc', $row);
4332 4332
                             
4333 4333
                             $post_id = '';
4334 4334
                             $post_title = '';
@@ -4365,78 +4365,78 @@  discard block
 block discarded – undo
4365 4365
                             $original_post_id = '';
4366 4366
                                                         
4367 4367
                             $c = 0;
4368
-                            foreach ($columns as $column ) {
4368
+                            foreach ($columns as $column) {
4369 4369
                                 $gd_post[$column] = $row[$c];
4370 4370
                                 
4371
-                                if ( $column == 'post_id' ) {
4371
+                                if ($column == 'post_id') {
4372 4372
                                     $post_id = $row[$c];
4373
-                                } else if ( $column == 'post_title' ) {
4373
+                                } else if ($column == 'post_title') {
4374 4374
                                     $post_title = sanitize_text_field($row[$c]);
4375
-                                } else if ( $column == 'post_author' ) {
4375
+                                } else if ($column == 'post_author') {
4376 4376
                                     $post_author = $row[$c];
4377
-                                } else if ( $column == 'post_content' ) {
4377
+                                } else if ($column == 'post_content') {
4378 4378
                                     $post_content = $row[$c];
4379
-                                } else if ( $column == 'post_category' && $row[$c] != '' ) {
4380
-                                    $post_category_arr = explode( ',', $row[$c] );
4381
-                                } else if ( $column == 'default_category' ) {
4379
+                                } else if ($column == 'post_category' && $row[$c] != '') {
4380
+                                    $post_category_arr = explode(',', $row[$c]);
4381
+                                } else if ($column == 'default_category') {
4382 4382
                                     $default_category = wp_kses_normalize_entities($row[$c]);
4383
-                                } else if ( $column == 'post_tags' && $row[$c] != '' ) {
4384
-                                    $post_tags = explode( ',', sanitize_text_field($row[$c]) );
4385
-                                } else if ( $column == 'post_type' ) {
4383
+                                } else if ($column == 'post_tags' && $row[$c] != '') {
4384
+                                    $post_tags = explode(',', sanitize_text_field($row[$c]));
4385
+                                } else if ($column == 'post_type') {
4386 4386
                                     $post_type = $row[$c];
4387
-                                } else if ( $column == 'post_status' ) {
4388
-                                    $post_status = sanitize_key( $row[$c] );
4389
-                                } else if ( $column == 'is_featured' ) {
4390
-                                    $is_featured = (int)$row[$c];
4391
-                                } else if ( $column == 'geodir_video' ) {
4387
+                                } else if ($column == 'post_status') {
4388
+                                    $post_status = sanitize_key($row[$c]);
4389
+                                } else if ($column == 'is_featured') {
4390
+                                    $is_featured = (int) $row[$c];
4391
+                                } else if ($column == 'geodir_video') {
4392 4392
                                     $geodir_video = $row[$c];
4393
-                                } else if ( $column == 'post_address' ) {
4393
+                                } else if ($column == 'post_address') {
4394 4394
                                     $post_address = sanitize_text_field($row[$c]);
4395
-                                } else if ( $column == 'post_city' ) {
4395
+                                } else if ($column == 'post_city') {
4396 4396
                                     $post_city = sanitize_text_field($row[$c]);
4397
-                                } else if ( $column == 'post_region' ) {
4397
+                                } else if ($column == 'post_region') {
4398 4398
                                     $post_region = sanitize_text_field($row[$c]);
4399
-                                } else if ( $column == 'post_country' ) {
4399
+                                } else if ($column == 'post_country') {
4400 4400
                                     $post_country = sanitize_text_field($row[$c]);
4401
-                                } else if ( $column == 'post_zip' ) {
4401
+                                } else if ($column == 'post_zip') {
4402 4402
                                     $post_zip = sanitize_text_field($row[$c]);
4403
-                                } else if ( $column == 'post_latitude' ) {
4403
+                                } else if ($column == 'post_latitude') {
4404 4404
                                     $post_latitude = sanitize_text_field($row[$c]);
4405
-                                } else if ( $column == 'post_longitude' ) {
4405
+                                } else if ($column == 'post_longitude') {
4406 4406
                                     $post_longitude = sanitize_text_field($row[$c]);
4407
-                                } else if ( $column == 'post_neighbourhood' ) {
4407
+                                } else if ($column == 'post_neighbourhood') {
4408 4408
                                     $post_neighbourhood = sanitize_text_field($row[$c]);
4409 4409
                                     unset($gd_post[$column]);
4410
-                                } else if ( $column == 'neighbourhood_latitude' ) {
4410
+                                } else if ($column == 'neighbourhood_latitude') {
4411 4411
                                     $neighbourhood_latitude = sanitize_text_field($row[$c]);
4412
-                                } else if ( $column == 'neighbourhood_longitude' ) {
4412
+                                } else if ($column == 'neighbourhood_longitude') {
4413 4413
                                     $neighbourhood_longitude = sanitize_text_field($row[$c]);
4414
-                                } else if ( $column == 'geodir_timing' ) {
4414
+                                } else if ($column == 'geodir_timing') {
4415 4415
                                     $geodir_timing = sanitize_text_field($row[$c]);
4416
-                                } else if ( $column == 'geodir_contact' ) {
4416
+                                } else if ($column == 'geodir_contact') {
4417 4417
                                     $geodir_contact = sanitize_text_field($row[$c]);
4418
-                                } else if ( $column == 'geodir_email' ) {
4418
+                                } else if ($column == 'geodir_email') {
4419 4419
                                     $geodir_email = sanitize_email($row[$c]);
4420
-                                } else if ( $column == 'geodir_website' ) {
4420
+                                } else if ($column == 'geodir_website') {
4421 4421
                                     $geodir_website = sanitize_text_field($row[$c]);
4422
-                                } else if ( $column == 'geodir_twitter' ) {
4422
+                                } else if ($column == 'geodir_twitter') {
4423 4423
                                     $geodir_twitter = sanitize_text_field($row[$c]);
4424
-                                } else if ( $column == 'geodir_facebook' ) {
4424
+                                } else if ($column == 'geodir_facebook') {
4425 4425
                                     $geodir_facebook = sanitize_text_field($row[$c]);
4426
-                                } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
4426
+                                } else if ($column == 'IMAGE' && !empty($row[$c]) && $row[$c] != '') {
4427 4427
                                     $post_images[] = $row[$c];
4428
-                                } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
4429
-                                    $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) );
4430
-                                } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
4428
+                                } else if ($column == 'alive_days' && (int) $row[$c] > 0) {
4429
+                                    $expire_date = date_i18n('Y-m-d', strtotime($current_date.'+'.(int) $row[$c].' days'));
4430
+                                } else if ($column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never') {
4431 4431
                                     $row[$c] = str_replace('/', '-', $row[$c]);
4432
-                                    $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) );
4432
+                                    $expire_date = date_i18n('Y-m-d', strtotime($row[$c]));
4433 4433
                                 }
4434 4434
                                 // WPML
4435 4435
                                 if ($is_wpml) {
4436 4436
                                     if ($column == 'language') {
4437 4437
                                         $language = geodir_strtolower(trim($row[$c]));
4438 4438
                                     } else if ($column == 'original_post_id') {
4439
-                                        $original_post_id = (int)$row[$c];
4439
+                                        $original_post_id = (int) $row[$c];
4440 4440
                                     }
4441 4441
                                 }
4442 4442
                                 // WPML
@@ -4451,43 +4451,43 @@  discard block
 block discarded – undo
4451 4451
 
4452 4452
                             $gd_post['IMAGE'] = $post_images;
4453 4453
                             
4454
-                            $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
4455
-                            $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
4454
+                            $post_status = !empty($post_status) ? sanitize_key($post_status) : $default_status;
4455
+                            $post_status = !empty($wp_post_statuses) && !isset($wp_post_statuses[$post_status]) ? $default_status : $post_status;
4456 4456
                                                                                                                 
4457 4457
                             $valid = true;
4458 4458
                             
4459
-                            if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
4459
+                            if ($post_title == '' || !in_array($post_type, $post_types)) {
4460 4460
                                 $invalid++;
4461 4461
                                 $valid = false;
4462
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) );
4462
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be added due to blank title/invalid post type', 'geodirectory'));
4463 4463
                             }
4464 4464
                             
4465
-                            $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
4466
-                            if ( $location_allowed ) {
4465
+                            $location_allowed = function_exists('geodir_cpt_no_location') && geodir_cpt_no_location($post_type) ? false : true;
4466
+                            if ($location_allowed) {
4467 4467
                                 $location_result = geodir_get_default_location();
4468
-                                if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
4468
+                                if ($post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '') {
4469 4469
                                     $invalid_addr++;
4470 4470
                                     $valid = false;
4471
-                                    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' ) );
4472
-                                } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
4473
-                                    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 ) ) ) {
4471
+                                    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'));
4472
+                                } else if (!empty($location_result) && $location_result->location_id == 0) {
4473
+                                    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))) {
4474 4474
                                         $invalid_addr++;
4475 4475
                                         $valid = false;
4476
-                                        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' ) );
4476
+                                        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'));
4477 4477
                                     } else {
4478 4478
                                         if (!$location_manager) {
4479
-                                            $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.
4479
+                                            $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.
4480 4480
                                         }
4481 4481
                                     }
4482 4482
                                 }
4483 4483
                             }
4484 4484
                             
4485
-                            if ( !$valid ) {
4485
+                            if (!$valid) {
4486 4486
                                 continue;
4487 4487
                             }
4488 4488
 
4489
-                            $cat_taxonomy = $post_type . 'category';
4490
-                            $tags_taxonomy = $post_type . '_tags';
4489
+                            $cat_taxonomy = $post_type.'category';
4490
+                            $tags_taxonomy = $post_type.'_tags';
4491 4491
                             
4492 4492
                             if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
4493 4493
                                 $post_category_arr = array_merge(array($default_category), $post_category_arr);
@@ -4495,29 +4495,29 @@  discard block
 block discarded – undo
4495 4495
 
4496 4496
                             $post_category = array();
4497 4497
                             $default_category_id = NULL;
4498
-                            if ( !empty( $post_category_arr ) ) {
4499
-                                foreach ( $post_category_arr as $value ) {
4500
-                                    $category_name = wp_kses_normalize_entities( trim( $value ) );
4498
+                            if (!empty($post_category_arr)) {
4499
+                                foreach ($post_category_arr as $value) {
4500
+                                    $category_name = wp_kses_normalize_entities(trim($value));
4501 4501
                                     
4502
-                                    if ( $category_name != '' ) {
4502
+                                    if ($category_name != '') {
4503 4503
                                         $term_category = array();
4504 4504
                                         
4505
-                                        if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
4505
+                                        if ($term = get_term_by('name', $category_name, $cat_taxonomy)) {
4506 4506
                                             $term_category = $term;
4507
-                                        } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
4507
+                                        } else if ($term = get_term_by('slug', $category_name, $cat_taxonomy)) {
4508 4508
                                             $term_category = $term;
4509 4509
                                         } else {
4510 4510
                                             $term_data = array();
4511 4511
                                             $term_data['name'] = $category_name;
4512 4512
                                             $term_data['taxonomy'] = $cat_taxonomy;
4513 4513
                                             
4514
-                                            $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data );
4515
-                                            if ( $term_id ) {
4516
-                                                $term_category = get_term( $term_id, $cat_taxonomy );
4514
+                                            $term_id = geodir_imex_insert_term($cat_taxonomy, $term_data);
4515
+                                            if ($term_id) {
4516
+                                                $term_category = get_term($term_id, $cat_taxonomy);
4517 4517
                                             }
4518 4518
                                         }
4519 4519
                                         
4520
-                                        if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
4520
+                                        if (!empty($term_category) && !is_wp_error($term_category)) {
4521 4521
                                             $post_category[] = intval($term_category->term_id);
4522 4522
                                             
4523 4523
                                             if ($category_name == $default_category) {
@@ -4538,15 +4538,15 @@  discard block
 block discarded – undo
4538 4538
                             $save_post['post_tags'] = $post_tags;
4539 4539
 
4540 4540
                             $saved_post_id = NULL;
4541
-                            if ( $import_choice == 'update' ) {
4542
-                                $gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' );
4541
+                            if ($import_choice == 'update') {
4542
+                                $gd_wp_error = __('Unable to add listing, please check the listing data.', 'geodirectory');
4543 4543
                                 
4544
-                                if ( $post_id > 0 && get_post( $post_id ) ) {
4544
+                                if ($post_id > 0 && get_post($post_id)) {
4545 4545
                                     $save_post['ID'] = $post_id;
4546 4546
                                     
4547
-                                    if ( $saved_post_id = wp_update_post( $save_post, true ) ) {
4548
-                                        if ( is_wp_error( $saved_post_id ) ) {
4549
-                                            $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4547
+                                    if ($saved_post_id = wp_update_post($save_post, true)) {
4548
+                                        if (is_wp_error($saved_post_id)) {
4549
+                                            $gd_wp_error = $saved_post_id->get_error_message().' '.$wp_chars_error;
4550 4550
                                             $saved_post_id = 0;
4551 4551
                                         } else {
4552 4552
                                             $saved_post_id = $post_id;
@@ -4554,9 +4554,9 @@  discard block
 block discarded – undo
4554 4554
                                         }
4555 4555
                                     }
4556 4556
                                 } else {
4557
-                                    if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4558
-                                        if ( is_wp_error( $saved_post_id ) ) {
4559
-                                            $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error;
4557
+                                    if ($saved_post_id = wp_insert_post($save_post, true)) {
4558
+                                        if (is_wp_error($saved_post_id)) {
4559
+                                            $gd_wp_error = $saved_post_id->get_error_message().' '.$wp_chars_error;
4560 4560
                                             $saved_post_id = 0;
4561 4561
                                         } else {
4562 4562
                                             $created++;
@@ -4564,19 +4564,19 @@  discard block
 block discarded – undo
4564 4564
                                     }
4565 4565
                                 }
4566 4566
                                 
4567
-                                if ( !$saved_post_id > 0 ) {
4567
+                                if (!$saved_post_id > 0) {
4568 4568
                                     $invalid++;
4569
-                                    geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error );
4569
+                                    geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_wp_error);
4570 4570
                                 }
4571
-                            } else if ( $import_choice == 'skip' ) {
4572
-                                if ( $post_id > 0 && get_post( $post_id ) ) {
4571
+                            } else if ($import_choice == 'skip') {
4572
+                                if ($post_id > 0 && get_post($post_id)) {
4573 4573
                                     $skipped++;	
4574 4574
                                 } else {
4575
-                                    if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
4576
-                                        if ( is_wp_error( $saved_post_id ) ) {
4575
+                                    if ($saved_post_id = wp_insert_post($save_post, true)) {
4576
+                                        if (is_wp_error($saved_post_id)) {
4577 4577
                                             $invalid++;
4578 4578
                                             
4579
-                                            geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error );
4579
+                                            geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$saved_post_id->get_error_message().' '.$wp_chars_error);
4580 4580
                                             $saved_post_id = 0;
4581 4581
                                         } else {
4582 4582
                                             $created++;
@@ -4584,28 +4584,28 @@  discard block
 block discarded – undo
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 4590
                             } else {
4591 4591
                                 $invalid++;
4592 4592
                                 
4593
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error );
4593
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$wp_chars_error);
4594 4594
                             }
4595 4595
 
4596
-                            if ( (int)$saved_post_id > 0 ) {
4596
+                            if ((int) $saved_post_id > 0) {
4597 4597
                                 // WPML
4598 4598
                                 if ($is_wpml && $original_post_id > 0 && $language != '') {
4599
-                                    $wpml_post_type = 'post_' . $post_type;
4600
-                                    $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type );
4599
+                                    $wpml_post_type = 'post_'.$post_type;
4600
+                                    $source_language = geodir_get_language_for_element($original_post_id, $wpml_post_type);
4601 4601
                                     $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language();
4602 4602
 
4603
-                                    $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type );
4603
+                                    $trid = $sitepress->get_element_trid($original_post_id, $wpml_post_type);
4604 4604
                                     
4605
-                                    $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language );
4605
+                                    $sitepress->set_element_language_details($saved_post_id, $wpml_post_type, $trid, $language, $source_language);
4606 4606
                                 }
4607 4607
                                 // WPML
4608
-                                $gd_post_info = geodir_get_post_info( $saved_post_id );
4608
+                                $gd_post_info = geodir_get_post_info($saved_post_id);
4609 4609
                                 
4610 4610
                                 $gd_post['post_id'] = $saved_post_id;
4611 4611
                                 $gd_post['ID'] = $saved_post_id;
@@ -4617,7 +4617,7 @@  discard block
 block discarded – undo
4617 4617
                                                     
4618 4618
                                 // post location
4619 4619
                                 $post_location_id = 0;
4620
-                                if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
4620
+                                if ($location_allowed && !empty($location_result) && $location_result->location_id > 0) {
4621 4621
                                     $gd_post['post_neighbourhood'] = '';
4622 4622
                                     
4623 4623
                                     $post_location_info = array(
@@ -4627,7 +4627,7 @@  discard block
 block discarded – undo
4627 4627
                                                                 'geo_lat' => $post_latitude,
4628 4628
                                                                 'geo_lng' => $post_longitude
4629 4629
                                                             );
4630
-                                    if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
4630
+                                    if ($location_id = (int) geodir_add_new_location($post_location_info)) {
4631 4631
                                         $post_location_id = $location_id;
4632 4632
                                     }
4633 4633
                                     
@@ -4665,14 +4665,14 @@  discard block
 block discarded – undo
4665 4665
                                 $gd_post['post_location_id'] = $post_location_id;
4666 4666
                                 
4667 4667
                                 // post package info
4668
-                                $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0;
4668
+                                $package_id = isset($gd_post['package_id']) && !empty($gd_post['package_id']) ? (int) $gd_post['package_id'] : 0;
4669 4669
                                 if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
4670 4670
                                     $package_id = $gd_post_info->package_id;
4671 4671
                                 }
4672 4672
                                 
4673 4673
                                 $package_info = array();
4674 4674
                                 if ($package_id && function_exists('geodir_get_package_info_by_id')) {
4675
-                                    $package_info = (array)geodir_get_package_info_by_id($package_id);
4675
+                                    $package_info = (array) geodir_get_package_info_by_id($package_id);
4676 4676
                                     
4677 4677
                                     if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
4678 4678
                                         $package_info = array();
@@ -4680,18 +4680,18 @@  discard block
 block discarded – undo
4680 4680
                                 }
4681 4681
                                 
4682 4682
                                 if (empty($package_info)) {
4683
-                                    $package_info = (array)geodir_post_package_info( array(), '', $post_type );
4683
+                                    $package_info = (array) geodir_post_package_info(array(), '', $post_type);
4684 4684
                                 }
4685 4685
                                  
4686
-                                if (!empty($package_info))	 {
4686
+                                if (!empty($package_info)) {
4687 4687
                                     $package_id = $package_info['pid'];
4688 4688
                                     
4689 4689
                                     if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
4690 4690
                                         $gd_post['expire_date'] = $expire_date;
4691 4691
                                     } else {
4692
-                                        if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
4693
-                                            $gd_post['alive_days'] = (int)$package_info['days'];
4694
-                                            $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) );
4692
+                                        if (isset($package_info['days']) && (int) $package_info['days'] > 0) {
4693
+                                            $gd_post['alive_days'] = (int) $package_info['days'];
4694
+                                            $gd_post['expire_date'] = date_i18n('Y-m-d', strtotime($current_date.'+'.(int) $package_info['days'].' days'));
4695 4695
                                         } else {
4696 4696
                                             $gd_post['expire_date'] = 'Never';
4697 4697
                                         }
@@ -4700,7 +4700,7 @@  discard block
 block discarded – undo
4700 4700
                                     $gd_post['package_id'] = $package_id;
4701 4701
                                 }
4702 4702
 
4703
-                                $table = $plugin_prefix . $post_type . '_detail';
4703
+                                $table = $plugin_prefix.$post_type.'_detail';
4704 4704
                                 
4705 4705
                                 if ($post_type == 'gd_event') {
4706 4706
                                     $gd_post = geodir_imex_process_event_data($gd_post);
@@ -4711,28 +4711,28 @@  discard block
 block discarded – undo
4711 4711
                                 }
4712 4712
 
4713 4713
                                 // Export franchise fields
4714
-                                $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false;
4714
+                                $is_franchise_active = is_plugin_active('geodir_franchise/geodir_franchise.php') && geodir_franchise_enabled($post_type) ? true : false;
4715 4715
                                 if ($is_franchise_active) {
4716
-                                    if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
4716
+                                    if (isset($gd_post['gd_is_franchise']) && (int) $gd_post['gd_is_franchise'] == 1) {
4717 4717
                                         $gd_franchise_lock = array();
4718 4718
                                         
4719
-                                        if ( isset( $gd_post['gd_franchise_lock'] ) ) {
4720
-                                            $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
4721
-                                            $gd_franchise_lock = trim( $gd_franchise_lock );
4722
-                                            $gd_franchise_lock = explode( ",", $gd_franchise_lock );
4719
+                                        if (isset($gd_post['gd_franchise_lock'])) {
4720
+                                            $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock']);
4721
+                                            $gd_franchise_lock = trim($gd_franchise_lock);
4722
+                                            $gd_franchise_lock = explode(",", $gd_franchise_lock);
4723 4723
                                         }
4724 4724
                                         
4725
-                                        update_post_meta( $saved_post_id, 'gd_is_franchise', 1 );
4726
-                                        update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock );
4725
+                                        update_post_meta($saved_post_id, 'gd_is_franchise', 1);
4726
+                                        update_post_meta($saved_post_id, 'gd_franchise_lock', $gd_franchise_lock);
4727 4727
                                     } else {
4728
-                                        if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
4729
-                                            geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] );
4728
+                                        if (isset($gd_post['franchise']) && (int) $gd_post['franchise'] > 0 && geodir_franchise_check((int) $gd_post['franchise'])) {
4729
+                                            geodir_save_post_meta($saved_post_id, 'franchise', (int) $gd_post['franchise']);
4730 4730
                                         }
4731 4731
                                     }
4732 4732
                                 }
4733 4733
                                 
4734 4734
                                 if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
4735
-                                    $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) );
4735
+                                    $save_post['post_category'] = array_unique(array_map('intval', $save_post['post_category']));
4736 4736
                                     if ($default_category_id) {
4737 4737
                                         $save_post['post_default_category'] = $default_category_id;
4738 4738
                                         $gd_post['default_category'] = $default_category_id;
@@ -4741,34 +4741,34 @@  discard block
 block discarded – undo
4741 4741
                                 }
4742 4742
                                 
4743 4743
                                 // Save post info
4744
-                                geodir_save_post_info( $saved_post_id, $gd_post );
4744
+                                geodir_save_post_info($saved_post_id, $gd_post);
4745 4745
                                 // post taxonomies
4746
-                                if ( !empty( $save_post['post_category'] ) ) {
4747
-                                    wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy );
4746
+                                if (!empty($save_post['post_category'])) {
4747
+                                    wp_set_object_terms($saved_post_id, $save_post['post_category'], $cat_taxonomy);
4748 4748
                                     
4749
-                                    $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : '';
4749
+                                    $post_default_category = isset($save_post['post_default_category']) ? $save_post['post_default_category'] : '';
4750 4750
                                     if ($default_category_id) {
4751 4751
                                         $post_default_category = $default_category_id;
4752 4752
                                     }
4753 4753
                                     $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy);
4754 4754
                                     $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
4755
-                                    $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
4755
+                                    $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']).',y:' : '';
4756 4756
                                     
4757 4757
                                     if ($post_category_str != '' && $post_default_category) {
4758
-                                        $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str);
4758
+                                        $post_category_str = str_replace($post_default_category.',y:', $post_default_category.',y,d:', $post_category_str);
4759 4759
                                     }
4760 4760
                                     
4761 4761
                                     $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : '';
4762 4762
                                     
4763
-                                    geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str );
4763
+                                    geodir_set_postcat_structure($saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str);
4764 4764
                                 }
4765 4765
 
4766
-                                if ( !empty( $save_post['post_tags'] ) ) {
4767
-                                    wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy );
4766
+                                if (!empty($save_post['post_tags'])) {
4767
+                                    wp_set_object_terms($saved_post_id, $save_post['post_tags'], $tags_taxonomy);
4768 4768
                                 }
4769 4769
 
4770 4770
                                 // Post images
4771
-                                if ( !empty( $post_images ) ) {
4771
+                                if (!empty($post_images)) {
4772 4772
                                     $post_images = array_unique($post_images);
4773 4773
                                     
4774 4774
                                     $old_post_images_arr = array();
@@ -4776,82 +4776,82 @@  discard block
 block discarded – undo
4776 4776
                                     
4777 4777
                                     $order = 1;
4778 4778
                                     
4779
-                                    $old_post_images = geodir_get_images( $saved_post_id );
4779
+                                    $old_post_images = geodir_get_images($saved_post_id);
4780 4780
                                     if (!empty($old_post_images)) {
4781
-                                        foreach( $old_post_images as $old_post_image ) {
4781
+                                        foreach ($old_post_images as $old_post_image) {
4782 4782
                                             if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
4783 4783
                                                 $old_post_images_arr[] = $old_post_image->file;
4784 4784
                                             }
4785 4785
                                         }
4786 4786
                                     }
4787 4787
                                     
4788
-                                    foreach ( $post_images as $post_image ) {
4789
-                                        $image_name = basename( $post_image );
4788
+                                    foreach ($post_images as $post_image) {
4789
+                                        $image_name = basename($post_image);
4790 4790
                                         $saved_post_images_arr[] = $image_name;
4791 4791
                                         
4792
-                                        if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
4792
+                                        if (!empty($old_post_images_arr) && in_array($image_name, $old_post_images_arr)) {
4793 4793
                                             continue; // Skip if image already exists.
4794 4794
                                         }
4795 4795
                                         
4796
-                                        $image_name_parts = explode( '.', $image_name );
4797
-                                        array_pop( $image_name_parts );
4798
-                                        $proper_image_name = implode( '.', $image_name_parts );
4796
+                                        $image_name_parts = explode('.', $image_name);
4797
+                                        array_pop($image_name_parts);
4798
+                                        $proper_image_name = implode('.', $image_name_parts);
4799 4799
                                         
4800
-                                        $arr_file_type = wp_check_filetype( $image_name );
4800
+                                        $arr_file_type = wp_check_filetype($image_name);
4801 4801
                                         
4802
-                                        if ( !empty( $arr_file_type ) ) {
4802
+                                        if (!empty($arr_file_type)) {
4803 4803
                                             $uploaded_file_type = $arr_file_type['type'];
4804 4804
                                             
4805 4805
                                             $attachment = array();
4806 4806
                                             $attachment['post_id'] = $saved_post_id;
4807 4807
                                             $attachment['title'] = $proper_image_name;
4808 4808
                                             $attachment['content'] = '';
4809
-                                            $attachment['file'] = $uploads_subdir . '/' . $image_name;
4809
+                                            $attachment['file'] = $uploads_subdir.'/'.$image_name;
4810 4810
                                             $attachment['mime_type'] = $uploaded_file_type;
4811 4811
                                             $attachment['menu_order'] = $order;
4812 4812
                                             $attachment['is_featured'] = 0;
4813 4813
 
4814 4814
                                             $attachment_set = '';
4815
-                                            foreach ( $attachment as $key => $val ) {
4816
-                                                if ( $val != '' ) {
4817
-                                                    $attachment_set .= $key . " = '" . $val . "', ";
4815
+                                            foreach ($attachment as $key => $val) {
4816
+                                                if ($val != '') {
4817
+                                                    $attachment_set .= $key." = '".$val."', ";
4818 4818
                                                 }
4819 4819
                                             }
4820
-                                            $attachment_set = trim( $attachment_set, ", " );
4820
+                                            $attachment_set = trim($attachment_set, ", ");
4821 4821
                                                                                         
4822 4822
                                             // Add new attachment
4823
-                                            $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set );
4823
+                                            $wpdb->query("INSERT INTO ".GEODIR_ATTACHMENT_TABLE." SET ".$attachment_set);
4824 4824
                                                                                         
4825 4825
                                             $order++;
4826 4826
                                         }
4827 4827
                                     }
4828 4828
 
4829
-                                    $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/",  $saved_post_images_arr) . "' )" : '';
4829
+                                    $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/".implode("' AND file NOT LIKE '%/", $saved_post_images_arr)."' )" : '';
4830 4830
                                     // Remove previous attachment
4831
-                                    $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql );
4831
+                                    $wpdb->query("DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE post_id = ".(int) $saved_post_id." ".$saved_post_images_sql);
4832 4832
                                     
4833
-                                    if ( !empty( $saved_post_images_arr ) ) {
4833
+                                    if (!empty($saved_post_images_arr)) {
4834 4834
                                         $menu_order = 1;
4835 4835
                                         
4836
-                                        foreach ( $saved_post_images_arr as $img_name ) {
4837
-                                            $wpdb->query( $wpdb->prepare( "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d WHERE post_id =%d AND file LIKE %s", array( $menu_order, $saved_post_id, '%/' . $img_name ) ) );
4836
+                                        foreach ($saved_post_images_arr as $img_name) {
4837
+                                            $wpdb->query($wpdb->prepare("UPDATE ".GEODIR_ATTACHMENT_TABLE." SET menu_order = %d WHERE post_id =%d AND file LIKE %s", array($menu_order, $saved_post_id, '%/'.$img_name)));
4838 4838
                                             
4839
-                                            if( $menu_order == 1 ) {
4840
-                                                if ( $featured_image = $wpdb->get_var( $wpdb->prepare( "SELECT file FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =%d AND file LIKE %s", array( $saved_post_id, '%/' . $img_name ) ) ) ) {
4841
-                                                    $wpdb->query( $wpdb->prepare( "UPDATE " . $table . " SET featured_image = %s WHERE post_id =%d", array( $featured_image, $saved_post_id ) ) );
4839
+                                            if ($menu_order == 1) {
4840
+                                                if ($featured_image = $wpdb->get_var($wpdb->prepare("SELECT file FROM ".GEODIR_ATTACHMENT_TABLE." WHERE post_id =%d AND file LIKE %s", array($saved_post_id, '%/'.$img_name)))) {
4841
+                                                    $wpdb->query($wpdb->prepare("UPDATE ".$table." SET featured_image = %s WHERE post_id =%d", array($featured_image, $saved_post_id)));
4842 4842
                                                 }
4843 4843
                                             }
4844 4844
                                             $menu_order++;
4845 4845
                                         }
4846 4846
                                     }
4847 4847
                                     
4848
-                                    if ( $order > 1 ) {
4848
+                                    if ($order > 1) {
4849 4849
                                         $images++;
4850 4850
                                     }
4851 4851
                                 }
4852 4852
 
4853 4853
                                 /** This action is documented in geodirectory-functions/post-functions.php */
4854
-                                do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post );
4854
+                                do_action('geodir_after_save_listing', $saved_post_id, $gd_post);
4855 4855
                                 
4856 4856
                                 if (isset($is_featured)) {
4857 4857
                                     geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured);
@@ -4871,10 +4871,10 @@  discard block
 block discarded – undo
4871 4871
                 }
4872 4872
 
4873 4873
                 //undo some stuff to make the import quicker
4874
-                wp_defer_term_counting( false );
4875
-                wp_defer_comment_counting( false );
4876
-                $wpdb->query( 'COMMIT;' );
4877
-                $wpdb->query( 'SET autocommit = 1;' );
4874
+                wp_defer_term_counting(false);
4875
+                wp_defer_comment_counting(false);
4876
+                $wpdb->query('COMMIT;');
4877
+                $wpdb->query('SET autocommit = 1;');
4878 4878
 
4879 4879
                 $json = array();
4880 4880
                 $json['processed'] = $processed_actual;
@@ -4885,9 +4885,9 @@  discard block
 block discarded – undo
4885 4885
                 $json['invalid_addr'] = $invalid_addr;
4886 4886
                 $json['images'] = $images;
4887 4887
                 
4888
-                wp_send_json( $json );
4888
+                wp_send_json($json);
4889 4889
                 exit;
4890
-            } else if ( $task == 'import_loc' ) {
4890
+            } else if ($task == 'import_loc') {
4891 4891
                 global $gd_post_types;
4892 4892
                 $gd_post_types = $post_types;
4893 4893
                 
@@ -4896,82 +4896,82 @@  discard block
 block discarded – undo
4896 4896
                     
4897 4897
                     if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4898 4898
                         $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4899
-                        wp_send_json( $json );
4899
+                        wp_send_json($json);
4900 4900
                     }
4901 4901
                     
4902 4902
                     $gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory');
4903
-                    $gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' );
4903
+                    $gd_error_location = __('Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory');
4904 4904
                     for ($i = 1; $i <= $limit; $i++) {
4905 4905
                         $index = $processed + $i;
4906 4906
                         
4907 4907
                         if (isset($file[$index])) {
4908 4908
                             $row = $file[$index];
4909
-                            $row = array_map( 'trim', $row );
4909
+                            $row = array_map('trim', $row);
4910 4910
                             $data = array();
4911 4911
                             
4912
-                            foreach ($columns as $c => $column ) {
4912
+                            foreach ($columns as $c => $column) {
4913 4913
                                 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'))) {
4914 4914
                                     $data[$column] = $row[$c];
4915 4915
                                 }
4916 4916
                             }
4917 4917
 
4918
-                            if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
4918
+                            if (empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude'])) {
4919 4919
                                 $invalid++;
4920
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4920
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location);
4921 4921
                                 continue;
4922 4922
                             }
4923 4923
                             
4924 4924
                             $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0;
4925 4925
                             
4926
-                            if ( $import_choice == 'update' ) {
4927
-                                if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4928
-                                    if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4926
+                            if ($import_choice == 'update') {
4927
+                                if ((int) $data['location_id'] > 0 && $location = geodir_get_location_by_id('', (int) $data['location_id'])) {
4928
+                                    if ($location_id = geodir_location_update_city($data, true, $location)) {
4929 4929
                                         $updated++;
4930 4930
                                     } else {
4931 4931
                                         $invalid++;
4932
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4932
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location);
4933 4933
                                     }
4934
-                                } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4935
-                                    $data['location_id'] = (int)$location->location_id;
4934
+                                } else if (!empty($data['city_slug']) && $location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug']))) {
4935
+                                    $data['location_id'] = (int) $location->location_id;
4936 4936
                                     
4937
-                                    if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
4938
-                                        $data['location_id'] = (int)$location->location_id;
4939
-                                    } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
4940
-                                        $data['location_id'] = (int)$location->location_id;
4941
-                                    } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
4942
-                                        $data['location_id'] = (int)$location->location_id;
4937
+                                    if ($location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region']))) {
4938
+                                        $data['location_id'] = (int) $location->location_id;
4939
+                                    } else if ($location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug'], 'region' => $data['region']))) {
4940
+                                        $data['location_id'] = (int) $location->location_id;
4941
+                                    } else if ($location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug'], 'country' => $data['country']))) {
4942
+                                        $data['location_id'] = (int) $location->location_id;
4943 4943
                                     }
4944 4944
                                     
4945
-                                    if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
4945
+                                    if ($location_id = geodir_location_update_city($data, true, $location)) {
4946 4946
                                         $updated++;
4947 4947
                                     } else {
4948 4948
                                         $invalid++;
4949
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4949
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location);
4950 4950
                                     }
4951 4951
                                 } else {
4952
-                                    if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4952
+                                    if ($location_id = geodir_location_insert_city($data, true)) {
4953 4953
                                         $created++;
4954 4954
                                     } else {
4955 4955
                                         $invalid++;
4956
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4956
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location);
4957 4957
                                     }
4958 4958
                                 }
4959
-                            } elseif ( $import_choice == 'skip' ) {
4960
-                                if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
4959
+                            } elseif ($import_choice == 'skip') {
4960
+                                if ((int) $data['location_id'] > 0 && $location = geodir_get_location_by_id('', (int) $data['location_id'])) {
4961 4961
                                     $skipped++;
4962
-                                } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
4962
+                                } else if (!empty($data['city_slug']) && $location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug']))) {
4963 4963
                                     $skipped++;
4964 4964
                                 } else {
4965
-                                    if ( $location_id = geodir_location_insert_city( $data, true ) ) {
4965
+                                    if ($location_id = geodir_location_insert_city($data, true)) {
4966 4966
                                         $created++;
4967 4967
                                     } else {
4968 4968
                                         $invalid++;
4969
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4969
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location);
4970 4970
                                     }
4971 4971
                                 }
4972 4972
                             } else {
4973 4973
                                 $invalid++;
4974
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location );
4974
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location);
4975 4975
                             }
4976 4976
                         }
4977 4977
                     }
@@ -4985,24 +4985,24 @@  discard block
 block discarded – undo
4985 4985
                 $json['invalid'] = $invalid;
4986 4986
                 $json['images'] = $images;
4987 4987
                 
4988
-                wp_send_json( $json );
4989
-            } else if ( $task == 'import_hood' ) {               
4988
+                wp_send_json($json);
4989
+            } else if ($task == 'import_hood') {               
4990 4990
                 if (!empty($file)) {
4991 4991
                     $columns = isset($file[0]) ? $file[0] : NULL;
4992 4992
                     
4993 4993
                     if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
4994 4994
                         $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
4995
-                        wp_send_json( $json );
4995
+                        wp_send_json($json);
4996 4996
                     }
4997 4997
                     
4998 4998
                     $gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory');
4999
-                    $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' );
4999
+                    $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');
5000 5000
                     for ($i = 1; $i <= $limit; $i++) {
5001 5001
                         $index = $processed + $i;
5002 5002
                         
5003 5003
                         if (isset($file[$index])) {
5004 5004
                             $row = $file[$index];
5005
-                            $row = array_map( 'trim', $row );
5005
+                            $row = array_map('trim', $row);
5006 5006
                             $data = array();
5007 5007
                             
5008 5008
                             foreach ($columns as $c => $column) {
@@ -5013,20 +5013,20 @@  discard block
 block discarded – undo
5013 5013
 
5014 5014
                             if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
5015 5015
                                 $invalid++;
5016
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5016
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood);
5017 5017
                                 continue;
5018 5018
                             }
5019 5019
                             
5020 5020
                             $location_info = array();
5021
-                            if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
5022
-                                $location_info = geodir_get_location_by_id('', (int)$data['location_id']);
5021
+                            if (!empty($data['location_id']) && (int) $data['location_id'] > 0) {
5022
+                                $location_info = geodir_get_location_by_id('', (int) $data['location_id']);
5023 5023
                             } else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
5024 5024
                                 $location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
5025 5025
                             }
5026 5026
 
5027 5027
                             if (empty($location_info)) {
5028 5028
                                 $invalid++;
5029
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5029
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood);
5030 5030
                                 continue;
5031 5031
                             }
5032 5032
                             
@@ -5041,35 +5041,35 @@  discard block
 block discarded – undo
5041 5041
                             $hood_data['hood_longitude'] = $data['longitude'];
5042 5042
                             $hood_data['hood_location_id'] = $location_id;
5043 5043
                                     
5044
-                            if ( $import_choice == 'update' ) {
5045
-                                if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
5046
-                                    $hood_data['hood_id'] = (int)$data['neighbourhood_id'];
5044
+                            if ($import_choice == 'update') {
5045
+                                if ((int) $data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int) $data['neighbourhood_id']))) {
5046
+                                    $hood_data['hood_id'] = (int) $data['neighbourhood_id'];
5047 5047
                                     
5048 5048
                                     if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5049 5049
                                         $updated++;
5050 5050
                                     } else {
5051 5051
                                         $invalid++;
5052
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5052
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood);
5053 5053
                                     }
5054 5054
                                 } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
5055
-                                    $hood_data['hood_id'] = (int)$neighbourhood->hood_id;
5055
+                                    $hood_data['hood_id'] = (int) $neighbourhood->hood_id;
5056 5056
                                     
5057 5057
                                     if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5058 5058
                                         $updated++;
5059 5059
                                     } else {
5060 5060
                                         $invalid++;
5061
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5061
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood);
5062 5062
                                     }
5063 5063
                                 } else {
5064 5064
                                     if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
5065 5065
                                         $created++;
5066 5066
                                     } else {
5067 5067
                                         $invalid++;
5068
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5068
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood);
5069 5069
                                     }
5070 5070
                                 }
5071
-                            } elseif ( $import_choice == 'skip' ) {
5072
-                                if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
5071
+                            } elseif ($import_choice == 'skip') {
5072
+                                if ((int) $data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int) $data['neighbourhood_id']))) {
5073 5073
                                     $skipped++;
5074 5074
                                 } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
5075 5075
                                     $skipped++;
@@ -5079,12 +5079,12 @@  discard block
 block discarded – undo
5079 5079
                                         $created++;
5080 5080
                                     } else {
5081 5081
                                         $invalid++;
5082
-                                        geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5082
+                                        geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood);
5083 5083
                                     }
5084 5084
                                 }
5085 5085
                             } else {
5086 5086
                                 $invalid++;
5087
-                                geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood );
5087
+                                geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood);
5088 5088
                             }
5089 5089
                         }
5090 5090
                     }
@@ -5098,7 +5098,7 @@  discard block
 block discarded – undo
5098 5098
                 $json['invalid'] = $invalid;
5099 5099
                 $json['images'] = $images;
5100 5100
                 
5101
-                wp_send_json( $json );
5101
+                wp_send_json($json);
5102 5102
             }
5103 5103
         }
5104 5104
         break;
@@ -5142,29 +5142,29 @@  discard block
 block discarded – undo
5142 5142
  * }
5143 5143
  * @return int|bool Term id when success, false when fail.
5144 5144
  */
5145
-function geodir_imex_insert_term( $taxonomy, $term_data ) {
5146
-	if ( empty( $taxonomy ) || empty( $term_data ) ) {
5145
+function geodir_imex_insert_term($taxonomy, $term_data) {
5146
+	if (empty($taxonomy) || empty($term_data)) {
5147 5147
 		return false;
5148 5148
 	}
5149 5149
 	
5150
-	$term = isset( $term_data['name'] ) && !empty( $term_data['name'] ) ? $term_data['name'] : '';
5150
+	$term = isset($term_data['name']) && !empty($term_data['name']) ? $term_data['name'] : '';
5151 5151
 	$args = array();
5152
-	$args['description'] = isset( $term_data['description'] ) ? $term_data['description'] : '';
5153
-	$args['slug'] = isset( $term_data['slug'] ) ? $term_data['slug'] : '';
5154
-	$args['parent'] = isset( $term_data['parent'] ) ? (int)$term_data['parent'] : '';
5152
+	$args['description'] = isset($term_data['description']) ? $term_data['description'] : '';
5153
+	$args['slug'] = isset($term_data['slug']) ? $term_data['slug'] : '';
5154
+	$args['parent'] = isset($term_data['parent']) ? (int) $term_data['parent'] : '';
5155 5155
 	
5156
-	if ( ( !empty( $args['slug'] ) && term_exists( $args['slug'], $taxonomy ) ) || empty( $args['slug'] ) ) {
5157
-		$term_args = array_merge( $term_data, $args );
5158
-		$defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
5159
-		$term_args = wp_parse_args( $term_args, $defaults );
5160
-		$term_args = sanitize_term( $term_args, $taxonomy, 'db' );
5161
-		$args['slug'] = wp_unique_term_slug( $args['slug'], (object)$term_args );
5156
+	if ((!empty($args['slug']) && term_exists($args['slug'], $taxonomy)) || empty($args['slug'])) {
5157
+		$term_args = array_merge($term_data, $args);
5158
+		$defaults = array('alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
5159
+		$term_args = wp_parse_args($term_args, $defaults);
5160
+		$term_args = sanitize_term($term_args, $taxonomy, 'db');
5161
+		$args['slug'] = wp_unique_term_slug($args['slug'], (object) $term_args);
5162 5162
 	}
5163 5163
 	
5164
-    if( !empty( $term ) ) {
5165
-		$result = wp_insert_term( $term, $taxonomy, $args );
5166
-        if( !is_wp_error( $result ) ) {
5167
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5164
+    if (!empty($term)) {
5165
+		$result = wp_insert_term($term, $taxonomy, $args);
5166
+        if (!is_wp_error($result)) {
5167
+            return isset($result['term_id']) ? $result['term_id'] : 0;
5168 5168
         }
5169 5169
     }
5170 5170
 	
@@ -5194,36 +5194,36 @@  discard block
 block discarded – undo
5194 5194
  * }
5195 5195
  * @return int|bool Term id when success, false when fail.
5196 5196
  */
5197
-function geodir_imex_update_term( $taxonomy, $term_data ) {
5198
-	if ( empty( $taxonomy ) || empty( $term_data ) ) {
5197
+function geodir_imex_update_term($taxonomy, $term_data) {
5198
+	if (empty($taxonomy) || empty($term_data)) {
5199 5199
 		return false;
5200 5200
 	}
5201 5201
 	
5202
-	$term_id = isset( $term_data['term_id'] ) && !empty( $term_data['term_id'] ) ? $term_data['term_id'] : 0;
5202
+	$term_id = isset($term_data['term_id']) && !empty($term_data['term_id']) ? $term_data['term_id'] : 0;
5203 5203
 	
5204 5204
 	$args = array();
5205
-	$args['description'] = isset( $term_data['description'] ) ? $term_data['description'] : '';
5206
-	$args['slug'] = isset( $term_data['slug'] ) ? $term_data['slug'] : '';
5207
-	$args['parent'] = isset( $term_data['parent'] ) ? (int)$term_data['parent'] : '';
5205
+	$args['description'] = isset($term_data['description']) ? $term_data['description'] : '';
5206
+	$args['slug'] = isset($term_data['slug']) ? $term_data['slug'] : '';
5207
+	$args['parent'] = isset($term_data['parent']) ? (int) $term_data['parent'] : '';
5208 5208
 	
5209
-	if ( $term_id > 0 && $term_info = (array)get_term( $term_id, $taxonomy ) ) {
5209
+	if ($term_id > 0 && $term_info = (array) get_term($term_id, $taxonomy)) {
5210 5210
 		$term_data['term_id'] = $term_info['term_id'];
5211 5211
 		
5212
-		$result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
5212
+		$result = wp_update_term($term_data['term_id'], $taxonomy, $term_data);
5213 5213
 		
5214
-		if( !is_wp_error( $result ) ) {
5215
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5214
+		if (!is_wp_error($result)) {
5215
+            return isset($result['term_id']) ? $result['term_id'] : 0;
5216 5216
         }
5217
-	} else if ( $term_data['slug'] != '' && $term_info = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
5217
+	} else if ($term_data['slug'] != '' && $term_info = (array) term_exists($term_data['slug'], $taxonomy)) {
5218 5218
 		$term_data['term_id'] = $term_info['term_id'];
5219 5219
 		
5220
-		$result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data );
5220
+		$result = wp_update_term($term_data['term_id'], $taxonomy, $term_data);
5221 5221
 		
5222
-		if( !is_wp_error( $result ) ) {
5223
-            return isset( $result['term_id'] ) ? $result['term_id'] : 0;
5222
+		if (!is_wp_error($result)) {
5223
+            return isset($result['term_id']) ? $result['term_id'] : 0;
5224 5224
         }
5225 5225
 	} else {
5226
-		return geodir_imex_insert_term( $taxonomy, $term_data );
5226
+		return geodir_imex_insert_term($taxonomy, $term_data);
5227 5227
 	}
5228 5228
 	
5229 5229
 	return false;
@@ -5241,25 +5241,25 @@  discard block
 block discarded – undo
5241 5241
  * @param string $post_type Post type.
5242 5242
  * @return int Posts count.
5243 5243
  */
5244
-function geodir_get_posts_count( $post_type ) {
5244
+function geodir_get_posts_count($post_type) {
5245 5245
     global $wpdb, $plugin_prefix;
5246 5246
 
5247
-    if ( !post_type_exists( $post_type ) ) {
5247
+    if (!post_type_exists($post_type)) {
5248 5248
         return 0;
5249 5249
     }
5250 5250
         
5251
-    $table = $plugin_prefix . $post_type . '_detail';
5251
+    $table = $plugin_prefix.$post_type.'_detail';
5252 5252
 
5253 5253
     // Skip listing with statuses trash, auto-draft etc...
5254 5254
     $skip_statuses = geodir_imex_export_skip_statuses();
5255 5255
     $where_statuses = '';
5256
-    if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5257
-        $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5256
+    if (!empty($skip_statuses) && is_array($skip_statuses)) {
5257
+        $where_statuses = "AND `".$wpdb->posts."`.`post_status` NOT IN('".implode("','", $skip_statuses)."')";
5258 5258
     }
5259 5259
 
5260
-    $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 );
5260
+    $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);
5261 5261
 
5262
-    $posts_count = (int)$wpdb->get_var( $query );
5262
+    $posts_count = (int) $wpdb->get_var($query);
5263 5263
     
5264 5264
     /**
5265 5265
      * Modify returned post counts for the current post type.
@@ -5270,7 +5270,7 @@  discard block
 block discarded – undo
5270 5270
      * @param int $posts_count Post counts.
5271 5271
      * @param string $post_type Post type.
5272 5272
      */
5273
-    $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type );
5273
+    $posts_count = apply_filters('geodir_imex_count_posts', $posts_count, $post_type);
5274 5274
 
5275 5275
     return $posts_count;
5276 5276
 }
@@ -5291,17 +5291,17 @@  discard block
 block discarded – undo
5291 5291
  * @param int $page_no Page number. Default 0.
5292 5292
  * @return array Array of posts data.
5293 5293
  */
5294
-function geodir_imex_get_posts( $post_type, $per_page = 0, $page_no = 0 ) {	
5294
+function geodir_imex_get_posts($post_type, $per_page = 0, $page_no = 0) {	
5295 5295
 	global $wp_filesystem;
5296 5296
 
5297
-	$posts = geodir_get_export_posts( $post_type, $per_page, $page_no );
5297
+	$posts = geodir_get_export_posts($post_type, $per_page, $page_no);
5298 5298
 
5299 5299
 	$csv_rows = array();
5300 5300
 	
5301
-	if ( !empty( $posts ) ) {
5302
-		$is_payment_plugin = is_plugin_active( 'geodir_payment_manager/geodir_payment_manager.php' );
5301
+	if (!empty($posts)) {
5302
+		$is_payment_plugin = is_plugin_active('geodir_payment_manager/geodir_payment_manager.php');
5303 5303
         $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
5304
-        $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true;
5304
+        $location_allowed = function_exists('geodir_cpt_no_location') && geodir_cpt_no_location($post_type) ? false : true;
5305 5305
         $neighbourhood_active = $location_manager && $location_allowed && get_option('location_neighbourhoods') ? true : false;
5306 5306
 		
5307 5307
 		$csv_row = array();
@@ -5313,7 +5313,7 @@  discard block
 block discarded – undo
5313 5313
 		$csv_row[] = 'default_category';
5314 5314
 		$csv_row[] = 'post_tags';
5315 5315
 		$csv_row[] = 'post_type';
5316
-		if ( $post_type == 'gd_event' ) {
5316
+		if ($post_type == 'gd_event') {
5317 5317
 			$csv_row[] = 'event_date';
5318 5318
 			$csv_row[] = 'event_enddate';
5319 5319
 			$csv_row[] = 'starttime';
@@ -5367,15 +5367,15 @@  discard block
 block discarded – undo
5367 5367
 		}
5368 5368
 		// WPML
5369 5369
 
5370
-		$custom_fields = geodir_imex_get_custom_fields( $post_type );
5371
-		if ( !empty( $custom_fields ) ) {
5372
-			foreach ( $custom_fields as $custom_field ) {
5370
+		$custom_fields = geodir_imex_get_custom_fields($post_type);
5371
+		if (!empty($custom_fields)) {
5372
+			foreach ($custom_fields as $custom_field) {
5373 5373
 				$csv_row[] = $custom_field->htmlvar_name;
5374 5374
 			}
5375 5375
 		}
5376 5376
 
5377 5377
 		// Export franchise fields
5378
-		$is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false;
5378
+		$is_franchise_active = is_plugin_active('geodir_franchise/geodir_franchise.php') && geodir_franchise_enabled($post_type) ? true : false;
5379 5379
 		if ($is_franchise_active) {
5380 5380
 			$csv_row[] = 'gd_is_franchise';
5381 5381
 			$csv_row[] = 'gd_franchise_lock';
@@ -5385,28 +5385,28 @@  discard block
 block discarded – undo
5385 5385
 		$csv_rows[] = $csv_row;
5386 5386
 
5387 5387
 		$images_count = 5;
5388
-        $xx=0;
5389
-		foreach ( $posts as $post ) {$xx++;
5388
+        $xx = 0;
5389
+		foreach ($posts as $post) {$xx++;
5390 5390
 			$post_id = $post['ID'];
5391 5391
 			
5392
-			$gd_post_info = geodir_get_post_info( $post_id );
5393
-			$post_info = (array)$gd_post_info;
5392
+			$gd_post_info = geodir_get_post_info($post_id);
5393
+			$post_info = (array) $gd_post_info;
5394 5394
 						
5395
-			$taxonomy_category = $post_type . 'category';
5396
-			$taxonomy_tags = $post_type . '_tags';
5395
+			$taxonomy_category = $post_type.'category';
5396
+			$taxonomy_tags = $post_type.'_tags';
5397 5397
 			
5398 5398
 			$post_category = '';
5399 5399
 			$default_category_id = $gd_post_info->default_category;
5400 5400
 			$default_category = '';
5401 5401
 			$post_tags = '';
5402
-			$terms = wp_get_post_terms( $post_id, array( $taxonomy_category, $taxonomy_tags ) );
5402
+			$terms = wp_get_post_terms($post_id, array($taxonomy_category, $taxonomy_tags));
5403 5403
 			
5404
-			if ( !empty( $terms ) && !is_wp_error( $terms ) ) {
5404
+			if (!empty($terms) && !is_wp_error($terms)) {
5405 5405
 				$post_category = array();
5406 5406
 				$post_tags = array();
5407 5407
 			
5408
-				foreach ( $terms as $term ) {
5409
-					if ( $term->taxonomy == $taxonomy_category ) {
5408
+				foreach ($terms as $term) {
5409
+					if ($term->taxonomy == $taxonomy_category) {
5410 5410
 						$post_category[] = $term->name;
5411 5411
 						
5412 5412
 						if ($default_category_id == $term->term_id) {
@@ -5414,7 +5414,7 @@  discard block
 block discarded – undo
5414 5414
 						}
5415 5415
 					}
5416 5416
 					
5417
-					if ( $term->taxonomy == $taxonomy_tags ) {
5417
+					if ($term->taxonomy == $taxonomy_tags) {
5418 5418
 						$post_tags[] = $term->name;
5419 5419
 					}
5420 5420
 				}
@@ -5422,47 +5422,47 @@  discard block
 block discarded – undo
5422 5422
 				if (empty($default_category) && !empty($post_category)) {
5423 5423
 					$default_category = $post_category[0]; // Set first one as default category.
5424 5424
 				}
5425
-				$post_category = !empty( $post_category ) ? implode( ',', $post_category ) : '';
5426
-				$post_tags = !empty( $post_tags ) ? implode( ',', $post_tags ) : '';
5425
+				$post_category = !empty($post_category) ? implode(',', $post_category) : '';
5426
+				$post_tags = !empty($post_tags) ? implode(',', $post_tags) : '';
5427 5427
 			}
5428 5428
 
5429 5429
 			// Franchise data
5430
-			if ($is_franchise_active && isset($post_info['franchise']) && (int)$post_info['franchise'] > 0 && geodir_franchise_check((int)$post_info['franchise'])) {
5430
+			if ($is_franchise_active && isset($post_info['franchise']) && (int) $post_info['franchise'] > 0 && geodir_franchise_check((int) $post_info['franchise'])) {
5431 5431
 				$franchise_id = $post_info['franchise'];
5432 5432
 				$gd_franchise_info = geodir_get_post_info($franchise_id);
5433 5433
 
5434 5434
 				if (geodir_franchise_pkg_is_active($gd_franchise_info)) {
5435
-					$franchise_info = (array)$gd_franchise_info;
5435
+					$franchise_info = (array) $gd_franchise_info;
5436 5436
 					$locked_fields = geodir_franchise_get_locked_fields($franchise_id, true);
5437 5437
 					
5438 5438
 					if (!empty($locked_fields)) {
5439
-						foreach( $locked_fields as $locked_field) {
5439
+						foreach ($locked_fields as $locked_field) {
5440 5440
 							if (isset($post_info[$locked_field]) && isset($franchise_info[$locked_field])) {
5441 5441
 								$post_info[$locked_field] = $franchise_info[$locked_field];
5442 5442
 							}
5443 5443
 							
5444 5444
 							if (in_array($taxonomy_category, $locked_fields) || in_array('post_tags', $locked_fields)) {
5445
-								$franchise_terms = wp_get_post_terms( $franchise_id, array( $taxonomy_category, $taxonomy_tags ) );
5445
+								$franchise_terms = wp_get_post_terms($franchise_id, array($taxonomy_category, $taxonomy_tags));
5446 5446
 			
5447
-								if ( !empty( $franchise_terms ) && !is_wp_error( $franchise_terms ) ) {
5447
+								if (!empty($franchise_terms) && !is_wp_error($franchise_terms)) {
5448 5448
 									$franchise_post_category = array();
5449 5449
 									$franchise_post_tags = array();
5450 5450
 								
5451
-									foreach ( $franchise_terms as $franchise_term ) {
5452
-										if ( $franchise_term->taxonomy == $taxonomy_category ) {
5451
+									foreach ($franchise_terms as $franchise_term) {
5452
+										if ($franchise_term->taxonomy == $taxonomy_category) {
5453 5453
 											$franchise_post_category[] = $franchise_term->name;
5454 5454
 										}
5455 5455
 										
5456
-										if ( $franchise_term->taxonomy == $taxonomy_tags ) {
5456
+										if ($franchise_term->taxonomy == $taxonomy_tags) {
5457 5457
 											$franchise_post_tags[] = $franchise_term->name;
5458 5458
 										}
5459 5459
 									}
5460 5460
 									
5461 5461
 									if (in_array($taxonomy_category, $locked_fields)) {
5462
-										$post_category = !empty( $franchise_post_category ) ? implode( ',', $franchise_post_category ) : '';
5462
+										$post_category = !empty($franchise_post_category) ? implode(',', $franchise_post_category) : '';
5463 5463
 									}
5464 5464
 									if (in_array('post_tags', $locked_fields)) {
5465
-										$post_tags = !empty( $franchise_post_tags ) ? implode( ',', $franchise_post_tags ) : '';
5465
+										$post_tags = !empty($franchise_post_tags) ? implode(',', $franchise_post_tags) : '';
5466 5466
 									}
5467 5467
 								}
5468 5468
 							}
@@ -5471,18 +5471,18 @@  discard block
 block discarded – undo
5471 5471
 				}
5472 5472
 			}
5473 5473
 						
5474
-			$post_images = geodir_get_images( $post_id );
5474
+			$post_images = geodir_get_images($post_id);
5475 5475
 			$current_images = array();
5476
-			if ( !empty( $post_images ) ) {
5477
-				foreach ( $post_images as $post_image ) {
5478
-					$post_image = (array)$post_image;
5479
-					$image = !empty( $post_image ) && isset( $post_image['path'] ) && $wp_filesystem->is_file( $post_image['path'] ) && $wp_filesystem->exists( $post_image['path'] ) ? $post_image['src'] : '';
5480
-					if ( $image ) {
5476
+			if (!empty($post_images)) {
5477
+				foreach ($post_images as $post_image) {
5478
+					$post_image = (array) $post_image;
5479
+					$image = !empty($post_image) && isset($post_image['path']) && $wp_filesystem->is_file($post_image['path']) && $wp_filesystem->exists($post_image['path']) ? $post_image['src'] : '';
5480
+					if ($image) {
5481 5481
 						$current_images[] = $image;
5482 5482
 					}
5483 5483
 				}
5484 5484
 				
5485
-				$images_count = max( $images_count, count( $current_images ) );
5485
+				$images_count = max($images_count, count($current_images));
5486 5486
 			}
5487 5487
 
5488 5488
 			$csv_row = array();
@@ -5494,7 +5494,7 @@  discard block
 block discarded – undo
5494 5494
 			$csv_row[] = $default_category; // default_category
5495 5495
 			$csv_row[] = $post_tags; // post_tags
5496 5496
 			$csv_row[] = $post_type; // post_type
5497
-			if ( $post_type == 'gd_event' ) {
5497
+			if ($post_type == 'gd_event') {
5498 5498
 				$event_data = geodir_imex_get_event_data($post, $gd_post_info);
5499 5499
 				$csv_row[] = $event_data['event_date']; // event_date
5500 5500
 				$csv_row[] = $event_data['event_enddate']; // enddate
@@ -5515,9 +5515,9 @@  discard block
 block discarded – undo
5515 5515
 				$csv_row[] = $event_data['recurring_end_date']; // repeat_end
5516 5516
 			}
5517 5517
 			$csv_row[] = $post_info['post_status']; // post_status
5518
-			$csv_row[] = (int)$post_info['is_featured'] == 1 ? 1 : ''; // is_featured
5518
+			$csv_row[] = (int) $post_info['is_featured'] == 1 ? 1 : ''; // is_featured
5519 5519
 			if ($is_payment_plugin) {
5520
-				$csv_row[] = (int)$post_info['package_id']; // package_id
5520
+				$csv_row[] = (int) $post_info['package_id']; // package_id
5521 5521
 				$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
5522 5522
 			}
5523 5523
 			$csv_row[] = $post_info['geodir_video']; // geodir_video
@@ -5553,14 +5553,14 @@  discard block
 block discarded – undo
5553 5553
 			$csv_row[] = $post_info['geodir_special_offers']; // geodir_special_offers
5554 5554
 			// WPML
5555 5555
 			if ($is_wpml) {
5556
-				$csv_row[] = geodir_get_language_for_element( $post_id, 'post_' . $post_type );
5557
-				$csv_row[] = geodir_imex_original_post_id( $post_id, 'post_' . $post_type );
5556
+				$csv_row[] = geodir_get_language_for_element($post_id, 'post_'.$post_type);
5557
+				$csv_row[] = geodir_imex_original_post_id($post_id, 'post_'.$post_type);
5558 5558
 			}
5559 5559
 			// WPML
5560 5560
 			
5561
-			if ( !empty( $custom_fields ) ) {
5562
-				foreach ( $custom_fields as $custom_field ) {
5563
-					$csv_row[] = isset( $post_info[$custom_field->htmlvar_name] ) ? $post_info[$custom_field->htmlvar_name] : '';
5561
+			if (!empty($custom_fields)) {
5562
+				foreach ($custom_fields as $custom_field) {
5563
+					$csv_row[] = isset($post_info[$custom_field->htmlvar_name]) ? $post_info[$custom_field->htmlvar_name] : '';
5564 5564
 				}
5565 5565
 			}
5566 5566
 			
@@ -5571,26 +5571,26 @@  discard block
 block discarded – undo
5571 5571
 				$franchise = '';
5572 5572
 					
5573 5573
 				if (geodir_franchise_pkg_is_active($gd_post_info)) {
5574
-					$gd_is_franchise = (int)get_post_meta( $post_id, 'gd_is_franchise', true );
5575
-					$locaked_fields = $gd_is_franchise ? get_post_meta( $post_id, 'gd_franchise_lock', true ) : '';
5574
+					$gd_is_franchise = (int) get_post_meta($post_id, 'gd_is_franchise', true);
5575
+					$locaked_fields = $gd_is_franchise ? get_post_meta($post_id, 'gd_franchise_lock', true) : '';
5576 5576
 					$locaked_fields = (is_array($locaked_fields) && !empty($locaked_fields) ? implode(",", $locaked_fields) : '');
5577
-					$franchise = !$gd_is_franchise && isset($post_info['franchise']) && (int)$post_info['franchise'] > 0 ? (int)$post_info['franchise'] : 0; // franchise id
5577
+					$franchise = !$gd_is_franchise && isset($post_info['franchise']) && (int) $post_info['franchise'] > 0 ? (int) $post_info['franchise'] : 0; // franchise id
5578 5578
 				}
5579 5579
 				
5580
-				$csv_row[] = (int)$gd_is_franchise; // gd_is_franchise
5580
+				$csv_row[] = (int) $gd_is_franchise; // gd_is_franchise
5581 5581
 				$csv_row[] = $locaked_fields; // gd_franchise_lock fields
5582
-				$csv_row[] = (int)$franchise; // franchise id
5582
+				$csv_row[] = (int) $franchise; // franchise id
5583 5583
 			}
5584 5584
 			
5585
-			for ( $c = 0; $c < $images_count; $c++ ) {
5586
-				$csv_row[] = isset( $current_images[$c] ) ? $current_images[$c] : ''; // IMAGE
5585
+			for ($c = 0; $c < $images_count; $c++) {
5586
+				$csv_row[] = isset($current_images[$c]) ? $current_images[$c] : ''; // IMAGE
5587 5587
 			}
5588 5588
 			
5589 5589
 			$csv_rows[] = $csv_row;
5590 5590
 
5591 5591
 		}
5592 5592
 
5593
-		for ( $c = 0; $c < $images_count; $c++ ) {
5593
+		for ($c = 0; $c < $images_count; $c++) {
5594 5594
 			$csv_rows[0][] = 'IMAGE';
5595 5595
 		}
5596 5596
 	}
@@ -5612,33 +5612,33 @@  discard block
 block discarded – undo
5612 5612
  * @param int $page_no Page number. Default 0.
5613 5613
  * @return array Array of posts data.
5614 5614
  */
5615
-function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) {
5615
+function geodir_get_export_posts($post_type, $per_page = 0, $page_no = 0) {
5616 5616
     global $wpdb, $plugin_prefix;
5617 5617
 
5618
-    if ( ! post_type_exists( $post_type ) )
5618
+    if (!post_type_exists($post_type))
5619 5619
         return new stdClass;
5620 5620
         
5621
-    $table = $plugin_prefix . $post_type . '_detail';
5621
+    $table = $plugin_prefix.$post_type.'_detail';
5622 5622
 
5623 5623
     $limit = '';
5624
-    if ( $per_page > 0 && $page_no > 0 ) {
5625
-        $offset = ( $page_no - 1 ) * $per_page;
5624
+    if ($per_page > 0 && $page_no > 0) {
5625
+        $offset = ($page_no - 1) * $per_page;
5626 5626
         
5627
-        if ( $offset > 0 ) {
5628
-            $limit = " LIMIT " . $offset . "," . $per_page;
5627
+        if ($offset > 0) {
5628
+            $limit = " LIMIT ".$offset.",".$per_page;
5629 5629
         } else {
5630
-            $limit = " LIMIT " . $per_page;
5630
+            $limit = " LIMIT ".$per_page;
5631 5631
         }
5632 5632
     }
5633 5633
 
5634 5634
     // Skip listing with statuses trash, auto-draft etc...
5635 5635
     $skip_statuses = geodir_imex_export_skip_statuses();
5636 5636
     $where_statuses = '';
5637
-    if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5638
-        $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5637
+    if (!empty($skip_statuses) && is_array($skip_statuses)) {
5638
+        $where_statuses = "AND `".$wpdb->posts."`.`post_status` NOT IN('".implode("','", $skip_statuses)."')";
5639 5639
     }
5640 5640
 
5641
-    $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;
5641
+    $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;
5642 5642
     /**
5643 5643
      * Modify returned posts SQL query for the current post type.
5644 5644
      *
@@ -5648,9 +5648,9 @@  discard block
 block discarded – undo
5648 5648
      * @param int $query The SQL query.
5649 5649
      * @param string $post_type Post type.
5650 5650
      */
5651
-    $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type );
5651
+    $query = apply_filters('geodir_imex_export_posts_query', $query, $post_type);
5652 5652
 
5653
-    $results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A );
5653
+    $results = (array) $wpdb->get_results($wpdb->prepare($query, $post_type), ARRAY_A);
5654 5654
 
5655 5655
     /**
5656 5656
      * Modify returned post results for the current post type.
@@ -5661,7 +5661,7 @@  discard block
 block discarded – undo
5661 5661
      * @param object $results An object containing all post ids.
5662 5662
      * @param string $post_type Post type.
5663 5663
      */
5664
-    return apply_filters( 'geodir_export_posts', $results, $post_type );
5664
+    return apply_filters('geodir_export_posts', $results, $post_type);
5665 5665
 }
5666 5666
 
5667 5667
 /**
@@ -5678,21 +5678,21 @@  discard block
 block discarded – undo
5678 5678
  * @param string $post_type Post type.
5679 5679
  * @return string The SQL query.
5680 5680
  */
5681
-function geodir_imex_get_events_query( $query, $post_type ) {
5682
-    if ( $post_type == 'gd_event' ) {
5681
+function geodir_imex_get_events_query($query, $post_type) {
5682
+    if ($post_type == 'gd_event') {
5683 5683
         global $wpdb, $plugin_prefix;
5684 5684
         
5685
-        $table = $plugin_prefix . $post_type . '_detail';
5685
+        $table = $plugin_prefix.$post_type.'_detail';
5686 5686
         $schedule_table = EVENT_SCHEDULE;
5687 5687
         
5688 5688
         // Skip listing with statuses trash, auto-draft etc...
5689 5689
         $skip_statuses = geodir_imex_export_skip_statuses();
5690 5690
         $where_statuses = '';
5691
-        if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
5692
-            $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
5691
+        if (!empty($skip_statuses) && is_array($skip_statuses)) {
5692
+            $where_statuses = "AND `".$wpdb->posts."`.`post_status` NOT IN('".implode("','", $skip_statuses)."')";
5693 5693
         }
5694 5694
 
5695
-        $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";
5695
+        $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";
5696 5696
     }
5697 5697
 
5698 5698
     return $query;
@@ -5716,35 +5716,35 @@  discard block
 block discarded – undo
5716 5716
  * @param  string $post_type Post type.
5717 5717
  * @return int Total terms count.
5718 5718
  */
5719
-function geodir_get_terms_count( $post_type ) {
5720
-    $args = array( 'hide_empty' => 0 );
5719
+function geodir_get_terms_count($post_type) {
5720
+    $args = array('hide_empty' => 0);
5721 5721
 
5722
-    remove_all_filters( 'get_terms' );
5722
+    remove_all_filters('get_terms');
5723 5723
 
5724
-    $taxonomy = $post_type . 'category';
5724
+    $taxonomy = $post_type.'category';
5725 5725
 
5726 5726
     // WPML
5727 5727
     $is_wpml = geodir_is_wpml();
5728 5728
     $active_lang = 'all';
5729
-    if ( $is_wpml ) {
5729
+    if ($is_wpml) {
5730 5730
         global $sitepress;
5731 5731
         $active_lang = $sitepress->get_current_language();
5732 5732
         
5733
-        if ( $active_lang != 'all' ) {
5734
-            $sitepress->switch_lang( 'all', true );
5733
+        if ($active_lang != 'all') {
5734
+            $sitepress->switch_lang('all', true);
5735 5735
         }
5736 5736
     }
5737 5737
     // WPML
5738 5738
             
5739
-    $count_terms = wp_count_terms( $taxonomy, $args );
5739
+    $count_terms = wp_count_terms($taxonomy, $args);
5740 5740
 
5741 5741
     // WPML
5742
-    if ( $is_wpml && $active_lang !== 'all' ) {
5742
+    if ($is_wpml && $active_lang !== 'all') {
5743 5743
         global $sitepress;
5744
-        $sitepress->switch_lang( $active_lang, true );
5744
+        $sitepress->switch_lang($active_lang, true);
5745 5745
     }
5746 5746
     // WPML
5747
-    $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0;
5747
+    $count_terms = !is_wp_error($count_terms) ? $count_terms : 0;
5748 5748
      
5749 5749
     return $count_terms;
5750 5750
 }
@@ -5761,23 +5761,23 @@  discard block
 block discarded – undo
5761 5761
  * @param int $page_no Page number. Default 0.
5762 5762
  * @return array Array of terms data.
5763 5763
  */
5764
-function geodir_imex_get_terms( $post_type, $per_page = 0, $page_no = 0 ) {
5765
-	$args = array( 'hide_empty' => 0, 'orderby' => 'id' );
5764
+function geodir_imex_get_terms($post_type, $per_page = 0, $page_no = 0) {
5765
+	$args = array('hide_empty' => 0, 'orderby' => 'id');
5766 5766
 	
5767
-	remove_all_filters( 'get_terms' );
5767
+	remove_all_filters('get_terms');
5768 5768
 	
5769
-	$taxonomy = $post_type . 'category';
5769
+	$taxonomy = $post_type.'category';
5770 5770
 	
5771
-	if ( $per_page > 0 && $page_no > 0 ) {
5772
-		$args['offset'] = ( $page_no - 1 ) * $per_page;
5771
+	if ($per_page > 0 && $page_no > 0) {
5772
+		$args['offset'] = ($page_no - 1) * $per_page;
5773 5773
 		$args['number'] = $per_page;
5774 5774
 	}
5775 5775
 	
5776
-	$terms = get_terms( $taxonomy, $args );
5776
+	$terms = get_terms($taxonomy, $args);
5777 5777
 
5778 5778
 	$csv_rows = array();
5779 5779
 	
5780
-	if ( !empty( $terms ) ) {
5780
+	if (!empty($terms)) {
5781 5781
 		$csv_row = array();
5782 5782
 		$csv_row[] = 'cat_id';
5783 5783
 		$csv_row[] = 'cat_name';
@@ -5799,16 +5799,16 @@  discard block
 block discarded – undo
5799 5799
 		
5800 5800
 		$csv_rows[] = $csv_row;
5801 5801
 		
5802
-		foreach ( $terms as $term ) {
5803
-			$cat_icon = get_tax_meta( $term->term_id, 'ct_cat_icon', false, $post_type );
5804
-			$cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : '';
5802
+		foreach ($terms as $term) {
5803
+			$cat_icon = get_tax_meta($term->term_id, 'ct_cat_icon', false, $post_type);
5804
+			$cat_icon = !empty($cat_icon) && isset($cat_icon['src']) ? $cat_icon['src'] : '';
5805 5805
 			
5806
-			$cat_image = geodir_get_default_catimage( $term->term_id, $post_type );
5807
-			$cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; 
5806
+			$cat_image = geodir_get_default_catimage($term->term_id, $post_type);
5807
+			$cat_image = !empty($cat_image) && isset($cat_image['src']) ? $cat_image['src'] : ''; 
5808 5808
 			
5809 5809
 			$cat_parent = '';
5810
-			if (isset($term->parent) && (int)$term->parent > 0 && term_exists((int)$term->parent, $taxonomy)) {
5811
-				$parent_term = (array)get_term_by( 'id', (int)$term->parent, $taxonomy );
5810
+			if (isset($term->parent) && (int) $term->parent > 0 && term_exists((int) $term->parent, $taxonomy)) {
5811
+				$parent_term = (array) get_term_by('id', (int) $term->parent, $taxonomy);
5812 5812
 				$cat_parent = !empty($parent_term) && isset($parent_term['name']) ? $parent_term['name'] : '';
5813 5813
 			}
5814 5814
 			
@@ -5818,15 +5818,15 @@  discard block
 block discarded – undo
5818 5818
 			$csv_row[] = $term->slug;
5819 5819
 			$csv_row[] = $post_type;
5820 5820
 			$csv_row[] = $cat_parent;
5821
-			$csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_schema', false, $post_type );
5821
+			$csv_row[] = get_tax_meta($term->term_id, 'ct_cat_schema', false, $post_type);
5822 5822
             // WPML
5823 5823
 			if ($is_wpml) {
5824
-				$csv_row[] = geodir_get_language_for_element( $term->term_id, 'tax_' . $taxonomy );
5825
-                $csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy );
5824
+				$csv_row[] = geodir_get_language_for_element($term->term_id, 'tax_'.$taxonomy);
5825
+                $csv_row[] = geodir_imex_original_post_id($term->term_id, 'tax_'.$taxonomy);
5826 5826
 			}
5827 5827
 			// WPML
5828 5828
 			$csv_row[] = $term->description;
5829
-			$csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_top_desc', false, $post_type );
5829
+			$csv_row[] = get_tax_meta($term->term_id, 'ct_cat_top_desc', false, $post_type);
5830 5830
 			$csv_row[] = $cat_image;
5831 5831
 			$csv_row[] = $cat_icon;
5832 5832
 			
@@ -5845,10 +5845,10 @@  discard block
 block discarded – undo
5845 5845
  * @param  bool $relative True for relative path & False for absolute path.
5846 5846
  * @return string Path to the cache directory.
5847 5847
  */
5848
-function geodir_path_import_export( $relative = true ) {
5848
+function geodir_path_import_export($relative = true) {
5849 5849
 	$upload_dir = wp_upload_dir();
5850 5850
 	
5851
-	return $relative ? $upload_dir['baseurl'] . '/cache' : $upload_dir['basedir'] . '/cache';
5851
+	return $relative ? $upload_dir['baseurl'].'/cache' : $upload_dir['basedir'].'/cache';
5852 5852
 }
5853 5853
 
5854 5854
 /**
@@ -5864,8 +5864,8 @@  discard block
 block discarded – undo
5864 5864
  * @param  bool $clear If true then it overwrite data otherwise add rows at the end of file.
5865 5865
  * @return bool true if success otherwise false.
5866 5866
  */
5867
-function geodir_save_csv_data( $file_path, $csv_data = array(), $clear = true ) {
5868
-	if ( empty( $csv_data ) ) {
5867
+function geodir_save_csv_data($file_path, $csv_data = array(), $clear = true) {
5868
+	if (empty($csv_data)) {
5869 5869
 		return false;
5870 5870
 	}
5871 5871
 	
@@ -5873,17 +5873,17 @@  discard block
 block discarded – undo
5873 5873
 	
5874 5874
 	$mode = $clear ? 'w+' : 'a+';
5875 5875
 	
5876
-	if ( function_exists( 'fputcsv' ) ) {
5877
-		$file = fopen( $file_path, $mode );
5878
-		foreach( $csv_data as $csv_row ) {
5876
+	if (function_exists('fputcsv')) {
5877
+		$file = fopen($file_path, $mode);
5878
+		foreach ($csv_data as $csv_row) {
5879 5879
 			//$csv_row = array_map( 'utf8_decode', $csv_row );
5880
-			$write_successful = fputcsv( $file, $csv_row, ",", $enclosure = '"' );
5880
+			$write_successful = fputcsv($file, $csv_row, ",", $enclosure = '"');
5881 5881
 		}
5882
-		fclose( $file );
5882
+		fclose($file);
5883 5883
 	} else {
5884
-		foreach( $csv_data as $csv_row ) {
5884
+		foreach ($csv_data as $csv_row) {
5885 5885
 			//$csv_row = array_map( 'utf8_decode', $csv_row );
5886
-			$wp_filesystem->put_contents( $file_path, $csv_row );
5886
+			$wp_filesystem->put_contents($file_path, $csv_row);
5887 5887
 		}
5888 5888
 	}
5889 5889
 		
@@ -5901,14 +5901,14 @@  discard block
 block discarded – undo
5901 5901
  * @param  string $file Full path to file.
5902 5902
  * @return int No of file rows.
5903 5903
  */
5904
-function geodir_import_export_line_count( $file ) {
5904
+function geodir_import_export_line_count($file) {
5905 5905
 	global $wp_filesystem;
5906 5906
 	
5907
-	if ( $wp_filesystem->is_file( $file ) && $wp_filesystem->exists( $file ) ) {
5908
-		$contents = $wp_filesystem->get_contents_array( $file );
5907
+	if ($wp_filesystem->is_file($file) && $wp_filesystem->exists($file)) {
5908
+		$contents = $wp_filesystem->get_contents_array($file);
5909 5909
 		
5910
-		if ( !empty( $contents ) && is_array( $contents ) ) {
5911
-			return count( $contents ) - 1;
5910
+		if (!empty($contents) && is_array($contents)) {
5911
+			return count($contents) - 1;
5912 5912
 		}
5913 5913
 	}
5914 5914
 	
@@ -5925,11 +5925,11 @@  discard block
 block discarded – undo
5925 5925
  * @param string $post_type The post type.
5926 5926
  * @return object Queried object.
5927 5927
  */
5928
-function geodir_imex_get_custom_fields( $post_type ) {
5928
+function geodir_imex_get_custom_fields($post_type) {
5929 5929
 	global $wpdb;
5930 5930
 	 
5931
-	$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 ) );
5932
-	$rows = $wpdb->get_results( $sql );
5931
+	$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));
5932
+	$rows = $wpdb->get_results($sql);
5933 5933
 	 
5934 5934
 	return $rows;
5935 5935
 }
@@ -6008,14 +6008,14 @@  discard block
 block discarded – undo
6008 6008
 	global $wpdb, $plugin_prefix;
6009 6009
 	
6010 6010
 	$post_type = get_post_type($master_post_id);
6011
-	$post_table = $plugin_prefix . $post_type . '_detail';
6011
+	$post_table = $plugin_prefix.$post_type.'_detail';
6012 6012
 	
6013
-	$query = $wpdb->prepare("SELECT * FROM " . $post_table . " WHERE post_id = %d", array($master_post_id));
6014
-	$data = (array)$wpdb->get_row($query);
6013
+	$query = $wpdb->prepare("SELECT * FROM ".$post_table." WHERE post_id = %d", array($master_post_id));
6014
+	$data = (array) $wpdb->get_row($query);
6015 6015
 	
6016
-	if ( !empty( $data ) ) {
6016
+	if (!empty($data)) {
6017 6017
 		$data['post_id'] = $tr_post_id;
6018
-		unset($data['default_category'], $data['marker_json'], $data['featured_image'], $data[$post_type . 'category'], $data['overall_rating'], $data['rating_count'], $data['ratings']);
6018
+		unset($data['default_category'], $data['marker_json'], $data['featured_image'], $data[$post_type.'category'], $data['overall_rating'], $data['rating_count'], $data['ratings']);
6019 6019
 		
6020 6020
 		$wpdb->update($post_table, $data, array('post_id' => $tr_post_id));		
6021 6021
 		return true;
@@ -6041,7 +6041,7 @@  discard block
 block discarded – undo
6041 6041
 	global $sitepress, $wpdb;
6042 6042
 	$post_type = get_post_type($master_post_id);
6043 6043
 	
6044
-	remove_filter('get_term', array($sitepress,'get_term_adjust_id')); // AVOID filtering to current language
6044
+	remove_filter('get_term', array($sitepress, 'get_term_adjust_id')); // AVOID filtering to current language
6045 6045
 
6046 6046
 	$taxonomies = get_object_taxonomies($post_type);
6047 6047
 	foreach ($taxonomies as $taxonomy) {
@@ -6050,9 +6050,9 @@  discard block
 block discarded – undo
6050 6050
 		
6051 6051
 		if ($terms) {
6052 6052
 			foreach ($terms as $term) {
6053
-				$tr_id = apply_filters( 'translate_object_id',$term->term_id, $taxonomy, false, $lang);
6053
+				$tr_id = apply_filters('translate_object_id', $term->term_id, $taxonomy, false, $lang);
6054 6054
 				
6055
-				if (!is_null($tr_id)){
6055
+				if (!is_null($tr_id)) {
6056 6056
 					// not using get_term - unfiltered get_term
6057 6057
 					$translated_term = $wpdb->get_row($wpdb->prepare("
6058 6058
 						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));
@@ -6061,14 +6061,14 @@  discard block
 block discarded – undo
6061 6061
 				}
6062 6062
 			}
6063 6063
 
6064
-			if (!is_taxonomy_hierarchical($taxonomy)){
6065
-				$terms_array = array_unique( array_map( 'intval', $terms_array ) );
6064
+			if (!is_taxonomy_hierarchical($taxonomy)) {
6065
+				$terms_array = array_unique(array_map('intval', $terms_array));
6066 6066
 			}
6067 6067
 
6068 6068
 			wp_set_post_terms($tr_post_id, $terms_array, $taxonomy);
6069 6069
 			
6070
-			if ($taxonomy == $post_type . 'category') {
6071
-				geodir_set_postcat_structure($tr_post_id, $post_type . 'category');
6070
+			if ($taxonomy == $post_type.'category') {
6071
+				geodir_set_postcat_structure($tr_post_id, $post_type.'category');
6072 6072
 			}
6073 6073
 		}
6074 6074
 	}
@@ -6089,15 +6089,15 @@  discard block
 block discarded – undo
6089 6089
 function geodir_icl_duplicate_post_images($master_post_id, $tr_post_id, $lang) {
6090 6090
 	global $wpdb;
6091 6091
 	
6092
-	$query = $wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d", array('%image%', $tr_post_id));
6092
+	$query = $wpdb->prepare("DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE mime_type like %s AND post_id = %d", array('%image%', $tr_post_id));
6093 6093
 	$wpdb->query($query);
6094 6094
 	
6095
-	$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));
6095
+	$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));
6096 6096
 	$post_images = $wpdb->get_results($query);
6097 6097
 	
6098
-	if ( !empty( $post_images ) ) {
6099
-		foreach ( $post_images as $post_image) {
6100
-			$image_data = (array)$post_image;
6098
+	if (!empty($post_images)) {
6099
+		foreach ($post_images as $post_image) {
6100
+			$image_data = (array) $post_image;
6101 6101
 			unset($image_data['ID']);
6102 6102
 			$image_data['post_id'] = $tr_post_id;
6103 6103
 			
@@ -6123,10 +6123,10 @@  discard block
 block discarded – undo
6123 6123
  * @return array Event data array.
6124 6124
  */
6125 6125
 function geodir_imex_get_event_data($post, $gd_post_info) {
6126
-	$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'] ) ) : '';
6126
+	$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'])) : '';
6127 6127
 	$event_enddate = $event_date;
6128
-	$starttime = isset( $post['starttime'] ) && $post['starttime'] != '' && $post['starttime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $post['starttime'] ) ) : '';
6129
-	$endtime = isset( $post['endtime'] ) && $post['endtime'] != '' && $post['endtime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $post['endtime'] ) ) : '';
6128
+	$starttime = isset($post['starttime']) && $post['starttime'] != '' && $post['starttime'] != '00:00:00' ? date_i18n('H:i', strtotime($post['starttime'])) : '';
6129
+	$endtime = isset($post['endtime']) && $post['endtime'] != '' && $post['endtime'] != '00:00:00' ? date_i18n('H:i', strtotime($post['endtime'])) : '';
6130 6130
 	
6131 6131
 	$is_recurring_event = '';
6132 6132
 	$event_duration_days = '';
@@ -6143,15 +6143,15 @@  discard block
 block discarded – undo
6143 6143
 		
6144 6144
 	$recurring_data = isset($gd_post_info->recurring_dates) ? maybe_unserialize($gd_post_info->recurring_dates) : array();
6145 6145
 	if (!empty($recurring_data)) {
6146
-		$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;
6147
-		$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;
6148
-		$starttime = isset( $recurring_data['starttime'] ) && $recurring_data['starttime'] != '' && $recurring_data['starttime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $recurring_data['starttime'] ) ) : $starttime;
6149
-		$endtime = isset( $recurring_data['endtime'] ) && $recurring_data['endtime'] != '' && $recurring_data['endtime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $recurring_data['endtime'] ) ) : $endtime;
6146
+		$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;
6147
+		$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;
6148
+		$starttime = isset($recurring_data['starttime']) && $recurring_data['starttime'] != '' && $recurring_data['starttime'] != '00:00:00' ? date_i18n('H:i', strtotime($recurring_data['starttime'])) : $starttime;
6149
+		$endtime = isset($recurring_data['endtime']) && $recurring_data['endtime'] != '' && $recurring_data['endtime'] != '00:00:00' ? date_i18n('H:i', strtotime($recurring_data['endtime'])) : $endtime;
6150 6150
 		$is_whole_day_event = !empty($recurring_data['all_day']) ? 1 : '';
6151 6151
 		$different_times = !empty($recurring_data['different_times']) ? true : false;
6152 6152
 	
6153
-		$recurring_pkg = geodir_event_recurring_pkg( $gd_post_info );
6154
-		$is_recurring = isset( $gd_post_info->is_recurring ) && (int)$gd_post_info->is_recurring == 0 ? false : true;
6153
+		$recurring_pkg = geodir_event_recurring_pkg($gd_post_info);
6154
+		$is_recurring = isset($gd_post_info->is_recurring) && (int) $gd_post_info->is_recurring == 0 ? false : true;
6155 6155
 			
6156 6156
 		if ($recurring_pkg && $is_recurring) {
6157 6157
 			$recurring_dates = $event_date;
@@ -6161,13 +6161,13 @@  discard block
 block discarded – undo
6161 6161
 			$recurring_type = !empty($recurring_data['repeat_type']) && in_array($recurring_data['repeat_type'], array('day', 'week', 'month', 'year', 'custom')) ? $recurring_data['repeat_type'] : 'custom';
6162 6162
 			
6163 6163
 			if (!empty($recurring_data['event_recurring_dates'])) {
6164
-				$event_recurring_dates = explode( ',', $recurring_data['event_recurring_dates'] );
6164
+				$event_recurring_dates = explode(',', $recurring_data['event_recurring_dates']);
6165 6165
 				
6166 6166
 				if (!empty($event_recurring_dates)) {
6167 6167
 					$recurring_dates = array();
6168 6168
 					
6169 6169
 					foreach ($event_recurring_dates as $date) {
6170
-						$recurring_dates[] = date_i18n( 'd/m/Y', strtotime( $date ) );
6170
+						$recurring_dates[] = date_i18n('d/m/Y', strtotime($date));
6171 6171
 					}
6172 6172
 					
6173 6173
 					$recurring_dates = implode(",", $recurring_dates);
@@ -6183,7 +6183,7 @@  discard block
 block discarded – undo
6183 6183
 						$times = array();
6184 6184
 						
6185 6185
 						foreach ($recurring_data['starttimes'] as $time) {
6186
-							$times[] = $time != '00:00:00' ? date_i18n( 'H:i', strtotime( $time ) ) : '00:00';
6186
+							$times[] = $time != '00:00:00' ? date_i18n('H:i', strtotime($time)) : '00:00';
6187 6187
 						}
6188 6188
 						
6189 6189
 						$event_starttimes = implode(",", $times);
@@ -6193,7 +6193,7 @@  discard block
 block discarded – undo
6193 6193
 						$times = array();
6194 6194
 						
6195 6195
 						foreach ($recurring_data['endtimes'] as $time) {
6196
-							$times[] = $time != '00:00:00' ? date_i18n( 'H:i', strtotime( $time ) ) : '00:00';
6196
+							$times[] = $time != '00:00:00' ? date_i18n('H:i', strtotime($time)) : '00:00';
6197 6197
 						}
6198 6198
 						
6199 6199
 						$event_endtimes = implode(",", $times);
@@ -6205,8 +6205,8 @@  discard block
 block discarded – undo
6205 6205
 					}
6206 6206
 				}
6207 6207
 			} else {
6208
-				$event_duration_days = isset($recurring_data['duration_x']) ? (int)$recurring_data['duration_x'] : 1;
6209
-				$recurring_interval = !empty($recurring_data['repeat_x']) && (int)$recurring_data['repeat_x'] > 0 ? $recurring_data['repeat_x'] : 1;
6208
+				$event_duration_days = isset($recurring_data['duration_x']) ? (int) $recurring_data['duration_x'] : 1;
6209
+				$recurring_interval = !empty($recurring_data['repeat_x']) && (int) $recurring_data['repeat_x'] > 0 ? $recurring_data['repeat_x'] : 1;
6210 6210
 				
6211 6211
 				if (($recurring_type == 'week' || $recurring_type == 'month') && !empty($recurring_data['repeat_days'])) {
6212 6212
 					$week_days = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
@@ -6222,11 +6222,11 @@  discard block
 block discarded – undo
6222 6222
 				}
6223 6223
 				
6224 6224
 				$recurring_week_nos = $recurring_type == 'month' && !empty($recurring_data['repeat_weeks']) ? implode(",", $recurring_data['repeat_weeks']) : $recurring_week_nos;
6225
-				if (!empty($recurring_data['repeat_end_type']) && (int)$recurring_data['repeat_end_type'] == 1) {
6226
-					$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'] ) ) : '';
6225
+				if (!empty($recurring_data['repeat_end_type']) && (int) $recurring_data['repeat_end_type'] == 1) {
6226
+					$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'])) : '';
6227 6227
 					$max_recurring_count = empty($recurring_end_date) ? 1 : '';
6228 6228
 				} else {
6229
-					$max_recurring_count = (!empty($recurring_data['max_repeat']) && (int)$recurring_data['max_repeat'] > 0 ? (int)$recurring_data['max_repeat'] : 1);
6229
+					$max_recurring_count = (!empty($recurring_data['max_repeat']) && (int) $recurring_data['max_repeat'] > 0 ? (int) $recurring_data['max_repeat'] : 1);
6230 6230
 				}
6231 6231
 			}
6232 6232
 		}
@@ -6290,9 +6290,9 @@  discard block
 block discarded – undo
6290 6290
  * @return array Event data array.
6291 6291
  */
6292 6292
 function geodir_imex_process_event_data($gd_post) {
6293
-	$recurring_pkg = geodir_event_recurring_pkg( (object)$gd_post );
6293
+	$recurring_pkg = geodir_event_recurring_pkg((object) $gd_post);
6294 6294
 
6295
-	$is_recurring = isset( $gd_post['is_recurring_event'] ) && (int)$gd_post['is_recurring_event'] == 0 ? false : true;
6295
+	$is_recurring = isset($gd_post['is_recurring_event']) && (int) $gd_post['is_recurring_event'] == 0 ? false : true;
6296 6296
 	$event_date = isset($gd_post['event_date']) && $gd_post['event_date'] != '' ? geodir_imex_get_date_ymd($gd_post['event_date']) : '';
6297 6297
 	$event_enddate = isset($gd_post['event_enddate']) && $gd_post['event_enddate'] != '' ? geodir_imex_get_date_ymd($gd_post['event_enddate']) : $event_date;
6298 6298
 	$all_day = isset($gd_post['is_whole_day_event']) && !empty($gd_post['is_whole_day_event']) ? true : false;
@@ -6339,17 +6339,17 @@  discard block
 block discarded – undo
6339 6339
 				$event_recurring_dates = implode(",", $event_recurring_dates);
6340 6340
 			}
6341 6341
 		} else {
6342
-			$duration_x = !empty( $gd_post['event_duration_days'] ) ? (int)$gd_post['event_duration_days'] : 1;
6343
-			$repeat_x = !empty( $gd_post['recurring_interval'] ) ? (int)$gd_post['recurring_interval'] : 1;
6344
-			$max_repeat = !empty( $gd_post['max_recurring_count'] ) ? (int)$gd_post['max_recurring_count'] : 1;
6345
-			$repeat_end = !empty( $gd_post['recurring_end_date'] ) ? geodir_imex_get_date_ymd($gd_post['recurring_end_date']) : '';
6342
+			$duration_x = !empty($gd_post['event_duration_days']) ? (int) $gd_post['event_duration_days'] : 1;
6343
+			$repeat_x = !empty($gd_post['recurring_interval']) ? (int) $gd_post['recurring_interval'] : 1;
6344
+			$max_repeat = !empty($gd_post['max_recurring_count']) ? (int) $gd_post['max_recurring_count'] : 1;
6345
+			$repeat_end = !empty($gd_post['recurring_end_date']) ? geodir_imex_get_date_ymd($gd_post['recurring_end_date']) : '';
6346 6346
 			
6347 6347
 			$repeat_end_type = $repeat_end != '' ? 1 : 0;
6348 6348
 			$max_repeat = $repeat_end != '' ? '' : $max_repeat;
6349 6349
 			
6350 6350
 			$week_days = array_flip(array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'));
6351 6351
 			
6352
-			$a_repeat_days = isset($gd_post['recurring_week_days']) && trim($gd_post['recurring_week_days'])!='' ? explode(',', trim($gd_post['recurring_week_days'])) : array();
6352
+			$a_repeat_days = isset($gd_post['recurring_week_days']) && trim($gd_post['recurring_week_days']) != '' ? explode(',', trim($gd_post['recurring_week_days'])) : array();
6353 6353
 			$repeat_days = array();
6354 6354
 			if (!empty($a_repeat_days)) {
6355 6355
 				foreach ($a_repeat_days as $repeat_day) {
@@ -6367,7 +6367,7 @@  discard block
 block discarded – undo
6367 6367
 			$repeat_weeks = array();
6368 6368
 			if (!empty($a_repeat_weeks)) {
6369 6369
 				foreach ($a_repeat_weeks as $repeat_week) {
6370
-					$repeat_weeks[] = (int)$repeat_week;
6370
+					$repeat_weeks[] = (int) $repeat_week;
6371 6371
 				}
6372 6372
 				
6373 6373
 				$repeat_weeks = array_unique($repeat_weeks);
@@ -6431,7 +6431,7 @@  discard block
 block discarded – undo
6431 6431
 
6432 6432
     $page_found = $wpdb->get_var(
6433 6433
         $wpdb->prepare(
6434
-            "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
6434
+            "SELECT ID FROM ".$wpdb->posts." WHERE post_name = %s LIMIT 1;",
6435 6435
             array($slug)
6436 6436
         )
6437 6437
     );
@@ -6486,7 +6486,7 @@  discard block
 block discarded – undo
6486 6486
  */
6487 6487
 function geodir_admin_upgrade_notice() {
6488 6488
     $class = "error";
6489
-    $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
6489
+    $message = __("Please update core GeoDirectory or some addons may not function correctly.", "geodirectory");
6490 6490
     echo"<div class=\"$class\"> <p>$message</p></div>";
6491 6491
 }
6492 6492
 
@@ -6498,7 +6498,7 @@  discard block
 block discarded – undo
6498 6498
  * @param (object) $r
6499 6499
  * @return (string) $output
6500 6500
  */
6501
-function geodire_admin_upgrade_notice( $plugin_data, $r )
6501
+function geodire_admin_upgrade_notice($plugin_data, $r)
6502 6502
 {
6503 6503
     // readme contents
6504 6504
     $args = array(
@@ -6506,7 +6506,7 @@  discard block
 block discarded – undo
6506 6506
         'redirection' => 5
6507 6507
     );
6508 6508
     $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt";
6509
-    $data       = wp_remote_get( $url, $args );
6509
+    $data = wp_remote_get($url, $args);
6510 6510
 
6511 6511
     if (!is_wp_error($data) && $data['response']['code'] == 200) {
6512 6512
 
@@ -6521,20 +6521,20 @@  discard block
 block discarded – undo
6521 6521
 function geodir_in_plugin_update_message($content) {
6522 6522
     // Output Upgrade Notice
6523 6523
     $matches        = null;
6524
-    $regexp         = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis';
6524
+    $regexp         = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*'.preg_quote(GEODIRECTORY_VERSION).'\s*=|$)~Uis';
6525 6525
     $upgrade_notice = '';
6526
-    if ( preg_match( $regexp, $content, $matches ) ) {
6527
-        if(empty($matches)){return;}
6526
+    if (preg_match($regexp, $content, $matches)) {
6527
+        if (empty($matches)) {return; }
6528 6528
 
6529
-        $version = trim( $matches[1] );
6530
-        if($version && $version>GEODIRECTORY_VERSION){
6529
+        $version = trim($matches[1]);
6530
+        if ($version && $version > GEODIRECTORY_VERSION) {
6531 6531
 
6532 6532
 
6533
-        $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
6534
-        if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
6533
+        $notices = (array) preg_split('~[\r\n]+~', trim($matches[2]));
6534
+        if (version_compare(GEODIRECTORY_VERSION, $version, '<')) {
6535 6535
             $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">';
6536
-            foreach ( $notices as $index => $line ) {
6537
-                $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
6536
+            foreach ($notices as $index => $line) {
6537
+                $upgrade_notice .= wp_kses_post(preg_replace('~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line));
6538 6538
             }
6539 6539
             $upgrade_notice .= '</div> ';
6540 6540
         }
@@ -6558,7 +6558,7 @@  discard block
 block discarded – undo
6558 6558
 		$default_language = $sitepress->get_default_language();
6559 6559
 		if ($current_language != 'all' && $current_language != $default_language) {
6560 6560
 	?>
6561
-	<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>
6561
+	<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>
6562 6562
 	<?php
6563 6563
 		}
6564 6564
 	}
@@ -6573,7 +6573,7 @@  discard block
 block discarded – undo
6573 6573
  * @param array Listing statuses to be skipped.
6574 6574
  */
6575 6575
 function geodir_imex_export_skip_statuses() {
6576
-    $statuses = array( 'trash', 'auto-draft' );
6576
+    $statuses = array('trash', 'auto-draft');
6577 6577
     
6578 6578
     /**
6579 6579
      * Filter the statuses to skip during GD export listings.
@@ -6583,7 +6583,7 @@  discard block
 block discarded – undo
6583 6583
      *
6584 6584
      * @param array $statuses Listing statuses to be skipped.
6585 6585
      */
6586
-    $statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses );
6586
+    $statuses = apply_filters('geodir_imex_export_skip_statuses', $statuses);
6587 6587
      
6588 6588
     return $statuses;
6589 6589
 }
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   +1299 added lines, -1299 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
 
@@ -84,18 +84,18 @@  discard block
 block discarded – undo
84 84
  */
85 85
 function geodir_conditional_admin_script_load()
86 86
 {
87
-    global $pagenow;
87
+	global $pagenow;
88 88
 	
89 89
 	// Get the current post type
90 90
 	$post_type = geodir_admin_current_post_type();
91 91
 	$geodir_post_types = geodir_get_posttypes();
92 92
     
93 93
 	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')) {
94
-        add_action('admin_enqueue_scripts', 'geodir_admin_scripts');
95
-        add_action('admin_enqueue_scripts', 'geodir_admin_styles');
96
-    }
94
+		add_action('admin_enqueue_scripts', 'geodir_admin_scripts');
95
+		add_action('admin_enqueue_scripts', 'geodir_admin_styles');
96
+	}
97 97
 
98
-    add_action('admin_enqueue_scripts', 'geodir_admin_styles_req');
98
+	add_action('admin_enqueue_scripts', 'geodir_admin_styles_req');
99 99
 
100 100
 }
101 101
 
@@ -129,12 +129,12 @@  discard block
 block discarded – undo
129 129
  */
130 130
 function create_default_admin_main_nav()
131 131
 {
132
-    add_filter('geodir_settings_tabs_array', 'geodir_default_admin_main_tabs', 1);
133
-    add_filter('geodir_settings_tabs_array', 'places_custom_fields_tab', 2);
134
-    add_filter('geodir_settings_tabs_array', 'geodir_compatibility_setting_tab', 90);
135
-    add_filter('geodir_settings_tabs_array', 'geodir_tools_setting_tab', 95);
136
-    add_filter('geodir_settings_tabs_array', 'geodir_extend_geodirectory_setting_tab', 100);
137
-    //add_filter('geodir_settings_tabs_array', 'geodir_hide_set_location_default',3);
132
+	add_filter('geodir_settings_tabs_array', 'geodir_default_admin_main_tabs', 1);
133
+	add_filter('geodir_settings_tabs_array', 'places_custom_fields_tab', 2);
134
+	add_filter('geodir_settings_tabs_array', 'geodir_compatibility_setting_tab', 90);
135
+	add_filter('geodir_settings_tabs_array', 'geodir_tools_setting_tab', 95);
136
+	add_filter('geodir_settings_tabs_array', 'geodir_extend_geodirectory_setting_tab', 100);
137
+	//add_filter('geodir_settings_tabs_array', 'geodir_hide_set_location_default',3);
138 138
 
139 139
 }
140 140
 
@@ -147,16 +147,16 @@  discard block
 block discarded – undo
147 147
  */
148 148
 function geodir_admin_list_columns()
149 149
 {
150
-    if ($post_types = geodir_get_posttypes()) {
150
+	if ($post_types = geodir_get_posttypes()) {
151 151
 
152
-        foreach ($post_types as $post_type):
153
-            add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100);
154
-            //Filter-Payment-Manager to show Package
155
-            add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2);
152
+		foreach ($post_types as $post_type):
153
+			add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100);
154
+			//Filter-Payment-Manager to show Package
155
+			add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2);
156 156
 
157
-            add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns');
158
-        endforeach;
159
-    }
157
+			add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns');
158
+		endforeach;
159
+	}
160 160
 }
161 161
 
162 162
 /**
@@ -169,15 +169,15 @@  discard block
 block discarded – undo
169 169
  */
170 170
 function geodir_default_admin_main_tabs($tabs)
171 171
 {
172
-    return $tabs = array(
173
-        'general_settings' => array('label' => __('General', 'geodirectory')),
174
-        'design_settings' => array('label' => __('Design', 'geodirectory')),
175
-        'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')),
176
-        'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')),
177
-        'notifications_settings' => array('label' => __('Notifications', 'geodirectory')),
178
-        'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')),
179
-
180
-    );
172
+	return $tabs = array(
173
+		'general_settings' => array('label' => __('General', 'geodirectory')),
174
+		'design_settings' => array('label' => __('Design', 'geodirectory')),
175
+		'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')),
176
+		'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')),
177
+		'notifications_settings' => array('label' => __('Notifications', 'geodirectory')),
178
+		'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')),
179
+
180
+	);
181 181
 }
182 182
 
183 183
 add_action('do_meta_boxes', 'geodir_remove_image_box');
@@ -190,16 +190,16 @@  discard block
 block discarded – undo
190 190
  */
191 191
 function geodir_remove_image_box()
192 192
 {
193
-    global $post;
193
+	global $post;
194 194
 
195
-    $geodir_posttypes = geodir_get_posttypes();
195
+	$geodir_posttypes = geodir_get_posttypes();
196 196
 
197
-    if (isset($post) && in_array($post->post_type, $geodir_posttypes)):
197
+	if (isset($post) && in_array($post->post_type, $geodir_posttypes)):
198 198
 
199
-        remove_meta_box('postimagediv', $post->post_type, 'side');
200
-        remove_meta_box('revisionsdiv', $post->post_type, 'normal');
199
+		remove_meta_box('postimagediv', $post->post_type, 'side');
200
+		remove_meta_box('revisionsdiv', $post->post_type, 'normal');
201 201
 
202
-    endif;
202
+	endif;
203 203
 
204 204
 }
205 205
 
@@ -214,26 +214,26 @@  discard block
 block discarded – undo
214 214
  */
215 215
 function geodir_meta_box_add()
216 216
 {
217
-    global $post;
217
+	global $post;
218 218
 
219
-    $geodir_post_types = geodir_get_posttypes('array');
220
-    $geodir_posttypes = array_keys($geodir_post_types);
219
+	$geodir_post_types = geodir_get_posttypes('array');
220
+	$geodir_posttypes = array_keys($geodir_post_types);
221 221
 
222
-    if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)):
222
+	if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)):
223 223
 
224
-        $geodir_posttype = $post->post_type;
225
-        $post_typename = geodir_ucwords($geodir_post_types[$geodir_posttype]['labels']['singular_name']);
224
+		$geodir_posttype = $post->post_type;
225
+		$post_typename = geodir_ucwords($geodir_post_types[$geodir_posttype]['labels']['singular_name']);
226 226
 
227
-        // Filter-Payment-Manager
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
-        // no need of this box as all fields moved to main information box
234
-        //add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
233
+		// no need of this box as all fields moved to main information box
234
+		//add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
235 235
 
236
-    endif;
236
+	endif;
237 237
 
238 238
 }
239 239
 
@@ -257,23 +257,23 @@  discard block
 block discarded – undo
257 257
 function geodir_hide_post_taxonomy_meta_boxes()
258 258
 {
259 259
 
260
-    $geodir_post_types = get_option('geodir_post_types');
260
+	$geodir_post_types = get_option('geodir_post_types');
261 261
 
262
-    if (!empty($geodir_post_types)) {
263
-        foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) {
262
+	if (!empty($geodir_post_types)) {
263
+		foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) {
264 264
 
265
-            $gd_taxonomy = geodir_get_taxonomies($geodir_post_type);
265
+			$gd_taxonomy = geodir_get_taxonomies($geodir_post_type);
266 266
 
267
-            if(!empty($gd_taxonomy)) {
268
-                foreach ($gd_taxonomy as $tax) {
267
+			if(!empty($gd_taxonomy)) {
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
-                }
273
-            }
272
+				}
273
+			}
274 274
 
275
-        }
276
-    }
275
+		}
276
+	}
277 277
 }
278 278
 
279 279
 add_filter('geodir_add_listing_map_restrict', 'geodir_add_listing_map_restrict');
@@ -287,12 +287,12 @@  discard block
 block discarded – undo
287 287
  */
288 288
 function geodir_add_listing_map_restrict($map_restirct)
289 289
 {
290
-    if (is_admin()) {
291
-        if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') {
292
-            $map_restirct = false;
293
-        }
294
-    }
295
-    return $map_restirct;
290
+	if (is_admin()) {
291
+		if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') {
292
+			$map_restirct = false;
293
+		}
294
+	}
295
+	return $map_restirct;
296 296
 }
297 297
 
298 298
 
@@ -311,16 +311,16 @@  discard block
 block discarded – undo
311 311
 function geodir_enable_editor_on_notifications($notification)
312 312
 {
313 313
 
314
-    if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
314
+	if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
315 315
 
316
-        foreach ($notification as $key => $value) {
317
-            if ($value['type'] == 'textarea')
318
-                $notification[$key]['type'] = 'editor';
319
-        }
316
+		foreach ($notification as $key => $value) {
317
+			if ($value['type'] == 'textarea')
318
+				$notification[$key]['type'] = 'editor';
319
+		}
320 320
 
321
-    }
321
+	}
322 322
 
323
-    return $notification;
323
+	return $notification;
324 324
 }
325 325
 
326 326
 
@@ -337,16 +337,16 @@  discard block
 block discarded – undo
337 337
 function geodir_enable_editor_on_design_settings($design_setting)
338 338
 {
339 339
 
340
-    if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
340
+	if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
341 341
 
342
-        foreach ($design_setting as $key => $value) {
343
-            if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content')
344
-                $design_setting[$key]['type'] = 'editor';
345
-        }
342
+		foreach ($design_setting as $key => $value) {
343
+			if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content')
344
+				$design_setting[$key]['type'] = 'editor';
345
+		}
346 346
 
347
-    }
347
+	}
348 348
 
349
-    return $design_setting;
349
+	return $design_setting;
350 350
 }
351 351
 
352 352
 /* ----------- START MANAGE CUSTOM FIELDS ---------------- */
@@ -367,16 +367,16 @@  discard block
 block discarded – undo
367 367
 function geodir_manage_available_fields($sub_tab)
368 368
 {
369 369
 
370
-    switch ($sub_tab) {
371
-        case 'custom_fields':
372
-            geodir_custom_available_fields();
373
-            break;
370
+	switch ($sub_tab) {
371
+		case 'custom_fields':
372
+			geodir_custom_available_fields();
373
+			break;
374 374
 
375
-        case 'sorting_options':
376
-            geodir_sorting_options_available_fields();
377
-            break;
375
+		case 'sorting_options':
376
+			geodir_sorting_options_available_fields();
377
+			break;
378 378
 
379
-    }
379
+	}
380 380
 }
381 381
 
382 382
 
@@ -392,16 +392,16 @@  discard block
 block discarded – undo
392 392
 function geodir_manage_selected_fields($sub_tab)
393 393
 {
394 394
 
395
-    switch ($sub_tab) {
396
-        case 'custom_fields':
397
-            geodir_custom_selected_fields();
398
-            break;
395
+	switch ($sub_tab) {
396
+		case 'custom_fields':
397
+			geodir_custom_selected_fields();
398
+			break;
399 399
 
400
-        case 'sorting_options':
401
-            geodir_sorting_options_selected_fields();
402
-            break;
400
+		case 'sorting_options':
401
+			geodir_sorting_options_selected_fields();
402
+			break;
403 403
 
404
-    }
404
+	}
405 405
 }
406 406
 
407 407
 /**
@@ -413,27 +413,27 @@  discard block
 block discarded – undo
413 413
  */
414 414
 function geodir_sorting_options_available_fields()
415 415
 {
416
-    global $wpdb;
417
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
418
-    ?>
416
+	global $wpdb;
417
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
418
+	?>
419 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
423
-        $sort_options = geodir_get_custom_sort_options($listing_type);
423
+		$sort_options = geodir_get_custom_sort_options($listing_type);
424 424
         
425
-        foreach ($sort_options as $key => $val) {
426
-            $val = stripslashes_deep($val); // strip slashes
427
-
428
-            $check_html_variable = $wpdb->get_var(
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",
431
-                    array($val['htmlvar_name'], $listing_type, $val['field_type'])
432
-                )
433
-            );
425
+		foreach ($sort_options as $key => $val) {
426
+			$val = stripslashes_deep($val); // strip slashes
427
+
428
+			$check_html_variable = $wpdb->get_var(
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",
431
+					array($val['htmlvar_name'], $listing_type, $val['field_type'])
432
+				)
433
+			);
434 434
             
435
-            $display = $check_html_variable ? ' style="display:none;"' : '';
436
-            ?>
435
+			$display = $check_html_variable ? ' style="display:none;"' : '';
436
+			?>
437 437
             <li <?php echo $display;?>>
438 438
             <a id="gt-<?php echo $val['field_type'];?>-_-<?php echo $val['htmlvar_name'];?>"
439 439
                title="<?php echo $val['site_title'];?>"
@@ -441,8 +441,8 @@  discard block
 block discarded – undo
441 441
                href="javascript:void(0);"><b></b><?php _e($val['site_title'], 'geodirectory');?></a>
442 442
             </li>
443 443
             <?php
444
-        }
445
-    ?>
444
+		}
445
+	?>
446 446
     </ul>
447 447
     <?php
448 448
 }
@@ -456,28 +456,28 @@  discard block
 block discarded – undo
456 456
  */
457 457
 function geodir_sorting_options_selected_fields()
458 458
 {
459
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
460
-    ?>
459
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
460
+	?>
461 461
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
462 462
     <ul class="core">
463 463
     <?php 
464
-        global $wpdb;
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
-        if (!empty($fields)) {
469
-            foreach ($fields as $field) {
470
-                //$result_str = $field->id;
471
-                $result_str = $field;
472
-                $field_type = $field->field_type;
473
-                $field_ins_upd = 'display';
468
+		if (!empty($fields)) {
469
+			foreach ($fields as $field) {
470
+				//$result_str = $field->id;
471
+				$result_str = $field;
472
+				$field_type = $field->field_type;
473
+				$field_ins_upd = 'display';
474 474
 
475
-                $default = false;
475
+				$default = false;
476 476
 
477
-                geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default);
478
-            }
479
-        }
480
-    ?>
477
+				geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default);
478
+			}
479
+		}
480
+	?>
481 481
     </ul>
482 482
     <?php
483 483
 }
@@ -490,8 +490,8 @@  discard block
 block discarded – undo
490 490
  */
491 491
 function geodir_custom_available_fields()
492 492
 {
493
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
494
-    ?>
493
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
494
+	?>
495 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">
@@ -542,25 +542,25 @@  discard block
 block discarded – undo
542 542
  */
543 543
 function geodir_custom_selected_fields()
544 544
 {
545
-    $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
546
-    ?>
545
+	$listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place';
546
+	?>
547 547
     <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/>
548 548
     <ul class="core">
549 549
     <?php 
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)));
552
-
553
-        if (!empty($fields)) {
554
-            foreach ($fields as $field) {
555
-                //$result_str = $field->id;
556
-                $result_str = $field;
557
-                $field_type = $field->field_type;
558
-                $field_ins_upd = 'display';
559
-
560
-                geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd);
561
-            }
562
-        }
563
-        ?></ul>
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)));
552
+
553
+		if (!empty($fields)) {
554
+			foreach ($fields as $field) {
555
+				//$result_str = $field->id;
556
+				$result_str = $field;
557
+				$field_type = $field->field_type;
558
+				$field_ins_upd = 'display';
559
+
560
+				geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd);
561
+			}
562
+		}
563
+		?></ul>
564 564
 <?php
565 565
 
566 566
 }
@@ -579,16 +579,16 @@  discard block
 block discarded – undo
579 579
 function geodir_custom_fields_panel_head($heading, $sub_tab, $listing_type)
580 580
 {
581 581
 
582
-    switch ($sub_tab) {
583
-        case 'custom_fields':
584
-            $heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
585
-            break;
582
+	switch ($sub_tab) {
583
+		case 'custom_fields':
584
+			$heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
585
+			break;
586 586
 
587
-        case 'sorting_options':
588
-            $heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
589
-            break;
590
-    }
591
-    return $heading;
587
+		case 'sorting_options':
588
+			$heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
589
+			break;
590
+	}
591
+	return $heading;
592 592
 }
593 593
 
594 594
 
@@ -606,16 +606,16 @@  discard block
 block discarded – undo
606 606
 function geodir_cf_panel_available_fields_head($heading, $sub_tab, $listing_type)
607 607
 {
608 608
 
609
-    switch ($sub_tab) {
610
-        case 'custom_fields':
611
-            $heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type));
612
-            break;
609
+	switch ($sub_tab) {
610
+		case 'custom_fields':
611
+			$heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type));
612
+			break;
613 613
 
614
-        case 'sorting_options':
615
-            $heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type));
616
-            break;
617
-    }
618
-    return $heading;
614
+		case 'sorting_options':
615
+			$heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type));
616
+			break;
617
+	}
618
+	return $heading;
619 619
 }
620 620
 
621 621
 
@@ -633,16 +633,16 @@  discard block
 block discarded – undo
633 633
 function geodir_cf_panel_available_fields_note($note, $sub_tab, $listing_type)
634 634
 {
635 635
 
636
-    switch ($sub_tab) {
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));;
639
-            break;
636
+	switch ($sub_tab) {
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));;
639
+			break;
640 640
 
641
-        case 'sorting_options':
642
-            $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));
643
-            break;
644
-    }
645
-    return $note;
641
+		case 'sorting_options':
642
+			$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));
643
+			break;
644
+	}
645
+	return $note;
646 646
 }
647 647
 
648 648
 
@@ -660,16 +660,16 @@  discard block
 block discarded – undo
660 660
 function geodir_cf_panel_selected_fields_head($heading, $sub_tab, $listing_type)
661 661
 {
662 662
 
663
-    switch ($sub_tab) {
664
-        case 'custom_fields':
665
-            $heading = sprintf(__('List of fields those will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type));
666
-            break;
663
+	switch ($sub_tab) {
664
+		case 'custom_fields':
665
+			$heading = sprintf(__('List of fields those will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type));
666
+			break;
667 667
 
668
-        case 'sorting_options':
669
-            $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));
670
-            break;
671
-    }
672
-    return $heading;
668
+		case 'sorting_options':
669
+			$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));
670
+			break;
671
+	}
672
+	return $heading;
673 673
 }
674 674
 
675 675
 
@@ -687,16 +687,16 @@  discard block
 block discarded – undo
687 687
 function geodir_cf_panel_selected_fields_note($note, $sub_tab, $listing_type)
688 688
 {
689 689
 
690
-    switch ($sub_tab) {
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));;
693
-            break;
690
+	switch ($sub_tab) {
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));;
693
+			break;
694 694
 
695
-        case 'sorting_options':
696
-            $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));
697
-            break;
698
-    }
699
-    return $note;
695
+		case 'sorting_options':
696
+			$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));
697
+			break;
698
+	}
699
+	return $note;
700 700
 }
701 701
 
702 702
 
@@ -712,16 +712,16 @@  discard block
 block discarded – undo
712 712
  */
713 713
 function geodir_remove_unnecessary_fields()
714 714
 {
715
-    global $wpdb, $plugin_prefix;
715
+	global $wpdb, $plugin_prefix;
716 716
 
717
-    if (!get_option('geodir_remove_unnecessary_fields')) {
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
-        update_option('geodir_remove_unnecessary_fields', '1');
722
+		update_option('geodir_remove_unnecessary_fields', '1');
723 723
 
724
-    }
724
+	}
725 725
 
726 726
 }
727 727
 
@@ -739,25 +739,25 @@  discard block
 block discarded – undo
739 739
  */
740 740
 function geodir_admin_ajax_handler()
741 741
 {
742
-    if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') {
743
-        $geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action'];
744
-        switch ($geodir_admin_ajax_action) {
745
-            case 'diagnosis' :
746
-                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
747
-                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
748
-                call_user_func('geodir_diagnose_' . $diagnose_this);
749
-                exit();
750
-                break;
751
-
752
-            case 'diagnosis-fix' :
753
-                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
754
-                    $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
755
-                call_user_func('geodir_diagnose_' . $diagnose_this);
756
-                exit();
757
-                break;
758
-        }
759
-    }
760
-    exit();
742
+	if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') {
743
+		$geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action'];
744
+		switch ($geodir_admin_ajax_action) {
745
+			case 'diagnosis' :
746
+				if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
747
+					$diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
748
+				call_user_func('geodir_diagnose_' . $diagnose_this);
749
+				exit();
750
+				break;
751
+
752
+			case 'diagnosis-fix' :
753
+				if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '')
754
+					$diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']);
755
+				call_user_func('geodir_diagnose_' . $diagnose_this);
756
+				exit();
757
+				break;
758
+		}
759
+	}
760
+	exit();
761 761
 }
762 762
 
763 763
 
@@ -775,127 +775,127 @@  discard block
 block discarded – undo
775 775
  */
776 776
 function geodir_diagnose_multisite_table($filter_arr, $table, $tabel_name, $fix)
777 777
 {
778
-    global $wpdb;
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>";
782
-        $filter_arr['is_error_during_diagnose'] = true;
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>";
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>";
788
-        $filter_arr['is_error_during_diagnose'] = true;
789
-
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
793
-
794
-            if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
795
-                //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
796
-
797
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
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>";
801
-                } else {
802
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
803
-                }
804
-
805
-            } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
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
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>";
812
-                } else {
813
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
814
-                }
815
-
816
-            } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
817
-
818
-                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
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>";
822
-                } else {
823
-                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
824
-                }
825
-
826
-            }
827
-
828
-        }
829
-
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>";
833
-        $filter_arr['is_error_during_diagnose'] = true;
834
-
835
-        if ($fix) {
836
-            if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
837
-                if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
838
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
839
-                } else {
840
-                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
841
-                }
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>";
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>";
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>";
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>";
853
-                }
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>";
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>";
859
-                }
860
-            }
861
-        }
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>";
865
-        $filter_arr['is_error_during_diagnose'] = true;
866
-
867
-        if ($fix) {
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>";
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>";
873
-            }
874
-
875
-        }
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>";
879
-        $filter_arr['is_error_during_diagnose'] = true;
880
-
881
-        if ($fix) {
882
-            // if original table does not exist try deleting db_vers of all addons so the initial db_install scripts run;
883
-            delete_option('geodirlocation_db_version');
884
-            delete_option('geodirevents_db_version');
885
-            delete_option('geodir_reviewrating_db_version');
886
-            delete_option('gdevents_db_version');
887
-            delete_option('geodirectory_db_version');
888
-            delete_option('geodirclaim_db_version');
889
-            delete_option('geodir_custom_posts_db_version');
890
-            delete_option('geodir_reviewratings_db_version');
891
-            delete_option('geodiradvancesearch_db_version');
892
-            $filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
893
-        }
894
-
895
-    } else {
896
-        $filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
897
-    }
898
-    return $filter_arr;
778
+	global $wpdb;
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>";
782
+		$filter_arr['is_error_during_diagnose'] = true;
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>";
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>";
788
+		$filter_arr['is_error_during_diagnose'] = true;
789
+
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
793
+
794
+			if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
795
+				//$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
796
+
797
+				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
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>";
801
+				} else {
802
+					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
803
+				}
804
+
805
+			} elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
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
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>";
812
+				} else {
813
+					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
814
+				}
815
+
816
+			} elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
817
+
818
+				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
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>";
822
+				} else {
823
+					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
824
+				}
825
+
826
+			}
827
+
828
+		}
829
+
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>";
833
+		$filter_arr['is_error_during_diagnose'] = true;
834
+
835
+		if ($fix) {
836
+			if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
837
+				if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
838
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
839
+				} else {
840
+					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
841
+				}
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>";
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>";
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>";
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>";
853
+				}
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>";
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>";
859
+				}
860
+			}
861
+		}
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>";
865
+		$filter_arr['is_error_during_diagnose'] = true;
866
+
867
+		if ($fix) {
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>";
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>";
873
+			}
874
+
875
+		}
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>";
879
+		$filter_arr['is_error_during_diagnose'] = true;
880
+
881
+		if ($fix) {
882
+			// if original table does not exist try deleting db_vers of all addons so the initial db_install scripts run;
883
+			delete_option('geodirlocation_db_version');
884
+			delete_option('geodirevents_db_version');
885
+			delete_option('geodir_reviewrating_db_version');
886
+			delete_option('gdevents_db_version');
887
+			delete_option('geodirectory_db_version');
888
+			delete_option('geodirclaim_db_version');
889
+			delete_option('geodir_custom_posts_db_version');
890
+			delete_option('geodir_reviewratings_db_version');
891
+			delete_option('geodiradvancesearch_db_version');
892
+			$filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
893
+		}
894
+
895
+	} else {
896
+		$filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
897
+	}
898
+	return $filter_arr;
899 899
 }
900 900
 
901 901
 
@@ -909,53 +909,53 @@  discard block
 block discarded – undo
909 909
  */
910 910
 function geodir_diagnose_tags_sync()
911 911
 {
912
-    global $wpdb, $plugin_prefix;
913
-    $fix = isset($_POST['fix']) ? true : false;
914
-
915
-    //if($fix){echo 'true';}else{echo 'false';}
916
-    $is_error_during_diagnose = false;
917
-    $output_str = '';
918
-
919
-
920
-    $all_postypes = geodir_get_posttypes();
921
-
922
-    if (!empty($all_postypes)) {
923
-        foreach ($all_postypes as $key) {
924
-            // update each GD CPT
925
-            $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d");
926
-
927
-            if (!empty($posts)) {
928
-
929
-                foreach ($posts as $p) {
930
-                    $p->post_type = $key;
931
-                    $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
932
-                    if (empty($raw_tags)) {
933
-                        $post_tags = '';
934
-                    } else {
935
-                        $post_tags = implode(",", $raw_tags);
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));
939
-
940
-                }
941
-                $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
942
-            }
943
-
944
-        }
945
-
946
-    }
947
-
948
-    if ($is_error_during_diagnose) {
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' />";
951
-    } else {
952
-        $info_div_class = "geodir_noproblem_info";
953
-        $fix_button_txt = '';
954
-    }
955
-    echo "<ul class='$info_div_class'>";
956
-    echo $output_str;
957
-    echo $fix_button_txt;
958
-    echo "</ul>";
912
+	global $wpdb, $plugin_prefix;
913
+	$fix = isset($_POST['fix']) ? true : false;
914
+
915
+	//if($fix){echo 'true';}else{echo 'false';}
916
+	$is_error_during_diagnose = false;
917
+	$output_str = '';
918
+
919
+
920
+	$all_postypes = geodir_get_posttypes();
921
+
922
+	if (!empty($all_postypes)) {
923
+		foreach ($all_postypes as $key) {
924
+			// update each GD CPT
925
+			$posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d");
926
+
927
+			if (!empty($posts)) {
928
+
929
+				foreach ($posts as $p) {
930
+					$p->post_type = $key;
931
+					$raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
932
+					if (empty($raw_tags)) {
933
+						$post_tags = '';
934
+					} else {
935
+						$post_tags = implode(",", $raw_tags);
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));
939
+
940
+				}
941
+				$output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
942
+			}
943
+
944
+		}
945
+
946
+	}
947
+
948
+	if ($is_error_during_diagnose) {
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' />";
951
+	} else {
952
+		$info_div_class = "geodir_noproblem_info";
953
+		$fix_button_txt = '';
954
+	}
955
+	echo "<ul class='$info_div_class'>";
956
+	echo $output_str;
957
+	echo $fix_button_txt;
958
+	echo "</ul>";
959 959
 
960 960
 }
961 961
 
@@ -971,75 +971,75 @@  discard block
 block discarded – undo
971 971
  */
972 972
 function geodir_diagnose_cats_sync()
973 973
 {
974
-    global $wpdb, $plugin_prefix;
975
-    $fix = isset($_POST['fix']) ? true : false;
974
+	global $wpdb, $plugin_prefix;
975
+	$fix = isset($_POST['fix']) ? true : false;
976 976
 
977
-    //if($fix){echo 'true';}else{echo 'false';}
978
-    $is_error_during_diagnose = false;
979
-    $output_str = '';
977
+	//if($fix){echo 'true';}else{echo 'false';}
978
+	$is_error_during_diagnose = false;
979
+	$output_str = '';
980 980
 
981 981
 
982
-    $all_postypes = geodir_get_posttypes();
982
+	$all_postypes = geodir_get_posttypes();
983 983
 
984
-    if (!empty($all_postypes)) {
985
-        foreach ($all_postypes as $key) {
986
-            // update each GD CTP
987
-            $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
984
+	if (!empty($all_postypes)) {
985
+		foreach ($all_postypes as $key) {
986
+			// update each GD CTP
987
+			$posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
988 988
 
989
-            if (!empty($posts)) {
989
+			if (!empty($posts)) {
990 990
 
991
-                foreach ($posts as $p) {
992
-                    $p->post_type = $key;
993
-                    $raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
991
+				foreach ($posts as $p) {
992
+					$p->post_type = $key;
993
+					$raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
994 994
 
995
-                    if (empty($raw_cats)) {
996
-                        $post_categories = get_post_meta($p->post_id, 'post_categories', true);
995
+					if (empty($raw_cats)) {
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) {
1001
-                                if (is_numeric($cat_part)) {
1002
-                                    $raw_cats[] = (int)$cat_part;
1003
-                                }
1004
-                            }
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
+								if (is_numeric($cat_part)) {
1002
+									$raw_cats[] = (int)$cat_part;
1003
+								}
1004
+							}
1005 1005
 
1006
-                        }
1006
+						}
1007 1007
 
1008
-                        if (!empty($raw_cats)) {
1009
-                            $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category');
1008
+						if (!empty($raw_cats)) {
1009
+							$term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category');
1010 1010
 
1011
-                        }
1011
+						}
1012 1012
 
1013
-                    }
1013
+					}
1014 1014
 
1015 1015
 
1016
-                    if (empty($raw_cats)) {
1017
-                        $post_cats = '';
1018
-                    } else {
1019
-                        $post_cats = ',' . implode(",", $raw_cats) . ',';
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));
1023
-                }
1016
+					if (empty($raw_cats)) {
1017
+						$post_cats = '';
1018
+					} else {
1019
+						$post_cats = ',' . implode(",", $raw_cats) . ',';
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));
1023
+				}
1024 1024
 
1025
-            }
1026
-            $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1025
+			}
1026
+			$output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
1027 1027
 
1028
-        }
1028
+		}
1029 1029
 
1030
-    }
1030
+	}
1031 1031
 
1032
-    if ($is_error_during_diagnose) {
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' />";
1035
-    } else {
1036
-        $info_div_class = "geodir_noproblem_info";
1037
-        $fix_button_txt = '';
1038
-    }
1039
-    echo "<ul class='$info_div_class'>";
1040
-    echo $output_str;
1041
-    echo $fix_button_txt;
1042
-    echo "</ul>";
1032
+	if ($is_error_during_diagnose) {
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' />";
1035
+	} else {
1036
+		$info_div_class = "geodir_noproblem_info";
1037
+		$fix_button_txt = '';
1038
+	}
1039
+	echo "<ul class='$info_div_class'>";
1040
+	echo $output_str;
1041
+	echo $fix_button_txt;
1042
+	echo "</ul>";
1043 1043
 
1044 1044
 }
1045 1045
 
@@ -1053,61 +1053,61 @@  discard block
 block discarded – undo
1053 1053
  */
1054 1054
 function geodir_diagnose_version_clear()
1055 1055
 {
1056
-    global $wpdb, $plugin_prefix;
1057
-    $fix = isset($_POST['fix']) ? true : false;
1058
-
1059
-    //if($fix){echo 'true';}else{echo 'false';}
1060
-    $is_error_during_diagnose = false;
1061
-    $output_str = '';
1062
-
1063
-
1064
-    $gd_arr = array('GeoDirectory' => 'geodirectory_db_version',
1065
-        'Payment Manager' => 'geodir_payments_db_version',
1066
-        'GeoDirectory Framework' => 'gdf_db_version',
1067
-        'Advanced Search' => 'geodiradvancesearch_db_version',
1068
-        'Review Rating Manager' => 'geodir_reviewratings_db_version',
1069
-        'Claim Manager' => 'geodirclaim_db_version',
1070
-        'CPT Manager' => 'geodir_custom_posts_db_version',
1071
-        'Location Manager' => 'geodirlocation_db_version',
1072
-        'Payment Manager' => 'geodir_payments_db_version',
1073
-        'Events Manager' => 'geodirevents_db_version',
1074
-    );
1075
-
1076
-    /**
1077
-     * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers.
1078
-     *
1079
-     * @since 1.0.0
1080
-     * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',...
1081
-     */
1082
-    $ver_arr = apply_filters('geodir_db_version_name', $gd_arr);
1083
-
1084
-    if (!empty($ver_arr)) {
1085
-        foreach ($ver_arr as $key => $val) {
1086
-            if (delete_option($val)) {
1087
-                $output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
1088
-            } else {
1089
-                $output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
1090
-            }
1091
-
1092
-        }
1093
-
1094
-        if ($output_str) {
1095
-            $output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
1096
-        }
1097
-
1098
-    }
1099
-
1100
-    if ($is_error_during_diagnose) {
1101
-        $info_div_class = "geodir_problem_info";
1102
-        $fix_button_txt = "";
1103
-    } else {
1104
-        $info_div_class = "geodir_noproblem_info";
1105
-        $fix_button_txt = '';
1106
-    }
1107
-    echo "<ul class='$info_div_class'>";
1108
-    echo $output_str;
1109
-    echo $fix_button_txt;
1110
-    echo "</ul>";
1056
+	global $wpdb, $plugin_prefix;
1057
+	$fix = isset($_POST['fix']) ? true : false;
1058
+
1059
+	//if($fix){echo 'true';}else{echo 'false';}
1060
+	$is_error_during_diagnose = false;
1061
+	$output_str = '';
1062
+
1063
+
1064
+	$gd_arr = array('GeoDirectory' => 'geodirectory_db_version',
1065
+		'Payment Manager' => 'geodir_payments_db_version',
1066
+		'GeoDirectory Framework' => 'gdf_db_version',
1067
+		'Advanced Search' => 'geodiradvancesearch_db_version',
1068
+		'Review Rating Manager' => 'geodir_reviewratings_db_version',
1069
+		'Claim Manager' => 'geodirclaim_db_version',
1070
+		'CPT Manager' => 'geodir_custom_posts_db_version',
1071
+		'Location Manager' => 'geodirlocation_db_version',
1072
+		'Payment Manager' => 'geodir_payments_db_version',
1073
+		'Events Manager' => 'geodirevents_db_version',
1074
+	);
1075
+
1076
+	/**
1077
+	 * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers.
1078
+	 *
1079
+	 * @since 1.0.0
1080
+	 * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',...
1081
+	 */
1082
+	$ver_arr = apply_filters('geodir_db_version_name', $gd_arr);
1083
+
1084
+	if (!empty($ver_arr)) {
1085
+		foreach ($ver_arr as $key => $val) {
1086
+			if (delete_option($val)) {
1087
+				$output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
1088
+			} else {
1089
+				$output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
1090
+			}
1091
+
1092
+		}
1093
+
1094
+		if ($output_str) {
1095
+			$output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
1096
+		}
1097
+
1098
+	}
1099
+
1100
+	if ($is_error_during_diagnose) {
1101
+		$info_div_class = "geodir_problem_info";
1102
+		$fix_button_txt = "";
1103
+	} else {
1104
+		$info_div_class = "geodir_noproblem_info";
1105
+		$fix_button_txt = '';
1106
+	}
1107
+	echo "<ul class='$info_div_class'>";
1108
+	echo $output_str;
1109
+	echo $fix_button_txt;
1110
+	echo "</ul>";
1111 1111
 
1112 1112
 }
1113 1113
 
@@ -1121,59 +1121,59 @@  discard block
 block discarded – undo
1121 1121
  */
1122 1122
 function geodir_diagnose_ratings()
1123 1123
 {
1124
-    global $wpdb;
1125
-    $fix = isset($_POST['fix']) ? true : false;
1126
-
1127
-    //if($fix){echo 'true';}else{echo 'false';}
1128
-    $is_error_during_diagnose = false;
1129
-    $output_str = '';
1130
-
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>";
1134
-        $is_error_during_diagnose = true;
1135
-
1136
-        if ($fix) {
1137
-            if (geodir_fix_review_location()) {
1138
-                $output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
1139
-            } else {
1140
-                $output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
1141
-            }
1142
-        }
1143
-
1144
-    } else {
1145
-        $output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
1146
-    }
1147
-
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>";
1151
-        $is_error_during_diagnose = true;
1152
-
1153
-        if ($fix) {
1154
-            if (geodir_fix_review_content()) {
1155
-                $output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
1156
-            } else {
1157
-                $output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
1158
-            }
1159
-        }
1160
-
1161
-    } else {
1162
-        $output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
1163
-    }
1164
-
1165
-
1166
-    if ($is_error_during_diagnose) {
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' />";
1169
-    } else {
1170
-        $info_div_class = "geodir_noproblem_info";
1171
-        $fix_button_txt = '';
1172
-    }
1173
-    echo "<ul class='$info_div_class'>";
1174
-    echo $output_str;
1175
-    echo $fix_button_txt;
1176
-    echo "</ul>";
1124
+	global $wpdb;
1125
+	$fix = isset($_POST['fix']) ? true : false;
1126
+
1127
+	//if($fix){echo 'true';}else{echo 'false';}
1128
+	$is_error_during_diagnose = false;
1129
+	$output_str = '';
1130
+
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>";
1134
+		$is_error_during_diagnose = true;
1135
+
1136
+		if ($fix) {
1137
+			if (geodir_fix_review_location()) {
1138
+				$output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
1139
+			} else {
1140
+				$output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
1141
+			}
1142
+		}
1143
+
1144
+	} else {
1145
+		$output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
1146
+	}
1147
+
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>";
1151
+		$is_error_during_diagnose = true;
1152
+
1153
+		if ($fix) {
1154
+			if (geodir_fix_review_content()) {
1155
+				$output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
1156
+			} else {
1157
+				$output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
1158
+			}
1159
+		}
1160
+
1161
+	} else {
1162
+		$output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
1163
+	}
1164
+
1165
+
1166
+	if ($is_error_during_diagnose) {
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' />";
1169
+	} else {
1170
+		$info_div_class = "geodir_noproblem_info";
1171
+		$fix_button_txt = '';
1172
+	}
1173
+	echo "<ul class='$info_div_class'>";
1174
+	echo $output_str;
1175
+	echo $fix_button_txt;
1176
+	echo "</ul>";
1177 1177
 
1178 1178
 }
1179 1179
 
@@ -1187,57 +1187,57 @@  discard block
 block discarded – undo
1187 1187
  */
1188 1188
 function geodir_diagnose_multisite_conversion()
1189 1189
 {
1190
-    global $wpdb;
1191
-    $fix = isset($_POST['fix']) ? true : false;
1192
-    //if($fix){echo 'true';}else{echo 'false';}
1193
-    $is_error_during_diagnose = false;
1194
-    $output_str = '';
1195
-
1196
-    $filter_arr = array();
1197
-    $filter_arr['output_str'] = $output_str;
1198
-    $filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose;
1199
-    $table_arr = array('geodir_countries' => __('Countries', 'geodirectory'),
1200
-        'geodir_custom_fields' => __('Custom fields', 'geodirectory'),
1201
-        'geodir_post_icon' => __('Post icon', 'geodirectory'),
1202
-        'geodir_attachments' => __('Attachments', 'geodirectory'),
1203
-        'geodir_post_review' => __('Reviews', 'geodirectory'),
1204
-        'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'),
1205
-        'geodir_gd_place_detail' => __('Place detail', 'geodirectory')
1206
-    );
1207
-
1208
-    // allow other addons to hook in and add their checks
1209
-
1210
-    /**
1211
-     * Filter the array of tables.
1212
-     *
1213
-     * 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.
1214
-     *
1215
-     * @since 1.0.0
1216
-     * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),...
1217
-     */
1218
-    $table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr);
1219
-
1220
-    foreach ($table_arr as $table => $table_name) {
1221
-        // Diagnose table
1222
-        $filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix);
1223
-    }
1224
-
1225
-
1226
-    $output_str = $filter_arr['output_str'];
1227
-    $is_error_during_diagnose = $filter_arr['is_error_during_diagnose'];
1228
-
1229
-
1230
-    if ($is_error_during_diagnose) {
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' />";
1233
-    } else {
1234
-        $info_div_class = "geodir_noproblem_info";
1235
-        $fix_button_txt = '';
1236
-    }
1237
-    echo "<ul class='$info_div_class'>";
1238
-    echo $output_str;
1239
-    echo $fix_button_txt;
1240
-    echo "</ul>";
1190
+	global $wpdb;
1191
+	$fix = isset($_POST['fix']) ? true : false;
1192
+	//if($fix){echo 'true';}else{echo 'false';}
1193
+	$is_error_during_diagnose = false;
1194
+	$output_str = '';
1195
+
1196
+	$filter_arr = array();
1197
+	$filter_arr['output_str'] = $output_str;
1198
+	$filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose;
1199
+	$table_arr = array('geodir_countries' => __('Countries', 'geodirectory'),
1200
+		'geodir_custom_fields' => __('Custom fields', 'geodirectory'),
1201
+		'geodir_post_icon' => __('Post icon', 'geodirectory'),
1202
+		'geodir_attachments' => __('Attachments', 'geodirectory'),
1203
+		'geodir_post_review' => __('Reviews', 'geodirectory'),
1204
+		'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'),
1205
+		'geodir_gd_place_detail' => __('Place detail', 'geodirectory')
1206
+	);
1207
+
1208
+	// allow other addons to hook in and add their checks
1209
+
1210
+	/**
1211
+	 * Filter the array of tables.
1212
+	 *
1213
+	 * 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.
1214
+	 *
1215
+	 * @since 1.0.0
1216
+	 * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),...
1217
+	 */
1218
+	$table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr);
1219
+
1220
+	foreach ($table_arr as $table => $table_name) {
1221
+		// Diagnose table
1222
+		$filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix);
1223
+	}
1224
+
1225
+
1226
+	$output_str = $filter_arr['output_str'];
1227
+	$is_error_during_diagnose = $filter_arr['is_error_during_diagnose'];
1228
+
1229
+
1230
+	if ($is_error_during_diagnose) {
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' />";
1233
+	} else {
1234
+		$info_div_class = "geodir_noproblem_info";
1235
+		$fix_button_txt = '';
1236
+	}
1237
+	echo "<ul class='$info_div_class'>";
1238
+	echo $output_str;
1239
+	echo $fix_button_txt;
1240
+	echo "</ul>";
1241 1241
 }
1242 1242
 
1243 1243
 /**
@@ -1255,39 +1255,39 @@  discard block
 block discarded – undo
1255 1255
  */
1256 1256
 function geodir_fix_virtual_page($slug, $page_title, $old_id, $option)
1257 1257
 {
1258
-    global $wpdb, $current_user;
1259
-
1260
-    if (!empty($old_id)) {
1261
-        wp_delete_post($old_id, true);
1262
-    }//delete post if already there
1263
-    else {
1264
-        $page_found = $wpdb->get_var(
1265
-            $wpdb->prepare(
1266
-                "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
1267
-                array($slug)
1268
-            )
1269
-        );
1270
-        wp_delete_post($page_found, true);
1271
-
1272
-    }
1273
-
1274
-    $page_data = array(
1275
-        'post_status' => 'publish',
1276
-        'post_type' => 'page',
1277
-        'post_author' => $current_user->ID,
1278
-        'post_name' => $slug,
1279
-        'post_title' => $page_title,
1280
-        'post_content' => '',
1281
-        'post_parent' => 0,
1282
-        'comment_status' => 'closed'
1283
-    );
1284
-    $page_id = wp_insert_post($page_data);
1285
-    update_option($option, $page_id);
1286
-    if ($page_id) {
1287
-        return true;
1288
-    } else {
1289
-        return false;
1290
-    }
1258
+	global $wpdb, $current_user;
1259
+
1260
+	if (!empty($old_id)) {
1261
+		wp_delete_post($old_id, true);
1262
+	}//delete post if already there
1263
+	else {
1264
+		$page_found = $wpdb->get_var(
1265
+			$wpdb->prepare(
1266
+				"SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;",
1267
+				array($slug)
1268
+			)
1269
+		);
1270
+		wp_delete_post($page_found, true);
1271
+
1272
+	}
1273
+
1274
+	$page_data = array(
1275
+		'post_status' => 'publish',
1276
+		'post_type' => 'page',
1277
+		'post_author' => $current_user->ID,
1278
+		'post_name' => $slug,
1279
+		'post_title' => $page_title,
1280
+		'post_content' => '',
1281
+		'post_parent' => 0,
1282
+		'comment_status' => 'closed'
1283
+	);
1284
+	$page_id = wp_insert_post($page_data);
1285
+	update_option($option, $page_id);
1286
+	if ($page_id) {
1287
+		return true;
1288
+	} else {
1289
+		return false;
1290
+	}
1291 1291
 }
1292 1292
 
1293 1293
 /**
@@ -1299,212 +1299,212 @@  discard block
 block discarded – undo
1299 1299
  */
1300 1300
 function geodir_diagnose_default_pages()
1301 1301
 {
1302
-    global $wpdb;
1303
-    $is_error_during_diagnose = false;
1304
-    $output_str = '';
1305
-    $fix = isset($_POST['fix']) ? true : false;
1306
-
1307
-    //////////////////////////////////
1308
-    /* Diagnose GD Home Page Starts */
1309
-    //////////////////////////////////
1310
-    $option_value = get_option('geodir_home_page');
1311
-    $page = get_post($option_value);
1312
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
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>";
1316
-    else {
1317
-        $is_error_during_diagnose = true;
1318
-        $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
1319
-        if ($fix) {
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>";
1322
-            } else {
1323
-                $output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
1324
-            }
1325
-        }
1326
-    }
1327
-
1328
-    ////////////////////////////////
1329
-    /* Diagnose GD Home Page Ends */
1330
-    ////////////////////////////////
1331
-
1332
-    //////////////////////////////////
1333
-    /* Diagnose Add Listing Page Starts */
1334
-    //////////////////////////////////
1335
-    $option_value = get_option('geodir_add_listing_page');
1336
-    $page = get_post($option_value);
1337
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
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>";
1341
-    else {
1342
-        $is_error_during_diagnose = true;
1343
-        $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
1344
-        if ($fix) {
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>";
1347
-            } else {
1348
-                $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
1349
-            }
1350
-        }
1351
-    }
1352
-
1353
-    ////////////////////////////////
1354
-    /* Diagnose Add Listing Page Ends */
1355
-    ////////////////////////////////
1356
-
1357
-
1358
-    //////////////////////////////////
1359
-    /* Diagnose Listing Preview Page Starts */
1360
-    //////////////////////////////////
1361
-    $option_value = get_option('geodir_preview_page');
1362
-    $page = get_post($option_value);
1363
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
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>";
1367
-    else {
1368
-        $is_error_during_diagnose = true;
1369
-        $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
1370
-        if ($fix) {
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>";
1373
-            } else {
1374
-                $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
1375
-            }
1376
-        }
1377
-    }
1378
-
1379
-    ////////////////////////////////
1380
-    /* Diagnose Listing Preview Page Ends */
1381
-    ////////////////////////////////
1382
-
1383
-    //////////////////////////////////
1384
-    /* Diagnose Listing Success Page Starts */
1385
-    //////////////////////////////////
1386
-    $option_value = get_option('geodir_success_page');
1387
-    $page = get_post($option_value);
1388
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
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>";
1392
-    else {
1393
-        $is_error_during_diagnose = true;
1394
-        $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
1395
-        if ($fix) {
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>";
1398
-            } else {
1399
-                $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
1400
-            }
1401
-        }
1402
-    }
1403
-
1404
-    ////////////////////////////////
1405
-    /* Diagnose Listing Sucess Page Ends */
1406
-    ////////////////////////////////
1407
-
1408
-    //////////////////////////////////
1409
-    /* Diagnose Info Page Starts */
1410
-    //////////////////////////////////
1411
-    $option_value = get_option('geodir_info_page');
1412
-    $page = get_post($option_value);
1413
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
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>";
1417
-    else {
1418
-        $is_error_during_diagnose = true;
1419
-        $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
1420
-        if ($fix) {
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>";
1423
-            } else {
1424
-                $output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
1425
-            }
1426
-        }
1427
-    }
1428
-
1429
-    ////////////////////////////////
1430
-    /* Diagnose Info Page Ends */
1431
-    ////////////////////////////////
1432
-
1433
-    //////////////////////////////////
1434
-    /* Diagnose Login Page Starts */
1435
-    //////////////////////////////////
1436
-    $option_value = get_option('geodir_login_page');
1437
-    $page = get_post($option_value);
1438
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
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>";
1442
-    else {
1443
-        $is_error_during_diagnose = true;
1444
-        $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
1445
-        if ($fix) {
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>";
1448
-            } else {
1449
-                $output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
1450
-            }
1451
-        }
1452
-    }
1453
-
1454
-    ////////////////////////////////
1455
-    /* Diagnose Info Page Ends */
1456
-    ////////////////////////////////
1457
-
1458
-    //////////////////////////////////
1459
-    /* Diagnose Location Page Starts */
1460
-    //////////////////////////////////
1461
-    $option_value = get_option('geodir_location_page');
1462
-    $page = get_post($option_value);
1463
-    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
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>";
1467
-    else {
1468
-        $is_error_during_diagnose = true;
1469
-        $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
1470
-        if ($fix) {
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>";
1473
-            } else {
1474
-                $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
1475
-            }
1476
-        }
1477
-    }
1478
-
1479
-    ////////////////////////////////
1480
-    /* Diagnose Location Page Ends */
1481
-    ////////////////////////////////
1482
-
1483
-    $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
1484
-    /**
1485
-     * This action is called at the end of the GD Tools page check function.
1486
-     *
1487
-     * @since 1.5.2
1488
-     */
1489
-    $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
1490
-
1491
-    $output_str = $page_chk_arr['output_str'];
1492
-    $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose'];
1493
-
1494
-    if ($is_error_during_diagnose) {
1495
-        if ($fix) {
1496
-            flush_rewrite_rules();
1497
-        }
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' />";
1500
-    } else {
1501
-        $info_div_class = "geodir_noproblem_info";
1502
-        $fix_button_txt = '';
1503
-    }
1504
-    echo "<ul class='$info_div_class'>";
1505
-    echo $output_str;
1506
-    echo $fix_button_txt;
1507
-    echo "</ul>";
1302
+	global $wpdb;
1303
+	$is_error_during_diagnose = false;
1304
+	$output_str = '';
1305
+	$fix = isset($_POST['fix']) ? true : false;
1306
+
1307
+	//////////////////////////////////
1308
+	/* Diagnose GD Home Page Starts */
1309
+	//////////////////////////////////
1310
+	$option_value = get_option('geodir_home_page');
1311
+	$page = get_post($option_value);
1312
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
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>";
1316
+	else {
1317
+		$is_error_during_diagnose = true;
1318
+		$output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
1319
+		if ($fix) {
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>";
1322
+			} else {
1323
+				$output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
1324
+			}
1325
+		}
1326
+	}
1327
+
1328
+	////////////////////////////////
1329
+	/* Diagnose GD Home Page Ends */
1330
+	////////////////////////////////
1331
+
1332
+	//////////////////////////////////
1333
+	/* Diagnose Add Listing Page Starts */
1334
+	//////////////////////////////////
1335
+	$option_value = get_option('geodir_add_listing_page');
1336
+	$page = get_post($option_value);
1337
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
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>";
1341
+	else {
1342
+		$is_error_during_diagnose = true;
1343
+		$output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
1344
+		if ($fix) {
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>";
1347
+			} else {
1348
+				$output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
1349
+			}
1350
+		}
1351
+	}
1352
+
1353
+	////////////////////////////////
1354
+	/* Diagnose Add Listing Page Ends */
1355
+	////////////////////////////////
1356
+
1357
+
1358
+	//////////////////////////////////
1359
+	/* Diagnose Listing Preview Page Starts */
1360
+	//////////////////////////////////
1361
+	$option_value = get_option('geodir_preview_page');
1362
+	$page = get_post($option_value);
1363
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
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>";
1367
+	else {
1368
+		$is_error_during_diagnose = true;
1369
+		$output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
1370
+		if ($fix) {
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>";
1373
+			} else {
1374
+				$output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
1375
+			}
1376
+		}
1377
+	}
1378
+
1379
+	////////////////////////////////
1380
+	/* Diagnose Listing Preview Page Ends */
1381
+	////////////////////////////////
1382
+
1383
+	//////////////////////////////////
1384
+	/* Diagnose Listing Success Page Starts */
1385
+	//////////////////////////////////
1386
+	$option_value = get_option('geodir_success_page');
1387
+	$page = get_post($option_value);
1388
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
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>";
1392
+	else {
1393
+		$is_error_during_diagnose = true;
1394
+		$output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
1395
+		if ($fix) {
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>";
1398
+			} else {
1399
+				$output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
1400
+			}
1401
+		}
1402
+	}
1403
+
1404
+	////////////////////////////////
1405
+	/* Diagnose Listing Sucess Page Ends */
1406
+	////////////////////////////////
1407
+
1408
+	//////////////////////////////////
1409
+	/* Diagnose Info Page Starts */
1410
+	//////////////////////////////////
1411
+	$option_value = get_option('geodir_info_page');
1412
+	$page = get_post($option_value);
1413
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
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>";
1417
+	else {
1418
+		$is_error_during_diagnose = true;
1419
+		$output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
1420
+		if ($fix) {
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>";
1423
+			} else {
1424
+				$output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
1425
+			}
1426
+		}
1427
+	}
1428
+
1429
+	////////////////////////////////
1430
+	/* Diagnose Info Page Ends */
1431
+	////////////////////////////////
1432
+
1433
+	//////////////////////////////////
1434
+	/* Diagnose Login Page Starts */
1435
+	//////////////////////////////////
1436
+	$option_value = get_option('geodir_login_page');
1437
+	$page = get_post($option_value);
1438
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
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>";
1442
+	else {
1443
+		$is_error_during_diagnose = true;
1444
+		$output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
1445
+		if ($fix) {
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>";
1448
+			} else {
1449
+				$output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
1450
+			}
1451
+		}
1452
+	}
1453
+
1454
+	////////////////////////////////
1455
+	/* Diagnose Info Page Ends */
1456
+	////////////////////////////////
1457
+
1458
+	//////////////////////////////////
1459
+	/* Diagnose Location Page Starts */
1460
+	//////////////////////////////////
1461
+	$option_value = get_option('geodir_location_page');
1462
+	$page = get_post($option_value);
1463
+	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
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>";
1467
+	else {
1468
+		$is_error_during_diagnose = true;
1469
+		$output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
1470
+		if ($fix) {
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>";
1473
+			} else {
1474
+				$output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
1475
+			}
1476
+		}
1477
+	}
1478
+
1479
+	////////////////////////////////
1480
+	/* Diagnose Location Page Ends */
1481
+	////////////////////////////////
1482
+
1483
+	$page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
1484
+	/**
1485
+	 * This action is called at the end of the GD Tools page check function.
1486
+	 *
1487
+	 * @since 1.5.2
1488
+	 */
1489
+	$page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
1490
+
1491
+	$output_str = $page_chk_arr['output_str'];
1492
+	$is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose'];
1493
+
1494
+	if ($is_error_during_diagnose) {
1495
+		if ($fix) {
1496
+			flush_rewrite_rules();
1497
+		}
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' />";
1500
+	} else {
1501
+		$info_div_class = "geodir_noproblem_info";
1502
+		$fix_button_txt = '';
1503
+	}
1504
+	echo "<ul class='$info_div_class'>";
1505
+	echo $output_str;
1506
+	echo $fix_button_txt;
1507
+	echo "</ul>";
1508 1508
 
1509 1509
 }
1510 1510
 
@@ -1516,26 +1516,26 @@  discard block
 block discarded – undo
1516 1516
  * @global object $wpdb WordPress Database object.
1517 1517
  */
1518 1518
 function geodir_diagnose_load_db_language() {
1519
-    global $wpdb;
1519
+	global $wpdb;
1520 1520
 	
1521 1521
 	$is_error_during_diagnose = geodirectory_load_db_language();
1522 1522
 
1523
-    $output_str = '';
1524
-    $fix_button_txt = '';
1523
+	$output_str = '';
1524
+	$fix_button_txt = '';
1525 1525
 
1526
-    if ($is_error_during_diagnose) {
1527
-        $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
+	if ($is_error_during_diagnose) {
1527
+		$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 1528
 		$info_div_class = "geodir_problem_info";
1529
-    } else {
1530
-        $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
1529
+	} else {
1530
+		$output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
1531 1531
 		$info_div_class = "geodir_noproblem_info";
1532
-        $fix_button_txt = '';
1533
-    }
1532
+		$fix_button_txt = '';
1533
+	}
1534 1534
     
1535 1535
 	echo "<ul class='$info_div_class'>";
1536
-    echo $output_str;
1537
-    echo $fix_button_txt;
1538
-    echo "</ul>";
1536
+	echo $output_str;
1537
+	echo $fix_button_txt;
1538
+	echo "</ul>";
1539 1539
 
1540 1540
 }
1541 1541
 
@@ -1566,23 +1566,23 @@  discard block
 block discarded – undo
1566 1566
  */
1567 1567
 function geodir_posts_clauses_request($clauses)
1568 1568
 {
1569
-    global $wpdb, $wp_query, $plugin_prefix;
1569
+	global $wpdb, $wp_query, $plugin_prefix;
1570 1570
 
1571
-    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'])) {
1572
-        $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail';
1571
+	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'])) {
1572
+		$table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail';
1573 1573
 
1574
-        $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)';
1575
-        $clauses['join'] = $join;
1574
+		$join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)';
1575
+		$clauses['join'] = $join;
1576 1576
 
1577
-        $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : '';
1578
-        $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';
1579
-        $clauses['fields'] = $fields;
1577
+		$fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : '';
1578
+		$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';
1579
+		$clauses['fields'] = $fields;
1580 1580
 
1581
-        $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC';
1582
-        $orderby = 'gd_expire ' . $order;
1583
-        $clauses['orderby'] = $orderby;
1584
-    }
1585
-    return $clauses;
1581
+		$order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC';
1582
+		$orderby = 'gd_expire ' . $order;
1583
+		$clauses['orderby'] = $orderby;
1584
+	}
1585
+	return $clauses;
1586 1586
 }
1587 1587
 
1588 1588
 
@@ -1603,7 +1603,7 @@  discard block
 block discarded – undo
1603 1603
  */
1604 1604
 function gd_theme_switch_compat_check()
1605 1605
 {
1606
-    gd_set_theme_compat();
1606
+	gd_set_theme_compat();
1607 1607
 }
1608 1608
 
1609 1609
 /**
@@ -1616,27 +1616,27 @@  discard block
 block discarded – undo
1616 1616
  */
1617 1617
 function geodir_str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\")
1618 1618
 {
1619
-    if (function_exists('str_getcsv')) {
1620
-        $fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape);
1621
-    } else {
1622
-        global $current_user;
1623
-        $upload_dir = wp_upload_dir();
1624
-
1625
-        $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv';
1626
-        $handle = fopen($file, 'w');
1627
-
1628
-        fwrite($handle, $input);
1629
-        fclose($handle);
1630
-
1631
-        $handle = fopen($file, 'rt');
1632
-        if (PHP_VERSION >= '5.3.0') {
1633
-            $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape);
1634
-        } else {
1635
-            $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure);
1636
-        }
1637
-        fclose($handle);
1638
-    }
1639
-    return $fgetcsv;
1619
+	if (function_exists('str_getcsv')) {
1620
+		$fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape);
1621
+	} else {
1622
+		global $current_user;
1623
+		$upload_dir = wp_upload_dir();
1624
+
1625
+		$file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv';
1626
+		$handle = fopen($file, 'w');
1627
+
1628
+		fwrite($handle, $input);
1629
+		fclose($handle);
1630
+
1631
+		$handle = fopen($file, 'rt');
1632
+		if (PHP_VERSION >= '5.3.0') {
1633
+			$fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape);
1634
+		} else {
1635
+			$fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure);
1636
+		}
1637
+		fclose($handle);
1638
+	}
1639
+	return $fgetcsv;
1640 1640
 }
1641 1641
 
1642 1642
 add_action('wp_ajax_gdImportCsv', 'geodir_ajax_import_csv');
@@ -1651,375 +1651,375 @@  discard block
 block discarded – undo
1651 1651
  */
1652 1652
 function geodir_ajax_import_csv()
1653 1653
 {
1654
-    error_reporting(0); // hide error to get clean json response
1654
+	error_reporting(0); // hide error to get clean json response
1655 1655
 
1656
-    global $wpdb, $plugin_prefix, $current_user;
1657
-    $uploads = wp_upload_dir();
1658
-    ini_set('auto_detect_line_endings', true);
1656
+	global $wpdb, $plugin_prefix, $current_user;
1657
+	$uploads = wp_upload_dir();
1658
+	ini_set('auto_detect_line_endings', true);
1659 1659
 	
1660 1660
 	$wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses.
1661 1661
 
1662
-    $task = isset($_POST['task']) ? $_POST['task'] : '';
1663
-    $uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL;
1664
-    $filename = $uploadedFile;
1665
-
1666
-    $uploads = wp_upload_dir();
1667
-    $uploads_dir = $uploads['path'];
1668
-    $image_name_arr = explode('/', $filename);
1669
-    $filename = end($image_name_arr);
1670
-    $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1671
-    $return = array();
1672
-    $return['file'] = $uploadedFile;
1673
-    $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
1674
-
1675
-    if (is_file($target_path) && file_exists($target_path) && $uploadedFile) {
1676
-        $wp_filetype = wp_check_filetype_and_ext($target_path, $filename);
1677
-
1678
-        if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
1679
-            $return['error'] = NULL;
1680
-
1681
-            $return['rows'] = 0;
1682
-
1683
-
1684
-
1685
-                if (($handle = fopen($target_path, "r")) !== FALSE) {
1686
-                    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
1687
-                        if(is_array($data) && !empty($data)) {
1688
-                            $file[] = '"' . implode('","', $data) . '"';
1689
-                        }
1690
-                    }
1691
-                    fclose($handle);
1692
-                    $file = $file;
1693
-                }
1694
-
1695
-
1696
-
1697
-                $return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
1698
-
1699
-
1700
-            if (!$return['rows'] > 0) {
1701
-                $return['error'] = __('No data found in csv file.', 'geodirectory');
1702
-            }
1703
-        }
1704
-    }
1705
-    if ($task == 'prepare' || !empty($return['error'])) {
1706
-        echo json_encode($return);
1707
-        exit;
1708
-    }
1709
-
1710
-    $totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL;
1711
-    $importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1;
1712
-    $count = $importlimit;
1713
-    $requested_limit = $importlimit;
1714
-    $tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0;
1715
-
1716
-    if ($count < $totRecords) {
1717
-        $count = $tmpCnt + $count;
1718
-        if ($count > $totRecords) {
1719
-            $count = $totRecords;
1720
-        }
1721
-    } else {
1722
-        $count = $totRecords;
1723
-    }
1724
-
1725
-    $total_records = 0;
1726
-    $rowcount = 0;
1727
-    $address_invalid = 0;
1728
-    $blank_address = 0;
1729
-    $upload_files = 0;
1730
-    $invalid_post_type = 0;
1731
-    $invalid_title = 0;
1732
-    $customKeyarray = array();
1733
-    $gd_post_info = array();
1734
-    $post_location = array();
1735
-    $countpost = 0;
1736
-
1737
-    if (!empty($file)) {
1738
-        $columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL;
1739
-        $customKeyarray = $columns;
1740
-
1741
-        if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
1742
-            $return['error'] = CSV_INVAILD_FILE;
1743
-            echo json_encode($return);
1744
-            exit;
1745
-        }
1746
-
1747
-        for ($i = 1; $i <= $importlimit; $i++) {
1748
-            $current_index = $tmpCnt + $i;
1749
-            if (isset($file[$current_index])) {
1750
-                $total_records++;
1751
-
1752
-                $buffer = geodir_str_getcsv($file[$current_index]);
1753
-                $post_title = addslashes($buffer[0]);
1754
-                $current_post_author = $buffer[1];
1755
-                $post_desc = addslashes($buffer[2]);
1756
-                $post_cat = array();
1757
-                $catids_arr = array();
1758
-                $post_cat = trim($buffer[3]); // comma seperated category name
1759
-
1760
-                if ($post_cat) {
1761
-                    $post_cat_arr = explode(',', $post_cat);
1762
-
1763
-                    for ($c = 0; $c < count($post_cat_arr); $c++) {
1764
-                        $catid = wp_kses_normalize_entities(trim($post_cat_arr[$c]));
1765
-
1766
-                        if (!empty($buffer[5])) {
1767
-                            if (in_array($buffer[5], geodir_get_posttypes())) {
1768
-
1769
-                                $p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5]));
1770
-
1771
-                                if (get_term_by('name', $catid, $p_taxonomy[0])) {
1772
-                                    $cat = get_term_by('name', $catid, $p_taxonomy[0]);
1773
-                                    $catids_arr[] = $cat->slug;
1774
-                                } else if (get_term_by('slug', $catid, $p_taxonomy[0])) {
1775
-                                    $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
1776
-                                    $catids_arr[] = $cat->slug;
1777
-                                } else {
1778
-                                    $ret = wp_insert_term($catid, $p_taxonomy[0]);
1779
-                                    if ($ret && !is_wp_error($ret)) {
1780
-                                        if (get_term_by('name', $catid, $p_taxonomy[0])) {
1781
-                                            $cat = get_term_by('name', $catid, $p_taxonomy[0]);
1782
-                                            $catids_arr[] = $cat->slug;
1783
-                                        } elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
1784
-                                            $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
1785
-                                            $catids_arr[] = $cat->slug;
1786
-                                        }
1787
-                                    }
1788
-                                }
1789
-                            }
1790
-                        }
1791
-                    }
1792
-                }
1793
-
1794
-                if (!$catids_arr) {
1795
-                    $catids_arr[] = 1;
1796
-                }
1797
-
1798
-                $post_tags = trim($buffer[4]); // comma seperated tags
1799
-
1800
-                $tag_arr = '';
1801
-                if ($post_tags) {
1802
-                    $tag_arr = explode(',', $post_tags);
1803
-                }
1804
-
1805
-                $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database
1806
-
1807
-                $error = '';
1808
-                if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
1809
-                    $invalid_post_type++;
1810
-                    continue;
1811
-                }
1812
-
1813
-                if ($post_title != '') {
1814
-                    $menu_order = 0;
1815
-                    $image_folder_name = 'uplaod/';
1816
-
1817
-                    $image_names = array();
1818
-
1819
-                    for ($c = 5; $c < count($customKeyarray); $c++) {
1820
-                        $gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]);
1821
-
1822
-                        if ($customKeyarray[$c] == 'IMAGE') {
1823
-                            $buffer[$c] = trim($buffer[$c]);
1824
-
1825
-                            if (!empty($buffer[$c])) {
1826
-                                $image_names[] = $buffer[$c];
1827
-                            }
1828
-                        }
1829
-
1830
-                        if ($customKeyarray[$c] == 'alive_days') {
1831
-                            if ($buffer[$c] != '0' && $buffer[$c] != '') {
1832
-                                $submitdata = date('Y-m-d');
1833
-
1834
-                                $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
1835
-                            } else {
1836
-                                $gd_post_info['expire_date'] = 'Never';
1837
-                            }
1838
-                        }
1839
-
1840
-                        if ($customKeyarray[$c] == 'post_city') {
1841
-                            $post_city = addslashes($buffer[$c]);
1842
-                        }
1843
-
1844
-                        if ($customKeyarray[$c] == 'post_region') {
1845
-                            $post_region = addslashes($buffer[$c]);
1846
-                        }
1847
-
1848
-                        if ($customKeyarray[$c] == 'post_country') {
1849
-                            $post_country = addslashes($buffer[$c]);
1850
-                        }
1851
-
1852
-                        if ($customKeyarray[$c] == 'post_latitude') {
1853
-                            $post_latitude = addslashes($buffer[$c]);
1854
-                        }
1855
-
1856
-                        if ($customKeyarray[$c] == 'post_longitude') {
1857
-                            $post_longitude = addslashes($buffer[$c]);
1858
-                        }
1662
+	$task = isset($_POST['task']) ? $_POST['task'] : '';
1663
+	$uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL;
1664
+	$filename = $uploadedFile;
1665
+
1666
+	$uploads = wp_upload_dir();
1667
+	$uploads_dir = $uploads['path'];
1668
+	$image_name_arr = explode('/', $filename);
1669
+	$filename = end($image_name_arr);
1670
+	$target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1671
+	$return = array();
1672
+	$return['file'] = $uploadedFile;
1673
+	$return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
1674
+
1675
+	if (is_file($target_path) && file_exists($target_path) && $uploadedFile) {
1676
+		$wp_filetype = wp_check_filetype_and_ext($target_path, $filename);
1677
+
1678
+		if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
1679
+			$return['error'] = NULL;
1680
+
1681
+			$return['rows'] = 0;
1682
+
1683
+
1684
+
1685
+				if (($handle = fopen($target_path, "r")) !== FALSE) {
1686
+					while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
1687
+						if(is_array($data) && !empty($data)) {
1688
+							$file[] = '"' . implode('","', $data) . '"';
1689
+						}
1690
+					}
1691
+					fclose($handle);
1692
+					$file = $file;
1693
+				}
1694
+
1695
+
1696
+
1697
+				$return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0;
1698
+
1699
+
1700
+			if (!$return['rows'] > 0) {
1701
+				$return['error'] = __('No data found in csv file.', 'geodirectory');
1702
+			}
1703
+		}
1704
+	}
1705
+	if ($task == 'prepare' || !empty($return['error'])) {
1706
+		echo json_encode($return);
1707
+		exit;
1708
+	}
1709
+
1710
+	$totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL;
1711
+	$importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1;
1712
+	$count = $importlimit;
1713
+	$requested_limit = $importlimit;
1714
+	$tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0;
1715
+
1716
+	if ($count < $totRecords) {
1717
+		$count = $tmpCnt + $count;
1718
+		if ($count > $totRecords) {
1719
+			$count = $totRecords;
1720
+		}
1721
+	} else {
1722
+		$count = $totRecords;
1723
+	}
1724
+
1725
+	$total_records = 0;
1726
+	$rowcount = 0;
1727
+	$address_invalid = 0;
1728
+	$blank_address = 0;
1729
+	$upload_files = 0;
1730
+	$invalid_post_type = 0;
1731
+	$invalid_title = 0;
1732
+	$customKeyarray = array();
1733
+	$gd_post_info = array();
1734
+	$post_location = array();
1735
+	$countpost = 0;
1736
+
1737
+	if (!empty($file)) {
1738
+		$columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL;
1739
+		$customKeyarray = $columns;
1740
+
1741
+		if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
1742
+			$return['error'] = CSV_INVAILD_FILE;
1743
+			echo json_encode($return);
1744
+			exit;
1745
+		}
1746
+
1747
+		for ($i = 1; $i <= $importlimit; $i++) {
1748
+			$current_index = $tmpCnt + $i;
1749
+			if (isset($file[$current_index])) {
1750
+				$total_records++;
1751
+
1752
+				$buffer = geodir_str_getcsv($file[$current_index]);
1753
+				$post_title = addslashes($buffer[0]);
1754
+				$current_post_author = $buffer[1];
1755
+				$post_desc = addslashes($buffer[2]);
1756
+				$post_cat = array();
1757
+				$catids_arr = array();
1758
+				$post_cat = trim($buffer[3]); // comma seperated category name
1759
+
1760
+				if ($post_cat) {
1761
+					$post_cat_arr = explode(',', $post_cat);
1762
+
1763
+					for ($c = 0; $c < count($post_cat_arr); $c++) {
1764
+						$catid = wp_kses_normalize_entities(trim($post_cat_arr[$c]));
1765
+
1766
+						if (!empty($buffer[5])) {
1767
+							if (in_array($buffer[5], geodir_get_posttypes())) {
1768
+
1769
+								$p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5]));
1770
+
1771
+								if (get_term_by('name', $catid, $p_taxonomy[0])) {
1772
+									$cat = get_term_by('name', $catid, $p_taxonomy[0]);
1773
+									$catids_arr[] = $cat->slug;
1774
+								} else if (get_term_by('slug', $catid, $p_taxonomy[0])) {
1775
+									$cat = get_term_by('slug', $catid, $p_taxonomy[0]);
1776
+									$catids_arr[] = $cat->slug;
1777
+								} else {
1778
+									$ret = wp_insert_term($catid, $p_taxonomy[0]);
1779
+									if ($ret && !is_wp_error($ret)) {
1780
+										if (get_term_by('name', $catid, $p_taxonomy[0])) {
1781
+											$cat = get_term_by('name', $catid, $p_taxonomy[0]);
1782
+											$catids_arr[] = $cat->slug;
1783
+										} elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
1784
+											$cat = get_term_by('slug', $catid, $p_taxonomy[0]);
1785
+											$catids_arr[] = $cat->slug;
1786
+										}
1787
+									}
1788
+								}
1789
+							}
1790
+						}
1791
+					}
1792
+				}
1793
+
1794
+				if (!$catids_arr) {
1795
+					$catids_arr[] = 1;
1796
+				}
1797
+
1798
+				$post_tags = trim($buffer[4]); // comma seperated tags
1799
+
1800
+				$tag_arr = '';
1801
+				if ($post_tags) {
1802
+					$tag_arr = explode(',', $post_tags);
1803
+				}
1804
+
1805
+				$table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database
1806
+
1807
+				$error = '';
1808
+				if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
1809
+					$invalid_post_type++;
1810
+					continue;
1811
+				}
1812
+
1813
+				if ($post_title != '') {
1814
+					$menu_order = 0;
1815
+					$image_folder_name = 'uplaod/';
1816
+
1817
+					$image_names = array();
1818
+
1819
+					for ($c = 5; $c < count($customKeyarray); $c++) {
1820
+						$gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]);
1821
+
1822
+						if ($customKeyarray[$c] == 'IMAGE') {
1823
+							$buffer[$c] = trim($buffer[$c]);
1824
+
1825
+							if (!empty($buffer[$c])) {
1826
+								$image_names[] = $buffer[$c];
1827
+							}
1828
+						}
1829
+
1830
+						if ($customKeyarray[$c] == 'alive_days') {
1831
+							if ($buffer[$c] != '0' && $buffer[$c] != '') {
1832
+								$submitdata = date('Y-m-d');
1833
+
1834
+								$gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
1835
+							} else {
1836
+								$gd_post_info['expire_date'] = 'Never';
1837
+							}
1838
+						}
1839
+
1840
+						if ($customKeyarray[$c] == 'post_city') {
1841
+							$post_city = addslashes($buffer[$c]);
1842
+						}
1843
+
1844
+						if ($customKeyarray[$c] == 'post_region') {
1845
+							$post_region = addslashes($buffer[$c]);
1846
+						}
1847
+
1848
+						if ($customKeyarray[$c] == 'post_country') {
1849
+							$post_country = addslashes($buffer[$c]);
1850
+						}
1851
+
1852
+						if ($customKeyarray[$c] == 'post_latitude') {
1853
+							$post_latitude = addslashes($buffer[$c]);
1854
+						}
1855
+
1856
+						if ($customKeyarray[$c] == 'post_longitude') {
1857
+							$post_longitude = addslashes($buffer[$c]);
1858
+						}
1859 1859
 						
1860 1860
 						// Post status
1861 1861
 						if ($customKeyarray[$c] == 'post_status') {
1862
-                            $post_status = sanitize_key( $buffer[$c] );
1863
-                        }
1864
-                    }
1865
-
1866
-                    /* ================ before array create ============== */
1867
-                    $location_result = geodir_get_default_location();
1868
-                    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'] == '')) {
1869
-                        $blank_address++;
1870
-                        continue;
1871
-                    } else if ($location_result->location_id == 0) {
1872
-                        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))) {
1873
-                            $address_invalid++;
1874
-                            continue;
1875
-                        }
1876
-                    }
1862
+							$post_status = sanitize_key( $buffer[$c] );
1863
+						}
1864
+					}
1865
+
1866
+					/* ================ before array create ============== */
1867
+					$location_result = geodir_get_default_location();
1868
+					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'] == '')) {
1869
+						$blank_address++;
1870
+						continue;
1871
+					} else if ($location_result->location_id == 0) {
1872
+						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))) {
1873
+							$address_invalid++;
1874
+							continue;
1875
+						}
1876
+					}
1877 1877
 					
1878 1878
 					// Default post status
1879 1879
 					$default_status = 'publish';
1880 1880
 					$post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status;
1881 1881
 					$post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status;
1882 1882
 
1883
-                    $my_post['post_title'] = $post_title;
1884
-                    $my_post['post_content'] = $post_desc;
1885
-                    $my_post['post_type'] = addslashes($buffer[5]);
1886
-                    $my_post['post_author'] = $current_post_author;
1887
-                    $my_post['post_status'] = $post_status;
1888
-                    $my_post['post_category'] = $catids_arr;
1889
-                    $my_post['post_tags'] = $tag_arr;
1890
-
1891
-                    $gd_post_info['post_tags'] = $tag_arr;
1892
-                    $gd_post_info['post_title'] = $post_title;
1893
-                    $gd_post_info['post_status'] = $post_status;
1894
-                    $gd_post_info['submit_time'] = time();
1895
-                    $gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR'];
1896
-
1897
-                    $last_postid = wp_insert_post($my_post);
1898
-                    $countpost++;
1899
-
1900
-                    // Check if we need to save post location as new location
1901
-                    if ($location_result->location_id > 0) {
1902
-                        if (isset($post_city) && isset($post_region)) {
1903
-                            $request_info['post_location'] = array(
1904
-                                'city' => $post_city,
1905
-                                'region' => $post_region,
1906
-                                'country' => $post_country,
1907
-                                'geo_lat' => $post_latitude,
1908
-                                'geo_lng' => $post_longitude
1909
-                            );
1910
-
1911
-                            $post_location_info = $request_info['post_location'];
1912
-                            if ($location_id = geodir_add_new_location($post_location_info))
1913
-                                $post_location_id = $location_id;
1914
-                        } else {
1915
-                            $post_location_id = 0;
1916
-                        }
1917
-                    } else {
1918
-                        $post_location_id = 0;
1919
-                    }
1920
-
1921
-                    /* ------- get default package info ----- */
1922
-                    $payment_info = array();
1923
-                    $package_info = array();
1924
-
1925
-                    $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]);
1926
-                    $package_id = '';
1927
-                    if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
1928
-                        $package_id = $gd_post_info['package_id'];
1929
-                    }
1930
-
1931
-                    if (!empty($package_info)) {
1932
-                        $payment_info['package_id'] = $package_info['pid'];
1933
-
1934
-                        if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
1935
-                            $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
1936
-                        } else {
1937
-                            $payment_info['expire_date'] = 'Never';
1938
-                        }
1939
-
1940
-                        $gd_post_info = array_merge($gd_post_info, $payment_info);
1941
-                    }
1942
-
1943
-                    $gd_post_info['post_location_id'] = $post_location_id;
1944
-
1945
-                    $post_type = get_post_type($last_postid);
1946
-
1947
-                    $table = $plugin_prefix . $post_type . '_detail';
1948
-
1949
-                    geodir_save_post_info($last_postid, $gd_post_info);
1950
-
1951
-                    if (!empty($image_names)) {
1952
-                        $upload_files++;
1953
-                        $menu_order = 1;
1954
-
1955
-                        foreach ($image_names as $image_name) {
1956
-                            $img_name_arr = explode('.', $image_name);
1957
-
1958
-                            $uploads = wp_upload_dir();
1959
-                            $sub_dir = $uploads['subdir'];
1960
-
1961
-                            $arr_file_type = wp_check_filetype($image_name);
1962
-                            $uploaded_file_type = $arr_file_type['type'];
1963
-
1964
-                            $attachment = array();
1965
-                            $attachment['post_id'] = $last_postid;
1966
-                            $attachment['title'] = $img_name_arr[0];
1967
-                            $attachment['content'] = '';
1968
-                            $attachment['file'] = $sub_dir . '/' . $image_name;
1969
-                            $attachment['mime_type'] = $uploaded_file_type;
1970
-                            $attachment['menu_order'] = $menu_order;
1971
-                            $attachment['is_featured'] = 0;
1972
-
1973
-                            $attachment_set = '';
1974
-
1975
-                            foreach ($attachment as $key => $val) {
1976
-                                if ($val != '')
1977
-                                    $attachment_set .= $key . " = '" . $val . "', ";
1978
-                            }
1979
-                            $attachment_set = trim($attachment_set, ", ");
1980
-
1981
-                            $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
1982
-
1983
-                            if ($menu_order == 1) {
1984
-                                $post_type = get_post_type($last_postid);
1985
-                                $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
1986
-                            }
1987
-                            $menu_order++;
1988
-                        }
1989
-                    }
1990
-
1991
-                    $gd_post_info['package_id'] = $package_id;
1992
-
1993
-                    /** This action is documented in geodirectory-functions/post-functions.php */
1994
-                    do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
1995
-
1996
-                    if (!empty($buffer[5])) {
1997
-                        if (in_array($buffer[5], geodir_get_posttypes())) {
1998
-                            $taxonomies = geodir_get_posttype_info(addslashes($buffer[5]));
1999
-                            wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]);
2000
-                            wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]);
2001
-
2002
-                            $post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : '';
2003
-                            $post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : '';
2004
-                            geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str);
2005
-                        }
2006
-                    }
2007
-                } else {
2008
-                    $invalid_title++;
2009
-                }
2010
-            }
2011
-        }
2012
-    }
2013
-    $return['rowcount'] = $countpost;
2014
-    $return['invalidcount'] = $address_invalid;
2015
-    $return['blank_address'] = $blank_address;
2016
-    $return['upload_files'] = $upload_files;
2017
-    $return['invalid_post_type'] = $invalid_post_type;
2018
-    $return['invalid_title'] = $invalid_title;
2019
-    $return['total_records'] = $total_records;
2020
-
2021
-    echo json_encode($return);
2022
-    exit;
1883
+					$my_post['post_title'] = $post_title;
1884
+					$my_post['post_content'] = $post_desc;
1885
+					$my_post['post_type'] = addslashes($buffer[5]);
1886
+					$my_post['post_author'] = $current_post_author;
1887
+					$my_post['post_status'] = $post_status;
1888
+					$my_post['post_category'] = $catids_arr;
1889
+					$my_post['post_tags'] = $tag_arr;
1890
+
1891
+					$gd_post_info['post_tags'] = $tag_arr;
1892
+					$gd_post_info['post_title'] = $post_title;
1893
+					$gd_post_info['post_status'] = $post_status;
1894
+					$gd_post_info['submit_time'] = time();
1895
+					$gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR'];
1896
+
1897
+					$last_postid = wp_insert_post($my_post);
1898
+					$countpost++;
1899
+
1900
+					// Check if we need to save post location as new location
1901
+					if ($location_result->location_id > 0) {
1902
+						if (isset($post_city) && isset($post_region)) {
1903
+							$request_info['post_location'] = array(
1904
+								'city' => $post_city,
1905
+								'region' => $post_region,
1906
+								'country' => $post_country,
1907
+								'geo_lat' => $post_latitude,
1908
+								'geo_lng' => $post_longitude
1909
+							);
1910
+
1911
+							$post_location_info = $request_info['post_location'];
1912
+							if ($location_id = geodir_add_new_location($post_location_info))
1913
+								$post_location_id = $location_id;
1914
+						} else {
1915
+							$post_location_id = 0;
1916
+						}
1917
+					} else {
1918
+						$post_location_id = 0;
1919
+					}
1920
+
1921
+					/* ------- get default package info ----- */
1922
+					$payment_info = array();
1923
+					$package_info = array();
1924
+
1925
+					$package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]);
1926
+					$package_id = '';
1927
+					if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
1928
+						$package_id = $gd_post_info['package_id'];
1929
+					}
1930
+
1931
+					if (!empty($package_info)) {
1932
+						$payment_info['package_id'] = $package_info['pid'];
1933
+
1934
+						if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
1935
+							$payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
1936
+						} else {
1937
+							$payment_info['expire_date'] = 'Never';
1938
+						}
1939
+
1940
+						$gd_post_info = array_merge($gd_post_info, $payment_info);
1941
+					}
1942
+
1943
+					$gd_post_info['post_location_id'] = $post_location_id;
1944
+
1945
+					$post_type = get_post_type($last_postid);
1946
+
1947
+					$table = $plugin_prefix . $post_type . '_detail';
1948
+
1949
+					geodir_save_post_info($last_postid, $gd_post_info);
1950
+
1951
+					if (!empty($image_names)) {
1952
+						$upload_files++;
1953
+						$menu_order = 1;
1954
+
1955
+						foreach ($image_names as $image_name) {
1956
+							$img_name_arr = explode('.', $image_name);
1957
+
1958
+							$uploads = wp_upload_dir();
1959
+							$sub_dir = $uploads['subdir'];
1960
+
1961
+							$arr_file_type = wp_check_filetype($image_name);
1962
+							$uploaded_file_type = $arr_file_type['type'];
1963
+
1964
+							$attachment = array();
1965
+							$attachment['post_id'] = $last_postid;
1966
+							$attachment['title'] = $img_name_arr[0];
1967
+							$attachment['content'] = '';
1968
+							$attachment['file'] = $sub_dir . '/' . $image_name;
1969
+							$attachment['mime_type'] = $uploaded_file_type;
1970
+							$attachment['menu_order'] = $menu_order;
1971
+							$attachment['is_featured'] = 0;
1972
+
1973
+							$attachment_set = '';
1974
+
1975
+							foreach ($attachment as $key => $val) {
1976
+								if ($val != '')
1977
+									$attachment_set .= $key . " = '" . $val . "', ";
1978
+							}
1979
+							$attachment_set = trim($attachment_set, ", ");
1980
+
1981
+							$wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
1982
+
1983
+							if ($menu_order == 1) {
1984
+								$post_type = get_post_type($last_postid);
1985
+								$wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
1986
+							}
1987
+							$menu_order++;
1988
+						}
1989
+					}
1990
+
1991
+					$gd_post_info['package_id'] = $package_id;
1992
+
1993
+					/** This action is documented in geodirectory-functions/post-functions.php */
1994
+					do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
1995
+
1996
+					if (!empty($buffer[5])) {
1997
+						if (in_array($buffer[5], geodir_get_posttypes())) {
1998
+							$taxonomies = geodir_get_posttype_info(addslashes($buffer[5]));
1999
+							wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]);
2000
+							wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]);
2001
+
2002
+							$post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : '';
2003
+							$post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : '';
2004
+							geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str);
2005
+						}
2006
+					}
2007
+				} else {
2008
+					$invalid_title++;
2009
+				}
2010
+			}
2011
+		}
2012
+	}
2013
+	$return['rowcount'] = $countpost;
2014
+	$return['invalidcount'] = $address_invalid;
2015
+	$return['blank_address'] = $blank_address;
2016
+	$return['upload_files'] = $upload_files;
2017
+	$return['invalid_post_type'] = $invalid_post_type;
2018
+	$return['invalid_title'] = $invalid_title;
2019
+	$return['total_records'] = $total_records;
2020
+
2021
+	echo json_encode($return);
2022
+	exit;
2023 2023
 }
2024 2024
 
2025 2025
 // Add the tab in left sidebar menu fro import & export page.
@@ -2039,9 +2039,9 @@  discard block
 block discarded – undo
2039 2039
  * @param $post object $post The post object of the post being saved.
2040 2040
  */
2041 2041
 function geodir_update_location_prefix($post_id,$post){
2042
-    if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
2043
-        update_option('geodir_location_prefix',$post->post_name);
2044
-    }
2042
+	if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
2043
+		update_option('geodir_location_prefix',$post->post_name);
2044
+	}
2045 2045
 
2046 2046
 }
2047 2047
 
@@ -2052,50 +2052,50 @@  discard block
 block discarded – undo
2052 2052
 function geodir_ga_callback(){
2053 2053
 
2054 2054
 if(isset($_REQUEST['code']) && $_REQUEST['code']) {
2055
-    $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?";
2056
-    $code = "code=".$_REQUEST['code'];
2057
-    $grant_type = "&grant_type=authorization_code";
2058
-    $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
2059
-    $client_id = "&client_id=".get_option('geodir_ga_client_id');
2060
-    $client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
2055
+	$oAuthURL = "https://www.googleapis.com/oauth2/v3/token?";
2056
+	$code = "code=".$_REQUEST['code'];
2057
+	$grant_type = "&grant_type=authorization_code";
2058
+	$redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
2059
+	$client_id = "&client_id=".get_option('geodir_ga_client_id');
2060
+	$client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
2061 2061
 
2062
-    $auth_url = $oAuthURL . $code . $redirect_uri .  $grant_type . $client_id .$client_secret;
2062
+	$auth_url = $oAuthURL . $code . $redirect_uri .  $grant_type . $client_id .$client_secret;
2063 2063
 
2064
-    $response = wp_remote_post($auth_url, array('timeout' => 15));
2064
+	$response = wp_remote_post($auth_url, array('timeout' => 15));
2065 2065
 
2066
-    //print_r($response);
2066
+	//print_r($response);
2067 2067
 
2068
-    $error_msg =  __('Something went wrong','geodirectory');
2069
-    if(!empty($response['response']['code']) && $response['response']['code']==200){
2068
+	$error_msg =  __('Something went wrong','geodirectory');
2069
+	if(!empty($response['response']['code']) && $response['response']['code']==200){
2070 2070
 
2071
-        $parts = json_decode($response['body']);
2072
-        //print_r($parts);
2073
-        if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
2074
-        else{
2071
+		$parts = json_decode($response['body']);
2072
+		//print_r($parts);
2073
+		if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
2074
+		else{
2075 2075
 
2076
-            update_option('gd_ga_access_token', $parts->access_token);
2077
-            update_option('gd_ga_refresh_token', $parts->refresh_token);
2078
-            ?><script>window.close();</script><?php
2079
-        }
2076
+			update_option('gd_ga_access_token', $parts->access_token);
2077
+			update_option('gd_ga_refresh_token', $parts->refresh_token);
2078
+			?><script>window.close();</script><?php
2079
+		}
2080 2080
 
2081 2081
 
2082
-    }
2083
-    elseif(!empty($response['response']['code'])) {
2084
-        $parts = json_decode($response['body']);
2082
+	}
2083
+	elseif(!empty($response['response']['code'])) {
2084
+		$parts = json_decode($response['body']);
2085 2085
 
2086
-        if(isset($parts->error)){
2087
-            echo $parts->error.": ".$parts->error_description;exit;
2088
-        }else{
2089
-            echo $error_msg." - #2";exit;
2090
-        }
2086
+		if(isset($parts->error)){
2087
+			echo $parts->error.": ".$parts->error_description;exit;
2088
+		}else{
2089
+			echo $error_msg." - #2";exit;
2090
+		}
2091 2091
 
2092
-    }else{
2092
+	}else{
2093 2093
 
2094
-        echo $error_msg." - #3";exit;
2094
+		echo $error_msg." - #3";exit;
2095 2095
 
2096
-    }
2096
+	}
2097 2097
 }
2098
-    exit;
2098
+	exit;
2099 2099
 }
2100 2100
 
2101 2101
 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.
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', 'http://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css');
427
-                wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery'));
426
+                wp_enqueue_style('tmc-jquery-ui-css', 'http://ajax.googleapis.com/ajax/libs/jqueryui/'.$this->get_jqueryui_ver().'/themes/base/jquery-ui.css');
427
+                wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/'.$this->get_jqueryui_ver().'/jquery-ui.min.js', array('jquery'));
428 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.
Indentation   +2028 added lines, -2028 removed lines patch added patch discarded remove patch
@@ -28,260 +28,260 @@  discard block
 block discarded – undo
28 28
 
29 29
 if (!class_exists('Tax_Meta_Class')) :
30 30
 
31
-    /**
32
-     * All Types Meta Box class.
33
-     *
34
-     * @package All Types Meta Box
35
-     * @since 1.0
36
-     *
37
-     * @todo Nothing.
38
-     */
39
-
40
-
41
-    class Tax_Meta_Class
42
-    {
43
-
44
-        /**
45
-         * Holds meta box object
46
-         *
47
-         * @var object
48
-         * @access protected
49
-         */
50
-        protected $_meta_box;
51
-
52
-        /**
53
-         * Holds meta box fields.
54
-         *
55
-         * @var array
56
-         * @access protected
57
-         */
58
-        protected $_prefix;
59
-
60
-        /**
61
-         * Holds Prefix for meta box fields.
62
-         *
63
-         * @var array
64
-         * @access protected
65
-         */
66
-        protected $_fields;
67
-
68
-        /**
69
-         * Use local images.
70
-         *
71
-         * @var bool
72
-         * @access protected
73
-         */
74
-        protected $_Local_images;
75
-
76
-        /**
77
-         * What form is this? edit or new term.
78
-         *
79
-         * @var string
80
-         * @access protected
81
-         * $since 1.0
82
-         */
83
-        protected $_form_type;
84
-        /**
85
-         * SelfPath to allow themes as well as plugins.
86
-         *
87
-         * @var string
88
-         * @access protected
89
-         * $since 1.0
90
-         */
91
-        protected $SelfPath;
92
-
93
-        /**
94
-         * Constructor
95
-         *
96
-         * @since 1.0
97
-         * @access public
98
-         *
99
-         * @param array $meta_box
100
-         */
101
-        public function __construct($meta_box)
102
-        {
103
-
104
-            // If we are not in admin area exit.
105
-            if (!is_admin())
106
-                return;
107
-
108
-            // Assign meta box values to local variables and add it's missed values.
109
-            $this->_meta_box = $meta_box;
110
-            $this->_prefix = (isset($meta_box['prefix'])) ? $meta_box['prefix'] : '';
111
-            $this->_fields = &$this->_meta_box['fields'];
112
-            $this->_Local_images = (isset($meta_box['local_images'])) ? true : false;
113
-            $this->add_missed_values();
114
-            if (isset($meta_box['use_with_theme']))
115
-                if ($meta_box['use_with_theme'] === true) {
116
-                    $this->SelfPath = get_stylesheet_directory_uri() . '/library/cat-meta';
117
-                } elseif ($meta_box['use_with_theme'] === false) {
118
-                    $this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__)));
119
-                } else {
120
-                    $this->SelfPath = $meta_box['use_with_theme'];
121
-                }
122
-            else {
123
-                $this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__)));
124
-            }
125
-
126
-
127
-            // Add Actions
128
-            add_action('admin_init', array(&$this, 'add'));
129
-
130
-            // Check for special fields and add needed actions for them.
131
-            $this->check_field_upload();
132
-            $this->check_field_color();
133
-            $this->check_field_date();
134
-            $this->check_field_time();
135
-
136
-            // Load common js, css files
137
-            // Must enqueue for all pages as we need js for the media upload, too.
138
-            add_action('admin_print_styles', array(&$this, 'load_scripts_styles'));
139
-
140
-        }
141
-
142
-        /**
143
-         * Load all Javascript and CSS
144
-         *
145
-         * @since 1.0
146
-         * @access public
147
-         */
148
-        public function load_scripts_styles()
149
-        {
150
-
151
-            // Get Plugin Path
152
-            $plugin_path = $this->SelfPath;
153
-            //only load styles and js when needed
154
-            /* 
31
+	/**
32
+	 * All Types Meta Box class.
33
+	 *
34
+	 * @package All Types Meta Box
35
+	 * @since 1.0
36
+	 *
37
+	 * @todo Nothing.
38
+	 */
39
+
40
+
41
+	class Tax_Meta_Class
42
+	{
43
+
44
+		/**
45
+		 * Holds meta box object
46
+		 *
47
+		 * @var object
48
+		 * @access protected
49
+		 */
50
+		protected $_meta_box;
51
+
52
+		/**
53
+		 * Holds meta box fields.
54
+		 *
55
+		 * @var array
56
+		 * @access protected
57
+		 */
58
+		protected $_prefix;
59
+
60
+		/**
61
+		 * Holds Prefix for meta box fields.
62
+		 *
63
+		 * @var array
64
+		 * @access protected
65
+		 */
66
+		protected $_fields;
67
+
68
+		/**
69
+		 * Use local images.
70
+		 *
71
+		 * @var bool
72
+		 * @access protected
73
+		 */
74
+		protected $_Local_images;
75
+
76
+		/**
77
+		 * What form is this? edit or new term.
78
+		 *
79
+		 * @var string
80
+		 * @access protected
81
+		 * $since 1.0
82
+		 */
83
+		protected $_form_type;
84
+		/**
85
+		 * SelfPath to allow themes as well as plugins.
86
+		 *
87
+		 * @var string
88
+		 * @access protected
89
+		 * $since 1.0
90
+		 */
91
+		protected $SelfPath;
92
+
93
+		/**
94
+		 * Constructor
95
+		 *
96
+		 * @since 1.0
97
+		 * @access public
98
+		 *
99
+		 * @param array $meta_box
100
+		 */
101
+		public function __construct($meta_box)
102
+		{
103
+
104
+			// If we are not in admin area exit.
105
+			if (!is_admin())
106
+				return;
107
+
108
+			// Assign meta box values to local variables and add it's missed values.
109
+			$this->_meta_box = $meta_box;
110
+			$this->_prefix = (isset($meta_box['prefix'])) ? $meta_box['prefix'] : '';
111
+			$this->_fields = &$this->_meta_box['fields'];
112
+			$this->_Local_images = (isset($meta_box['local_images'])) ? true : false;
113
+			$this->add_missed_values();
114
+			if (isset($meta_box['use_with_theme']))
115
+				if ($meta_box['use_with_theme'] === true) {
116
+					$this->SelfPath = get_stylesheet_directory_uri() . '/library/cat-meta';
117
+				} elseif ($meta_box['use_with_theme'] === false) {
118
+					$this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__)));
119
+				} else {
120
+					$this->SelfPath = $meta_box['use_with_theme'];
121
+				}
122
+			else {
123
+				$this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__)));
124
+			}
125
+
126
+
127
+			// Add Actions
128
+			add_action('admin_init', array(&$this, 'add'));
129
+
130
+			// Check for special fields and add needed actions for them.
131
+			$this->check_field_upload();
132
+			$this->check_field_color();
133
+			$this->check_field_date();
134
+			$this->check_field_time();
135
+
136
+			// Load common js, css files
137
+			// Must enqueue for all pages as we need js for the media upload, too.
138
+			add_action('admin_print_styles', array(&$this, 'load_scripts_styles'));
139
+
140
+		}
141
+
142
+		/**
143
+		 * Load all Javascript and CSS
144
+		 *
145
+		 * @since 1.0
146
+		 * @access public
147
+		 */
148
+		public function load_scripts_styles()
149
+		{
150
+
151
+			// Get Plugin Path
152
+			$plugin_path = $this->SelfPath;
153
+			//only load styles and js when needed
154
+			/* 
155 155
 		 * since 1.0
156 156
 		 */
157
-            $taxnow = isset($_REQUEST['taxonomy']) ? $_REQUEST['taxonomy'] : '';
158
-
159
-            if (!empty($this->_meta_box['pages'])) {
160
-                if (in_array($taxnow, $this->_meta_box['pages'])) {
161
-                    // Enqueue Meta Box Style
162
-                    //wp_enqueue_style( 'tax-meta-clss', $plugin_path . '/css/Tax-meta-class.css' );
163
-                    // Enqueue Meta Box Scripts
164
-                    //wp_enqueue_script( 'tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array( 'jquery' ), null, true );
165
-
166
-                }
167
-            }
168
-
169
-        }
170
-
171
-        /**
172
-         * Check the Field Upload, Add needed Actions
173
-         *
174
-         * @since 1.0
175
-         * @access public
176
-         */
177
-        public function enqueue_tax_meta_scripts()
178
-        {
179
-            // Make upload feature work event when custom post type doesn't support 'editor'
180
-            wp_enqueue_script('media-upload');
181
-            wp_enqueue_script('thickbox');
182
-            add_thickbox();
183
-            wp_enqueue_script('jquery-ui-core');
184
-            wp_enqueue_script('jquery-ui-sortable');
185
-
186
-
187
-        }
188
-
189
-        public function check_field_upload()
190
-        {
191
-
192
-            // Check if the field is an image or file. If not, return.
193
-            if (!$this->has_field('image') && !$this->has_field('file'))
194
-                return;
195
-
196
-
197
-            add_action('wp_enqueue_scripts', array(&$this, 'enqueue_tax_meta_scripts'), 100);
198
-
199
-            // Add data encoding type for file uploading.	
200
-            add_action('post_edit_form_tag', array(&$this, 'add_enctype'));
201
-
202
-
203
-            // Add filters for media upload.
204
-            add_filter('media_upload_gallery', array(&$this, 'insert_images'));
205
-            add_filter('media_upload_library', array(&$this, 'insert_images'));
206
-            add_filter('media_upload_image', array(&$this, 'insert_images'));
207
-
208
-            // Delete all attachments when delete custom post type.
209
-            add_action('wp_ajax_at_delete_file', array(&$this, 'delete_file'));
210
-            add_action('wp_ajax_at_reorder_images', array(&$this, 'reorder_images'));
211
-            // Delete file via Ajax
212
-            add_action('wp_ajax_at_delete_mupload', array($this, 'wp_ajax_delete_image'));
213
-        }
214
-
215
-        /**
216
-         * Add data encoding type for file uploading
217
-         *
218
-         * @since 1.0
219
-         * @access public
220
-         */
221
-        public function add_enctype()
222
-        {
223
-            echo ' enctype="multipart/form-data"';
224
-        }
225
-
226
-        /**
227
-         * Process images added to meta field.
228
-         *
229
-         * Modified from Faster Image Insert plugin.
230
-         *
231
-         * @return void
232
-         * @author Cory Crowley
233
-         */
234
-        public function insert_images()
235
-        {
236
-
237
-            // If post variables are empty, return.
238
-            if (!isset($_POST['at-insert']) || empty($_POST['attachments']))
239
-                return;
240
-
241
-            // Security Check
242
-            check_admin_referer('media-form');
243
-
244
-            // Create Security Nonce
245
-            $nonce = wp_create_nonce('at_ajax_delete');
246
-
247
-            // Get Post Id and Field Id
248
-            $term_id = $_POST['post_id'];
249
-            $id = $_POST['field_id'];
250
-
251
-            // Modify the insertion string
252
-            $html = '';
253
-            foreach ($_POST['attachments'] as $attachment_id => $attachment) {
254
-
255
-                // Strip Slashes
256
-                $attachment = stripslashes_deep($attachment);
257
-
258
-                // If not selected or url is empty, continue in loop.
259
-                if (empty($attachment['selected']) || empty($attachment['url']))
260
-                    continue;
261
-
262
-                $li = "<li id='item_{$attachment_id}'>";
263
-                $li .= "<img src='{$attachment['url']}' alt='image_{$attachment_id}' />";
264
-                //$li 	.= "<a title='" . __( 'Delete this image' ) . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'>" . __( 'Delete' ) . "</a>";
265
-                $li .= "<a title='" . __('Remove this image', 'geodirectory') . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'><img src='" . $this->SelfPath . "/images/delete-16.png' alt='" . __('Remove', 'geodirectory') . "' /></a>";
266
-                $li .= "<input type='hidden' name='{$id}[]' value='{$attachment_id}' />";
267
-                $li .= "</li>";
268
-                $html .= $li;
269
-
270
-            } // End For Each
271
-
272
-            return media_send_to_editor($html);
273
-
274
-        }
275
-
276
-        /**
277
-         * Delete attachments associated with the post.
278
-         *
279
-         * @since 1.0
280
-         * @access public
281
-         *
282
-         * @param int|string $term_id The term ID.
283
-         */
284
-        /*public function delete_attachments( $term_id ) {
157
+			$taxnow = isset($_REQUEST['taxonomy']) ? $_REQUEST['taxonomy'] : '';
158
+
159
+			if (!empty($this->_meta_box['pages'])) {
160
+				if (in_array($taxnow, $this->_meta_box['pages'])) {
161
+					// Enqueue Meta Box Style
162
+					//wp_enqueue_style( 'tax-meta-clss', $plugin_path . '/css/Tax-meta-class.css' );
163
+					// Enqueue Meta Box Scripts
164
+					//wp_enqueue_script( 'tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array( 'jquery' ), null, true );
165
+
166
+				}
167
+			}
168
+
169
+		}
170
+
171
+		/**
172
+		 * Check the Field Upload, Add needed Actions
173
+		 *
174
+		 * @since 1.0
175
+		 * @access public
176
+		 */
177
+		public function enqueue_tax_meta_scripts()
178
+		{
179
+			// Make upload feature work event when custom post type doesn't support 'editor'
180
+			wp_enqueue_script('media-upload');
181
+			wp_enqueue_script('thickbox');
182
+			add_thickbox();
183
+			wp_enqueue_script('jquery-ui-core');
184
+			wp_enqueue_script('jquery-ui-sortable');
185
+
186
+
187
+		}
188
+
189
+		public function check_field_upload()
190
+		{
191
+
192
+			// Check if the field is an image or file. If not, return.
193
+			if (!$this->has_field('image') && !$this->has_field('file'))
194
+				return;
195
+
196
+
197
+			add_action('wp_enqueue_scripts', array(&$this, 'enqueue_tax_meta_scripts'), 100);
198
+
199
+			// Add data encoding type for file uploading.	
200
+			add_action('post_edit_form_tag', array(&$this, 'add_enctype'));
201
+
202
+
203
+			// Add filters for media upload.
204
+			add_filter('media_upload_gallery', array(&$this, 'insert_images'));
205
+			add_filter('media_upload_library', array(&$this, 'insert_images'));
206
+			add_filter('media_upload_image', array(&$this, 'insert_images'));
207
+
208
+			// Delete all attachments when delete custom post type.
209
+			add_action('wp_ajax_at_delete_file', array(&$this, 'delete_file'));
210
+			add_action('wp_ajax_at_reorder_images', array(&$this, 'reorder_images'));
211
+			// Delete file via Ajax
212
+			add_action('wp_ajax_at_delete_mupload', array($this, 'wp_ajax_delete_image'));
213
+		}
214
+
215
+		/**
216
+		 * Add data encoding type for file uploading
217
+		 *
218
+		 * @since 1.0
219
+		 * @access public
220
+		 */
221
+		public function add_enctype()
222
+		{
223
+			echo ' enctype="multipart/form-data"';
224
+		}
225
+
226
+		/**
227
+		 * Process images added to meta field.
228
+		 *
229
+		 * Modified from Faster Image Insert plugin.
230
+		 *
231
+		 * @return void
232
+		 * @author Cory Crowley
233
+		 */
234
+		public function insert_images()
235
+		{
236
+
237
+			// If post variables are empty, return.
238
+			if (!isset($_POST['at-insert']) || empty($_POST['attachments']))
239
+				return;
240
+
241
+			// Security Check
242
+			check_admin_referer('media-form');
243
+
244
+			// Create Security Nonce
245
+			$nonce = wp_create_nonce('at_ajax_delete');
246
+
247
+			// Get Post Id and Field Id
248
+			$term_id = $_POST['post_id'];
249
+			$id = $_POST['field_id'];
250
+
251
+			// Modify the insertion string
252
+			$html = '';
253
+			foreach ($_POST['attachments'] as $attachment_id => $attachment) {
254
+
255
+				// Strip Slashes
256
+				$attachment = stripslashes_deep($attachment);
257
+
258
+				// If not selected or url is empty, continue in loop.
259
+				if (empty($attachment['selected']) || empty($attachment['url']))
260
+					continue;
261
+
262
+				$li = "<li id='item_{$attachment_id}'>";
263
+				$li .= "<img src='{$attachment['url']}' alt='image_{$attachment_id}' />";
264
+				//$li 	.= "<a title='" . __( 'Delete this image' ) . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'>" . __( 'Delete' ) . "</a>";
265
+				$li .= "<a title='" . __('Remove this image', 'geodirectory') . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'><img src='" . $this->SelfPath . "/images/delete-16.png' alt='" . __('Remove', 'geodirectory') . "' /></a>";
266
+				$li .= "<input type='hidden' name='{$id}[]' value='{$attachment_id}' />";
267
+				$li .= "</li>";
268
+				$html .= $li;
269
+
270
+			} // End For Each
271
+
272
+			return media_send_to_editor($html);
273
+
274
+		}
275
+
276
+		/**
277
+		 * Delete attachments associated with the post.
278
+		 *
279
+		 * @since 1.0
280
+		 * @access public
281
+		 *
282
+		 * @param int|string $term_id The term ID.
283
+		 */
284
+		/*public function delete_attachments( $term_id ) {
285 285
 		
286 286
 		// Get Attachments
287 287
 		$attachments = get_posts( array( 'numberposts' => -1, 'post_type' => 'attachment', 'post_parent' => $term_id ) );
@@ -295,349 +295,349 @@  discard block
 block discarded – undo
295 295
 		
296 296
 	}*/
297 297
 
298
-        /**
299
-         * Ajax callback for deleting files.
300
-         *
301
-         * Modified from a function used by "Verve Meta Boxes" plugin ( http://goo.gl/aw64H )
302
-         *
303
-         * @since 1.0
304
-         * @access public
305
-         */
306
-        public function delete_file()
307
-        {
308
-
309
-
310
-            // If data is not set, die.
311
-            if (!isset($_POST['data']))
312
-                die();
313
-
314
-            list($nonce, $term_id, $key, $attach_id) = explode('|', $_POST['data']);
315
-
316
-            if (!wp_verify_nonce($nonce, 'at_ajax_delete'))
317
-                die('1');
318
-
319
-            $this->delete_tax_meta($term_id, $key, $attach_id);
320
-
321
-            die('0');
322
-
323
-        }
324
-
325
-        /**
326
-         * Ajax callback for deleting files.
327
-         * Modified from a function used by "Verve Meta Boxes" plugin (http://goo.gl/LzYSq)
328
-         * @since 1.0
329
-         * @access public
330
-         */
331
-        public function wp_ajax_delete_image()
332
-        {
333
-            $term_id = isset($_GET['post_id']) ? intval($_GET['post_id']) : 0;
334
-            $field_id = isset($_GET['field_id']) ? $_GET['field_id'] : 0;
335
-            $attachment_id = isset($_GET['attachment_id']) ? intval($_GET['attachment_id']) : 0;
336
-            $ok = false;
337
-            if (strpos($field_id, '[') === false) {
338
-                check_admin_referer("at-delete-mupload_" . urldecode($field_id));
339
-                if ($term_id > 0)
340
-                    $this->delete_tax_meta($term_id, $field_id);
341
-                //$ok = wp_delete_attachment( $attachment_id );
342
-                $ok = 1;
343
-            } else {
344
-                $f = explode('[', urldecode($field_id));
345
-                $f_fiexed = array();
346
-                foreach ($f as $k => $v) {
347
-                    $f[$k] = str_replace(']', '', $v);
348
-                }
349
-                $saved = $this->get_tax_meta($term_id, $f[0], true);
350
-                if (isset($saved[$f[1]][$f[2]])) {
351
-                    unset($saved[$f[1]][$f[2]]);
352
-                    if ($term_id > 0)
353
-                        update_post_meta($term_id, $f[0], $saved);
354
-                    //$ok = wp_delete_attachment( $attachment_id );
355
-                    $ok = 1;
356
-                }
357
-            }
358
-
359
-
360
-            if ($ok) {
361
-                echo json_encode(array('status' => 'success'));
362
-                die();
363
-            } else {
364
-                echo json_encode(array('message' => __('Cannot delete file. Something\'s wrong.', 'geodirectory')));
365
-                die();
366
-            }
367
-        }
368
-
369
-        /**
370
-         * Ajax callback for reordering Images.
371
-         *
372
-         * @since 1.0
373
-         * @access public
374
-         */
375
-        public function reorder_images()
376
-        {
377
-
378
-            if (!isset($_POST['data']))
379
-                die();
380
-
381
-            list($order, $term_id, $key, $nonce) = explode('|', $_POST['data']);
382
-
383
-            if (!wp_verify_nonce($nonce, 'at_ajax_reorder'))
384
-                die('1');
385
-
386
-            parse_str($order, $items);
387
-            $items = $items['item'];
388
-            $order = 1;
389
-            foreach ($items as $item) {
390
-                wp_update_post(array('ID' => $item, 'post_parent' => $term_id, 'menu_order' => $order));
391
-                $order++;
392
-            }
393
-
394
-            die('0');
395
-
396
-        }
397
-
398
-        /**
399
-         * Check Field Color
400
-         *
401
-         * @since 1.0
402
-         * @access public
403
-         */
404
-        public function check_field_color()
405
-        {
406
-
407
-            if ($this->has_field('color') && $this->is_edit_page()) {
408
-                // Enqueu built-in script and style for color picker.
409
-                wp_enqueue_style('farbtastic');
410
-                wp_enqueue_script('farbtastic');
411
-            }
412
-
413
-        }
414
-
415
-        /**
416
-         * Check Field Date
417
-         *
418
-         * @since 1.0
419
-         * @access public
420
-         */
421
-        public function check_field_date()
422
-        {
423
-
424
-            if ($this->has_field('date') && $this->is_edit_page()) {
425
-                // Enqueu JQuery UI, use proper version.
426
-                wp_enqueue_style('tmc-jquery-ui-css', 'http://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css');
427
-                wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery'));
428
-            }
429
-
430
-        }
431
-
432
-        /**
433
-         * Check Field Time
434
-         *
435
-         * @since 1.0
436
-         * @access public
437
-         */
438
-        public function check_field_time()
439
-        {
440
-
441
-            if ($this->has_field('time') && $this->is_edit_page()) {
442
-
443
-                // Enqueu JQuery UI, use proper version.
444
-                wp_enqueue_style('tmc-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css', array(), false, true);
445
-                wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery'), false, true);
446
-                wp_enqueue_script('at-timepicker', 'https://github.com/trentrichardson/jQuery-Timepicker-Addon/raw/master/jquery-ui-timepicker-addon.js', array('tmc-jquery-ui'), false, true);
447
-
448
-            }
449
-
450
-        }
451
-
452
-        /**
453
-         * Add Meta Box for multiple post types.
454
-         *
455
-         * @since 1.0
456
-         * @access public
457
-         */
458
-        public function add()
459
-        {
460
-
461
-            // Loop through array
462
-            if (!empty($this->_meta_box['pages'])) {
463
-                foreach ($this->_meta_box['pages'] as $page) {
464
-                    //add fields to edit form
465
-                    add_action($page . '_edit_form_fields', array(&$this, 'show_edit_form'));
466
-                    //add fields to add new form
467
-                    add_action($page . '_add_form_fields', array(&$this, 'show_new_form'));
468
-                    // this saves the edit fields
469
-                    add_action('edited_' . $page, array(&$this, 'save'), 10, 2);
470
-                    // this saves the add fields
471
-                    add_action('created_' . $page, array(&$this, 'save'), 10, 2);
472
-                }
473
-            }
474
-
475
-        }
476
-
477
-        /**
478
-         * Callback function to show fields on add new taxonomy term form.
479
-         *
480
-         * @since 1.0
481
-         * @access public
482
-         */
483
-        public function show_new_form($term_id)
484
-        {
485
-            $this->_form_type = 'new';
486
-            $this->show($term_id);
487
-        }
488
-
489
-        /**
490
-         * Callback function to show fields on term edit form.
491
-         *
492
-         * @since 1.0
493
-         * @access public
494
-         */
495
-        public function show_edit_form($term_id)
496
-        {
497
-            $this->_form_type = 'edit';
498
-            $this->show($term_id);
499
-        }
500
-
501
-
502
-        /**
503
-         * Callback function to show fields in meta box.
504
-         *
505
-         * @since 1.0
506
-         * @access public
507
-         */
508
-        public function show($term_id)
509
-        {
510
-
511
-            wp_nonce_field(basename(__FILE__), 'tax_meta_class_nonce');
512
-
513
-            foreach ($this->_fields as $field) {
514
-                $meta = $this->get_tax_meta($term_id, $field['id'], !$field['multiple']);
515
-                $meta = ($meta !== '') ? $meta : $field['std'];
516
-                if ('image' != $field['type'] && $field['type'] != 'repeater')
517
-                    $meta = is_array($meta) ? array_map('esc_attr', $meta) : esc_attr($meta);
518
-
519
-                if ($field['validate_func']) {
520
-                    echo '<tr class="form-field form-required ' . $field['style'] . '">';
521
-                } else {
522
-                    echo '<tr class="form-field ' . $field['style'] . '">';
523
-                }
524
-
525
-                // Call Separated methods for displaying each type of field.
526
-                call_user_func(array(&$this, 'show_field_' . $field['type']), $field, $meta);
527
-                echo '</tr>';
528
-            }
529
-            echo '</table>';
530
-        }
531
-
532
-        /**
533
-         * Show Repeater Fields.
534
-         *
535
-         * @param string $field
536
-         * @param string $meta
537
-         * @since 1.0
538
-         * @access public
539
-         */
540
-        public function show_field_repeater($field, $meta)
541
-        {
542
-            // Get Plugin Path
543
-            $plugin_path = $this->SelfPath;
544
-            $this->show_field_begin($field, $meta);
545
-            echo "<div class='at-repeat' id='{$field['id']}'>";
546
-
547
-            $c = 0;
548
-
549
-            if (count($meta) > 0 && is_array($meta)) {
550
-                foreach ($meta as $me) {
551
-                    //for labling toggles
552
-                    $mmm = $me[$field['fields'][0]['id']];
553
-                    echo '<div class="at-repater-block">' . $mmm . '<br/><table class="repeater-table" style="display: none;">';
554
-                    if ($field['inline']) {
555
-                        echo '<tr class="at-inline" VALIGN="top">';
556
-                    }
557
-                    foreach ($field['fields'] as $f) {
558
-                        //reset var $id for repeater
559
-                        $id = '';
560
-                        $id = $field['id'] . '[' . $c . '][' . $f['id'] . ']';
561
-                        $m = $me[$f['id']];
562
-                        $m = ($m !== '') ? $m : $f['std'];
563
-                        if ('image' != $f['type'] && $f['type'] != 'repeater')
564
-                            $m = is_array($m) ? array_map('esc_attr', $m) : esc_attr($m);
565
-                        //set new id for field in array format
566
-                        $f['id'] = $id;
567
-                        if (!$field['inline']) {
568
-                            echo '<tr>';
569
-                        }
570
-                        call_user_func(array(&$this, 'show_field_' . $f['type']), $f, $m);
571
-                        if (!$field['inline']) {
572
-                            echo '</tr>';
573
-                        }
574
-                    }
575
-                    if ($field['inline']) {
576
-                        echo '</tr>';
577
-                    }
578
-                    echo '</table>
298
+		/**
299
+		 * Ajax callback for deleting files.
300
+		 *
301
+		 * Modified from a function used by "Verve Meta Boxes" plugin ( http://goo.gl/aw64H )
302
+		 *
303
+		 * @since 1.0
304
+		 * @access public
305
+		 */
306
+		public function delete_file()
307
+		{
308
+
309
+
310
+			// If data is not set, die.
311
+			if (!isset($_POST['data']))
312
+				die();
313
+
314
+			list($nonce, $term_id, $key, $attach_id) = explode('|', $_POST['data']);
315
+
316
+			if (!wp_verify_nonce($nonce, 'at_ajax_delete'))
317
+				die('1');
318
+
319
+			$this->delete_tax_meta($term_id, $key, $attach_id);
320
+
321
+			die('0');
322
+
323
+		}
324
+
325
+		/**
326
+		 * Ajax callback for deleting files.
327
+		 * Modified from a function used by "Verve Meta Boxes" plugin (http://goo.gl/LzYSq)
328
+		 * @since 1.0
329
+		 * @access public
330
+		 */
331
+		public function wp_ajax_delete_image()
332
+		{
333
+			$term_id = isset($_GET['post_id']) ? intval($_GET['post_id']) : 0;
334
+			$field_id = isset($_GET['field_id']) ? $_GET['field_id'] : 0;
335
+			$attachment_id = isset($_GET['attachment_id']) ? intval($_GET['attachment_id']) : 0;
336
+			$ok = false;
337
+			if (strpos($field_id, '[') === false) {
338
+				check_admin_referer("at-delete-mupload_" . urldecode($field_id));
339
+				if ($term_id > 0)
340
+					$this->delete_tax_meta($term_id, $field_id);
341
+				//$ok = wp_delete_attachment( $attachment_id );
342
+				$ok = 1;
343
+			} else {
344
+				$f = explode('[', urldecode($field_id));
345
+				$f_fiexed = array();
346
+				foreach ($f as $k => $v) {
347
+					$f[$k] = str_replace(']', '', $v);
348
+				}
349
+				$saved = $this->get_tax_meta($term_id, $f[0], true);
350
+				if (isset($saved[$f[1]][$f[2]])) {
351
+					unset($saved[$f[1]][$f[2]]);
352
+					if ($term_id > 0)
353
+						update_post_meta($term_id, $f[0], $saved);
354
+					//$ok = wp_delete_attachment( $attachment_id );
355
+					$ok = 1;
356
+				}
357
+			}
358
+
359
+
360
+			if ($ok) {
361
+				echo json_encode(array('status' => 'success'));
362
+				die();
363
+			} else {
364
+				echo json_encode(array('message' => __('Cannot delete file. Something\'s wrong.', 'geodirectory')));
365
+				die();
366
+			}
367
+		}
368
+
369
+		/**
370
+		 * Ajax callback for reordering Images.
371
+		 *
372
+		 * @since 1.0
373
+		 * @access public
374
+		 */
375
+		public function reorder_images()
376
+		{
377
+
378
+			if (!isset($_POST['data']))
379
+				die();
380
+
381
+			list($order, $term_id, $key, $nonce) = explode('|', $_POST['data']);
382
+
383
+			if (!wp_verify_nonce($nonce, 'at_ajax_reorder'))
384
+				die('1');
385
+
386
+			parse_str($order, $items);
387
+			$items = $items['item'];
388
+			$order = 1;
389
+			foreach ($items as $item) {
390
+				wp_update_post(array('ID' => $item, 'post_parent' => $term_id, 'menu_order' => $order));
391
+				$order++;
392
+			}
393
+
394
+			die('0');
395
+
396
+		}
397
+
398
+		/**
399
+		 * Check Field Color
400
+		 *
401
+		 * @since 1.0
402
+		 * @access public
403
+		 */
404
+		public function check_field_color()
405
+		{
406
+
407
+			if ($this->has_field('color') && $this->is_edit_page()) {
408
+				// Enqueu built-in script and style for color picker.
409
+				wp_enqueue_style('farbtastic');
410
+				wp_enqueue_script('farbtastic');
411
+			}
412
+
413
+		}
414
+
415
+		/**
416
+		 * Check Field Date
417
+		 *
418
+		 * @since 1.0
419
+		 * @access public
420
+		 */
421
+		public function check_field_date()
422
+		{
423
+
424
+			if ($this->has_field('date') && $this->is_edit_page()) {
425
+				// Enqueu JQuery UI, use proper version.
426
+				wp_enqueue_style('tmc-jquery-ui-css', 'http://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css');
427
+				wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery'));
428
+			}
429
+
430
+		}
431
+
432
+		/**
433
+		 * Check Field Time
434
+		 *
435
+		 * @since 1.0
436
+		 * @access public
437
+		 */
438
+		public function check_field_time()
439
+		{
440
+
441
+			if ($this->has_field('time') && $this->is_edit_page()) {
442
+
443
+				// Enqueu JQuery UI, use proper version.
444
+				wp_enqueue_style('tmc-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css', array(), false, true);
445
+				wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery'), false, true);
446
+				wp_enqueue_script('at-timepicker', 'https://github.com/trentrichardson/jQuery-Timepicker-Addon/raw/master/jquery-ui-timepicker-addon.js', array('tmc-jquery-ui'), false, true);
447
+
448
+			}
449
+
450
+		}
451
+
452
+		/**
453
+		 * Add Meta Box for multiple post types.
454
+		 *
455
+		 * @since 1.0
456
+		 * @access public
457
+		 */
458
+		public function add()
459
+		{
460
+
461
+			// Loop through array
462
+			if (!empty($this->_meta_box['pages'])) {
463
+				foreach ($this->_meta_box['pages'] as $page) {
464
+					//add fields to edit form
465
+					add_action($page . '_edit_form_fields', array(&$this, 'show_edit_form'));
466
+					//add fields to add new form
467
+					add_action($page . '_add_form_fields', array(&$this, 'show_new_form'));
468
+					// this saves the edit fields
469
+					add_action('edited_' . $page, array(&$this, 'save'), 10, 2);
470
+					// this saves the add fields
471
+					add_action('created_' . $page, array(&$this, 'save'), 10, 2);
472
+				}
473
+			}
474
+
475
+		}
476
+
477
+		/**
478
+		 * Callback function to show fields on add new taxonomy term form.
479
+		 *
480
+		 * @since 1.0
481
+		 * @access public
482
+		 */
483
+		public function show_new_form($term_id)
484
+		{
485
+			$this->_form_type = 'new';
486
+			$this->show($term_id);
487
+		}
488
+
489
+		/**
490
+		 * Callback function to show fields on term edit form.
491
+		 *
492
+		 * @since 1.0
493
+		 * @access public
494
+		 */
495
+		public function show_edit_form($term_id)
496
+		{
497
+			$this->_form_type = 'edit';
498
+			$this->show($term_id);
499
+		}
500
+
501
+
502
+		/**
503
+		 * Callback function to show fields in meta box.
504
+		 *
505
+		 * @since 1.0
506
+		 * @access public
507
+		 */
508
+		public function show($term_id)
509
+		{
510
+
511
+			wp_nonce_field(basename(__FILE__), 'tax_meta_class_nonce');
512
+
513
+			foreach ($this->_fields as $field) {
514
+				$meta = $this->get_tax_meta($term_id, $field['id'], !$field['multiple']);
515
+				$meta = ($meta !== '') ? $meta : $field['std'];
516
+				if ('image' != $field['type'] && $field['type'] != 'repeater')
517
+					$meta = is_array($meta) ? array_map('esc_attr', $meta) : esc_attr($meta);
518
+
519
+				if ($field['validate_func']) {
520
+					echo '<tr class="form-field form-required ' . $field['style'] . '">';
521
+				} else {
522
+					echo '<tr class="form-field ' . $field['style'] . '">';
523
+				}
524
+
525
+				// Call Separated methods for displaying each type of field.
526
+				call_user_func(array(&$this, 'show_field_' . $field['type']), $field, $meta);
527
+				echo '</tr>';
528
+			}
529
+			echo '</table>';
530
+		}
531
+
532
+		/**
533
+		 * Show Repeater Fields.
534
+		 *
535
+		 * @param string $field
536
+		 * @param string $meta
537
+		 * @since 1.0
538
+		 * @access public
539
+		 */
540
+		public function show_field_repeater($field, $meta)
541
+		{
542
+			// Get Plugin Path
543
+			$plugin_path = $this->SelfPath;
544
+			$this->show_field_begin($field, $meta);
545
+			echo "<div class='at-repeat' id='{$field['id']}'>";
546
+
547
+			$c = 0;
548
+
549
+			if (count($meta) > 0 && is_array($meta)) {
550
+				foreach ($meta as $me) {
551
+					//for labling toggles
552
+					$mmm = $me[$field['fields'][0]['id']];
553
+					echo '<div class="at-repater-block">' . $mmm . '<br/><table class="repeater-table" style="display: none;">';
554
+					if ($field['inline']) {
555
+						echo '<tr class="at-inline" VALIGN="top">';
556
+					}
557
+					foreach ($field['fields'] as $f) {
558
+						//reset var $id for repeater
559
+						$id = '';
560
+						$id = $field['id'] . '[' . $c . '][' . $f['id'] . ']';
561
+						$m = $me[$f['id']];
562
+						$m = ($m !== '') ? $m : $f['std'];
563
+						if ('image' != $f['type'] && $f['type'] != 'repeater')
564
+							$m = is_array($m) ? array_map('esc_attr', $m) : esc_attr($m);
565
+						//set new id for field in array format
566
+						$f['id'] = $id;
567
+						if (!$field['inline']) {
568
+							echo '<tr>';
569
+						}
570
+						call_user_func(array(&$this, 'show_field_' . $f['type']), $f, $m);
571
+						if (!$field['inline']) {
572
+							echo '</tr>';
573
+						}
574
+					}
575
+					if ($field['inline']) {
576
+						echo '</tr>';
577
+					}
578
+					echo '</table>
579 579
 				<span class="at-re-toggle"><img src="';
580
-                    if ($this->_Local_images) {
581
-                        echo $plugin_path . '/images/edit.png';
582
-                    } else {
583
-                        echo 'http://i.imgur.com/ka0E2.png';
584
-                    }
585
-                    echo '" alt="Edit" title="Edit"/></span> 
580
+					if ($this->_Local_images) {
581
+						echo $plugin_path . '/images/edit.png';
582
+					} else {
583
+						echo 'http://i.imgur.com/ka0E2.png';
584
+					}
585
+					echo '" alt="Edit" title="Edit"/></span> 
586 586
 				<img src="';
587
-                    if ($this->_Local_images) {
588
-                        echo $plugin_path . '/images/remove.png';
589
-                    } else {
590
-                        echo 'http://i.imgur.com/g8Duj.png';
591
-                    }
592
-                    echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>';
593
-                    $c = $c + 1;
594
-
595
-                }
596
-                $this->show_field_end($field, $meta);
597
-            }
598
-
599
-            echo '<img src="';
600
-            if ($this->_Local_images) {
601
-                echo $plugin_path . '/images/add.png';
602
-            } else {
603
-                echo 'http://i.imgur.com/w5Tuc.png';
604
-            }
605
-            echo '" alt="' . __('Add', 'geodirectory') . '" title="' . __('Add', 'geodirectory') . '" id="add-' . $field['id'] . '"><br/></div>';
606
-
607
-            //create all fields once more for js function and catch with object buffer
608
-            ob_start();
609
-            echo '<div class="at-repater-block"><table class="repeater-table">';
610
-            if ($field['inline']) {
611
-                echo '<tr class="at-inline" VALIGN="top">';
612
-            }
613
-            foreach ($field['fields'] as $f) {
614
-                //reset var $id for repeater
615
-                $id = '';
616
-                $id = $field['id'] . '[CurrentCounter][' . $f['id'] . ']';
617
-                $f['id'] = $id;
618
-                if (!$field['inline']) {
619
-                    echo '<tr>';
620
-                }
621
-                call_user_func(array(&$this, 'show_field_' . $f['type']), $f, '');
622
-                if (!$field['inline']) {
623
-                    echo '</tr>';
624
-                }
625
-            }
626
-            if ($field['inline']) {
627
-                echo '</tr>';
628
-            }
629
-            echo '</table><img src="';
630
-            if ($this->_Local_images) {
631
-                echo $plugin_path . '/images/remove.png';
632
-            } else {
633
-                echo 'http://i.imgur.com/g8Duj.png';
634
-            }
635
-            echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>';
636
-            $counter = 'countadd_' . $field['id'];
637
-            $js_code = ob_get_clean();
638
-            $js_code = str_replace("'", "\"", $js_code);
639
-            $js_code = str_replace("CurrentCounter", "' + " . $counter . " + '", $js_code);
640
-            echo '<script>
587
+					if ($this->_Local_images) {
588
+						echo $plugin_path . '/images/remove.png';
589
+					} else {
590
+						echo 'http://i.imgur.com/g8Duj.png';
591
+					}
592
+					echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>';
593
+					$c = $c + 1;
594
+
595
+				}
596
+				$this->show_field_end($field, $meta);
597
+			}
598
+
599
+			echo '<img src="';
600
+			if ($this->_Local_images) {
601
+				echo $plugin_path . '/images/add.png';
602
+			} else {
603
+				echo 'http://i.imgur.com/w5Tuc.png';
604
+			}
605
+			echo '" alt="' . __('Add', 'geodirectory') . '" title="' . __('Add', 'geodirectory') . '" id="add-' . $field['id'] . '"><br/></div>';
606
+
607
+			//create all fields once more for js function and catch with object buffer
608
+			ob_start();
609
+			echo '<div class="at-repater-block"><table class="repeater-table">';
610
+			if ($field['inline']) {
611
+				echo '<tr class="at-inline" VALIGN="top">';
612
+			}
613
+			foreach ($field['fields'] as $f) {
614
+				//reset var $id for repeater
615
+				$id = '';
616
+				$id = $field['id'] . '[CurrentCounter][' . $f['id'] . ']';
617
+				$f['id'] = $id;
618
+				if (!$field['inline']) {
619
+					echo '<tr>';
620
+				}
621
+				call_user_func(array(&$this, 'show_field_' . $f['type']), $f, '');
622
+				if (!$field['inline']) {
623
+					echo '</tr>';
624
+				}
625
+			}
626
+			if ($field['inline']) {
627
+				echo '</tr>';
628
+			}
629
+			echo '</table><img src="';
630
+			if ($this->_Local_images) {
631
+				echo $plugin_path . '/images/remove.png';
632
+			} else {
633
+				echo 'http://i.imgur.com/g8Duj.png';
634
+			}
635
+			echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>';
636
+			$counter = 'countadd_' . $field['id'];
637
+			$js_code = ob_get_clean();
638
+			$js_code = str_replace("'", "\"", $js_code);
639
+			$js_code = str_replace("CurrentCounter", "' + " . $counter . " + '", $js_code);
640
+			echo '<script>
641 641
 				jQuery(document).ready(function() {
642 642
 					var ' . $counter . ' = ' . $c . ';
643 643
 					jQuery("#add-' . $field['id'] . '").live(\'click\', function() {
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
         			});
651 651
     			});
652 652
     		</script>';
653
-            echo '<br/><style>
653
+			echo '<br/><style>
654 654
 .at-inline{line-height: 1 !important;}
655 655
 .at-inline .at-field{border: 0px !important;}
656 656
 .at-inline .at-label{margin: 0 0 1px !important;}
@@ -658,532 +658,532 @@  discard block
 block discarded – undo
658 658
 .at-inline .at-textarea{width: 100px; height: 75px;}
659 659
 .at-repater-block{background-color: #FFFFFF;border: 1px solid;margin: 2px;}
660 660
 </style>';
661
-            $this->show_field_end($field, $meta);
662
-        }
663
-
664
-        /**
665
-         * Begin Field.
666
-         *
667
-         * @param string $field
668
-         * @param string $meta
669
-         * @since 1.0
670
-         * @access public
671
-         */
672
-        public function show_field_begin($field, $meta)
673
-        {
674
-            if (isset($field['group'])) {
675
-                if ($field['group'] == "start") {
676
-                    echo "<td class='at-field'>";
677
-                }
678
-            } else {
679
-                if ($this->_form_type == 'edit') {
680
-                    echo '<th valign="top" scope="row">';
681
-                } else {
682
-                    if ($field['validate_func']) {
683
-                        echo '<td><div class="form-field form-required">';
684
-                    } else {
685
-                        echo '<td><div class="form-field">';
686
-                    }
687
-                }
688
-            }
689
-            if ($field['name'] != '' || $field['name'] != FALSE) {
690
-                //echo "<div class='at-label'>";
691
-                echo "<label for='{$field['id']}'>{$field['name']}</label>";
692
-                //echo "</div>";
693
-            }
694
-            if ($this->_form_type == 'edit') {
695
-                echo '</th><td>';
696
-            }
697
-        }
698
-
699
-        /**
700
-         * End Field.
701
-         *
702
-         * @param string $field
703
-         * @param string $meta
704
-         * @since 1.0
705
-         * @access public
706
-         */
707
-        public function show_field_end($field, $meta = NULL, $group = false)
708
-        {
709
-            if (isset($field['group'])) {
710
-                if ($group == 'end') {
711
-                    if ($field['desc'] != '') {
712
-                        echo "<p class='desc-field'>{$field['desc']}</p></td>";
713
-                    } else {
714
-                        echo "</td>";
715
-                    }
716
-                } else {
717
-                    if ($field['desc'] != '') {
718
-                        echo "<p class='desc-field'>{$field['desc']}</p><br/>";
719
-                    } else {
720
-                        echo '<br/>';
721
-                    }
722
-                }
723
-            } else {
724
-                if ($field['desc'] != '') {
725
-                    echo "<p class='desc-field'>{$field['desc']}</p>";
726
-                }
727
-                if ($this->_form_type == 'edit') {
728
-                    echo '</td>';
729
-                } else {
730
-                    echo '</td></div>';
731
-                }
732
-            }
733
-        }
734
-
735
-        /**
736
-         * Show Field Text.
737
-         *
738
-         * @param string $field
739
-         * @param string $meta
740
-         * @since 1.0
741
-         * @access public
742
-         */
743
-        public function show_field_text($field, $meta)
744
-        {
745
-            $this->show_field_begin($field, $meta);
746
-            echo "<input type='text' class='at-text' name='{$field['id']}' id='{$field['id']}' value='{$meta}' size='30' />";
747
-            $this->show_field_end($field, $meta);
748
-        }
749
-
750
-        /**
751
-         * Show Field hidden.
752
-         *
753
-         * @param string $field
754
-         * @param string|mixed $meta
755
-         * @since 0.1.3
756
-         * @access public
757
-         */
758
-        public function show_field_hidden($field, $meta)
759
-        {
760
-            //$this->show_field_begin( $field, $meta );
761
-            echo "<input type='hidden' class='at-text' name='{$field['id']}' id='{$field['id']}' value='{$meta}'/>";
762
-            //$this->show_field_end( $field, $meta );
763
-        }
764
-
765
-        /**
766
-         * Show Field Paragraph.
767
-         *
768
-         * @param string $field
769
-         * @since 0.1.3
770
-         * @access public
771
-         */
772
-        public function show_field_paragraph($field)
773
-        {
774
-            //$this->show_field_begin( $field, $meta );
775
-            echo '<p>' . $field['value'] . '</p>';
776
-            //$this->show_field_end( $field, $meta );
777
-        }
778
-
779
-        /**
780
-         * Show Field Textarea.
781
-         *
782
-         * @param string $field
783
-         * @param string $meta
784
-         * @since 1.0
785
-         * @access public
786
-         */
787
-        public function show_field_textarea($field, $meta)
788
-        {
789
-            $this->show_field_begin($field, $meta);
790
-            echo "<textarea class='at-textarea large-text' name='{$field['id']}' id='{$field['id']}' cols='60' rows='10'>{$meta}</textarea>";
791
-            $this->show_field_end($field, $meta);
792
-        }
793
-
794
-        /**
795
-         * Show Field Select.
796
-         *
797
-         * @param string $field
798
-         * @param string $meta
799
-         * @since 1.0
800
-         * @access public
801
-         */
802
-        public function show_field_select($field, $meta)
803
-        {
804
-
805
-            if (!is_array($meta))
806
-                $meta = (array)$meta;
807
-
808
-            $this->show_field_begin($field, $meta);
809
-            echo "<select class='at-select' name='{$field['id']}" . ($field['multiple'] ? "[]' id='{$field['id']}' multiple='multiple'" : "'") . ">";
810
-            foreach ($field['options'] as $key => $value) {
811
-                echo "<option value='{$key}'" . selected(in_array($key, $meta), true, false) . ">{$value}</option>";
812
-            }
813
-            echo "</select>";
814
-            $this->show_field_end($field, $meta);
815
-
816
-        }
817
-
818
-        /**
819
-         * Show Radio Field.
820
-         *
821
-         * @param string $field
822
-         * @param string $meta
823
-         * @since 1.0
824
-         * @access public
825
-         */
826
-        public function show_field_radio($field, $meta)
827
-        {
828
-
829
-            if (!is_array($meta))
830
-                $meta = (array)$meta;
831
-
832
-            $this->show_field_begin($field, $meta);
833
-            foreach ($field['options'] as $key => $value) {
834
-                echo "<input type='radio' class='at-radio' name='{$field['id']}' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> <span class='at-radio-label'>{$value}</span>";
835
-            }
836
-            $this->show_field_end($field, $meta);
837
-        }
838
-
839
-        /**
840
-         * Show Checkbox Field.
841
-         *
842
-         * @param string $field
843
-         * @param string $meta
844
-         * @since 1.0
845
-         * @access public
846
-         */
847
-        public function show_field_checkbox($field, $meta)
848
-        {
849
-
850
-            $this->show_field_begin($field, $meta);
851
-            echo "<input type='checkbox' class='rw-checkbox' name='{$field['id']}' id='{$field['id']}'" . checked(!empty($meta), true, false) . " /> {$field['desc']}";
852
-            $this->show_field_end($field, $meta);
853
-        }
854
-
855
-        /**
856
-         * Show Wysiwig Field.
857
-         *
858
-         * @param string $field
859
-         * @param string $meta
860
-         * @since 1.0
861
-         * @access public
862
-         */
863
-        public function show_field_wysiwyg($field, $meta)
864
-        {
865
-            $this->show_field_begin($field, $meta);
866
-            // Add TinyMCE script for WP version < 3.3
867
-            global $wp_version;
868
-
869
-            if (version_compare($wp_version, '3.2.1') < 1) {
870
-                echo "<textarea class='at-wysiwyg theEditor large-text' name='{$field['id']}' id='{$field['id']}' cols='60' rows='10'>{$meta}</textarea>";
871
-            } else {
872
-                // Use new wp_editor() since WP 3.3
873
-                wp_editor(stripslashes(html_entity_decode($meta)), $field['id'], array('editor_class' => 'at-wysiwyg'));
874
-            }
875
-            $this->show_field_end($field, $meta);
876
-        }
877
-
878
-        /**
879
-         * Show File Field.
880
-         *
881
-         * @global object $post The current post object.
882
-         * @param string $field
883
-         * @param string $meta
884
-         * @since 1.0
885
-         * @access public
886
-         */
887
-        public function show_field_file($field, $meta)
888
-        {
889
-
890
-            global $post;
891
-
892
-            if (!is_array($meta))
893
-                $meta = (array)$meta;
894
-
895
-            $this->show_field_begin($field, $meta);
896
-            echo "{$field['desc']}<br />";
897
-
898
-            if (!empty($meta)) {
899
-                $nonce = wp_create_nonce('at_ajax_delete');
900
-                echo '<div style="margin-bottom: 10px"><strong>' . __('Uploaded files', 'geodirectory') . '</strong></div>';
901
-                echo '<ol class="at-upload">';
902
-                foreach ($meta as $att) {
903
-                    // if (wp_attachment_is_image($att)) continue; // what's image uploader for?
904
-                    echo "<li>" . wp_get_attachment_link($att, '', false, false, ' ') . " (<a class='at-delete-file' href='#' rel='{$nonce}|{$post->ID}|{$field['id']}|{$att}'>" . __('Remove', 'geodirectory') . "</a>)</li>";
905
-                }
906
-                echo '</ol>';
907
-            }
908
-
909
-            // show form upload
910
-
911
-            echo "<div class='at-file-upload-label'>";
912
-            echo "<strong>" . __('Upload new files', 'geodirectory') . "</strong>";
913
-            echo "</div>";
914
-            echo "<div class='new-files'>";
915
-            echo "<div class='file-input'>";
916
-            echo "<input type='file' name='{$field['id']}[]' />";
917
-            echo "</div><!-- End .file-input -->";
918
-            echo "<a class='at-add-file button' href='#'>" . __('Add more files', 'geodirectory') . "</a>";
919
-            echo "</div><!-- End .new-files -->";
920
-            echo "</td>";
921
-            $this->show_field_end($field, $meta);
922
-        }
923
-
924
-        /**
925
-         * Show Image Field.
926
-         *
927
-         * @param array $field
928
-         * @param array $meta
929
-         * @since 1.0
930
-         * @access public
931
-         */
932
-        public function show_field_image($field, $meta)
933
-        {
934
-            $this->show_field_begin($field, $meta);
935
-            $html = wp_nonce_field("at-delete-mupload_{$field['id']}", "nonce-delete-mupload_" . $field['id'], false, false);
936
-            if (is_array($meta)) {
937
-                if (isset($meta[0]) && is_array($meta[0]))
938
-                    $meta = $meta[0];
939
-            }
940
-
941
-            $uploads = wp_upload_dir();
942
-            if (is_array($meta) && isset($meta['src']) && $meta['src'] != '') {
943
-
944
-                $file_info = pathinfo($meta['src']);
945
-
946
-                //print_r($meta);
947
-                //print_r($uploads);
948
-                //print_r($file_info);
949
-
950
-                if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
951
-                    $sub_dir = $file_info['dirname'];
952
-
953
-                $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs	
954
-                $uploads_baseurl = $uploads['baseurl'];
955
-                $uploads_path = $uploads['path'];
956
-
957
-                $file_name = $file_info['basename'];
958
-
959
-                $sub_dir = str_replace($uploads_baseurl, '', $sub_dir);
960
-
961
-                $uploads_url = $uploads_baseurl . $sub_dir;
962
-
963
-                $meta['src'] = $uploads_url . '/' . $file_name;
964
-
965
-
966
-                $html .= "<span class='mupload_img_holder'><img src='" . $meta['src'] . "' style='max-height: 150px;max-width: 150px;' /></span>";
967
-                $html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='" . $meta['id'] . "' />";
968
-                $html .= "<input type='hidden' class='" . $field['id'] . "[src]' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='" . $meta['src'] . "' />";
969
-                $html .= "<input class='at-delete_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Remove Image', 'geodirectory') . "' />";
970
-            } else {
971
-                $html .= "<span class='mupload_img_holder'></span>";
972
-                $html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='' />";
973
-                $html .= "<input class='" . $field['id'] . "[src]' style='position:absolute;left:-500px;width:50px;' type='text' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='' />";
974
-                $html .= "<input class='at-upload_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Upload Image', 'geodirectory') . "' />";
975
-            }
976
-            echo $html;
977
-            $this->show_field_end($field, $meta);
978
-        }
979
-
980
-        /**
981
-         * Show Color Field.
982
-         *
983
-         * @param string $field
984
-         * @param string $meta
985
-         * @since 1.0
986
-         * @access public
987
-         */
988
-        public function show_field_color($field, $meta)
989
-        {
990
-
991
-            if (empty($meta))
992
-                $meta = '#';
993
-
994
-            $this->show_field_begin($field, $meta);
995
-
996
-            echo "<input class='at-color' type='text' name='{$field['id']}' id='{$field['id']}' value='{$meta}' size='8' />";
997
-            //	echo "<a href='#' class='at-color-select button' rel='{$field['id']}'>" . __( 'Select a color' ) . "</a>";
998
-            echo "<input type='button' class='at-color-select button' rel='{$field['id']}' value='" . __('Select a color', 'geodirectory') . "'/>";
999
-            echo "<div style='display:none' class='at-color-picker' rel='{$field['id']}'></div>";
1000
-            $this->show_field_end($field, $meta);
1001
-
1002
-        }
1003
-
1004
-        /**
1005
-         * Show Checkbox List Field
1006
-         *
1007
-         * @param string $field
1008
-         * @param string $meta
1009
-         * @since 1.0
1010
-         * @access public
1011
-         */
1012
-        public function show_field_checkbox_list($field, $meta)
1013
-        {
1014
-
1015
-            if (!is_array($meta))
1016
-                $meta = (array)$meta;
1017
-
1018
-            $this->show_field_begin($field, $meta);
1019
-
1020
-            $html = array();
1021
-
1022
-            foreach ($field['options'] as $key => $value) {
1023
-                $html[] = "<input type='checkbox' class='at-checkbox_list' name='{$field['id']}[]' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> {$value}";
1024
-            }
1025
-
1026
-            echo implode('<br />', $html);
1027
-
1028
-            $this->show_field_end($field, $meta);
1029
-
1030
-        }
1031
-
1032
-        /**
1033
-         * Show Date Field.
1034
-         *
1035
-         * @param string $field
1036
-         * @param string $meta
1037
-         * @since 1.0
1038
-         * @access public
1039
-         */
1040
-        public function show_field_date($field, $meta)
1041
-        {
1042
-            $this->show_field_begin($field, $meta);
1043
-            echo "<input type='text' class='at-date' name='{$field['id']}' id='{$field['id']}' rel='{$field['format']}' value='{$meta}' size='30' />";
1044
-            $this->show_field_end($field, $meta);
1045
-        }
1046
-
1047
-        /**
1048
-         * Show time field.
1049
-         *
1050
-         * @param string $field
1051
-         * @param string $meta
1052
-         * @since 1.0
1053
-         * @access public
1054
-         */
1055
-        public function show_field_time($field, $meta)
1056
-        {
1057
-            $this->show_field_begin($field, $meta);
1058
-            echo "<input type='text' class='at-time' name='{$field['id']}' id='{$field['id']}' rel='{$field['format']}' value='{$meta}' size='30' />";
1059
-            $this->show_field_end($field, $meta);
1060
-        }
1061
-
1062
-        /**
1063
-         * Show Posts field.
1064
-         * used creating a posts/pages/custom types checkboxlist or a select dropdown
1065
-         *
1066
-         * @global object $post The current post object.
1067
-         * @param string $field
1068
-         * @param string $meta
1069
-         * @since 1.0
1070
-         * @access public
1071
-         */
1072
-        public function show_field_posts($field, $meta)
1073
-        {
1074
-            global $post;
1075
-
1076
-            if (!is_array($meta)) $meta = (array)$meta;
1077
-            $this->show_field_begin($field, $meta);
1078
-            $options = $field['options'];
1079
-            $posts = get_posts($options['args']);
1080
-
1081
-            // checkbox_list
1082
-            if ('checkbox_list' == $options['type']) {
1083
-                foreach ($posts as $p) {
1084
-                    echo "<input type='checkbox' name='{$field['id']}[]' value='$p->ID'" . checked(in_array($p->ID, $meta), true, false) . " /> $p->post_title<br/>";
1085
-                }
1086
-            } // select
1087
-            else {
1088
-                echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">";
1089
-                foreach ($posts as $p) {
1090
-                    echo "<option value='$p->ID'" . selected(in_array($p->ID, $meta), true, false) . ">$p->post_title</option>";
1091
-                }
1092
-                echo "</select>";
1093
-            }
1094
-
1095
-            $this->show_field_end($field, $meta);
1096
-        }
1097
-
1098
-        /**
1099
-         * Show Taxonomy field.
1100
-         * used creating a category/tags/custom taxonomy checkboxlist or a select dropdown
1101
-         *
1102
-         * @global object $post The current post object.
1103
-         * @param string $field
1104
-         * @param string $meta
1105
-         * @since 1.0
1106
-         * @access public
1107
-         *
1108
-         * @uses get_terms()
1109
-         */
1110
-        public function show_field_taxonomy($field, $meta)
1111
-        {
1112
-            global $post;
1113
-
1114
-            if (!is_array($meta)) $meta = (array)$meta;
1115
-            $this->show_field_begin($field, $meta);
1116
-            $options = $field['options'];
1117
-            $terms = get_terms($options['taxonomy'], $options['args']);
1118
-
1119
-            // checkbox_list
1120
-            if ('checkbox_list' == $options['type']) {
1121
-                foreach ($terms as $term) {
1122
-                    echo "<input type='checkbox' name='{$field['id']}[]' value='$term->slug'" . checked(in_array($term->slug, $meta), true, false) . " /> $term->name<br/>";
1123
-                }
1124
-            } // select
1125
-            else {
1126
-                echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">";
1127
-                foreach ($terms as $term) {
1128
-                    echo "<option value='$term->slug'" . selected(in_array($term->slug, $meta), true, false) . ">$term->name</option>";
1129
-                }
1130
-                echo "</select>";
1131
-            }
1132
-
1133
-            $this->show_field_end($field, $meta);
1134
-        }
1135
-
1136
-        /**
1137
-         * Save Data from Metabox
1138
-         *
1139
-         * @param string $term_id The term ID.
1140
-         * @since 1.0
1141
-         * @access public
1142
-         * @return string
1143
-         */
1144
-        public function save($term_id)
1145
-        {
1146
-
1147
-            $taxnow = '';
1148
-            if (isset($_POST['taxonomy']))
1149
-                $taxnow = $_POST['taxonomy'];
1150
-
1151
-            if (!isset($term_id)                                                        // Check Revision
1152
-                || (!in_array($taxnow, $this->_meta_box['pages']))                            // Check if current taxonomy type is supported.
1153
-                || (!check_admin_referer(basename(__FILE__), 'tax_meta_class_nonce'))        // Check nonce - Security
1154
-                || (!current_user_can('manage_categories'))
1155
-            )                                // Check permission
1156
-            {
1157
-                return $term_id;
1158
-            }
1159
-
1160
-
1161
-            foreach ($this->_fields as $field) {
1162
-
1163
-                $name = $field['id'];
1164
-                $type = $field['type'];
1165
-                $old = $this->get_tax_meta($term_id, $name, !$field['multiple']);
1166
-                $new = (isset($_POST[$name])) ? $_POST[$name] : (($field['multiple']) ? array() : '');
1167
-
1168
-                // Validate meta value
1169
-                if (class_exists('Tax_Meta_Validate') && method_exists('Tax_Meta_Validate', $field['validate_func'])) {
1170
-                    $new = call_user_func(array('Tax_Meta_Validate', $field['validate_func']), $new);
1171
-                }
1172
-
1173
-
1174
-                if ($name == 'ct_cat_icon') {
1175
-
1176
-                    $upload_dir = wp_upload_dir();
1177
-
1178
-                    $image_name_arr = explode('/', $new['src']);
1179
-                    //$old_filename = end($image_name_arr);
1180
-                    //$img_name_arr = explode('.',$old_filename);
1181
-
1182
-                    //$old_filename = $upload_dir['path'].'/'.$old_filename;
1183
-
1184
-                    $new_filename = $upload_dir['path'] . '/' . 'cat_icon_' . $term_id . '.png';
1185
-
1186
-                    /*rename($old_filename, $new_filename);
661
+			$this->show_field_end($field, $meta);
662
+		}
663
+
664
+		/**
665
+		 * Begin Field.
666
+		 *
667
+		 * @param string $field
668
+		 * @param string $meta
669
+		 * @since 1.0
670
+		 * @access public
671
+		 */
672
+		public function show_field_begin($field, $meta)
673
+		{
674
+			if (isset($field['group'])) {
675
+				if ($field['group'] == "start") {
676
+					echo "<td class='at-field'>";
677
+				}
678
+			} else {
679
+				if ($this->_form_type == 'edit') {
680
+					echo '<th valign="top" scope="row">';
681
+				} else {
682
+					if ($field['validate_func']) {
683
+						echo '<td><div class="form-field form-required">';
684
+					} else {
685
+						echo '<td><div class="form-field">';
686
+					}
687
+				}
688
+			}
689
+			if ($field['name'] != '' || $field['name'] != FALSE) {
690
+				//echo "<div class='at-label'>";
691
+				echo "<label for='{$field['id']}'>{$field['name']}</label>";
692
+				//echo "</div>";
693
+			}
694
+			if ($this->_form_type == 'edit') {
695
+				echo '</th><td>';
696
+			}
697
+		}
698
+
699
+		/**
700
+		 * End Field.
701
+		 *
702
+		 * @param string $field
703
+		 * @param string $meta
704
+		 * @since 1.0
705
+		 * @access public
706
+		 */
707
+		public function show_field_end($field, $meta = NULL, $group = false)
708
+		{
709
+			if (isset($field['group'])) {
710
+				if ($group == 'end') {
711
+					if ($field['desc'] != '') {
712
+						echo "<p class='desc-field'>{$field['desc']}</p></td>";
713
+					} else {
714
+						echo "</td>";
715
+					}
716
+				} else {
717
+					if ($field['desc'] != '') {
718
+						echo "<p class='desc-field'>{$field['desc']}</p><br/>";
719
+					} else {
720
+						echo '<br/>';
721
+					}
722
+				}
723
+			} else {
724
+				if ($field['desc'] != '') {
725
+					echo "<p class='desc-field'>{$field['desc']}</p>";
726
+				}
727
+				if ($this->_form_type == 'edit') {
728
+					echo '</td>';
729
+				} else {
730
+					echo '</td></div>';
731
+				}
732
+			}
733
+		}
734
+
735
+		/**
736
+		 * Show Field Text.
737
+		 *
738
+		 * @param string $field
739
+		 * @param string $meta
740
+		 * @since 1.0
741
+		 * @access public
742
+		 */
743
+		public function show_field_text($field, $meta)
744
+		{
745
+			$this->show_field_begin($field, $meta);
746
+			echo "<input type='text' class='at-text' name='{$field['id']}' id='{$field['id']}' value='{$meta}' size='30' />";
747
+			$this->show_field_end($field, $meta);
748
+		}
749
+
750
+		/**
751
+		 * Show Field hidden.
752
+		 *
753
+		 * @param string $field
754
+		 * @param string|mixed $meta
755
+		 * @since 0.1.3
756
+		 * @access public
757
+		 */
758
+		public function show_field_hidden($field, $meta)
759
+		{
760
+			//$this->show_field_begin( $field, $meta );
761
+			echo "<input type='hidden' class='at-text' name='{$field['id']}' id='{$field['id']}' value='{$meta}'/>";
762
+			//$this->show_field_end( $field, $meta );
763
+		}
764
+
765
+		/**
766
+		 * Show Field Paragraph.
767
+		 *
768
+		 * @param string $field
769
+		 * @since 0.1.3
770
+		 * @access public
771
+		 */
772
+		public function show_field_paragraph($field)
773
+		{
774
+			//$this->show_field_begin( $field, $meta );
775
+			echo '<p>' . $field['value'] . '</p>';
776
+			//$this->show_field_end( $field, $meta );
777
+		}
778
+
779
+		/**
780
+		 * Show Field Textarea.
781
+		 *
782
+		 * @param string $field
783
+		 * @param string $meta
784
+		 * @since 1.0
785
+		 * @access public
786
+		 */
787
+		public function show_field_textarea($field, $meta)
788
+		{
789
+			$this->show_field_begin($field, $meta);
790
+			echo "<textarea class='at-textarea large-text' name='{$field['id']}' id='{$field['id']}' cols='60' rows='10'>{$meta}</textarea>";
791
+			$this->show_field_end($field, $meta);
792
+		}
793
+
794
+		/**
795
+		 * Show Field Select.
796
+		 *
797
+		 * @param string $field
798
+		 * @param string $meta
799
+		 * @since 1.0
800
+		 * @access public
801
+		 */
802
+		public function show_field_select($field, $meta)
803
+		{
804
+
805
+			if (!is_array($meta))
806
+				$meta = (array)$meta;
807
+
808
+			$this->show_field_begin($field, $meta);
809
+			echo "<select class='at-select' name='{$field['id']}" . ($field['multiple'] ? "[]' id='{$field['id']}' multiple='multiple'" : "'") . ">";
810
+			foreach ($field['options'] as $key => $value) {
811
+				echo "<option value='{$key}'" . selected(in_array($key, $meta), true, false) . ">{$value}</option>";
812
+			}
813
+			echo "</select>";
814
+			$this->show_field_end($field, $meta);
815
+
816
+		}
817
+
818
+		/**
819
+		 * Show Radio Field.
820
+		 *
821
+		 * @param string $field
822
+		 * @param string $meta
823
+		 * @since 1.0
824
+		 * @access public
825
+		 */
826
+		public function show_field_radio($field, $meta)
827
+		{
828
+
829
+			if (!is_array($meta))
830
+				$meta = (array)$meta;
831
+
832
+			$this->show_field_begin($field, $meta);
833
+			foreach ($field['options'] as $key => $value) {
834
+				echo "<input type='radio' class='at-radio' name='{$field['id']}' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> <span class='at-radio-label'>{$value}</span>";
835
+			}
836
+			$this->show_field_end($field, $meta);
837
+		}
838
+
839
+		/**
840
+		 * Show Checkbox Field.
841
+		 *
842
+		 * @param string $field
843
+		 * @param string $meta
844
+		 * @since 1.0
845
+		 * @access public
846
+		 */
847
+		public function show_field_checkbox($field, $meta)
848
+		{
849
+
850
+			$this->show_field_begin($field, $meta);
851
+			echo "<input type='checkbox' class='rw-checkbox' name='{$field['id']}' id='{$field['id']}'" . checked(!empty($meta), true, false) . " /> {$field['desc']}";
852
+			$this->show_field_end($field, $meta);
853
+		}
854
+
855
+		/**
856
+		 * Show Wysiwig Field.
857
+		 *
858
+		 * @param string $field
859
+		 * @param string $meta
860
+		 * @since 1.0
861
+		 * @access public
862
+		 */
863
+		public function show_field_wysiwyg($field, $meta)
864
+		{
865
+			$this->show_field_begin($field, $meta);
866
+			// Add TinyMCE script for WP version < 3.3
867
+			global $wp_version;
868
+
869
+			if (version_compare($wp_version, '3.2.1') < 1) {
870
+				echo "<textarea class='at-wysiwyg theEditor large-text' name='{$field['id']}' id='{$field['id']}' cols='60' rows='10'>{$meta}</textarea>";
871
+			} else {
872
+				// Use new wp_editor() since WP 3.3
873
+				wp_editor(stripslashes(html_entity_decode($meta)), $field['id'], array('editor_class' => 'at-wysiwyg'));
874
+			}
875
+			$this->show_field_end($field, $meta);
876
+		}
877
+
878
+		/**
879
+		 * Show File Field.
880
+		 *
881
+		 * @global object $post The current post object.
882
+		 * @param string $field
883
+		 * @param string $meta
884
+		 * @since 1.0
885
+		 * @access public
886
+		 */
887
+		public function show_field_file($field, $meta)
888
+		{
889
+
890
+			global $post;
891
+
892
+			if (!is_array($meta))
893
+				$meta = (array)$meta;
894
+
895
+			$this->show_field_begin($field, $meta);
896
+			echo "{$field['desc']}<br />";
897
+
898
+			if (!empty($meta)) {
899
+				$nonce = wp_create_nonce('at_ajax_delete');
900
+				echo '<div style="margin-bottom: 10px"><strong>' . __('Uploaded files', 'geodirectory') . '</strong></div>';
901
+				echo '<ol class="at-upload">';
902
+				foreach ($meta as $att) {
903
+					// if (wp_attachment_is_image($att)) continue; // what's image uploader for?
904
+					echo "<li>" . wp_get_attachment_link($att, '', false, false, ' ') . " (<a class='at-delete-file' href='#' rel='{$nonce}|{$post->ID}|{$field['id']}|{$att}'>" . __('Remove', 'geodirectory') . "</a>)</li>";
905
+				}
906
+				echo '</ol>';
907
+			}
908
+
909
+			// show form upload
910
+
911
+			echo "<div class='at-file-upload-label'>";
912
+			echo "<strong>" . __('Upload new files', 'geodirectory') . "</strong>";
913
+			echo "</div>";
914
+			echo "<div class='new-files'>";
915
+			echo "<div class='file-input'>";
916
+			echo "<input type='file' name='{$field['id']}[]' />";
917
+			echo "</div><!-- End .file-input -->";
918
+			echo "<a class='at-add-file button' href='#'>" . __('Add more files', 'geodirectory') . "</a>";
919
+			echo "</div><!-- End .new-files -->";
920
+			echo "</td>";
921
+			$this->show_field_end($field, $meta);
922
+		}
923
+
924
+		/**
925
+		 * Show Image Field.
926
+		 *
927
+		 * @param array $field
928
+		 * @param array $meta
929
+		 * @since 1.0
930
+		 * @access public
931
+		 */
932
+		public function show_field_image($field, $meta)
933
+		{
934
+			$this->show_field_begin($field, $meta);
935
+			$html = wp_nonce_field("at-delete-mupload_{$field['id']}", "nonce-delete-mupload_" . $field['id'], false, false);
936
+			if (is_array($meta)) {
937
+				if (isset($meta[0]) && is_array($meta[0]))
938
+					$meta = $meta[0];
939
+			}
940
+
941
+			$uploads = wp_upload_dir();
942
+			if (is_array($meta) && isset($meta['src']) && $meta['src'] != '') {
943
+
944
+				$file_info = pathinfo($meta['src']);
945
+
946
+				//print_r($meta);
947
+				//print_r($uploads);
948
+				//print_r($file_info);
949
+
950
+				if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
951
+					$sub_dir = $file_info['dirname'];
952
+
953
+				$uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs	
954
+				$uploads_baseurl = $uploads['baseurl'];
955
+				$uploads_path = $uploads['path'];
956
+
957
+				$file_name = $file_info['basename'];
958
+
959
+				$sub_dir = str_replace($uploads_baseurl, '', $sub_dir);
960
+
961
+				$uploads_url = $uploads_baseurl . $sub_dir;
962
+
963
+				$meta['src'] = $uploads_url . '/' . $file_name;
964
+
965
+
966
+				$html .= "<span class='mupload_img_holder'><img src='" . $meta['src'] . "' style='max-height: 150px;max-width: 150px;' /></span>";
967
+				$html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='" . $meta['id'] . "' />";
968
+				$html .= "<input type='hidden' class='" . $field['id'] . "[src]' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='" . $meta['src'] . "' />";
969
+				$html .= "<input class='at-delete_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Remove Image', 'geodirectory') . "' />";
970
+			} else {
971
+				$html .= "<span class='mupload_img_holder'></span>";
972
+				$html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='' />";
973
+				$html .= "<input class='" . $field['id'] . "[src]' style='position:absolute;left:-500px;width:50px;' type='text' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='' />";
974
+				$html .= "<input class='at-upload_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Upload Image', 'geodirectory') . "' />";
975
+			}
976
+			echo $html;
977
+			$this->show_field_end($field, $meta);
978
+		}
979
+
980
+		/**
981
+		 * Show Color Field.
982
+		 *
983
+		 * @param string $field
984
+		 * @param string $meta
985
+		 * @since 1.0
986
+		 * @access public
987
+		 */
988
+		public function show_field_color($field, $meta)
989
+		{
990
+
991
+			if (empty($meta))
992
+				$meta = '#';
993
+
994
+			$this->show_field_begin($field, $meta);
995
+
996
+			echo "<input class='at-color' type='text' name='{$field['id']}' id='{$field['id']}' value='{$meta}' size='8' />";
997
+			//	echo "<a href='#' class='at-color-select button' rel='{$field['id']}'>" . __( 'Select a color' ) . "</a>";
998
+			echo "<input type='button' class='at-color-select button' rel='{$field['id']}' value='" . __('Select a color', 'geodirectory') . "'/>";
999
+			echo "<div style='display:none' class='at-color-picker' rel='{$field['id']}'></div>";
1000
+			$this->show_field_end($field, $meta);
1001
+
1002
+		}
1003
+
1004
+		/**
1005
+		 * Show Checkbox List Field
1006
+		 *
1007
+		 * @param string $field
1008
+		 * @param string $meta
1009
+		 * @since 1.0
1010
+		 * @access public
1011
+		 */
1012
+		public function show_field_checkbox_list($field, $meta)
1013
+		{
1014
+
1015
+			if (!is_array($meta))
1016
+				$meta = (array)$meta;
1017
+
1018
+			$this->show_field_begin($field, $meta);
1019
+
1020
+			$html = array();
1021
+
1022
+			foreach ($field['options'] as $key => $value) {
1023
+				$html[] = "<input type='checkbox' class='at-checkbox_list' name='{$field['id']}[]' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> {$value}";
1024
+			}
1025
+
1026
+			echo implode('<br />', $html);
1027
+
1028
+			$this->show_field_end($field, $meta);
1029
+
1030
+		}
1031
+
1032
+		/**
1033
+		 * Show Date Field.
1034
+		 *
1035
+		 * @param string $field
1036
+		 * @param string $meta
1037
+		 * @since 1.0
1038
+		 * @access public
1039
+		 */
1040
+		public function show_field_date($field, $meta)
1041
+		{
1042
+			$this->show_field_begin($field, $meta);
1043
+			echo "<input type='text' class='at-date' name='{$field['id']}' id='{$field['id']}' rel='{$field['format']}' value='{$meta}' size='30' />";
1044
+			$this->show_field_end($field, $meta);
1045
+		}
1046
+
1047
+		/**
1048
+		 * Show time field.
1049
+		 *
1050
+		 * @param string $field
1051
+		 * @param string $meta
1052
+		 * @since 1.0
1053
+		 * @access public
1054
+		 */
1055
+		public function show_field_time($field, $meta)
1056
+		{
1057
+			$this->show_field_begin($field, $meta);
1058
+			echo "<input type='text' class='at-time' name='{$field['id']}' id='{$field['id']}' rel='{$field['format']}' value='{$meta}' size='30' />";
1059
+			$this->show_field_end($field, $meta);
1060
+		}
1061
+
1062
+		/**
1063
+		 * Show Posts field.
1064
+		 * used creating a posts/pages/custom types checkboxlist or a select dropdown
1065
+		 *
1066
+		 * @global object $post The current post object.
1067
+		 * @param string $field
1068
+		 * @param string $meta
1069
+		 * @since 1.0
1070
+		 * @access public
1071
+		 */
1072
+		public function show_field_posts($field, $meta)
1073
+		{
1074
+			global $post;
1075
+
1076
+			if (!is_array($meta)) $meta = (array)$meta;
1077
+			$this->show_field_begin($field, $meta);
1078
+			$options = $field['options'];
1079
+			$posts = get_posts($options['args']);
1080
+
1081
+			// checkbox_list
1082
+			if ('checkbox_list' == $options['type']) {
1083
+				foreach ($posts as $p) {
1084
+					echo "<input type='checkbox' name='{$field['id']}[]' value='$p->ID'" . checked(in_array($p->ID, $meta), true, false) . " /> $p->post_title<br/>";
1085
+				}
1086
+			} // select
1087
+			else {
1088
+				echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">";
1089
+				foreach ($posts as $p) {
1090
+					echo "<option value='$p->ID'" . selected(in_array($p->ID, $meta), true, false) . ">$p->post_title</option>";
1091
+				}
1092
+				echo "</select>";
1093
+			}
1094
+
1095
+			$this->show_field_end($field, $meta);
1096
+		}
1097
+
1098
+		/**
1099
+		 * Show Taxonomy field.
1100
+		 * used creating a category/tags/custom taxonomy checkboxlist or a select dropdown
1101
+		 *
1102
+		 * @global object $post The current post object.
1103
+		 * @param string $field
1104
+		 * @param string $meta
1105
+		 * @since 1.0
1106
+		 * @access public
1107
+		 *
1108
+		 * @uses get_terms()
1109
+		 */
1110
+		public function show_field_taxonomy($field, $meta)
1111
+		{
1112
+			global $post;
1113
+
1114
+			if (!is_array($meta)) $meta = (array)$meta;
1115
+			$this->show_field_begin($field, $meta);
1116
+			$options = $field['options'];
1117
+			$terms = get_terms($options['taxonomy'], $options['args']);
1118
+
1119
+			// checkbox_list
1120
+			if ('checkbox_list' == $options['type']) {
1121
+				foreach ($terms as $term) {
1122
+					echo "<input type='checkbox' name='{$field['id']}[]' value='$term->slug'" . checked(in_array($term->slug, $meta), true, false) . " /> $term->name<br/>";
1123
+				}
1124
+			} // select
1125
+			else {
1126
+				echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">";
1127
+				foreach ($terms as $term) {
1128
+					echo "<option value='$term->slug'" . selected(in_array($term->slug, $meta), true, false) . ">$term->name</option>";
1129
+				}
1130
+				echo "</select>";
1131
+			}
1132
+
1133
+			$this->show_field_end($field, $meta);
1134
+		}
1135
+
1136
+		/**
1137
+		 * Save Data from Metabox
1138
+		 *
1139
+		 * @param string $term_id The term ID.
1140
+		 * @since 1.0
1141
+		 * @access public
1142
+		 * @return string
1143
+		 */
1144
+		public function save($term_id)
1145
+		{
1146
+
1147
+			$taxnow = '';
1148
+			if (isset($_POST['taxonomy']))
1149
+				$taxnow = $_POST['taxonomy'];
1150
+
1151
+			if (!isset($term_id)                                                        // Check Revision
1152
+				|| (!in_array($taxnow, $this->_meta_box['pages']))                            // Check if current taxonomy type is supported.
1153
+				|| (!check_admin_referer(basename(__FILE__), 'tax_meta_class_nonce'))        // Check nonce - Security
1154
+				|| (!current_user_can('manage_categories'))
1155
+			)                                // Check permission
1156
+			{
1157
+				return $term_id;
1158
+			}
1159
+
1160
+
1161
+			foreach ($this->_fields as $field) {
1162
+
1163
+				$name = $field['id'];
1164
+				$type = $field['type'];
1165
+				$old = $this->get_tax_meta($term_id, $name, !$field['multiple']);
1166
+				$new = (isset($_POST[$name])) ? $_POST[$name] : (($field['multiple']) ? array() : '');
1167
+
1168
+				// Validate meta value
1169
+				if (class_exists('Tax_Meta_Validate') && method_exists('Tax_Meta_Validate', $field['validate_func'])) {
1170
+					$new = call_user_func(array('Tax_Meta_Validate', $field['validate_func']), $new);
1171
+				}
1172
+
1173
+
1174
+				if ($name == 'ct_cat_icon') {
1175
+
1176
+					$upload_dir = wp_upload_dir();
1177
+
1178
+					$image_name_arr = explode('/', $new['src']);
1179
+					//$old_filename = end($image_name_arr);
1180
+					//$img_name_arr = explode('.',$old_filename);
1181
+
1182
+					//$old_filename = $upload_dir['path'].'/'.$old_filename;
1183
+
1184
+					$new_filename = $upload_dir['path'] . '/' . 'cat_icon_' . $term_id . '.png';
1185
+
1186
+					/*rename($old_filename, $new_filename);
1187 1187
 				
1188 1188
 				//subdir
1189 1189
 				$new['src'] = $upload_dir['url'].'/'.'cat_icon_'.$term_id.'.png';
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
 				update_attached_file( $new['id'], $new['src'] );*/
1192 1192
 
1193 1193
 
1194
-                    /*	
1194
+					/*	
1195 1195
 		
1196 1196
 		$new['src'] = $upload_dir['url'].'/'.'cat_icon_'.$term_id.'.png';
1197 1197
 		
@@ -1216,67 +1216,67 @@  discard block
 block discarded – undo
1216 1216
 		$attach_id = wp_insert_attachment( $attachment, $filename);*/
1217 1217
 
1218 1218
 
1219
-                }
1220
-
1221
-
1222
-                //skip on Paragraph field
1223
-                if ($type != "paragraph") {
1224
-
1225
-                    // Call defined method to save meta value, if there's no methods, call common one.
1226
-                    $save_func = 'save_field_' . $type;
1227
-                    if (method_exists($this, $save_func)) {
1228
-                        call_user_func(array(&$this, 'save_field_' . $type), $term_id, $field, $old, $new);
1229
-                    } else {
1230
-                        $this->save_field($term_id, $field, $old, $new);
1231
-                    }
1232
-                }
1233
-
1234
-            } // End foreach
1235
-
1236
-        }
1237
-
1238
-        /**
1239
-         * Common function for saving fields.
1240
-         *
1241
-         * @param string $term_id The term ID.
1242
-         * @param string $field
1243
-         * @param string $old
1244
-         * @param string|mixed $new
1245
-         * @since 1.0
1246
-         * @access public
1247
-         */
1248
-        public function save_field($term_id, $field, $old, $new)
1249
-        {
1250
-            $name = $field['id'];
1251
-            $this->delete_tax_meta($term_id, $name);
1252
-            if ($new === '' || $new === array())
1253
-                return;
1254
-
1255
-            $this->update_tax_meta($term_id, $name, $new);
1256
-        }
1257
-
1258
-        /**
1259
-         * function for saving image field.
1260
-         *
1261
-         * @param string $term_id The term ID.
1262
-         * @param string $field
1263
-         * @param string $old
1264
-         * @param string|mixed $new
1265
-         * @since 1.0
1266
-         * @access public
1267
-         */
1268
-        public function save_field_image($term_id, $field, $old, $new)
1269
-        {
1270
-            $name = $field['id'];
1271
-
1272
-            $this->delete_tax_meta($term_id, $name);
1273
-            if ($new === '' || $new === array() || $new['id'] == '' || $new['src'] == '')
1274
-                return;
1275
-
1276
-            $this->update_tax_meta($term_id, $name, $new);
1277
-        }
1278
-
1279
-        /*
1219
+				}
1220
+
1221
+
1222
+				//skip on Paragraph field
1223
+				if ($type != "paragraph") {
1224
+
1225
+					// Call defined method to save meta value, if there's no methods, call common one.
1226
+					$save_func = 'save_field_' . $type;
1227
+					if (method_exists($this, $save_func)) {
1228
+						call_user_func(array(&$this, 'save_field_' . $type), $term_id, $field, $old, $new);
1229
+					} else {
1230
+						$this->save_field($term_id, $field, $old, $new);
1231
+					}
1232
+				}
1233
+
1234
+			} // End foreach
1235
+
1236
+		}
1237
+
1238
+		/**
1239
+		 * Common function for saving fields.
1240
+		 *
1241
+		 * @param string $term_id The term ID.
1242
+		 * @param string $field
1243
+		 * @param string $old
1244
+		 * @param string|mixed $new
1245
+		 * @since 1.0
1246
+		 * @access public
1247
+		 */
1248
+		public function save_field($term_id, $field, $old, $new)
1249
+		{
1250
+			$name = $field['id'];
1251
+			$this->delete_tax_meta($term_id, $name);
1252
+			if ($new === '' || $new === array())
1253
+				return;
1254
+
1255
+			$this->update_tax_meta($term_id, $name, $new);
1256
+		}
1257
+
1258
+		/**
1259
+		 * function for saving image field.
1260
+		 *
1261
+		 * @param string $term_id The term ID.
1262
+		 * @param string $field
1263
+		 * @param string $old
1264
+		 * @param string|mixed $new
1265
+		 * @since 1.0
1266
+		 * @access public
1267
+		 */
1268
+		public function save_field_image($term_id, $field, $old, $new)
1269
+		{
1270
+			$name = $field['id'];
1271
+
1272
+			$this->delete_tax_meta($term_id, $name);
1273
+			if ($new === '' || $new === array() || $new['id'] == '' || $new['src'] == '')
1274
+				return;
1275
+
1276
+			$this->update_tax_meta($term_id, $name, $new);
1277
+		}
1278
+
1279
+		/*
1280 1280
 	 * Save Wysiwyg Field.
1281 1281
 	 *
1282 1282
 	 * @param string $term_id The term ID. 
@@ -1286,806 +1286,806 @@  discard block
 block discarded – undo
1286 1286
 	 * @since 1.0
1287 1287
 	 * @access public 
1288 1288
 	 */
1289
-        public function save_field_wysiwyg($term_id, $field, $old, $new)
1290
-        {
1291
-            $this->save_field($term_id, $field, $old, $new);
1292
-        }
1293
-
1294
-        /**
1295
-         * Save repeater Fields.
1296
-         *
1297
-         * @param string $term_id The term ID.
1298
-         * @param string $field
1299
-         * @param string|mixed $old
1300
-         * @param string|mixed $new
1301
-         * @since 1.0
1302
-         * @access public
1303
-         */
1304
-        public function save_field_repeater($term_id, $field, $old, $new)
1305
-        {
1306
-            if (is_array($new) && count($new) > 0) {
1307
-                foreach ($new as $n) {
1308
-                    foreach ($field['fields'] as $f) {
1309
-                        $type = $f['type'];
1310
-                        switch ($type) {
1311
-                            case 'wysiwyg':
1312
-                                $n[$f['id']] = wpautop($n[$f['id']]);
1313
-                                break;
1314
-                            case 'file':
1315
-                                $n[$f['id']] = $this->save_field_file_repeater($term_id, $f, '', $n[$f['id']]);
1316
-                                break;
1317
-                            default:
1318
-                                break;
1319
-                        }
1320
-                    }
1321
-                    if (!$this->is_array_empty($n))
1322
-                        $temp[] = $n;
1323
-                }
1324
-                if (isset($temp) && count($temp) > 0 && !$this->is_array_empty($temp)) {
1325
-                    $this->update_tax_meta($term_id, $field['id'], $temp);
1326
-                } else {
1327
-                    //	remove old meta if exists
1328
-                    delete_post_meta($term_id, $field['id']);
1329
-                }
1330
-            } else {
1331
-                //	remove old meta if exists
1332
-                delete_post_meta($term_id, $field['id']);
1333
-            }
1334
-        }
1335
-
1336
-        /**
1337
-         * Save File Field.
1338
-         *
1339
-         * @param string $term_id The term ID.
1340
-         * @param string $field
1341
-         * @param string $old
1342
-         * @param string $new
1343
-         * @since 1.0
1344
-         * @access public
1345
-         */
1346
-        public function save_field_file($term_id, $field, $old, $new)
1347
-        {
1348
-
1349
-            $name = $field['id'];
1350
-            if (empty($_FILES[$name]))
1351
-                return;
1352
-            $this->fix_file_array($_FILES[$name]);
1353
-            foreach ($_FILES[$name] as $position => $fileitem) {
1354
-
1355
-                $file = wp_handle_upload($fileitem, array('test_form' => false));
1356
-                if (empty($file['file']))
1357
-                    continue;
1358
-                $filename = $file['file'];
1359
-
1360
-                $attachment = array(
1361
-                    'post_mime_type' => $file['type'],
1362
-                    'guid' => $file['url'],
1363
-                    'post_parent' => $term_id,
1364
-                    'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
1365
-                    'post_content' => ''
1366
-                );
1367
-
1368
-                $id = wp_insert_attachment($attachment, $filename, $term_id);
1369
-
1370
-                if (!is_wp_error($id)) {
1371
-
1372
-                    wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename));
1373
-                    add_post_meta($term_id, $name, $id, false);    // save file's url in meta fields
1374
-
1375
-                } // End if
1376
-
1377
-            } // End foreach
1378
-
1379
-        }
1380
-
1381
-        /**
1382
-         * Save repeater File Field.
1383
-         * @param string $term_id The term ID.
1384
-         * @param string $field
1385
-         * @param string $old
1386
-         * @param string $new
1387
-         * @since 1.0
1388
-         * @access public
1389
-         * @return int|void
1390
-         */
1391
-        public function save_field_file_repeater($term_id, $field, $old, $new)
1392
-        {
1393
-
1394
-            $name = $field['id'];
1395
-            if (empty($_FILES[$name]))
1396
-                return;
1397
-            $this->fix_file_array($_FILES[$name]);
1398
-            foreach ($_FILES[$name] as $position => $fileitem) {
1399
-
1400
-                $file = wp_handle_upload($fileitem, array('test_form' => false));
1401
-                if (empty($file['file']))
1402
-                    continue;
1403
-                $filename = $file['file'];
1404
-
1405
-                $attachment = array(
1406
-                    'post_mime_type' => $file['type'],
1407
-                    'guid' => $file['url'],
1408
-                    'post_parent' => $term_id,
1409
-                    'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
1410
-                    'post_content' => ''
1411
-                );
1412
-
1413
-                $id = wp_insert_attachment($attachment, $filename);
1414
-
1415
-                if (!is_wp_error($id)) {
1416
-
1417
-                    wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename));
1418
-                    return $id;    // return file's url in meta fields
1419
-                } // End if
1420
-            } // End foreach
1421
-        }
1422
-
1423
-        /**
1424
-         * Add missed values for meta box.
1425
-         *
1426
-         * @since 1.0
1427
-         * @access public
1428
-         */
1429
-        public function add_missed_values()
1430
-        {
1431
-
1432
-            // Default values for meta box
1433
-            $this->_meta_box = array_merge(array('context' => 'normal', 'priority' => 'high', 'pages' => array('post')), (array)$this->_meta_box);
1434
-
1435
-            if(is_array($this->_fields)) {
1436
-                // Default values for fields
1437
-                foreach ($this->_fields as &$field) {
1438
-                    $multiple = in_array($field['type'], array('checkbox_list', 'file', 'image'));
1439
-                    $std = $multiple ? array() : '';
1440
-                    $format = 'date' == $field['type'] ? 'yy-mm-dd' : ('time' == $field['type'] ? 'hh:mm' : '');
1441
-                    $field = array_merge(array('multiple' => $multiple, 'std' => $std, 'desc' => '', 'format' => $format, 'validate_func' => ''), $field);
1442
-                } // End foreach
1443
-            }
1444
-        }
1445
-
1446
-        /**
1447
-         * Check if field with $type exists.
1448
-         *
1449
-         * @param string $type
1450
-         * @since 1.0
1451
-         * @access public
1452
-         */
1453
-        public function has_field($type)
1454
-        {
1455
-            if(is_array($this->_fields)) {
1456
-                foreach ($this->_fields as $field) {
1457
-                    if ($type == $field['type'])
1458
-                        return true;
1459
-                }
1460
-            }
1461
-            return false;
1462
-        }
1463
-
1464
-        /**
1465
-         * Check if current page is edit page.
1466
-         *
1467
-         * @since 1.0
1468
-         * @access public
1469
-         */
1470
-        public function is_edit_page()
1471
-        {
1472
-            global $pagenow;
1473
-            return ($pagenow == 'edit-tags.php' || $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.
geodirectory-functions/compatibility/X.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -113,7 +113,7 @@
 block discarded – undo
113 113
  * @since 1.0.0
114 114
  * @package GeoDirectory
115 115
  * @param array $classes Class array.
116
- * @return array Modified class array.
116
+ * @return string[] Modified class array.
117 117
  */
118 118
 function geodir_x_body_class($classes)
119 119
 {
Please login to merge, or discard this patch.
Indentation   +211 added lines, -211 removed lines patch added patch discarded remove patch
@@ -19,60 +19,60 @@  discard block
 block discarded – undo
19 19
 function geodir_x_action_calls()
20 20
 {
21 21
 
22
-    /* ACTIONS
22
+	/* ACTIONS
23 23
     ****************************************************************************************/
24 24
 
25
-    // Add body class for styling purposes
26
-    add_filter('body_class', 'geodir_x_body_class');
25
+	// Add body class for styling purposes
26
+	add_filter('body_class', 'geodir_x_body_class');
27 27
 
28
-    // HOME TOP SIDEBAR
29
-    //remove_action( 'geodir_location_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10 );
30
-    //remove_action( 'geodir_home_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10 );
31
-    //add_action( 'geodir_wrapper_open', 'geodir_x_home_sidebar', 5 );
32
-    add_action('geodir_before_search_form', 'geodir_x_search_container_open');
33
-    add_action('geodir_after_search_form', 'geodir_x_search_container_close');
28
+	// HOME TOP SIDEBAR
29
+	//remove_action( 'geodir_location_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10 );
30
+	//remove_action( 'geodir_home_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10 );
31
+	//add_action( 'geodir_wrapper_open', 'geodir_x_home_sidebar', 5 );
32
+	add_action('geodir_before_search_form', 'geodir_x_search_container_open');
33
+	add_action('geodir_after_search_form', 'geodir_x_search_container_close');
34 34
 
35
-    // WRAPPER OPEN ACTIONS
36
-    remove_action('geodir_wrapper_open', 'geodir_action_wrapper_open', 10);
37
-    add_action('geodir_wrapper_open', 'geodir_x_action_wrapper_open', 9);
35
+	// WRAPPER OPEN ACTIONS
36
+	remove_action('geodir_wrapper_open', 'geodir_action_wrapper_open', 10);
37
+	add_action('geodir_wrapper_open', 'geodir_x_action_wrapper_open', 9);
38 38
 
39
-    // WRAPPER CLOSE ACTIONS
40
-    remove_action('geodir_wrapper_close', 'geodir_action_wrapper_close', 10);
41
-    add_action('geodir_wrapper_close', 'geodir_x_action_wrapper_close', 11);
39
+	// WRAPPER CLOSE ACTIONS
40
+	remove_action('geodir_wrapper_close', 'geodir_action_wrapper_close', 10);
41
+	add_action('geodir_wrapper_close', 'geodir_x_action_wrapper_close', 11);
42 42
 
43
-    // WRAPPER CONTENT OPEN ACTIONS
44
-    remove_action('geodir_wrapper_content_open', 'geodir_action_wrapper_content_open', 10);
45
-    add_action('geodir_wrapper_content_open', 'geodir_x_action_wrapper_content_open', 9, 3);
43
+	// WRAPPER CONTENT OPEN ACTIONS
44
+	remove_action('geodir_wrapper_content_open', 'geodir_action_wrapper_content_open', 10);
45
+	add_action('geodir_wrapper_content_open', 'geodir_x_action_wrapper_content_open', 9, 3);
46 46
 
47
-    // WRAPPER CONTENT CLOSE ACTIONS
48
-    remove_action('geodir_wrapper_content_close', 'geodir_action_wrapper_content_close', 10);
49
-    add_action('geodir_wrapper_content_close', 'geodir_x_action_wrapper_content_close', 11);
47
+	// WRAPPER CONTENT CLOSE ACTIONS
48
+	remove_action('geodir_wrapper_content_close', 'geodir_action_wrapper_content_close', 10);
49
+	add_action('geodir_wrapper_content_close', 'geodir_x_action_wrapper_content_close', 11);
50 50
 
51
-    // SIDEBAR RIGHT OPEN ACTIONS
52
-    remove_action('geodir_sidebar_right_open', 'geodir_action_sidebar_right_open', 10);
53
-    add_action('geodir_sidebar_right_open', 'geodir_x_action_sidebar_right_open', 10, 4);
51
+	// SIDEBAR RIGHT OPEN ACTIONS
52
+	remove_action('geodir_sidebar_right_open', 'geodir_action_sidebar_right_open', 10);
53
+	add_action('geodir_sidebar_right_open', 'geodir_x_action_sidebar_right_open', 10, 4);
54 54
 
55
-    // SIDEBAR RIGHT CLOSE ACTIONS
56
-    remove_action('geodir_sidebar_right_close', 'geodir_action_sidebar_right_close', 10);
57
-    add_action('geodir_sidebar_right_close', 'geodir_x_action_sidebar_right_close', 10, 1);
55
+	// SIDEBAR RIGHT CLOSE ACTIONS
56
+	remove_action('geodir_sidebar_right_close', 'geodir_action_sidebar_right_close', 10);
57
+	add_action('geodir_sidebar_right_close', 'geodir_x_action_sidebar_right_close', 10, 1);
58 58
 
59
-    // REMOVE BREADCRUMBS
60
-    remove_action('geodir_listings_before_main_content', 'geodir_breadcrumb', 20);
61
-    remove_action('geodir_detail_before_main_content', 'geodir_breadcrumb', 20);
62
-    remove_action('geodir_search_before_main_content', 'geodir_breadcrumb', 20);
63
-    remove_action('geodir_author_before_main_content', 'geodir_breadcrumb', 20);
64
-    remove_action('geodir_home_before_main_content', 'geodir_breadcrumb', 20);
65
-    remove_action('geodir_location_before_main_content', 'geodir_breadcrumb', 20);
59
+	// REMOVE BREADCRUMBS
60
+	remove_action('geodir_listings_before_main_content', 'geodir_breadcrumb', 20);
61
+	remove_action('geodir_detail_before_main_content', 'geodir_breadcrumb', 20);
62
+	remove_action('geodir_search_before_main_content', 'geodir_breadcrumb', 20);
63
+	remove_action('geodir_author_before_main_content', 'geodir_breadcrumb', 20);
64
+	remove_action('geodir_home_before_main_content', 'geodir_breadcrumb', 20);
65
+	remove_action('geodir_location_before_main_content', 'geodir_breadcrumb', 20);
66 66
 
67
-    // make top section wide
68
-    remove_action('geodir_home_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10);
69
-    remove_action('geodir_location_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10);
70
-    remove_action('geodir_author_before_main_content', 'geodir_action_geodir_sidebar_author_top', 10);
71
-    remove_action('geodir_search_before_main_content', 'geodir_action_geodir_sidebar_search_top', 10);
72
-    remove_action('geodir_detail_before_main_content', 'geodir_action_geodir_sidebar_detail_top', 10);
73
-    remove_action('geodir_listings_before_main_content', 'geodir_action_geodir_sidebar_listings_top', 10);
67
+	// make top section wide
68
+	remove_action('geodir_home_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10);
69
+	remove_action('geodir_location_before_main_content', 'geodir_action_geodir_sidebar_home_top', 10);
70
+	remove_action('geodir_author_before_main_content', 'geodir_action_geodir_sidebar_author_top', 10);
71
+	remove_action('geodir_search_before_main_content', 'geodir_action_geodir_sidebar_search_top', 10);
72
+	remove_action('geodir_detail_before_main_content', 'geodir_action_geodir_sidebar_detail_top', 10);
73
+	remove_action('geodir_listings_before_main_content', 'geodir_action_geodir_sidebar_listings_top', 10);
74 74
 
75
-    add_action('geodir_wrapper_open', 'gd_X_compat_add_top_section_back', 5);
75
+	add_action('geodir_wrapper_open', 'gd_X_compat_add_top_section_back', 5);
76 76
 
77 77
 
78 78
 } // Close geodir_x_action_calls
@@ -89,17 +89,17 @@  discard block
 block discarded – undo
89 89
 function gd_X_compat_add_top_section_back()
90 90
 {
91 91
 
92
-    if (is_page_geodir_home() || geodir_is_page('location')) {
93
-        geodir_action_geodir_sidebar_home_top();
94
-    } elseif (geodir_is_page('listing')) {
95
-        geodir_action_geodir_sidebar_listings_top();
96
-    } elseif (geodir_is_page('detail')) {
97
-        geodir_action_geodir_sidebar_detail_top();
98
-    } elseif (geodir_is_page('search')) {
99
-        geodir_action_geodir_sidebar_search_top();
100
-    } elseif (geodir_is_page('author')) {
101
-        geodir_action_geodir_sidebar_author_top();
102
-    }
92
+	if (is_page_geodir_home() || geodir_is_page('location')) {
93
+		geodir_action_geodir_sidebar_home_top();
94
+	} elseif (geodir_is_page('listing')) {
95
+		geodir_action_geodir_sidebar_listings_top();
96
+	} elseif (geodir_is_page('detail')) {
97
+		geodir_action_geodir_sidebar_detail_top();
98
+	} elseif (geodir_is_page('search')) {
99
+		geodir_action_geodir_sidebar_search_top();
100
+	} elseif (geodir_is_page('author')) {
101
+		geodir_action_geodir_sidebar_author_top();
102
+	}
103 103
 
104 104
 
105 105
 }
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
  */
118 118
 function geodir_x_body_class($classes)
119 119
 {
120
-    $classes[] = 'geodir-x';
121
-    return $classes;
120
+	$classes[] = 'geodir-x';
121
+	return $classes;
122 122
 }
123 123
 
124 124
 /**
@@ -130,14 +130,14 @@  discard block
 block discarded – undo
130 130
  */
131 131
 function geodir_x_home_sidebar()
132 132
 {
133
-    //if ( geodir_is_geodir_page() ) {
134
-    global $wp;
135
-    if ($wp->query_vars['page_id'] == geodir_location_page_id() || is_home() && !geodir_is_page('login')) {
136
-        echo '<div class="x-main full">';
137
-        dynamic_sidebar('geodir_home_top');
138
-        echo '</div>';
139
-    }
140
-    //}
133
+	//if ( geodir_is_geodir_page() ) {
134
+	global $wp;
135
+	if ($wp->query_vars['page_id'] == geodir_location_page_id() || is_home() && !geodir_is_page('login')) {
136
+		echo '<div class="x-main full">';
137
+		dynamic_sidebar('geodir_home_top');
138
+		echo '</div>';
139
+	}
140
+	//}
141 141
 }
142 142
 
143 143
 /**
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
  */
149 149
 function geodir_x_search_container_open()
150 150
 {
151
-    echo '<div class="x-container-fluid x-container max">';
151
+	echo '<div class="x-container-fluid x-container max">';
152 152
 }
153 153
 
154 154
 /**
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
  */
160 160
 function geodir_x_search_container_close()
161 161
 {
162
-    echo '</div>';
162
+	echo '</div>';
163 163
 }
164 164
 
165 165
 /**
@@ -170,16 +170,16 @@  discard block
 block discarded – undo
170 170
  */
171 171
 function geodir_x_action_wrapper_open()
172 172
 {
173
-    global $stack;
174
-    if ($stack == 'integrity') {
175
-        echo '<div class="x-container-fluid x-container max width offset">';
176
-    } elseif ($stack == 'renew') {
177
-        echo '<div class="x-container-fluid x-container max width offset cf">';
178
-    } elseif ($stack == 'icon') {
179
-        echo '<div class="x-main full" role="main">';
180
-    } elseif ($stack == 'ethos') {
181
-        echo '<div class="x-container-fluid x-container max width main"><div class="offset cf">';
182
-    }
173
+	global $stack;
174
+	if ($stack == 'integrity') {
175
+		echo '<div class="x-container-fluid x-container max width offset">';
176
+	} elseif ($stack == 'renew') {
177
+		echo '<div class="x-container-fluid x-container max width offset cf">';
178
+	} elseif ($stack == 'icon') {
179
+		echo '<div class="x-main full" role="main">';
180
+	} elseif ($stack == 'ethos') {
181
+		echo '<div class="x-container-fluid x-container max width main"><div class="offset cf">';
182
+	}
183 183
 }
184 184
 
185 185
 /**
@@ -190,12 +190,12 @@  discard block
 block discarded – undo
190 190
  */
191 191
 function geodir_x_action_wrapper_close()
192 192
 {
193
-    global $stack;
194
-    if ($stack == 'ethos') {
195
-        echo '</div></div>';
196
-    } else {
197
-        echo '</div>';
198
-    }
193
+	global $stack;
194
+	if ($stack == 'ethos') {
195
+		echo '</div></div>';
196
+	} else {
197
+		echo '</div>';
198
+	}
199 199
 }
200 200
 
201 201
 /**
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
  */
210 210
 function geodir_x_action_wrapper_content_open($type = '', $id = '', $class = '')
211 211
 {
212
-    echo '<div class="x-main left ' . $class . '" role="main">';
212
+	echo '<div class="x-main left ' . $class . '" role="main">';
213 213
 }
214 214
 
215 215
 /**
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
  */
221 221
 function geodir_x_action_wrapper_content_close()
222 222
 {
223
-    echo '</div>';
223
+	echo '</div>';
224 224
 }
225 225
 
226 226
 /**
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
  */
236 236
 function geodir_x_action_sidebar_right_open($type = '', $id = '', $class = '', $itemtype = '')
237 237
 {
238
-    echo '<aside class="x-sidebar right" role="complementary" itemscope itemtype="' . $itemtype . '">';
238
+	echo '<aside class="x-sidebar right" role="complementary" itemscope itemtype="' . $itemtype . '">';
239 239
 }
240 240
 
241 241
 /**
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
  */
248 248
 function geodir_x_action_sidebar_right_close($type = '')
249 249
 {
250
-    echo '</aside>';
250
+	echo '</aside>';
251 251
 }
252 252
 
253 253
 add_filter('geodir_breadcrumb', 'geodir_x_breadcrumb');
@@ -261,12 +261,12 @@  discard block
 block discarded – undo
261 261
  */
262 262
 function geodir_x_breadcrumb($breadcrumb)
263 263
 {
264
-    $breadcrumb = str_replace('<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs">', '', $breadcrumb);
265
-    $breadcrumb = str_replace('<li>', '', $breadcrumb);
266
-    $breadcrumb = str_replace('</li>', '', $breadcrumb);
267
-    $breadcrumb = str_replace('Home', '<span class="home"><i class="x-icon-home"></i></span>', $breadcrumb);
268
-    $breadcrumb = str_replace('</ul></div>', '', $breadcrumb);
269
-    return $breadcrumb;
264
+	$breadcrumb = str_replace('<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs">', '', $breadcrumb);
265
+	$breadcrumb = str_replace('<li>', '', $breadcrumb);
266
+	$breadcrumb = str_replace('</li>', '', $breadcrumb);
267
+	$breadcrumb = str_replace('Home', '<span class="home"><i class="x-icon-home"></i></span>', $breadcrumb);
268
+	$breadcrumb = str_replace('</ul></div>', '', $breadcrumb);
269
+	return $breadcrumb;
270 270
 }
271 271
 
272 272
 add_filter('geodir_breadcrumb_separator', 'geodir_x_breadcrumb_separator');
@@ -280,125 +280,125 @@  discard block
 block discarded – undo
280 280
  */
281 281
 function geodir_x_breadcrumb_separator($separator)
282 282
 {
283
-    $separator = str_replace(' > ', ' <span class="delimiter"><i class="x-icon-angle-right"></i></span> ', $separator);
284
-    return $separator;
283
+	$separator = str_replace(' > ', ' <span class="delimiter"><i class="x-icon-angle-right"></i></span> ', $separator);
284
+	return $separator;
285 285
 }
286 286
 
287 287
 if (!function_exists('x_breadcrumbs')) :
288
-    /**
289
-     * breadcrumbs.
290
-     *
291
-     * @since 1.0.0
292
-     * @package GeoDirectory
293
-     */
294
-    function x_breadcrumbs()
295
-    {
296
-
297
-        if (x_get_option('x_breadcrumb_display', '1')) {
298
-
299
-            //
300
-            // 1. Delimiter between crumbs.
301
-            // 2. Output text for the "Home" link.
302
-            // 3. Link to the home page.
303
-            // 4. Tag before the current crumb.
304
-            // 5. Tag after the current crumb.
305
-            // 6. Get page title.
306
-            // 7. Get blog title.
307
-            // 8. Get shop title.
308
-            //
309
-
310
-            GLOBAL $post,$wp;
311
-
312
-            if (geodir_is_page('detail') || geodir_is_page('listing') || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id())) {
313
-                geodir_breadcrumb();
314
-            } else {
315
-
316
-                $stack = x_get_stack();
317
-                $delimiter = ' <span class="delimiter"><i class="x-icon-angle-right"></i></span> '; // 1
318
-                $home_text = '<span class="home"><i class="x-icon-home"></i></span>';               // 2
319
-                $home_link = home_url();                                                            // 3
320
-                $current_before = '<span class="current">';                                              // 4
321
-                $current_after = '</span>';                                                             // 5
322
-                $page_title = get_the_title();                                                       // 6
323
-                $blog_title = get_the_title(get_option('page_for_posts', true));                 // 7
324
-                $shop_title = get_theme_mod('x_' . $stack . '_shop_title');                        // 8
325
-
326
-                if (function_exists('woocommerce_get_page_id')) {
327
-                    $shop_url = x_get_shop_link();
328
-                    $shop_link = '<a href="' . $shop_url . '">' . $shop_title . '</a>';
329
-                }
330
-
331
-                if (is_front_page()) {
332
-                    echo '<div class="x-breadcrumbs">' . $current_before . $home_text . $current_after . '</div>';
333
-                } elseif (is_home()) {
334
-                    echo '<div class="x-breadcrumbs"><a href="' . $home_link . '">' . $home_text . '</a>' . $delimiter . $current_before . $blog_title . $current_after . '</div>';
335
-                } else {
336
-                    echo '<div class="x-breadcrumbs"><a href="' . $home_link . '">' . $home_text . '</a>' . $delimiter;
337
-                    if (is_category()) {
338
-                        $the_cat = get_category(get_query_var('cat'), false);
339
-                        if ($the_cat->parent != 0) echo get_category_parents($the_cat->parent, TRUE, $delimiter);
340
-                        echo $current_before . single_cat_title('', false) . $current_after;
341
-                    } elseif (x_is_product_category()) {
342
-                        echo $shop_link . $delimiter . $current_before . single_cat_title('', false) . $current_after;
343
-                    } elseif (x_is_product_tag()) {
344
-                        echo $shop_link . $delimiter . $current_before . single_tag_title('', false) . $current_after;
345
-                    } elseif (is_search()) {
346
-                        echo $current_before . __('Search Results for ', '__x__') . '&#8220;' . get_search_query() . '&#8221;' . $current_after;
347
-                    } elseif (is_singular('post')) {
348
-                        if (get_option('page_for_posts') == is_front_page()) {
349
-                            echo $current_before . $page_title . $current_after;
350
-                        } else {
351
-                            echo '<a href="' . get_permalink(get_option('page_for_posts')) . '" title="' . esc_attr(__('See All Posts', '__x__')) . '">' . $blog_title . '</a>' . $delimiter . $current_before . $page_title . $current_after;
352
-                        }
353
-                    } elseif (x_is_portfolio()) {
354
-                        echo $current_before . get_the_title() . $current_after;
355
-                    } elseif (x_is_portfolio_item()) {
356
-                        $link = x_get_parent_portfolio_link();
357
-                        $title = x_get_parent_portfolio_title();
358
-                        echo '<a href="' . $link . '" title="' . esc_attr(__('See All Posts', '__x__')) . '">' . $title . '</a>' . $delimiter . $current_before . $page_title . $current_after;
359
-                    } elseif (x_is_product()) {
360
-                        echo $shop_link . $delimiter . $current_before . $page_title . $current_after;
361
-                    } elseif (is_page() && !$post->post_parent) {
362
-                        echo $current_before . $page_title . $current_after;
363
-                    } elseif (is_page() && $post->post_parent) {
364
-                        $parent_id = $post->post_parent;
365
-                        $breadcrumbs = array();
366
-                        while ($parent_id) {
367
-                            $page = get_page($parent_id);
368
-                            $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
369
-                            $parent_id = $page->post_parent;
370
-                        }
371
-                        $breadcrumbs = array_reverse($breadcrumbs);
372
-                        for ($i = 0; $i < count($breadcrumbs); $i++) {
373
-                            echo $breadcrumbs[$i];
374
-                            if ($i != count($breadcrumbs) - 1) echo $delimiter;
375
-                        }
376
-                        echo $delimiter . $current_before . $page_title . $current_after;
377
-                    } elseif (is_tag()) {
378
-                        echo $current_before . single_tag_title('', false) . $current_after;
379
-                    } elseif (is_author()) {
380
-                        GLOBAL $author;
381
-                        $userdata = get_userdata($author);
382
-                        echo $current_before . __('Posts by ', '__x__') . '&#8220;' . $userdata->display_name . $current_after . '&#8221;';
383
-                    } elseif (is_404()) {
384
-                        echo $current_before . __('404 (Page Not Found)', '__x__') . $current_after;
385
-                    } elseif (is_archive()) {
386
-                        if (x_is_shop()) {
387
-                            echo $current_before . $shop_title . $current_after;
388
-                        } else {
389
-                            echo $current_before . __('Archives ', '__x__') . $current_after;
390
-                        }
391
-                    }
392
-                    if (get_query_var('paged')) {
393
-                        echo ' <span class="current" style="white-space: nowrap;">(' . __('Page', '__x__') . ' ' . get_query_var('paged') . ')</span>';
394
-                    }
395
-                    echo '</div>';
396
-                }
397
-
398
-            }
399
-
400
-        }
401
-    } // ends my geodir check
288
+	/**
289
+	 * breadcrumbs.
290
+	 *
291
+	 * @since 1.0.0
292
+	 * @package GeoDirectory
293
+	 */
294
+	function x_breadcrumbs()
295
+	{
296
+
297
+		if (x_get_option('x_breadcrumb_display', '1')) {
298
+
299
+			//
300
+			// 1. Delimiter between crumbs.
301
+			// 2. Output text for the "Home" link.
302
+			// 3. Link to the home page.
303
+			// 4. Tag before the current crumb.
304
+			// 5. Tag after the current crumb.
305
+			// 6. Get page title.
306
+			// 7. Get blog title.
307
+			// 8. Get shop title.
308
+			//
309
+
310
+			GLOBAL $post,$wp;
311
+
312
+			if (geodir_is_page('detail') || geodir_is_page('listing') || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id())) {
313
+				geodir_breadcrumb();
314
+			} else {
315
+
316
+				$stack = x_get_stack();
317
+				$delimiter = ' <span class="delimiter"><i class="x-icon-angle-right"></i></span> '; // 1
318
+				$home_text = '<span class="home"><i class="x-icon-home"></i></span>';               // 2
319
+				$home_link = home_url();                                                            // 3
320
+				$current_before = '<span class="current">';                                              // 4
321
+				$current_after = '</span>';                                                             // 5
322
+				$page_title = get_the_title();                                                       // 6
323
+				$blog_title = get_the_title(get_option('page_for_posts', true));                 // 7
324
+				$shop_title = get_theme_mod('x_' . $stack . '_shop_title');                        // 8
325
+
326
+				if (function_exists('woocommerce_get_page_id')) {
327
+					$shop_url = x_get_shop_link();
328
+					$shop_link = '<a href="' . $shop_url . '">' . $shop_title . '</a>';
329
+				}
330
+
331
+				if (is_front_page()) {
332
+					echo '<div class="x-breadcrumbs">' . $current_before . $home_text . $current_after . '</div>';
333
+				} elseif (is_home()) {
334
+					echo '<div class="x-breadcrumbs"><a href="' . $home_link . '">' . $home_text . '</a>' . $delimiter . $current_before . $blog_title . $current_after . '</div>';
335
+				} else {
336
+					echo '<div class="x-breadcrumbs"><a href="' . $home_link . '">' . $home_text . '</a>' . $delimiter;
337
+					if (is_category()) {
338
+						$the_cat = get_category(get_query_var('cat'), false);
339
+						if ($the_cat->parent != 0) echo get_category_parents($the_cat->parent, TRUE, $delimiter);
340
+						echo $current_before . single_cat_title('', false) . $current_after;
341
+					} elseif (x_is_product_category()) {
342
+						echo $shop_link . $delimiter . $current_before . single_cat_title('', false) . $current_after;
343
+					} elseif (x_is_product_tag()) {
344
+						echo $shop_link . $delimiter . $current_before . single_tag_title('', false) . $current_after;
345
+					} elseif (is_search()) {
346
+						echo $current_before . __('Search Results for ', '__x__') . '&#8220;' . get_search_query() . '&#8221;' . $current_after;
347
+					} elseif (is_singular('post')) {
348
+						if (get_option('page_for_posts') == is_front_page()) {
349
+							echo $current_before . $page_title . $current_after;
350
+						} else {
351
+							echo '<a href="' . get_permalink(get_option('page_for_posts')) . '" title="' . esc_attr(__('See All Posts', '__x__')) . '">' . $blog_title . '</a>' . $delimiter . $current_before . $page_title . $current_after;
352
+						}
353
+					} elseif (x_is_portfolio()) {
354
+						echo $current_before . get_the_title() . $current_after;
355
+					} elseif (x_is_portfolio_item()) {
356
+						$link = x_get_parent_portfolio_link();
357
+						$title = x_get_parent_portfolio_title();
358
+						echo '<a href="' . $link . '" title="' . esc_attr(__('See All Posts', '__x__')) . '">' . $title . '</a>' . $delimiter . $current_before . $page_title . $current_after;
359
+					} elseif (x_is_product()) {
360
+						echo $shop_link . $delimiter . $current_before . $page_title . $current_after;
361
+					} elseif (is_page() && !$post->post_parent) {
362
+						echo $current_before . $page_title . $current_after;
363
+					} elseif (is_page() && $post->post_parent) {
364
+						$parent_id = $post->post_parent;
365
+						$breadcrumbs = array();
366
+						while ($parent_id) {
367
+							$page = get_page($parent_id);
368
+							$breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
369
+							$parent_id = $page->post_parent;
370
+						}
371
+						$breadcrumbs = array_reverse($breadcrumbs);
372
+						for ($i = 0; $i < count($breadcrumbs); $i++) {
373
+							echo $breadcrumbs[$i];
374
+							if ($i != count($breadcrumbs) - 1) echo $delimiter;
375
+						}
376
+						echo $delimiter . $current_before . $page_title . $current_after;
377
+					} elseif (is_tag()) {
378
+						echo $current_before . single_tag_title('', false) . $current_after;
379
+					} elseif (is_author()) {
380
+						GLOBAL $author;
381
+						$userdata = get_userdata($author);
382
+						echo $current_before . __('Posts by ', '__x__') . '&#8220;' . $userdata->display_name . $current_after . '&#8221;';
383
+					} elseif (is_404()) {
384
+						echo $current_before . __('404 (Page Not Found)', '__x__') . $current_after;
385
+					} elseif (is_archive()) {
386
+						if (x_is_shop()) {
387
+							echo $current_before . $shop_title . $current_after;
388
+						} else {
389
+							echo $current_before . __('Archives ', '__x__') . $current_after;
390
+						}
391
+					}
392
+					if (get_query_var('paged')) {
393
+						echo ' <span class="current" style="white-space: nowrap;">(' . __('Page', '__x__') . ' ' . get_query_var('paged') . ')</span>';
394
+					}
395
+					echo '</div>';
396
+				}
397
+
398
+			}
399
+
400
+		}
401
+	} // ends my geodir check
402 402
 endif;
403 403
 
404 404
 
@@ -413,8 +413,8 @@  discard block
 block discarded – undo
413 413
  */
414 414
 function geodir_x_location_switcher_menu_li_class($class)
415 415
 {
416
-    $class .= " menu-item-has-children ";
417
-    return $class;
416
+	$class .= " menu-item-has-children ";
417
+	return $class;
418 418
 }
419 419
 
420 420
 add_filter('geodir_sub_menu_li_class', 'geodir_x_sub_menu_li_class', 10, 1);
@@ -428,6 +428,6 @@  discard block
 block discarded – undo
428 428
  */
429 429
 function geodir_x_sub_menu_li_class($class)
430 430
 {
431
-    $class .= " menu-item-has-children ";
432
-    return $class;
431
+	$class .= " menu-item-has-children ";
432
+	return $class;
433 433
 }
434 434
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -336,7 +336,9 @@  discard block
 block discarded – undo
336 336
                     echo '<div class="x-breadcrumbs"><a href="' . $home_link . '">' . $home_text . '</a>' . $delimiter;
337 337
                     if (is_category()) {
338 338
                         $the_cat = get_category(get_query_var('cat'), false);
339
-                        if ($the_cat->parent != 0) echo get_category_parents($the_cat->parent, TRUE, $delimiter);
339
+                        if ($the_cat->parent != 0) {
340
+                        	echo get_category_parents($the_cat->parent, TRUE, $delimiter);
341
+                        }
340 342
                         echo $current_before . single_cat_title('', false) . $current_after;
341 343
                     } elseif (x_is_product_category()) {
342 344
                         echo $shop_link . $delimiter . $current_before . single_cat_title('', false) . $current_after;
@@ -371,7 +373,9 @@  discard block
 block discarded – undo
371 373
                         $breadcrumbs = array_reverse($breadcrumbs);
372 374
                         for ($i = 0; $i < count($breadcrumbs); $i++) {
373 375
                             echo $breadcrumbs[$i];
374
-                            if ($i != count($breadcrumbs) - 1) echo $delimiter;
376
+                            if ($i != count($breadcrumbs) - 1) {
377
+                            	echo $delimiter;
378
+                            }
375 379
                         }
376 380
                         echo $delimiter . $current_before . $page_title . $current_after;
377 381
                     } elseif (is_tag()) {
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
  */
210 210
 function geodir_x_action_wrapper_content_open($type = '', $id = '', $class = '')
211 211
 {
212
-    echo '<div class="x-main left ' . $class . '" role="main">';
212
+    echo '<div class="x-main left '.$class.'" role="main">';
213 213
 }
214 214
 
215 215
 /**
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
  */
236 236
 function geodir_x_action_sidebar_right_open($type = '', $id = '', $class = '', $itemtype = '')
237 237
 {
238
-    echo '<aside class="x-sidebar right" role="complementary" itemscope itemtype="' . $itemtype . '">';
238
+    echo '<aside class="x-sidebar right" role="complementary" itemscope itemtype="'.$itemtype.'">';
239 239
 }
240 240
 
241 241
 /**
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
             // 8. Get shop title.
308 308
             //
309 309
 
310
-            GLOBAL $post,$wp;
310
+            GLOBAL $post, $wp;
311 311
 
312 312
             if (geodir_is_page('detail') || geodir_is_page('listing') || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id())) {
313 313
                 geodir_breadcrumb();
@@ -315,57 +315,57 @@  discard block
 block discarded – undo
315 315
 
316 316
                 $stack = x_get_stack();
317 317
                 $delimiter = ' <span class="delimiter"><i class="x-icon-angle-right"></i></span> '; // 1
318
-                $home_text = '<span class="home"><i class="x-icon-home"></i></span>';               // 2
319
-                $home_link = home_url();                                                            // 3
320
-                $current_before = '<span class="current">';                                              // 4
321
-                $current_after = '</span>';                                                             // 5
322
-                $page_title = get_the_title();                                                       // 6
323
-                $blog_title = get_the_title(get_option('page_for_posts', true));                 // 7
324
-                $shop_title = get_theme_mod('x_' . $stack . '_shop_title');                        // 8
318
+                $home_text = '<span class="home"><i class="x-icon-home"></i></span>'; // 2
319
+                $home_link = home_url(); // 3
320
+                $current_before = '<span class="current">'; // 4
321
+                $current_after = '</span>'; // 5
322
+                $page_title = get_the_title(); // 6
323
+                $blog_title = get_the_title(get_option('page_for_posts', true)); // 7
324
+                $shop_title = get_theme_mod('x_'.$stack.'_shop_title'); // 8
325 325
 
326 326
                 if (function_exists('woocommerce_get_page_id')) {
327 327
                     $shop_url = x_get_shop_link();
328
-                    $shop_link = '<a href="' . $shop_url . '">' . $shop_title . '</a>';
328
+                    $shop_link = '<a href="'.$shop_url.'">'.$shop_title.'</a>';
329 329
                 }
330 330
 
331 331
                 if (is_front_page()) {
332
-                    echo '<div class="x-breadcrumbs">' . $current_before . $home_text . $current_after . '</div>';
332
+                    echo '<div class="x-breadcrumbs">'.$current_before.$home_text.$current_after.'</div>';
333 333
                 } elseif (is_home()) {
334
-                    echo '<div class="x-breadcrumbs"><a href="' . $home_link . '">' . $home_text . '</a>' . $delimiter . $current_before . $blog_title . $current_after . '</div>';
334
+                    echo '<div class="x-breadcrumbs"><a href="'.$home_link.'">'.$home_text.'</a>'.$delimiter.$current_before.$blog_title.$current_after.'</div>';
335 335
                 } else {
336
-                    echo '<div class="x-breadcrumbs"><a href="' . $home_link . '">' . $home_text . '</a>' . $delimiter;
336
+                    echo '<div class="x-breadcrumbs"><a href="'.$home_link.'">'.$home_text.'</a>'.$delimiter;
337 337
                     if (is_category()) {
338 338
                         $the_cat = get_category(get_query_var('cat'), false);
339 339
                         if ($the_cat->parent != 0) echo get_category_parents($the_cat->parent, TRUE, $delimiter);
340
-                        echo $current_before . single_cat_title('', false) . $current_after;
340
+                        echo $current_before.single_cat_title('', false).$current_after;
341 341
                     } elseif (x_is_product_category()) {
342
-                        echo $shop_link . $delimiter . $current_before . single_cat_title('', false) . $current_after;
342
+                        echo $shop_link.$delimiter.$current_before.single_cat_title('', false).$current_after;
343 343
                     } elseif (x_is_product_tag()) {
344
-                        echo $shop_link . $delimiter . $current_before . single_tag_title('', false) . $current_after;
344
+                        echo $shop_link.$delimiter.$current_before.single_tag_title('', false).$current_after;
345 345
                     } elseif (is_search()) {
346
-                        echo $current_before . __('Search Results for ', '__x__') . '&#8220;' . get_search_query() . '&#8221;' . $current_after;
346
+                        echo $current_before.__('Search Results for ', '__x__').'&#8220;'.get_search_query().'&#8221;'.$current_after;
347 347
                     } elseif (is_singular('post')) {
348 348
                         if (get_option('page_for_posts') == is_front_page()) {
349
-                            echo $current_before . $page_title . $current_after;
349
+                            echo $current_before.$page_title.$current_after;
350 350
                         } else {
351
-                            echo '<a href="' . get_permalink(get_option('page_for_posts')) . '" title="' . esc_attr(__('See All Posts', '__x__')) . '">' . $blog_title . '</a>' . $delimiter . $current_before . $page_title . $current_after;
351
+                            echo '<a href="'.get_permalink(get_option('page_for_posts')).'" title="'.esc_attr(__('See All Posts', '__x__')).'">'.$blog_title.'</a>'.$delimiter.$current_before.$page_title.$current_after;
352 352
                         }
353 353
                     } elseif (x_is_portfolio()) {
354
-                        echo $current_before . get_the_title() . $current_after;
354
+                        echo $current_before.get_the_title().$current_after;
355 355
                     } elseif (x_is_portfolio_item()) {
356 356
                         $link = x_get_parent_portfolio_link();
357 357
                         $title = x_get_parent_portfolio_title();
358
-                        echo '<a href="' . $link . '" title="' . esc_attr(__('See All Posts', '__x__')) . '">' . $title . '</a>' . $delimiter . $current_before . $page_title . $current_after;
358
+                        echo '<a href="'.$link.'" title="'.esc_attr(__('See All Posts', '__x__')).'">'.$title.'</a>'.$delimiter.$current_before.$page_title.$current_after;
359 359
                     } elseif (x_is_product()) {
360
-                        echo $shop_link . $delimiter . $current_before . $page_title . $current_after;
360
+                        echo $shop_link.$delimiter.$current_before.$page_title.$current_after;
361 361
                     } elseif (is_page() && !$post->post_parent) {
362
-                        echo $current_before . $page_title . $current_after;
362
+                        echo $current_before.$page_title.$current_after;
363 363
                     } elseif (is_page() && $post->post_parent) {
364 364
                         $parent_id = $post->post_parent;
365 365
                         $breadcrumbs = array();
366 366
                         while ($parent_id) {
367 367
                             $page = get_page($parent_id);
368
-                            $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
368
+                            $breadcrumbs[] = '<a href="'.get_permalink($page->ID).'">'.get_the_title($page->ID).'</a>';
369 369
                             $parent_id = $page->post_parent;
370 370
                         }
371 371
                         $breadcrumbs = array_reverse($breadcrumbs);
@@ -373,24 +373,24 @@  discard block
 block discarded – undo
373 373
                             echo $breadcrumbs[$i];
374 374
                             if ($i != count($breadcrumbs) - 1) echo $delimiter;
375 375
                         }
376
-                        echo $delimiter . $current_before . $page_title . $current_after;
376
+                        echo $delimiter.$current_before.$page_title.$current_after;
377 377
                     } elseif (is_tag()) {
378
-                        echo $current_before . single_tag_title('', false) . $current_after;
378
+                        echo $current_before.single_tag_title('', false).$current_after;
379 379
                     } elseif (is_author()) {
380 380
                         GLOBAL $author;
381 381
                         $userdata = get_userdata($author);
382
-                        echo $current_before . __('Posts by ', '__x__') . '&#8220;' . $userdata->display_name . $current_after . '&#8221;';
382
+                        echo $current_before.__('Posts by ', '__x__').'&#8220;'.$userdata->display_name.$current_after.'&#8221;';
383 383
                     } elseif (is_404()) {
384
-                        echo $current_before . __('404 (Page Not Found)', '__x__') . $current_after;
384
+                        echo $current_before.__('404 (Page Not Found)', '__x__').$current_after;
385 385
                     } elseif (is_archive()) {
386 386
                         if (x_is_shop()) {
387
-                            echo $current_before . $shop_title . $current_after;
387
+                            echo $current_before.$shop_title.$current_after;
388 388
                         } else {
389
-                            echo $current_before . __('Archives ', '__x__') . $current_after;
389
+                            echo $current_before.__('Archives ', '__x__').$current_after;
390 390
                         }
391 391
                     }
392 392
                     if (get_query_var('paged')) {
393
-                        echo ' <span class="current" style="white-space: nowrap;">(' . __('Page', '__x__') . ' ' . get_query_var('paged') . ')</span>';
393
+                        echo ' <span class="current" style="white-space: nowrap;">('.__('Page', '__x__').' '.get_query_var('paged').')</span>';
394 394
                     }
395 395
                     echo '</div>';
396 396
                 }
Please login to merge, or discard this patch.
geodirectory-functions/custom_functions.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -153,7 +153,7 @@
 block discarded – undo
153 153
  * @param array $package_info Package info array.
154 154
  * @param object|string $post The post object.
155 155
  * @param string $post_type The post type.
156
- * @return object Returns filtered package info as an object.
156
+ * @return string Returns filtered package info as an object.
157 157
  */
158 158
 function geodir_post_package_info($package_info, $post = '', $post_type = '')
159 159
 {
Please login to merge, or discard this patch.
Braces   +61 added lines, -50 removed lines patch added patch discarded remove patch
@@ -526,13 +526,15 @@  discard block
 block discarded – undo
526 526
 
527 527
         $all_postypes = geodir_get_posttypes();
528 528
 
529
-        if (!in_array($post_type, $all_postypes))
530
-            return false;
529
+        if (!in_array($post_type, $all_postypes)) {
530
+                    return false;
531
+        }
531 532
 
532 533
         $sort_field_info = $wpdb->get_var($wpdb->prepare("select default_order from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where	post_type= %s and is_active=%d and is_default=%d", array($post_type, 1, 1)));
533 534
 
534
-        if (!empty($sort_field_info))
535
-            return $sort_field_info;
535
+        if (!empty($sort_field_info)) {
536
+                    return $sort_field_info;
537
+        }
536 538
 
537 539
     }
538 540
 
@@ -554,8 +556,9 @@  discard block
 block discarded – undo
554 556
     if ($post_type != '') {
555 557
         $all_postypes = geodir_get_posttypes();
556 558
 
557
-        if (!in_array($post_type, $all_postypes))
558
-            return false;
559
+        if (!in_array($post_type, $all_postypes)) {
560
+                    return false;
561
+        }
559 562
 
560 563
         $sort_field_info = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type=%s AND is_active=%d AND (sort_asc=1 || sort_desc=1 || field_type='random') AND field_type != 'address' ORDER BY sort_order ASC", array($post_type, 1)));
561 564
         /**
@@ -593,7 +596,9 @@  discard block
 block discarded – undo
593 596
 
594 597
     $sort_by = '';
595 598
 
596
-    if (isset($_REQUEST['sort_by'])) $sort_by = $_REQUEST['sort_by'];
599
+    if (isset($_REQUEST['sort_by'])) {
600
+    	$sort_by = $_REQUEST['sort_by'];
601
+    }
597 602
 
598 603
     $gd_post_type = geodir_get_current_posttype();
599 604
 
@@ -621,8 +626,9 @@  discard block
 block discarded – undo
621 626
             if ($sort->sort_asc) {
622 627
                 $key = $sort->htmlvar_name . '_asc';
623 628
                 $label = $sort->site_title;
624
-                if ($sort->asc_title)
625
-                    $label = $sort->asc_title;
629
+                if ($sort->asc_title) {
630
+                                    $label = $sort->asc_title;
631
+                }
626 632
                 ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
627 633
                 $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
628 634
             }
@@ -630,8 +636,9 @@  discard block
 block discarded – undo
630 636
             if ($sort->sort_desc) {
631 637
                 $key = $sort->htmlvar_name . '_desc';
632 638
                 $label = $sort->site_title;
633
-                if ($sort->desc_title)
634
-                    $label = $sort->desc_title;
639
+                if ($sort->desc_title) {
640
+                                    $label = $sort->desc_title;
641
+                }
635 642
                 ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
636 643
                 $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
637 644
             }
@@ -648,7 +655,10 @@  discard block
 block discarded – undo
648 655
             <select name="sort_by" id="sort_by" onchange="javascript:window.location=this.value;">
649 656
 
650 657
                 <option
651
-                    value="<?php echo esc_url( add_query_arg('sort_by', '') );?>" <?php if ($sort_by == '') echo 'selected="selected"';?>><?php _e('Sort By', 'geodirectory');?></option><?php
658
+                    value="<?php echo esc_url( add_query_arg('sort_by', '') );?>" <?php if ($sort_by == '') {
659
+	echo 'selected="selected"';
660
+}
661
+?>><?php _e('Sort By', 'geodirectory');?></option><?php
652 662
 
653 663
                 echo $sort_field_options;?>
654 664
 
@@ -721,8 +731,9 @@  discard block
 block discarded – undo
721 731
         if (isset($_REQUEST['backandedit'])) {
722 732
             $post = (object)$gd_session->get('listing');
723 733
             $post_type = $post->listing_type;
724
-            if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
725
-                $post_id = $_REQUEST['pid'];
734
+            if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
735
+                            $post_id = $_REQUEST['pid'];
736
+            }
726 737
         } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
727 738
             $post = geodir_get_post_info($_REQUEST['pid']);
728 739
             $post_type = $post->post_type;
@@ -735,25 +746,29 @@  discard block
 block discarded – undo
735 746
         if ($relate_to == 'category') {
736 747
 
737 748
             $category_taxonomy = $post_type . $relate_to;
738
-            if (isset($post->{$category_taxonomy}) && $post->{$category_taxonomy} != '')
739
-                $category = explode(',', trim($post->{$category_taxonomy}, ','));
749
+            if (isset($post->{$category_taxonomy}) && $post->{$category_taxonomy} != '') {
750
+                            $category = explode(',', trim($post->{$category_taxonomy}, ','));
751
+            }
740 752
 
741 753
         } elseif ($relate_to == 'tags') {
742 754
 
743 755
             $category_taxonomy = $post_type . '_' . $relate_to;
744
-            if ($post->post_tags != '')
745
-                $category = explode(',', trim($post->post_tags, ','));
756
+            if ($post->post_tags != '') {
757
+                            $category = explode(',', trim($post->post_tags, ','));
758
+            }
746 759
             $tax_field = 'name';
747 760
         }
748 761
 
749 762
         /* --- return false in invalid request --- */
750
-        if (empty($category))
751
-            return false;
763
+        if (empty($category)) {
764
+                    return false;
765
+        }
752 766
 
753 767
         $all_postypes = geodir_get_posttypes();
754 768
 
755
-        if (!in_array($post_type, $all_postypes))
756
-            return false;
769
+        if (!in_array($post_type, $all_postypes)) {
770
+                    return false;
771
+        }
757 772
 
758 773
         /* --- return false in invalid request --- */
759 774
 
@@ -911,8 +926,9 @@  discard block
 block discarded – undo
911 926
 function geodir_get_map_default_language()
912 927
 {
913 928
     $geodir_default_map_language = get_option('geodir_default_map_language');
914
-    if (empty($geodir_default_map_language))
915
-        $geodir_default_map_language = 'en';
929
+    if (empty($geodir_default_map_language)) {
930
+            $geodir_default_map_language = 'en';
931
+    }
916 932
     /**
917 933
      * Filter default map language.
918 934
      *
@@ -1090,42 +1106,33 @@  discard block
 block discarded – undo
1090 1106
     if(geodir_is_page('home')){
1091 1107
         $gd_page = 'home';
1092 1108
         $meta_desc = (get_option('geodir_meta_desc_homepage')) ? get_option('geodir_meta_desc_homepage') : $meta_desc;
1093
-    }
1094
-    elseif(geodir_is_page('detail')){
1109
+    } elseif(geodir_is_page('detail')){
1095 1110
         $gd_page = 'detail';
1096 1111
         $meta_desc = (get_option('geodir_meta_desc_detail')) ? get_option('geodir_meta_desc_detail') : $meta_desc;
1097
-    }
1098
-    elseif(geodir_is_page('pt')){
1112
+    } elseif(geodir_is_page('pt')){
1099 1113
         $gd_page = 'pt';
1100 1114
         $meta_desc = (get_option('geodir_meta_desc_pt')) ? get_option('geodir_meta_desc_pt') : $meta_desc;
1101
-    }
1102
-    elseif(geodir_is_page('listing')){
1115
+    } elseif(geodir_is_page('listing')){
1103 1116
         $gd_page = 'listing';
1104 1117
         $meta_desc = (get_option('geodir_meta_desc_listing')) ? get_option('geodir_meta_desc_listing') : $meta_desc;
1105
-    }
1106
-    elseif(geodir_is_page('location')){
1118
+    } elseif(geodir_is_page('location')){
1107 1119
         $gd_page = 'location';
1108 1120
         $meta_desc = (get_option('geodir_meta_desc_location')) ? get_option('geodir_meta_desc_location') : $meta_desc;
1109 1121
         $meta_desc = apply_filters('geodir_seo_meta_location_description', $meta_desc);
1110 1122
 
1111
-    }
1112
-    elseif(geodir_is_page('search')){
1123
+    } elseif(geodir_is_page('search')){
1113 1124
         $gd_page = 'search';
1114 1125
         $meta_desc = (get_option('geodir_meta_desc_search')) ? get_option('geodir_meta_desc_search') : $meta_desc;
1115
-    }
1116
-    elseif(geodir_is_page('add-listing')){
1126
+    } elseif(geodir_is_page('add-listing')){
1117 1127
         $gd_page = 'add-listing';
1118 1128
         $meta_desc = (get_option('geodir_meta_desc_add-listing')) ? get_option('geodir_meta_desc_add-listing') : $meta_desc;
1119
-    }
1120
-    elseif(geodir_is_page('author')){
1129
+    } elseif(geodir_is_page('author')){
1121 1130
         $gd_page = 'author';
1122 1131
         $meta_desc = (get_option('geodir_meta_desc_author')) ? get_option('geodir_meta_desc_author') : $meta_desc;
1123
-    }
1124
-    elseif(geodir_is_page('login')){
1132
+    } elseif(geodir_is_page('login')){
1125 1133
         $gd_page = 'login';
1126 1134
         $meta_desc = (get_option('geodir_meta_desc_login')) ? get_option('geodir_meta_desc_login') : $meta_desc;
1127
-    }
1128
-    elseif(geodir_is_page('listing-success')){
1135
+    } elseif(geodir_is_page('listing-success')){
1129 1136
         $gd_page = 'listing-success';
1130 1137
         $meta_desc = (get_option('geodir_meta_desc_listing-success')) ? get_option('geodir_meta_desc_listing-success') : $meta_desc;
1131 1138
     }
@@ -1331,8 +1338,9 @@  discard block
 block discarded – undo
1331 1338
     $tabs_array = geodir_detail_page_tabs_array();
1332 1339
     if (!empty($tabs_excluded)) {
1333 1340
         foreach ($tabs_excluded as $tab) {
1334
-            if (array_key_exists($tab, $tabs_array))
1335
-                unset($tabs_array[$tab]);
1341
+            if (array_key_exists($tab, $tabs_array)) {
1342
+                            unset($tabs_array[$tab]);
1343
+            }
1336 1344
         }
1337 1345
     }
1338 1346
     return $tabs_array;
@@ -1370,8 +1378,9 @@  discard block
 block discarded – undo
1370 1378
         $video = geodir_get_video($post->ID);
1371 1379
         $special_offers = geodir_get_special_offers($post->ID);
1372 1380
         $related_listing_array = array();
1373
-        if (get_option('geodir_add_related_listing_posttypes'))
1374
-            $related_listing_array = get_option('geodir_add_related_listing_posttypes');
1381
+        if (get_option('geodir_add_related_listing_posttypes')) {
1382
+                    $related_listing_array = get_option('geodir_add_related_listing_posttypes');
1383
+        }
1375 1384
 
1376 1385
         $related_listing = '';
1377 1386
         if (in_array($post->post_type, $related_listing_array)) {
@@ -1417,11 +1426,13 @@  discard block
 block discarded – undo
1417 1426
         $video = isset($post->geodir_video) ? $post->geodir_video : '';
1418 1427
         $special_offers = isset($post->geodir_special_offers) ? $post->geodir_special_offers : '';
1419 1428
 
1420
-        if (isset($post->post_images))
1421
-            $post->post_images = trim($post->post_images, ",");
1429
+        if (isset($post->post_images)) {
1430
+                    $post->post_images = trim($post->post_images, ",");
1431
+        }
1422 1432
 
1423
-        if (isset($post->post_images) && !empty($post->post_images))
1424
-            $post_images = explode(",", $post->post_images);
1433
+        if (isset($post->post_images) && !empty($post->post_images)) {
1434
+                    $post_images = explode(",", $post->post_images);
1435
+        }
1425 1436
 
1426 1437
         $thumb_image = '';
1427 1438
         if (!empty($post_images)) {
Please login to merge, or discard this patch.
Indentation   +1380 added lines, -1380 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,151 +1353,151 @@  discard block
 block discarded – undo
1353 1353
  */
1354 1354
 function geodir_show_detail_page_tabs()
1355 1355
 {
1356
-    global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields;
1356
+	global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields;
1357 1357
 
1358
-    $post_id = !empty($post) && isset($post->ID) ? (int)$post->ID : 0;
1359
-    $request_post_id = !empty($_REQUEST['p']) ? (int)$_REQUEST['p'] : 0;
1360
-    $is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend
1358
+	$post_id = !empty($post) && isset($post->ID) ? (int)$post->ID : 0;
1359
+	$request_post_id = !empty($_REQUEST['p']) ? (int)$_REQUEST['p'] : 0;
1360
+	$is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend
1361 1361
 
1362
-    if ($is_backend_preview && !$post_id > 0 && $request_post_id > 0) {
1363
-        $post = geodir_get_post_info($request_post_id);
1364
-        setup_postdata($post);
1365
-    }
1362
+	if ($is_backend_preview && !$post_id > 0 && $request_post_id > 0) {
1363
+		$post = geodir_get_post_info($request_post_id);
1364
+		setup_postdata($post);
1365
+	}
1366 1366
 
1367
-    $geodir_post_detail_fields = geodir_show_listing_info('detail');
1368
-
1369
-    if (geodir_is_page('detail')) {
1370
-        $video = geodir_get_video($post->ID);
1371
-        $special_offers = geodir_get_special_offers($post->ID);
1372
-        $related_listing_array = array();
1373
-        if (get_option('geodir_add_related_listing_posttypes'))
1374
-            $related_listing_array = get_option('geodir_add_related_listing_posttypes');
1375
-
1376
-        $related_listing = '';
1377
-        if (in_array($post->post_type, $related_listing_array)) {
1378
-            $request = array('post_number' => get_option('geodir_related_post_count'),
1379
-                'relate_to' => get_option('geodir_related_post_relate_to'),
1380
-                'layout' => get_option('geodir_related_post_listing_view'),
1381
-                'add_location_filter' => get_option('geodir_related_post_location_filter'),
1382
-                'list_sort' => get_option('geodir_related_post_sortby'),
1383
-                'character_count' => get_option('geodir_related_post_excerpt'));
1384
-
1385
-            $related_listing = geodir_related_posts_display($request);
1386
-        }
1367
+	$geodir_post_detail_fields = geodir_show_listing_info('detail');
1368
+
1369
+	if (geodir_is_page('detail')) {
1370
+		$video = geodir_get_video($post->ID);
1371
+		$special_offers = geodir_get_special_offers($post->ID);
1372
+		$related_listing_array = array();
1373
+		if (get_option('geodir_add_related_listing_posttypes'))
1374
+			$related_listing_array = get_option('geodir_add_related_listing_posttypes');
1375
+
1376
+		$related_listing = '';
1377
+		if (in_array($post->post_type, $related_listing_array)) {
1378
+			$request = array('post_number' => get_option('geodir_related_post_count'),
1379
+				'relate_to' => get_option('geodir_related_post_relate_to'),
1380
+				'layout' => get_option('geodir_related_post_listing_view'),
1381
+				'add_location_filter' => get_option('geodir_related_post_location_filter'),
1382
+				'list_sort' => get_option('geodir_related_post_sortby'),
1383
+				'character_count' => get_option('geodir_related_post_excerpt'));
1384
+
1385
+			$related_listing = geodir_related_posts_display($request);
1386
+		}
1387 1387
 
1388
-        $post_images = geodir_get_images($post->ID, 'thumbnail');
1389
-        $thumb_image = '';
1390
-        if (!empty($post_images)) {
1391
-            foreach ($post_images as $image) {
1392
-                $caption = (!empty($image->caption)) ? $image->caption : '';
1393
-                $thumb_image .= '<a href="' . $image->src . '" title="'.$caption.'">';
1394
-                $thumb_image .= geodir_show_image($image, 'thumbnail', true, false);
1395
-                $thumb_image .= '</a>';
1396
-            }
1397
-        }
1388
+		$post_images = geodir_get_images($post->ID, 'thumbnail');
1389
+		$thumb_image = '';
1390
+		if (!empty($post_images)) {
1391
+			foreach ($post_images as $image) {
1392
+				$caption = (!empty($image->caption)) ? $image->caption : '';
1393
+				$thumb_image .= '<a href="' . $image->src . '" title="'.$caption.'">';
1394
+				$thumb_image .= geodir_show_image($image, 'thumbnail', true, false);
1395
+				$thumb_image .= '</a>';
1396
+			}
1397
+		}
1398 1398
 
1399
-        $map_args = array();
1400
-        $map_args['map_canvas_name'] = 'detail_page_map_canvas';
1401
-        $map_args['width'] = '600';
1402
-        $map_args['height'] = '300';
1403
-        if ($post->post_mapzoom) {
1404
-            $map_args['zoom'] = '' . $post->post_mapzoom . '';
1405
-        }
1406
-        $map_args['autozoom'] = false;
1407
-        $map_args['child_collapse'] = '0';
1408
-        $map_args['enable_cat_filters'] = false;
1409
-        $map_args['enable_text_search'] = false;
1410
-        $map_args['enable_post_type_filters'] = false;
1411
-        $map_args['enable_location_filters'] = false;
1412
-        $map_args['enable_jason_on_load'] = true;
1413
-        $map_args['enable_map_direction'] = true;
1414
-        $map_args['map_class_name'] = 'geodir-map-detail-page';
1415
-        $map_args['maptype'] = (!empty($post->post_mapview)) ? $post->post_mapview : 'ROADMAP';
1416
-    } else if (geodir_is_page('preview')) {
1417
-        $video = isset($post->geodir_video) ? $post->geodir_video : '';
1418
-        $special_offers = isset($post->geodir_special_offers) ? $post->geodir_special_offers : '';
1419
-
1420
-        if (isset($post->post_images))
1421
-            $post->post_images = trim($post->post_images, ",");
1422
-
1423
-        if (isset($post->post_images) && !empty($post->post_images))
1424
-            $post_images = explode(",", $post->post_images);
1425
-
1426
-        $thumb_image = '';
1427
-        if (!empty($post_images)) {
1428
-            foreach ($post_images as $image) {
1429
-                if ($image != '') {
1430
-                    $thumb_image .= '<a href="' . $image . '">';
1431
-                    $thumb_image .= geodir_show_image(array('src' => $image), 'thumbnail', true, false);
1432
-                    $thumb_image .= '</a>';
1433
-                }
1434
-            }
1435
-        }
1399
+		$map_args = array();
1400
+		$map_args['map_canvas_name'] = 'detail_page_map_canvas';
1401
+		$map_args['width'] = '600';
1402
+		$map_args['height'] = '300';
1403
+		if ($post->post_mapzoom) {
1404
+			$map_args['zoom'] = '' . $post->post_mapzoom . '';
1405
+		}
1406
+		$map_args['autozoom'] = false;
1407
+		$map_args['child_collapse'] = '0';
1408
+		$map_args['enable_cat_filters'] = false;
1409
+		$map_args['enable_text_search'] = false;
1410
+		$map_args['enable_post_type_filters'] = false;
1411
+		$map_args['enable_location_filters'] = false;
1412
+		$map_args['enable_jason_on_load'] = true;
1413
+		$map_args['enable_map_direction'] = true;
1414
+		$map_args['map_class_name'] = 'geodir-map-detail-page';
1415
+		$map_args['maptype'] = (!empty($post->post_mapview)) ? $post->post_mapview : 'ROADMAP';
1416
+	} else if (geodir_is_page('preview')) {
1417
+		$video = isset($post->geodir_video) ? $post->geodir_video : '';
1418
+		$special_offers = isset($post->geodir_special_offers) ? $post->geodir_special_offers : '';
1419
+
1420
+		if (isset($post->post_images))
1421
+			$post->post_images = trim($post->post_images, ",");
1422
+
1423
+		if (isset($post->post_images) && !empty($post->post_images))
1424
+			$post_images = explode(",", $post->post_images);
1425
+
1426
+		$thumb_image = '';
1427
+		if (!empty($post_images)) {
1428
+			foreach ($post_images as $image) {
1429
+				if ($image != '') {
1430
+					$thumb_image .= '<a href="' . $image . '">';
1431
+					$thumb_image .= geodir_show_image(array('src' => $image), 'thumbnail', true, false);
1432
+					$thumb_image .= '</a>';
1433
+				}
1434
+			}
1435
+		}
1436 1436
 
1437
-        global $map_jason;
1438
-        $marker_json = $post->marker_json != '' ? json_decode($post->marker_json, true) : array();
1439
-        $icon_size = (!empty($marker_json) && !empty($marker_json['icon'])) ? $marker_json['icon'] : '';             
1440
-        $icon_size = geodir_get_marker_size($marker_json['icon']);
1441
-        $marker_json['w'] = $icon_size['w'];
1442
-        $marker_json['h'] = $icon_size['h'];
1443
-        $map_jason[] = json_encode($marker_json);
1444
-
1445
-        $address_latitude = isset($post->post_latitude) ? $post->post_latitude : '';
1446
-        $address_longitude = isset($post->post_longitude) ? $post->post_longitude : '';
1447
-        $mapview = isset($post->post_mapview) ? $post->post_mapview : '';
1448
-        $mapzoom = isset($post->post_mapzoom) ? $post->post_mapzoom : '';
1449
-        if (!$mapzoom) {
1450
-            $mapzoom = 12;
1451
-        }
1437
+		global $map_jason;
1438
+		$marker_json = $post->marker_json != '' ? json_decode($post->marker_json, true) : array();
1439
+		$icon_size = (!empty($marker_json) && !empty($marker_json['icon'])) ? $marker_json['icon'] : '';             
1440
+		$icon_size = geodir_get_marker_size($marker_json['icon']);
1441
+		$marker_json['w'] = $icon_size['w'];
1442
+		$marker_json['h'] = $icon_size['h'];
1443
+		$map_jason[] = json_encode($marker_json);
1444
+
1445
+		$address_latitude = isset($post->post_latitude) ? $post->post_latitude : '';
1446
+		$address_longitude = isset($post->post_longitude) ? $post->post_longitude : '';
1447
+		$mapview = isset($post->post_mapview) ? $post->post_mapview : '';
1448
+		$mapzoom = isset($post->post_mapzoom) ? $post->post_mapzoom : '';
1449
+		if (!$mapzoom) {
1450
+			$mapzoom = 12;
1451
+		}
1452 1452
 
1453
-        $map_args = array();
1454
-        $map_args['map_canvas_name'] = 'preview_map_canvas';
1455
-        $map_args['width'] = '950';
1456
-        $map_args['height'] = '300';
1457
-        $map_args['child_collapse'] = '0';
1458
-        $map_args['maptype'] = $mapview;
1459
-        $map_args['autozoom'] = false;
1460
-        $map_args['zoom'] = "$mapzoom";
1461
-        $map_args['latitude'] = $address_latitude;
1462
-        $map_args['longitude'] = $address_longitude;
1463
-        $map_args['enable_cat_filters'] = false;
1464
-        $map_args['enable_text_search'] = false;
1465
-        $map_args['enable_post_type_filters'] = false;
1466
-        $map_args['enable_location_filters'] = false;
1467
-        $map_args['enable_jason_on_load'] = true;
1468
-        $map_args['enable_map_direction'] = true;
1469
-        $map_args['map_class_name'] = 'geodir-map-preview-page';
1470
-    }
1453
+		$map_args = array();
1454
+		$map_args['map_canvas_name'] = 'preview_map_canvas';
1455
+		$map_args['width'] = '950';
1456
+		$map_args['height'] = '300';
1457
+		$map_args['child_collapse'] = '0';
1458
+		$map_args['maptype'] = $mapview;
1459
+		$map_args['autozoom'] = false;
1460
+		$map_args['zoom'] = "$mapzoom";
1461
+		$map_args['latitude'] = $address_latitude;
1462
+		$map_args['longitude'] = $address_longitude;
1463
+		$map_args['enable_cat_filters'] = false;
1464
+		$map_args['enable_text_search'] = false;
1465
+		$map_args['enable_post_type_filters'] = false;
1466
+		$map_args['enable_location_filters'] = false;
1467
+		$map_args['enable_jason_on_load'] = true;
1468
+		$map_args['enable_map_direction'] = true;
1469
+		$map_args['map_class_name'] = 'geodir-map-preview-page';
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
-    $active_tab = '';
1475
-    $active_tab_name = '';
1476
-    $default_tab = '';
1477
-    $default_tab_name = '';
1478
-    foreach($arr_detail_page_tabs as $tab_index => $tabs){
1479
-        if (isset($tabs['is_active_tab']) && $tabs['is_active_tab'] && !empty($tabs['is_display']) && isset($tabs['heading_text']) && $tabs['heading_text']) {
1480
-            $active_tab = $tab_index;
1481
-            $active_tab_name = __($tabs['heading_text'], 'geodirectory');
1482
-        }
1474
+	$active_tab = '';
1475
+	$active_tab_name = '';
1476
+	$default_tab = '';
1477
+	$default_tab_name = '';
1478
+	foreach($arr_detail_page_tabs as $tab_index => $tabs){
1479
+		if (isset($tabs['is_active_tab']) && $tabs['is_active_tab'] && !empty($tabs['is_display']) && isset($tabs['heading_text']) && $tabs['heading_text']) {
1480
+			$active_tab = $tab_index;
1481
+			$active_tab_name = __($tabs['heading_text'], 'geodirectory');
1482
+		}
1483 1483
         
1484
-        if ($default_tab === '' && !empty($tabs['is_display']) && !empty($tabs['heading_text'])) {
1485
-            $default_tab = $tab_index;
1486
-            $default_tab_name = __($tabs['heading_text'], 'geodirectory');
1487
-        }
1488
-    }
1484
+		if ($default_tab === '' && !empty($tabs['is_display']) && !empty($tabs['heading_text'])) {
1485
+			$default_tab = $tab_index;
1486
+			$default_tab_name = __($tabs['heading_text'], 'geodirectory');
1487
+		}
1488
+	}
1489 1489
     
1490
-    if ($active_tab === '' && $default_tab !== '') { // Make first tab acs a active tab if not any tab is active.
1491
-        if (isset($arr_detail_page_tabs[$active_tab]) && isset($arr_detail_page_tabs[$active_tab]['is_active_tab'])) {
1492
-            $arr_detail_page_tabs[$active_tab]['is_active_tab'] = false;
1493
-        }
1490
+	if ($active_tab === '' && $default_tab !== '') { // Make first tab acs a active tab if not any tab is active.
1491
+		if (isset($arr_detail_page_tabs[$active_tab]) && isset($arr_detail_page_tabs[$active_tab]['is_active_tab'])) {
1492
+			$arr_detail_page_tabs[$active_tab]['is_active_tab'] = false;
1493
+		}
1494 1494
         
1495
-        $arr_detail_page_tabs[$default_tab]['is_active_tab'] = true;
1496
-        $active_tab = $default_tab;
1497
-        $active_tab_name = $default_tab_name;
1498
-    }
1499
-    $tab_list = (get_option('geodir_disable_tabs',true)) ? true : false;
1500
-    ?>
1495
+		$arr_detail_page_tabs[$default_tab]['is_active_tab'] = true;
1496
+		$active_tab = $default_tab;
1497
+		$active_tab_name = $default_tab_name;
1498
+	}
1499
+	$tab_list = (get_option('geodir_disable_tabs',true)) ? true : false;
1500
+	?>
1501 1501
     <div class="geodir-tabs" id="gd-tabs" style="position:relative;">
1502 1502
         <?php if(!$tab_list){ ?>
1503 1503
         <div id="geodir-tab-mobile-menu">
@@ -1507,166 +1507,166 @@  discard block
 block discarded – undo
1507 1507
         </div>
1508 1508
         <dl class="geodir-tab-head">
1509 1509
             <?php
1510
-            }
1511
-            /**
1512
-             * Called before the details page tab list headings, inside the `dl` tag.
1513
-             *
1514
-             * @since 1.0.0
1515
-             * @see 'geodir_after_tab_list'
1516
-             */
1517
-            do_action('geodir_before_tab_list'); ?>
1510
+			}
1511
+			/**
1512
+			 * Called before the details page tab list headings, inside the `dl` tag.
1513
+			 *
1514
+			 * @since 1.0.0
1515
+			 * @see 'geodir_after_tab_list'
1516
+			 */
1517
+			do_action('geodir_before_tab_list'); ?>
1518 1518
             <?php
1519 1519
 
1520
-            foreach ($arr_detail_page_tabs as $tab_index => $detail_page_tab) {
1521
-                if ($detail_page_tab['is_display']) {
1520
+			foreach ($arr_detail_page_tabs as $tab_index => $detail_page_tab) {
1521
+				if ($detail_page_tab['is_display']) {
1522 1522
 
1523
-                    if(!$tab_list) {
1524
-                        ?>
1523
+					if(!$tab_list) {
1524
+						?>
1525 1525
                         <dt></dt> <!-- added to comply with validation -->
1526 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>
1530 1530
                         <?php
1531
-                    }
1532
-                    ob_start() // start tab content buffering
1533
-                    ?>
1531
+					}
1532
+					ob_start() // start tab content buffering
1533
+					?>
1534 1534
                     <li id="<?php echo $tab_index;?>Tab">
1535 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
-                            /**
1538
-                             * Filter the tab list title html.
1539
-                             *
1540
-                             * @since 1.6.1
1541
-                             * @param string $tab_title The html for the tab title.
1542
-                             * @param string $tab_index The tab index type.
1543
-                             * @param array $detail_page_tab The array of values including title text.
1544
-                             */
1545
-                            echo apply_filters('geodir_tab_list_title',$tab_title ,$tab_index ,$detail_page_tab);
1546
-                        }?>
1536
+							$tab_title = '<span class="gd-tab-list-title" ><a href="#'.$tab_index.'">'.__($detail_page_tab['heading_text'],'geodirectory').'</a></span><hr />';
1537
+							/**
1538
+							 * Filter the tab list title html.
1539
+							 *
1540
+							 * @since 1.6.1
1541
+							 * @param string $tab_title The html for the tab title.
1542
+							 * @param string $tab_index The tab index type.
1543
+							 * @param array $detail_page_tab The array of values including title text.
1544
+							 */
1545
+							echo apply_filters('geodir_tab_list_title',$tab_title ,$tab_index ,$detail_page_tab);
1546
+						}?>
1547 1547
                         <div id="<?php echo $tab_index;?>" class="hash-offset"></div>
1548 1548
                         <?php
1549
-                        /**
1550
-                         * Called before the details tab content is output per tab.
1551
-                         *
1552
-                         * @since 1.0.0
1553
-                         * @param string $tab_index The tab name ID.
1554
-                         */
1555
-                        do_action('geodir_before_tab_content', $tab_index);
1556
-
1557
-                        /**
1558
-                         * Called before the details tab content is output per tab.
1559
-                         *
1560
-                         * Uses dynamic hook name: geodir_before_$tab_index_tab_content
1561
-                         *
1562
-                         * @since 1.0.0
1563
-                         * @todo do we need this if we have the hook above? 'geodir_before_tab_content'
1564
-                         */
1565
-                        do_action('geodir_before_' . $tab_index . '_tab_content');
1566
-                        /// write a code to generate content of each tab
1567
-                        switch ($tab_index) {
1568
-                            case 'post_profile':
1569
-                                /**
1570
-                                 * Called before the listing description content on the details page tab.
1571
-                                 *
1572
-                                 * @since 1.0.0
1573
-                                 */
1574
-                                do_action('geodir_before_description_on_listing_detail');
1575
-                                if (geodir_is_page('detail')) {
1576
-                                    the_content();
1577
-                                } else {
1578
-                                    /** This action is documented in geodirectory_template_actions.php */
1579
-                                    echo apply_filters('the_content', stripslashes($post->post_desc));
1580
-                                }
1581
-
1582
-                                /**
1583
-                                 * Called after the listing description content on the details page tab.
1584
-                                 *
1585
-                                 * @since 1.0.0
1586
-                                 */
1587
-                                do_action('geodir_after_description_on_listing_detail');
1588
-                                break;
1589
-                            case 'post_info':
1590
-                                echo $geodir_post_detail_fields;
1591
-                                break;
1592
-                            case 'post_images':
1593
-                                echo $thumb_image;
1594
-                                break;
1595
-                            case 'post_video':
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;
1598
-                                break;
1599
-                            case 'special_offers':
1600
-                                echo wpautop(stripslashes($special_offers));
1601
-
1602
-                                break;
1603
-                            case 'post_map':
1604
-                                geodir_draw_map($map_args);
1605
-                                break;
1606
-                            case 'reviews':
1607
-                                comments_template();
1608
-                                break;
1609
-                            case 'related_listing':
1610
-                                echo $related_listing;
1611
-                                break;
1612
-                            default: {
1613
-                                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'])) {
1614
-                                    echo $detail_page_tab['tab_content'];
1615
-                                }
1616
-                            }
1617
-                                break;
1618
-                        }
1619
-
1620
-                        /**
1621
-                         * Called after the details tab content is output per tab.
1622
-                         *
1623
-                         * @since 1.0.0
1624
-                         */
1625
-                        do_action('geodir_after_tab_content', $tab_index);
1626
-
1627
-                        /**
1628
-                         * Called after the details tab content is output per tab.
1629
-                         *
1630
-                         * Uses dynamic hook name: geodir_after_$tab_index_tab_content
1631
-                         *
1632
-                         * @since 1.0.0
1633
-                         * @todo do we need this if we have the hook above? 'geodir_after_tab_content'
1634
-                         */
1635
-                        do_action('geodir_after_' . $tab_index . '_tab_content');
1636
-                        ?> </li>
1549
+						/**
1550
+						 * Called before the details tab content is output per tab.
1551
+						 *
1552
+						 * @since 1.0.0
1553
+						 * @param string $tab_index The tab name ID.
1554
+						 */
1555
+						do_action('geodir_before_tab_content', $tab_index);
1556
+
1557
+						/**
1558
+						 * Called before the details tab content is output per tab.
1559
+						 *
1560
+						 * Uses dynamic hook name: geodir_before_$tab_index_tab_content
1561
+						 *
1562
+						 * @since 1.0.0
1563
+						 * @todo do we need this if we have the hook above? 'geodir_before_tab_content'
1564
+						 */
1565
+						do_action('geodir_before_' . $tab_index . '_tab_content');
1566
+						/// write a code to generate content of each tab
1567
+						switch ($tab_index) {
1568
+							case 'post_profile':
1569
+								/**
1570
+								 * Called before the listing description content on the details page tab.
1571
+								 *
1572
+								 * @since 1.0.0
1573
+								 */
1574
+								do_action('geodir_before_description_on_listing_detail');
1575
+								if (geodir_is_page('detail')) {
1576
+									the_content();
1577
+								} else {
1578
+									/** This action is documented in geodirectory_template_actions.php */
1579
+									echo apply_filters('the_content', stripslashes($post->post_desc));
1580
+								}
1581
+
1582
+								/**
1583
+								 * Called after the listing description content on the details page tab.
1584
+								 *
1585
+								 * @since 1.0.0
1586
+								 */
1587
+								do_action('geodir_after_description_on_listing_detail');
1588
+								break;
1589
+							case 'post_info':
1590
+								echo $geodir_post_detail_fields;
1591
+								break;
1592
+							case 'post_images':
1593
+								echo $thumb_image;
1594
+								break;
1595
+							case 'post_video':
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;
1598
+								break;
1599
+							case 'special_offers':
1600
+								echo wpautop(stripslashes($special_offers));
1601
+
1602
+								break;
1603
+							case 'post_map':
1604
+								geodir_draw_map($map_args);
1605
+								break;
1606
+							case 'reviews':
1607
+								comments_template();
1608
+								break;
1609
+							case 'related_listing':
1610
+								echo $related_listing;
1611
+								break;
1612
+							default: {
1613
+								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'])) {
1614
+									echo $detail_page_tab['tab_content'];
1615
+								}
1616
+							}
1617
+								break;
1618
+						}
1619
+
1620
+						/**
1621
+						 * Called after the details tab content is output per tab.
1622
+						 *
1623
+						 * @since 1.0.0
1624
+						 */
1625
+						do_action('geodir_after_tab_content', $tab_index);
1626
+
1627
+						/**
1628
+						 * Called after the details tab content is output per tab.
1629
+						 *
1630
+						 * Uses dynamic hook name: geodir_after_$tab_index_tab_content
1631
+						 *
1632
+						 * @since 1.0.0
1633
+						 * @todo do we need this if we have the hook above? 'geodir_after_tab_content'
1634
+						 */
1635
+						do_action('geodir_after_' . $tab_index . '_tab_content');
1636
+						?> </li>
1637 1637
                     <?php
1638
-                    /**
1639
-                     * Filter the current tab content.
1640
-                     *
1641
-                     * @since 1.0.0
1642
-                     */
1643
-                    $arr_detail_page_tabs[$tab_index]['tab_content'] = apply_filters("geodir_modify_" . $detail_page_tab['tab_content'] . "_tab_content", ob_get_clean());
1644
-                } // end of if for is_display
1645
-            }// end of foreach
1646
-
1647
-            /**
1648
-             * Called after the details page tab list headings, inside the `dl` tag.
1649
-             *
1650
-             * @since 1.0.0
1651
-             * @see 'geodir_before_tab_list'
1652
-             */
1653
-            do_action('geodir_after_tab_list');
1654
-            ?>
1638
+					/**
1639
+					 * Filter the current tab content.
1640
+					 *
1641
+					 * @since 1.0.0
1642
+					 */
1643
+					$arr_detail_page_tabs[$tab_index]['tab_content'] = apply_filters("geodir_modify_" . $detail_page_tab['tab_content'] . "_tab_content", ob_get_clean());
1644
+				} // end of if for is_display
1645
+			}// end of foreach
1646
+
1647
+			/**
1648
+			 * Called after the details page tab list headings, inside the `dl` tag.
1649
+			 *
1650
+			 * @since 1.0.0
1651
+			 * @see 'geodir_before_tab_list'
1652
+			 */
1653
+			do_action('geodir_after_tab_list');
1654
+			?>
1655 1655
             <?php if(!$tab_list){?></dl><?php }?>
1656 1656
         <ul class="geodir-tabs-content entry-content" style="position:relative;">
1657 1657
             <?php
1658
-            foreach ($arr_detail_page_tabs as $detail_page_tab) {
1659
-                if ($detail_page_tab['is_display'] && !empty($detail_page_tab['tab_content'])) {
1660
-                    echo $detail_page_tab['tab_content'];
1661
-                }// end of if
1662
-            }// end of foreach
1663
-
1664
-            /**
1665
-             * Called after all the tab content is output in `li` tags, called before the closing `ul` tag.
1666
-             *
1667
-             * @since 1.0.0
1668
-             */
1669
-            do_action('geodir_add_tab_content'); ?>
1658
+			foreach ($arr_detail_page_tabs as $detail_page_tab) {
1659
+				if ($detail_page_tab['is_display'] && !empty($detail_page_tab['tab_content'])) {
1660
+					echo $detail_page_tab['tab_content'];
1661
+				}// end of if
1662
+			}// end of foreach
1663
+
1664
+			/**
1665
+			 * Called after all the tab content is output in `li` tags, called before the closing `ul` tag.
1666
+			 *
1667
+			 * @since 1.0.0
1668
+			 */
1669
+			do_action('geodir_add_tab_content'); ?>
1670 1670
         </ul>
1671 1671
         <!--gd-tabs-content ul end-->
1672 1672
     </div>
@@ -1689,7 +1689,7 @@  discard block
 block discarded – undo
1689 1689
         });
1690 1690
     </script>
1691 1691
     <?php
1692
-    }
1692
+	}
1693 1693
 }
1694 1694
 
1695 1695
 /**
@@ -1702,127 +1702,127 @@  discard block
 block discarded – undo
1702 1702
  */
1703 1703
 function geodir_exif($file)
1704 1704
 {
1705
-    if (empty($file) || !is_array($file)) {
1706
-        return $file;
1707
-    }
1705
+	if (empty($file) || !is_array($file)) {
1706
+		return $file;
1707
+	}
1708 1708
     
1709
-    $file_path = !empty($file['tmp_name']) ? sanitize_text_field($file['tmp_name']) : '';
1710
-    if (!($file_path && file_exists($file_path))) {
1711
-        return $file;
1712
-    }
1713
-    $file['file'] = $file_path;
1709
+	$file_path = !empty($file['tmp_name']) ? sanitize_text_field($file['tmp_name']) : '';
1710
+	if (!($file_path && file_exists($file_path))) {
1711
+		return $file;
1712
+	}
1713
+	$file['file'] = $file_path;
1714 1714
     
1715
-    if (!file_is_valid_image($file_path)) {
1716
-        return $file; // Bail if file is not an image.
1717
-    }
1715
+	if (!file_is_valid_image($file_path)) {
1716
+		return $file; // Bail if file is not an image.
1717
+	}
1718 1718
     
1719
-    if (!function_exists('wp_get_image_editor')) {
1720
-        return $file;
1721
-    }
1719
+	if (!function_exists('wp_get_image_editor')) {
1720
+		return $file;
1721
+	}
1722 1722
    
1723
-    $mime_type = $file['type'];
1724
-    $exif = array();
1725
-    if ($mime_type == 'image/jpeg' && function_exists('exif_read_data')) {
1726
-        try {
1727
-            $exif = exif_read_data($file_path);
1728
-        } catch(Exception $e) {
1729
-            $exif = array();
1730
-        }
1731
-    }
1723
+	$mime_type = $file['type'];
1724
+	$exif = array();
1725
+	if ($mime_type == 'image/jpeg' && function_exists('exif_read_data')) {
1726
+		try {
1727
+			$exif = exif_read_data($file_path);
1728
+		} catch(Exception $e) {
1729
+			$exif = array();
1730
+		}
1731
+	}
1732 1732
     
1733
-    $rotate = false;
1734
-    $flip = false;
1735
-    $modify = false;
1736
-    $orientation = 0;
1737
-    if (!empty($exif) && isset($exif['Orientation'])) {
1738
-        switch ((int)$exif['Orientation']) {
1739
-            case 1:
1740
-                // do nothing
1741
-                break;
1742
-            case 2:
1743
-                $flip = array(false, true);
1744
-                $modify = true;
1745
-                break;
1746
-            case 3:
1747
-                $orientation = -180;
1748
-                $rotate = true;
1749
-                $modify = true;
1750
-                break;
1751
-            case 4:
1752
-                $flip = array(true, false);
1753
-                $modify = true;
1754
-                break;
1755
-            case 5:
1756
-                $orientation = -90;
1757
-                $rotate = true;
1758
-                $flip = array(false, true);
1759
-                $modify = true;
1760
-                break;
1761
-            case 6:
1762
-                $orientation = -90;
1763
-                $rotate = true;
1764
-                $modify = true;
1765
-                break;
1766
-            case 7:
1767
-                $orientation = -270;
1768
-                $rotate = true;
1769
-                $flip = array(false, true);
1770
-                $modify = true;
1771
-                break;
1772
-            case 8:
1773
-            case 9:
1774
-                $orientation = -270;
1775
-                $rotate = true;
1776
-                $modify = true;
1777
-                break;
1778
-            default:
1779
-                $orientation = 0;
1780
-                $rotate = true;
1781
-                $modify = true;
1782
-                break;
1783
-        }
1784
-    }
1733
+	$rotate = false;
1734
+	$flip = false;
1735
+	$modify = false;
1736
+	$orientation = 0;
1737
+	if (!empty($exif) && isset($exif['Orientation'])) {
1738
+		switch ((int)$exif['Orientation']) {
1739
+			case 1:
1740
+				// do nothing
1741
+				break;
1742
+			case 2:
1743
+				$flip = array(false, true);
1744
+				$modify = true;
1745
+				break;
1746
+			case 3:
1747
+				$orientation = -180;
1748
+				$rotate = true;
1749
+				$modify = true;
1750
+				break;
1751
+			case 4:
1752
+				$flip = array(true, false);
1753
+				$modify = true;
1754
+				break;
1755
+			case 5:
1756
+				$orientation = -90;
1757
+				$rotate = true;
1758
+				$flip = array(false, true);
1759
+				$modify = true;
1760
+				break;
1761
+			case 6:
1762
+				$orientation = -90;
1763
+				$rotate = true;
1764
+				$modify = true;
1765
+				break;
1766
+			case 7:
1767
+				$orientation = -270;
1768
+				$rotate = true;
1769
+				$flip = array(false, true);
1770
+				$modify = true;
1771
+				break;
1772
+			case 8:
1773
+			case 9:
1774
+				$orientation = -270;
1775
+				$rotate = true;
1776
+				$modify = true;
1777
+				break;
1778
+			default:
1779
+				$orientation = 0;
1780
+				$rotate = true;
1781
+				$modify = true;
1782
+				break;
1783
+		}
1784
+	}
1785 1785
     
1786
-    $quality = null;
1787
-    /**
1788
-     * Filter the image quality.
1789
-     *
1790
-     * @since 1.5.7
1791
-     * @param int|null $quality Image Compression quality between 1-100% scale. Default null.
1792
-     * @param string $quality Image mime type.
1793
-     */
1794
-    $quality = apply_filters('geodir_image_upload_set_quality', $quality, $mime_type);
1795
-    if ($quality !== null) {
1796
-        $modify = true;
1797
-    }
1786
+	$quality = null;
1787
+	/**
1788
+	 * Filter the image quality.
1789
+	 *
1790
+	 * @since 1.5.7
1791
+	 * @param int|null $quality Image Compression quality between 1-100% scale. Default null.
1792
+	 * @param string $quality Image mime type.
1793
+	 */
1794
+	$quality = apply_filters('geodir_image_upload_set_quality', $quality, $mime_type);
1795
+	if ($quality !== null) {
1796
+		$modify = true;
1797
+	}
1798 1798
 
1799
-    if (!$modify) {
1800
-        return $file; // no change
1801
-    }
1799
+	if (!$modify) {
1800
+		return $file; // no change
1801
+	}
1802 1802
 
1803
-    $image = wp_get_image_editor($file_path);
1804
-    if (!is_wp_error($image)) {
1805
-        if ($rotate) {
1806
-            $image->rotate($orientation);
1807
-        }
1803
+	$image = wp_get_image_editor($file_path);
1804
+	if (!is_wp_error($image)) {
1805
+		if ($rotate) {
1806
+			$image->rotate($orientation);
1807
+		}
1808 1808
         
1809
-        if (!empty($flip)) {
1810
-            $image->flip($flip[0], $flip[1]);
1811
-        }
1809
+		if (!empty($flip)) {
1810
+			$image->flip($flip[0], $flip[1]);
1811
+		}
1812 1812
         
1813
-        if ($quality !== null) {
1814
-            $image->set_quality((int)$quality);
1815
-        }
1813
+		if ($quality !== null) {
1814
+			$image->set_quality((int)$quality);
1815
+		}
1816 1816
         
1817
-       $result = $image->save($file_path);
1818
-       if (!is_wp_error($result)) {
1819
-           $file['file'] = $result['path'];
1820
-           $file['tmp_name'] = $result['path'];
1821
-       }
1822
-    }
1817
+	   $result = $image->save($file_path);
1818
+	   if (!is_wp_error($result)) {
1819
+		   $file['file'] = $result['path'];
1820
+		   $file['tmp_name'] = $result['path'];
1821
+	   }
1822
+	}
1823 1823
     
1824
-    // The image orientation is fixed, pass it back for further processing
1825
-    return $file;
1824
+	// The image orientation is fixed, pass it back for further processing
1825
+	return $file;
1826 1826
 }
1827 1827
 
1828 1828
 /**
@@ -1841,138 +1841,138 @@  discard block
 block discarded – undo
1841 1841
  * @return string Returns the recent reviews html.
1842 1842
  */
1843 1843
 function geodir_get_recent_reviews($g_size = 60, $no_comments = 10, $comment_lenth = 60, $show_pass_post = false) {
1844
-    global $wpdb, $tablecomments, $tableposts, $rating_table_name, $gd_session;
1845
-    $tablecomments = $wpdb->comments;
1846
-    $tableposts = $wpdb->posts;
1847
-
1848
-    $comments_echo = '';
1849
-    $city_filter = '';
1850
-    $region_filter = '';
1851
-    $country_filter = '';
1852
-
1853
-    if ($gd_session->get('gd_multi_location')) {
1854
-        if ($gd_ses_country = $gd_session->get('gd_country')) {
1855
-            $country_filter = $wpdb->prepare(" AND r.post_country=%s ", str_replace("-", " ", $gd_ses_country));
1856
-        }
1844
+	global $wpdb, $tablecomments, $tableposts, $rating_table_name, $gd_session;
1845
+	$tablecomments = $wpdb->comments;
1846
+	$tableposts = $wpdb->posts;
1847
+
1848
+	$comments_echo = '';
1849
+	$city_filter = '';
1850
+	$region_filter = '';
1851
+	$country_filter = '';
1852
+
1853
+	if ($gd_session->get('gd_multi_location')) {
1854
+		if ($gd_ses_country = $gd_session->get('gd_country')) {
1855
+			$country_filter = $wpdb->prepare(" AND r.post_country=%s ", str_replace("-", " ", $gd_ses_country));
1856
+		}
1857 1857
 
1858
-        if ($gd_ses_region = $gd_session->get('gd_region')) {
1859
-            $region_filter = $wpdb->prepare(" AND r.post_region=%s ", str_replace("-", " ", $gd_ses_region));
1860
-        }
1858
+		if ($gd_ses_region = $gd_session->get('gd_region')) {
1859
+			$region_filter = $wpdb->prepare(" AND r.post_region=%s ", str_replace("-", " ", $gd_ses_region));
1860
+		}
1861 1861
 
1862
-        if ($gd_ses_city = $gd_session->get('gd_city')) {
1863
-            $city_filter = $wpdb->prepare(" AND r.post_city=%s ", str_replace("-", " ", $gd_ses_city));
1864
-        }
1865
-    }
1862
+		if ($gd_ses_city = $gd_session->get('gd_city')) {
1863
+			$city_filter = $wpdb->prepare(" AND r.post_city=%s ", str_replace("-", " ", $gd_ses_city));
1864
+		}
1865
+	}
1866 1866
 	
1867
-    $review_table = GEODIR_REVIEW_TABLE;
1868
-    $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";
1869
-
1870
-    $comments = $wpdb->get_results($request);
1871
-
1872
-    foreach ($comments as $comment) {
1873
-        // Set the extra comment info needed.
1874
-        $comment_extra = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID");
1875
-        //echo "SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID";
1876
-        $comment->comment_content = $comment_extra->comment_content;
1877
-        $comment->comment_author = $comment_extra->comment_author;
1878
-        $comment->comment_author_email = $comment_extra->comment_author_email;
1879
-
1880
-        $comment_id = '';
1881
-        $comment_id = $comment->comment_ID;
1882
-        $comment_content = strip_tags($comment->comment_content);
1883
-
1884
-        $comment_content = preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_content);
1885
-
1886
-        $permalink = get_permalink($comment->ID) . "#comment-" . $comment->comment_ID;
1887
-        $comment_author_email = $comment->comment_author_email;
1888
-        $comment_post_ID = $comment->post_id;
1889
-
1890
-        $na = true;
1891
-        if (function_exists('icl_object_id') && icl_object_id($comment_post_ID, $comment->post_type, true)) {
1892
-            $comment_post_ID2 = icl_object_id($comment_post_ID, $comment->post_type, false);
1893
-            if ($comment_post_ID == $comment_post_ID2) {
1894
-            } else {
1895
-                $na = false;
1896
-            }
1897
-        }
1867
+	$review_table = GEODIR_REVIEW_TABLE;
1868
+	$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";
1869
+
1870
+	$comments = $wpdb->get_results($request);
1871
+
1872
+	foreach ($comments as $comment) {
1873
+		// Set the extra comment info needed.
1874
+		$comment_extra = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID");
1875
+		//echo "SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID";
1876
+		$comment->comment_content = $comment_extra->comment_content;
1877
+		$comment->comment_author = $comment_extra->comment_author;
1878
+		$comment->comment_author_email = $comment_extra->comment_author_email;
1879
+
1880
+		$comment_id = '';
1881
+		$comment_id = $comment->comment_ID;
1882
+		$comment_content = strip_tags($comment->comment_content);
1883
+
1884
+		$comment_content = preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_content);
1885
+
1886
+		$permalink = get_permalink($comment->ID) . "#comment-" . $comment->comment_ID;
1887
+		$comment_author_email = $comment->comment_author_email;
1888
+		$comment_post_ID = $comment->post_id;
1889
+
1890
+		$na = true;
1891
+		if (function_exists('icl_object_id') && icl_object_id($comment_post_ID, $comment->post_type, true)) {
1892
+			$comment_post_ID2 = icl_object_id($comment_post_ID, $comment->post_type, false);
1893
+			if ($comment_post_ID == $comment_post_ID2) {
1894
+			} else {
1895
+				$na = false;
1896
+			}
1897
+		}
1898 1898
 
1899
-        $post_title = get_the_title($comment_post_ID);
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>';
1899
+		$post_title = get_the_title($comment_post_ID);
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>';
1903 1903
 
1904
-        $comment_content_length = strlen($comment_content);
1905
-        if ($comment_content_length > $comment_lenth) {
1906
-            $comment_excerpt = mb_substr($comment_content, 0, $comment_lenth) . '... ' . $read_more;
1907
-        } else {
1908
-            $comment_excerpt = $comment_content;
1909
-        }
1904
+		$comment_content_length = strlen($comment_content);
1905
+		if ($comment_content_length > $comment_lenth) {
1906
+			$comment_excerpt = mb_substr($comment_content, 0, $comment_lenth) . '... ' . $read_more;
1907
+		} else {
1908
+			$comment_excerpt = $comment_content;
1909
+		}
1910 1910
 
1911
-        if ($comment->user_id) {
1912
-            $user_profile_url = get_author_posts_url($comment->user_id);
1913
-        } else {
1914
-            $user_profile_url = '';
1915
-        }
1911
+		if ($comment->user_id) {
1912
+			$user_profile_url = get_author_posts_url($comment->user_id);
1913
+		} else {
1914
+			$user_profile_url = '';
1915
+		}
1916 1916
 
1917
-        if ($comment_id && $na) {
1918
-            $comments_echo .= '<li class="clearfix">';
1919
-            $comments_echo .= "<span class=\"li" . $comment_id . " geodir_reviewer_image\">";
1920
-            if (function_exists('get_avatar')) {
1921
-                if (!isset($comment->comment_type)) {
1922
-                    if ($user_profile_url) {
1923
-                        $comments_echo .= '<a href="' . $user_profile_url . '">';
1924
-                    }
1925
-                    $comments_echo .= get_avatar($comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1926
-                    if ($user_profile_url) {
1927
-                        $comments_echo .= '</a>';
1928
-                    }
1929
-                } elseif ((isset($comment->comment_type) && $comment->comment_type == 'trackback') || (isset($comment->comment_type) && $comment->comment_type == 'pingback')) {
1930
-                    if ($user_profile_url) {
1931
-                        $comments_echo .= '<a href="' . $user_profile_url . '">';
1932
-                    }
1933
-                    $comments_echo .= get_avatar($comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1934
-                }
1935
-            } elseif (function_exists('gravatar')) {
1936
-                if ($user_profile_url) {
1937
-                    $comments_echo .= '<a href="' . $user_profile_url . '">';
1938
-                }
1939
-                $comments_echo .= "<img src=\"";
1940
-                if ('' == $comment->comment_type) {
1941
-                    $comments_echo .= gravatar($comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1942
-                    if ($user_profile_url) {
1943
-                        $comments_echo .= '</a>';
1944
-                    }
1945
-                } elseif (('trackback' == $comment->comment_type) || ('pingback' == $comment->comment_type)) {
1946
-                    if ($user_profile_url) {
1947
-                        $comments_echo .= '<a href="' . $user_profile_url . '">';
1948
-                    }
1949
-                    $comments_echo .= gravatar($comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1950
-                    if ($user_profile_url) {
1951
-                        $comments_echo .= '</a>';
1952
-                    }
1953
-                }
1954
-                $comments_echo .= "\" alt=\"\" class=\"avatar\" />";
1955
-            }
1917
+		if ($comment_id && $na) {
1918
+			$comments_echo .= '<li class="clearfix">';
1919
+			$comments_echo .= "<span class=\"li" . $comment_id . " geodir_reviewer_image\">";
1920
+			if (function_exists('get_avatar')) {
1921
+				if (!isset($comment->comment_type)) {
1922
+					if ($user_profile_url) {
1923
+						$comments_echo .= '<a href="' . $user_profile_url . '">';
1924
+					}
1925
+					$comments_echo .= get_avatar($comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1926
+					if ($user_profile_url) {
1927
+						$comments_echo .= '</a>';
1928
+					}
1929
+				} elseif ((isset($comment->comment_type) && $comment->comment_type == 'trackback') || (isset($comment->comment_type) && $comment->comment_type == 'pingback')) {
1930
+					if ($user_profile_url) {
1931
+						$comments_echo .= '<a href="' . $user_profile_url . '">';
1932
+					}
1933
+					$comments_echo .= get_avatar($comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1934
+				}
1935
+			} elseif (function_exists('gravatar')) {
1936
+				if ($user_profile_url) {
1937
+					$comments_echo .= '<a href="' . $user_profile_url . '">';
1938
+				}
1939
+				$comments_echo .= "<img src=\"";
1940
+				if ('' == $comment->comment_type) {
1941
+					$comments_echo .= gravatar($comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1942
+					if ($user_profile_url) {
1943
+						$comments_echo .= '</a>';
1944
+					}
1945
+				} elseif (('trackback' == $comment->comment_type) || ('pingback' == $comment->comment_type)) {
1946
+					if ($user_profile_url) {
1947
+						$comments_echo .= '<a href="' . $user_profile_url . '">';
1948
+					}
1949
+					$comments_echo .= gravatar($comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png');
1950
+					if ($user_profile_url) {
1951
+						$comments_echo .= '</a>';
1952
+					}
1953
+				}
1954
+				$comments_echo .= "\" alt=\"\" class=\"avatar\" />";
1955
+			}
1956 1956
 
1957
-            $comments_echo .= "</span>\n";
1958
-
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>';
1965
-            $comments_echo .= geodir_get_rating_stars($comment->overall_rating, $comment_post_ID);
1966
-            $comments_echo .= '<p class="geodir_reviewer_text">' . $comment_excerpt . '';
1967
-            //echo preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_excerpt);
1968
-            $comments_echo .= '</p>';
1969
-
1970
-            $comments_echo .= "</span>\n";
1971
-            $comments_echo .= '</li>';
1972
-        }
1973
-    }
1957
+			$comments_echo .= "</span>\n";
1958
+
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>';
1965
+			$comments_echo .= geodir_get_rating_stars($comment->overall_rating, $comment_post_ID);
1966
+			$comments_echo .= '<p class="geodir_reviewer_text">' . $comment_excerpt . '';
1967
+			//echo preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_excerpt);
1968
+			$comments_echo .= '</p>';
1969
+
1970
+			$comments_echo .= "</span>\n";
1971
+			$comments_echo .= '</li>';
1972
+		}
1973
+	}
1974 1974
 
1975
-    return $comments_echo;
1975
+	return $comments_echo;
1976 1976
 }
1977 1977
 
1978 1978
 /**
@@ -1984,29 +1984,29 @@  discard block
 block discarded – undo
1984 1984
  */
1985 1985
 function geodir_home_map_cats_key_value_array()
1986 1986
 {
1987
-    $post_types = geodir_get_posttypes('object');
1988
-
1989
-    $return = array();
1990
-    if (!empty($post_types)) {
1991
-        foreach ($post_types as $key => $post_type) {
1992
-            $cpt_name = __($post_type->labels->singular_name, 'geodirectory');
1993
-            $post_type_name =   sprintf(__('%s Categories', 'geodirectory'),$cpt_name);
1994
-            $taxonomies = geodir_get_taxonomies($key);
1995
-            $cat_taxonomy = !empty($taxonomies[0]) ? $taxonomies[0] : NULL;
1996
-            $cat_terms = $cat_taxonomy ? get_terms($cat_taxonomy) : NULL;
1997
-
1998
-            if (!empty($cat_terms)) {
1999
-                $return['optgroup_start-' . $key] = $post_type_name;
2000
-
2001
-                foreach ($cat_terms as $cat_term) {
2002
-                    $return[$key . '_' . $cat_term->term_id] = $cat_term->name;
2003
-                }
1987
+	$post_types = geodir_get_posttypes('object');
2004 1988
 
2005
-                $return['optgroup_end-' . $key] = $post_type_name;
2006
-            }
2007
-        }
2008
-    }
2009
-    return $return;
1989
+	$return = array();
1990
+	if (!empty($post_types)) {
1991
+		foreach ($post_types as $key => $post_type) {
1992
+			$cpt_name = __($post_type->labels->singular_name, 'geodirectory');
1993
+			$post_type_name =   sprintf(__('%s Categories', 'geodirectory'),$cpt_name);
1994
+			$taxonomies = geodir_get_taxonomies($key);
1995
+			$cat_taxonomy = !empty($taxonomies[0]) ? $taxonomies[0] : NULL;
1996
+			$cat_terms = $cat_taxonomy ? get_terms($cat_taxonomy) : NULL;
1997
+
1998
+			if (!empty($cat_terms)) {
1999
+				$return['optgroup_start-' . $key] = $post_type_name;
2000
+
2001
+				foreach ($cat_terms as $cat_term) {
2002
+					$return[$key . '_' . $cat_term->term_id] = $cat_term->name;
2003
+				}
2004
+
2005
+				$return['optgroup_end-' . $key] = $post_type_name;
2006
+			}
2007
+		}
2008
+	}
2009
+	return $return;
2010 2010
 }
2011 2011
 
2012 2012
 /**
@@ -2018,7 +2018,7 @@  discard block
 block discarded – undo
2018 2018
  */
2019 2019
 function geodir_twitter_tweet_button()
2020 2020
 {
2021
-    ?>
2021
+	?>
2022 2022
     <a href="http://twitter.com/share"
2023 2023
        class="twitter-share-button"><?php _e('Tweet', 'geodirectory'); ?></a>
2024 2024
     <script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
@@ -2035,11 +2035,11 @@  discard block
 block discarded – undo
2035 2035
  * @global object $post The current post object.
2036 2036
  */
2037 2037
 function geodir_fb_like_button() {
2038
-    global $post;
2039
-    ?>
2038
+	global $post;
2039
+	?>
2040 2040
     <iframe <?php if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) {
2041
-        echo 'allowtransparency="true"';
2042
-    } ?> class="facebook"
2041
+		echo 'allowtransparency="true"';
2042
+	} ?> class="facebook"
2043 2043
          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"
2044 2044
          style="border:none; overflow:hidden; width:100px; height:20px"></iframe>
2045 2045
     <?php
@@ -2054,7 +2054,7 @@  discard block
 block discarded – undo
2054 2054
  * @package GeoDirectory
2055 2055
  */
2056 2056
 function geodir_google_plus_button() {
2057
-    ?>
2057
+	?>
2058 2058
     <div id="plusone-div" class="g-plusone" data-size="medium"></div>
2059 2059
     <script type="text/javascript">
2060 2060
         (function () {
@@ -2079,8 +2079,8 @@  discard block
 block discarded – undo
2079 2079
  * @global object $post The current post object.
2080 2080
  */
2081 2081
 function geodir_share_this_button_code() {
2082
-    global $post;
2083
-    ?>
2082
+	global $post;
2083
+	?>
2084 2084
     <div class="addthis_toolbox addthis_default_style">
2085 2085
         <span id='st_sharethis'></span>
2086 2086
         <script type="text/javascript">var switchTo5x = false;</script>
@@ -2105,8 +2105,8 @@  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)) {
2109
-        ?>
2108
+	if(get_option('geodir_listing_hover_bounce_map_pin',true)) {
2109
+		?>
2110 2110
         <script>
2111 2111
             jQuery(function ($) {
2112 2112
                 if (typeof(animate_marker) == 'function') {
@@ -2120,27 +2120,27 @@  discard block
 block discarded – undo
2120 2120
             });
2121 2121
         </script>
2122 2122
         <?php
2123
-    }
2123
+	}
2124 2124
 }
2125 2125
 add_action('geodir_after_listing_listview','geodir_listing_bounce_map_pin_on_hover',10);
2126 2126
 
2127 2127
 add_action('geodir_after_favorite_html','geodir_output_favourite_html_listings',1,1);
2128 2128
 function geodir_output_favourite_html_listings( $post_id){
2129
-    geodir_favourite_html('', $post_id);
2129
+	geodir_favourite_html('', $post_id);
2130 2130
 }
2131 2131
 
2132 2132
 add_action( 'geodir_listing_after_pinpoint', 'geodir_output_pinpoint_html_listings', 1, 2);
2133 2133
 function geodir_output_pinpoint_html_listings( $post_id, $post){
2134
-    global $wp_query;
2134
+	global $wp_query;
2135 2135
 
2136
-    $show_pin_point = $wp_query->is_main_query();
2136
+	$show_pin_point = $wp_query->is_main_query();
2137 2137
     
2138
-    if (!empty($show_pin_point) && is_active_widget(false, "", "geodir_map_v3_listing_map")) {
2139
-        $term_icon_url = get_tax_meta($post->default_category, 'ct_cat_icon', false, $post->post_type);
2140
-        $marker_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : get_option('geodir_default_marker_icon');
2141
-        ?>
2138
+	if (!empty($show_pin_point) && is_active_widget(false, "", "geodir_map_v3_listing_map")) {
2139
+		$term_icon_url = get_tax_meta($post->default_category, 'ct_cat_icon', false, $post->post_type);
2140
+		$marker_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : get_option('geodir_default_marker_icon');
2141
+		?>
2142 2142
         <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>
2143 2143
         <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>
2144 2144
         <?php
2145
-    }
2145
+	}
2146 2146
 }
2147 2147
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -51,20 +51,20 @@  discard block
 block discarded – undo
51 51
 			jQuery(listSel).children('li').switchClass('gridview_onehalf gridview_onethird gridview_onefourth', 'gridview_onefifth', 600);
52 52
 		}
53 53
 
54
-		jQuery.post("<?php echo geodir_get_ajax_url();?>&gd_listing_view=" + val, function (data) {
54
+		jQuery.post("<?php echo geodir_get_ajax_url(); ?>&gd_listing_view=" + val, function (data) {
55 55
 			//alert(data );
56 56
 		});
57 57
 	}
58 58
     </script>
59 59
     <div class="geodir-list-view-select">
60 60
         <select name="gd_list_view" id="gd_list_view" onchange="geodir_list_view_select(this);">
61
-            <?php $listing_view = (int)$gd_session->get('gd_listing_view'); ?>
62
-            <option value=""><?php _e('View:', 'geodirectory');?></option>
63
-            <option value="1" <?php selected(1, $listing_view);?>><?php _e('View: List', 'geodirectory');?></option>
64
-            <option value="2" <?php selected(2, $listing_view);?>><?php _e('View: Grid 2', 'geodirectory');?></option>
65
-            <option value="3" <?php selected(3, $listing_view);?>><?php _e('View: Grid 3', 'geodirectory');?></option>
66
-            <option value="4" <?php selected(4, $listing_view);?>><?php _e('View: Grid 4', 'geodirectory');?></option>
67
-            <option value="5" <?php selected(5, $listing_view);?>><?php _e('View: Grid 5', 'geodirectory');?></option>
61
+            <?php $listing_view = (int) $gd_session->get('gd_listing_view'); ?>
62
+            <option value=""><?php _e('View:', 'geodirectory'); ?></option>
63
+            <option value="1" <?php selected(1, $listing_view); ?>><?php _e('View: List', 'geodirectory'); ?></option>
64
+            <option value="2" <?php selected(2, $listing_view); ?>><?php _e('View: Grid 2', 'geodirectory'); ?></option>
65
+            <option value="3" <?php selected(3, $listing_view); ?>><?php _e('View: Grid 3', 'geodirectory'); ?></option>
66
+            <option value="4" <?php selected(4, $listing_view); ?>><?php _e('View: Grid 4', 'geodirectory'); ?></option>
67
+            <option value="5" <?php selected(5, $listing_view); ?>><?php _e('View: Grid 5', 'geodirectory'); ?></option>
68 68
         </select>
69 69
     </div>
70 70
 <?php
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
                 $out .= $subex;
116 116
             }
117 117
         }
118
-        $out .= ' <a class="excerpt-read-more" href="' . get_permalink() . '" title="' . get_the_title() . '">';
118
+        $out .= ' <a class="excerpt-read-more" href="'.get_permalink().'" title="'.get_the_title().'">';
119 119
         /**
120 120
          * Filter excerpt read more text.
121 121
          *
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
         if (mb_strlen($excerpt_more) > 0 && mb_strpos($excerpt, $excerpt_more) !== false) {
129 129
             $excut = -(mb_strlen($excerpt_more));
130 130
             $out .= mb_substr($excerpt, 0, $excut);
131
-            $out .= ' <a class="excerpt-read-more" href="' . get_permalink() . '" title="' . get_the_title() . '">';
131
+            $out .= ' <a class="excerpt-read-more" href="'.get_permalink().'" title="'.get_the_title().'">';
132 132
             /**
133 133
              * Filter excerpt read more text.
134 134
              *
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
      * @param object|string $post The post object.
185 185
      * @param string $post_type The post type.
186 186
      */
187
-    return (object)apply_filters('geodir_post_package_info', $package_info, $post, $post_type);
187
+    return (object) apply_filters('geodir_post_package_info', $package_info, $post, $post_type);
188 188
 
189 189
 }
190 190
 
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
         $post_title = $productinfo->post_title;
239 239
     }
240 240
 
241
-    $post_title = '<a href="' . get_permalink($pid) . '">' . $post_title . '</a>';
241
+    $post_title = '<a href="'.get_permalink($pid).'">'.$post_title.'</a>';
242 242
 
243 243
     $user_info = get_userdata($author_id);
244 244
     $to_email = geodir_get_post_meta($pid, 'geodir_email', true);
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
     do_action('geodir_after_send_enquiry', $request, 'Enquiry');
269 269
 
270 270
     $client_message = $frnd_comments;
271
-    $client_message .= '<br>' . __('From :', 'geodirectory') . ' ' . $yourname . '<br>' . __('Phone :', 'geodirectory') . ' ' . $inq_phone . '<br>' . __('Email :', 'geodirectory') . ' ' . $youremail . '<br><br>' . __('Sent from', 'geodirectory') . ' - <b><a href="' . trailingslashit(home_url()) . '">' . get_option('blogname') . '</a></b>.';
271
+    $client_message .= '<br>'.__('From :', 'geodirectory').' '.$yourname.'<br>'.__('Phone :', 'geodirectory').' '.$inq_phone.'<br>'.__('Email :', 'geodirectory').' '.$youremail.'<br><br>'.__('Sent from', 'geodirectory').' - <b><a href="'.trailingslashit(home_url()).'">'.get_option('blogname').'</a></b>.';
272 272
     /**
273 273
      * Filter client message text.
274 274
      *
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
         // strip slashes message
299 299
         $client_message = stripslashes_deep($client_message);
300 300
 
301
-        geodir_sendEmail($youremail, $yourname, $to_email, $to_name, '', $client_message, $extra = '', 'send_enquiry', $request['pid']);//To client email
301
+        geodir_sendEmail($youremail, $yourname, $to_email, $to_name, '', $client_message, $extra = '', 'send_enquiry', $request['pid']); //To client email
302 302
     }
303 303
 
304 304
     /**
@@ -320,9 +320,9 @@  discard block
 block discarded – undo
320 320
     do_action('geodir_after_send_enquiry_email', $request);
321 321
     $url = get_permalink($pid);
322 322
     if (strstr($url, '?')) {
323
-        $url = $url . "&send_inquiry=success";
323
+        $url = $url."&send_inquiry=success";
324 324
     } else {
325
-        $url = $url . "?send_inquiry=success";
325
+        $url = $url."?send_inquiry=success";
326 326
     }
327 327
     /**
328 328
      * Filter redirect url after the send enquiry email is sent.
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
      * }
404 404
      */
405 405
     do_action('geodir_before_send_to_friend_email', $request);
406
-    geodir_sendEmail($youremail, $yourname, $to_email, $to_name, $frnd_subject, $frnd_comments, $extra = '', 'send_friend', $request['pid']);//To client email
406
+    geodir_sendEmail($youremail, $yourname, $to_email, $to_name, $frnd_subject, $frnd_comments, $extra = '', 'send_friend', $request['pid']); //To client email
407 407
 
408 408
     /**
409 409
      * Called after the send to friend email is sent.
@@ -427,9 +427,9 @@  discard block
 block discarded – undo
427 427
 
428 428
     $url = get_permalink($pid);
429 429
     if (strstr($url, '?')) {
430
-        $url = $url . "&sendtofrnd=success";
430
+        $url = $url."&sendtofrnd=success";
431 431
     } else {
432
-        $url = $url . "?sendtofrnd=success";
432
+        $url = $url."?sendtofrnd=success";
433 433
     }
434 434
     /**
435 435
      * Filter redirect url after the send to friend email is sent.
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
              *
464 464
              * @since 1.0.0
465 465
              */
466
-            echo ' <div id="' . apply_filters('geodir_post_gallery_id', 'geodir-post-gallery') . '" class="clearfix" >';
466
+            echo ' <div id="'.apply_filters('geodir_post_gallery_id', 'geodir-post-gallery').'" class="clearfix" >';
467 467
             break;
468 468
         case 'reviews' :
469 469
             echo '<div id="reviews-wrap" class="clearfix"> ';
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
         if (!in_array($post_type, $all_postypes))
530 530
             return false;
531 531
 
532
-        $sort_field_info = $wpdb->get_var($wpdb->prepare("select default_order from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where	post_type= %s and is_active=%d and is_default=%d", array($post_type, 1, 1)));
532
+        $sort_field_info = $wpdb->get_var($wpdb->prepare("select default_order from ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." where	post_type= %s and is_active=%d and is_default=%d", array($post_type, 1, 1)));
533 533
 
534 534
         if (!empty($sort_field_info))
535 535
             return $sort_field_info;
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
         if (!in_array($post_type, $all_postypes))
558 558
             return false;
559 559
 
560
-        $sort_field_info = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type=%s AND is_active=%d AND (sort_asc=1 || sort_desc=1 || field_type='random') AND field_type != 'address' ORDER BY sort_order ASC", array($post_type, 1)));
560
+        $sort_field_info = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." WHERE post_type=%s AND is_active=%d AND (sort_asc=1 || sort_desc=1 || field_type='random') AND field_type != 'address' ORDER BY sort_order ASC", array($post_type, 1)));
561 561
         /**
562 562
          * Filter post sort options.
563 563
          *
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 	 *
588 588
 	 * @since 1.4.4
589 589
 	 */
590
-	if ( is_search() ) {
590
+	if (is_search()) {
591 591
 		return;
592 592
 	}
593 593
 
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
             if ($sort->field_type == 'random') {
612 612
                 $key = $sort->field_type;
613 613
                 ($sort_by == $key || ($sort->is_default == '1' && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
614
-                $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
614
+                $sort_field_options .= '<option '.$selected.' value="'.esc_url(add_query_arg('sort_by', $key)).'">'.__($label, 'geodirectory').'</option>';
615 615
             }
616 616
 
617 617
             if ($sort->htmlvar_name == 'comment_count') {
@@ -619,21 +619,21 @@  discard block
 block discarded – undo
619 619
             }
620 620
 
621 621
             if ($sort->sort_asc) {
622
-                $key = $sort->htmlvar_name . '_asc';
622
+                $key = $sort->htmlvar_name.'_asc';
623 623
                 $label = $sort->site_title;
624 624
                 if ($sort->asc_title)
625 625
                     $label = $sort->asc_title;
626 626
                 ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
627
-                $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
627
+                $sort_field_options .= '<option '.$selected.' value="'.esc_url(add_query_arg('sort_by', $key)).'">'.__($label, 'geodirectory').'</option>';
628 628
             }
629 629
 
630 630
             if ($sort->sort_desc) {
631
-                $key = $sort->htmlvar_name . '_desc';
631
+                $key = $sort->htmlvar_name.'_desc';
632 632
                 $label = $sort->site_title;
633 633
                 if ($sort->desc_title)
634 634
                     $label = $sort->desc_title;
635 635
                 ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
636
-                $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
636
+                $sort_field_options .= '<option '.$selected.' value="'.esc_url(add_query_arg('sort_by', $key)).'">'.__($label, 'geodirectory').'</option>';
637 637
             }
638 638
 
639 639
         }
@@ -648,9 +648,9 @@  discard block
 block discarded – undo
648 648
             <select name="sort_by" id="sort_by" onchange="javascript:window.location=this.value;">
649 649
 
650 650
                 <option
651
-                    value="<?php echo esc_url( add_query_arg('sort_by', '') );?>" <?php if ($sort_by == '') echo 'selected="selected"';?>><?php _e('Sort By', 'geodirectory');?></option><?php
651
+                    value="<?php echo esc_url(add_query_arg('sort_by', '')); ?>" <?php if ($sort_by == '') echo 'selected="selected"'; ?>><?php _e('Sort By', 'geodirectory'); ?></option><?php
652 652
 
653
-                echo $sort_field_options;?>
653
+                echo $sort_field_options; ?>
654 654
 
655 655
             </select>
656 656
 
@@ -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',true)) ? true : false;
1499
+    $tab_list = (get_option('geodir_disable_tabs', true)) ? 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.
geodirectory-functions/custom_taxonomy_hooks_actions.php 4 patches
Doc Comments   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
  * @global wpdb $wpdb WordPress database abstraction object.
326 326
  * @deprecated 1.5.0 No longer required.
327 327
  * @param string $rules mod_rewrite Rewrite rules formatted for .htaccess.
328
- * @return array Rewrite rules.
328
+ * @return string Rewrite rules.
329 329
  */
330 330
 function geodir_htaccess_contents($rules)
331 331
 {
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
  * @since 1.0.0
351 351
  *
352 352
  * @param array $public_query_vars The array of query variables.
353
- * @return array Query variables.
353
+ * @return string[] Query variables.
354 354
  */
355 355
 function geodir_add_location_var($public_query_vars)
356 356
 {
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
  * @since 1.0.0
367 367
  *
368 368
  * @param array $public_query_vars The array of query variables.
369
- * @return array Query variables.
369
+ * @return string[] Query variables.
370 370
  */
371 371
 function geodir_add_geodir_page_var($public_query_vars)
372 372
 {
@@ -793,7 +793,6 @@  discard block
 block discarded – undo
793 793
  *
794 794
  * @since 1.0.0
795 795
  *
796
- * @param object $wp The WordPress object.
797 796
  */
798 797
 function geodir_custom_post_status()
799 798
 {
Please login to merge, or discard this patch.
Braces   +103 added lines, -70 removed lines patch added patch discarded remove patch
@@ -106,24 +106,30 @@  discard block
 block discarded – undo
106 106
         $listing_slug = htmlentities(trim($_REQUEST['geodir_listing_prefix']));
107 107
 
108 108
         if ($post_type == 'gd_place') {
109
-            if (array_key_exists('has_archive', $args))
110
-                $args['has_archive'] = $listing_slug;
109
+            if (array_key_exists('has_archive', $args)) {
110
+                            $args['has_archive'] = $listing_slug;
111
+            }
111 112
 
112 113
             if (array_key_exists('rewrite', $args)) {
113
-                if (array_key_exists('slug', $args['rewrite']))
114
-                    $args['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
114
+                if (array_key_exists('slug', $args['rewrite'])) {
115
+                                    $args['rewrite']['slug'] = $listing_slug;
116
+                }
117
+                // . '/%gd_taxonomy%';
115 118
             }
116 119
 
117 120
             $geodir_post_types = get_option('geodir_post_types');
118 121
 
119 122
             if (array_key_exists($post_type, $geodir_post_types)) {
120 123
 
121
-                if (array_key_exists('has_archive', $geodir_post_types[$post_type]))
122
-                    $geodir_post_types[$post_type]['has_archive'] = $listing_slug;
124
+                if (array_key_exists('has_archive', $geodir_post_types[$post_type])) {
125
+                                    $geodir_post_types[$post_type]['has_archive'] = $listing_slug;
126
+                }
123 127
 
124
-                if (array_key_exists('rewrite', $geodir_post_types[$post_type]))
125
-                    if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
126
-                        $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
128
+                if (array_key_exists('rewrite', $geodir_post_types[$post_type])) {
129
+                                    if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
130
+                        $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;
131
+                }
132
+                // . '/%gd_taxonomy%';
127 133
 
128 134
                 update_option('geodir_post_types', $geodir_post_types);
129 135
 
@@ -138,10 +144,11 @@  discard block
 block discarded – undo
138 144
             if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type . 'category'])) {
139 145
                 $geodir_taxonomies[$post_type . 'category']['listing_slug'] = $listing_slug;
140 146
 
141
-                if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category']))
142
-                    if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
147
+                if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category'])) {
148
+                                    if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
143 149
                         if (array_key_exists('slug', $geodir_taxonomies[$post_type . 'category']['args']['rewrite']))
144
-                            $geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug;
150
+                            $geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug;
151
+                }
145 152
 
146 153
                 update_option('geodir_taxonomies', $geodir_taxonomies);
147 154
 
@@ -152,10 +159,11 @@  discard block
 block discarded – undo
152 159
             if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type . '_tags'])) {
153 160
                 $geodir_taxonomies_tag[$post_type . '_tags']['listing_slug'] = $listing_slug . '/tags';
154 161
 
155
-                if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags']))
156
-                    if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
162
+                if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags'])) {
163
+                                    if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
157 164
                         if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']))
158
-                            $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags';
165
+                            $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags';
166
+                }
159 167
 
160 168
                 update_option('geodir_taxonomies', $geodir_taxonomies_tag);
161 169
 
@@ -221,8 +229,9 @@  discard block
 block discarded – undo
221 229
         global $wpdb;
222 230
         $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $location_page));
223 231
     }
224
-    if (!isset($location_prefix))
225
-        $location_prefix = 'location';
232
+    if (!isset($location_prefix)) {
233
+            $location_prefix = 'location';
234
+    }
226 235
 
227 236
 	$location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
228 237
 	if ($location_manager) {
@@ -441,14 +450,17 @@  discard block
 block discarded – undo
441 450
         $gd_country = '';
442 451
         $gd_region = '';
443 452
         $gd_city = '';
444
-        if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '')
445
-            $gd_country = urldecode($wp->query_vars['gd_country']);
453
+        if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') {
454
+                    $gd_country = urldecode($wp->query_vars['gd_country']);
455
+        }
446 456
 
447
-        if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '')
448
-            $gd_region = urldecode($wp->query_vars['gd_region']);
457
+        if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') {
458
+                    $gd_region = urldecode($wp->query_vars['gd_region']);
459
+        }
449 460
 
450
-        if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '')
451
-            $gd_city = urldecode($wp->query_vars['gd_city']);
461
+        if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') {
462
+                    $gd_city = urldecode($wp->query_vars['gd_city']);
463
+        }
452 464
 
453 465
         if (!($gd_country == '' && $gd_region == '' && $gd_city == '')) {
454 466
             $default_location = geodir_get_default_location();
@@ -456,17 +468,19 @@  discard block
 block discarded – undo
456 468
             if (get_option('geodir_add_location_url')) {
457 469
                 if ($geodir_show_location_url != 'all') {
458 470
                     if ($gd_region == '') {
459
-                        if ($gd_ses_region = $gd_session->get('gd_region'))
460
-                            $gd_region = $gd_ses_region;
461
-                        else
462
-                            $gd_region = $default_location->region_slug;
471
+                        if ($gd_ses_region = $gd_session->get('gd_region')) {
472
+                                                    $gd_region = $gd_ses_region;
473
+                        } else {
474
+                                                    $gd_region = $default_location->region_slug;
475
+                        }
463 476
                     }
464 477
 
465 478
                     if ($gd_city == '') {
466
-                        if ($gd_ses_city = $gd_session->get('gd_city'))
467
-                            $gd_city = $gd_ses_city;
468
-                        else
469
-                            $gd_city = $default_location->city_slug;
479
+                        if ($gd_ses_city = $gd_session->get('gd_city')) {
480
+                                                    $gd_city = $gd_ses_city;
481
+                        } else {
482
+                                                    $gd_city = $default_location->city_slug;
483
+                        }
470 484
 
471 485
                         $base_location_link = geodir_get_location_link('base');
472 486
                         wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city);
@@ -585,8 +599,9 @@  discard block
 block discarded – undo
585 599
 
586 600
 
587 601
 				$geodir_term = str_replace('/' . $geodir_last_term, '', $geodir_term, $post_title_replace_count);
588
-				if (!$post_title_replace_count)
589
-					$geodir_term = str_replace($geodir_last_term, '', $geodir_term, $post_title_replace_count);
602
+				if (!$post_title_replace_count) {
603
+									$geodir_term = str_replace($geodir_last_term, '', $geodir_term, $post_title_replace_count);
604
+				}
590 605
 				$geodir_terms = explode('/', $geodir_term);
591 606
 				$geodir_last_term = end($geodir_terms);
592 607
 
@@ -622,8 +637,9 @@  discard block
 block discarded – undo
622 637
                     if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
623 638
                         geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) &&
624 639
                         geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)
625
-                    )
626
-                        $is_geodir_location_found = true;
640
+                    ) {
641
+                                            $is_geodir_location_found = true;
642
+                    }
627 643
 
628 644
                     // if location has not been found for country , region and city then search for country and region only
629 645
 
@@ -631,8 +647,9 @@  discard block
 block discarded – undo
631 647
                         $gd_city = '';
632 648
                         if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
633 649
                             geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region)
634
-                        )
635
-                            $is_geodir_location_found = true;
650
+                        ) {
651
+                                                    $is_geodir_location_found = true;
652
+                        }
636 653
 
637 654
                     }
638 655
 
@@ -640,8 +657,9 @@  discard block
 block discarded – undo
640 657
                     if (!$is_geodir_location_found) {
641 658
                         $gd_city = '';
642 659
                         $gd_region = '';
643
-                        if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
644
-                            $is_geodir_location_found = true;
660
+                        if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) {
661
+                                                    $is_geodir_location_found = true;
662
+                        }
645 663
                     }
646 664
                 } else if ($geodir_show_location_url == 'country_city') {
647 665
                     if (count($geodir_terms) >= 2) {
@@ -651,17 +669,19 @@  discard block
 block discarded – undo
651 669
                         $gd_country = urldecode($geodir_terms[0]);
652 670
                     }
653 671
 
654
-                    if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
655
-                        $is_geodir_location_found = true;
672
+                    if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) {
673
+                                            $is_geodir_location_found = true;
674
+                    }
656 675
 
657 676
                     // if location has not been found for country and city  then search for country only
658 677
                     if (!$is_geodir_location_found) {
659 678
                         $gd_city = '';
660 679
                         
661
-						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
662
-                            $is_geodir_location_found = true;
680
+						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) {
681
+						                            $is_geodir_location_found = true;
682
+						}
663 683
                     }
664
-                }  else if ($geodir_show_location_url == 'region_city') {
684
+                } else if ($geodir_show_location_url == 'region_city') {
665 685
                     if (count($geodir_terms) >= 2) {
666 686
                         $gd_region = urldecode($geodir_terms[0]);
667 687
                         $gd_city = urldecode($geodir_terms[1]);
@@ -669,15 +689,17 @@  discard block
 block discarded – undo
669 689
                         $gd_region = urldecode($geodir_terms[0]);
670 690
                     }
671 691
 
672
-                    if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
673
-                        $is_geodir_location_found = true;
692
+                    if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) {
693
+                                            $is_geodir_location_found = true;
694
+                    }
674 695
 
675 696
                     // if location has not been found for region and city  then search for region only
676 697
                     if (!$is_geodir_location_found) {
677 698
                         $gd_city = '';
678 699
                         
679
-						if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region))
680
-                            $is_geodir_location_found = true;
700
+						if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region)) {
701
+						                            $is_geodir_location_found = true;
702
+						}
681 703
                     }
682 704
                 } else {
683 705
                     $gd_city = $geodir_terms[0];
@@ -719,14 +741,17 @@  discard block
 block discarded – undo
719 741
 
720 742
             $wp->query_vars[$geodir_taxonomy] = $geodir_term;
721 743
             // eliminate location related terms from taxonomy term
722
-            if ($gd_country != '')
723
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
744
+            if ($gd_country != '') {
745
+                            $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
746
+            }
724 747
 
725
-            if ($gd_region != '')
726
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
748
+            if ($gd_region != '') {
749
+                            $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
750
+            }
727 751
 
728
-            if ($gd_city != '')
729
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
752
+            if ($gd_city != '') {
753
+                            $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
754
+            }
730 755
 
731 756
 
732 757
             $wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
@@ -762,27 +787,34 @@  discard block
 block discarded – undo
762 787
     if (get_option('geodir_add_location_url')) {        
763 788
 		if ($geodir_show_location_url == 'all') {
764 789
 		} else if ($geodir_show_location_url == 'country_city') {
765
-			 if (isset($wp->query_vars['gd_region']))
766
-                $wp->query_vars['gd_region'] = '';
790
+			 if (isset($wp->query_vars['gd_region'])) {
791
+			                 $wp->query_vars['gd_region'] = '';
792
+			 }
767 793
 		} else if ($geodir_show_location_url == 'region_city') {
768
-			if (isset($wp->query_vars['gd_country']))
769
-                $wp->query_vars['gd_country'] = '';
794
+			if (isset($wp->query_vars['gd_country'])) {
795
+			                $wp->query_vars['gd_country'] = '';
796
+			}
770 797
 		} else {
771
-			if (isset($wp->query_vars['gd_country']))
772
-                $wp->query_vars['gd_country'] = '';
798
+			if (isset($wp->query_vars['gd_country'])) {
799
+			                $wp->query_vars['gd_country'] = '';
800
+			}
773 801
 
774
-            if (isset($wp->query_vars['gd_region']))
775
-                $wp->query_vars['gd_region'] = '';
802
+            if (isset($wp->query_vars['gd_region'])) {
803
+                            $wp->query_vars['gd_region'] = '';
804
+            }
776 805
 		}
777 806
     } else {
778
-        if (isset($wp->query_vars['gd_country']))
779
-            $wp->query_vars['gd_country'] = '';
807
+        if (isset($wp->query_vars['gd_country'])) {
808
+                    $wp->query_vars['gd_country'] = '';
809
+        }
780 810
 
781
-        if (isset($wp->query_vars['gd_region']))
782
-            $wp->query_vars['gd_region'] = '';
811
+        if (isset($wp->query_vars['gd_region'])) {
812
+                    $wp->query_vars['gd_region'] = '';
813
+        }
783 814
 
784
-        if (isset($wp->query_vars['gd_city']))
785
-            $wp->query_vars['gd_city'] = '';
815
+        if (isset($wp->query_vars['gd_city'])) {
816
+                    $wp->query_vars['gd_city'] = '';
817
+        }
786 818
     }
787 819
 }
788 820
 
@@ -894,8 +926,9 @@  discard block
 block discarded – undo
894 926
 function geodir_exclude_page_where($where)
895 927
 {
896 928
     global $wpdb;
897
-    if (is_admin())
898
-        $where .= " AND $wpdb->posts.post_status != 'virtual'";
929
+    if (is_admin()) {
930
+            $where .= " AND $wpdb->posts.post_status != 'virtual'";
931
+    }
899 932
 
900 933
     return $where;
901 934
 }
Please login to merge, or discard this patch.
Indentation   +462 added lines, -462 removed lines patch added patch discarded remove patch
@@ -13,29 +13,29 @@  discard block
 block discarded – undo
13 13
  */
14 14
 function geodir_register_taxonomies()
15 15
 {
16
-    $taxonomies = array();
17
-    $taxonomies = get_option('geodir_taxonomies');
18
-    // If custom taxonomies are present, register them
19
-    if (is_array($taxonomies)) {
20
-        // Sort taxonomies
21
-        ksort($taxonomies);
22
-
23
-        // Register taxonomies
24
-        foreach ($taxonomies as $taxonomy => $args) {
25
-            // Allow taxonomie names to be translated
26
-            if (!empty($args['args']['labels'])) {
27
-                foreach ($args['args']['labels'] as $key => $tax_label) {
28
-                    $args['args']['labels'][$key] = __($tax_label, 'geodirectory');
29
-                }
30
-            }
31
-
32
-            $tax = register_taxonomy($taxonomy, $args['object_type'], $args['args']);
33
-
34
-            if (taxonomy_exists($taxonomy)) {
35
-                $tax = register_taxonomy_for_object_type($taxonomy, $args['object_type']);
36
-            }
37
-        }
38
-    }
16
+	$taxonomies = array();
17
+	$taxonomies = get_option('geodir_taxonomies');
18
+	// If custom taxonomies are present, register them
19
+	if (is_array($taxonomies)) {
20
+		// Sort taxonomies
21
+		ksort($taxonomies);
22
+
23
+		// Register taxonomies
24
+		foreach ($taxonomies as $taxonomy => $args) {
25
+			// Allow taxonomie names to be translated
26
+			if (!empty($args['args']['labels'])) {
27
+				foreach ($args['args']['labels'] as $key => $tax_label) {
28
+					$args['args']['labels'][$key] = __($tax_label, 'geodirectory');
29
+				}
30
+			}
31
+
32
+			$tax = register_taxonomy($taxonomy, $args['object_type'], $args['args']);
33
+
34
+			if (taxonomy_exists($taxonomy)) {
35
+				$tax = register_taxonomy_for_object_type($taxonomy, $args['object_type']);
36
+			}
37
+		}
38
+	}
39 39
 }
40 40
 
41 41
 
@@ -53,40 +53,40 @@  discard block
 block discarded – undo
53 53
  */
54 54
 function geodir_register_post_types() 
55 55
 {
56
-    global $wp_post_types;
56
+	global $wp_post_types;
57 57
 
58
-    $post_types = array();
59
-    $post_types = get_option('geodir_post_types');
58
+	$post_types = array();
59
+	$post_types = get_option('geodir_post_types');
60 60
 
61
-    // Register each post type if array of data is returned
62
-    if (is_array($post_types)):
61
+	// Register each post type if array of data is returned
62
+	if (is_array($post_types)):
63 63
 
64
-        foreach ($post_types as $post_type => $args):
64
+		foreach ($post_types as $post_type => $args):
65 65
 
66
-            if (!empty($args['rewrite']['slug'])) {
67
-                $args['rewrite']['slug'] = _x($args['rewrite']['slug'], 'URL slug', 'geodirectory');
68
-            }
69
-            $args = stripslashes_deep($args);
66
+			if (!empty($args['rewrite']['slug'])) {
67
+				$args['rewrite']['slug'] = _x($args['rewrite']['slug'], 'URL slug', 'geodirectory');
68
+			}
69
+			$args = stripslashes_deep($args);
70 70
 
71
-            if (!empty($args['labels'])) {
72
-                foreach ($args['labels'] as $key => $val) {
73
-                    $args['labels'][$key] = __($val, 'geodirectory');// allow translation
74
-                }
75
-            }
71
+			if (!empty($args['labels'])) {
72
+				foreach ($args['labels'] as $key => $val) {
73
+					$args['labels'][$key] = __($val, 'geodirectory');// allow translation
74
+				}
75
+			}
76 76
 
77
-            /**
78
-             * Filter post type args.
79
-             *
80
-             * @since 1.0.0
81
-             * @param string $args Post type args.
82
-             * @param string $post_type The post type.
83
-             */
84
-            $args = apply_filters('geodir_post_type_args', $args, $post_type);
77
+			/**
78
+			 * Filter post type args.
79
+			 *
80
+			 * @since 1.0.0
81
+			 * @param string $args Post type args.
82
+			 * @param string $post_type The post type.
83
+			 */
84
+			$args = apply_filters('geodir_post_type_args', $args, $post_type);
85 85
 
86
-            $post_type = register_post_type($post_type, $args);
86
+			$post_type = register_post_type($post_type, $args);
87 87
 
88
-        endforeach;
89
-    endif;
88
+		endforeach;
89
+	endif;
90 90
 }
91 91
 
92 92
 /**
@@ -100,72 +100,72 @@  discard block
 block discarded – undo
100 100
  */
101 101
 function geodir_post_type_args_modify($args, $post_type)
102 102
 {
103
-    $geodir_location_prefix = isset($_REQUEST['geodir_location_prefix']) ? trim($_REQUEST['geodir_location_prefix']) : get_option('geodir_location_prefix');
103
+	$geodir_location_prefix = isset($_REQUEST['geodir_location_prefix']) ? trim($_REQUEST['geodir_location_prefix']) : get_option('geodir_location_prefix');
104 104
 	if (isset($_REQUEST['geodir_listing_prefix']) && $_REQUEST['geodir_listing_prefix'] != '' && geodir_strtolower($_REQUEST['geodir_listing_prefix']) != geodir_strtolower($geodir_location_prefix)) {
105 105
 
106
-        $listing_slug = htmlentities(trim($_REQUEST['geodir_listing_prefix']));
106
+		$listing_slug = htmlentities(trim($_REQUEST['geodir_listing_prefix']));
107 107
 
108
-        if ($post_type == 'gd_place') {
109
-            if (array_key_exists('has_archive', $args))
110
-                $args['has_archive'] = $listing_slug;
108
+		if ($post_type == 'gd_place') {
109
+			if (array_key_exists('has_archive', $args))
110
+				$args['has_archive'] = $listing_slug;
111 111
 
112
-            if (array_key_exists('rewrite', $args)) {
113
-                if (array_key_exists('slug', $args['rewrite']))
114
-                    $args['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
115
-            }
112
+			if (array_key_exists('rewrite', $args)) {
113
+				if (array_key_exists('slug', $args['rewrite']))
114
+					$args['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
115
+			}
116 116
 
117
-            $geodir_post_types = get_option('geodir_post_types');
117
+			$geodir_post_types = get_option('geodir_post_types');
118 118
 
119
-            if (array_key_exists($post_type, $geodir_post_types)) {
119
+			if (array_key_exists($post_type, $geodir_post_types)) {
120 120
 
121
-                if (array_key_exists('has_archive', $geodir_post_types[$post_type]))
122
-                    $geodir_post_types[$post_type]['has_archive'] = $listing_slug;
121
+				if (array_key_exists('has_archive', $geodir_post_types[$post_type]))
122
+					$geodir_post_types[$post_type]['has_archive'] = $listing_slug;
123 123
 
124
-                if (array_key_exists('rewrite', $geodir_post_types[$post_type]))
125
-                    if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
126
-                        $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
124
+				if (array_key_exists('rewrite', $geodir_post_types[$post_type]))
125
+					if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
126
+						$geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
127 127
 
128
-                update_option('geodir_post_types', $geodir_post_types);
128
+				update_option('geodir_post_types', $geodir_post_types);
129 129
 
130
-            }
130
+			}
131 131
 
132
-            $geodir_post_types = get_option('geodir_post_types');
132
+			$geodir_post_types = get_option('geodir_post_types');
133 133
 
134
-            /* --- update taxonomies (category) --- */
134
+			/* --- update taxonomies (category) --- */
135 135
 
136
-            $geodir_taxonomies = get_option('geodir_taxonomies');
136
+			$geodir_taxonomies = get_option('geodir_taxonomies');
137 137
 
138
-            if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type . 'category'])) {
139
-                $geodir_taxonomies[$post_type . 'category']['listing_slug'] = $listing_slug;
138
+			if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type . 'category'])) {
139
+				$geodir_taxonomies[$post_type . 'category']['listing_slug'] = $listing_slug;
140 140
 
141
-                if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category']))
142
-                    if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
143
-                        if (array_key_exists('slug', $geodir_taxonomies[$post_type . 'category']['args']['rewrite']))
144
-                            $geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug;
141
+				if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category']))
142
+					if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
143
+						if (array_key_exists('slug', $geodir_taxonomies[$post_type . 'category']['args']['rewrite']))
144
+							$geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug;
145 145
 
146
-                update_option('geodir_taxonomies', $geodir_taxonomies);
146
+				update_option('geodir_taxonomies', $geodir_taxonomies);
147 147
 
148
-            }
148
+			}
149 149
 
150
-            /* --- update taxonomies (tags) --- */
151
-            $geodir_taxonomies_tag = get_option('geodir_taxonomies');
152
-            if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type . '_tags'])) {
153
-                $geodir_taxonomies_tag[$post_type . '_tags']['listing_slug'] = $listing_slug . '/tags';
150
+			/* --- update taxonomies (tags) --- */
151
+			$geodir_taxonomies_tag = get_option('geodir_taxonomies');
152
+			if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type . '_tags'])) {
153
+				$geodir_taxonomies_tag[$post_type . '_tags']['listing_slug'] = $listing_slug . '/tags';
154 154
 
155
-                if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags']))
156
-                    if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
157
-                        if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']))
158
-                            $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags';
155
+				if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags']))
156
+					if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
157
+						if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']))
158
+							$geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags';
159 159
 
160
-                update_option('geodir_taxonomies', $geodir_taxonomies_tag);
160
+				update_option('geodir_taxonomies', $geodir_taxonomies_tag);
161 161
 
162
-            }
162
+			}
163 163
 
164
-        }
164
+		}
165 165
 
166
-    }
166
+	}
167 167
 
168
-    return $args;
168
+	return $args;
169 169
 }
170 170
 
171 171
 /**
@@ -178,8 +178,8 @@  discard block
 block discarded – undo
178 178
  */
179 179
 function geodir_flush_rewrite_rules()
180 180
 {
181
-    global $wp_rewrite;
182
-    $wp_rewrite->flush_rules(false);
181
+	global $wp_rewrite;
182
+	$wp_rewrite->flush_rules(false);
183 183
 }
184 184
 
185 185
 /**
@@ -194,35 +194,35 @@  discard block
 block discarded – undo
194 194
  * @return array Rewrite rules.
195 195
  */
196 196
 function geodir_listing_rewrite_rules($rules) {
197
-    $newrules = array();
198
-    $taxonomies = get_option('geodir_taxonomies');
199
-    $detail_url_seprator = get_option('geodir_detailurl_separator');
197
+	$newrules = array();
198
+	$taxonomies = get_option('geodir_taxonomies');
199
+	$detail_url_seprator = get_option('geodir_detailurl_separator');
200 200
     
201 201
 	// create rules for post listing
202
-    if (is_array($taxonomies)):
203
-        foreach ($taxonomies as $taxonomy => $args):
204
-            $post_type = $args['object_type'];
205
-            $listing_slug = $args['listing_slug'];
206
-
207
-            if (strpos($taxonomy, 'tags')) {
208
-                $newrules[$listing_slug . '/(.+?)/page/?([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&paged=$matches[2]';
209
-                $newrules[$listing_slug . '/(.+?)/?$'] = 'index.php?' . $taxonomy . '=$matches[1]';
210
-            } else {
211
-                // use this loop to add paging for details page comments paging
212
-                $newrules[str_replace("/tags","",$listing_slug) . '/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&cpage=$matches[2]';
213
-            }
214
-        endforeach;
215
-    endif;
216
-
217
-    // create rules for location listing
218
-    $location_page = get_option('geodir_location_page');
202
+	if (is_array($taxonomies)):
203
+		foreach ($taxonomies as $taxonomy => $args):
204
+			$post_type = $args['object_type'];
205
+			$listing_slug = $args['listing_slug'];
206
+
207
+			if (strpos($taxonomy, 'tags')) {
208
+				$newrules[$listing_slug . '/(.+?)/page/?([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&paged=$matches[2]';
209
+				$newrules[$listing_slug . '/(.+?)/?$'] = 'index.php?' . $taxonomy . '=$matches[1]';
210
+			} else {
211
+				// use this loop to add paging for details page comments paging
212
+				$newrules[str_replace("/tags","",$listing_slug) . '/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&cpage=$matches[2]';
213
+			}
214
+		endforeach;
215
+	endif;
216
+
217
+	// create rules for location listing
218
+	$location_page = get_option('geodir_location_page');
219 219
 	
220
-    if($location_page) {
221
-        global $wpdb;
222
-        $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $location_page));
223
-    }
224
-    if (!isset($location_prefix))
225
-        $location_prefix = 'location';
220
+	if($location_page) {
221
+		global $wpdb;
222
+		$location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $location_page));
223
+	}
224
+	if (!isset($location_prefix))
225
+		$location_prefix = 'location';
226 226
 
227 227
 	$location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
228 228
 	if ($location_manager) {
@@ -266,12 +266,12 @@  discard block
 block discarded – undo
266 266
 		$newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]';
267 267
 	}
268 268
 
269
-    if ($location_page && function_exists('icl_object_id')) {
270
-        foreach(icl_get_languages('skip_missing=N') as $lang){
271
-            $alt_page_id = '';
272
-            $alt_page_id = icl_object_id($location_page, 'page', false,$lang['language_code']);
273
-            if($alt_page_id){
274
-                $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $alt_page_id));
269
+	if ($location_page && function_exists('icl_object_id')) {
270
+		foreach(icl_get_languages('skip_missing=N') as $lang){
271
+			$alt_page_id = '';
272
+			$alt_page_id = icl_object_id($location_page, 'page', false,$lang['language_code']);
273
+			if($alt_page_id){
274
+				$location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $alt_page_id));
275 275
 
276 276
 				if ($location_manager && ($hide_country_part || $hide_region_part)) {
277 277
 					$matches2 = '';
@@ -307,14 +307,14 @@  discard block
 block discarded – undo
307 307
 					$newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]';
308 308
 					$newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]';
309 309
 				}
310
-            }
311
-        }
312
-    }
310
+			}
311
+		}
312
+	}
313 313
 
314
-    $newrules[$location_prefix . '/?$'] = 'index.php?page_id=' . $location_page;
314
+	$newrules[$location_prefix . '/?$'] = 'index.php?page_id=' . $location_page;
315 315
 
316
-    $rules = array_merge($newrules, $rules);
317
-    return $rules;
316
+	$rules = array_merge($newrules, $rules);
317
+	return $rules;
318 318
 }
319 319
 
320 320
 /**
@@ -329,18 +329,18 @@  discard block
 block discarded – undo
329 329
  */
330 330
 function geodir_htaccess_contents($rules)
331 331
 {
332
-    global $wpdb;
333
-    $location_prefix = get_option('geodir_location_prefix');
334
-    // if location page slug changed then add redirect
335
-    if ($location_prefix == 'location') {
336
-        return $rules;
337
-    }
338
-    $my_content = <<<EOD
332
+	global $wpdb;
333
+	$location_prefix = get_option('geodir_location_prefix');
334
+	// if location page slug changed then add redirect
335
+	if ($location_prefix == 'location') {
336
+		return $rules;
337
+	}
338
+	$my_content = <<<EOD
339 339
 \n# BEGIN GeoDirectory Rules
340 340
 #Redirect 301 /location/ /$location_prefix/
341 341
 # END GeoDirectory Rules\n\n
342 342
 EOD;
343
-    return $my_content . $rules;
343
+	return $my_content . $rules;
344 344
 }
345 345
 //add_filter('mod_rewrite_rules', 'geodir_htaccess_contents');
346 346
 
@@ -354,10 +354,10 @@  discard block
 block discarded – undo
354 354
  */
355 355
 function geodir_add_location_var($public_query_vars)
356 356
 {
357
-    $public_query_vars[] = 'gd_country';
358
-    $public_query_vars[] = 'gd_region';
359
-    $public_query_vars[] = 'gd_city';
360
-    return $public_query_vars;
357
+	$public_query_vars[] = 'gd_country';
358
+	$public_query_vars[] = 'gd_region';
359
+	$public_query_vars[] = 'gd_city';
360
+	return $public_query_vars;
361 361
 }
362 362
 
363 363
 /**
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
  */
371 371
 function geodir_add_geodir_page_var($public_query_vars)
372 372
 {
373
-    $public_query_vars[] = 'gd_is_geodir_page';
374
-    return $public_query_vars;
373
+	$public_query_vars[] = 'gd_is_geodir_page';
374
+	return $public_query_vars;
375 375
 }
376 376
 
377 377
 /**
@@ -383,20 +383,20 @@  discard block
 block discarded – undo
383 383
  */
384 384
 function geodir_add_page_id_in_query_var()
385 385
 {
386
-    global $wp_query;
386
+	global $wp_query;
387 387
 
388
-    $page_id = $wp_query->get_queried_object_id();
388
+	$page_id = $wp_query->get_queried_object_id();
389 389
 
390
-    if (!get_query_var('page_id')) {
391
-        // fix for WP tags conflict with enfold theme
392
-        $theme_name = geodir_strtolower(wp_get_theme());
393
-        if (!geodir_is_geodir_page() && strpos($theme_name, 'enfold') !== false) {
394
-            return $wp_query;
395
-        }
396
-        $wp_query->set('page_id', $page_id);
397
-    }
390
+	if (!get_query_var('page_id')) {
391
+		// fix for WP tags conflict with enfold theme
392
+		$theme_name = geodir_strtolower(wp_get_theme());
393
+		if (!geodir_is_geodir_page() && strpos($theme_name, 'enfold') !== false) {
394
+			return $wp_query;
395
+		}
396
+		$wp_query->set('page_id', $page_id);
397
+	}
398 398
 
399
-    return $wp_query;
399
+	return $wp_query;
400 400
 }
401 401
 
402 402
 /**
@@ -411,24 +411,24 @@  discard block
 block discarded – undo
411 411
 function geodir_set_location_var_in_session_in_core($wp) {
412 412
 	global $gd_session;
413 413
 	
414
-    // Fix for WPML removing page_id query var:
415
-    if (isset($wp->query_vars['page']) && !isset($wp->query_vars['page_id']) && isset($wp->query_vars['pagename']) && !is_home()) {
416
-        global $wpdb;
417
-
418
-        $page_for_posts = get_option('page_for_posts');
419
-        $real_page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_name=%s",$wp->query_vars['pagename']));
420
-
421
-        if (function_exists('icl_object_id')) {
422
-            $real_page_id = icl_object_id($real_page_id, 'page', true, ICL_LANGUAGE_CODE);
423
-        }
424
-        if ($real_page_id && $real_page_id!=$page_for_posts) {
425
-            $wp->query_vars['page_id'] = $real_page_id;
426
-        }
427
-    }
414
+	// Fix for WPML removing page_id query var:
415
+	if (isset($wp->query_vars['page']) && !isset($wp->query_vars['page_id']) && isset($wp->query_vars['pagename']) && !is_home()) {
416
+		global $wpdb;
417
+
418
+		$page_for_posts = get_option('page_for_posts');
419
+		$real_page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_name=%s",$wp->query_vars['pagename']));
420
+
421
+		if (function_exists('icl_object_id')) {
422
+			$real_page_id = icl_object_id($real_page_id, 'page', true, ICL_LANGUAGE_CODE);
423
+		}
424
+		if ($real_page_id && $real_page_id!=$page_for_posts) {
425
+			$wp->query_vars['page_id'] = $real_page_id;
426
+		}
427
+	}
428 428
 	
429 429
 	// Query Vars will have page_id parameter
430 430
 	// check if query var has page_id and that page id is location page
431
-    geodir_set_is_geodir_page($wp);
431
+	geodir_set_is_geodir_page($wp);
432 432
 	// if is GD homepage set the page ID
433 433
 	if (geodir_is_page('home')) {
434 434
 		$wp->query_vars['page_id'] = get_option('page_on_front');
@@ -437,118 +437,118 @@  discard block
 block discarded – undo
437 437
 	// The location url format (all or country_city or region_city or city).
438 438
 	$geodir_show_location_url = get_option('geodir_show_location_url');
439 439
 
440
-    if (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id()) {
441
-        $gd_country = '';
442
-        $gd_region = '';
443
-        $gd_city = '';
444
-        if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '')
445
-            $gd_country = urldecode($wp->query_vars['gd_country']);
446
-
447
-        if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '')
448
-            $gd_region = urldecode($wp->query_vars['gd_region']);
449
-
450
-        if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '')
451
-            $gd_city = urldecode($wp->query_vars['gd_city']);
452
-
453
-        if (!($gd_country == '' && $gd_region == '' && $gd_city == '')) {
454
-            $default_location = geodir_get_default_location();
455
-
456
-            if (get_option('geodir_add_location_url')) {
457
-                if ($geodir_show_location_url != 'all') {
458
-                    if ($gd_region == '') {
459
-                        if ($gd_ses_region = $gd_session->get('gd_region'))
460
-                            $gd_region = $gd_ses_region;
461
-                        else
462
-                            $gd_region = $default_location->region_slug;
463
-                    }
464
-
465
-                    if ($gd_city == '') {
466
-                        if ($gd_ses_city = $gd_session->get('gd_city'))
467
-                            $gd_city = $gd_ses_city;
468
-                        else
469
-                            $gd_city = $default_location->city_slug;
470
-
471
-                        $base_location_link = geodir_get_location_link('base');
472
-                        wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city);
473
-                        exit();
474
-                    }
475
-                }
476
-            }
477
-
478
-            $args = array(
479
-                'what' => 'city',
480
-                'city_val' => $gd_city,
481
-                'region_val' => $gd_region,
482
-                'country_val' => $gd_country,
483
-                'country_column_name' => 'country_slug',
484
-                'region_column_name' => 'region_slug',
485
-                'city_column_name' => 'city_slug',
486
-                'location_link_part' => false,
487
-                'compare_operator' => ''
488
-            );
489
-
490
-            $location_array = function_exists('geodir_get_location_array') ? geodir_get_location_array($args) : array();
491
-            if (!empty($location_array)) {
492
-                $gd_session->set('gd_multi_location', 1);
493
-                $gd_session->set('gd_country', $gd_country);
494
-                $gd_session->set('gd_region', $gd_region);
495
-                $gd_session->set('gd_city', $gd_city);
440
+	if (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id()) {
441
+		$gd_country = '';
442
+		$gd_region = '';
443
+		$gd_city = '';
444
+		if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '')
445
+			$gd_country = urldecode($wp->query_vars['gd_country']);
446
+
447
+		if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '')
448
+			$gd_region = urldecode($wp->query_vars['gd_region']);
449
+
450
+		if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '')
451
+			$gd_city = urldecode($wp->query_vars['gd_city']);
452
+
453
+		if (!($gd_country == '' && $gd_region == '' && $gd_city == '')) {
454
+			$default_location = geodir_get_default_location();
455
+
456
+			if (get_option('geodir_add_location_url')) {
457
+				if ($geodir_show_location_url != 'all') {
458
+					if ($gd_region == '') {
459
+						if ($gd_ses_region = $gd_session->get('gd_region'))
460
+							$gd_region = $gd_ses_region;
461
+						else
462
+							$gd_region = $default_location->region_slug;
463
+					}
464
+
465
+					if ($gd_city == '') {
466
+						if ($gd_ses_city = $gd_session->get('gd_city'))
467
+							$gd_city = $gd_ses_city;
468
+						else
469
+							$gd_city = $default_location->city_slug;
470
+
471
+						$base_location_link = geodir_get_location_link('base');
472
+						wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city);
473
+						exit();
474
+					}
475
+				}
476
+			}
477
+
478
+			$args = array(
479
+				'what' => 'city',
480
+				'city_val' => $gd_city,
481
+				'region_val' => $gd_region,
482
+				'country_val' => $gd_country,
483
+				'country_column_name' => 'country_slug',
484
+				'region_column_name' => 'region_slug',
485
+				'city_column_name' => 'city_slug',
486
+				'location_link_part' => false,
487
+				'compare_operator' => ''
488
+			);
489
+
490
+			$location_array = function_exists('geodir_get_location_array') ? geodir_get_location_array($args) : array();
491
+			if (!empty($location_array)) {
492
+				$gd_session->set('gd_multi_location', 1);
493
+				$gd_session->set('gd_country', $gd_country);
494
+				$gd_session->set('gd_region', $gd_region);
495
+				$gd_session->set('gd_city', $gd_city);
496 496
                 
497 497
 				$wp->query_vars['gd_country'] = $gd_country;
498
-                $wp->query_vars['gd_region'] = $gd_region;
499
-                $wp->query_vars['gd_city'] = $gd_city;
500
-            } else {
501
-                $gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
502
-            }
503
-        } else {
504
-            $gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
505
-        }
506
-
507
-    } else if (isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
508
-        if (!is_admin()) {
509
-            $requested_post_type = $wp->query_vars['post_type'];
510
-            // check if this post type is geodirectory post types
511
-            $post_type_array = geodir_get_posttypes();
498
+				$wp->query_vars['gd_region'] = $gd_region;
499
+				$wp->query_vars['gd_city'] = $gd_city;
500
+			} else {
501
+				$gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
502
+			}
503
+		} else {
504
+			$gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
505
+		}
506
+
507
+	} else if (isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
508
+		if (!is_admin()) {
509
+			$requested_post_type = $wp->query_vars['post_type'];
510
+			// check if this post type is geodirectory post types
511
+			$post_type_array = geodir_get_posttypes();
512 512
             
513 513
 			if (in_array($requested_post_type, $post_type_array)) {
514
-                // now u can apply geodirectory related manipulation.
515
-            }
516
-        }
517
-    } else {
518
-        // check if a geodirectory taxonomy is set
519
-        $gd_country = '';
520
-        $gd_region = '';
521
-        $gd_city = '';
514
+				// now u can apply geodirectory related manipulation.
515
+			}
516
+		}
517
+	} else {
518
+		// check if a geodirectory taxonomy is set
519
+		$gd_country = '';
520
+		$gd_region = '';
521
+		$gd_city = '';
522 522
         
523 523
 		$is_geodir_taxonomy = false;
524
-        $is_geodir_taxonomy_term = false; // the last term is real geodirectory taxonomy term or not
525
-        $is_geodir_location_found = false;
524
+		$is_geodir_taxonomy_term = false; // the last term is real geodirectory taxonomy term or not
525
+		$is_geodir_location_found = false;
526 526
 		
527 527
 		$geodir_taxonomy = '';
528
-        $geodir_post_type = '';
529
-        $geodir_term = '';
530
-        $geodir_set_location_session = true;
531
-        $geodir_taxonomis = geodir_get_taxonomies('', true);
532
-
533
-        if(!empty($geodir_taxonomis)){
534
-            foreach ($geodir_taxonomis as $taxonomy) {
535
-                if (array_key_exists($taxonomy, $wp->query_vars)) {
536
-                    $is_geodir_taxonomy = true;
537
-                    $geodir_taxonomy = $taxonomy;
538
-                    $geodir_post_type = str_replace('category', '', $taxonomy);
539
-                    $geodir_post_type = str_replace('_tags', '', $geodir_post_type);
540
-                    $geodir_term = $wp->query_vars[$geodir_taxonomy];
541
-                    break;
542
-                }
543
-            }
544
-        }
545
-
546
-        // now get an array of all terms seperated by '/'
547
-        $geodir_terms = explode('/', $geodir_term);
548
-        $geodir_last_term = end($geodir_terms);
549
-
550
-        if ($is_geodir_taxonomy) { // do all these only when it is a geodirectory taxonomy
551
-            $wp->query_vars['post_type'] = $geodir_post_type;
528
+		$geodir_post_type = '';
529
+		$geodir_term = '';
530
+		$geodir_set_location_session = true;
531
+		$geodir_taxonomis = geodir_get_taxonomies('', true);
532
+
533
+		if(!empty($geodir_taxonomis)){
534
+			foreach ($geodir_taxonomis as $taxonomy) {
535
+				if (array_key_exists($taxonomy, $wp->query_vars)) {
536
+					$is_geodir_taxonomy = true;
537
+					$geodir_taxonomy = $taxonomy;
538
+					$geodir_post_type = str_replace('category', '', $taxonomy);
539
+					$geodir_post_type = str_replace('_tags', '', $geodir_post_type);
540
+					$geodir_term = $wp->query_vars[$geodir_taxonomy];
541
+					break;
542
+				}
543
+			}
544
+		}
545
+
546
+		// now get an array of all terms seperated by '/'
547
+		$geodir_terms = explode('/', $geodir_term);
548
+		$geodir_last_term = end($geodir_terms);
549
+
550
+		if ($is_geodir_taxonomy) { // do all these only when it is a geodirectory taxonomy
551
+			$wp->query_vars['post_type'] = $geodir_post_type;
552 552
 
553 553
 			// now check if last term is a post of geodirectory post types
554 554
 			$geodir_post = get_posts(array(
@@ -597,196 +597,196 @@  discard block
 block discarded – undo
597 597
 				//return ;
598 598
 			}
599 599
 
600
-            $geodir_location_terms = '';
601
-            // if last term is not a post then check if last term is a term of the specific texonomy or not
602
-            if (geodir_term_exists($geodir_last_term, $geodir_taxonomy)) {
603
-                $is_geodir_taxonomy_term = true;
600
+			$geodir_location_terms = '';
601
+			// if last term is not a post then check if last term is a term of the specific texonomy or not
602
+			if (geodir_term_exists($geodir_last_term, $geodir_taxonomy)) {
603
+				$is_geodir_taxonomy_term = true;
604 604
 
605
-                $geodir_set_location_session = false;
606
-            }
605
+				$geodir_set_location_session = false;
606
+			}
607 607
 
608 608
 
609
-            // now check if there is location parts in the url or not
610
-            if (get_option('geodir_add_location_url')) {				
609
+			// now check if there is location parts in the url or not
610
+			if (get_option('geodir_add_location_url')) {				
611 611
 				$default_location = geodir_get_default_location();
612 612
                 
613 613
 				if ($geodir_show_location_url == 'all') {
614
-                    if (count($geodir_terms) >= 3) {
615
-                        $gd_country = urldecode($geodir_terms[0]);
616
-                        $gd_region = urldecode($geodir_terms[1]);
617
-                        $gd_city = urldecode($geodir_terms[2]);
618
-                    } else if (count($geodir_terms) >= 2) {
619
-                        $gd_country = urldecode($geodir_terms[0]);
620
-                        $gd_region = urldecode($geodir_terms[1]);
621
-                    } else if (count($geodir_terms) >= 1) {
622
-                        $gd_country = urldecode($geodir_terms[0]);
623
-                    }
624
-
625
-                    if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
626
-                        geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) &&
627
-                        geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)
628
-                    )
629
-                        $is_geodir_location_found = true;
630
-
631
-                    // if location has not been found for country , region and city then search for country and region only
632
-
633
-                    if (!$is_geodir_location_found) {
634
-                        $gd_city = '';
635
-                        if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
636
-                            geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region)
637
-                        )
638
-                            $is_geodir_location_found = true;
639
-
640
-                    }
641
-
642
-                    // if location has not been found for country , region  then search for country only
643
-                    if (!$is_geodir_location_found) {
644
-                        $gd_city = '';
645
-                        $gd_region = '';
646
-                        if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
647
-                            $is_geodir_location_found = true;
648
-                    }
649
-                } else if ($geodir_show_location_url == 'country_city') {
650
-                    if (count($geodir_terms) >= 2) {
651
-                        $gd_country = urldecode($geodir_terms[0]);
652
-                        $gd_city = urldecode($geodir_terms[1]);
653
-                    } else if (count($geodir_terms) >= 1) {
654
-                        $gd_country = urldecode($geodir_terms[0]);
655
-                    }
656
-
657
-                    if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
658
-                        $is_geodir_location_found = true;
659
-
660
-                    // if location has not been found for country and city  then search for country only
661
-                    if (!$is_geodir_location_found) {
662
-                        $gd_city = '';
614
+					if (count($geodir_terms) >= 3) {
615
+						$gd_country = urldecode($geodir_terms[0]);
616
+						$gd_region = urldecode($geodir_terms[1]);
617
+						$gd_city = urldecode($geodir_terms[2]);
618
+					} else if (count($geodir_terms) >= 2) {
619
+						$gd_country = urldecode($geodir_terms[0]);
620
+						$gd_region = urldecode($geodir_terms[1]);
621
+					} else if (count($geodir_terms) >= 1) {
622
+						$gd_country = urldecode($geodir_terms[0]);
623
+					}
624
+
625
+					if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
626
+						geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) &&
627
+						geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)
628
+					)
629
+						$is_geodir_location_found = true;
630
+
631
+					// if location has not been found for country , region and city then search for country and region only
632
+
633
+					if (!$is_geodir_location_found) {
634
+						$gd_city = '';
635
+						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) &&
636
+							geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region)
637
+						)
638
+							$is_geodir_location_found = true;
639
+
640
+					}
641
+
642
+					// if location has not been found for country , region  then search for country only
643
+					if (!$is_geodir_location_found) {
644
+						$gd_city = '';
645
+						$gd_region = '';
646
+						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
647
+							$is_geodir_location_found = true;
648
+					}
649
+				} else if ($geodir_show_location_url == 'country_city') {
650
+					if (count($geodir_terms) >= 2) {
651
+						$gd_country = urldecode($geodir_terms[0]);
652
+						$gd_city = urldecode($geodir_terms[1]);
653
+					} else if (count($geodir_terms) >= 1) {
654
+						$gd_country = urldecode($geodir_terms[0]);
655
+					}
656
+
657
+					if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
658
+						$is_geodir_location_found = true;
659
+
660
+					// if location has not been found for country and city  then search for country only
661
+					if (!$is_geodir_location_found) {
662
+						$gd_city = '';
663 663
                         
664 664
 						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
665
-                            $is_geodir_location_found = true;
666
-                    }
667
-                }  else if ($geodir_show_location_url == 'region_city') {
668
-                    if (count($geodir_terms) >= 2) {
669
-                        $gd_region = urldecode($geodir_terms[0]);
670
-                        $gd_city = urldecode($geodir_terms[1]);
671
-                    } else if (count($geodir_terms) >= 1) {
672
-                        $gd_region = urldecode($geodir_terms[0]);
673
-                    }
674
-
675
-                    if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
676
-                        $is_geodir_location_found = true;
677
-
678
-                    // if location has not been found for region and city  then search for region only
679
-                    if (!$is_geodir_location_found) {
680
-                        $gd_city = '';
665
+							$is_geodir_location_found = true;
666
+					}
667
+				}  else if ($geodir_show_location_url == 'region_city') {
668
+					if (count($geodir_terms) >= 2) {
669
+						$gd_region = urldecode($geodir_terms[0]);
670
+						$gd_city = urldecode($geodir_terms[1]);
671
+					} else if (count($geodir_terms) >= 1) {
672
+						$gd_region = urldecode($geodir_terms[0]);
673
+					}
674
+
675
+					if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city))
676
+						$is_geodir_location_found = true;
677
+
678
+					// if location has not been found for region and city  then search for region only
679
+					if (!$is_geodir_location_found) {
680
+						$gd_city = '';
681 681
                         
682 682
 						if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region))
683
-                            $is_geodir_location_found = true;
684
-                    }
685
-                } else {
686
-                    $gd_city = $geodir_terms[0];
687
-
688
-                    if (geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) {
689
-                        $is_geodir_location_found = true;
690
-                        $gd_region = $default_location->region_slug;
691
-                        $gd_country = $default_location->country_slug;
692
-                    }
693
-                }
694
-                // if locaton still not found then clear location related session variables
695
-                if ($is_geodir_location_found && $geodir_set_location_session) {
696
-                    $gd_session->set('gd_multi_location', 1);
697
-                    $gd_session->set('gd_country', $gd_country);
698
-                    $gd_session->set('gd_region', $gd_region);
699
-                    $gd_session->set('gd_city', $gd_city);
700
-                }
701
-
702
-                if ($geodir_show_location_url == 'all') {
683
+							$is_geodir_location_found = true;
684
+					}
685
+				} else {
686
+					$gd_city = $geodir_terms[0];
687
+
688
+					if (geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) {
689
+						$is_geodir_location_found = true;
690
+						$gd_region = $default_location->region_slug;
691
+						$gd_country = $default_location->country_slug;
692
+					}
693
+				}
694
+				// if locaton still not found then clear location related session variables
695
+				if ($is_geodir_location_found && $geodir_set_location_session) {
696
+					$gd_session->set('gd_multi_location', 1);
697
+					$gd_session->set('gd_country', $gd_country);
698
+					$gd_session->set('gd_region', $gd_region);
699
+					$gd_session->set('gd_city', $gd_city);
700
+				}
701
+
702
+				if ($geodir_show_location_url == 'all') {
703 703
 				} else if ($geodir_show_location_url == 'country_city') {
704 704
 					$gd_region = '';
705 705
 				} else if ($geodir_show_location_url == 'region_city') {
706 706
 					$gd_country = '';
707 707
 				} else {
708 708
 					$gd_country = '';
709
-                    $gd_region = '';
709
+					$gd_region = '';
710
+				}
711
+
712
+				if ($is_geodir_location_found) {
713
+					$wp->query_vars['gd_country'] = $gd_country;
714
+					$wp->query_vars['gd_region'] = $gd_region;
715
+					$wp->query_vars['gd_city'] = $gd_city;
716
+				} else {
717
+					$gd_country = '';
718
+					$gd_region = '';
719
+					$gd_city = '';
710 720
 				}
721
+			}
722
+
723
+			$wp->query_vars[$geodir_taxonomy] = $geodir_term;
724
+			// eliminate location related terms from taxonomy term
725
+			if ($gd_country != '')
726
+				$wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
727
+
728
+			if ($gd_region != '')
729
+				$wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
730
+
731
+			if ($gd_city != '')
732
+				$wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
733
+
734
+
735
+			$wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
736
+			$wp->query_vars[$geodir_taxonomy] = str_replace('//', '', $wp->query_vars[$geodir_taxonomy]);
711 737
 
712
-                if ($is_geodir_location_found) {
713
-                    $wp->query_vars['gd_country'] = $gd_country;
714
-                    $wp->query_vars['gd_region'] = $gd_region;
715
-                    $wp->query_vars['gd_city'] = $gd_city;
716
-                } else {
717
-                    $gd_country = '';
718
-                    $gd_region = '';
719
-                    $gd_city = '';
720
-                }
721
-            }
722
-
723
-            $wp->query_vars[$geodir_taxonomy] = $geodir_term;
724
-            // eliminate location related terms from taxonomy term
725
-            if ($gd_country != '')
726
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
727
-
728
-            if ($gd_region != '')
729
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
730
-
731
-            if ($gd_city != '')
732
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
733
-
734
-
735
-            $wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
736
-            $wp->query_vars[$geodir_taxonomy] = str_replace('//', '', $wp->query_vars[$geodir_taxonomy]);
737
-
738
-            $wp->query_vars[$geodir_taxonomy] = trim($wp->query_vars[$geodir_taxonomy], '/');
739
-
740
-            if ($wp->query_vars[$geodir_taxonomy] == '') {
741
-                unset($wp->query_vars[$geodir_taxonomy]);
742
-            } else {
743
-                if (!$is_geodir_taxonomy_term) {
744
-                    foreach ($wp->query_vars as $key => $vars) {
745
-                        unset($wp->query_vars[$key]);
746
-                    }
747
-                    $wp->query_vars['error'] = '404';
748
-                }
749
-            }
750
-        }
751
-    }
738
+			$wp->query_vars[$geodir_taxonomy] = trim($wp->query_vars[$geodir_taxonomy], '/');
739
+
740
+			if ($wp->query_vars[$geodir_taxonomy] == '') {
741
+				unset($wp->query_vars[$geodir_taxonomy]);
742
+			} else {
743
+				if (!$is_geodir_taxonomy_term) {
744
+					foreach ($wp->query_vars as $key => $vars) {
745
+						unset($wp->query_vars[$key]);
746
+					}
747
+					$wp->query_vars['error'] = '404';
748
+				}
749
+			}
750
+		}
751
+	}
752 752
 	
753 753
 	// Unset location session if gd page and location not set.
754 754
 	if (isset($wp->query_vars['gd_is_geodir_page']) && !isset($wp->query_vars['gd_country'])) {
755 755
 		$gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
756 756
 	}
757 757
 
758
-    if ($gd_session->get('gd_multi_location') == 1) {
759
-        $wp->query_vars['gd_country'] = $gd_session->get('gd_country');
760
-        $wp->query_vars['gd_region'] = $gd_session->get('gd_region');
761
-        $wp->query_vars['gd_city'] = $gd_session->get('gd_city');
762
-    }
758
+	if ($gd_session->get('gd_multi_location') == 1) {
759
+		$wp->query_vars['gd_country'] = $gd_session->get('gd_country');
760
+		$wp->query_vars['gd_region'] = $gd_session->get('gd_region');
761
+		$wp->query_vars['gd_city'] = $gd_session->get('gd_city');
762
+	}
763 763
 
764
-    // now check if there is location parts in the url or not
765
-    if (get_option('geodir_add_location_url')) {        
764
+	// now check if there is location parts in the url or not
765
+	if (get_option('geodir_add_location_url')) {        
766 766
 		if ($geodir_show_location_url == 'all') {
767 767
 		} else if ($geodir_show_location_url == 'country_city') {
768 768
 			 if (isset($wp->query_vars['gd_region']))
769
-                $wp->query_vars['gd_region'] = '';
769
+				$wp->query_vars['gd_region'] = '';
770 770
 		} else if ($geodir_show_location_url == 'region_city') {
771 771
 			if (isset($wp->query_vars['gd_country']))
772
-                $wp->query_vars['gd_country'] = '';
772
+				$wp->query_vars['gd_country'] = '';
773 773
 		} else {
774 774
 			if (isset($wp->query_vars['gd_country']))
775
-                $wp->query_vars['gd_country'] = '';
775
+				$wp->query_vars['gd_country'] = '';
776 776
 
777
-            if (isset($wp->query_vars['gd_region']))
778
-                $wp->query_vars['gd_region'] = '';
777
+			if (isset($wp->query_vars['gd_region']))
778
+				$wp->query_vars['gd_region'] = '';
779 779
 		}
780
-    } else {
781
-        if (isset($wp->query_vars['gd_country']))
782
-            $wp->query_vars['gd_country'] = '';
780
+	} else {
781
+		if (isset($wp->query_vars['gd_country']))
782
+			$wp->query_vars['gd_country'] = '';
783 783
 
784
-        if (isset($wp->query_vars['gd_region']))
785
-            $wp->query_vars['gd_region'] = '';
784
+		if (isset($wp->query_vars['gd_region']))
785
+			$wp->query_vars['gd_region'] = '';
786 786
 
787
-        if (isset($wp->query_vars['gd_city']))
788
-            $wp->query_vars['gd_city'] = '';
789
-    }
787
+		if (isset($wp->query_vars['gd_city']))
788
+			$wp->query_vars['gd_city'] = '';
789
+	}
790 790
 }
791 791
 
792 792
 /**
@@ -800,24 +800,24 @@  discard block
 block discarded – undo
800 800
  */
801 801
 function geodir_custom_post_status()
802 802
 {
803
-    // Vertual Page Status
804
-    register_post_status('virtual', array(
805
-        'label' => _x('Virtual', 'page', 'geodirectory'),
806
-        'public' => true,
807
-        'exclude_from_search' => true,
808
-        'show_in_admin_all_list' => true,
809
-        'show_in_admin_status_list' => true,
810
-        'label_count' => _n_noop('Virtual <span class="count">(%s)</span>', 'Virtual <span class="count">(%s)</span>', 'geodirectory'),
811
-    ));
812
-
813
-    /**
814
-     * Called after we register the custom post status 'Virtual'.
815
-     *
816
-     * Can be use to add more post statuses.
817
-     *
818
-     * @since 1.0.0
819
-     */
820
-    do_action('geodir_custom_post_status');
803
+	// Vertual Page Status
804
+	register_post_status('virtual', array(
805
+		'label' => _x('Virtual', 'page', 'geodirectory'),
806
+		'public' => true,
807
+		'exclude_from_search' => true,
808
+		'show_in_admin_all_list' => true,
809
+		'show_in_admin_status_list' => true,
810
+		'label_count' => _n_noop('Virtual <span class="count">(%s)</span>', 'Virtual <span class="count">(%s)</span>', 'geodirectory'),
811
+	));
812
+
813
+	/**
814
+	 * Called after we register the custom post status 'Virtual'.
815
+	 *
816
+	 * Can be use to add more post statuses.
817
+	 *
818
+	 * @since 1.0.0
819
+	 */
820
+	do_action('geodir_custom_post_status');
821 821
 }
822 822
 
823 823
 /**
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
  */
833 833
 function geodir_get_term_link($termlink, $term, $taxonomy)
834 834
 {
835
-    return geodir_term_link($termlink, $term, $taxonomy); // taxonomy_functions.php
835
+	return geodir_term_link($termlink, $term, $taxonomy); // taxonomy_functions.php
836 836
 }
837 837
 
838 838
 /**
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
  */
847 847
 function geodir_get_posttype_link($link, $post_type)
848 848
 {
849
-    return geodir_posttype_link($link, $post_type); // taxonomy_functions.php
849
+	return geodir_posttype_link($link, $post_type); // taxonomy_functions.php
850 850
 }
851 851
 
852 852
 /**
@@ -861,13 +861,13 @@  discard block
 block discarded – undo
861 861
  */
862 862
 function exclude_from_wp_list_pages($exclude_array)
863 863
 {
864
-    $pages_ids = array();
865
-    $pages_array = get_posts(array('post_type' => 'page', 'post_status' => 'virtual'));
866
-    foreach ($pages_array as $page) {
867
-        $pages_ids[] = $page->ID;
868
-    }
869
-    $exclude_array = $exclude_array + $pages_ids;
870
-    return $exclude_array;
864
+	$pages_ids = array();
865
+	$pages_array = get_posts(array('post_type' => 'page', 'post_status' => 'virtual'));
866
+	foreach ($pages_array as $page) {
867
+		$pages_ids[] = $page->ID;
868
+	}
869
+	$exclude_array = $exclude_array + $pages_ids;
870
+	return $exclude_array;
871 871
 }
872 872
 
873 873
 /**
@@ -880,8 +880,8 @@  discard block
 block discarded – undo
880 880
  */
881 881
 function geodir_exclude_page($query)
882 882
 {
883
-    add_filter('posts_where', 'geodir_exclude_page_where', 100);
884
-    return $query;
883
+	add_filter('posts_where', 'geodir_exclude_page_where', 100);
884
+	return $query;
885 885
 }
886 886
 
887 887
 /**
@@ -896,9 +896,9 @@  discard block
 block discarded – undo
896 896
  */
897 897
 function geodir_exclude_page_where($where)
898 898
 {
899
-    global $wpdb;
900
-    if (is_admin())
901
-        $where .= " AND $wpdb->posts.post_status != 'virtual'";
899
+	global $wpdb;
900
+	if (is_admin())
901
+		$where .= " AND $wpdb->posts.post_status != 'virtual'";
902 902
 
903
-    return $where;
903
+	return $where;
904 904
 }
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
             if (!empty($args['labels'])) {
72 72
                 foreach ($args['labels'] as $key => $val) {
73
-                    $args['labels'][$key] = __($val, 'geodirectory');// allow translation
73
+                    $args['labels'][$key] = __($val, 'geodirectory'); // allow translation
74 74
                 }
75 75
             }
76 76
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 
112 112
             if (array_key_exists('rewrite', $args)) {
113 113
                 if (array_key_exists('slug', $args['rewrite']))
114
-                    $args['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
114
+                    $args['rewrite']['slug'] = $listing_slug; // . '/%gd_taxonomy%';
115 115
             }
116 116
 
117 117
             $geodir_post_types = get_option('geodir_post_types');
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 
124 124
                 if (array_key_exists('rewrite', $geodir_post_types[$post_type]))
125 125
                     if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
126
-                        $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%';
126
+                        $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug; // . '/%gd_taxonomy%';
127 127
 
128 128
                 update_option('geodir_post_types', $geodir_post_types);
129 129
 
@@ -135,13 +135,13 @@  discard block
 block discarded – undo
135 135
 
136 136
             $geodir_taxonomies = get_option('geodir_taxonomies');
137 137
 
138
-            if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type . 'category'])) {
139
-                $geodir_taxonomies[$post_type . 'category']['listing_slug'] = $listing_slug;
138
+            if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type.'category'])) {
139
+                $geodir_taxonomies[$post_type.'category']['listing_slug'] = $listing_slug;
140 140
 
141
-                if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category']))
142
-                    if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
143
-                        if (array_key_exists('slug', $geodir_taxonomies[$post_type . 'category']['args']['rewrite']))
144
-                            $geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug;
141
+                if (array_key_exists('args', $geodir_taxonomies[$post_type.'category']))
142
+                    if (array_key_exists('rewrite', $geodir_taxonomies[$post_type.'category']['args']))
143
+                        if (array_key_exists('slug', $geodir_taxonomies[$post_type.'category']['args']['rewrite']))
144
+                            $geodir_taxonomies[$post_type.'category']['args']['rewrite']['slug'] = $listing_slug;
145 145
 
146 146
                 update_option('geodir_taxonomies', $geodir_taxonomies);
147 147
 
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
 
150 150
             /* --- update taxonomies (tags) --- */
151 151
             $geodir_taxonomies_tag = get_option('geodir_taxonomies');
152
-            if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type . '_tags'])) {
153
-                $geodir_taxonomies_tag[$post_type . '_tags']['listing_slug'] = $listing_slug . '/tags';
152
+            if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type.'_tags'])) {
153
+                $geodir_taxonomies_tag[$post_type.'_tags']['listing_slug'] = $listing_slug.'/tags';
154 154
 
155
-                if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags']))
156
-                    if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
157
-                        if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']))
158
-                            $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags';
155
+                if (array_key_exists('args', $geodir_taxonomies_tag[$post_type.'_tags']))
156
+                    if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type.'_tags']['args']))
157
+                        if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type.'_tags']['args']['rewrite']))
158
+                            $geodir_taxonomies_tag[$post_type.'_tags']['args']['rewrite']['slug'] = $listing_slug.'/tags';
159 159
 
160 160
                 update_option('geodir_taxonomies', $geodir_taxonomies_tag);
161 161
 
@@ -205,11 +205,11 @@  discard block
 block discarded – undo
205 205
             $listing_slug = $args['listing_slug'];
206 206
 
207 207
             if (strpos($taxonomy, 'tags')) {
208
-                $newrules[$listing_slug . '/(.+?)/page/?([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&paged=$matches[2]';
209
-                $newrules[$listing_slug . '/(.+?)/?$'] = 'index.php?' . $taxonomy . '=$matches[1]';
208
+                $newrules[$listing_slug.'/(.+?)/page/?([0-9]{1,})/?$'] = 'index.php?'.$taxonomy.'=$matches[1]&paged=$matches[2]';
209
+                $newrules[$listing_slug.'/(.+?)/?$'] = 'index.php?'.$taxonomy.'=$matches[1]';
210 210
             } else {
211 211
                 // use this loop to add paging for details page comments paging
212
-                $newrules[str_replace("/tags","",$listing_slug) . '/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&cpage=$matches[2]';
212
+                $newrules[str_replace("/tags", "", $listing_slug).'/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?'.$taxonomy.'=$matches[1]&cpage=$matches[2]';
213 213
             }
214 214
         endforeach;
215 215
     endif;
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
     // create rules for location listing
218 218
     $location_page = get_option('geodir_location_page');
219 219
 	
220
-    if($location_page) {
220
+    if ($location_page) {
221 221
         global $wpdb;
222 222
         $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $location_page));
223 223
     }
@@ -247,30 +247,30 @@  discard block
 block discarded – undo
247 247
 		
248 248
 		if ($matches2) {
249 249
 			if ($neighbourhood_active) {
250
-				$newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]&gd_neighbourhood=$matches[3]';
250
+				$newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&'.$matches1.'=$matches[1]&'.$matches2.'=$matches[2]&gd_neighbourhood=$matches[3]';
251 251
 			}
252
-			$newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]';
252
+			$newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&'.$matches1.'=$matches[1]&'.$matches2.'=$matches[2]';
253 253
 		} else {
254 254
 			if ($neighbourhood_active) {
255
-				$newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]&gd_neighbourhood=$matches[2]';
255
+				$newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&'.$matches1.'=$matches[1]&gd_neighbourhood=$matches[2]';
256 256
 			}
257 257
 		}
258 258
 		
259
-		$newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]';
259
+		$newrules[$location_prefix.'/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&'.$matches1.'=$matches[1]';
260 260
 	} else { // country/region/city
261 261
 		if ($neighbourhood_active) {
262
-			$newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]&gd_neighbourhood=$matches[4]';
262
+			$newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]&gd_neighbourhood=$matches[4]';
263 263
 		}
264
-		$newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]';
265
-		$newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]&gd_region=$matches[2]';
266
-		$newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]';
264
+		$newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]';
265
+		$newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&gd_country=$matches[1]&gd_region=$matches[2]';
266
+		$newrules[$location_prefix.'/([^/]+)/?$'] = 'index.php?page_id='.$location_page.'&gd_country=$matches[1]';
267 267
 	}
268 268
 
269 269
     if ($location_page && function_exists('icl_object_id')) {
270
-        foreach(icl_get_languages('skip_missing=N') as $lang){
270
+        foreach (icl_get_languages('skip_missing=N') as $lang) {
271 271
             $alt_page_id = '';
272
-            $alt_page_id = icl_object_id($location_page, 'page', false,$lang['language_code']);
273
-            if($alt_page_id){
272
+            $alt_page_id = icl_object_id($location_page, 'page', false, $lang['language_code']);
273
+            if ($alt_page_id) {
274 274
                 $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $alt_page_id));
275 275
 
276 276
 				if ($location_manager && ($hide_country_part || $hide_region_part)) {
@@ -289,29 +289,29 @@  discard block
 block discarded – undo
289 289
 					
290 290
 					if ($matches2) {
291 291
 						if ($neighbourhood_active) {
292
-							$newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]&gd_neighbourhood=$matches[3]';
292
+							$newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&'.$matches1.'=$matches[1]&'.$matches2.'=$matches[2]&gd_neighbourhood=$matches[3]';
293 293
 						}
294
-						$newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]';
294
+						$newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&'.$matches1.'=$matches[1]&'.$matches2.'=$matches[2]';
295 295
 					} else {
296 296
 						if ($neighbourhood_active) {
297
-							$newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]&gd_neighbourhood=$matches[2]';
297
+							$newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&'.$matches1.'=$matches[1]&gd_neighbourhood=$matches[2]';
298 298
 						}
299 299
 					}
300 300
 					
301
-					$newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]';
301
+					$newrules[$location_prefix.'/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&'.$matches1.'=$matches[1]';
302 302
 				} else { // country/region/city
303 303
 					if ($neighbourhood_active) {
304
-						$newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]&gd_neighbourhood=$matches[4]';
304
+						$newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]&gd_neighbourhood=$matches[4]';
305 305
 					}
306
-					$newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]';
307
-					$newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]';
308
-					$newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]';
306
+					$newrules[$location_prefix.'/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]';
307
+					$newrules[$location_prefix.'/([^/]+)/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&gd_country=$matches[1]&gd_region=$matches[2]';
308
+					$newrules[$location_prefix.'/([^/]+)/?$'] = 'index.php?page_id='.$alt_page_id.'&gd_country=$matches[1]';
309 309
 				}
310 310
             }
311 311
         }
312 312
     }
313 313
 
314
-    $newrules[$location_prefix . '/?$'] = 'index.php?page_id=' . $location_page;
314
+    $newrules[$location_prefix.'/?$'] = 'index.php?page_id='.$location_page;
315 315
 
316 316
     $rules = array_merge($newrules, $rules);
317 317
     return $rules;
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 #Redirect 301 /location/ /$location_prefix/
341 341
 # END GeoDirectory Rules\n\n
342 342
 EOD;
343
-    return $my_content . $rules;
343
+    return $my_content.$rules;
344 344
 }
345 345
 //add_filter('mod_rewrite_rules', 'geodir_htaccess_contents');
346 346
 
@@ -416,12 +416,12 @@  discard block
 block discarded – undo
416 416
         global $wpdb;
417 417
 
418 418
         $page_for_posts = get_option('page_for_posts');
419
-        $real_page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_name=%s",$wp->query_vars['pagename']));
419
+        $real_page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_name=%s", $wp->query_vars['pagename']));
420 420
 
421 421
         if (function_exists('icl_object_id')) {
422 422
             $real_page_id = icl_object_id($real_page_id, 'page', true, ICL_LANGUAGE_CODE);
423 423
         }
424
-        if ($real_page_id && $real_page_id!=$page_for_posts) {
424
+        if ($real_page_id && $real_page_id != $page_for_posts) {
425 425
             $wp->query_vars['page_id'] = $real_page_id;
426 426
         }
427 427
     }
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
                             $gd_city = $default_location->city_slug;
470 470
 
471 471
                         $base_location_link = geodir_get_location_link('base');
472
-                        wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city);
472
+                        wp_redirect($base_location_link.'/'.$gd_country.'/'.$gd_region.'/'.$gd_city);
473 473
                         exit();
474 474
                     }
475 475
                 }
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
         $geodir_set_location_session = true;
531 531
         $geodir_taxonomis = geodir_get_taxonomies('', true);
532 532
 
533
-        if(!empty($geodir_taxonomis)){
533
+        if (!empty($geodir_taxonomis)) {
534 534
             foreach ($geodir_taxonomis as $taxonomy) {
535 535
                 if (array_key_exists($taxonomy, $wp->query_vars)) {
536 536
                     $is_geodir_taxonomy = true;
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 				}
588 588
 
589 589
 
590
-				$geodir_term = str_replace('/' . $geodir_last_term, '', $geodir_term, $post_title_replace_count);
590
+				$geodir_term = str_replace('/'.$geodir_last_term, '', $geodir_term, $post_title_replace_count);
591 591
 				if (!$post_title_replace_count)
592 592
 					$geodir_term = str_replace($geodir_last_term, '', $geodir_term, $post_title_replace_count);
593 593
 				$geodir_terms = explode('/', $geodir_term);
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 						if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country))
665 665
                             $is_geodir_location_found = true;
666 666
                     }
667
-                }  else if ($geodir_show_location_url == 'region_city') {
667
+                } else if ($geodir_show_location_url == 'region_city') {
668 668
                     if (count($geodir_terms) >= 2) {
669 669
                         $gd_region = urldecode($geodir_terms[0]);
670 670
                         $gd_city = urldecode($geodir_terms[1]);
@@ -723,13 +723,13 @@  discard block
 block discarded – undo
723 723
             $wp->query_vars[$geodir_taxonomy] = $geodir_term;
724 724
             // eliminate location related terms from taxonomy term
725 725
             if ($gd_country != '')
726
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
726
+                $wp->query_vars[$geodir_taxonomy] = preg_replace('/'.urlencode($gd_country).'/', '', $wp->query_vars[$geodir_taxonomy], 1);
727 727
 
728 728
             if ($gd_region != '')
729
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
729
+                $wp->query_vars[$geodir_taxonomy] = preg_replace('/'.urlencode($gd_region).'/', '', $wp->query_vars[$geodir_taxonomy], 1);
730 730
 
731 731
             if ($gd_city != '')
732
-                $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
732
+                $wp->query_vars[$geodir_taxonomy] = preg_replace('/'.urlencode($gd_city).'/', '', $wp->query_vars[$geodir_taxonomy], 1);
733 733
 
734 734
 
735 735
             $wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
Please login to merge, or discard this patch.
geodirectory-functions/general_functions.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1732,7 +1732,7 @@  discard block
 block discarded – undo
1732 1732
  * @global string $plugin_prefix Geodirectory plugin table prefix.
1733 1733
  * @global string $table_prefix WordPress Database Table prefix.
1734 1734
  * @param array $query_args The query array.
1735
- * @param  int|bool $count_only If true returns listings count only, otherwise returns array
1735
+ * @param  boolean $count_only If true returns listings count only, otherwise returns array
1736 1736
  * @return mixed Result object.
1737 1737
  */
1738 1738
 function geodir_get_widget_listings($query_args = array(), $count_only = false)
@@ -3264,7 +3264,7 @@  discard block
 block discarded – undo
3264 3264
  *
3265 3265
  * @since 1.0.0
3266 3266
  * @package GeoDirectory
3267
- * @return bool
3267
+ * @return null|boolean
3268 3268
  */
3269 3269
 function geodir_term_review_count_force_update($new_status, $old_status='', $post='')
3270 3270
 {
Please login to merge, or discard this patch.
Braces   +270 added lines, -188 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
     /**
@@ -774,20 +811,16 @@  discard block
 block discarded – undo
774 811
             $subject .= ' - ADMIN BCC COPY';
775 812
             $admin_bcc = true;
776 813
 
777
-        }
778
-        elseif ($message_type == 'registration' && get_option('geodir_bcc_new_user')) {
814
+        } elseif ($message_type == 'registration' && get_option('geodir_bcc_new_user')) {
779 815
             $subject .= ' - ADMIN BCC COPY';
780 816
             $admin_bcc = true;
781
-        }
782
-        elseif ($message_type == 'send_friend' && get_option('geodir_bcc_friend')) {
817
+        } elseif ($message_type == 'send_friend' && get_option('geodir_bcc_friend')) {
783 818
             $subject .= ' - ADMIN BCC COPY';
784 819
             $admin_bcc = true;
785
-        }
786
-        elseif ($message_type == 'send_enquiry' && get_option('geodir_bcc_enquiry')) {
820
+        } elseif ($message_type == 'send_enquiry' && get_option('geodir_bcc_enquiry')) {
787 821
             $subject .= ' - ADMIN BCC COPY';
788 822
             $admin_bcc = true;
789
-        }
790
-        elseif ($message_type == 'listing_published' && get_option('geodir_bcc_listing_published')) {
823
+        } elseif ($message_type == 'listing_published' && get_option('geodir_bcc_listing_published')) {
791 824
             $subject .= ' - ADMIN BCC COPY';
792 825
             $admin_bcc = true;
793 826
         }
@@ -956,21 +989,24 @@  discard block
 block discarded – undo
956 989
             $is_location_last = '';
957 990
             $is_taxonomy_last = '';
958 991
             $breadcrumb .= '<li>';
959
-            if (get_query_var($gd_post_type . 'category'))
960
-                $gd_taxonomy = $gd_post_type . 'category';
961
-            elseif (get_query_var($gd_post_type . '_tags'))
962
-                $gd_taxonomy = $gd_post_type . '_tags';
992
+            if (get_query_var($gd_post_type . 'category')) {
993
+                            $gd_taxonomy = $gd_post_type . 'category';
994
+            } elseif (get_query_var($gd_post_type . '_tags')) {
995
+                            $gd_taxonomy = $gd_post_type . '_tags';
996
+            }
963 997
 
964 998
             $breadcrumb .= $separator . '<a href="' . $listing_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>';
965
-            if (!empty($gd_taxonomy) || geodir_is_page('detail'))
966
-                $is_location_last = false;
967
-            else
968
-                $is_location_last = true;
969
-
970
-            if (!empty($gd_taxonomy) && geodir_is_page('listing'))
971
-                $is_taxonomy_last = true;
972
-            else
973
-                $is_taxonomy_last = false;
999
+            if (!empty($gd_taxonomy) || geodir_is_page('detail')) {
1000
+                            $is_location_last = false;
1001
+            } else {
1002
+                            $is_location_last = true;
1003
+            }
1004
+
1005
+            if (!empty($gd_taxonomy) && geodir_is_page('listing')) {
1006
+                            $is_taxonomy_last = true;
1007
+            } else {
1008
+                            $is_taxonomy_last = false;
1009
+            }
974 1010
 
975 1011
             if (!empty($location_terms)) {
976 1012
                 $geodir_get_locations = function_exists('get_actual_location_name') ? true : false;
@@ -1052,8 +1088,9 @@  discard block
 block discarded – undo
1052 1088
                 {
1053 1089
                     if (get_query_var($gd_post_type . '_tags')) {
1054 1090
                         $cat_link = $listing_link . 'tags/';
1055
-                    } else
1056
-                        $cat_link = $listing_link;
1091
+                    } else {
1092
+                                            $cat_link = $listing_link;
1093
+                    }
1057 1094
 
1058 1095
                     foreach ($location_terms as $key => $location_term) {
1059 1096
                         if ($location_manager && in_array($key, $hide_url_part)) {
@@ -1080,9 +1117,9 @@  discard block
 block discarded – undo
1080 1117
                             $term_link_text = geodir_ucwords(urldecode($term_link_text));
1081 1118
                         }
1082 1119
 
1083
-                        if ($term_index == count($term_array) && $is_taxonomy_last)
1084
-                            $breadcrumb .= $separator . $term_link_text;
1085
-                        else {
1120
+                        if ($term_index == count($term_array) && $is_taxonomy_last) {
1121
+                                                    $breadcrumb .= $separator . $term_link_text;
1122
+                        } else {
1086 1123
                             $cat_link .= $term . '/';
1087 1124
                             $breadcrumb .= $separator . '<a href="' . $cat_link . '">' . $term_link_text . '</a>';
1088 1125
                         }
@@ -1093,8 +1130,9 @@  discard block
 block discarded – undo
1093 1130
 
1094 1131
             }
1095 1132
 
1096
-            if (geodir_is_page('detail'))
1097
-                $breadcrumb .= $separator . get_the_title();
1133
+            if (geodir_is_page('detail')) {
1134
+                            $breadcrumb .= $separator . get_the_title();
1135
+            }
1098 1136
 
1099 1137
             $breadcrumb .= '</li>';
1100 1138
 
@@ -1131,8 +1169,9 @@  discard block
 block discarded – undo
1131 1169
 
1132 1170
                 $breadcrumb .= $separator . '<a href="' . $author_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>';
1133 1171
                 $breadcrumb .= $separator . ucfirst(__('My', 'geodirectory') . ' ' . $_REQUEST['list']);
1134
-            } else
1135
-                $breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory');
1172
+            } else {
1173
+                            $breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory');
1174
+            }
1136 1175
 
1137 1176
             $breadcrumb .= '</li>';
1138 1177
         } elseif (is_category() || is_single()) {
@@ -1207,12 +1246,14 @@  discard block
 block discarded – undo
1207 1246
     function geodir_allow_wpadmin()
1208 1247
     {
1209 1248
         global $wpdb;
1210
-        if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) // checking action in request to allow ajax request go through
1249
+        if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) {
1250
+        	// checking action in request to allow ajax request go through
1211 1251
         {
1212 1252
             if (current_user_can('manage_options')) {
1213 1253
             } else {
1214 1254
 
1215
-                wp_redirect(home_url());
1255
+                wp_redirect(home_url());
1256
+        }
1216 1257
                 exit;
1217 1258
             }
1218 1259
 
@@ -1244,8 +1285,9 @@  discard block
 block discarded – undo
1244 1285
     $post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : '';
1245 1286
 
1246 1287
     $upload = wp_upload_bits($file_name, 0, '', $post_upload_date);
1247
-    if ($upload['error'])
1248
-        return new WP_Error('upload_dir_error', $upload['error']);
1288
+    if ($upload['error']) {
1289
+            return new WP_Error('upload_dir_error', $upload['error']);
1290
+    }
1249 1291
 
1250 1292
     // fetch the remote url and write it to the placeholder file
1251 1293
     $headers = wp_remote_get($url, array('stream' => true,'filename' => $upload['file']));
@@ -1259,11 +1301,9 @@  discard block
 block discarded – undo
1259 1301
     // make sure the fetch was successful
1260 1302
     elseif ($headers['response']['code'] != '200') {
1261 1303
         $log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
1262
-    }
1263
-    elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
1304
+    } elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
1264 1305
         $log_message =  __('Remote file is incorrect size', 'geodirectory');
1265
-    }
1266
-    elseif (0 == $filesize) {
1306
+    } elseif (0 == $filesize) {
1267 1307
         $log_message = __('Zero size file downloaded', 'geodirectory');
1268 1308
     }
1269 1309
 
@@ -1315,10 +1355,11 @@  discard block
 block discarded – undo
1315 1355
 function geodir_dummy_folder_exists()
1316 1356
 {
1317 1357
     $path = geodir_plugin_path() . '/geodirectory-admin/dummy/';
1318
-    if (!is_dir($path))
1319
-        return false;
1320
-    else
1321
-        return true;
1358
+    if (!is_dir($path)) {
1359
+            return false;
1360
+    } else {
1361
+            return true;
1362
+    }
1322 1363
 
1323 1364
 }
1324 1365
 
@@ -1536,12 +1577,10 @@  discard block
 block discarded – undo
1536 1577
         if ($message_type == 'registration' && get_option('bcc_new_user')) {
1537 1578
             $subject .= ' - ADMIN BCC COPY';
1538 1579
             $admin_bcc = true;
1539
-        }
1540
-        elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
1580
+        } elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
1541 1581
             $subject .= ' - ADMIN BCC COPY';
1542 1582
             $admin_bcc = true;
1543
-        }
1544
-        elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
1583
+        } elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
1545 1584
             $subject .= ' - ADMIN BCC COPY';
1546 1585
             $admin_bcc = true;
1547 1586
         }
@@ -1585,7 +1624,9 @@  discard block
 block discarded – undo
1585 1624
         $res = array();
1586 1625
         foreach ($ids_array as $id) {
1587 1626
             $xlat = icl_object_id($id, $type, false);
1588
-            if (!is_null($xlat)) $res[] = $xlat;
1627
+            if (!is_null($xlat)) {
1628
+            	$res[] = $xlat;
1629
+            }
1589 1630
         }
1590 1631
         return $res;
1591 1632
     } else {
@@ -1926,8 +1967,9 @@  discard block
 block discarded – undo
1926 1967
         $limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
1927 1968
 
1928 1969
         $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1;
1929
-        if ( !$page )
1930
-            $page = 1;
1970
+        if ( !$page ) {
1971
+                    $page = 1;
1972
+        }
1931 1973
 
1932 1974
         $limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : "";
1933 1975
 
@@ -2253,7 +2295,7 @@  discard block
 block discarded – undo
2253 2295
     $home_url = str_replace("www.", "", $home_url);
2254 2296
     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')) ) {
2255 2297
         return true;
2256
-    }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')){
2298
+    } 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')){
2257 2299
         return true;
2258 2300
     } else {
2259 2301
         return false;
@@ -2745,8 +2787,9 @@  discard block
 block discarded – undo
2745 2787
                         $name = $postobj->labels->name;
2746 2788
 
2747 2789
                         $selected = '';
2748
-                        if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing'))
2749
-                            $selected = 'selected="selected"';
2790
+                        if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing')) {
2791
+                                                    $selected = 'selected="selected"';
2792
+                        }
2750 2793
 
2751 2794
                         /**
2752 2795
                          * Filter add listing link.
@@ -3213,8 +3256,9 @@  discard block
 block discarded – undo
3213 3256
             $geodir_is_widget_listing = false;
3214 3257
 
3215 3258
             $GLOBALS['post'] = $current_post;
3216
-            if (!empty($current_post))
3217
-                setup_postdata($current_post);
3259
+            if (!empty($current_post)) {
3260
+                            setup_postdata($current_post);
3261
+            }
3218 3262
             $map_jason = $current_map_jason;
3219 3263
             $map_canvas_arr = $current_map_canvas_arr;
3220 3264
             ?>
@@ -3530,11 +3574,15 @@  discard block
 block discarded – undo
3530 3574
 
3531 3575
     $language_file = geodir_plugin_path() . '/db-language.php';
3532 3576
 
3533
-    if(is_file($language_file) && !is_writable($language_file))
3534
-        return false; // Not possible to create.
3577
+    if(is_file($language_file) && !is_writable($language_file)) {
3578
+            return false;
3579
+    }
3580
+    // Not possible to create.
3535 3581
 
3536
-    if(!is_file($language_file) && !is_writable(dirname($language_file)))
3537
-        return false; // Not possible to create.
3582
+    if(!is_file($language_file) && !is_writable(dirname($language_file))) {
3583
+            return false;
3584
+    }
3585
+    // Not possible to create.
3538 3586
 
3539 3587
     $contents_strings = array();
3540 3588
 
@@ -3577,8 +3625,10 @@  discard block
 block discarded – undo
3577 3625
 
3578 3626
     $contents .= implode(PHP_EOL, $contents_foot);
3579 3627
 
3580
-    if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE))
3581
-        return false; // Failure; could not write file.
3628
+    if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE)) {
3629
+            return false;
3630
+    }
3631
+    // Failure; could not write file.
3582 3632
 
3583 3633
     return true;
3584 3634
 }
@@ -3604,23 +3654,29 @@  discard block
 block discarded – undo
3604 3654
 
3605 3655
     if (!empty($rows)) {
3606 3656
         foreach($rows as $row) {
3607
-            if (!empty($row->admin_title))
3608
-                $translation_texts[] = stripslashes_deep($row->admin_title);
3657
+            if (!empty($row->admin_title)) {
3658
+                            $translation_texts[] = stripslashes_deep($row->admin_title);
3659
+            }
3609 3660
 			
3610
-            if (!empty($row->admin_desc))
3611
-                $translation_texts[] = stripslashes_deep($row->admin_desc);
3661
+            if (!empty($row->admin_desc)) {
3662
+                            $translation_texts[] = stripslashes_deep($row->admin_desc);
3663
+            }
3612 3664
 
3613
-            if (!empty($row->site_title))
3614
-                $translation_texts[] = stripslashes_deep($row->site_title);
3665
+            if (!empty($row->site_title)) {
3666
+                            $translation_texts[] = stripslashes_deep($row->site_title);
3667
+            }
3615 3668
 
3616
-            if (!empty($row->clabels))
3617
-                $translation_texts[] = stripslashes_deep($row->clabels);
3669
+            if (!empty($row->clabels)) {
3670
+                            $translation_texts[] = stripslashes_deep($row->clabels);
3671
+            }
3618 3672
 
3619
-            if (!empty($row->required_msg))
3620
-                $translation_texts[] = stripslashes_deep($row->required_msg);
3673
+            if (!empty($row->required_msg)) {
3674
+                            $translation_texts[] = stripslashes_deep($row->required_msg);
3675
+            }
3621 3676
 			
3622
-			if (!empty($row->default_value))
3623
-                $translation_texts[] = stripslashes_deep($row->default_value);
3677
+			if (!empty($row->default_value)) {
3678
+			                $translation_texts[] = stripslashes_deep($row->default_value);
3679
+			}
3624 3680
 			
3625 3681
 			if (!empty($row->option_values)) {
3626 3682
 				$option_values = geodir_string_values_to_options(stripslashes_deep($row->option_values));
@@ -3642,14 +3698,17 @@  discard block
 block discarded – undo
3642 3698
 
3643 3699
     if (!empty($rows)) {
3644 3700
         foreach($rows as $row) {
3645
-            if (!empty($row->site_title))
3646
-                $translation_texts[] = stripslashes_deep($row->site_title);
3701
+            if (!empty($row->site_title)) {
3702
+                            $translation_texts[] = stripslashes_deep($row->site_title);
3703
+            }
3647 3704
 
3648
-            if (!empty($row->asc_title))
3649
-                $translation_texts[] = stripslashes_deep($row->asc_title);
3705
+            if (!empty($row->asc_title)) {
3706
+                            $translation_texts[] = stripslashes_deep($row->asc_title);
3707
+            }
3650 3708
 
3651
-            if (!empty($row->desc_title))
3652
-                $translation_texts[] = stripslashes_deep($row->desc_title);
3709
+            if (!empty($row->desc_title)) {
3710
+                            $translation_texts[] = stripslashes_deep($row->desc_title);
3711
+            }
3653 3712
         }
3654 3713
     }
3655 3714
 	
@@ -3660,14 +3719,17 @@  discard block
 block discarded – undo
3660 3719
 
3661 3720
 		if (!empty($rows)) {
3662 3721
 			foreach($rows as $row) {
3663
-				if (!empty($row->field_site_name))
3664
-					$translation_texts[] = stripslashes_deep($row->field_site_name);
3722
+				if (!empty($row->field_site_name)) {
3723
+									$translation_texts[] = stripslashes_deep($row->field_site_name);
3724
+				}
3665 3725
 
3666
-				if (!empty($row->front_search_title))
3667
-					$translation_texts[] = stripslashes_deep($row->front_search_title);
3726
+				if (!empty($row->front_search_title)) {
3727
+									$translation_texts[] = stripslashes_deep($row->front_search_title);
3728
+				}
3668 3729
 
3669
-				if (!empty($row->field_desc))
3670
-					$translation_texts[] = stripslashes_deep($row->field_desc);
3730
+				if (!empty($row->field_desc)) {
3731
+									$translation_texts[] = stripslashes_deep($row->field_desc);
3732
+				}
3671 3733
 			}
3672 3734
 		}
3673 3735
 	}
@@ -3985,7 +4047,7 @@  discard block
 block discarded – undo
3985 4047
             if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
3986 4048
                 $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
3987 4049
             }
3988
-        }elseif($gd_page=='add-listing'){
4050
+        } elseif($gd_page=='add-listing'){
3989 4051
             $geodir_post_types = get_option('geodir_post_types');
3990 4052
             $spt = isset($_REQUEST['listing_type']) ? esc_attr($_REQUEST['listing_type']) : '';
3991 4053
             if(!$spt && isset($_REQUEST['pid'])){
@@ -3995,8 +4057,7 @@  discard block
 block discarded – undo
3995 4057
             if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
3996 4058
                 $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
3997 4059
             }
3998
-        }
3999
-        elseif($post->post_type){
4060
+        } elseif($post->post_type){
4000 4061
             $geodir_post_types = get_option('geodir_post_types');
4001 4062
             if(isset($geodir_post_types[$post->post_type]['labels']['singular_name'])){
4002 4063
                 $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'],'geodirectory');
@@ -4015,15 +4076,14 @@  discard block
 block discarded – undo
4015 4076
             if(isset($geodir_post_types[$spt]['labels']['name'])){
4016 4077
                 $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4017 4078
             }
4018
-        }elseif($gd_page=='add-listing'){
4079
+        } elseif($gd_page=='add-listing'){
4019 4080
             $geodir_post_types = get_option('geodir_post_types');
4020 4081
             $spt = sanitize_text_field($_REQUEST['listing_type']);
4021 4082
             if(!$spt){$spt='gd_place';}
4022 4083
             if(isset($geodir_post_types[$spt]['labels']['name'])){
4023 4084
                 $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4024 4085
             }
4025
-        }
4026
-        elseif(isset($post->post_type) && $post->post_type){
4086
+        } elseif(isset($post->post_type) && $post->post_type){
4027 4087
             $geodir_post_types = get_option('geodir_post_types');
4028 4088
             if(isset($geodir_post_types[$post->post_type]['labels']['name'])){
4029 4089
                 $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'],'geodirectory');
@@ -4043,7 +4103,7 @@  discard block
 block discarded – undo
4043 4103
                 $cat = get_term($post->default_category, $post->post_type . 'category');
4044 4104
                 $cat_name = (isset($cat->name)) ? $cat->name : '';
4045 4105
             }
4046
-        }elseif($gd_page=='listing'){
4106
+        } elseif($gd_page=='listing'){
4047 4107
             $queried_object = get_queried_object();
4048 4108
             if(isset($queried_object->name)){
4049 4109
                 $cat_name = $queried_object->name;
@@ -4060,7 +4120,7 @@  discard block
 block discarded – undo
4060 4120
                 $cat = get_term($post->default_category, $post->post_type . 'category');
4061 4121
                 $cat_name = (isset($cat->name)) ? $cat->name : '';
4062 4122
             }
4063
-        }elseif($gd_page=='listing'){
4123
+        } elseif($gd_page=='listing'){
4064 4124
             $queried_object = get_queried_object();
4065 4125
             if(isset($queried_object->name)){
4066 4126
                 $cat_name = $queried_object->name;
@@ -4265,38 +4325,54 @@  discard block
 block discarded – undo
4265 4325
             $seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : '';
4266 4326
 
4267 4327
             if (!empty($labels)) {
4268
-                if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts))
4269
-                    $translation_texts[] = $labels['name'];
4270
-                if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts))
4271
-                    $translation_texts[] = $labels['singular_name'];
4272
-                if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts))
4273
-                    $translation_texts[] = $labels['add_new'];
4274
-                if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts))
4275
-                    $translation_texts[] = $labels['add_new_item'];
4276
-                if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts))
4277
-                    $translation_texts[] = $labels['edit_item'];
4278
-                if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts))
4279
-                    $translation_texts[] = $labels['new_item'];
4280
-                if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts))
4281
-                    $translation_texts[] = $labels['view_item'];
4282
-                if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts))
4283
-                    $translation_texts[] = $labels['search_items'];
4284
-                if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts))
4285
-                    $translation_texts[] = $labels['not_found'];
4286
-                if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts))
4287
-                    $translation_texts[] = $labels['not_found_in_trash'];
4288
-                if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts))
4289
-                    $translation_texts[] = $labels['label_post_profile'];
4290
-                if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts))
4291
-                    $translation_texts[] = $labels['label_post_info'];
4292
-                if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts))
4293
-                    $translation_texts[] = $labels['label_post_images'];
4294
-                if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts))
4295
-                    $translation_texts[] = $labels['label_post_map'];
4296
-                if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts))
4297
-                    $translation_texts[] = $labels['label_reviews'];
4298
-                if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts))
4299
-                    $translation_texts[] = $labels['label_related_listing'];
4328
+                if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts)) {
4329
+                                    $translation_texts[] = $labels['name'];
4330
+                }
4331
+                if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts)) {
4332
+                                    $translation_texts[] = $labels['singular_name'];
4333
+                }
4334
+                if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts)) {
4335
+                                    $translation_texts[] = $labels['add_new'];
4336
+                }
4337
+                if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts)) {
4338
+                                    $translation_texts[] = $labels['add_new_item'];
4339
+                }
4340
+                if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts)) {
4341
+                                    $translation_texts[] = $labels['edit_item'];
4342
+                }
4343
+                if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts)) {
4344
+                                    $translation_texts[] = $labels['new_item'];
4345
+                }
4346
+                if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts)) {
4347
+                                    $translation_texts[] = $labels['view_item'];
4348
+                }
4349
+                if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts)) {
4350
+                                    $translation_texts[] = $labels['search_items'];
4351
+                }
4352
+                if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts)) {
4353
+                                    $translation_texts[] = $labels['not_found'];
4354
+                }
4355
+                if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts)) {
4356
+                                    $translation_texts[] = $labels['not_found_in_trash'];
4357
+                }
4358
+                if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts)) {
4359
+                                    $translation_texts[] = $labels['label_post_profile'];
4360
+                }
4361
+                if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts)) {
4362
+                                    $translation_texts[] = $labels['label_post_info'];
4363
+                }
4364
+                if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts)) {
4365
+                                    $translation_texts[] = $labels['label_post_images'];
4366
+                }
4367
+                if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts)) {
4368
+                                    $translation_texts[] = $labels['label_post_map'];
4369
+                }
4370
+                if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts)) {
4371
+                                    $translation_texts[] = $labels['label_reviews'];
4372
+                }
4373
+                if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts)) {
4374
+                                    $translation_texts[] = $labels['label_related_listing'];
4375
+                }
4300 4376
             }
4301 4377
 
4302 4378
             if ($description != '' && !in_array($description, $translation_texts)) {
@@ -4304,11 +4380,13 @@  discard block
 block discarded – undo
4304 4380
             }
4305 4381
 
4306 4382
             if (!empty($seo)) {
4307
-                if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts))
4308
-                    $translation_texts[] = normalize_whitespace($seo['meta_keyword']);
4383
+                if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts)) {
4384
+                                    $translation_texts[] = normalize_whitespace($seo['meta_keyword']);
4385
+                }
4309 4386
 
4310
-                if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts))
4311
-                    $translation_texts[] = normalize_whitespace($seo['meta_description']);
4387
+                if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts)) {
4388
+                                    $translation_texts[] = normalize_whitespace($seo['meta_description']);
4389
+                }
4312 4390
             }
4313 4391
         }
4314 4392
     }
@@ -4334,16 +4412,20 @@  discard block
 block discarded – undo
4334 4412
         $hide_region_part = get_option('geodir_location_hide_region_part');
4335 4413
 
4336 4414
         if ($hide_region_part && $hide_country_part) {
4337
-            if (isset($location_terms['gd_country']))
4338
-                unset($location_terms['gd_country']);
4339
-            if (isset($location_terms['gd_region']))
4340
-                unset($location_terms['gd_region']);
4415
+            if (isset($location_terms['gd_country'])) {
4416
+                            unset($location_terms['gd_country']);
4417
+            }
4418
+            if (isset($location_terms['gd_region'])) {
4419
+                            unset($location_terms['gd_region']);
4420
+            }
4341 4421
         } else if ($hide_region_part && !$hide_country_part) {
4342
-            if (isset($location_terms['gd_region']))
4343
-                unset($location_terms['gd_region']);
4422
+            if (isset($location_terms['gd_region'])) {
4423
+                            unset($location_terms['gd_region']);
4424
+            }
4344 4425
         } else if (!$hide_region_part && $hide_country_part) {
4345
-            if (isset($location_terms['gd_country']))
4346
-                unset($location_terms['gd_country']);
4426
+            if (isset($location_terms['gd_country'])) {
4427
+                            unset($location_terms['gd_country']);
4428
+            }
4347 4429
         }
4348 4430
     }
4349 4431
 
Please login to merge, or discard this patch.
Spacing   +381 added lines, -381 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);
@@ -1322,7 +1322,7 @@  discard block
 block discarded – undo
1322 1322
         return new WP_Error('upload_dir_error', $upload['error']);
1323 1323
 
1324 1324
     // fetch the remote url and write it to the placeholder file
1325
-    $headers = wp_remote_get($url, array('stream' => true,'filename' => $upload['file']));
1325
+    $headers = wp_remote_get($url, array('stream' => true, 'filename' => $upload['file']));
1326 1326
 
1327 1327
     $log_message = '';
1328 1328
     $filesize = filesize($upload['file']);
@@ -1335,16 +1335,16 @@  discard block
 block discarded – undo
1335 1335
         $log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
1336 1336
     }
1337 1337
     elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
1338
-        $log_message =  __('Remote file is incorrect size', 'geodirectory');
1338
+        $log_message = __('Remote file is incorrect size', 'geodirectory');
1339 1339
     }
1340 1340
     elseif (0 == $filesize) {
1341 1341
         $log_message = __('Zero size file downloaded', 'geodirectory');
1342 1342
     }
1343 1343
 
1344
-    if($log_message){
1344
+    if ($log_message) {
1345 1345
         $del = unlink($upload['file']);
1346
-        if(!$del){geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory'));}
1347
-        return new WP_Error('import_file_error',$log_message );
1346
+        if (!$del) {geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory')); }
1347
+        return new WP_Error('import_file_error', $log_message);
1348 1348
     }
1349 1349
 
1350 1350
 
@@ -1360,12 +1360,12 @@  discard block
 block discarded – undo
1360 1360
  */
1361 1361
 function geodir_max_upload_size()
1362 1362
 {
1363
-    $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
1363
+    $max_filesize = (float) get_option('geodir_upload_max_filesize', 2);
1364 1364
 
1365 1365
     if ($max_filesize > 0 && $max_filesize < 1) {
1366
-        $max_filesize = (int)($max_filesize * 1024) . 'kb';
1366
+        $max_filesize = (int) ($max_filesize * 1024).'kb';
1367 1367
     } else {
1368
-        $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
1368
+        $max_filesize = $max_filesize > 0 ? $max_filesize.'mb' : '2mb';
1369 1369
     }
1370 1370
 
1371 1371
     /**
@@ -1388,7 +1388,7 @@  discard block
 block discarded – undo
1388 1388
  */
1389 1389
 function geodir_dummy_folder_exists()
1390 1390
 {
1391
-    $path = geodir_plugin_path() . '/geodirectory-admin/dummy/';
1391
+    $path = geodir_plugin_path().'/geodirectory-admin/dummy/';
1392 1392
     if (!is_dir($path))
1393 1393
         return false;
1394 1394
     else
@@ -1432,35 +1432,35 @@  discard block
 block discarded – undo
1432 1432
     {
1433 1433
         global $wpdb;
1434 1434
         if ($message_type == 'expiration') {
1435
-            $subject = stripslashes(__(get_option('renew_email_subject'),'geodirectory'));
1436
-            $client_message = stripslashes(__(get_option('renew_email_content'),'geodirectory'));
1435
+            $subject = stripslashes(__(get_option('renew_email_subject'), 'geodirectory'));
1436
+            $client_message = stripslashes(__(get_option('renew_email_content'), 'geodirectory'));
1437 1437
         } elseif ($message_type == 'post_submited') {
1438
-            $subject = __(get_option('post_submited_success_email_subject_admin'),'geodirectory');
1439
-            $client_message = __(get_option('post_submited_success_email_content_admin'),'geodirectory');
1438
+            $subject = __(get_option('post_submited_success_email_subject_admin'), 'geodirectory');
1439
+            $client_message = __(get_option('post_submited_success_email_content_admin'), 'geodirectory');
1440 1440
         } elseif ($message_type == 'renew') {
1441
-            $subject = __(get_option('post_renew_success_email_subject_admin'),'geodirectory');
1442
-            $client_message = __(get_option('post_renew_success_email_content_admin'),'geodirectory');
1441
+            $subject = __(get_option('post_renew_success_email_subject_admin'), 'geodirectory');
1442
+            $client_message = __(get_option('post_renew_success_email_content_admin'), 'geodirectory');
1443 1443
         } elseif ($message_type == 'upgrade') {
1444
-            $subject = __(get_option('post_upgrade_success_email_subject_admin'),'geodirectory');
1445
-            $client_message = __(get_option('post_upgrade_success_email_content_admin'),'geodirectory');
1444
+            $subject = __(get_option('post_upgrade_success_email_subject_admin'), 'geodirectory');
1445
+            $client_message = __(get_option('post_upgrade_success_email_content_admin'), 'geodirectory');
1446 1446
         } elseif ($message_type == 'claim_approved') {
1447
-            $subject = __(get_option('claim_approved_email_subject'),'geodirectory');
1448
-            $client_message = __(get_option('claim_approved_email_content'),'geodirectory');
1447
+            $subject = __(get_option('claim_approved_email_subject'), 'geodirectory');
1448
+            $client_message = __(get_option('claim_approved_email_content'), 'geodirectory');
1449 1449
         } elseif ($message_type == 'claim_rejected') {
1450
-            $subject = __(get_option('claim_rejected_email_subject'),'geodirectory');
1451
-            $client_message = __(get_option('claim_rejected_email_content'),'geodirectory');
1450
+            $subject = __(get_option('claim_rejected_email_subject'), 'geodirectory');
1451
+            $client_message = __(get_option('claim_rejected_email_content'), 'geodirectory');
1452 1452
         } elseif ($message_type == 'claim_requested') {
1453
-            $subject = __(get_option('claim_email_subject_admin'),'geodirectory');
1454
-            $client_message = __(get_option('claim_email_content_admin'),'geodirectory');
1453
+            $subject = __(get_option('claim_email_subject_admin'), 'geodirectory');
1454
+            $client_message = __(get_option('claim_email_content_admin'), 'geodirectory');
1455 1455
         } elseif ($message_type == 'auto_claim') {
1456
-            $subject = __(get_option('auto_claim_email_subject'),'geodirectory');
1457
-            $client_message = __(get_option('auto_claim_email_content'),'geodirectory');
1456
+            $subject = __(get_option('auto_claim_email_subject'), 'geodirectory');
1457
+            $client_message = __(get_option('auto_claim_email_content'), 'geodirectory');
1458 1458
         } elseif ($message_type == 'payment_success') {
1459
-            $subject = __(get_option('post_payment_success_admin_email_subject'),'geodirectory');
1460
-            $client_message = __(get_option('post_payment_success_admin_email_content'),'geodirectory');
1459
+            $subject = __(get_option('post_payment_success_admin_email_subject'), 'geodirectory');
1460
+            $client_message = __(get_option('post_payment_success_admin_email_content'), 'geodirectory');
1461 1461
         } elseif ($message_type == 'payment_fail') {
1462
-            $subject = __(get_option('post_payment_fail_admin_email_subject'),'geodirectory');
1463
-            $client_message = __(get_option('post_payment_fail_admin_email_content'),'geodirectory');
1462
+            $subject = __(get_option('post_payment_fail_admin_email_subject'), 'geodirectory');
1463
+            $client_message = __(get_option('post_payment_fail_admin_email_content'), 'geodirectory');
1464 1464
         }
1465 1465
         $transaction_details = $custom_1;
1466 1466
         $fromEmail = get_option('site_email');
@@ -1471,11 +1471,11 @@  discard block
 block discarded – undo
1471 1471
         $productlink = get_permalink($page_id);
1472 1472
         $post_info = get_post($page_id);
1473 1473
         $post_date = date('dS F,Y', strtotime($post_info->post_date));
1474
-        $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1474
+        $listingLink = '<a href="'.$productlink.'"><b>'.$post_info->post_title.'</b></a>';
1475 1475
         $loginurl = geodir_login_url();
1476
-        $loginurl_link = '<a href="' . $loginurl . '">login</a>';
1476
+        $loginurl_link = '<a href="'.$loginurl.'">login</a>';
1477 1477
         $siteurl = home_url();
1478
-        $siteurl_link = '<a href="' . $siteurl . '">' . $fromEmailName . '</a>';
1478
+        $siteurl_link = '<a href="'.$siteurl.'">'.$fromEmailName.'</a>';
1479 1479
         $user_info = get_userdata($user_id);
1480 1480
         $user_email = $user_info->user_email;
1481 1481
         $display_name = geodir_get_client_name($user_id);
@@ -1489,14 +1489,14 @@  discard block
 block discarded – undo
1489 1489
         } else {
1490 1490
             $post_type = 'listing';
1491 1491
         }
1492
-        $renew_link = '<a href="' . $siteurl . '?ptype=post_' . $post_type . '&renew=1&pid=' . $page_id . '">' . RENEW_LINK . '</a>';
1492
+        $renew_link = '<a href="'.$siteurl.'?ptype=post_'.$post_type.'&renew=1&pid='.$page_id.'">'.RENEW_LINK.'</a>';
1493 1493
         $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#]');
1494 1494
         $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);
1495 1495
         $client_message = str_replace($search_array, $replace_array, $client_message);
1496 1496
         $subject = str_replace($search_array, $replace_array, $subject);
1497
-        $headers = 'MIME-Version: 1.0' . "\r\n";
1498
-        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1499
-        $headers .= 'From: ' . $fromEmailName . ' <' . $fromEmail . '>' . "\r\n";
1497
+        $headers = 'MIME-Version: 1.0'."\r\n";
1498
+        $headers .= 'Content-type: text/html; charset=UTF-8'."\r\n";
1499
+        $headers .= 'From: '.$fromEmailName.' <'.$fromEmail.'>'."\r\n";
1500 1500
 
1501 1501
         $to = $fromEmail;
1502 1502
         $message = $client_message;
@@ -1513,7 +1513,7 @@  discard block
 block discarded – undo
1513 1513
          * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1514 1514
          * @param string $custom_1 Custom data to be sent.
1515 1515
          */
1516
-        $to = apply_filters('geodir_adminEmail_to',$to,$page_id, $user_id, $message_type, $custom_1 );
1516
+        $to = apply_filters('geodir_adminEmail_to', $to, $page_id, $user_id, $message_type, $custom_1);
1517 1517
         /**
1518 1518
          * Filter the admin email subject.
1519 1519
          *
@@ -1525,7 +1525,7 @@  discard block
 block discarded – undo
1525 1525
          * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1526 1526
          * @param string $custom_1 Custom data to be sent.
1527 1527
          */
1528
-        $subject = apply_filters('geodir_adminEmail_subject',$subject,$page_id, $user_id, $message_type, $custom_1);
1528
+        $subject = apply_filters('geodir_adminEmail_subject', $subject, $page_id, $user_id, $message_type, $custom_1);
1529 1529
         /**
1530 1530
          * Filter the admin email message.
1531 1531
          *
@@ -1537,7 +1537,7 @@  discard block
 block discarded – undo
1537 1537
          * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1538 1538
          * @param string $custom_1 Custom data to be sent.
1539 1539
          */
1540
-        $message = apply_filters('geodir_adminEmail_message',$message,$page_id, $user_id, $message_type, $custom_1);
1540
+        $message = apply_filters('geodir_adminEmail_message', $message, $page_id, $user_id, $message_type, $custom_1);
1541 1541
         /**
1542 1542
          * Filter the admin email headers.
1543 1543
          *
@@ -1549,23 +1549,23 @@  discard block
 block discarded – undo
1549 1549
          * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1550 1550
          * @param string $custom_1 Custom data to be sent.
1551 1551
          */
1552
-        $headers = apply_filters('geodir_adminEmail_headers',$headers,$page_id, $user_id, $message_type, $custom_1);
1552
+        $headers = apply_filters('geodir_adminEmail_headers', $headers, $page_id, $user_id, $message_type, $custom_1);
1553 1553
 
1554 1554
 
1555 1555
 
1556 1556
         $sent = wp_mail($to, $subject, $message, $headers);
1557
-        if( ! $sent ) {
1558
-            if ( is_array( $to ) ) {
1559
-                $to = implode( ',', $to );
1557
+        if (!$sent) {
1558
+            if (is_array($to)) {
1559
+                $to = implode(',', $to);
1560 1560
             }
1561 1561
             $log_message = sprintf(
1562
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1562
+                __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
1563 1563
                 $message_type,
1564
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1564
+                date_i18n('F j Y H:i:s', current_time('timestamp')),
1565 1565
                 $to,
1566 1566
                 $subject
1567 1567
             );
1568
-            geodir_error_log( $log_message );
1568
+            geodir_error_log($log_message);
1569 1569
         }
1570 1570
     }
1571 1571
 }
@@ -1591,18 +1591,18 @@  discard block
 block discarded – undo
1591 1591
     {
1592 1592
         $login_details = '';
1593 1593
         if ($message_type == 'send_friend') {
1594
-            $subject = stripslashes(__(get_option('email_friend_subject'),'geodirectory'));
1595
-            $message = stripslashes(__(get_option('email_friend_content'),'geodirectory'));
1594
+            $subject = stripslashes(__(get_option('email_friend_subject'), 'geodirectory'));
1595
+            $message = stripslashes(__(get_option('email_friend_content'), 'geodirectory'));
1596 1596
         } elseif ($message_type == 'send_enquiry') {
1597
-            $subject = __(get_option('email_enquiry_subject'),'geodirectory');
1598
-            $message = __(get_option('email_enquiry_content'),'geodirectory');
1597
+            $subject = __(get_option('email_enquiry_subject'), 'geodirectory');
1598
+            $message = __(get_option('email_enquiry_content'), 'geodirectory');
1599 1599
         } elseif ($message_type == 'forgot_password') {
1600
-            $subject = __(get_option('forgot_password_subject'),'geodirectory');
1601
-            $message = __(get_option('forgot_password_content'),'geodirectory');
1600
+            $subject = __(get_option('forgot_password_subject'), 'geodirectory');
1601
+            $message = __(get_option('forgot_password_content'), 'geodirectory');
1602 1602
             $login_details = $to_message;
1603 1603
         } elseif ($message_type == 'registration') {
1604
-            $subject = __(get_option('registration_success_email_subject'),'geodirectory');
1605
-            $message = __(get_option('registration_success_email_content'),'geodirectory');
1604
+            $subject = __(get_option('registration_success_email_subject'), 'geodirectory');
1605
+            $message = __(get_option('registration_success_email_content'), 'geodirectory');
1606 1606
             $login_details = $to_message;
1607 1607
         }
1608 1608
         $to_message = nl2br($to_message);
@@ -1610,11 +1610,11 @@  discard block
 block discarded – undo
1610 1610
         $sitefromEmailName = get_site_emailName();
1611 1611
         $productlink = get_permalink($post_id);
1612 1612
         $post_info = get_post($post_id);
1613
-        $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1613
+        $listingLink = '<a href="'.$productlink.'"><b>'.$post_info->post_title.'</b></a>';
1614 1614
         $siteurl = home_url();
1615
-        $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
1615
+        $siteurl_link = '<a href="'.$siteurl.'">'.$siteurl.'</a>';
1616 1616
         $loginurl = geodir_login_url();
1617
-        $loginurl_link = '<a href="' . $loginurl . '">login</a>';
1617
+        $loginurl_link = '<a href="'.$loginurl.'">login</a>';
1618 1618
         if ($fromEmail == '') {
1619 1619
             $fromEmail = get_option('site_email');
1620 1620
         }
@@ -1628,26 +1628,26 @@  discard block
 block discarded – undo
1628 1628
         $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]');
1629 1629
         $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName);
1630 1630
         $subject = str_replace($search_array, $replace_array, $subject);
1631
-        $headers = 'MIME-Version: 1.0' . "\r\n";
1632
-        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1633
-        $headers .= "Reply-To: " . $fromEmail . "\r\n";
1634
-        $headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
1631
+        $headers = 'MIME-Version: 1.0'."\r\n";
1632
+        $headers .= 'Content-type: text/html; charset=UTF-8'."\r\n";
1633
+        $headers .= "Reply-To: ".$fromEmail."\r\n";
1634
+        $headers .= 'From: '.$sitefromEmailName.' <'.$sitefromEmail.'>'."\r\n";
1635 1635
 
1636 1636
         $to = $toEmail;
1637 1637
 
1638 1638
         $sent = wp_mail($to, $subject, $message, $headers);
1639
-        if( ! $sent ) {
1640
-            if ( is_array( $to ) ) {
1641
-                $to = implode( ',', $to );
1639
+        if (!$sent) {
1640
+            if (is_array($to)) {
1641
+                $to = implode(',', $to);
1642 1642
             }
1643 1643
             $log_message = sprintf(
1644
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1644
+                __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
1645 1645
                 $message_type,
1646
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1646
+                date_i18n('F j Y H:i:s', current_time('timestamp')),
1647 1647
                 $to,
1648 1648
                 $subject
1649 1649
             );
1650
-            geodir_error_log( $log_message );
1650
+            geodir_error_log($log_message);
1651 1651
         }
1652 1652
 
1653 1653
         ///////// ADMIN BCC EMIALS
@@ -1655,7 +1655,7 @@  discard block
 block discarded – undo
1655 1655
         if ($message_type == 'registration') {
1656 1656
             $message_raw = explode(__("Password:", 'geodirectory'), $message);
1657 1657
             $message_raw2 = explode("</p>", $message_raw[1], 2);
1658
-            $message = $message_raw[0] . __('Password:', 'geodirectory') . ' **********</p>' . $message_raw2[1];
1658
+            $message = $message_raw[0].__('Password:', 'geodirectory').' **********</p>'.$message_raw2[1];
1659 1659
         }
1660 1660
         $adminEmail = get_bloginfo('admin_email');
1661 1661
         $to = $adminEmail;
@@ -1673,20 +1673,20 @@  discard block
 block discarded – undo
1673 1673
             $admin_bcc = true;
1674 1674
         }
1675 1675
 
1676
-        if($admin_bcc === true){
1676
+        if ($admin_bcc === true) {
1677 1677
             $sent = wp_mail($to, $subject, $message, $headers);
1678
-            if( ! $sent ) {
1679
-                if ( is_array( $to ) ) {
1680
-                    $to = implode( ',', $to );
1678
+            if (!$sent) {
1679
+                if (is_array($to)) {
1680
+                    $to = implode(',', $to);
1681 1681
                 }
1682 1682
                 $log_message = sprintf(
1683
-                    __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1683
+                    __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
1684 1684
                     $message_type,
1685
-                    date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1685
+                    date_i18n('F j Y H:i:s', current_time('timestamp')),
1686 1686
                     $to,
1687 1687
                     $subject
1688 1688
                 );
1689
-                geodir_error_log( $log_message );
1689
+                geodir_error_log($log_message);
1690 1690
             }
1691 1691
         }
1692 1692
 
@@ -1734,7 +1734,7 @@  discard block
 block discarded – undo
1734 1734
 function geodir_custom_posts_body_class($classes) {
1735 1735
     global $wpdb, $wp;
1736 1736
     $post_types = geodir_get_posttypes('object');
1737
-    if (!empty($post_types) && count((array)$post_types) > 1) {
1737
+    if (!empty($post_types) && count((array) $post_types) > 1) {
1738 1738
         $classes[] = 'geodir_custom_posts';
1739 1739
     }
1740 1740
 
@@ -1794,7 +1794,7 @@  discard block
 block discarded – undo
1794 1794
     $geodir_option = get_option($geodir_option_name);
1795 1795
 
1796 1796
     if (!empty($geodir_option)) {
1797
-        add_option($geodir_option_name . '_' . $version_date, $geodir_option);
1797
+        add_option($geodir_option_name.'_'.$version_date, $geodir_option);
1798 1798
     }
1799 1799
 }
1800 1800
 
@@ -1900,36 +1900,36 @@  discard block
 block discarded – undo
1900 1900
 
1901 1901
     $query_args = $gd_query_args_widgets;
1902 1902
     if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
1903
-        return $wpdb->posts . ".post_date DESC, ";
1903
+        return $wpdb->posts.".post_date DESC, ";
1904 1904
     }
1905 1905
 
1906 1906
     $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1907
-    $table = $plugin_prefix . $post_type . '_detail';
1907
+    $table = $plugin_prefix.$post_type.'_detail';
1908 1908
 
1909 1909
     $sort_by = !empty($query_args['order_by']) ? $query_args['order_by'] : '';
1910 1910
 
1911 1911
     switch ($sort_by) {
1912 1912
         case 'latest':
1913 1913
         case 'newest':
1914
-            $orderby = $wpdb->posts . ".post_date DESC, ";
1914
+            $orderby = $wpdb->posts.".post_date DESC, ";
1915 1915
             break;
1916 1916
         case 'featured':
1917
-            $orderby = $table . ".is_featured ASC, ";
1917
+            $orderby = $table.".is_featured ASC, ";
1918 1918
             break;
1919 1919
         case 'az':
1920
-            $orderby = $wpdb->posts . ".post_title ASC, ";
1920
+            $orderby = $wpdb->posts.".post_title ASC, ";
1921 1921
             break;
1922 1922
         case 'high_review':
1923
-            $orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, ";
1923
+            $orderby = $table.".rating_count DESC, ".$table.".overall_rating DESC, ";
1924 1924
             break;
1925 1925
         case 'high_rating':
1926
-            $orderby = "( " . $table . ".overall_rating  ) DESC, ";
1926
+            $orderby = "( ".$table.".overall_rating  ) DESC, ";
1927 1927
             break;
1928 1928
         case 'random':
1929 1929
             $orderby = "RAND(), ";
1930 1930
             break;
1931 1931
         default:
1932
-            $orderby = $wpdb->posts . ".post_title ASC, ";
1932
+            $orderby = $wpdb->posts.".post_title ASC, ";
1933 1933
             break;
1934 1934
     }
1935 1935
 
@@ -1956,9 +1956,9 @@  discard block
 block discarded – undo
1956 1956
     $gd_query_args_widgets = $query_args;
1957 1957
 
1958 1958
     $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1959
-    $table = $plugin_prefix . $post_type . '_detail';
1959
+    $table = $plugin_prefix.$post_type.'_detail';
1960 1960
 
1961
-    $fields = $wpdb->posts . ".*, " . $table . ".*";
1961
+    $fields = $wpdb->posts.".*, ".$table.".*";
1962 1962
     /**
1963 1963
      * Filter widget listing fields string part that is being used for query.
1964 1964
      *
@@ -1969,7 +1969,7 @@  discard block
 block discarded – undo
1969 1969
      */
1970 1970
     $fields = apply_filters('geodir_filter_widget_listings_fields', $fields, $table, $post_type);
1971 1971
 
1972
-    $join = "INNER JOIN " . $table . " ON (" . $table . ".post_id = " . $wpdb->posts . ".ID)";
1972
+    $join = "INNER JOIN ".$table." ON (".$table.".post_id = ".$wpdb->posts.".ID)";
1973 1973
 
1974 1974
     ########### WPML ###########
1975 1975
 
@@ -1977,7 +1977,7 @@  discard block
 block discarded – undo
1977 1977
         global $sitepress;
1978 1978
         $lang_code = ICL_LANGUAGE_CODE;
1979 1979
         if ($lang_code) {
1980
-            $join .= " JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID";
1980
+            $join .= " JOIN ".$table_prefix."icl_translations icl_t ON icl_t.element_id = ".$table_prefix."posts.ID";
1981 1981
         }
1982 1982
     }
1983 1983
 
@@ -1992,9 +1992,9 @@  discard block
 block discarded – undo
1992 1992
      */
1993 1993
     $join = apply_filters('geodir_filter_widget_listings_join', $join, $post_type);
1994 1994
 
1995
-    $post_status = is_super_admin() ? " OR " . $wpdb->posts . ".post_status = 'private'" : '';
1995
+    $post_status = is_super_admin() ? " OR ".$wpdb->posts.".post_status = 'private'" : '';
1996 1996
 
1997
-    $where = " AND ( " . $wpdb->posts . ".post_status = 'publish' " . $post_status . " ) AND " . $wpdb->posts . ".post_type = '" . $post_type . "'";
1997
+    $where = " AND ( ".$wpdb->posts.".post_status = 'publish' ".$post_status." ) AND ".$wpdb->posts.".post_type = '".$post_type."'";
1998 1998
 
1999 1999
     ########### WPML ###########
2000 2000
     if (function_exists('icl_object_id')) {
@@ -2011,7 +2011,7 @@  discard block
 block discarded – undo
2011 2011
      * @param string $post_type Post type.
2012 2012
      */
2013 2013
     $where = apply_filters('geodir_filter_widget_listings_where', $where, $post_type);
2014
-    $where = $where != '' ? " WHERE 1=1 " . $where : '';
2014
+    $where = $where != '' ? " WHERE 1=1 ".$where : '';
2015 2015
 
2016 2016
     $groupby = " GROUP BY $wpdb->posts.ID ";
2017 2017
     /**
@@ -2024,10 +2024,10 @@  discard block
 block discarded – undo
2024 2024
     $groupby = apply_filters('geodir_filter_widget_listings_groupby', $groupby, $post_type);
2025 2025
 
2026 2026
     if ($count_only) {
2027
-        $sql = "SELECT COUNT(" . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . "
2028
-			" . $join . "
2027
+        $sql = "SELECT COUNT(".$wpdb->posts.".ID) AS total FROM ".$wpdb->posts."
2028
+			" . $join."
2029 2029
 			" . $where;
2030
-        $rows = (int)$wpdb->get_var($sql);
2030
+        $rows = (int) $wpdb->get_var($sql);
2031 2031
     } else {
2032 2032
         $orderby = geodir_widget_listings_get_order($query_args);
2033 2033
         /**
@@ -2039,8 +2039,8 @@  discard block
 block discarded – undo
2039 2039
          * @param string $post_type Post type.
2040 2040
          */
2041 2041
         $orderby = apply_filters('geodir_filter_widget_listings_orderby', $orderby, $table, $post_type);
2042
-        $orderby .= $wpdb->posts . ".post_title ASC";
2043
-        $orderby = $orderby != '' ? " ORDER BY " . $orderby : '';
2042
+        $orderby .= $wpdb->posts.".post_title ASC";
2043
+        $orderby = $orderby != '' ? " ORDER BY ".$orderby : '';
2044 2044
 
2045 2045
         $limit = !empty($query_args['posts_per_page']) ? $query_args['posts_per_page'] : 5;
2046 2046
         /**
@@ -2053,16 +2053,16 @@  discard block
 block discarded – undo
2053 2053
         $limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
2054 2054
 
2055 2055
         $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1;
2056
-        if ( !$page )
2056
+        if (!$page)
2057 2057
             $page = 1;
2058 2058
 
2059
-        $limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : "";
2059
+        $limit = (int) $limit > 0 ? " LIMIT ".absint(($page - 1) * (int) $limit).", ".(int) $limit : "";
2060 2060
 
2061
-        $sql = "SELECT SQL_CALC_FOUND_ROWS " . $fields . " FROM " . $wpdb->posts . "
2062
-			" . $join . "
2063
-			" . $where . "
2064
-			" . $groupby . "
2065
-			" . $orderby . "
2061
+        $sql = "SELECT SQL_CALC_FOUND_ROWS ".$fields." FROM ".$wpdb->posts."
2062
+			" . $join."
2063
+			" . $where."
2064
+			" . $groupby."
2065
+			" . $orderby."
2066 2066
 			" . $limit;
2067 2067
         $rows = $wpdb->get_results($sql);
2068 2068
     }
@@ -2115,10 +2115,10 @@  discard block
 block discarded – undo
2115 2115
     }
2116 2116
 
2117 2117
     $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2118
-    $table = $plugin_prefix . $post_type . '_detail';
2118
+    $table = $plugin_prefix.$post_type.'_detail';
2119 2119
 
2120 2120
     if (!empty($query_args['with_pics_only'])) {
2121
-        $join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )";
2121
+        $join .= " LEFT JOIN ".GEODIR_ATTACHMENT_TABLE." ON ( ".GEODIR_ATTACHMENT_TABLE.".post_id=".$table.".post_id AND ".GEODIR_ATTACHMENT_TABLE.".mime_type LIKE '%image%' )";
2122 2122
     }
2123 2123
 
2124 2124
     if (!empty($query_args['tax_query'])) {
@@ -2150,7 +2150,7 @@  discard block
 block discarded – undo
2150 2150
         return $where;
2151 2151
     }
2152 2152
     $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2153
-    $table = $plugin_prefix . $post_type . '_detail';
2153
+    $table = $plugin_prefix.$post_type.'_detail';
2154 2154
 
2155 2155
     if (!empty($query_args)) {
2156 2156
         if (!empty($query_args['gd_location']) && function_exists('geodir_default_location_where')) {
@@ -2158,27 +2158,27 @@  discard block
 block discarded – undo
2158 2158
         }
2159 2159
 
2160 2160
         if (!empty($query_args['post_author'])) {
2161
-            $where .= " AND " . $wpdb->posts . ".post_author = " . (int)$query_args['post_author'];
2161
+            $where .= " AND ".$wpdb->posts.".post_author = ".(int) $query_args['post_author'];
2162 2162
         }
2163 2163
         
2164 2164
         if (!empty($query_args['show_featured_only'])) {
2165
-            $where .= " AND " . $table . ".is_featured = '1'";
2165
+            $where .= " AND ".$table.".is_featured = '1'";
2166 2166
         }
2167 2167
 
2168 2168
         if (!empty($query_args['show_special_only'])) {
2169
-            $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )";
2169
+            $where .= " AND ( ".$table.".geodir_special_offers != '' AND ".$table.".geodir_special_offers IS NOT NULL )";
2170 2170
         }
2171 2171
 
2172 2172
         if (!empty($query_args['with_pics_only'])) {
2173
-            $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL ";
2173
+            $where .= " AND ".GEODIR_ATTACHMENT_TABLE.".ID IS NOT NULL ";
2174 2174
         }
2175 2175
 
2176 2176
         if (!empty($query_args['featured_image_only'])) {
2177
-            $where .= " AND " . $table . ".featured_image IS NOT NULL AND " . $table . ".featured_image!='' ";
2177
+            $where .= " AND ".$table.".featured_image IS NOT NULL AND ".$table.".featured_image!='' ";
2178 2178
         }
2179 2179
 
2180 2180
         if (!empty($query_args['with_videos_only'])) {
2181
-            $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )";
2181
+            $where .= " AND ( ".$table.".geodir_video != '' AND ".$table.".geodir_video IS NOT NULL )";
2182 2182
         }
2183 2183
 
2184 2184
         if (!empty($query_args['tax_query'])) {
@@ -2235,7 +2235,7 @@  discard block
 block discarded – undo
2235 2235
     }
2236 2236
 
2237 2237
     if (!empty($query_args) && !empty($query_args['posts_per_page'])) {
2238
-        $limit = (int)$query_args['posts_per_page'];
2238
+        $limit = (int) $query_args['posts_per_page'];
2239 2239
     }
2240 2240
 
2241 2241
     return $limit;
@@ -2378,9 +2378,9 @@  discard block
 block discarded – undo
2378 2378
         add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
2379 2379
     }
2380 2380
     $home_url = str_replace("www.", "", $home_url);
2381
-    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')) ) {
2381
+    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'))) {
2382 2382
         return true;
2383
-    }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')){
2383
+    }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')) {
2384 2384
         return true;
2385 2385
     } else {
2386 2386
         return false;
@@ -2463,12 +2463,12 @@  discard block
 block discarded – undo
2463 2463
 
2464 2464
     $gd_post_type = geodir_get_current_posttype();
2465 2465
 
2466
-    $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15;
2466
+    $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int) $instance['category_limit'] : 15;
2467 2467
     $default_post_type = !empty($gd_post_type) ? $gd_post_type : (isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ? $instance['default_post_type'] : '');
2468 2468
 
2469 2469
     $taxonomy = array();
2470 2470
     if (!empty($gd_post_type)) {
2471
-        $taxonomy[] = $gd_post_type . "category";
2471
+        $taxonomy[] = $gd_post_type."category";
2472 2472
     } else {
2473 2473
         $default_post_type = geodir_get_posttypes()[0];
2474 2474
         $taxonomy = geodir_get_taxonomies($gd_post_type);
@@ -2489,7 +2489,7 @@  discard block
 block discarded – undo
2489 2489
             $b_terms[$b_key] = geodir_sort_terms($b_val, 'count');
2490 2490
         }
2491 2491
 
2492
-        $default_taxonomy = $default_post_type != '' && isset($b_terms[$default_post_type . 'category']) ? $default_post_type . 'category' : '';
2492
+        $default_taxonomy = $default_post_type != '' && isset($b_terms[$default_post_type.'category']) ? $default_post_type.'category' : '';
2493 2493
 
2494 2494
         $tax_change_output = '';
2495 2495
         if (count($b_terms) > 1) {
@@ -2497,20 +2497,20 @@  discard block
 block discarded – undo
2497 2497
             foreach ($b_terms as $key => $val) {
2498 2498
                 $ptype = get_post_type_object(str_replace("category", "", $key));
2499 2499
                 $cpt_name = __($ptype->labels->singular_name, 'geodirectory');
2500
-                $tax_change_output .= "<option value='$key' ". selected($key, $default_taxonomy, false) .">" . sprintf(__('%s Categories', 'geodirectory'),$cpt_name) . "</option>";
2500
+                $tax_change_output .= "<option value='$key' ".selected($key, $default_taxonomy, false).">".sprintf(__('%s Categories', 'geodirectory'), $cpt_name)."</option>";
2501 2501
             }
2502 2502
             $tax_change_output .= "</select>";
2503 2503
         }
2504 2504
 
2505 2505
         if (!empty($b_terms)) {
2506
-            $terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms);// get the first array
2507
-            global $cat_count;//make global so we can change via function
2506
+            $terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms); // get the first array
2507
+            global $cat_count; //make global so we can change via function
2508 2508
             $cat_count = 0;
2509 2509
             ?>
2510 2510
             <div class="geodir-category-list-in clearfix">
2511 2511
                 <div class="geodir-cat-list clearfix">
2512 2512
                     <?php
2513
-                    echo $before_title . __($title) . $after_title;
2513
+                    echo $before_title.__($title).$after_title;
2514 2514
 
2515 2515
                     echo $tax_change_output;
2516 2516
 
@@ -2527,8 +2527,8 @@  discard block
 block discarded – undo
2527 2527
                     $hide = 'style="display:none;"';
2528 2528
                 }
2529 2529
                 echo "<div class='geodir-cat-list-more' $hide >";
2530
-                echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">' . __('More Categories', 'geodirectory') . '</a>';
2531
-                echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">' . __('Less Categories', 'geodirectory') . '</a>';
2530
+                echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">'.__('More Categories', 'geodirectory').'</a>';
2531
+                echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">'.__('Less Categories', 'geodirectory').'</a>';
2532 2532
                 echo "</div>";
2533 2533
                 /* add scripts */
2534 2534
                 add_action('wp_footer', 'geodir_popular_category_add_scripts', 100);
@@ -2568,7 +2568,7 @@  discard block
 block discarded – undo
2568 2568
         $class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show';
2569 2569
         $total_post = $cat->count;
2570 2570
 
2571
-        $term_link = get_term_link( $cat, $cat->taxonomy );
2571
+        $term_link = get_term_link($cat, $cat->taxonomy);
2572 2572
         /**
2573 2573
          * Filer the category term link.
2574 2574
          *
@@ -2577,10 +2577,10 @@  discard block
 block discarded – undo
2577 2577
          * @param int    $cat->term_id The term id.
2578 2578
          * @param string $post_type Wordpress post type.
2579 2579
          */
2580
-        $term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type );
2580
+        $term_link = apply_filters('geodir_category_term_link', $term_link, $cat->term_id, $post_type);
2581 2581
 
2582
-        echo '<li class="' . $class_row . '"><a href="' . $term_link . '">';
2583
-        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> ';
2582
+        echo '<li class="'.$class_row.'"><a href="'.$term_link.'">';
2583
+        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> ';
2584 2584
         echo '</a></li>';
2585 2585
     }
2586 2586
 }
@@ -2711,29 +2711,29 @@  discard block
 block discarded – undo
2711 2711
                 itemWidth: 75,
2712 2712
                 itemMargin: 5,
2713 2713
                 asNavFor: '#geodir_widget_slider',
2714
-                rtl: <?php echo ( is_rtl() ? 'true' : 'false' ); /* fix rtl issue */ ?>
2714
+                rtl: <?php echo (is_rtl() ? 'true' : 'false'); /* fix rtl issue */ ?>
2715 2715
             });
2716 2716
 
2717 2717
             jQuery('#geodir_widget_slider').flexslider({
2718
-                animation: "<?php echo $animation;?>",
2718
+                animation: "<?php echo $animation; ?>",
2719 2719
                 selector: ".geodir-slides > li",
2720 2720
                 namespace: "geodir-",
2721 2721
                 controlNav: true,
2722
-                animationLoop: <?php echo $animationLoop;?>,
2723
-                slideshow: <?php echo $slideshow;?>,
2724
-                slideshowSpeed: <?php echo $slideshowSpeed;?>,
2725
-                animationSpeed: <?php echo $animationSpeed;?>,
2726
-                directionNav: <?php echo $directionNav;?>,
2727
-                maxItems: <?php echo $max_show;?>,
2722
+                animationLoop: <?php echo $animationLoop; ?>,
2723
+                slideshow: <?php echo $slideshow; ?>,
2724
+                slideshowSpeed: <?php echo $slideshowSpeed; ?>,
2725
+                animationSpeed: <?php echo $animationSpeed; ?>,
2726
+                directionNav: <?php echo $directionNav; ?>,
2727
+                maxItems: <?php echo $max_show; ?>,
2728 2728
                 move: 1,
2729
-                <?php if($slide_width){ echo "itemWidth: ".$slide_width.",";}?>
2729
+                <?php if ($slide_width) { echo "itemWidth: ".$slide_width.","; }?>
2730 2730
                 sync: "#geodir_widget_carousel",
2731 2731
                 start: function (slider) {
2732 2732
                     jQuery('.geodir-listing-flex-loader').hide();
2733 2733
                     jQuery('#geodir_widget_slider').css({'visibility': 'visible'});
2734 2734
                     jQuery('#geodir_widget_carousel').css({'visibility': 'visible'});
2735 2735
                 },
2736
-                rtl: <?php echo ( is_rtl() ? 'true' : 'false' ); /* fix rtl issue */ ?>
2736
+                rtl: <?php echo (is_rtl() ? 'true' : 'false'); /* fix rtl issue */ ?>
2737 2737
             });
2738 2738
         });
2739 2739
     </script>
@@ -2769,12 +2769,12 @@  discard block
 block discarded – undo
2769 2769
     $widget_listings = geodir_get_widget_listings($query_args);
2770 2770
     if (!empty($widget_listings) || (isset($with_no_results) && $with_no_results)) {
2771 2771
         if ($title) {
2772
-            echo $before_title . $title . $after_title;
2772
+            echo $before_title.$title.$after_title;
2773 2773
         }
2774 2774
 
2775 2775
         global $post;
2776 2776
 
2777
-        $current_post = $post;// keep current post info
2777
+        $current_post = $post; // keep current post info
2778 2778
 
2779 2779
         $widget_main_slides = '';
2780 2780
         $nav_slides = '';
@@ -2792,11 +2792,11 @@  discard block
 block discarded – undo
2792 2792
                     $widget_spacer_height = ((200 - $widget_image->height) / 2);
2793 2793
                 }
2794 2794
 
2795
-                $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" />';
2795
+                $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" />';
2796 2796
 
2797 2797
                 $title = '';
2798 2798
                 if ($show_title) {
2799
-                    $title_html = '<div class="geodir-slider-title"><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a></div>';
2799
+                    $title_html = '<div class="geodir-slider-title"><a href="'.get_permalink($post->ID).'">'.get_the_title($post->ID).'</a></div>';
2800 2800
                     $post_id = $post->ID;
2801 2801
                     $post_permalink = get_permalink($post->ID);
2802 2802
                     $post_title = get_the_title($post->ID);
@@ -2809,11 +2809,11 @@  discard block
 block discarded – undo
2809 2809
                      * @param string $post_permalink The post permalink url.
2810 2810
                      * @param string $post_title The post title text.
2811 2811
                      */
2812
-                    $title = apply_filters('geodir_listing_slider_title',$title_html,$post_id,$post_permalink,$post_title);
2812
+                    $title = apply_filters('geodir_listing_slider_title', $title_html, $post_id, $post_permalink, $post_title);
2813 2813
                 }
2814 2814
 
2815
-                $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>';
2816
-                $nav_slides .= '<li><img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:48px;margin:0 auto;" /></li>';
2815
+                $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>';
2816
+                $nav_slides .= '<li><img src="'.$widget_image->src.'" alt="'.$widget_image->title.'" title="'.$widget_image->title.'" style="max-height:48px;margin:0 auto;" /></li>';
2817 2817
                 $widget_slides++;
2818 2818
             }
2819 2819
         }
@@ -2857,7 +2857,7 @@  discard block
 block discarded – undo
2857 2857
     $title = empty($instance['title']) ? __('My Dashboard', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2858 2858
 
2859 2859
     echo $before_widget;
2860
-    echo $before_title . $title . $after_title;
2860
+    echo $before_title.$title.$after_title;
2861 2861
 
2862 2862
     if (is_user_logged_in()) {
2863 2863
         global $current_user;
@@ -2899,7 +2899,7 @@  discard block
 block discarded – undo
2899 2899
                          */
2900 2900
                         $add_link = apply_filters('geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID);
2901 2901
 
2902
-                        $addlisting_links .= '<option ' . $selected . ' value="' . $add_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2902
+                        $addlisting_links .= '<option '.$selected.' value="'.$add_link.'">'.__(ucfirst($name), 'geodirectory').'</option>';
2903 2903
 
2904 2904
                     }
2905 2905
                 }
@@ -2945,7 +2945,7 @@  discard block
 block discarded – undo
2945 2945
                      */
2946 2946
                     $post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID);
2947 2947
 
2948
-                    $favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2948
+                    $favourite_links .= '<option '.$selected.' value="'.$post_type_link.'">'.__(ucfirst($name), 'geodirectory').'</option>';
2949 2949
                 }
2950 2950
             }
2951 2951
 
@@ -2990,7 +2990,7 @@  discard block
 block discarded – undo
2990 2990
                      */
2991 2991
                     $listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID);
2992 2992
 
2993
-                    $listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2993
+                    $listing_links .= '<option '.$selected.' value="'.$listing_link.'">'.__(ucfirst($name), 'geodirectory').'</option>';
2994 2994
                 }
2995 2995
             }
2996 2996
 
@@ -3173,7 +3173,7 @@  discard block
 block discarded – undo
3173 3173
     }
3174 3174
 
3175 3175
     if (empty($title) || $title == 'All') {
3176
-        $title .= ' ' . __(get_post_type_plural_label($post_type), 'geodirectory');
3176
+        $title .= ' '.__(get_post_type_plural_label($post_type), 'geodirectory');
3177 3177
     }
3178 3178
 
3179 3179
     $location_url = array();
@@ -3227,7 +3227,7 @@  discard block
 block discarded – undo
3227 3227
             $geodir_add_location_url = '1';
3228 3228
         }
3229 3229
 
3230
-        $viewall_url = get_term_link((int)$category[0], $post_type . 'category');
3230
+        $viewall_url = get_term_link((int) $category[0], $post_type.'category');
3231 3231
 
3232 3232
         $geodir_add_location_url = NULL;
3233 3233
     }
@@ -3235,7 +3235,7 @@  discard block
 block discarded – undo
3235 3235
         $gd_session->set('gd_multi_location', 1);
3236 3236
     }
3237 3237
 
3238
-    if(is_wp_error( $viewall_url  )){$viewall_url = '';}
3238
+    if (is_wp_error($viewall_url)) {$viewall_url = ''; }
3239 3239
 
3240 3240
     $query_args = array(
3241 3241
         'posts_per_page' => $post_number,
@@ -3301,7 +3301,7 @@  discard block
 block discarded – undo
3301 3301
              */
3302 3302
             do_action('geodir_before_view_all_link_in_widget'); ?>
3303 3303
             <div class="geodir_list_heading clearfix">
3304
-                <?php echo $before_title . $title . $after_title; ?>
3304
+                <?php echo $before_title.$title.$after_title; ?>
3305 3305
                 <a href="<?php echo $viewall_url; ?>"
3306 3306
                    class="geodir-viewall"><?php _e('View all', 'geodirectory'); ?></a>
3307 3307
             </div>
@@ -3387,9 +3387,9 @@  discard block
 block discarded – undo
3387 3387
 {
3388 3388
     global $wpdb, $plugin_prefix;
3389 3389
 
3390
-    $detail_table = $plugin_prefix . $post_type . '_detail';
3390
+    $detail_table = $plugin_prefix.$post_type.'_detail';
3391 3391
 
3392
-    $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 . ")";
3392
+    $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.")";
3393 3393
 
3394 3394
     /**
3395 3395
      * Filter count review sql query.
@@ -3428,7 +3428,7 @@  discard block
 block discarded – undo
3428 3428
      * @param bool $force_update Force update option value?. Default.false.
3429 3429
      * @param int $post_ID The post id to update if any.
3430 3430
      */
3431
-    $option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update,$post_ID);
3431
+    $option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update, $post_ID);
3432 3432
     if (!empty($option_data)) {
3433 3433
         return $option_data;
3434 3434
     }
@@ -3436,12 +3436,12 @@  discard block
 block discarded – undo
3436 3436
     $option_data = get_option('geodir_global_review_count');
3437 3437
 
3438 3438
     if (!$option_data || $force_update) {
3439
-        if ((int)$post_ID > 0) { // Update reviews count for specific post categories only.
3439
+        if ((int) $post_ID > 0) { // Update reviews count for specific post categories only.
3440 3440
             global $gd_session;
3441 3441
                         
3442
-            $term_array = (array)$option_data;
3442
+            $term_array = (array) $option_data;
3443 3443
             $post_type = get_post_type($post_ID);
3444
-            $taxonomy = $post_type . 'category';
3444
+            $taxonomy = $post_type.'category';
3445 3445
             $terms = wp_get_object_terms($post_ID, $taxonomy, array('fields' => 'ids'));
3446 3446
 
3447 3447
             if (!empty($terms) && !is_wp_error($terms)) {
@@ -3456,9 +3456,9 @@  discard block
 block discarded – undo
3456 3456
             
3457 3457
             $terms = array();
3458 3458
             if (isset($_POST['post_category'][$taxonomy])) {
3459
-                $terms = (array)$_POST['post_category'][$taxonomy];
3459
+                $terms = (array) $_POST['post_category'][$taxonomy];
3460 3460
             } else if (!empty($session_listing) && isset($session_listing['post_category'][$taxonomy])) {
3461
-                $terms = (array)$session_listing['post_category'][$taxonomy];
3461
+                $terms = (array) $session_listing['post_category'][$taxonomy];
3462 3462
             }
3463 3463
             
3464 3464
             if (!empty($terms)) {
@@ -3679,17 +3679,17 @@  discard block
 block discarded – undo
3679 3679
      */
3680 3680
     $locale = apply_filters('plugin_locale', get_locale(), 'geodirectory');
3681 3681
 
3682
-    load_textdomain('geodirectory', WP_LANG_DIR . '/' . 'geodirectory' . '/' . 'geodirectory' . '-' . $locale . '.mo');
3683
-    load_plugin_textdomain('geodirectory', false, plugin_basename(dirname(dirname(__FILE__))) . '/geodirectory-languages');
3682
+    load_textdomain('geodirectory', WP_LANG_DIR.'/'.'geodirectory'.'/'.'geodirectory'.'-'.$locale.'.mo');
3683
+    load_plugin_textdomain('geodirectory', false, plugin_basename(dirname(dirname(__FILE__))).'/geodirectory-languages');
3684 3684
 
3685 3685
     /**
3686 3686
      * Define language constants.
3687 3687
      *
3688 3688
      * @since 1.0.0
3689 3689
      */
3690
-    require_once(geodir_plugin_path() . '/language.php');
3690
+    require_once(geodir_plugin_path().'/language.php');
3691 3691
 
3692
-    $language_file = geodir_plugin_path() . '/db-language.php';
3692
+    $language_file = geodir_plugin_path().'/db-language.php';
3693 3693
 
3694 3694
     // Load language string file if not created yet
3695 3695
     if (!file_exists($language_file)) {
@@ -3704,8 +3704,8 @@  discard block
 block discarded – undo
3704 3704
          */
3705 3705
         try {
3706 3706
             require_once($language_file);
3707
-        } catch(Exception $e) {
3708
-            error_log('Language Error: ' . $e->getMessage());
3707
+        } catch (Exception $e) {
3708
+            error_log('Language Error: '.$e->getMessage());
3709 3709
         }
3710 3710
     }
3711 3711
 }
@@ -3722,18 +3722,18 @@  discard block
 block discarded – undo
3722 3722
  */
3723 3723
 function geodirectory_load_db_language() {
3724 3724
     global $wp_filesystem;
3725
-    if( empty( $wp_filesystem ) ) {
3726
-        require_once( ABSPATH .'/wp-admin/includes/file.php' );
3725
+    if (empty($wp_filesystem)) {
3726
+        require_once(ABSPATH.'/wp-admin/includes/file.php');
3727 3727
         WP_Filesystem();
3728 3728
         global $wp_filesystem;
3729 3729
     }
3730 3730
 
3731
-    $language_file = geodir_plugin_path() . '/db-language.php';
3731
+    $language_file = geodir_plugin_path().'/db-language.php';
3732 3732
 
3733
-    if(is_file($language_file) && !is_writable($language_file))
3733
+    if (is_file($language_file) && !is_writable($language_file))
3734 3734
         return false; // Not possible to create.
3735 3735
 
3736
-    if(!is_file($language_file) && !is_writable(dirname($language_file)))
3736
+    if (!is_file($language_file) && !is_writable(dirname($language_file)))
3737 3737
         return false; // Not possible to create.
3738 3738
 
3739 3739
     $contents_strings = array();
@@ -3767,17 +3767,17 @@  discard block
 block discarded – undo
3767 3767
     $contents = implode(PHP_EOL, $contents_head);
3768 3768
 
3769 3769
     if (!empty($contents_strings)) {
3770
-        foreach ( $contents_strings as $string ) {
3770
+        foreach ($contents_strings as $string) {
3771 3771
             if (is_scalar($string) && $string != '') {
3772 3772
                 $string = str_replace("'", "\'", $string);
3773
-                $contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
3773
+                $contents .= PHP_EOL."__('".$string."', 'geodirectory');";
3774 3774
             }
3775 3775
         }
3776 3776
     }
3777 3777
 
3778 3778
     $contents .= implode(PHP_EOL, $contents_foot);
3779 3779
 
3780
-    if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE))
3780
+    if ($wp_filesystem->put_contents($language_file, $contents, FS_CHMOD_FILE))
3781 3781
         return false; // Failure; could not write file.
3782 3782
 
3783 3783
     return true;
@@ -3799,11 +3799,11 @@  discard block
 block discarded – undo
3799 3799
     global $wpdb;
3800 3800
 
3801 3801
     // Custom fields table
3802
-    $sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM " . GEODIR_CUSTOM_FIELDS_TABLE;
3802
+    $sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM ".GEODIR_CUSTOM_FIELDS_TABLE;
3803 3803
     $rows = $wpdb->get_results($sql);
3804 3804
 
3805 3805
     if (!empty($rows)) {
3806
-        foreach($rows as $row) {
3806
+        foreach ($rows as $row) {
3807 3807
             if (!empty($row->admin_title))
3808 3808
                 $translation_texts[] = stripslashes_deep($row->admin_title);
3809 3809
 			
@@ -3837,11 +3837,11 @@  discard block
 block discarded – undo
3837 3837
     }
3838 3838
 	
3839 3839
     // Custom sorting fields table
3840
-    $sql = "SELECT site_title, asc_title, desc_title FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE;
3840
+    $sql = "SELECT site_title, asc_title, desc_title FROM ".GEODIR_CUSTOM_SORT_FIELDS_TABLE;
3841 3841
     $rows = $wpdb->get_results($sql);
3842 3842
 
3843 3843
     if (!empty($rows)) {
3844
-        foreach($rows as $row) {
3844
+        foreach ($rows as $row) {
3845 3845
             if (!empty($row->site_title))
3846 3846
                 $translation_texts[] = stripslashes_deep($row->site_title);
3847 3847
 
@@ -3855,11 +3855,11 @@  discard block
 block discarded – undo
3855 3855
 	
3856 3856
 	// Advance search filter fields table
3857 3857
 	if (defined('GEODIR_ADVANCE_SEARCH_TABLE')) {
3858
-		$sql = "SELECT field_site_name, front_search_title, field_desc FROM " . GEODIR_ADVANCE_SEARCH_TABLE;
3858
+		$sql = "SELECT field_site_name, front_search_title, field_desc FROM ".GEODIR_ADVANCE_SEARCH_TABLE;
3859 3859
 		$rows = $wpdb->get_results($sql);
3860 3860
 
3861 3861
 		if (!empty($rows)) {
3862
-			foreach($rows as $row) {
3862
+			foreach ($rows as $row) {
3863 3863
 				if (!empty($row->field_site_name))
3864 3864
 					$translation_texts[] = stripslashes_deep($row->field_site_name);
3865 3865
 
@@ -3894,7 +3894,7 @@  discard block
 block discarded – undo
3894 3894
      *
3895 3895
      * @param array $geodir_allowed_mime_types and file extensions.
3896 3896
      */
3897
-    return apply_filters( 'geodir_allowed_mime_types', array(
3897
+    return apply_filters('geodir_allowed_mime_types', array(
3898 3898
             'Image' => array( // Image formats.
3899 3899
                 'jpg' => 'image/jpeg',
3900 3900
                 'jpe' => 'image/jpeg',
@@ -3983,13 +3983,13 @@  discard block
 block discarded – undo
3983 3983
 
3984 3984
 
3985 3985
 
3986
-add_filter('wpseo_replacements','geodir_wpseo_replacements',10,1);
3986
+add_filter('wpseo_replacements', 'geodir_wpseo_replacements', 10, 1);
3987 3987
 /*
3988 3988
  * Add location variables to wpseo replacements.
3989 3989
  *
3990 3990
  * @since 1.5.4
3991 3991
  */
3992
-function geodir_wpseo_replacements($vars){
3992
+function geodir_wpseo_replacements($vars) {
3993 3993
 
3994 3994
     global $wp;
3995 3995
     $title = '';
@@ -4004,12 +4004,12 @@  discard block
 block discarded – undo
4004 4004
      * @param array $location_array The array of location variables.
4005 4005
      * @param array $vars The page title variables.
4006 4006
      */
4007
-    $location_array = apply_filters('geodir_filter_title_variables_location_arr_seo',$location_array, $vars);
4007
+    $location_array = apply_filters('geodir_filter_title_variables_location_arr_seo', $location_array, $vars);
4008 4008
     $location_titles = array();
4009
-    if(get_query_var( 'gd_country_full' )){
4010
-        if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4011
-        if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4012
-        if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4009
+    if (get_query_var('gd_country_full')) {
4010
+        if (get_query_var('gd_country_full')) {$location_array['gd_country'] = get_query_var('gd_country_full'); }
4011
+        if (get_query_var('gd_region_full')) {$location_array['gd_region'] = get_query_var('gd_region_full'); }
4012
+        if (get_query_var('gd_city_full')) {$location_array['gd_city'] = get_query_var('gd_city_full'); }
4013 4013
     }
4014 4014
     $location_single = '';
4015 4015
     $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
@@ -4081,23 +4081,23 @@  discard block
 block discarded – undo
4081 4081
     }
4082 4082
 
4083 4083
 
4084
-    if(!empty($location_titles)) {
4084
+    if (!empty($location_titles)) {
4085 4085
         $vars['%%location%%'] = implode(", ", $location_titles);
4086 4086
     }
4087 4087
 
4088 4088
 
4089
-    if(!empty($location_titles)) {
4090
-        $vars['%%in_location%%'] = __('in ', 'geodirectory') . implode(", ", $location_titles);
4089
+    if (!empty($location_titles)) {
4090
+        $vars['%%in_location%%'] = __('in ', 'geodirectory').implode(", ", $location_titles);
4091 4091
     }
4092 4092
 
4093 4093
 
4094 4094
 
4095
-    if($location_single) {
4096
-        $vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' .$location_single;
4095
+    if ($location_single) {
4096
+        $vars['%%in_location_single%%'] = __('in', 'geodirectory').' '.$location_single;
4097 4097
     }
4098 4098
 
4099 4099
 
4100
-    if($location_single) {
4100
+    if ($location_single) {
4101 4101
         $vars['%%location_single%%'] = $location_single;
4102 4102
     }
4103 4103
 
@@ -4109,17 +4109,17 @@  discard block
 block discarded – undo
4109 4109
      * @param string $vars The title with variables.
4110 4110
      * @param array $location_array The array of location variables.
4111 4111
      */
4112
-    return apply_filters('geodir_wpseo_replacements_vars',$vars,$location_array);
4112
+    return apply_filters('geodir_wpseo_replacements_vars', $vars, $location_array);
4113 4113
 }
4114 4114
 
4115 4115
 
4116
-add_filter('geodir_seo_meta_title','geodir_filter_title_variables',10,3);
4117
-add_filter('geodir_seo_page_title','geodir_filter_title_variables',10,2);
4118
-add_filter('geodir_seo_meta_description_pre','geodir_filter_title_variables',10,3);
4119
-function geodir_filter_title_variables($title, $gd_page, $sep=''){
4116
+add_filter('geodir_seo_meta_title', 'geodir_filter_title_variables', 10, 3);
4117
+add_filter('geodir_seo_page_title', 'geodir_filter_title_variables', 10, 2);
4118
+add_filter('geodir_seo_meta_description_pre', 'geodir_filter_title_variables', 10, 3);
4119
+function geodir_filter_title_variables($title, $gd_page, $sep = '') {
4120 4120
 
4121 4121
 
4122
-    if(!$gd_page || !$title){return $title;}// if no a GD page then bail.
4122
+    if (!$gd_page || !$title) {return $title; }// if no a GD page then bail.
4123 4123
     global $post;
4124 4124
     //print_r($post);
4125 4125
     /*
@@ -4161,123 +4161,123 @@  discard block
 block discarded – undo
4161 4161
     }
4162 4162
 
4163 4163
 
4164
-    if(strpos($title,'%%title%%') !== false){
4165
-        $title = str_replace("%%title%%",$post->post_title,$title);
4164
+    if (strpos($title, '%%title%%') !== false) {
4165
+        $title = str_replace("%%title%%", $post->post_title, $title);
4166 4166
     }
4167 4167
 
4168
-    if(strpos($title,'%%sitename%%') !== false){
4169
-        $title = str_replace("%%sitename%%",get_bloginfo('name'),$title);
4168
+    if (strpos($title, '%%sitename%%') !== false) {
4169
+        $title = str_replace("%%sitename%%", get_bloginfo('name'), $title);
4170 4170
     }
4171 4171
 
4172
-    if(strpos($title,'%%sitedesc%%') !== false){
4173
-        $title = str_replace("%%sitedesc%%",get_bloginfo('description'),$title);
4172
+    if (strpos($title, '%%sitedesc%%') !== false) {
4173
+        $title = str_replace("%%sitedesc%%", get_bloginfo('description'), $title);
4174 4174
     }
4175 4175
 
4176
-    if(strpos($title,'%%excerpt%%') !== false){
4177
-        $title = str_replace("%%excerpt%%",strip_tags(get_the_excerpt()),$title);
4176
+    if (strpos($title, '%%excerpt%%') !== false) {
4177
+        $title = str_replace("%%excerpt%%", strip_tags(get_the_excerpt()), $title);
4178 4178
     }
4179 4179
 
4180
-    if(strpos($title,'%%pt_single%%') !== false){
4180
+    if (strpos($title, '%%pt_single%%') !== false) {
4181 4181
         $single_name = '';
4182
-        if($gd_page=='search' || $gd_page=='author'){
4182
+        if ($gd_page == 'search' || $gd_page == 'author') {
4183 4183
             $geodir_post_types = get_option('geodir_post_types');
4184 4184
             $spt = esc_attr($_REQUEST['stype']);
4185
-            if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
4186
-                $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
4185
+            if (isset($geodir_post_types[$spt]['labels']['singular_name'])) {
4186
+                $single_name = __($geodir_post_types[$spt]['labels']['singular_name'], 'geodirectory');
4187 4187
             }
4188
-        }elseif($gd_page=='add-listing'){
4188
+        }elseif ($gd_page == 'add-listing') {
4189 4189
             $geodir_post_types = get_option('geodir_post_types');
4190 4190
             $spt = isset($_REQUEST['listing_type']) ? esc_attr($_REQUEST['listing_type']) : '';
4191
-            if(!$spt && isset($_REQUEST['pid'])){
4192
-                $spt = get_post_type( $_REQUEST['pid'] );
4191
+            if (!$spt && isset($_REQUEST['pid'])) {
4192
+                $spt = get_post_type($_REQUEST['pid']);
4193 4193
             }
4194
-            if(!$spt){$spt='gd_place';}
4195
-            if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
4196
-                $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
4194
+            if (!$spt) {$spt = 'gd_place'; }
4195
+            if (isset($geodir_post_types[$spt]['labels']['singular_name'])) {
4196
+                $single_name = __($geodir_post_types[$spt]['labels']['singular_name'], 'geodirectory');
4197 4197
             }
4198 4198
         }
4199
-        elseif($post->post_type){
4199
+        elseif ($post->post_type) {
4200 4200
             $geodir_post_types = get_option('geodir_post_types');
4201
-            if(isset($geodir_post_types[$post->post_type]['labels']['singular_name'])){
4202
-                $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'],'geodirectory');
4201
+            if (isset($geodir_post_types[$post->post_type]['labels']['singular_name'])) {
4202
+                $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'], 'geodirectory');
4203 4203
             }
4204 4204
 
4205 4205
 
4206 4206
         }
4207
-        $title = str_replace("%%pt_single%%",$single_name,$title);
4207
+        $title = str_replace("%%pt_single%%", $single_name, $title);
4208 4208
     }
4209 4209
 
4210
-    if(strpos($title,'%%pt_plural%%') !== false){
4210
+    if (strpos($title, '%%pt_plural%%') !== false) {
4211 4211
         $plural_name = '';
4212
-        if($gd_page=='search' || $gd_page=='author'){
4212
+        if ($gd_page == 'search' || $gd_page == 'author') {
4213 4213
             $geodir_post_types = get_option('geodir_post_types');
4214 4214
             $spt = esc_attr($_REQUEST['stype']);
4215
-            if(isset($geodir_post_types[$spt]['labels']['name'])){
4216
-                $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4215
+            if (isset($geodir_post_types[$spt]['labels']['name'])) {
4216
+                $plural_name = __($geodir_post_types[$spt]['labels']['name'], 'geodirectory');
4217 4217
             }
4218
-        }elseif($gd_page=='add-listing'){
4218
+        }elseif ($gd_page == 'add-listing') {
4219 4219
             $geodir_post_types = get_option('geodir_post_types');
4220 4220
             $spt = sanitize_text_field($_REQUEST['listing_type']);
4221
-            if(!$spt){$spt='gd_place';}
4222
-            if(isset($geodir_post_types[$spt]['labels']['name'])){
4223
-                $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4221
+            if (!$spt) {$spt = 'gd_place'; }
4222
+            if (isset($geodir_post_types[$spt]['labels']['name'])) {
4223
+                $plural_name = __($geodir_post_types[$spt]['labels']['name'], 'geodirectory');
4224 4224
             }
4225 4225
         }
4226
-        elseif(isset($post->post_type) && $post->post_type){
4226
+        elseif (isset($post->post_type) && $post->post_type) {
4227 4227
             $geodir_post_types = get_option('geodir_post_types');
4228
-            if(isset($geodir_post_types[$post->post_type]['labels']['name'])){
4229
-                $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'],'geodirectory');
4228
+            if (isset($geodir_post_types[$post->post_type]['labels']['name'])) {
4229
+                $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'], 'geodirectory');
4230 4230
             }
4231 4231
 
4232 4232
         }
4233
-        $title = str_replace("%%pt_plural%%",$plural_name,$title);
4233
+        $title = str_replace("%%pt_plural%%", $plural_name, $title);
4234 4234
     }
4235 4235
 
4236 4236
 
4237 4237
 
4238
-    if(strpos($title,'%%category%%') !== false){
4238
+    if (strpos($title, '%%category%%') !== false) {
4239 4239
         $cat_name = '';
4240 4240
 
4241
-        if($gd_page=='detail') {
4241
+        if ($gd_page == 'detail') {
4242 4242
             if ($post->default_category) {
4243
-                $cat = get_term($post->default_category, $post->post_type . 'category');
4243
+                $cat = get_term($post->default_category, $post->post_type.'category');
4244 4244
                 $cat_name = (isset($cat->name)) ? $cat->name : '';
4245 4245
             }
4246
-        }elseif($gd_page=='listing'){
4246
+        }elseif ($gd_page == 'listing') {
4247 4247
             $queried_object = get_queried_object();
4248
-            if(isset($queried_object->name)){
4248
+            if (isset($queried_object->name)) {
4249 4249
                 $cat_name = $queried_object->name;
4250 4250
             }
4251 4251
         }
4252
-        $title = str_replace("%%category%%",$cat_name,$title);
4252
+        $title = str_replace("%%category%%", $cat_name, $title);
4253 4253
     }
4254 4254
 
4255
-    if(strpos($title,'%%tag%%') !== false){
4255
+    if (strpos($title, '%%tag%%') !== false) {
4256 4256
         $cat_name = '';
4257 4257
 
4258
-        if($gd_page=='detail') {
4258
+        if ($gd_page == 'detail') {
4259 4259
             if ($post->default_category) {
4260
-                $cat = get_term($post->default_category, $post->post_type . 'category');
4260
+                $cat = get_term($post->default_category, $post->post_type.'category');
4261 4261
                 $cat_name = (isset($cat->name)) ? $cat->name : '';
4262 4262
             }
4263
-        }elseif($gd_page=='listing'){
4263
+        }elseif ($gd_page == 'listing') {
4264 4264
             $queried_object = get_queried_object();
4265
-            if(isset($queried_object->name)){
4265
+            if (isset($queried_object->name)) {
4266 4266
                 $cat_name = $queried_object->name;
4267 4267
             }
4268 4268
         }
4269
-        $title = str_replace("%%tag%%",$cat_name,$title);
4269
+        $title = str_replace("%%tag%%", $cat_name, $title);
4270 4270
     }
4271 4271
 
4272 4272
 
4273 4273
 
4274
-    if(strpos($title,'%%id%%') !== false){
4274
+    if (strpos($title, '%%id%%') !== false) {
4275 4275
         $ID = (isset($post->ID)) ? $post->ID : '';
4276
-        $title = str_replace("%%id%%",$ID,$title);
4276
+        $title = str_replace("%%id%%", $ID, $title);
4277 4277
     }
4278 4278
 
4279
-    if(strpos($title,'%%sep%%') !== false){
4280
-        $title = str_replace("%%sep%%",$sep,$title);
4279
+    if (strpos($title, '%%sep%%') !== false) {
4280
+        $title = str_replace("%%sep%%", $sep, $title);
4281 4281
     }
4282 4282
 
4283 4283
 
@@ -4295,12 +4295,12 @@  discard block
 block discarded – undo
4295 4295
      * @param string $gd_page The page being filtered.
4296 4296
      * @param string $sep The separator, default: `|`.
4297 4297
      */
4298
-    $location_array = apply_filters('geodir_filter_title_variables_location_arr',$location_array,$title, $gd_page, $sep);
4298
+    $location_array = apply_filters('geodir_filter_title_variables_location_arr', $location_array, $title, $gd_page, $sep);
4299 4299
     $location_titles = array();
4300
-    if($gd_page=='location' && get_query_var( 'gd_country_full' )){
4301
-        if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4302
-        if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4303
-        if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4300
+    if ($gd_page == 'location' && get_query_var('gd_country_full')) {
4301
+        if (get_query_var('gd_country_full')) {$location_array['gd_country'] = get_query_var('gd_country_full'); }
4302
+        if (get_query_var('gd_region_full')) {$location_array['gd_region'] = get_query_var('gd_region_full'); }
4303
+        if (get_query_var('gd_city_full')) {$location_array['gd_city'] = get_query_var('gd_city_full'); }
4304 4304
     }
4305 4305
     $location_single = '';
4306 4306
     $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
@@ -4372,51 +4372,51 @@  discard block
 block discarded – undo
4372 4372
     }
4373 4373
 
4374 4374
 
4375
-    if(strpos($title,'%%location%%') !== false){
4375
+    if (strpos($title, '%%location%%') !== false) {
4376 4376
         $location = '';
4377
-        if($location_titles) {
4377
+        if ($location_titles) {
4378 4378
             $location = implode(", ", $location_titles);
4379 4379
         }
4380
-        $title = str_replace("%%location%%",$location,$title);
4380
+        $title = str_replace("%%location%%", $location, $title);
4381 4381
     }
4382 4382
 
4383
-    if(strpos($title,'%%in_location%%') !== false){
4383
+    if (strpos($title, '%%in_location%%') !== false) {
4384 4384
         $location = '';
4385
-        if($location_titles) {
4386
-            $location = __('in ', 'geodirectory') . implode(", ", $location_titles);
4385
+        if ($location_titles) {
4386
+            $location = __('in ', 'geodirectory').implode(", ", $location_titles);
4387 4387
         }
4388
-        $title = str_replace("%%in_location%%",$location,$title);
4388
+        $title = str_replace("%%in_location%%", $location, $title);
4389 4389
     }
4390 4390
 
4391
-    if(strpos($title,'%%in_location_single%%') !== false){
4392
-        if($location_single) {
4393
-            $location_single = __('in', 'geodirectory') . ' ' .$location_single;
4391
+    if (strpos($title, '%%in_location_single%%') !== false) {
4392
+        if ($location_single) {
4393
+            $location_single = __('in', 'geodirectory').' '.$location_single;
4394 4394
         }
4395
-        $title = str_replace("%%in_location_single%%",$location_single,$title);
4395
+        $title = str_replace("%%in_location_single%%", $location_single, $title);
4396 4396
     }
4397 4397
 
4398
-    if(strpos($title,'%%location_single%%') !== false){
4399
-        $title = str_replace("%%location_single%%",$location_single,$title);
4398
+    if (strpos($title, '%%location_single%%') !== false) {
4399
+        $title = str_replace("%%location_single%%", $location_single, $title);
4400 4400
     }
4401 4401
 
4402 4402
 
4403
-    if(strpos($title,'%%search_term%%') !== false){
4403
+    if (strpos($title, '%%search_term%%') !== false) {
4404 4404
         $search_term = '';
4405
-        if(isset($_REQUEST['s'])){
4405
+        if (isset($_REQUEST['s'])) {
4406 4406
             $search_term = esc_attr($_REQUEST['s']);
4407 4407
         }
4408
-        $title = str_replace("%%search_term%%",$search_term,$title);
4408
+        $title = str_replace("%%search_term%%", $search_term, $title);
4409 4409
     }
4410 4410
 
4411
-    if(strpos($title,'%%search_near%%') !== false){
4411
+    if (strpos($title, '%%search_near%%') !== false) {
4412 4412
         $search_term = '';
4413
-        if(isset($_REQUEST['snear'])){
4413
+        if (isset($_REQUEST['snear'])) {
4414 4414
             $search_term = esc_attr($_REQUEST['snear']);
4415 4415
         }
4416
-        $title = str_replace("%%search_near%%",$search_term,$title);
4416
+        $title = str_replace("%%search_near%%", $search_term, $title);
4417 4417
     }
4418 4418
 
4419
-    if(strpos($title,'%%name%%') !== false){
4419
+    if (strpos($title, '%%name%%') !== false) {
4420 4420
         $author_name = get_the_author();
4421 4421
         if (!$author_name || $author_name === '') {
4422 4422
             $queried_object = get_queried_object();
@@ -4441,9 +4441,9 @@  discard block
 block discarded – undo
4441 4441
         $title = str_replace("%%pagetotal%%", $pagetotal, $title);
4442 4442
     }
4443 4443
 
4444
-    $title = wptexturize( $title );
4445
-    $title = convert_chars( $title );
4446
-    $title = esc_html( $title );
4444
+    $title = wptexturize($title);
4445
+    $title = convert_chars($title);
4446
+    $title = esc_html($title);
4447 4447
 
4448 4448
     /**
4449 4449
      * Filter the title variables after standard ones have been filtered.
@@ -4456,7 +4456,7 @@  discard block
 block discarded – undo
4456 4456
      * @param string $sep The separator, default: `|`.
4457 4457
      */
4458 4458
 
4459
-    return apply_filters('geodir_filter_title_variables_vars',$title,$location_array, $gd_page, $sep);
4459
+    return apply_filters('geodir_filter_title_variables_vars', $title, $location_array, $gd_page, $sep);
4460 4460
 }
4461 4461
 
4462 4462
 /**
@@ -4579,7 +4579,7 @@  discard block
 block discarded – undo
4579 4579
     }
4580 4580
     
4581 4581
     $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : '';
4582
-    $is_admin = is_admin() && ( !defined('DOING_AJAX' ) || ( defined('DOING_AJAX') && !DOING_AJAX ) )  ? true : false;
4582
+    $is_admin = is_admin() && (!defined('DOING_AJAX') || (defined('DOING_AJAX') && !DOING_AJAX)) ? true : false;
4583 4583
     $inline_save = $action == 'inline-save' ? true : false;
4584 4584
 
4585 4585
     if (empty($post->post_type) || $is_admin || $inline_save || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) {
@@ -4590,7 +4590,7 @@  discard block
 block discarded – undo
4590 4590
         return;
4591 4591
     }
4592 4592
 
4593
-    $user_id = (int)get_current_user_id();
4593
+    $user_id = (int) get_current_user_id();
4594 4594
         
4595 4595
     if ($user_id > 0 && get_option('geodir_notify_post_edited') && !wp_is_post_revision($post_ID) && in_array($post->post_type, geodir_get_posttypes())) {
4596 4596
         $author_id = !empty($post->post_author) ? $post->post_author : 0;
@@ -4634,7 +4634,7 @@  discard block
 block discarded – undo
4634 4634
     $nr  = geodir_title_meta_pagenumbering('nr');
4635 4635
 
4636 4636
     if ($max > 1 && $nr > 1) {
4637
-        $replacement = sprintf($sep . ' ' . __('Page %1$d of %2$d', 'geodirectory'), $nr, $max);
4637
+        $replacement = sprintf($sep.' '.__('Page %1$d of %2$d', 'geodirectory'), $nr, $max);
4638 4638
     }
4639 4639
 
4640 4640
     return $replacement;
@@ -4653,7 +4653,7 @@  discard block
 block discarded – undo
4653 4653
 
4654 4654
     $nr = geodir_title_meta_pagenumbering('nr');
4655 4655
     if (isset($nr) && $nr > 0) {
4656
-        $replacement = (string)$nr;
4656
+        $replacement = (string) $nr;
4657 4657
     }
4658 4658
 
4659 4659
     return $replacement;
@@ -4672,7 +4672,7 @@  discard block
 block discarded – undo
4672 4672
 
4673 4673
     $max = geodir_title_meta_pagenumbering('max');
4674 4674
     if (isset($max) && $max > 0) {
4675
-        $replacement = (string)$max;
4675
+        $replacement = (string) $max;
4676 4676
     }
4677 4677
 
4678 4678
     return $replacement;
@@ -4714,7 +4714,7 @@  discard block
 block discarded – undo
4714 4714
         }
4715 4715
 
4716 4716
         if (isset($post->post_content)) {
4717
-            $max_num_pages = (substr_count($post->post_content, '<!--nextpage-->' ) + 1);
4717
+            $max_num_pages = (substr_count($post->post_content, '<!--nextpage-->') + 1);
4718 4718
         }
4719 4719
     }
4720 4720
 
Please login to merge, or discard this patch.
Indentation   +3356 added lines, -3356 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,50 +1305,50 @@  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
-
1315
-
1316
-    // get placeholder file in the upload dir with a unique, sanitized filename
1317
-
1318
-    $post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : '';
1319
-
1320
-    $upload = wp_upload_bits($file_name, 0, '', $post_upload_date);
1321
-    if ($upload['error'])
1322
-        return new WP_Error('upload_dir_error', $upload['error']);
1323
-
1324
-    // fetch the remote url and write it to the placeholder file
1325
-    $headers = wp_remote_get($url, array('stream' => true,'filename' => $upload['file']));
1326
-
1327
-    $log_message = '';
1328
-    $filesize = filesize($upload['file']);
1329
-    // request failed
1330
-    if (!$headers) {
1331
-        $log_message = __('Remote server did not respond', 'geodirectory');
1332
-    }
1333
-    // make sure the fetch was successful
1334
-    elseif ($headers['response']['code'] != '200') {
1335
-        $log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
1336
-    }
1337
-    elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
1338
-        $log_message =  __('Remote file is incorrect size', 'geodirectory');
1339
-    }
1340
-    elseif (0 == $filesize) {
1341
-        $log_message = __('Zero size file downloaded', 'geodirectory');
1342
-    }
1343
-
1344
-    if($log_message){
1345
-        $del = unlink($upload['file']);
1346
-        if(!$del){geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory'));}
1347
-        return new WP_Error('import_file_error',$log_message );
1348
-    }
1349
-
1350
-
1351
-    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
+
1315
+
1316
+	// get placeholder file in the upload dir with a unique, sanitized filename
1317
+
1318
+	$post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : '';
1319
+
1320
+	$upload = wp_upload_bits($file_name, 0, '', $post_upload_date);
1321
+	if ($upload['error'])
1322
+		return new WP_Error('upload_dir_error', $upload['error']);
1323
+
1324
+	// fetch the remote url and write it to the placeholder file
1325
+	$headers = wp_remote_get($url, array('stream' => true,'filename' => $upload['file']));
1326
+
1327
+	$log_message = '';
1328
+	$filesize = filesize($upload['file']);
1329
+	// request failed
1330
+	if (!$headers) {
1331
+		$log_message = __('Remote server did not respond', 'geodirectory');
1332
+	}
1333
+	// make sure the fetch was successful
1334
+	elseif ($headers['response']['code'] != '200') {
1335
+		$log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
1336
+	}
1337
+	elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
1338
+		$log_message =  __('Remote file is incorrect size', 'geodirectory');
1339
+	}
1340
+	elseif (0 == $filesize) {
1341
+		$log_message = __('Zero size file downloaded', 'geodirectory');
1342
+	}
1343
+
1344
+	if($log_message){
1345
+		$del = unlink($upload['file']);
1346
+		if(!$del){geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory'));}
1347
+		return new WP_Error('import_file_error',$log_message );
1348
+	}
1349
+
1350
+
1351
+	return $upload;
1352 1352
 }
1353 1353
 
1354 1354
 /**
@@ -1360,21 +1360,21 @@  discard block
 block discarded – undo
1360 1360
  */
1361 1361
 function geodir_max_upload_size()
1362 1362
 {
1363
-    $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
1364
-
1365
-    if ($max_filesize > 0 && $max_filesize < 1) {
1366
-        $max_filesize = (int)($max_filesize * 1024) . 'kb';
1367
-    } else {
1368
-        $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
1369
-    }
1370
-
1371
-    /**
1372
-     * Filter default image upload size limit.
1373
-     *
1374
-     * @since 1.0.0
1375
-     * @param string $max_filesize Max file upload size. Ex. 10mb, 512kb.
1376
-     */
1377
-    return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
1363
+	$max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
1364
+
1365
+	if ($max_filesize > 0 && $max_filesize < 1) {
1366
+		$max_filesize = (int)($max_filesize * 1024) . 'kb';
1367
+	} else {
1368
+		$max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
1369
+	}
1370
+
1371
+	/**
1372
+	 * Filter default image upload size limit.
1373
+	 *
1374
+	 * @since 1.0.0
1375
+	 * @param string $max_filesize Max file upload size. Ex. 10mb, 512kb.
1376
+	 */
1377
+	return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
1378 1378
 }
1379 1379
 
1380 1380
 /**
@@ -1388,11 +1388,11 @@  discard block
 block discarded – undo
1388 1388
  */
1389 1389
 function geodir_dummy_folder_exists()
1390 1390
 {
1391
-    $path = geodir_plugin_path() . '/geodirectory-admin/dummy/';
1392
-    if (!is_dir($path))
1393
-        return false;
1394
-    else
1395
-        return true;
1391
+	$path = geodir_plugin_path() . '/geodirectory-admin/dummy/';
1392
+	if (!is_dir($path))
1393
+		return false;
1394
+	else
1395
+		return true;
1396 1396
 
1397 1397
 }
1398 1398
 
@@ -1407,290 +1407,290 @@  discard block
 block discarded – undo
1407 1407
  */
1408 1408
 function  geodir_get_author_info($aid)
1409 1409
 {
1410
-    global $wpdb;
1411
-    /*$infosql = "select * from $wpdb->users where ID=$aid";*/
1412
-    $infosql = $wpdb->prepare("select * from $wpdb->users where ID=%d", array($aid));
1413
-    $info = $wpdb->get_results($infosql);
1414
-    if ($info) {
1415
-        return $info[0];
1416
-    }
1410
+	global $wpdb;
1411
+	/*$infosql = "select * from $wpdb->users where ID=$aid";*/
1412
+	$infosql = $wpdb->prepare("select * from $wpdb->users where ID=%d", array($aid));
1413
+	$info = $wpdb->get_results($infosql);
1414
+	if ($info) {
1415
+		return $info[0];
1416
+	}
1417 1417
 }
1418 1418
 
1419 1419
 if (!function_exists('adminEmail')) {
1420
-    /**
1421
-     * Send emails to client on post submission, renew etc.
1422
-     *
1423
-     * @since 1.0.0
1424
-     * @package GeoDirectory
1425
-     * @global object $wpdb WordPress Database object.
1426
-     * @param int|string $page_id Page ID.
1427
-     * @param int|string $user_id User ID.
1428
-     * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1429
-     * @param string $custom_1 Custom data to be sent.
1430
-     */
1431
-    function adminEmail($page_id, $user_id, $message_type, $custom_1 = '')
1432
-    {
1433
-        global $wpdb;
1434
-        if ($message_type == 'expiration') {
1435
-            $subject = stripslashes(__(get_option('renew_email_subject'),'geodirectory'));
1436
-            $client_message = stripslashes(__(get_option('renew_email_content'),'geodirectory'));
1437
-        } elseif ($message_type == 'post_submited') {
1438
-            $subject = __(get_option('post_submited_success_email_subject_admin'),'geodirectory');
1439
-            $client_message = __(get_option('post_submited_success_email_content_admin'),'geodirectory');
1440
-        } elseif ($message_type == 'renew') {
1441
-            $subject = __(get_option('post_renew_success_email_subject_admin'),'geodirectory');
1442
-            $client_message = __(get_option('post_renew_success_email_content_admin'),'geodirectory');
1443
-        } elseif ($message_type == 'upgrade') {
1444
-            $subject = __(get_option('post_upgrade_success_email_subject_admin'),'geodirectory');
1445
-            $client_message = __(get_option('post_upgrade_success_email_content_admin'),'geodirectory');
1446
-        } elseif ($message_type == 'claim_approved') {
1447
-            $subject = __(get_option('claim_approved_email_subject'),'geodirectory');
1448
-            $client_message = __(get_option('claim_approved_email_content'),'geodirectory');
1449
-        } elseif ($message_type == 'claim_rejected') {
1450
-            $subject = __(get_option('claim_rejected_email_subject'),'geodirectory');
1451
-            $client_message = __(get_option('claim_rejected_email_content'),'geodirectory');
1452
-        } elseif ($message_type == 'claim_requested') {
1453
-            $subject = __(get_option('claim_email_subject_admin'),'geodirectory');
1454
-            $client_message = __(get_option('claim_email_content_admin'),'geodirectory');
1455
-        } elseif ($message_type == 'auto_claim') {
1456
-            $subject = __(get_option('auto_claim_email_subject'),'geodirectory');
1457
-            $client_message = __(get_option('auto_claim_email_content'),'geodirectory');
1458
-        } elseif ($message_type == 'payment_success') {
1459
-            $subject = __(get_option('post_payment_success_admin_email_subject'),'geodirectory');
1460
-            $client_message = __(get_option('post_payment_success_admin_email_content'),'geodirectory');
1461
-        } elseif ($message_type == 'payment_fail') {
1462
-            $subject = __(get_option('post_payment_fail_admin_email_subject'),'geodirectory');
1463
-            $client_message = __(get_option('post_payment_fail_admin_email_content'),'geodirectory');
1464
-        }
1465
-        $transaction_details = $custom_1;
1466
-        $fromEmail = get_option('site_email');
1467
-        $fromEmailName = get_site_emailName();
1420
+	/**
1421
+	 * Send emails to client on post submission, renew etc.
1422
+	 *
1423
+	 * @since 1.0.0
1424
+	 * @package GeoDirectory
1425
+	 * @global object $wpdb WordPress Database object.
1426
+	 * @param int|string $page_id Page ID.
1427
+	 * @param int|string $user_id User ID.
1428
+	 * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1429
+	 * @param string $custom_1 Custom data to be sent.
1430
+	 */
1431
+	function adminEmail($page_id, $user_id, $message_type, $custom_1 = '')
1432
+	{
1433
+		global $wpdb;
1434
+		if ($message_type == 'expiration') {
1435
+			$subject = stripslashes(__(get_option('renew_email_subject'),'geodirectory'));
1436
+			$client_message = stripslashes(__(get_option('renew_email_content'),'geodirectory'));
1437
+		} elseif ($message_type == 'post_submited') {
1438
+			$subject = __(get_option('post_submited_success_email_subject_admin'),'geodirectory');
1439
+			$client_message = __(get_option('post_submited_success_email_content_admin'),'geodirectory');
1440
+		} elseif ($message_type == 'renew') {
1441
+			$subject = __(get_option('post_renew_success_email_subject_admin'),'geodirectory');
1442
+			$client_message = __(get_option('post_renew_success_email_content_admin'),'geodirectory');
1443
+		} elseif ($message_type == 'upgrade') {
1444
+			$subject = __(get_option('post_upgrade_success_email_subject_admin'),'geodirectory');
1445
+			$client_message = __(get_option('post_upgrade_success_email_content_admin'),'geodirectory');
1446
+		} elseif ($message_type == 'claim_approved') {
1447
+			$subject = __(get_option('claim_approved_email_subject'),'geodirectory');
1448
+			$client_message = __(get_option('claim_approved_email_content'),'geodirectory');
1449
+		} elseif ($message_type == 'claim_rejected') {
1450
+			$subject = __(get_option('claim_rejected_email_subject'),'geodirectory');
1451
+			$client_message = __(get_option('claim_rejected_email_content'),'geodirectory');
1452
+		} elseif ($message_type == 'claim_requested') {
1453
+			$subject = __(get_option('claim_email_subject_admin'),'geodirectory');
1454
+			$client_message = __(get_option('claim_email_content_admin'),'geodirectory');
1455
+		} elseif ($message_type == 'auto_claim') {
1456
+			$subject = __(get_option('auto_claim_email_subject'),'geodirectory');
1457
+			$client_message = __(get_option('auto_claim_email_content'),'geodirectory');
1458
+		} elseif ($message_type == 'payment_success') {
1459
+			$subject = __(get_option('post_payment_success_admin_email_subject'),'geodirectory');
1460
+			$client_message = __(get_option('post_payment_success_admin_email_content'),'geodirectory');
1461
+		} elseif ($message_type == 'payment_fail') {
1462
+			$subject = __(get_option('post_payment_fail_admin_email_subject'),'geodirectory');
1463
+			$client_message = __(get_option('post_payment_fail_admin_email_content'),'geodirectory');
1464
+		}
1465
+		$transaction_details = $custom_1;
1466
+		$fromEmail = get_option('site_email');
1467
+		$fromEmailName = get_site_emailName();
1468 1468
 //$alivedays = get_post_meta($page_id,'alive_days',true);
1469
-        $pkg_limit = get_property_price_info_listing($page_id);
1470
-        $alivedays = $pkg_limit['days'];
1471
-        $productlink = get_permalink($page_id);
1472
-        $post_info = get_post($page_id);
1473
-        $post_date = date('dS F,Y', strtotime($post_info->post_date));
1474
-        $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1475
-        $loginurl = geodir_login_url();
1476
-        $loginurl_link = '<a href="' . $loginurl . '">login</a>';
1477
-        $siteurl = home_url();
1478
-        $siteurl_link = '<a href="' . $siteurl . '">' . $fromEmailName . '</a>';
1479
-        $user_info = get_userdata($user_id);
1480
-        $user_email = $user_info->user_email;
1481
-        $display_name = geodir_get_client_name($user_id);
1482
-        $user_login = $user_info->user_login;
1483
-        $number_of_grace_days = get_option('ptthemes_listing_preexpiry_notice_days');
1484
-        if ($number_of_grace_days == '') {
1485
-            $number_of_grace_days = 1;
1486
-        }
1487
-        if ($post_info->post_type == 'event') {
1488
-            $post_type = 'event';
1489
-        } else {
1490
-            $post_type = 'listing';
1491
-        }
1492
-        $renew_link = '<a href="' . $siteurl . '?ptype=post_' . $post_type . '&renew=1&pid=' . $page_id . '">' . RENEW_LINK . '</a>';
1493
-        $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#]');
1494
-        $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);
1495
-        $client_message = str_replace($search_array, $replace_array, $client_message);
1496
-        $subject = str_replace($search_array, $replace_array, $subject);
1497
-        $headers = 'MIME-Version: 1.0' . "\r\n";
1498
-        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1499
-        $headers .= 'From: ' . $fromEmailName . ' <' . $fromEmail . '>' . "\r\n";
1500
-
1501
-        $to = $fromEmail;
1502
-        $message = $client_message;
1503
-
1504
-
1505
-        /**
1506
-         * Filter the admin email to address.
1507
-         *
1508
-         * @since 1.6.1
1509
-         * @package GeoDirectory
1510
-         * @param string $to The email address the email is being sent to.
1511
-         * @param int|string $page_id Page ID.
1512
-         * @param int|string $user_id User ID.
1513
-         * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1514
-         * @param string $custom_1 Custom data to be sent.
1515
-         */
1516
-        $to = apply_filters('geodir_adminEmail_to',$to,$page_id, $user_id, $message_type, $custom_1 );
1517
-        /**
1518
-         * Filter the admin email subject.
1519
-         *
1520
-         * @since 1.6.1
1521
-         * @package GeoDirectory_Payment_Manager
1522
-         * @param string $subject The email subject.
1523
-         * @param int|string $page_id Page ID.
1524
-         * @param int|string $user_id User ID.
1525
-         * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1526
-         * @param string $custom_1 Custom data to be sent.
1527
-         */
1528
-        $subject = apply_filters('geodir_adminEmail_subject',$subject,$page_id, $user_id, $message_type, $custom_1);
1529
-        /**
1530
-         * Filter the admin email message.
1531
-         *
1532
-         * @since 1.6.1
1533
-         * @package GeoDirectory_Payment_Manager
1534
-         * @param string $message The email message text.
1535
-         * @param int|string $page_id Page ID.
1536
-         * @param int|string $user_id User ID.
1537
-         * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1538
-         * @param string $custom_1 Custom data to be sent.
1539
-         */
1540
-        $message = apply_filters('geodir_adminEmail_message',$message,$page_id, $user_id, $message_type, $custom_1);
1541
-        /**
1542
-         * Filter the admin email headers.
1543
-         *
1544
-         * @since 1.6.1
1545
-         * @package GeoDirectory_Payment_Manager
1546
-         * @param string $headers The email headers.
1547
-         * @param int|string $page_id Page ID.
1548
-         * @param int|string $user_id User ID.
1549
-         * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1550
-         * @param string $custom_1 Custom data to be sent.
1551
-         */
1552
-        $headers = apply_filters('geodir_adminEmail_headers',$headers,$page_id, $user_id, $message_type, $custom_1);
1553
-
1554
-
1555
-
1556
-        $sent = wp_mail($to, $subject, $message, $headers);
1557
-        if( ! $sent ) {
1558
-            if ( is_array( $to ) ) {
1559
-                $to = implode( ',', $to );
1560
-            }
1561
-            $log_message = sprintf(
1562
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1563
-                $message_type,
1564
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1565
-                $to,
1566
-                $subject
1567
-            );
1568
-            geodir_error_log( $log_message );
1569
-        }
1570
-    }
1469
+		$pkg_limit = get_property_price_info_listing($page_id);
1470
+		$alivedays = $pkg_limit['days'];
1471
+		$productlink = get_permalink($page_id);
1472
+		$post_info = get_post($page_id);
1473
+		$post_date = date('dS F,Y', strtotime($post_info->post_date));
1474
+		$listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1475
+		$loginurl = geodir_login_url();
1476
+		$loginurl_link = '<a href="' . $loginurl . '">login</a>';
1477
+		$siteurl = home_url();
1478
+		$siteurl_link = '<a href="' . $siteurl . '">' . $fromEmailName . '</a>';
1479
+		$user_info = get_userdata($user_id);
1480
+		$user_email = $user_info->user_email;
1481
+		$display_name = geodir_get_client_name($user_id);
1482
+		$user_login = $user_info->user_login;
1483
+		$number_of_grace_days = get_option('ptthemes_listing_preexpiry_notice_days');
1484
+		if ($number_of_grace_days == '') {
1485
+			$number_of_grace_days = 1;
1486
+		}
1487
+		if ($post_info->post_type == 'event') {
1488
+			$post_type = 'event';
1489
+		} else {
1490
+			$post_type = 'listing';
1491
+		}
1492
+		$renew_link = '<a href="' . $siteurl . '?ptype=post_' . $post_type . '&renew=1&pid=' . $page_id . '">' . RENEW_LINK . '</a>';
1493
+		$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#]');
1494
+		$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);
1495
+		$client_message = str_replace($search_array, $replace_array, $client_message);
1496
+		$subject = str_replace($search_array, $replace_array, $subject);
1497
+		$headers = 'MIME-Version: 1.0' . "\r\n";
1498
+		$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1499
+		$headers .= 'From: ' . $fromEmailName . ' <' . $fromEmail . '>' . "\r\n";
1500
+
1501
+		$to = $fromEmail;
1502
+		$message = $client_message;
1503
+
1504
+
1505
+		/**
1506
+		 * Filter the admin email to address.
1507
+		 *
1508
+		 * @since 1.6.1
1509
+		 * @package GeoDirectory
1510
+		 * @param string $to The email address the email is being sent to.
1511
+		 * @param int|string $page_id Page ID.
1512
+		 * @param int|string $user_id User ID.
1513
+		 * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1514
+		 * @param string $custom_1 Custom data to be sent.
1515
+		 */
1516
+		$to = apply_filters('geodir_adminEmail_to',$to,$page_id, $user_id, $message_type, $custom_1 );
1517
+		/**
1518
+		 * Filter the admin email subject.
1519
+		 *
1520
+		 * @since 1.6.1
1521
+		 * @package GeoDirectory_Payment_Manager
1522
+		 * @param string $subject The email subject.
1523
+		 * @param int|string $page_id Page ID.
1524
+		 * @param int|string $user_id User ID.
1525
+		 * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1526
+		 * @param string $custom_1 Custom data to be sent.
1527
+		 */
1528
+		$subject = apply_filters('geodir_adminEmail_subject',$subject,$page_id, $user_id, $message_type, $custom_1);
1529
+		/**
1530
+		 * Filter the admin email message.
1531
+		 *
1532
+		 * @since 1.6.1
1533
+		 * @package GeoDirectory_Payment_Manager
1534
+		 * @param string $message The email message text.
1535
+		 * @param int|string $page_id Page ID.
1536
+		 * @param int|string $user_id User ID.
1537
+		 * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1538
+		 * @param string $custom_1 Custom data to be sent.
1539
+		 */
1540
+		$message = apply_filters('geodir_adminEmail_message',$message,$page_id, $user_id, $message_type, $custom_1);
1541
+		/**
1542
+		 * Filter the admin email headers.
1543
+		 *
1544
+		 * @since 1.6.1
1545
+		 * @package GeoDirectory_Payment_Manager
1546
+		 * @param string $headers The email headers.
1547
+		 * @param int|string $page_id Page ID.
1548
+		 * @param int|string $user_id User ID.
1549
+		 * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
1550
+		 * @param string $custom_1 Custom data to be sent.
1551
+		 */
1552
+		$headers = apply_filters('geodir_adminEmail_headers',$headers,$page_id, $user_id, $message_type, $custom_1);
1553
+
1554
+
1555
+
1556
+		$sent = wp_mail($to, $subject, $message, $headers);
1557
+		if( ! $sent ) {
1558
+			if ( is_array( $to ) ) {
1559
+				$to = implode( ',', $to );
1560
+			}
1561
+			$log_message = sprintf(
1562
+				__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1563
+				$message_type,
1564
+				date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1565
+				$to,
1566
+				$subject
1567
+			);
1568
+			geodir_error_log( $log_message );
1569
+		}
1570
+	}
1571 1571
 }
1572 1572
 
1573 1573
 if (!function_exists('sendEmail')) {
1574
-    /**
1575
-     * @todo could be a duplicate of geodir_sendEmail.
1576
-     *
1577
-     * @since 1.0.0
1578
-     * @package GeoDirectory
1579
-     * @param string $fromEmail Sender email address.
1580
-     * @param string $fromEmailName Sender name.
1581
-     * @param string $toEmail Receiver email address.
1582
-     * @param string $toEmailName Receiver name.
1583
-     * @param string $to_subject Email subject.
1584
-     * @param string $to_message Email content.
1585
-     * @param string $extra Not being used.
1586
-     * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration.
1587
-     * @param string $post_id The post ID.
1588
-     * @param string $user_id The user ID.
1589
-     */
1590
-    function sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '')
1591
-    {
1592
-        $login_details = '';
1593
-        if ($message_type == 'send_friend') {
1594
-            $subject = stripslashes(__(get_option('email_friend_subject'),'geodirectory'));
1595
-            $message = stripslashes(__(get_option('email_friend_content'),'geodirectory'));
1596
-        } elseif ($message_type == 'send_enquiry') {
1597
-            $subject = __(get_option('email_enquiry_subject'),'geodirectory');
1598
-            $message = __(get_option('email_enquiry_content'),'geodirectory');
1599
-        } elseif ($message_type == 'forgot_password') {
1600
-            $subject = __(get_option('forgot_password_subject'),'geodirectory');
1601
-            $message = __(get_option('forgot_password_content'),'geodirectory');
1602
-            $login_details = $to_message;
1603
-        } elseif ($message_type == 'registration') {
1604
-            $subject = __(get_option('registration_success_email_subject'),'geodirectory');
1605
-            $message = __(get_option('registration_success_email_content'),'geodirectory');
1606
-            $login_details = $to_message;
1607
-        }
1608
-        $to_message = nl2br($to_message);
1609
-        $sitefromEmail = get_option('site_email');
1610
-        $sitefromEmailName = get_site_emailName();
1611
-        $productlink = get_permalink($post_id);
1612
-        $post_info = get_post($post_id);
1613
-        $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1614
-        $siteurl = home_url();
1615
-        $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
1616
-        $loginurl = geodir_login_url();
1617
-        $loginurl_link = '<a href="' . $loginurl . '">login</a>';
1618
-        if ($fromEmail == '') {
1619
-            $fromEmail = get_option('site_email');
1620
-        }
1621
-        if ($fromEmailName == '') {
1622
-            $fromEmailName = get_option('site_email_name');
1623
-        }
1624
-        $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]');
1625
-        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName);
1626
-        $message = str_replace($search_array, $replace_array, $message);
1627
-
1628
-        $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]');
1629
-        $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName);
1630
-        $subject = str_replace($search_array, $replace_array, $subject);
1631
-        $headers = 'MIME-Version: 1.0' . "\r\n";
1632
-        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1633
-        $headers .= "Reply-To: " . $fromEmail . "\r\n";
1634
-        $headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
1635
-
1636
-        $to = $toEmail;
1637
-
1638
-        $sent = wp_mail($to, $subject, $message, $headers);
1639
-        if( ! $sent ) {
1640
-            if ( is_array( $to ) ) {
1641
-                $to = implode( ',', $to );
1642
-            }
1643
-            $log_message = sprintf(
1644
-                __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1645
-                $message_type,
1646
-                date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1647
-                $to,
1648
-                $subject
1649
-            );
1650
-            geodir_error_log( $log_message );
1651
-        }
1652
-
1653
-        ///////// ADMIN BCC EMIALS
1654
-        $admin_bcc = false;
1655
-        if ($message_type == 'registration') {
1656
-            $message_raw = explode(__("Password:", 'geodirectory'), $message);
1657
-            $message_raw2 = explode("</p>", $message_raw[1], 2);
1658
-            $message = $message_raw[0] . __('Password:', 'geodirectory') . ' **********</p>' . $message_raw2[1];
1659
-        }
1660
-        $adminEmail = get_bloginfo('admin_email');
1661
-        $to = $adminEmail;
1662
-
1663
-        if ($message_type == 'registration' && get_option('bcc_new_user')) {
1664
-            $subject .= ' - ADMIN BCC COPY';
1665
-            $admin_bcc = true;
1666
-        }
1667
-        elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
1668
-            $subject .= ' - ADMIN BCC COPY';
1669
-            $admin_bcc = true;
1670
-        }
1671
-        elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
1672
-            $subject .= ' - ADMIN BCC COPY';
1673
-            $admin_bcc = true;
1674
-        }
1675
-
1676
-        if($admin_bcc === true){
1677
-            $sent = wp_mail($to, $subject, $message, $headers);
1678
-            if( ! $sent ) {
1679
-                if ( is_array( $to ) ) {
1680
-                    $to = implode( ',', $to );
1681
-                }
1682
-                $log_message = sprintf(
1683
-                    __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1684
-                    $message_type,
1685
-                    date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1686
-                    $to,
1687
-                    $subject
1688
-                );
1689
-                geodir_error_log( $log_message );
1690
-            }
1691
-        }
1692
-
1693
-    }
1574
+	/**
1575
+	 * @todo could be a duplicate of geodir_sendEmail.
1576
+	 *
1577
+	 * @since 1.0.0
1578
+	 * @package GeoDirectory
1579
+	 * @param string $fromEmail Sender email address.
1580
+	 * @param string $fromEmailName Sender name.
1581
+	 * @param string $toEmail Receiver email address.
1582
+	 * @param string $toEmailName Receiver name.
1583
+	 * @param string $to_subject Email subject.
1584
+	 * @param string $to_message Email content.
1585
+	 * @param string $extra Not being used.
1586
+	 * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration.
1587
+	 * @param string $post_id The post ID.
1588
+	 * @param string $user_id The user ID.
1589
+	 */
1590
+	function sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '')
1591
+	{
1592
+		$login_details = '';
1593
+		if ($message_type == 'send_friend') {
1594
+			$subject = stripslashes(__(get_option('email_friend_subject'),'geodirectory'));
1595
+			$message = stripslashes(__(get_option('email_friend_content'),'geodirectory'));
1596
+		} elseif ($message_type == 'send_enquiry') {
1597
+			$subject = __(get_option('email_enquiry_subject'),'geodirectory');
1598
+			$message = __(get_option('email_enquiry_content'),'geodirectory');
1599
+		} elseif ($message_type == 'forgot_password') {
1600
+			$subject = __(get_option('forgot_password_subject'),'geodirectory');
1601
+			$message = __(get_option('forgot_password_content'),'geodirectory');
1602
+			$login_details = $to_message;
1603
+		} elseif ($message_type == 'registration') {
1604
+			$subject = __(get_option('registration_success_email_subject'),'geodirectory');
1605
+			$message = __(get_option('registration_success_email_content'),'geodirectory');
1606
+			$login_details = $to_message;
1607
+		}
1608
+		$to_message = nl2br($to_message);
1609
+		$sitefromEmail = get_option('site_email');
1610
+		$sitefromEmailName = get_site_emailName();
1611
+		$productlink = get_permalink($post_id);
1612
+		$post_info = get_post($post_id);
1613
+		$listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
1614
+		$siteurl = home_url();
1615
+		$siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
1616
+		$loginurl = geodir_login_url();
1617
+		$loginurl_link = '<a href="' . $loginurl . '">login</a>';
1618
+		if ($fromEmail == '') {
1619
+			$fromEmail = get_option('site_email');
1620
+		}
1621
+		if ($fromEmailName == '') {
1622
+			$fromEmailName = get_option('site_email_name');
1623
+		}
1624
+		$search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]');
1625
+		$replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName);
1626
+		$message = str_replace($search_array, $replace_array, $message);
1627
+
1628
+		$search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]');
1629
+		$replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName);
1630
+		$subject = str_replace($search_array, $replace_array, $subject);
1631
+		$headers = 'MIME-Version: 1.0' . "\r\n";
1632
+		$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
1633
+		$headers .= "Reply-To: " . $fromEmail . "\r\n";
1634
+		$headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
1635
+
1636
+		$to = $toEmail;
1637
+
1638
+		$sent = wp_mail($to, $subject, $message, $headers);
1639
+		if( ! $sent ) {
1640
+			if ( is_array( $to ) ) {
1641
+				$to = implode( ',', $to );
1642
+			}
1643
+			$log_message = sprintf(
1644
+				__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1645
+				$message_type,
1646
+				date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1647
+				$to,
1648
+				$subject
1649
+			);
1650
+			geodir_error_log( $log_message );
1651
+		}
1652
+
1653
+		///////// ADMIN BCC EMIALS
1654
+		$admin_bcc = false;
1655
+		if ($message_type == 'registration') {
1656
+			$message_raw = explode(__("Password:", 'geodirectory'), $message);
1657
+			$message_raw2 = explode("</p>", $message_raw[1], 2);
1658
+			$message = $message_raw[0] . __('Password:', 'geodirectory') . ' **********</p>' . $message_raw2[1];
1659
+		}
1660
+		$adminEmail = get_bloginfo('admin_email');
1661
+		$to = $adminEmail;
1662
+
1663
+		if ($message_type == 'registration' && get_option('bcc_new_user')) {
1664
+			$subject .= ' - ADMIN BCC COPY';
1665
+			$admin_bcc = true;
1666
+		}
1667
+		elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
1668
+			$subject .= ' - ADMIN BCC COPY';
1669
+			$admin_bcc = true;
1670
+		}
1671
+		elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
1672
+			$subject .= ' - ADMIN BCC COPY';
1673
+			$admin_bcc = true;
1674
+		}
1675
+
1676
+		if($admin_bcc === true){
1677
+			$sent = wp_mail($to, $subject, $message, $headers);
1678
+			if( ! $sent ) {
1679
+				if ( is_array( $to ) ) {
1680
+					$to = implode( ',', $to );
1681
+				}
1682
+				$log_message = sprintf(
1683
+					__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
1684
+					$message_type,
1685
+					date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
1686
+					$to,
1687
+					$subject
1688
+				);
1689
+				geodir_error_log( $log_message );
1690
+			}
1691
+		}
1692
+
1693
+	}
1694 1694
 }
1695 1695
 
1696 1696
 /*
@@ -1708,16 +1708,16 @@  discard block
 block discarded – undo
1708 1708
  */
1709 1709
 function gd_lang_object_ids($ids_array, $type)
1710 1710
 {
1711
-    if (function_exists('icl_object_id')) {
1712
-        $res = array();
1713
-        foreach ($ids_array as $id) {
1714
-            $xlat = icl_object_id($id, $type, false);
1715
-            if (!is_null($xlat)) $res[] = $xlat;
1716
-        }
1717
-        return $res;
1718
-    } else {
1719
-        return $ids_array;
1720
-    }
1711
+	if (function_exists('icl_object_id')) {
1712
+		$res = array();
1713
+		foreach ($ids_array as $id) {
1714
+			$xlat = icl_object_id($id, $type, false);
1715
+			if (!is_null($xlat)) $res[] = $xlat;
1716
+		}
1717
+		return $res;
1718
+	} else {
1719
+		return $ids_array;
1720
+	}
1721 1721
 }
1722 1722
 
1723 1723
 
@@ -1732,31 +1732,31 @@  discard block
 block discarded – undo
1732 1732
  * @return array Modified Body CSS classes.
1733 1733
  */
1734 1734
 function geodir_custom_posts_body_class($classes) {
1735
-    global $wpdb, $wp;
1736
-    $post_types = geodir_get_posttypes('object');
1737
-    if (!empty($post_types) && count((array)$post_types) > 1) {
1738
-        $classes[] = 'geodir_custom_posts';
1739
-    }
1740
-
1741
-    // fix body class for signup page
1742
-    if (geodir_is_page('login')) {
1743
-        $new_classes = array();
1744
-        $new_classes[] = 'signup page-geodir-signup';
1745
-        if (!empty($classes)) {
1746
-            foreach ($classes as $class) {
1747
-                if ($class && $class != 'home' && $class != 'blog') {
1748
-                    $new_classes[] = $class;
1749
-                }
1750
-            }
1751
-        }
1752
-        $classes = $new_classes;
1753
-    }
1754
-
1755
-    if (geodir_is_geodir_page()) {
1756
-        $classes[] = 'geodir-page';
1757
-    }
1758
-
1759
-    return $classes;
1735
+	global $wpdb, $wp;
1736
+	$post_types = geodir_get_posttypes('object');
1737
+	if (!empty($post_types) && count((array)$post_types) > 1) {
1738
+		$classes[] = 'geodir_custom_posts';
1739
+	}
1740
+
1741
+	// fix body class for signup page
1742
+	if (geodir_is_page('login')) {
1743
+		$new_classes = array();
1744
+		$new_classes[] = 'signup page-geodir-signup';
1745
+		if (!empty($classes)) {
1746
+			foreach ($classes as $class) {
1747
+				if ($class && $class != 'home' && $class != 'blog') {
1748
+					$new_classes[] = $class;
1749
+				}
1750
+			}
1751
+		}
1752
+		$classes = $new_classes;
1753
+	}
1754
+
1755
+	if (geodir_is_geodir_page()) {
1756
+		$classes[] = 'geodir-page';
1757
+	}
1758
+
1759
+	return $classes;
1760 1760
 }
1761 1761
 
1762 1762
 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
@@ -1771,12 +1771,12 @@  discard block
 block discarded – undo
1771 1771
  */
1772 1772
 function geodir_map_zoom_level()
1773 1773
 {
1774
-    /**
1775
-     * Filter GD map zoom level.
1776
-     *
1777
-     * @since 1.0.0
1778
-     */
1779
-    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));
1774
+	/**
1775
+	 * Filter GD map zoom level.
1776
+	 *
1777
+	 * @since 1.0.0
1778
+	 */
1779
+	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));
1780 1780
 
1781 1781
 }
1782 1782
 
@@ -1790,12 +1790,12 @@  discard block
 block discarded – undo
1790 1790
  */
1791 1791
 function geodir_option_version_backup($geodir_option_name)
1792 1792
 {
1793
-    $version_date = time();
1794
-    $geodir_option = get_option($geodir_option_name);
1793
+	$version_date = time();
1794
+	$geodir_option = get_option($geodir_option_name);
1795 1795
 
1796
-    if (!empty($geodir_option)) {
1797
-        add_option($geodir_option_name . '_' . $version_date, $geodir_option);
1798
-    }
1796
+	if (!empty($geodir_option)) {
1797
+		add_option($geodir_option_name . '_' . $version_date, $geodir_option);
1798
+	}
1799 1799
 }
1800 1800
 
1801 1801
 /**
@@ -1808,11 +1808,11 @@  discard block
 block discarded – undo
1808 1808
  */
1809 1809
 function get_page_id_geodir_add_listing_page($page_id)
1810 1810
 {
1811
-    if (geodir_wpml_multilingual_status()) {
1812
-        $post_type = 'post_page';
1813
-        $page_id = geodir_get_wpml_element_id($page_id, $post_type);
1814
-    }
1815
-    return $page_id;
1811
+	if (geodir_wpml_multilingual_status()) {
1812
+		$post_type = 'post_page';
1813
+		$page_id = geodir_get_wpml_element_id($page_id, $post_type);
1814
+	}
1815
+	return $page_id;
1816 1816
 }
1817 1817
 
1818 1818
 /**
@@ -1824,10 +1824,10 @@  discard block
 block discarded – undo
1824 1824
  */
1825 1825
 function geodir_wpml_multilingual_status()
1826 1826
 {
1827
-    if (function_exists('icl_object_id')) {
1828
-        return true;
1829
-    }
1830
-    return false;
1827
+	if (function_exists('icl_object_id')) {
1828
+		return true;
1829
+	}
1830
+	return false;
1831 1831
 }
1832 1832
 
1833 1833
 /**
@@ -1841,22 +1841,22 @@  discard block
 block discarded – undo
1841 1841
  */
1842 1842
 function geodir_get_wpml_element_id($page_id, $post_type)
1843 1843
 {
1844
-    global $sitepress;
1845
-    if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
1846
-        $trid = $sitepress->get_element_trid($page_id, $post_type);
1847
-
1848
-        if ($trid > 0) {
1849
-            $translations = $sitepress->get_element_translations($trid, $post_type);
1850
-
1851
-            $lang = $sitepress->get_current_language();
1852
-            $lang = $lang ? $lang : $sitepress->get_default_language();
1853
-
1854
-            if (!empty($translations) && !empty($lang) && isset($translations[$lang]) && isset($translations[$lang]->element_id) && !empty($translations[$lang]->element_id)) {
1855
-                $page_id = $translations[$lang]->element_id;
1856
-            }
1857
-        }
1858
-    }
1859
-    return $page_id;
1844
+	global $sitepress;
1845
+	if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
1846
+		$trid = $sitepress->get_element_trid($page_id, $post_type);
1847
+
1848
+		if ($trid > 0) {
1849
+			$translations = $sitepress->get_element_translations($trid, $post_type);
1850
+
1851
+			$lang = $sitepress->get_current_language();
1852
+			$lang = $lang ? $lang : $sitepress->get_default_language();
1853
+
1854
+			if (!empty($translations) && !empty($lang) && isset($translations[$lang]) && isset($translations[$lang]->element_id) && !empty($translations[$lang]->element_id)) {
1855
+				$page_id = $translations[$lang]->element_id;
1856
+			}
1857
+		}
1858
+	}
1859
+	return $page_id;
1860 1860
 }
1861 1861
 
1862 1862
 /**
@@ -1868,20 +1868,20 @@  discard block
 block discarded – undo
1868 1868
  */
1869 1869
 function geodir_wpml_check_element_id()
1870 1870
 {
1871
-    global $sitepress;
1872
-    if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
1873
-        $el_type = 'post_page';
1874
-        $el_id = get_option('geodir_add_listing_page');
1875
-        $default_lang = $sitepress->get_default_language();
1876
-        $el_details = $sitepress->get_element_language_details($el_id, $el_type);
1877
-
1878
-        if (!($el_id > 0 && $default_lang && !empty($el_details) && isset($el_details->language_code) && $el_details->language_code == $default_lang)) {
1879
-            if (!$el_details->source_language_code) {
1880
-                $sitepress->set_element_language_details($el_id, $el_type, '', $default_lang);
1881
-                $sitepress->icl_translations_cache->clear();
1882
-            }
1883
-        }
1884
-    }
1871
+	global $sitepress;
1872
+	if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
1873
+		$el_type = 'post_page';
1874
+		$el_id = get_option('geodir_add_listing_page');
1875
+		$default_lang = $sitepress->get_default_language();
1876
+		$el_details = $sitepress->get_element_language_details($el_id, $el_type);
1877
+
1878
+		if (!($el_id > 0 && $default_lang && !empty($el_details) && isset($el_details->language_code) && $el_details->language_code == $default_lang)) {
1879
+			if (!$el_details->source_language_code) {
1880
+				$sitepress->set_element_language_details($el_id, $el_type, '', $default_lang);
1881
+				$sitepress->icl_translations_cache->clear();
1882
+			}
1883
+		}
1884
+	}
1885 1885
 }
1886 1886
 
1887 1887
 /**
@@ -1896,44 +1896,44 @@  discard block
 block discarded – undo
1896 1896
  */
1897 1897
 function geodir_widget_listings_get_order($query_args)
1898 1898
 {
1899
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
1900
-
1901
-    $query_args = $gd_query_args_widgets;
1902
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
1903
-        return $wpdb->posts . ".post_date DESC, ";
1904
-    }
1905
-
1906
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1907
-    $table = $plugin_prefix . $post_type . '_detail';
1908
-
1909
-    $sort_by = !empty($query_args['order_by']) ? $query_args['order_by'] : '';
1910
-
1911
-    switch ($sort_by) {
1912
-        case 'latest':
1913
-        case 'newest':
1914
-            $orderby = $wpdb->posts . ".post_date DESC, ";
1915
-            break;
1916
-        case 'featured':
1917
-            $orderby = $table . ".is_featured ASC, ";
1918
-            break;
1919
-        case 'az':
1920
-            $orderby = $wpdb->posts . ".post_title ASC, ";
1921
-            break;
1922
-        case 'high_review':
1923
-            $orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, ";
1924
-            break;
1925
-        case 'high_rating':
1926
-            $orderby = "( " . $table . ".overall_rating  ) DESC, ";
1927
-            break;
1928
-        case 'random':
1929
-            $orderby = "RAND(), ";
1930
-            break;
1931
-        default:
1932
-            $orderby = $wpdb->posts . ".post_title ASC, ";
1933
-            break;
1934
-    }
1935
-
1936
-    return $orderby;
1899
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
1900
+
1901
+	$query_args = $gd_query_args_widgets;
1902
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
1903
+		return $wpdb->posts . ".post_date DESC, ";
1904
+	}
1905
+
1906
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1907
+	$table = $plugin_prefix . $post_type . '_detail';
1908
+
1909
+	$sort_by = !empty($query_args['order_by']) ? $query_args['order_by'] : '';
1910
+
1911
+	switch ($sort_by) {
1912
+		case 'latest':
1913
+		case 'newest':
1914
+			$orderby = $wpdb->posts . ".post_date DESC, ";
1915
+			break;
1916
+		case 'featured':
1917
+			$orderby = $table . ".is_featured ASC, ";
1918
+			break;
1919
+		case 'az':
1920
+			$orderby = $wpdb->posts . ".post_title ASC, ";
1921
+			break;
1922
+		case 'high_review':
1923
+			$orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, ";
1924
+			break;
1925
+		case 'high_rating':
1926
+			$orderby = "( " . $table . ".overall_rating  ) DESC, ";
1927
+			break;
1928
+		case 'random':
1929
+			$orderby = "RAND(), ";
1930
+			break;
1931
+		default:
1932
+			$orderby = $wpdb->posts . ".post_title ASC, ";
1933
+			break;
1934
+	}
1935
+
1936
+	return $orderby;
1937 1937
 }
1938 1938
 
1939 1939
 /**
@@ -1951,126 +1951,126 @@  discard block
 block discarded – undo
1951 1951
  */
1952 1952
 function geodir_get_widget_listings($query_args = array(), $count_only = false)
1953 1953
 {
1954
-    global $wpdb, $plugin_prefix, $table_prefix;
1955
-    $GLOBALS['gd_query_args_widgets'] = $query_args;
1956
-    $gd_query_args_widgets = $query_args;
1957
-
1958
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1959
-    $table = $plugin_prefix . $post_type . '_detail';
1960
-
1961
-    $fields = $wpdb->posts . ".*, " . $table . ".*";
1962
-    /**
1963
-     * Filter widget listing fields string part that is being used for query.
1964
-     *
1965
-     * @since 1.0.0
1966
-     * @param string $fields Fields string.
1967
-     * @param string $table Table name.
1968
-     * @param string $post_type Post type.
1969
-     */
1970
-    $fields = apply_filters('geodir_filter_widget_listings_fields', $fields, $table, $post_type);
1971
-
1972
-    $join = "INNER JOIN " . $table . " ON (" . $table . ".post_id = " . $wpdb->posts . ".ID)";
1954
+	global $wpdb, $plugin_prefix, $table_prefix;
1955
+	$GLOBALS['gd_query_args_widgets'] = $query_args;
1956
+	$gd_query_args_widgets = $query_args;
1957
+
1958
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
1959
+	$table = $plugin_prefix . $post_type . '_detail';
1960
+
1961
+	$fields = $wpdb->posts . ".*, " . $table . ".*";
1962
+	/**
1963
+	 * Filter widget listing fields string part that is being used for query.
1964
+	 *
1965
+	 * @since 1.0.0
1966
+	 * @param string $fields Fields string.
1967
+	 * @param string $table Table name.
1968
+	 * @param string $post_type Post type.
1969
+	 */
1970
+	$fields = apply_filters('geodir_filter_widget_listings_fields', $fields, $table, $post_type);
1971
+
1972
+	$join = "INNER JOIN " . $table . " ON (" . $table . ".post_id = " . $wpdb->posts . ".ID)";
1973
+
1974
+	########### WPML ###########
1975
+
1976
+	if (function_exists('icl_object_id')) {
1977
+		global $sitepress;
1978
+		$lang_code = ICL_LANGUAGE_CODE;
1979
+		if ($lang_code) {
1980
+			$join .= " JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID";
1981
+		}
1982
+	}
1973 1983
 
1974
-    ########### WPML ###########
1984
+	########### WPML ###########
1975 1985
 
1976
-    if (function_exists('icl_object_id')) {
1977
-        global $sitepress;
1978
-        $lang_code = ICL_LANGUAGE_CODE;
1979
-        if ($lang_code) {
1980
-            $join .= " JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID";
1981
-        }
1982
-    }
1986
+	/**
1987
+	 * Filter widget listing join clause string part that is being used for query.
1988
+	 *
1989
+	 * @since 1.0.0
1990
+	 * @param string $join Join clause string.
1991
+	 * @param string $post_type Post type.
1992
+	 */
1993
+	$join = apply_filters('geodir_filter_widget_listings_join', $join, $post_type);
1983 1994
 
1984
-    ########### WPML ###########
1995
+	$post_status = is_super_admin() ? " OR " . $wpdb->posts . ".post_status = 'private'" : '';
1985 1996
 
1986
-    /**
1987
-     * Filter widget listing join clause string part that is being used for query.
1988
-     *
1989
-     * @since 1.0.0
1990
-     * @param string $join Join clause string.
1991
-     * @param string $post_type Post type.
1992
-     */
1993
-    $join = apply_filters('geodir_filter_widget_listings_join', $join, $post_type);
1994
-
1995
-    $post_status = is_super_admin() ? " OR " . $wpdb->posts . ".post_status = 'private'" : '';
1996
-
1997
-    $where = " AND ( " . $wpdb->posts . ".post_status = 'publish' " . $post_status . " ) AND " . $wpdb->posts . ".post_type = '" . $post_type . "'";
1998
-
1999
-    ########### WPML ###########
2000
-    if (function_exists('icl_object_id')) {
2001
-        if ($lang_code) {
2002
-            $where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type = 'post_$post_type' ";
2003
-        }
2004
-    }
2005
-    ########### WPML ###########
2006
-    /**
2007
-     * Filter widget listing where clause string part that is being used for query.
2008
-     *
2009
-     * @since 1.0.0
2010
-     * @param string $where Where clause string.
2011
-     * @param string $post_type Post type.
2012
-     */
2013
-    $where = apply_filters('geodir_filter_widget_listings_where', $where, $post_type);
2014
-    $where = $where != '' ? " WHERE 1=1 " . $where : '';
2015
-
2016
-    $groupby = " GROUP BY $wpdb->posts.ID ";
2017
-    /**
2018
-     * Filter widget listing groupby clause string part that is being used for query.
2019
-     *
2020
-     * @since 1.0.0
2021
-     * @param string $groupby Group by clause string.
2022
-     * @param string $post_type Post type.
2023
-     */
2024
-    $groupby = apply_filters('geodir_filter_widget_listings_groupby', $groupby, $post_type);
1997
+	$where = " AND ( " . $wpdb->posts . ".post_status = 'publish' " . $post_status . " ) AND " . $wpdb->posts . ".post_type = '" . $post_type . "'";
2025 1998
 
2026
-    if ($count_only) {
2027
-        $sql = "SELECT COUNT(" . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . "
1999
+	########### WPML ###########
2000
+	if (function_exists('icl_object_id')) {
2001
+		if ($lang_code) {
2002
+			$where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type = 'post_$post_type' ";
2003
+		}
2004
+	}
2005
+	########### WPML ###########
2006
+	/**
2007
+	 * Filter widget listing where clause string part that is being used for query.
2008
+	 *
2009
+	 * @since 1.0.0
2010
+	 * @param string $where Where clause string.
2011
+	 * @param string $post_type Post type.
2012
+	 */
2013
+	$where = apply_filters('geodir_filter_widget_listings_where', $where, $post_type);
2014
+	$where = $where != '' ? " WHERE 1=1 " . $where : '';
2015
+
2016
+	$groupby = " GROUP BY $wpdb->posts.ID ";
2017
+	/**
2018
+	 * Filter widget listing groupby clause string part that is being used for query.
2019
+	 *
2020
+	 * @since 1.0.0
2021
+	 * @param string $groupby Group by clause string.
2022
+	 * @param string $post_type Post type.
2023
+	 */
2024
+	$groupby = apply_filters('geodir_filter_widget_listings_groupby', $groupby, $post_type);
2025
+
2026
+	if ($count_only) {
2027
+		$sql = "SELECT COUNT(" . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . "
2028 2028
 			" . $join . "
2029 2029
 			" . $where;
2030
-        $rows = (int)$wpdb->get_var($sql);
2031
-    } else {
2032
-        $orderby = geodir_widget_listings_get_order($query_args);
2033
-        /**
2034
-         * Filter widget listing orderby clause string part that is being used for query.
2035
-         *
2036
-         * @since 1.0.0
2037
-         * @param string $orderby Order by clause string.
2038
-         * @param string $table Table name.
2039
-         * @param string $post_type Post type.
2040
-         */
2041
-        $orderby = apply_filters('geodir_filter_widget_listings_orderby', $orderby, $table, $post_type);
2042
-        $orderby .= $wpdb->posts . ".post_title ASC";
2043
-        $orderby = $orderby != '' ? " ORDER BY " . $orderby : '';
2044
-
2045
-        $limit = !empty($query_args['posts_per_page']) ? $query_args['posts_per_page'] : 5;
2046
-        /**
2047
-         * Filter widget listing limit that is being used for query.
2048
-         *
2049
-         * @since 1.0.0
2050
-         * @param int $limit Query results limit.
2051
-         * @param string $post_type Post type.
2052
-         */
2053
-        $limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
2054
-
2055
-        $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1;
2056
-        if ( !$page )
2057
-            $page = 1;
2058
-
2059
-        $limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : "";
2060
-
2061
-        $sql = "SELECT SQL_CALC_FOUND_ROWS " . $fields . " FROM " . $wpdb->posts . "
2030
+		$rows = (int)$wpdb->get_var($sql);
2031
+	} else {
2032
+		$orderby = geodir_widget_listings_get_order($query_args);
2033
+		/**
2034
+		 * Filter widget listing orderby clause string part that is being used for query.
2035
+		 *
2036
+		 * @since 1.0.0
2037
+		 * @param string $orderby Order by clause string.
2038
+		 * @param string $table Table name.
2039
+		 * @param string $post_type Post type.
2040
+		 */
2041
+		$orderby = apply_filters('geodir_filter_widget_listings_orderby', $orderby, $table, $post_type);
2042
+		$orderby .= $wpdb->posts . ".post_title ASC";
2043
+		$orderby = $orderby != '' ? " ORDER BY " . $orderby : '';
2044
+
2045
+		$limit = !empty($query_args['posts_per_page']) ? $query_args['posts_per_page'] : 5;
2046
+		/**
2047
+		 * Filter widget listing limit that is being used for query.
2048
+		 *
2049
+		 * @since 1.0.0
2050
+		 * @param int $limit Query results limit.
2051
+		 * @param string $post_type Post type.
2052
+		 */
2053
+		$limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
2054
+
2055
+		$page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1;
2056
+		if ( !$page )
2057
+			$page = 1;
2058
+
2059
+		$limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : "";
2060
+
2061
+		$sql = "SELECT SQL_CALC_FOUND_ROWS " . $fields . " FROM " . $wpdb->posts . "
2062 2062
 			" . $join . "
2063 2063
 			" . $where . "
2064 2064
 			" . $groupby . "
2065 2065
 			" . $orderby . "
2066 2066
 			" . $limit;
2067
-        $rows = $wpdb->get_results($sql);
2068
-    }
2067
+		$rows = $wpdb->get_results($sql);
2068
+	}
2069 2069
 
2070
-    unset($GLOBALS['gd_query_args_widgets']);
2071
-    unset($gd_query_args_widgets);
2070
+	unset($GLOBALS['gd_query_args_widgets']);
2071
+	unset($gd_query_args_widgets);
2072 2072
 
2073
-    return $rows;
2073
+	return $rows;
2074 2074
 }
2075 2075
 
2076 2076
 /**
@@ -2085,14 +2085,14 @@  discard block
 block discarded – undo
2085 2085
  */
2086 2086
 function geodir_function_widget_listings_fields($fields)
2087 2087
 {
2088
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2088
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2089 2089
 
2090
-    $query_args = $gd_query_args_widgets;
2091
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2092
-        return $fields;
2093
-    }
2090
+	$query_args = $gd_query_args_widgets;
2091
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2092
+		return $fields;
2093
+	}
2094 2094
     
2095
-    return $fields;
2095
+	return $fields;
2096 2096
 }
2097 2097
 
2098 2098
 /**
@@ -2107,28 +2107,28 @@  discard block
 block discarded – undo
2107 2107
  */
2108 2108
 function geodir_function_widget_listings_join($join)
2109 2109
 {
2110
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2110
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2111 2111
 
2112
-    $query_args = $gd_query_args_widgets;
2113
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2114
-        return $join;
2115
-    }
2112
+	$query_args = $gd_query_args_widgets;
2113
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2114
+		return $join;
2115
+	}
2116 2116
 
2117
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2118
-    $table = $plugin_prefix . $post_type . '_detail';
2117
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2118
+	$table = $plugin_prefix . $post_type . '_detail';
2119 2119
 
2120
-    if (!empty($query_args['with_pics_only'])) {
2121
-        $join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )";
2122
-    }
2120
+	if (!empty($query_args['with_pics_only'])) {
2121
+		$join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )";
2122
+	}
2123 2123
 
2124
-    if (!empty($query_args['tax_query'])) {
2125
-        $tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
2126
-        if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
2127
-            $join .= $tax_queries['join'];
2128
-        }
2129
-    }
2124
+	if (!empty($query_args['tax_query'])) {
2125
+		$tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
2126
+		if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
2127
+			$join .= $tax_queries['join'];
2128
+		}
2129
+	}
2130 2130
 
2131
-    return $join;
2131
+	return $join;
2132 2132
 }
2133 2133
 
2134 2134
 /**
@@ -2143,58 +2143,58 @@  discard block
 block discarded – undo
2143 2143
  */
2144 2144
 function geodir_function_widget_listings_where($where)
2145 2145
 {
2146
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2147
-
2148
-    $query_args = $gd_query_args_widgets;
2149
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2150
-        return $where;
2151
-    }
2152
-    $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2153
-    $table = $plugin_prefix . $post_type . '_detail';
2154
-
2155
-    if (!empty($query_args)) {
2156
-        if (!empty($query_args['gd_location']) && function_exists('geodir_default_location_where')) {
2157
-            $where = geodir_default_location_where($where, $table);
2158
-        }
2159
-
2160
-        if (!empty($query_args['post_author'])) {
2161
-            $where .= " AND " . $wpdb->posts . ".post_author = " . (int)$query_args['post_author'];
2162
-        }
2163
-        
2164
-        if (!empty($query_args['show_featured_only'])) {
2165
-            $where .= " AND " . $table . ".is_featured = '1'";
2166
-        }
2146
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2167 2147
 
2168
-        if (!empty($query_args['show_special_only'])) {
2169
-            $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )";
2170
-        }
2148
+	$query_args = $gd_query_args_widgets;
2149
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2150
+		return $where;
2151
+	}
2152
+	$post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type'];
2153
+	$table = $plugin_prefix . $post_type . '_detail';
2171 2154
 
2172
-        if (!empty($query_args['with_pics_only'])) {
2173
-            $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL ";
2174
-        }
2155
+	if (!empty($query_args)) {
2156
+		if (!empty($query_args['gd_location']) && function_exists('geodir_default_location_where')) {
2157
+			$where = geodir_default_location_where($where, $table);
2158
+		}
2175 2159
 
2176
-        if (!empty($query_args['featured_image_only'])) {
2177
-            $where .= " AND " . $table . ".featured_image IS NOT NULL AND " . $table . ".featured_image!='' ";
2178
-        }
2160
+		if (!empty($query_args['post_author'])) {
2161
+			$where .= " AND " . $wpdb->posts . ".post_author = " . (int)$query_args['post_author'];
2162
+		}
2163
+        
2164
+		if (!empty($query_args['show_featured_only'])) {
2165
+			$where .= " AND " . $table . ".is_featured = '1'";
2166
+		}
2179 2167
 
2180
-        if (!empty($query_args['with_videos_only'])) {
2181
-            $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )";
2182
-        }
2168
+		if (!empty($query_args['show_special_only'])) {
2169
+			$where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )";
2170
+		}
2183 2171
 
2184
-        if (!empty($query_args['tax_query'])) {
2185
-            $tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
2172
+		if (!empty($query_args['with_pics_only'])) {
2173
+			$where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL ";
2174
+		}
2186 2175
 
2187
-            if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
2188
-                $where .= $tax_queries['where'];
2189
-            }
2190
-        }
2191
-    }
2176
+		if (!empty($query_args['featured_image_only'])) {
2177
+			$where .= " AND " . $table . ".featured_image IS NOT NULL AND " . $table . ".featured_image!='' ";
2178
+		}
2192 2179
 
2193
-    return $where;
2194
-}
2180
+		if (!empty($query_args['with_videos_only'])) {
2181
+			$where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )";
2182
+		}
2195 2183
 
2196
-/**
2197
- * Listing query orderby clause SQL part for widgets.
2184
+		if (!empty($query_args['tax_query'])) {
2185
+			$tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID');
2186
+
2187
+			if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
2188
+				$where .= $tax_queries['where'];
2189
+			}
2190
+		}
2191
+	}
2192
+
2193
+	return $where;
2194
+}
2195
+
2196
+/**
2197
+ * Listing query orderby clause SQL part for widgets.
2198 2198
  *
2199 2199
  * @since 1.0.0
2200 2200
  * @package GeoDirectory
@@ -2205,14 +2205,14 @@  discard block
 block discarded – undo
2205 2205
  */
2206 2206
 function geodir_function_widget_listings_orderby($orderby)
2207 2207
 {
2208
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2208
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2209 2209
 
2210
-    $query_args = $gd_query_args_widgets;
2211
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2212
-        return $orderby;
2213
-    }
2210
+	$query_args = $gd_query_args_widgets;
2211
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2212
+		return $orderby;
2213
+	}
2214 2214
 
2215
-    return $orderby;
2215
+	return $orderby;
2216 2216
 }
2217 2217
 
2218 2218
 /**
@@ -2227,18 +2227,18 @@  discard block
 block discarded – undo
2227 2227
  */
2228 2228
 function geodir_function_widget_listings_limit($limit)
2229 2229
 {
2230
-    global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2230
+	global $wpdb, $plugin_prefix, $gd_query_args_widgets;
2231 2231
 
2232
-    $query_args = $gd_query_args_widgets;
2233
-    if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2234
-        return $limit;
2235
-    }
2232
+	$query_args = $gd_query_args_widgets;
2233
+	if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
2234
+		return $limit;
2235
+	}
2236 2236
 
2237
-    if (!empty($query_args) && !empty($query_args['posts_per_page'])) {
2238
-        $limit = (int)$query_args['posts_per_page'];
2239
-    }
2237
+	if (!empty($query_args) && !empty($query_args['posts_per_page'])) {
2238
+		$limit = (int)$query_args['posts_per_page'];
2239
+	}
2240 2240
 
2241
-    return $limit;
2241
+	return $limit;
2242 2242
 }
2243 2243
 
2244 2244
 /**
@@ -2252,24 +2252,24 @@  discard block
 block discarded – undo
2252 2252
  */
2253 2253
 function geodir_media_image_large_width($default = 800, $params = '')
2254 2254
 {
2255
-    $large_size_w = get_option('large_size_w');
2256
-    $large_size_w = $large_size_w > 0 ? $large_size_w : $default;
2257
-    $large_size_w = absint($large_size_w);
2258
-
2259
-    if (!get_option('geodir_use_wp_media_large_size')) {
2260
-        $large_size_w = 800;
2261
-    }
2262
-
2263
-    /**
2264
-     * Filter large image width.
2265
-     *
2266
-     * @since 1.0.0
2267
-     * @param int $large_size_w Large image width.
2268
-     * @param int $default Default width.
2269
-     * @param string|array $params Image parameters.
2270
-     */
2271
-    $large_size_w = apply_filters('geodir_filter_media_image_large_width', $large_size_w, $default, $params);
2272
-    return $large_size_w;
2255
+	$large_size_w = get_option('large_size_w');
2256
+	$large_size_w = $large_size_w > 0 ? $large_size_w : $default;
2257
+	$large_size_w = absint($large_size_w);
2258
+
2259
+	if (!get_option('geodir_use_wp_media_large_size')) {
2260
+		$large_size_w = 800;
2261
+	}
2262
+
2263
+	/**
2264
+	 * Filter large image width.
2265
+	 *
2266
+	 * @since 1.0.0
2267
+	 * @param int $large_size_w Large image width.
2268
+	 * @param int $default Default width.
2269
+	 * @param string|array $params Image parameters.
2270
+	 */
2271
+	$large_size_w = apply_filters('geodir_filter_media_image_large_width', $large_size_w, $default, $params);
2272
+	return $large_size_w;
2273 2273
 }
2274 2274
 
2275 2275
 /**
@@ -2283,25 +2283,25 @@  discard block
 block discarded – undo
2283 2283
  */
2284 2284
 function geodir_media_image_large_height($default = 800, $params = '')
2285 2285
 {
2286
-    $large_size_h = get_option('large_size_h');
2287
-    $large_size_h = $large_size_h > 0 ? $large_size_h : $default;
2288
-    $large_size_h = absint($large_size_h);
2289
-
2290
-    if (!get_option('geodir_use_wp_media_large_size')) {
2291
-        $large_size_h = 800;
2292
-    }
2293
-
2294
-    /**
2295
-     * Filter large image height.
2296
-     *
2297
-     * @since 1.0.0
2298
-     * @param int $large_size_h Large image height.
2299
-     * @param int $default Default height.
2300
-     * @param string|array $params Image parameters.
2301
-     */
2302
-    $large_size_h = apply_filters('geodir_filter_media_image_large_height', $large_size_h, $default, $params);
2286
+	$large_size_h = get_option('large_size_h');
2287
+	$large_size_h = $large_size_h > 0 ? $large_size_h : $default;
2288
+	$large_size_h = absint($large_size_h);
2303 2289
 
2304
-    return $large_size_h;
2290
+	if (!get_option('geodir_use_wp_media_large_size')) {
2291
+		$large_size_h = 800;
2292
+	}
2293
+
2294
+	/**
2295
+	 * Filter large image height.
2296
+	 *
2297
+	 * @since 1.0.0
2298
+	 * @param int $large_size_h Large image height.
2299
+	 * @param int $default Default height.
2300
+	 * @param string|array $params Image parameters.
2301
+	 */
2302
+	$large_size_h = apply_filters('geodir_filter_media_image_large_height', $large_size_h, $default, $params);
2303
+
2304
+	return $large_size_h;
2305 2305
 }
2306 2306
 
2307 2307
 /**
@@ -2316,25 +2316,25 @@  discard block
 block discarded – undo
2316 2316
  */
2317 2317
 function geodir_sanitize_location_name($type, $name, $translate = true)
2318 2318
 {
2319
-    if ($name == '') {
2320
-        return NULL;
2321
-    }
2322
-
2323
-    $type = $type == 'gd_country' ? 'country' : $type;
2324
-    $type = $type == 'gd_region' ? 'region' : $type;
2325
-    $type = $type == 'gd_city' ? 'city' : $type;
2326
-
2327
-    $return = $name;
2328
-    if (function_exists('get_actual_location_name')) {
2329
-        $return = get_actual_location_name($type, $name, $translate);
2330
-    } else {
2331
-        $return = preg_replace('/-(\d+)$/', '', $return);
2332
-        $return = preg_replace('/[_-]/', ' ', $return);
2333
-        $return = geodir_ucwords($return);
2334
-        $return = $translate ? __($return, 'geodirectory') : $return;
2335
-    }
2336
-
2337
-    return $return;
2319
+	if ($name == '') {
2320
+		return NULL;
2321
+	}
2322
+
2323
+	$type = $type == 'gd_country' ? 'country' : $type;
2324
+	$type = $type == 'gd_region' ? 'region' : $type;
2325
+	$type = $type == 'gd_city' ? 'city' : $type;
2326
+
2327
+	$return = $name;
2328
+	if (function_exists('get_actual_location_name')) {
2329
+		$return = get_actual_location_name($type, $name, $translate);
2330
+	} else {
2331
+		$return = preg_replace('/-(\d+)$/', '', $return);
2332
+		$return = preg_replace('/[_-]/', ' ', $return);
2333
+		$return = geodir_ucwords($return);
2334
+		$return = $translate ? __($return, 'geodirectory') : $return;
2335
+	}
2336
+
2337
+	return $return;
2338 2338
 }
2339 2339
 
2340 2340
 
@@ -2348,14 +2348,14 @@  discard block
 block discarded – undo
2348 2348
 function geodir_comments_number($number)
2349 2349
 {
2350 2350
 
2351
-    if ($number > 1) {
2352
-        $output = str_replace('%', number_format_i18n($number), __('% Reviews', 'geodirectory'));
2353
-    } elseif ($number == 0 || $number == '') {
2354
-        $output = __('No Reviews', 'geodirectory');
2355
-    } else { // must be one
2356
-        $output = __('1 Review', 'geodirectory');
2357
-    }
2358
-    echo $output;
2351
+	if ($number > 1) {
2352
+		$output = str_replace('%', number_format_i18n($number), __('% Reviews', 'geodirectory'));
2353
+	} elseif ($number == 0 || $number == '') {
2354
+		$output = __('No Reviews', 'geodirectory');
2355
+	} else { // must be one
2356
+		$output = __('1 Review', 'geodirectory');
2357
+	}
2358
+	echo $output;
2359 2359
 }
2360 2360
 
2361 2361
 /**
@@ -2368,23 +2368,23 @@  discard block
 block discarded – undo
2368 2368
  */
2369 2369
 function is_page_geodir_home()
2370 2370
 {
2371
-    global $wpdb;
2372
-    $cur_url = str_replace(array("https://", "http://", "www."), array('', '', ''), geodir_curPageURL());
2373
-    if (function_exists('geodir_location_geo_home_link')) {
2374
-        remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
2375
-    }
2376
-    $home_url = home_url('', 'http');
2377
-    if (function_exists('geodir_location_geo_home_link')) {
2378
-        add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
2379
-    }
2380
-    $home_url = str_replace("www.", "", $home_url);
2381
-    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')) ) {
2382
-        return true;
2383
-    }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')){
2384
-        return true;
2385
-    } else {
2386
-        return false;
2387
-    }
2371
+	global $wpdb;
2372
+	$cur_url = str_replace(array("https://", "http://", "www."), array('', '', ''), geodir_curPageURL());
2373
+	if (function_exists('geodir_location_geo_home_link')) {
2374
+		remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
2375
+	}
2376
+	$home_url = home_url('', 'http');
2377
+	if (function_exists('geodir_location_geo_home_link')) {
2378
+		add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
2379
+	}
2380
+	$home_url = str_replace("www.", "", $home_url);
2381
+	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')) ) {
2382
+		return true;
2383
+	}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')){
2384
+		return true;
2385
+	} else {
2386
+		return false;
2387
+	}
2388 2388
 
2389 2389
 }
2390 2390
 
@@ -2400,13 +2400,13 @@  discard block
 block discarded – undo
2400 2400
  */
2401 2401
 function geodir_wpseo_homepage_canonical($url)
2402 2402
 {
2403
-    global $post;
2403
+	global $post;
2404 2404
 
2405
-    if (is_page_geodir_home()) {
2406
-        return home_url();
2407
-    }
2405
+	if (is_page_geodir_home()) {
2406
+		return home_url();
2407
+	}
2408 2408
 
2409
-    return $url;
2409
+	return $url;
2410 2410
 }
2411 2411
 
2412 2412
 add_filter('wpseo_canonical', 'geodir_wpseo_homepage_canonical', 10);
@@ -2423,16 +2423,16 @@  discard block
 block discarded – undo
2423 2423
  */
2424 2424
 function geodir_googlemap_script_extra_details_page($extra)
2425 2425
 {
2426
-    global $post;
2427
-    $add_google_places_api = false;
2428
-    if (isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
2429
-        $add_google_places_api = true;
2430
-    }
2431
-    if (!str_replace('libraries=places', '', $extra) && (geodir_is_page('detail') || $add_google_places_api)) {
2432
-        $extra .= "&amp;libraries=places";
2433
-    }
2434
-
2435
-    return $extra;
2426
+	global $post;
2427
+	$add_google_places_api = false;
2428
+	if (isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
2429
+		$add_google_places_api = true;
2430
+	}
2431
+	if (!str_replace('libraries=places', '', $extra) && (geodir_is_page('detail') || $add_google_places_api)) {
2432
+		$extra .= "&amp;libraries=places";
2433
+	}
2434
+
2435
+	return $extra;
2436 2436
 }
2437 2437
 
2438 2438
 add_filter('geodir_googlemap_script_extra', 'geodir_googlemap_script_extra_details_page', 101, 1);
@@ -2452,92 +2452,92 @@  discard block
 block discarded – undo
2452 2452
  */
2453 2453
 function geodir_popular_post_category_output($args = '', $instance = '')
2454 2454
 {
2455
-    // prints the widget
2456
-    global $wpdb, $plugin_prefix, $geodir_post_category_str;
2457
-    extract($args, EXTR_SKIP);
2458
-
2459
-    echo $before_widget;
2460
-
2461
-    /** This filter is documented in geodirectory_widgets.php */
2462
-    $title = empty($instance['title']) ? __('Popular Categories', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2463
-
2464
-    $gd_post_type = geodir_get_current_posttype();
2465
-
2466
-    $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15;
2467
-    $default_post_type = !empty($gd_post_type) ? $gd_post_type : (isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ? $instance['default_post_type'] : '');
2468
-
2469
-    $taxonomy = array();
2470
-    if (!empty($gd_post_type)) {
2471
-        $taxonomy[] = $gd_post_type . "category";
2472
-    } else {
2473
-        $default_post_type = geodir_get_posttypes()[0];
2474
-        $taxonomy = geodir_get_taxonomies($gd_post_type);
2475
-    }
2476
-
2477
-    $terms = get_terms($taxonomy);
2478
-    $a_terms = array();
2479
-    $b_terms = array();
2480
-
2481
-    foreach ($terms as $term) {
2482
-        if ($term->count > 0) {
2483
-            $a_terms[$term->taxonomy][] = $term;
2484
-        }
2485
-    }
2486
-
2487
-    if (!empty($a_terms)) {
2488
-        foreach ($a_terms as $b_key => $b_val) {
2489
-            $b_terms[$b_key] = geodir_sort_terms($b_val, 'count');
2490
-        }
2491
-
2492
-        $default_taxonomy = $default_post_type != '' && isset($b_terms[$default_post_type . 'category']) ? $default_post_type . 'category' : '';
2493
-
2494
-        $tax_change_output = '';
2495
-        if (count($b_terms) > 1) {
2496
-            $tax_change_output .= "<select data-limit='$category_limit' class='geodir-cat-list-tax'  onchange='geodir_get_post_term(this);'>";
2497
-            foreach ($b_terms as $key => $val) {
2498
-                $ptype = get_post_type_object(str_replace("category", "", $key));
2499
-                $cpt_name = __($ptype->labels->singular_name, 'geodirectory');
2500
-                $tax_change_output .= "<option value='$key' ". selected($key, $default_taxonomy, false) .">" . sprintf(__('%s Categories', 'geodirectory'),$cpt_name) . "</option>";
2501
-            }
2502
-            $tax_change_output .= "</select>";
2503
-        }
2504
-
2505
-        if (!empty($b_terms)) {
2506
-            $terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms);// get the first array
2507
-            global $cat_count;//make global so we can change via function
2508
-            $cat_count = 0;
2509
-            ?>
2455
+	// prints the widget
2456
+	global $wpdb, $plugin_prefix, $geodir_post_category_str;
2457
+	extract($args, EXTR_SKIP);
2458
+
2459
+	echo $before_widget;
2460
+
2461
+	/** This filter is documented in geodirectory_widgets.php */
2462
+	$title = empty($instance['title']) ? __('Popular Categories', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2463
+
2464
+	$gd_post_type = geodir_get_current_posttype();
2465
+
2466
+	$category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15;
2467
+	$default_post_type = !empty($gd_post_type) ? $gd_post_type : (isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ? $instance['default_post_type'] : '');
2468
+
2469
+	$taxonomy = array();
2470
+	if (!empty($gd_post_type)) {
2471
+		$taxonomy[] = $gd_post_type . "category";
2472
+	} else {
2473
+		$default_post_type = geodir_get_posttypes()[0];
2474
+		$taxonomy = geodir_get_taxonomies($gd_post_type);
2475
+	}
2476
+
2477
+	$terms = get_terms($taxonomy);
2478
+	$a_terms = array();
2479
+	$b_terms = array();
2480
+
2481
+	foreach ($terms as $term) {
2482
+		if ($term->count > 0) {
2483
+			$a_terms[$term->taxonomy][] = $term;
2484
+		}
2485
+	}
2486
+
2487
+	if (!empty($a_terms)) {
2488
+		foreach ($a_terms as $b_key => $b_val) {
2489
+			$b_terms[$b_key] = geodir_sort_terms($b_val, 'count');
2490
+		}
2491
+
2492
+		$default_taxonomy = $default_post_type != '' && isset($b_terms[$default_post_type . 'category']) ? $default_post_type . 'category' : '';
2493
+
2494
+		$tax_change_output = '';
2495
+		if (count($b_terms) > 1) {
2496
+			$tax_change_output .= "<select data-limit='$category_limit' class='geodir-cat-list-tax'  onchange='geodir_get_post_term(this);'>";
2497
+			foreach ($b_terms as $key => $val) {
2498
+				$ptype = get_post_type_object(str_replace("category", "", $key));
2499
+				$cpt_name = __($ptype->labels->singular_name, 'geodirectory');
2500
+				$tax_change_output .= "<option value='$key' ". selected($key, $default_taxonomy, false) .">" . sprintf(__('%s Categories', 'geodirectory'),$cpt_name) . "</option>";
2501
+			}
2502
+			$tax_change_output .= "</select>";
2503
+		}
2504
+
2505
+		if (!empty($b_terms)) {
2506
+			$terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms);// get the first array
2507
+			global $cat_count;//make global so we can change via function
2508
+			$cat_count = 0;
2509
+			?>
2510 2510
             <div class="geodir-category-list-in clearfix">
2511 2511
                 <div class="geodir-cat-list clearfix">
2512 2512
                     <?php
2513
-                    echo $before_title . __($title) . $after_title;
2513
+					echo $before_title . __($title) . $after_title;
2514 2514
 
2515
-                    echo $tax_change_output;
2515
+					echo $tax_change_output;
2516 2516
 
2517
-                    echo '<ul class="geodir-popular-cat-list">';
2517
+					echo '<ul class="geodir-popular-cat-list">';
2518 2518
 
2519
-                    geodir_helper_cat_list_output($terms, $category_limit);
2519
+					geodir_helper_cat_list_output($terms, $category_limit);
2520 2520
 
2521
-                    echo '</ul>';
2522
-                    ?>
2521
+					echo '</ul>';
2522
+					?>
2523 2523
                 </div>
2524 2524
                 <?php
2525
-                $hide = '';
2526
-                if ($cat_count < $category_limit) {
2527
-                    $hide = 'style="display:none;"';
2528
-                }
2529
-                echo "<div class='geodir-cat-list-more' $hide >";
2530
-                echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">' . __('More Categories', 'geodirectory') . '</a>';
2531
-                echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">' . __('Less Categories', 'geodirectory') . '</a>';
2532
-                echo "</div>";
2533
-                /* add scripts */
2534
-                add_action('wp_footer', 'geodir_popular_category_add_scripts', 100);
2535
-                ?>
2525
+				$hide = '';
2526
+				if ($cat_count < $category_limit) {
2527
+					$hide = 'style="display:none;"';
2528
+				}
2529
+				echo "<div class='geodir-cat-list-more' $hide >";
2530
+				echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">' . __('More Categories', 'geodirectory') . '</a>';
2531
+				echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">' . __('Less Categories', 'geodirectory') . '</a>';
2532
+				echo "</div>";
2533
+				/* add scripts */
2534
+				add_action('wp_footer', 'geodir_popular_category_add_scripts', 100);
2535
+				?>
2536 2536
             </div>
2537 2537
         <?php
2538
-        }
2539
-    }
2540
-    echo $after_widget;
2538
+		}
2539
+	}
2540
+	echo $after_widget;
2541 2541
 }
2542 2542
 
2543 2543
 /**
@@ -2551,38 +2551,38 @@  discard block
 block discarded – undo
2551 2551
  */
2552 2552
 function geodir_helper_cat_list_output($terms, $category_limit)
2553 2553
 {
2554
-    global $geodir_post_category_str, $cat_count;
2555
-    $term_icons = geodir_get_term_icon();
2554
+	global $geodir_post_category_str, $cat_count;
2555
+	$term_icons = geodir_get_term_icon();
2556 2556
 
2557
-    $geodir_post_category_str = array();
2557
+	$geodir_post_category_str = array();
2558 2558
 
2559 2559
 
2560
-    foreach ($terms as $cat) {
2561
-        $post_type = str_replace("category", "", $cat->taxonomy);
2562
-        $term_icon_url = !empty($term_icons) && isset($term_icons[$cat->term_id]) ? $term_icons[$cat->term_id] : '';
2560
+	foreach ($terms as $cat) {
2561
+		$post_type = str_replace("category", "", $cat->taxonomy);
2562
+		$term_icon_url = !empty($term_icons) && isset($term_icons[$cat->term_id]) ? $term_icons[$cat->term_id] : '';
2563 2563
 
2564
-        $cat_count++;
2564
+		$cat_count++;
2565 2565
 
2566
-        $geodir_post_category_str[] = array('posttype' => $post_type, 'termid' => $cat->term_id);
2566
+		$geodir_post_category_str[] = array('posttype' => $post_type, 'termid' => $cat->term_id);
2567 2567
 
2568
-        $class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show';
2569
-        $total_post = $cat->count;
2568
+		$class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show';
2569
+		$total_post = $cat->count;
2570 2570
 
2571
-        $term_link = get_term_link( $cat, $cat->taxonomy );
2572
-        /**
2573
-         * Filer the category term link.
2574
-         *
2575
-         * @since 1.4.5
2576
-         * @param string $term_link The term permalink.
2577
-         * @param int    $cat->term_id The term id.
2578
-         * @param string $post_type Wordpress post type.
2579
-         */
2580
-        $term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type );
2571
+		$term_link = get_term_link( $cat, $cat->taxonomy );
2572
+		/**
2573
+		 * Filer the category term link.
2574
+		 *
2575
+		 * @since 1.4.5
2576
+		 * @param string $term_link The term permalink.
2577
+		 * @param int    $cat->term_id The term id.
2578
+		 * @param string $post_type Wordpress post type.
2579
+		 */
2580
+		$term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type );
2581 2581
 
2582
-        echo '<li class="' . $class_row . '"><a href="' . $term_link . '">';
2583
-        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> ';
2584
-        echo '</a></li>';
2585
-    }
2582
+		echo '<li class="' . $class_row . '"><a href="' . $term_link . '">';
2583
+		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> ';
2584
+		echo '</a></li>';
2585
+	}
2586 2586
 }
2587 2587
 
2588 2588
 /**
@@ -2596,108 +2596,108 @@  discard block
 block discarded – undo
2596 2596
  */
2597 2597
 function geodir_listing_slider_widget_output($args = '', $instance = '')
2598 2598
 {
2599
-    // prints the widget
2600
-    extract($args, EXTR_SKIP);
2601
-
2602
-    echo $before_widget;
2603
-
2604
-    /** This filter is documented in geodirectory_widgets.php */
2605
-    $title = empty($instance['title']) ? '' : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2606
-    /**
2607
-     * Filter the widget post type.
2608
-     *
2609
-     * @since 1.0.0
2610
-     * @param string $instance['post_type'] Post type of listing.
2611
-     */
2612
-    $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
2613
-    /**
2614
-     * Filter the widget's term.
2615
-     *
2616
-     * @since 1.0.0
2617
-     * @param string $instance['category'] Filter by term. Can be any valid term.
2618
-     */
2619
-    $category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
2620
-    /**
2621
-     * Filter the widget listings limit.
2622
-     *
2623
-     * @since 1.0.0
2624
-     * @param string $instance['post_number'] Number of listings to display.
2625
-     */
2626
-    $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
2627
-    /**
2628
-     * Filter the widget listings limit shown at one time.
2629
-     *
2630
-     * @since 1.5.0
2631
-     * @param string $instance['max_show'] Number of listings to display on screen.
2632
-     */
2633
-    $max_show = empty($instance['max_show']) ? '1' : apply_filters('widget_max_show', $instance['max_show']);
2634
-    /**
2635
-     * Filter the widget slide width.
2636
-     *
2637
-     * @since 1.5.0
2638
-     * @param string $instance['slide_width'] Width of the slides shown.
2639
-     */
2640
-    $slide_width = empty($instance['slide_width']) ? '' : apply_filters('widget_slide_width', $instance['slide_width']);
2641
-    /**
2642
-     * Filter widget's "show title" value.
2643
-     *
2644
-     * @since 1.0.0
2645
-     * @param string|bool $instance['show_title'] Do you want to display title? Can be 1 or 0.
2646
-     */
2647
-    $show_title = empty($instance['show_title']) ? '' : apply_filters('widget_show_title', $instance['show_title']);
2648
-    /**
2649
-     * Filter widget's "slideshow" value.
2650
-     *
2651
-     * @since 1.0.0
2652
-     * @param int $instance['slideshow'] Setup a slideshow for the slider to animate automatically.
2653
-     */
2654
-    $slideshow = empty($instance['slideshow']) ? 0 : apply_filters('widget_slideshow', $instance['slideshow']);
2655
-    /**
2656
-     * Filter widget's "animationLoop" value.
2657
-     *
2658
-     * @since 1.0.0
2659
-     * @param int $instance['animationLoop'] Gives the slider a seamless infinite loop.
2660
-     */
2661
-    $animationLoop = empty($instance['animationLoop']) ? 0 : apply_filters('widget_animationLoop', $instance['animationLoop']);
2662
-    /**
2663
-     * Filter widget's "directionNav" value.
2664
-     *
2665
-     * @since 1.0.0
2666
-     * @param int $instance['directionNav'] Enable previous/next arrow navigation?. Can be 1 or 0.
2667
-     */
2668
-    $directionNav = empty($instance['directionNav']) ? 0 : apply_filters('widget_directionNav', $instance['directionNav']);
2669
-    /**
2670
-     * Filter widget's "slideshowSpeed" value.
2671
-     *
2672
-     * @since 1.0.0
2673
-     * @param int $instance['slideshowSpeed'] Set the speed of the slideshow cycling, in milliseconds.
2674
-     */
2675
-    $slideshowSpeed = empty($instance['slideshowSpeed']) ? 5000 : apply_filters('widget_slideshowSpeed', $instance['slideshowSpeed']);
2676
-    /**
2677
-     * Filter widget's "animationSpeed" value.
2678
-     *
2679
-     * @since 1.0.0
2680
-     * @param int $instance['animationSpeed'] Set the speed of animations, in milliseconds.
2681
-     */
2682
-    $animationSpeed = empty($instance['animationSpeed']) ? 600 : apply_filters('widget_animationSpeed', $instance['animationSpeed']);
2683
-    /**
2684
-     * Filter widget's "animation" value.
2685
-     *
2686
-     * @since 1.0.0
2687
-     * @param string $instance['animation'] Controls the animation type, "fade" or "slide".
2688
-     */
2689
-    $animation = empty($instance['animation']) ? 'slide' : apply_filters('widget_animation', $instance['animation']);
2690
-    /**
2691
-     * Filter widget's "list_sort" type.
2692
-     *
2693
-     * @since 1.0.0
2694
-     * @param string $instance['list_sort'] Listing sort by type.
2695
-     */
2696
-    $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
2697
-    $show_featured_only = !empty($instance['show_featured_only']) ? 1 : NULL;
2698
-
2699
-    wp_enqueue_script('geodirectory-jquery-flexslider-js');
2700
-    ?>
2599
+	// prints the widget
2600
+	extract($args, EXTR_SKIP);
2601
+
2602
+	echo $before_widget;
2603
+
2604
+	/** This filter is documented in geodirectory_widgets.php */
2605
+	$title = empty($instance['title']) ? '' : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2606
+	/**
2607
+	 * Filter the widget post type.
2608
+	 *
2609
+	 * @since 1.0.0
2610
+	 * @param string $instance['post_type'] Post type of listing.
2611
+	 */
2612
+	$post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
2613
+	/**
2614
+	 * Filter the widget's term.
2615
+	 *
2616
+	 * @since 1.0.0
2617
+	 * @param string $instance['category'] Filter by term. Can be any valid term.
2618
+	 */
2619
+	$category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
2620
+	/**
2621
+	 * Filter the widget listings limit.
2622
+	 *
2623
+	 * @since 1.0.0
2624
+	 * @param string $instance['post_number'] Number of listings to display.
2625
+	 */
2626
+	$post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
2627
+	/**
2628
+	 * Filter the widget listings limit shown at one time.
2629
+	 *
2630
+	 * @since 1.5.0
2631
+	 * @param string $instance['max_show'] Number of listings to display on screen.
2632
+	 */
2633
+	$max_show = empty($instance['max_show']) ? '1' : apply_filters('widget_max_show', $instance['max_show']);
2634
+	/**
2635
+	 * Filter the widget slide width.
2636
+	 *
2637
+	 * @since 1.5.0
2638
+	 * @param string $instance['slide_width'] Width of the slides shown.
2639
+	 */
2640
+	$slide_width = empty($instance['slide_width']) ? '' : apply_filters('widget_slide_width', $instance['slide_width']);
2641
+	/**
2642
+	 * Filter widget's "show title" value.
2643
+	 *
2644
+	 * @since 1.0.0
2645
+	 * @param string|bool $instance['show_title'] Do you want to display title? Can be 1 or 0.
2646
+	 */
2647
+	$show_title = empty($instance['show_title']) ? '' : apply_filters('widget_show_title', $instance['show_title']);
2648
+	/**
2649
+	 * Filter widget's "slideshow" value.
2650
+	 *
2651
+	 * @since 1.0.0
2652
+	 * @param int $instance['slideshow'] Setup a slideshow for the slider to animate automatically.
2653
+	 */
2654
+	$slideshow = empty($instance['slideshow']) ? 0 : apply_filters('widget_slideshow', $instance['slideshow']);
2655
+	/**
2656
+	 * Filter widget's "animationLoop" value.
2657
+	 *
2658
+	 * @since 1.0.0
2659
+	 * @param int $instance['animationLoop'] Gives the slider a seamless infinite loop.
2660
+	 */
2661
+	$animationLoop = empty($instance['animationLoop']) ? 0 : apply_filters('widget_animationLoop', $instance['animationLoop']);
2662
+	/**
2663
+	 * Filter widget's "directionNav" value.
2664
+	 *
2665
+	 * @since 1.0.0
2666
+	 * @param int $instance['directionNav'] Enable previous/next arrow navigation?. Can be 1 or 0.
2667
+	 */
2668
+	$directionNav = empty($instance['directionNav']) ? 0 : apply_filters('widget_directionNav', $instance['directionNav']);
2669
+	/**
2670
+	 * Filter widget's "slideshowSpeed" value.
2671
+	 *
2672
+	 * @since 1.0.0
2673
+	 * @param int $instance['slideshowSpeed'] Set the speed of the slideshow cycling, in milliseconds.
2674
+	 */
2675
+	$slideshowSpeed = empty($instance['slideshowSpeed']) ? 5000 : apply_filters('widget_slideshowSpeed', $instance['slideshowSpeed']);
2676
+	/**
2677
+	 * Filter widget's "animationSpeed" value.
2678
+	 *
2679
+	 * @since 1.0.0
2680
+	 * @param int $instance['animationSpeed'] Set the speed of animations, in milliseconds.
2681
+	 */
2682
+	$animationSpeed = empty($instance['animationSpeed']) ? 600 : apply_filters('widget_animationSpeed', $instance['animationSpeed']);
2683
+	/**
2684
+	 * Filter widget's "animation" value.
2685
+	 *
2686
+	 * @since 1.0.0
2687
+	 * @param string $instance['animation'] Controls the animation type, "fade" or "slide".
2688
+	 */
2689
+	$animation = empty($instance['animation']) ? 'slide' : apply_filters('widget_animation', $instance['animation']);
2690
+	/**
2691
+	 * Filter widget's "list_sort" type.
2692
+	 *
2693
+	 * @since 1.0.0
2694
+	 * @param string $instance['list_sort'] Listing sort by type.
2695
+	 */
2696
+	$list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
2697
+	$show_featured_only = !empty($instance['show_featured_only']) ? 1 : NULL;
2698
+
2699
+	wp_enqueue_script('geodirectory-jquery-flexslider-js');
2700
+	?>
2701 2701
     <script type="text/javascript">
2702 2702
         jQuery(window).load(function () {
2703 2703
             jQuery('#geodir_widget_carousel').flexslider({
@@ -2738,86 +2738,86 @@  discard block
 block discarded – undo
2738 2738
         });
2739 2739
     </script>
2740 2740
     <?php
2741
-    $query_args = array(
2742
-        'posts_per_page' => $post_number,
2743
-        'is_geodir_loop' => true,
2744
-        'post_type' => $post_type,
2745
-        'order_by' => $list_sort
2746
-    );
2747
-    if ($show_featured_only) {
2748
-        $query_args['show_featured_only'] = 1;
2749
-    }
2750
-
2751
-    if ($category != 0 || $category != '') {
2752
-        $category_taxonomy = geodir_get_taxonomies($post_type);
2753
-        $tax_query = array(
2754
-            'taxonomy' => $category_taxonomy[0],
2755
-            'field' => 'id',
2756
-            'terms' => $category
2757
-        );
2758
-
2759
-        $query_args['tax_query'] = array($tax_query);
2760
-    }
2761
-
2762
-    // we want listings with featured image only
2763
-    $query_args['featured_image_only'] = 1;
2764
-
2765
-    if ($post_type == 'gd_event') {
2766
-        $query_args['gedir_event_listing_filter'] = 'upcoming';
2767
-    }// show only upcomming events
2768
-
2769
-    $widget_listings = geodir_get_widget_listings($query_args);
2770
-    if (!empty($widget_listings) || (isset($with_no_results) && $with_no_results)) {
2771
-        if ($title) {
2772
-            echo $before_title . $title . $after_title;
2773
-        }
2774
-
2775
-        global $post;
2776
-
2777
-        $current_post = $post;// keep current post info
2778
-
2779
-        $widget_main_slides = '';
2780
-        $nav_slides = '';
2781
-        $widget_slides = 0;
2782
-
2783
-        foreach ($widget_listings as $widget_listing) {
2784
-            global $gd_widget_listing_type;
2785
-            $post = $widget_listing;
2786
-            $widget_image = geodir_get_featured_image($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
2787
-
2788
-            if (!empty($widget_image)) {
2789
-                if ($widget_image->height >= 200) {
2790
-                    $widget_spacer_height = 0;
2791
-                } else {
2792
-                    $widget_spacer_height = ((200 - $widget_image->height) / 2);
2793
-                }
2794
-
2795
-                $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" />';
2796
-
2797
-                $title = '';
2798
-                if ($show_title) {
2799
-                    $title_html = '<div class="geodir-slider-title"><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a></div>';
2800
-                    $post_id = $post->ID;
2801
-                    $post_permalink = get_permalink($post->ID);
2802
-                    $post_title = get_the_title($post->ID);
2803
-                    /**
2804
-                     * Filter the listing slider widget title.
2805
-                     *
2806
-                     * @since 1.6.1
2807
-                     * @param string $title_html The html output of the title.
2808
-                     * @param int $post_id The post id.
2809
-                     * @param string $post_permalink The post permalink url.
2810
-                     * @param string $post_title The post title text.
2811
-                     */
2812
-                    $title = apply_filters('geodir_listing_slider_title',$title_html,$post_id,$post_permalink,$post_title);
2813
-                }
2814
-
2815
-                $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>';
2816
-                $nav_slides .= '<li><img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:48px;margin:0 auto;" /></li>';
2817
-                $widget_slides++;
2818
-            }
2819
-        }
2820
-        ?>
2741
+	$query_args = array(
2742
+		'posts_per_page' => $post_number,
2743
+		'is_geodir_loop' => true,
2744
+		'post_type' => $post_type,
2745
+		'order_by' => $list_sort
2746
+	);
2747
+	if ($show_featured_only) {
2748
+		$query_args['show_featured_only'] = 1;
2749
+	}
2750
+
2751
+	if ($category != 0 || $category != '') {
2752
+		$category_taxonomy = geodir_get_taxonomies($post_type);
2753
+		$tax_query = array(
2754
+			'taxonomy' => $category_taxonomy[0],
2755
+			'field' => 'id',
2756
+			'terms' => $category
2757
+		);
2758
+
2759
+		$query_args['tax_query'] = array($tax_query);
2760
+	}
2761
+
2762
+	// we want listings with featured image only
2763
+	$query_args['featured_image_only'] = 1;
2764
+
2765
+	if ($post_type == 'gd_event') {
2766
+		$query_args['gedir_event_listing_filter'] = 'upcoming';
2767
+	}// show only upcomming events
2768
+
2769
+	$widget_listings = geodir_get_widget_listings($query_args);
2770
+	if (!empty($widget_listings) || (isset($with_no_results) && $with_no_results)) {
2771
+		if ($title) {
2772
+			echo $before_title . $title . $after_title;
2773
+		}
2774
+
2775
+		global $post;
2776
+
2777
+		$current_post = $post;// keep current post info
2778
+
2779
+		$widget_main_slides = '';
2780
+		$nav_slides = '';
2781
+		$widget_slides = 0;
2782
+
2783
+		foreach ($widget_listings as $widget_listing) {
2784
+			global $gd_widget_listing_type;
2785
+			$post = $widget_listing;
2786
+			$widget_image = geodir_get_featured_image($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
2787
+
2788
+			if (!empty($widget_image)) {
2789
+				if ($widget_image->height >= 200) {
2790
+					$widget_spacer_height = 0;
2791
+				} else {
2792
+					$widget_spacer_height = ((200 - $widget_image->height) / 2);
2793
+				}
2794
+
2795
+				$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" />';
2796
+
2797
+				$title = '';
2798
+				if ($show_title) {
2799
+					$title_html = '<div class="geodir-slider-title"><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a></div>';
2800
+					$post_id = $post->ID;
2801
+					$post_permalink = get_permalink($post->ID);
2802
+					$post_title = get_the_title($post->ID);
2803
+					/**
2804
+					 * Filter the listing slider widget title.
2805
+					 *
2806
+					 * @since 1.6.1
2807
+					 * @param string $title_html The html output of the title.
2808
+					 * @param int $post_id The post id.
2809
+					 * @param string $post_permalink The post permalink url.
2810
+					 * @param string $post_title The post title text.
2811
+					 */
2812
+					$title = apply_filters('geodir_listing_slider_title',$title_html,$post_id,$post_permalink,$post_title);
2813
+				}
2814
+
2815
+				$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>';
2816
+				$nav_slides .= '<li><img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:48px;margin:0 auto;" /></li>';
2817
+				$widget_slides++;
2818
+			}
2819
+		}
2820
+		?>
2821 2821
         <div class="flex-container" style="min-height:200px;">
2822 2822
             <div class="geodir-listing-flex-loader"><i class="fa fa-refresh fa-spin"></i></div>
2823 2823
             <div id="geodir_widget_slider" class="geodir_flexslider">
@@ -2830,10 +2830,10 @@  discard block
 block discarded – undo
2830 2830
             <?php } ?>
2831 2831
         </div>
2832 2832
         <?php
2833
-        $GLOBALS['post'] = $current_post;
2834
-        setup_postdata($current_post);
2835
-    }
2836
-    echo $after_widget;
2833
+		$GLOBALS['post'] = $current_post;
2834
+		setup_postdata($current_post);
2835
+	}
2836
+	echo $after_widget;
2837 2837
 }
2838 2838
 
2839 2839
 
@@ -2848,65 +2848,65 @@  discard block
 block discarded – undo
2848 2848
  */
2849 2849
 function geodir_loginwidget_output($args = '', $instance = '')
2850 2850
 {
2851
-    //print_r($args);
2852
-    //print_r($instance);
2853
-    // prints the widget
2854
-    extract($args, EXTR_SKIP);
2851
+	//print_r($args);
2852
+	//print_r($instance);
2853
+	// prints the widget
2854
+	extract($args, EXTR_SKIP);
2855 2855
 
2856
-    /** This filter is documented in geodirectory_widgets.php */
2857
-    $title = empty($instance['title']) ? __('My Dashboard', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2856
+	/** This filter is documented in geodirectory_widgets.php */
2857
+	$title = empty($instance['title']) ? __('My Dashboard', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
2858 2858
 
2859
-    echo $before_widget;
2860
-    echo $before_title . $title . $after_title;
2859
+	echo $before_widget;
2860
+	echo $before_title . $title . $after_title;
2861 2861
 
2862
-    if (is_user_logged_in()) {
2863
-        global $current_user;
2862
+	if (is_user_logged_in()) {
2863
+		global $current_user;
2864 2864
 
2865
-        $author_link = get_author_posts_url($current_user->data->ID);
2866
-        $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false);
2865
+		$author_link = get_author_posts_url($current_user->data->ID);
2866
+		$author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false);
2867 2867
 
2868
-        echo '<ul class="geodir-loginbox-list">';
2869
-        ob_start();
2870
-        ?>
2868
+		echo '<ul class="geodir-loginbox-list">';
2869
+		ob_start();
2870
+		?>
2871 2871
         <li><a class="signin"
2872 2872
                href="<?php echo wp_logout_url(home_url()); ?>"><?php _e('Logout', 'geodirectory'); ?></a></li>
2873 2873
         <?php
2874
-        $post_types = geodir_get_posttypes('object');
2875
-        $show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_user_dashboard');
2876
-        $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
2874
+		$post_types = geodir_get_posttypes('object');
2875
+		$show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_user_dashboard');
2876
+		$geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
2877 2877
 
2878
-        if (!empty($show_add_listing_post_types_main_nav)) {
2879
-            $addlisting_links = '';
2880
-            foreach ($post_types as $key => $postobj) {
2878
+		if (!empty($show_add_listing_post_types_main_nav)) {
2879
+			$addlisting_links = '';
2880
+			foreach ($post_types as $key => $postobj) {
2881 2881
 
2882
-                if (in_array($key, $show_add_listing_post_types_main_nav)) {
2882
+				if (in_array($key, $show_add_listing_post_types_main_nav)) {
2883 2883
 
2884
-                    if ($add_link = geodir_get_addlisting_link($key)) {
2884
+					if ($add_link = geodir_get_addlisting_link($key)) {
2885 2885
 
2886
-                        $name = $postobj->labels->name;
2886
+						$name = $postobj->labels->name;
2887 2887
 
2888
-                        $selected = '';
2889
-                        if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing'))
2890
-                            $selected = 'selected="selected"';
2888
+						$selected = '';
2889
+						if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing'))
2890
+							$selected = 'selected="selected"';
2891 2891
 
2892
-                        /**
2893
-                         * Filter add listing link.
2894
-                         *
2895
-                         * @since 1.0.0
2896
-                         * @param string $add_link Add listing link.
2897
-                         * @param string $key Add listing array key.
2898
-                         * @param int $current_user->ID Current user ID.
2899
-                         */
2900
-                        $add_link = apply_filters('geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID);
2892
+						/**
2893
+						 * Filter add listing link.
2894
+						 *
2895
+						 * @since 1.0.0
2896
+						 * @param string $add_link Add listing link.
2897
+						 * @param string $key Add listing array key.
2898
+						 * @param int $current_user->ID Current user ID.
2899
+						 */
2900
+						$add_link = apply_filters('geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID);
2901 2901
 
2902
-                        $addlisting_links .= '<option ' . $selected . ' value="' . $add_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2902
+						$addlisting_links .= '<option ' . $selected . ' value="' . $add_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2903 2903
 
2904
-                    }
2905
-                }
2904
+					}
2905
+				}
2906 2906
 
2907
-            }
2907
+			}
2908 2908
 
2909
-            if ($addlisting_links != '') { ?>
2909
+			if ($addlisting_links != '') { ?>
2910 2910
 
2911 2911
                 <li><select id="geodir_add_listing" class="chosen_select" onchange="window.location.href=this.value"
2912 2912
                             option-autoredirect="1" name="geodir_add_listing" option-ajaxchosen="false"
@@ -2915,42 +2915,42 @@  discard block
 block discarded – undo
2915 2915
                         <?php echo $addlisting_links; ?>
2916 2916
                     </select></li> <?php
2917 2917
 
2918
-            }
2919
-
2920
-        }
2921
-        // My Favourites in Dashboard
2922
-        $show_favorite_link_user_dashboard = get_option('geodir_favorite_link_user_dashboard');
2923
-        $user_favourite = geodir_user_favourite_listing_count();
2924
-
2925
-        if (!empty($show_favorite_link_user_dashboard) && !empty($user_favourite)) {
2926
-            $favourite_links = '';
2927
-
2928
-            foreach ($post_types as $key => $postobj) {
2929
-                if (in_array($key, $show_favorite_link_user_dashboard) && array_key_exists($key, $user_favourite)) {
2930
-                    $name = $postobj->labels->name;
2931
-                    $post_type_link = geodir_getlink($author_link, array('stype' => $key, 'list' => 'favourite'), false);
2932
-
2933
-                    $selected = '';
2934
-
2935
-                    if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key && isset($_REQUEST['geodir_dashbord'])) {
2936
-                        $selected = 'selected="selected"';
2937
-                    }
2938
-                    /**
2939
-                     * Filter favorite listing link.
2940
-                     *
2941
-                     * @since 1.0.0
2942
-                     * @param string $post_type_link Favorite listing link.
2943
-                     * @param string $key Favorite listing array key.
2944
-                     * @param int $current_user->ID Current user ID.
2945
-                     */
2946
-                    $post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID);
2947
-
2948
-                    $favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2949
-                }
2950
-            }
2951
-
2952
-            if ($favourite_links != '') {
2953
-                ?>
2918
+			}
2919
+
2920
+		}
2921
+		// My Favourites in Dashboard
2922
+		$show_favorite_link_user_dashboard = get_option('geodir_favorite_link_user_dashboard');
2923
+		$user_favourite = geodir_user_favourite_listing_count();
2924
+
2925
+		if (!empty($show_favorite_link_user_dashboard) && !empty($user_favourite)) {
2926
+			$favourite_links = '';
2927
+
2928
+			foreach ($post_types as $key => $postobj) {
2929
+				if (in_array($key, $show_favorite_link_user_dashboard) && array_key_exists($key, $user_favourite)) {
2930
+					$name = $postobj->labels->name;
2931
+					$post_type_link = geodir_getlink($author_link, array('stype' => $key, 'list' => 'favourite'), false);
2932
+
2933
+					$selected = '';
2934
+
2935
+					if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key && isset($_REQUEST['geodir_dashbord'])) {
2936
+						$selected = 'selected="selected"';
2937
+					}
2938
+					/**
2939
+					 * Filter favorite listing link.
2940
+					 *
2941
+					 * @since 1.0.0
2942
+					 * @param string $post_type_link Favorite listing link.
2943
+					 * @param string $key Favorite listing array key.
2944
+					 * @param int $current_user->ID Current user ID.
2945
+					 */
2946
+					$post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID);
2947
+
2948
+					$favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2949
+				}
2950
+			}
2951
+
2952
+			if ($favourite_links != '') {
2953
+				?>
2954 2954
                 <li>
2955 2955
                     <select id="geodir_my_favourites" class="chosen_select" onchange="window.location.href=this.value"
2956 2956
                             option-autoredirect="1" name="geodir_my_favourites" option-ajaxchosen="false"
@@ -2960,42 +2960,42 @@  discard block
 block discarded – undo
2960 2960
                     </select>
2961 2961
                 </li>
2962 2962
             <?php
2963
-            }
2964
-        }
2965
-
2966
-
2967
-        $show_listing_link_user_dashboard = get_option('geodir_listing_link_user_dashboard');
2968
-        $user_listing = geodir_user_post_listing_count();
2969
-
2970
-        if (!empty($show_listing_link_user_dashboard) && !empty($user_listing)) {
2971
-            $listing_links = '';
2972
-
2973
-            foreach ($post_types as $key => $postobj) {
2974
-                if (in_array($key, $show_listing_link_user_dashboard) && array_key_exists($key, $user_listing)) {
2975
-                    $name = $postobj->labels->name;
2976
-                    $listing_link = geodir_getlink($author_link, array('stype' => $key), false);
2977
-
2978
-                    $selected = '';
2979
-                    if (!isset($_REQUEST['list']) && isset($_REQUEST['geodir_dashbord']) && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key) {
2980
-                        $selected = 'selected="selected"';
2981
-                    }
2982
-
2983
-                    /**
2984
-                     * Filter my listing link.
2985
-                     *
2986
-                     * @since 1.0.0
2987
-                     * @param string $listing_link My listing link.
2988
-                     * @param string $key My listing array key.
2989
-                     * @param int $current_user->ID Current user ID.
2990
-                     */
2991
-                    $listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID);
2992
-
2993
-                    $listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2994
-                }
2995
-            }
2996
-
2997
-            if ($listing_links != '') {
2998
-                ?>
2963
+			}
2964
+		}
2965
+
2966
+
2967
+		$show_listing_link_user_dashboard = get_option('geodir_listing_link_user_dashboard');
2968
+		$user_listing = geodir_user_post_listing_count();
2969
+
2970
+		if (!empty($show_listing_link_user_dashboard) && !empty($user_listing)) {
2971
+			$listing_links = '';
2972
+
2973
+			foreach ($post_types as $key => $postobj) {
2974
+				if (in_array($key, $show_listing_link_user_dashboard) && array_key_exists($key, $user_listing)) {
2975
+					$name = $postobj->labels->name;
2976
+					$listing_link = geodir_getlink($author_link, array('stype' => $key), false);
2977
+
2978
+					$selected = '';
2979
+					if (!isset($_REQUEST['list']) && isset($_REQUEST['geodir_dashbord']) && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key) {
2980
+						$selected = 'selected="selected"';
2981
+					}
2982
+
2983
+					/**
2984
+					 * Filter my listing link.
2985
+					 *
2986
+					 * @since 1.0.0
2987
+					 * @param string $listing_link My listing link.
2988
+					 * @param string $key My listing array key.
2989
+					 * @param int $current_user->ID Current user ID.
2990
+					 */
2991
+					$listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID);
2992
+
2993
+					$listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>';
2994
+				}
2995
+			}
2996
+
2997
+			if ($listing_links != '') {
2998
+				?>
2999 2999
                 <li>
3000 3000
                     <select id="geodir_my_listings" class="chosen_select" onchange="window.location.href=this.value"
3001 3001
                             option-autoredirect="1" name="geodir_my_listings" option-ajaxchosen="false"
@@ -3005,27 +3005,27 @@  discard block
 block discarded – undo
3005 3005
                     </select>
3006 3006
                 </li>
3007 3007
             <?php
3008
-            }
3009
-        }
3010
-
3011
-        $dashboard_link = ob_get_clean();
3012
-        /**
3013
-         * Filter dashboard links HTML.
3014
-         *
3015
-         * @since 1.0.0
3016
-         * @param string $dashboard_link Dashboard links HTML.
3017
-         */
3018
-        echo apply_filters('geodir_dashboard_links', $dashboard_link);
3019
-        echo '</ul>';
3020
-    } else {
3021
-        ?>
3008
+			}
3009
+		}
3010
+
3011
+		$dashboard_link = ob_get_clean();
3012
+		/**
3013
+		 * Filter dashboard links HTML.
3014
+		 *
3015
+		 * @since 1.0.0
3016
+		 * @param string $dashboard_link Dashboard links HTML.
3017
+		 */
3018
+		echo apply_filters('geodir_dashboard_links', $dashboard_link);
3019
+		echo '</ul>';
3020
+	} else {
3021
+		?>
3022 3022
         <?php
3023
-        /**
3024
-         * Filter signup form action link.
3025
-         *
3026
-         * @since 1.0.0
3027
-         */
3028
-        ?>
3023
+		/**
3024
+		 * Filter signup form action link.
3025
+		 *
3026
+		 * @since 1.0.0
3027
+		 */
3028
+		?>
3029 3029
         <form name="loginform" class="loginform1"
3030 3030
               action="<?php echo geodir_login_url(); ?>"
3031 3031
               method="post">
@@ -3045,28 +3045,28 @@  discard block
 block discarded – undo
3045 3045
 
3046 3046
                 <p class="geodir-new-forgot-link">
3047 3047
                     <?php
3048
-                    /**
3049
-                     * Filter signup page register form link.
3050
-                     *
3051
-                     * @since 1.0.0
3052
-                     */
3053
-                    ?>
3048
+					/**
3049
+					 * Filter signup page register form link.
3050
+					 *
3051
+					 * @since 1.0.0
3052
+					 */
3053
+					?>
3054 3054
                     <a href="<?php echo geodir_login_url(array('signup' => true)); ?>"
3055 3055
                        class="goedir-newuser-link"><?php echo NEW_USER_TEXT; ?></a>
3056 3056
 
3057 3057
                     <?php
3058
-                    /**
3059
-                     * Filter signup page forgot password form link.
3060
-                     *
3061
-                     * @since 1.0.0
3062
-                     */
3063
-                    ?>
3058
+					/**
3059
+					 * Filter signup page forgot password form link.
3060
+					 *
3061
+					 * @since 1.0.0
3062
+					 */
3063
+					?>
3064 3064
                     <a href="<?php echo geodir_login_url(array('forgot' => true)); ?>"
3065 3065
                        class="goedir-forgot-link"><?php echo FORGOT_PW_TEXT; ?></a></p></div>
3066 3066
         </form>
3067 3067
     <?php }
3068 3068
 
3069
-    echo $after_widget;
3069
+	echo $after_widget;
3070 3070
 }
3071 3071
 
3072 3072
 
@@ -3085,284 +3085,284 @@  discard block
 block discarded – undo
3085 3085
  * @param array|string $instance The settings for the particular instance of the widget.
3086 3086
  */
3087 3087
 function geodir_popular_postview_output($args = '', $instance = '') {
3088
-    global $gd_session;
3088
+	global $gd_session;
3089 3089
 	
3090
-    // prints the widget
3091
-    extract($args, EXTR_SKIP);
3092
-
3093
-    echo $before_widget;
3094
-
3095
-    /** This filter is documented in geodirectory_widgets.php */
3096
-    $title = empty($instance['title']) ? geodir_ucwords($instance['category_title']) : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
3097
-    /**
3098
-     * Filter the widget post type.
3099
-     *
3100
-     * @since 1.0.0
3101
-     * @param string $instance['post_type'] Post type of listing.
3102
-     */
3103
-    $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
3104
-    /**
3105
-     * Filter the widget's term.
3106
-     *
3107
-     * @since 1.0.0
3108
-     * @param string $instance['category'] Filter by term. Can be any valid term.
3109
-     */
3110
-    $category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
3111
-    /**
3112
-     * Filter the widget listings limit.
3113
-     *
3114
-     * @since 1.0.0
3115
-     * @param string $instance['post_number'] Number of listings to display.
3116
-     */
3117
-    $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
3118
-    /**
3119
-     * Filter widget's "layout" type.
3120
-     *
3121
-     * @since 1.0.0
3122
-     * @param string $instance['layout'] Widget layout type.
3123
-     */
3124
-    $layout = empty($instance['layout']) ? 'gridview_onehalf' : apply_filters('widget_layout', $instance['layout']);
3125
-    /**
3126
-     * Filter widget's "add_location_filter" value.
3127
-     *
3128
-     * @since 1.0.0
3129
-     * @param string|bool $instance['add_location_filter'] Do you want to add location filter? Can be 1 or 0.
3130
-     */
3131
-    $add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_add_location_filter', $instance['add_location_filter']);
3132
-    /**
3133
-     * Filter widget's listing width.
3134
-     *
3135
-     * @since 1.0.0
3136
-     * @param string $instance['listing_width'] Listing width.
3137
-     */
3138
-    $listing_width = empty($instance['listing_width']) ? '' : apply_filters('widget_listing_width', $instance['listing_width']);
3139
-    /**
3140
-     * Filter widget's "list_sort" type.
3141
-     *
3142
-     * @since 1.0.0
3143
-     * @param string $instance['list_sort'] Listing sort by type.
3144
-     */
3145
-    $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
3146
-    $use_viewing_post_type = !empty($instance['use_viewing_post_type']) ? true : false;
3147
-
3148
-    // set post type to current viewing post type
3149
-    if ($use_viewing_post_type) {
3150
-        $current_post_type = geodir_get_current_posttype();
3151
-        if ($current_post_type != '' && $current_post_type != $post_type) {
3152
-            $post_type = $current_post_type;
3153
-            $category = array(); // old post type category will not work for current changed post type
3154
-        }
3155
-    }
3156
-    // replace widget title dynamically
3157
-    $posttype_plural_label = __(get_post_type_plural_label($post_type), 'geodirectory');
3158
-    $posttype_singular_label = __(get_post_type_singular_label($post_type), 'geodirectory');
3159
-
3160
-    $title = str_replace("%posttype_plural_label%", $posttype_plural_label, $title);
3161
-    $title = str_replace("%posttype_singular_label%", $posttype_singular_label, $title);
3162
-
3163
-    if (isset($instance['character_count'])) {
3164
-        /**
3165
-         * Filter the widget's excerpt character count.
3166
-         *
3167
-         * @since 1.0.0
3168
-         * @param int $instance['character_count'] Excerpt character count.
3169
-         */
3170
-        $character_count = apply_filters('widget_list_character_count', $instance['character_count']);
3171
-    } else {
3172
-        $character_count = '';
3173
-    }
3174
-
3175
-    if (empty($title) || $title == 'All') {
3176
-        $title .= ' ' . __(get_post_type_plural_label($post_type), 'geodirectory');
3177
-    }
3178
-
3179
-    $location_url = array();
3180
-    $city = get_query_var('gd_city');
3181
-    if (!empty($city)) {
3182
-        $country = get_query_var('gd_country');
3183
-        $region = get_query_var('gd_region');
3184
-
3185
-        $geodir_show_location_url = get_option('geodir_show_location_url');
3186
-
3187
-        if ($geodir_show_location_url == 'all') {
3188
-            if ($country != '') {
3189
-                $location_url[] = $country;
3190
-            }
3191
-
3192
-            if ($region != '') {
3193
-                $location_url[] = $region;
3194
-            }
3195
-        } else if ($geodir_show_location_url == 'country_city') {
3196
-            if ($country != '') {
3197
-                $location_url[] = $country;
3198
-            }
3199
-        } else if ($geodir_show_location_url == 'region_city') {
3200
-            if ($region != '') {
3201
-                $location_url[] = $region;
3202
-            }
3203
-        }
3204
-
3205
-        $location_url[] = $city;
3206
-    }
3207
-
3208
-    $location_url = implode('/', $location_url);
3209
-    $skip_location = false;
3210
-    if (!$add_location_filter && $gd_session->get('gd_multi_location')) {
3211
-        $skip_location = true;
3212
-        $gd_session->un_set('gd_multi_location');
3213
-    }
3214
-
3215
-    if (get_option('permalink_structure')) {
3216
-        $viewall_url = get_post_type_archive_link($post_type);
3217
-    } else {
3218
-        $viewall_url = get_post_type_archive_link($post_type);
3219
-    }
3220
-
3221
-    if (!empty($category) && $category[0] != '0') {
3222
-        global $geodir_add_location_url;
3223
-
3224
-        $geodir_add_location_url = '0';
3225
-
3226
-        if ($add_location_filter != '0') {
3227
-            $geodir_add_location_url = '1';
3228
-        }
3229
-
3230
-        $viewall_url = get_term_link((int)$category[0], $post_type . 'category');
3231
-
3232
-        $geodir_add_location_url = NULL;
3233
-    }
3234
-    if ($skip_location) {
3235
-        $gd_session->set('gd_multi_location', 1);
3236
-    }
3237
-
3238
-    if(is_wp_error( $viewall_url  )){$viewall_url = '';}
3239
-
3240
-    $query_args = array(
3241
-        'posts_per_page' => $post_number,
3242
-        'is_geodir_loop' => true,
3243
-        'gd_location' => $add_location_filter ? true : false,
3244
-        'post_type' => $post_type,
3245
-        'order_by' => $list_sort
3246
-    );
3247
-
3248
-    if ($character_count) {
3249
-        $query_args['excerpt_length'] = $character_count;
3250
-    }
3251
-
3252
-    if (!empty($instance['show_featured_only'])) {
3253
-        $query_args['show_featured_only'] = 1;
3254
-    }
3255
-
3256
-    if (!empty($instance['show_special_only'])) {
3257
-        $query_args['show_special_only'] = 1;
3258
-    }
3259
-
3260
-    if (!empty($instance['with_pics_only'])) {
3261
-        $query_args['with_pics_only'] = 0;
3262
-        $query_args['featured_image_only'] = 1;
3263
-    }
3264
-
3265
-    if (!empty($instance['with_videos_only'])) {
3266
-        $query_args['with_videos_only'] = 1;
3267
-    }
3268
-    $with_no_results = !empty($instance['without_no_results']) ? false : true;
3269
-
3270
-    if (!empty($category) && $category[0] != '0') {
3271
-        $category_taxonomy = geodir_get_taxonomies($post_type);
3272
-
3273
-        ######### WPML #########
3274
-        if (function_exists('icl_object_id')) {
3275
-            $category = gd_lang_object_ids($category, $category_taxonomy[0]);
3276
-        }
3277
-        ######### WPML #########
3278
-
3279
-        $tax_query = array(
3280
-            'taxonomy' => $category_taxonomy[0],
3281
-            'field' => 'id',
3282
-            'terms' => $category
3283
-        );
3284
-
3285
-        $query_args['tax_query'] = array($tax_query);
3286
-    }
3287
-
3288
-    global $gridview_columns_widget, $geodir_is_widget_listing;
3289
-
3290
-    $widget_listings = geodir_get_widget_listings($query_args);
3291
-
3292
-    if (!empty($widget_listings) || $with_no_results) {
3293
-        ?>
3090
+	// prints the widget
3091
+	extract($args, EXTR_SKIP);
3092
+
3093
+	echo $before_widget;
3094
+
3095
+	/** This filter is documented in geodirectory_widgets.php */
3096
+	$title = empty($instance['title']) ? geodir_ucwords($instance['category_title']) : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
3097
+	/**
3098
+	 * Filter the widget post type.
3099
+	 *
3100
+	 * @since 1.0.0
3101
+	 * @param string $instance['post_type'] Post type of listing.
3102
+	 */
3103
+	$post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
3104
+	/**
3105
+	 * Filter the widget's term.
3106
+	 *
3107
+	 * @since 1.0.0
3108
+	 * @param string $instance['category'] Filter by term. Can be any valid term.
3109
+	 */
3110
+	$category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
3111
+	/**
3112
+	 * Filter the widget listings limit.
3113
+	 *
3114
+	 * @since 1.0.0
3115
+	 * @param string $instance['post_number'] Number of listings to display.
3116
+	 */
3117
+	$post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
3118
+	/**
3119
+	 * Filter widget's "layout" type.
3120
+	 *
3121
+	 * @since 1.0.0
3122
+	 * @param string $instance['layout'] Widget layout type.
3123
+	 */
3124
+	$layout = empty($instance['layout']) ? 'gridview_onehalf' : apply_filters('widget_layout', $instance['layout']);
3125
+	/**
3126
+	 * Filter widget's "add_location_filter" value.
3127
+	 *
3128
+	 * @since 1.0.0
3129
+	 * @param string|bool $instance['add_location_filter'] Do you want to add location filter? Can be 1 or 0.
3130
+	 */
3131
+	$add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_add_location_filter', $instance['add_location_filter']);
3132
+	/**
3133
+	 * Filter widget's listing width.
3134
+	 *
3135
+	 * @since 1.0.0
3136
+	 * @param string $instance['listing_width'] Listing width.
3137
+	 */
3138
+	$listing_width = empty($instance['listing_width']) ? '' : apply_filters('widget_listing_width', $instance['listing_width']);
3139
+	/**
3140
+	 * Filter widget's "list_sort" type.
3141
+	 *
3142
+	 * @since 1.0.0
3143
+	 * @param string $instance['list_sort'] Listing sort by type.
3144
+	 */
3145
+	$list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
3146
+	$use_viewing_post_type = !empty($instance['use_viewing_post_type']) ? true : false;
3147
+
3148
+	// set post type to current viewing post type
3149
+	if ($use_viewing_post_type) {
3150
+		$current_post_type = geodir_get_current_posttype();
3151
+		if ($current_post_type != '' && $current_post_type != $post_type) {
3152
+			$post_type = $current_post_type;
3153
+			$category = array(); // old post type category will not work for current changed post type
3154
+		}
3155
+	}
3156
+	// replace widget title dynamically
3157
+	$posttype_plural_label = __(get_post_type_plural_label($post_type), 'geodirectory');
3158
+	$posttype_singular_label = __(get_post_type_singular_label($post_type), 'geodirectory');
3159
+
3160
+	$title = str_replace("%posttype_plural_label%", $posttype_plural_label, $title);
3161
+	$title = str_replace("%posttype_singular_label%", $posttype_singular_label, $title);
3162
+
3163
+	if (isset($instance['character_count'])) {
3164
+		/**
3165
+		 * Filter the widget's excerpt character count.
3166
+		 *
3167
+		 * @since 1.0.0
3168
+		 * @param int $instance['character_count'] Excerpt character count.
3169
+		 */
3170
+		$character_count = apply_filters('widget_list_character_count', $instance['character_count']);
3171
+	} else {
3172
+		$character_count = '';
3173
+	}
3174
+
3175
+	if (empty($title) || $title == 'All') {
3176
+		$title .= ' ' . __(get_post_type_plural_label($post_type), 'geodirectory');
3177
+	}
3178
+
3179
+	$location_url = array();
3180
+	$city = get_query_var('gd_city');
3181
+	if (!empty($city)) {
3182
+		$country = get_query_var('gd_country');
3183
+		$region = get_query_var('gd_region');
3184
+
3185
+		$geodir_show_location_url = get_option('geodir_show_location_url');
3186
+
3187
+		if ($geodir_show_location_url == 'all') {
3188
+			if ($country != '') {
3189
+				$location_url[] = $country;
3190
+			}
3191
+
3192
+			if ($region != '') {
3193
+				$location_url[] = $region;
3194
+			}
3195
+		} else if ($geodir_show_location_url == 'country_city') {
3196
+			if ($country != '') {
3197
+				$location_url[] = $country;
3198
+			}
3199
+		} else if ($geodir_show_location_url == 'region_city') {
3200
+			if ($region != '') {
3201
+				$location_url[] = $region;
3202
+			}
3203
+		}
3204
+
3205
+		$location_url[] = $city;
3206
+	}
3207
+
3208
+	$location_url = implode('/', $location_url);
3209
+	$skip_location = false;
3210
+	if (!$add_location_filter && $gd_session->get('gd_multi_location')) {
3211
+		$skip_location = true;
3212
+		$gd_session->un_set('gd_multi_location');
3213
+	}
3214
+
3215
+	if (get_option('permalink_structure')) {
3216
+		$viewall_url = get_post_type_archive_link($post_type);
3217
+	} else {
3218
+		$viewall_url = get_post_type_archive_link($post_type);
3219
+	}
3220
+
3221
+	if (!empty($category) && $category[0] != '0') {
3222
+		global $geodir_add_location_url;
3223
+
3224
+		$geodir_add_location_url = '0';
3225
+
3226
+		if ($add_location_filter != '0') {
3227
+			$geodir_add_location_url = '1';
3228
+		}
3229
+
3230
+		$viewall_url = get_term_link((int)$category[0], $post_type . 'category');
3231
+
3232
+		$geodir_add_location_url = NULL;
3233
+	}
3234
+	if ($skip_location) {
3235
+		$gd_session->set('gd_multi_location', 1);
3236
+	}
3237
+
3238
+	if(is_wp_error( $viewall_url  )){$viewall_url = '';}
3239
+
3240
+	$query_args = array(
3241
+		'posts_per_page' => $post_number,
3242
+		'is_geodir_loop' => true,
3243
+		'gd_location' => $add_location_filter ? true : false,
3244
+		'post_type' => $post_type,
3245
+		'order_by' => $list_sort
3246
+	);
3247
+
3248
+	if ($character_count) {
3249
+		$query_args['excerpt_length'] = $character_count;
3250
+	}
3251
+
3252
+	if (!empty($instance['show_featured_only'])) {
3253
+		$query_args['show_featured_only'] = 1;
3254
+	}
3255
+
3256
+	if (!empty($instance['show_special_only'])) {
3257
+		$query_args['show_special_only'] = 1;
3258
+	}
3259
+
3260
+	if (!empty($instance['with_pics_only'])) {
3261
+		$query_args['with_pics_only'] = 0;
3262
+		$query_args['featured_image_only'] = 1;
3263
+	}
3264
+
3265
+	if (!empty($instance['with_videos_only'])) {
3266
+		$query_args['with_videos_only'] = 1;
3267
+	}
3268
+	$with_no_results = !empty($instance['without_no_results']) ? false : true;
3269
+
3270
+	if (!empty($category) && $category[0] != '0') {
3271
+		$category_taxonomy = geodir_get_taxonomies($post_type);
3272
+
3273
+		######### WPML #########
3274
+		if (function_exists('icl_object_id')) {
3275
+			$category = gd_lang_object_ids($category, $category_taxonomy[0]);
3276
+		}
3277
+		######### WPML #########
3278
+
3279
+		$tax_query = array(
3280
+			'taxonomy' => $category_taxonomy[0],
3281
+			'field' => 'id',
3282
+			'terms' => $category
3283
+		);
3284
+
3285
+		$query_args['tax_query'] = array($tax_query);
3286
+	}
3287
+
3288
+	global $gridview_columns_widget, $geodir_is_widget_listing;
3289
+
3290
+	$widget_listings = geodir_get_widget_listings($query_args);
3291
+
3292
+	if (!empty($widget_listings) || $with_no_results) {
3293
+		?>
3294 3294
         <div class="geodir_locations geodir_location_listing">
3295 3295
 
3296 3296
             <?php
3297
-            /**
3298
-             * Called before the div containing the title and view all link in popular post view widget.
3299
-             *
3300
-             * @since 1.0.0
3301
-             */
3302
-            do_action('geodir_before_view_all_link_in_widget'); ?>
3297
+			/**
3298
+			 * Called before the div containing the title and view all link in popular post view widget.
3299
+			 *
3300
+			 * @since 1.0.0
3301
+			 */
3302
+			do_action('geodir_before_view_all_link_in_widget'); ?>
3303 3303
             <div class="geodir_list_heading clearfix">
3304 3304
                 <?php echo $before_title . $title . $after_title; ?>
3305 3305
                 <a href="<?php echo $viewall_url; ?>"
3306 3306
                    class="geodir-viewall"><?php _e('View all', 'geodirectory'); ?></a>
3307 3307
             </div>
3308 3308
             <?php
3309
-            /**
3310
-             * Called after the div containing the title and view all link in popular post view widget.
3311
-             *
3312
-             * @since 1.0.0
3313
-             */
3314
-            do_action('geodir_after_view_all_link_in_widget'); ?>
3309
+			/**
3310
+			 * Called after the div containing the title and view all link in popular post view widget.
3311
+			 *
3312
+			 * @since 1.0.0
3313
+			 */
3314
+			do_action('geodir_after_view_all_link_in_widget'); ?>
3315 3315
             <?php
3316
-            if (strstr($layout, 'gridview')) {
3317
-                $listing_view_exp = explode('_', $layout);
3318
-                $gridview_columns_widget = $layout;
3319
-                $layout = $listing_view_exp[0];
3320
-            } else {
3321
-                $gridview_columns_widget = '';
3322
-            }
3323
-
3324
-            /**
3325
-             * Filter the widget listing listview template path.
3326
-             *
3327
-             * @since 1.0.0
3328
-             */
3329
-            $template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview'));
3330
-            if (!isset($character_count)) {
3331
-                /**
3332
-                 * Filter the widget's excerpt character count.
3333
-                 *
3334
-                 * @since 1.0.0
3335
-                 * @param int $instance['character_count'] Excerpt character count.
3336
-                 */
3337
-                $character_count = $character_count == '' ? 50 : apply_filters('widget_character_count', $character_count);
3338
-            }
3339
-
3340
-            global $post, $map_jason, $map_canvas_arr;
3341
-
3342
-            $current_post = $post;
3343
-            $current_map_jason = $map_jason;
3344
-            $current_map_canvas_arr = $map_canvas_arr;
3345
-            $geodir_is_widget_listing = true;
3346
-
3347
-            /**
3348
-             * Includes related listing listview template.
3349
-             *
3350
-             * @since 1.0.0
3351
-             */
3352
-            include($template);
3353
-
3354
-            $geodir_is_widget_listing = false;
3355
-
3356
-            $GLOBALS['post'] = $current_post;
3357
-            if (!empty($current_post))
3358
-                setup_postdata($current_post);
3359
-            $map_jason = $current_map_jason;
3360
-            $map_canvas_arr = $current_map_canvas_arr;
3361
-            ?>
3316
+			if (strstr($layout, 'gridview')) {
3317
+				$listing_view_exp = explode('_', $layout);
3318
+				$gridview_columns_widget = $layout;
3319
+				$layout = $listing_view_exp[0];
3320
+			} else {
3321
+				$gridview_columns_widget = '';
3322
+			}
3323
+
3324
+			/**
3325
+			 * Filter the widget listing listview template path.
3326
+			 *
3327
+			 * @since 1.0.0
3328
+			 */
3329
+			$template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview'));
3330
+			if (!isset($character_count)) {
3331
+				/**
3332
+				 * Filter the widget's excerpt character count.
3333
+				 *
3334
+				 * @since 1.0.0
3335
+				 * @param int $instance['character_count'] Excerpt character count.
3336
+				 */
3337
+				$character_count = $character_count == '' ? 50 : apply_filters('widget_character_count', $character_count);
3338
+			}
3339
+
3340
+			global $post, $map_jason, $map_canvas_arr;
3341
+
3342
+			$current_post = $post;
3343
+			$current_map_jason = $map_jason;
3344
+			$current_map_canvas_arr = $map_canvas_arr;
3345
+			$geodir_is_widget_listing = true;
3346
+
3347
+			/**
3348
+			 * Includes related listing listview template.
3349
+			 *
3350
+			 * @since 1.0.0
3351
+			 */
3352
+			include($template);
3353
+
3354
+			$geodir_is_widget_listing = false;
3355
+
3356
+			$GLOBALS['post'] = $current_post;
3357
+			if (!empty($current_post))
3358
+				setup_postdata($current_post);
3359
+			$map_jason = $current_map_jason;
3360
+			$map_canvas_arr = $current_map_canvas_arr;
3361
+			?>
3362 3362
         </div>
3363 3363
     <?php
3364
-    }
3365
-    echo $after_widget;
3364
+	}
3365
+	echo $after_widget;
3366 3366
 
3367 3367
 }
3368 3368
 
@@ -3385,26 +3385,26 @@  discard block
 block discarded – undo
3385 3385
  */
3386 3386
 function geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type)
3387 3387
 {
3388
-    global $wpdb, $plugin_prefix;
3388
+	global $wpdb, $plugin_prefix;
3389 3389
 
3390
-    $detail_table = $plugin_prefix . $post_type . '_detail';
3390
+	$detail_table = $plugin_prefix . $post_type . '_detail';
3391 3391
 
3392
-    $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 . ")";
3392
+	$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 . ")";
3393 3393
 
3394
-    /**
3395
-     * Filter count review sql query.
3396
-     *
3397
-     * @since 1.5.1
3398
-     * @param string $sql Database sql query..
3399
-     * @param int $term_id The term ID.
3400
-     * @param int $taxonomy The taxonomy Id.
3401
-     * @param string $post_type The post type.
3402
-     */
3403
-    $sql = apply_filters('geodir_count_reviews_by_term_sql', $sql, $term_id, $taxonomy, $post_type);
3394
+	/**
3395
+	 * Filter count review sql query.
3396
+	 *
3397
+	 * @since 1.5.1
3398
+	 * @param string $sql Database sql query..
3399
+	 * @param int $term_id The term ID.
3400
+	 * @param int $taxonomy The taxonomy Id.
3401
+	 * @param string $post_type The post type.
3402
+	 */
3403
+	$sql = apply_filters('geodir_count_reviews_by_term_sql', $sql, $term_id, $taxonomy, $post_type);
3404 3404
 
3405
-    $count = $wpdb->get_var($sql);
3405
+	$count = $wpdb->get_var($sql);
3406 3406
 
3407
-    return $count;
3407
+	return $count;
3408 3408
 }
3409 3409
 
3410 3410
 /**
@@ -3420,91 +3420,91 @@  discard block
 block discarded – undo
3420 3420
  * @return array Term array data.
3421 3421
  */
3422 3422
 function geodir_count_reviews_by_terms($force_update = false, $post_ID = 0) {
3423
-    /**
3424
-     * Filter review count option data.
3425
-     *
3426
-     * @since 1.0.0
3427
-     * @since 1.6.1 Added $post_ID param.
3428
-     * @param bool $force_update Force update option value?. Default.false.
3429
-     * @param int $post_ID The post id to update if any.
3430
-     */
3431
-    $option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update,$post_ID);
3432
-    if (!empty($option_data)) {
3433
-        return $option_data;
3434
-    }
3423
+	/**
3424
+	 * Filter review count option data.
3425
+	 *
3426
+	 * @since 1.0.0
3427
+	 * @since 1.6.1 Added $post_ID param.
3428
+	 * @param bool $force_update Force update option value?. Default.false.
3429
+	 * @param int $post_ID The post id to update if any.
3430
+	 */
3431
+	$option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update,$post_ID);
3432
+	if (!empty($option_data)) {
3433
+		return $option_data;
3434
+	}
3435 3435
 
3436
-    $option_data = get_option('geodir_global_review_count');
3436
+	$option_data = get_option('geodir_global_review_count');
3437 3437
 
3438
-    if (!$option_data || $force_update) {
3439
-        if ((int)$post_ID > 0) { // Update reviews count for specific post categories only.
3440
-            global $gd_session;
3438
+	if (!$option_data || $force_update) {
3439
+		if ((int)$post_ID > 0) { // Update reviews count for specific post categories only.
3440
+			global $gd_session;
3441 3441
                         
3442
-            $term_array = (array)$option_data;
3443
-            $post_type = get_post_type($post_ID);
3444
-            $taxonomy = $post_type . 'category';
3445
-            $terms = wp_get_object_terms($post_ID, $taxonomy, array('fields' => 'ids'));
3446
-
3447
-            if (!empty($terms) && !is_wp_error($terms)) {
3448
-                foreach ($terms as $term_id) {
3449
-                    $count = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type);
3450
-                    $children = get_term_children($term_id, $taxonomy);
3451
-                    $term_array[$term_id] = $count;
3452
-                }
3453
-            }
3442
+			$term_array = (array)$option_data;
3443
+			$post_type = get_post_type($post_ID);
3444
+			$taxonomy = $post_type . 'category';
3445
+			$terms = wp_get_object_terms($post_ID, $taxonomy, array('fields' => 'ids'));
3446
+
3447
+			if (!empty($terms) && !is_wp_error($terms)) {
3448
+				foreach ($terms as $term_id) {
3449
+					$count = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type);
3450
+					$children = get_term_children($term_id, $taxonomy);
3451
+					$term_array[$term_id] = $count;
3452
+				}
3453
+			}
3454 3454
             
3455
-            $session_listing = $gd_session->get('listing');
3455
+			$session_listing = $gd_session->get('listing');
3456 3456
             
3457
-            $terms = array();
3458
-            if (isset($_POST['post_category'][$taxonomy])) {
3459
-                $terms = (array)$_POST['post_category'][$taxonomy];
3460
-            } else if (!empty($session_listing) && isset($session_listing['post_category'][$taxonomy])) {
3461
-                $terms = (array)$session_listing['post_category'][$taxonomy];
3462
-            }
3457
+			$terms = array();
3458
+			if (isset($_POST['post_category'][$taxonomy])) {
3459
+				$terms = (array)$_POST['post_category'][$taxonomy];
3460
+			} else if (!empty($session_listing) && isset($session_listing['post_category'][$taxonomy])) {
3461
+				$terms = (array)$session_listing['post_category'][$taxonomy];
3462
+			}
3463 3463
             
3464
-            if (!empty($terms)) {
3465
-                foreach ($terms as $term_id) {
3466
-                    if ($term_id > 0) {
3467
-                        $count = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type);
3468
-                        $children = get_term_children($term_id, $taxonomy);
3469
-                        $term_array[$term_id] = $count;
3470
-                    }
3471
-                }
3472
-            }
3473
-        } else { // Update reviews count for all post categories.
3474
-            $term_array = array();
3475
-            $post_types = geodir_get_posttypes();
3476
-            foreach ($post_types as $post_type) {
3477
-
3478
-                $taxonomy = geodir_get_taxonomies($post_type);
3479
-                $taxonomy = $taxonomy[0];
3480
-
3481
-                $args = array(
3482
-                    'hide_empty' => false
3483
-                );
3484
-
3485
-                $terms = get_terms($taxonomy, $args);
3486
-
3487
-                foreach ($terms as $term) {
3488
-                    $count = geodir_count_reviews_by_term_id($term->term_id, $taxonomy, $post_type);
3489
-                    $children = get_term_children($term->term_id, $taxonomy);
3490
-                    /*if ( is_array( $children ) ) {
3464
+			if (!empty($terms)) {
3465
+				foreach ($terms as $term_id) {
3466
+					if ($term_id > 0) {
3467
+						$count = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type);
3468
+						$children = get_term_children($term_id, $taxonomy);
3469
+						$term_array[$term_id] = $count;
3470
+					}
3471
+				}
3472
+			}
3473
+		} else { // Update reviews count for all post categories.
3474
+			$term_array = array();
3475
+			$post_types = geodir_get_posttypes();
3476
+			foreach ($post_types as $post_type) {
3477
+
3478
+				$taxonomy = geodir_get_taxonomies($post_type);
3479
+				$taxonomy = $taxonomy[0];
3480
+
3481
+				$args = array(
3482
+					'hide_empty' => false
3483
+				);
3484
+
3485
+				$terms = get_terms($taxonomy, $args);
3486
+
3487
+				foreach ($terms as $term) {
3488
+					$count = geodir_count_reviews_by_term_id($term->term_id, $taxonomy, $post_type);
3489
+					$children = get_term_children($term->term_id, $taxonomy);
3490
+					/*if ( is_array( $children ) ) {
3491 3491
                         foreach ( $children as $child_id ) {
3492 3492
                             $child_count = geodir_count_reviews_by_term_id($child_id, $taxonomy, $post_type);
3493 3493
                             $count = $count + $child_count;
3494 3494
                         }
3495 3495
                     }*/
3496
-                    $term_array[$term->term_id] = $count;
3497
-                }
3498
-            }
3499
-        }
3500
-
3501
-        update_option('geodir_global_review_count', $term_array);
3502
-        //clear cache
3503
-        wp_cache_delete('geodir_global_review_count');
3504
-        return $term_array;
3505
-    } else {
3506
-        return $option_data;
3507
-    }
3496
+					$term_array[$term->term_id] = $count;
3497
+				}
3498
+			}
3499
+		}
3500
+
3501
+		update_option('geodir_global_review_count', $term_array);
3502
+		//clear cache
3503
+		wp_cache_delete('geodir_global_review_count');
3504
+		return $term_array;
3505
+	} else {
3506
+		return $option_data;
3507
+	}
3508 3508
 }
3509 3509
 
3510 3510
 /**
@@ -3516,34 +3516,34 @@  discard block
 block discarded – undo
3516 3516
  * @return bool
3517 3517
  */
3518 3518
 function geodir_term_review_count_force_update($new_status, $old_status = '', $post = '') {
3519
-    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'geodir_import_export') {
3520
-        return; // do not run if importing listings
3521
-    }
3519
+	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'geodir_import_export') {
3520
+		return; // do not run if importing listings
3521
+	}
3522 3522
     
3523
-    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
3524
-        return;
3525
-    }
3526
-
3527
-    $post_ID = 0;
3528
-    if (!empty($post)) {
3529
-        if (isset($post->post_type) && strpos($post->post_type, 'gd_') !== 0) {
3530
-            return;
3531
-        }
3523
+	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
3524
+		return;
3525
+	}
3526
+
3527
+	$post_ID = 0;
3528
+	if (!empty($post)) {
3529
+		if (isset($post->post_type) && strpos($post->post_type, 'gd_') !== 0) {
3530
+			return;
3531
+		}
3532 3532
         
3533
-        if ($new_status == 'auto-draft' && $old_status == 'new') {
3534
-            return;
3535
-        }
3533
+		if ($new_status == 'auto-draft' && $old_status == 'new') {
3534
+			return;
3535
+		}
3536 3536
         
3537
-        if (!empty($post->ID)) {
3538
-            $post_ID = $post->ID;
3539
-        }
3540
-    }
3537
+		if (!empty($post->ID)) {
3538
+			$post_ID = $post->ID;
3539
+		}
3540
+	}
3541 3541
 
3542
-    if ($new_status != $old_status) {
3543
-        geodir_count_reviews_by_terms(true, $post_ID);
3544
-    }
3542
+	if ($new_status != $old_status) {
3543
+		geodir_count_reviews_by_terms(true, $post_ID);
3544
+	}
3545 3545
 
3546
-    return true;
3546
+	return true;
3547 3547
 }
3548 3548
 
3549 3549
 /*-----------------------------------------------------------------------------------*/
@@ -3561,15 +3561,15 @@  discard block
 block discarded – undo
3561 3561
 function geodir_count_posts_by_term($data, $term)
3562 3562
 {
3563 3563
 
3564
-    if ($data) {
3565
-        if (isset($data[$term->term_id])) {
3566
-            return $data[$term->term_id];
3567
-        } else {
3568
-            return 0;
3569
-        }
3570
-    } else {
3571
-        return $term->count;
3572
-    }
3564
+	if ($data) {
3565
+		if (isset($data[$term->term_id])) {
3566
+			return $data[$term->term_id];
3567
+		} else {
3568
+			return 0;
3569
+		}
3570
+	} else {
3571
+		return $term->count;
3572
+	}
3573 3573
 }
3574 3574
 
3575 3575
 /**
@@ -3582,8 +3582,8 @@  discard block
 block discarded – undo
3582 3582
  */
3583 3583
 function geodir_sort_terms_by_count($terms)
3584 3584
 {
3585
-    usort($terms, "geodir_sort_by_count_obj");
3586
-    return $terms;
3585
+	usort($terms, "geodir_sort_by_count_obj");
3586
+	return $terms;
3587 3587
 }
3588 3588
 
3589 3589
 /**
@@ -3596,8 +3596,8 @@  discard block
 block discarded – undo
3596 3596
  */
3597 3597
 function geodir_sort_terms_by_review_count($terms)
3598 3598
 {
3599
-    usort($terms, "geodir_sort_by_review_count_obj");
3600
-    return $terms;
3599
+	usort($terms, "geodir_sort_by_review_count_obj");
3600
+	return $terms;
3601 3601
 }
3602 3602
 
3603 3603
 /**
@@ -3611,12 +3611,12 @@  discard block
 block discarded – undo
3611 3611
  */
3612 3612
 function geodir_sort_terms($terms, $sort = 'count')
3613 3613
 {
3614
-    if ($sort == 'count') {
3615
-        return geodir_sort_terms_by_count($terms);
3616
-    }
3617
-    if ($sort == 'review_count') {
3618
-        return geodir_sort_terms_by_review_count($terms);
3619
-    }
3614
+	if ($sort == 'count') {
3615
+		return geodir_sort_terms_by_count($terms);
3616
+	}
3617
+	if ($sort == 'review_count') {
3618
+		return geodir_sort_terms_by_review_count($terms);
3619
+	}
3620 3620
 }
3621 3621
 
3622 3622
 /*-----------------------------------------------------------------------------------*/
@@ -3633,7 +3633,7 @@  discard block
 block discarded – undo
3633 3633
  */
3634 3634
 function geodir_sort_by_count($a, $b)
3635 3635
 {
3636
-    return $a['count'] < $b['count'];
3636
+	return $a['count'] < $b['count'];
3637 3637
 }
3638 3638
 
3639 3639
 /**
@@ -3647,7 +3647,7 @@  discard block
 block discarded – undo
3647 3647
  */
3648 3648
 function geodir_sort_by_count_obj($a, $b)
3649 3649
 {
3650
-    return $a->count < $b->count;
3650
+	return $a->count < $b->count;
3651 3651
 }
3652 3652
 
3653 3653
 /**
@@ -3661,7 +3661,7 @@  discard block
 block discarded – undo
3661 3661
  */
3662 3662
 function geodir_sort_by_review_count_obj($a, $b)
3663 3663
 {
3664
-    return $a->review_count < $b->review_count;
3664
+	return $a->review_count < $b->review_count;
3665 3665
 }
3666 3666
 
3667 3667
 /**
@@ -3671,43 +3671,43 @@  discard block
 block discarded – undo
3671 3671
  * @package GeoDirectory
3672 3672
  */
3673 3673
 function geodir_load_textdomain() {
3674
-    /**
3675
-     * Filter the plugin locale.
3676
-     *
3677
-     * @since 1.4.2
3678
-     * @package GeoDirectory
3679
-     */
3680
-    $locale = apply_filters('plugin_locale', get_locale(), 'geodirectory');
3681
-
3682
-    load_textdomain('geodirectory', WP_LANG_DIR . '/' . 'geodirectory' . '/' . 'geodirectory' . '-' . $locale . '.mo');
3683
-    load_plugin_textdomain('geodirectory', false, plugin_basename(dirname(dirname(__FILE__))) . '/geodirectory-languages');
3674
+	/**
3675
+	 * Filter the plugin locale.
3676
+	 *
3677
+	 * @since 1.4.2
3678
+	 * @package GeoDirectory
3679
+	 */
3680
+	$locale = apply_filters('plugin_locale', get_locale(), 'geodirectory');
3681
+
3682
+	load_textdomain('geodirectory', WP_LANG_DIR . '/' . 'geodirectory' . '/' . 'geodirectory' . '-' . $locale . '.mo');
3683
+	load_plugin_textdomain('geodirectory', false, plugin_basename(dirname(dirname(__FILE__))) . '/geodirectory-languages');
3684
+
3685
+	/**
3686
+	 * Define language constants.
3687
+	 *
3688
+	 * @since 1.0.0
3689
+	 */
3690
+	require_once(geodir_plugin_path() . '/language.php');
3691
+
3692
+	$language_file = geodir_plugin_path() . '/db-language.php';
3693
+
3694
+	// Load language string file if not created yet
3695
+	if (!file_exists($language_file)) {
3696
+		geodirectory_load_db_language();
3697
+	}
3684 3698
 
3685
-    /**
3686
-     * Define language constants.
3687
-     *
3688
-     * @since 1.0.0
3689
-     */
3690
-    require_once(geodir_plugin_path() . '/language.php');
3691
-
3692
-    $language_file = geodir_plugin_path() . '/db-language.php';
3693
-
3694
-    // Load language string file if not created yet
3695
-    if (!file_exists($language_file)) {
3696
-        geodirectory_load_db_language();
3697
-    }
3698
-
3699
-    if (file_exists($language_file)) {
3700
-        /**
3701
-         * Language strings from database.
3702
-         *
3703
-         * @since 1.4.2
3704
-         */
3705
-        try {
3706
-            require_once($language_file);
3707
-        } catch(Exception $e) {
3708
-            error_log('Language Error: ' . $e->getMessage());
3709
-        }
3710
-    }
3699
+	if (file_exists($language_file)) {
3700
+		/**
3701
+		 * Language strings from database.
3702
+		 *
3703
+		 * @since 1.4.2
3704
+		 */
3705
+		try {
3706
+			require_once($language_file);
3707
+		} catch(Exception $e) {
3708
+			error_log('Language Error: ' . $e->getMessage());
3709
+		}
3710
+	}
3711 3711
 }
3712 3712
 
3713 3713
 /**
@@ -3721,66 +3721,66 @@  discard block
 block discarded – undo
3721 3721
  * @return bool True if file created otherwise false
3722 3722
  */
3723 3723
 function geodirectory_load_db_language() {
3724
-    global $wp_filesystem;
3725
-    if( empty( $wp_filesystem ) ) {
3726
-        require_once( ABSPATH .'/wp-admin/includes/file.php' );
3727
-        WP_Filesystem();
3728
-        global $wp_filesystem;
3729
-    }
3730
-
3731
-    $language_file = geodir_plugin_path() . '/db-language.php';
3724
+	global $wp_filesystem;
3725
+	if( empty( $wp_filesystem ) ) {
3726
+		require_once( ABSPATH .'/wp-admin/includes/file.php' );
3727
+		WP_Filesystem();
3728
+		global $wp_filesystem;
3729
+	}
3732 3730
 
3733
-    if(is_file($language_file) && !is_writable($language_file))
3734
-        return false; // Not possible to create.
3731
+	$language_file = geodir_plugin_path() . '/db-language.php';
3732
+
3733
+	if(is_file($language_file) && !is_writable($language_file))
3734
+		return false; // Not possible to create.
3735
+
3736
+	if(!is_file($language_file) && !is_writable(dirname($language_file)))
3737
+		return false; // Not possible to create.
3738
+
3739
+	$contents_strings = array();
3740
+
3741
+	/**
3742
+	 * Filter the language string from database to translate via po editor
3743
+	 *
3744
+	 * @since 1.4.2
3745
+	 *
3746
+	 * @param array $contents_strings Array of strings.
3747
+	 */
3748
+	$contents_strings = apply_filters('geodir_load_db_language', $contents_strings);
3749
+
3750
+	$contents_strings = array_unique($contents_strings);
3751
+
3752
+	$contents_head = array();
3753
+	$contents_head[] = "<?php";
3754
+	$contents_head[] = "/**";
3755
+	$contents_head[] = " * Translate language string stored in database. Ex: Custom Fields";
3756
+	$contents_head[] = " *";
3757
+	$contents_head[] = " * @package GeoDirectory";
3758
+	$contents_head[] = " * @since 1.4.2";
3759
+	$contents_head[] = " */";
3760
+	$contents_head[] = "";
3761
+	$contents_head[] = "// Language keys";
3762
+
3763
+	$contents_foot = array();
3764
+	$contents_foot[] = "";
3765
+	$contents_foot[] = "";
3766
+
3767
+	$contents = implode(PHP_EOL, $contents_head);
3768
+
3769
+	if (!empty($contents_strings)) {
3770
+		foreach ( $contents_strings as $string ) {
3771
+			if (is_scalar($string) && $string != '') {
3772
+				$string = str_replace("'", "\'", $string);
3773
+				$contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
3774
+			}
3775
+		}
3776
+	}
3735 3777
 
3736
-    if(!is_file($language_file) && !is_writable(dirname($language_file)))
3737
-        return false; // Not possible to create.
3778
+	$contents .= implode(PHP_EOL, $contents_foot);
3738 3779
 
3739
-    $contents_strings = array();
3780
+	if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE))
3781
+		return false; // Failure; could not write file.
3740 3782
 
3741
-    /**
3742
-     * Filter the language string from database to translate via po editor
3743
-     *
3744
-     * @since 1.4.2
3745
-     *
3746
-     * @param array $contents_strings Array of strings.
3747
-     */
3748
-    $contents_strings = apply_filters('geodir_load_db_language', $contents_strings);
3749
-
3750
-    $contents_strings = array_unique($contents_strings);
3751
-
3752
-    $contents_head = array();
3753
-    $contents_head[] = "<?php";
3754
-    $contents_head[] = "/**";
3755
-    $contents_head[] = " * Translate language string stored in database. Ex: Custom Fields";
3756
-    $contents_head[] = " *";
3757
-    $contents_head[] = " * @package GeoDirectory";
3758
-    $contents_head[] = " * @since 1.4.2";
3759
-    $contents_head[] = " */";
3760
-    $contents_head[] = "";
3761
-    $contents_head[] = "// Language keys";
3762
-
3763
-    $contents_foot = array();
3764
-    $contents_foot[] = "";
3765
-    $contents_foot[] = "";
3766
-
3767
-    $contents = implode(PHP_EOL, $contents_head);
3768
-
3769
-    if (!empty($contents_strings)) {
3770
-        foreach ( $contents_strings as $string ) {
3771
-            if (is_scalar($string) && $string != '') {
3772
-                $string = str_replace("'", "\'", $string);
3773
-                $contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
3774
-            }
3775
-        }
3776
-    }
3777
-
3778
-    $contents .= implode(PHP_EOL, $contents_foot);
3779
-
3780
-    if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE))
3781
-        return false; // Failure; could not write file.
3782
-
3783
-    return true;
3783
+	return true;
3784 3784
 }
3785 3785
 
3786 3786
 /**
@@ -3796,31 +3796,31 @@  discard block
 block discarded – undo
3796 3796
  * @return array Translation texts.
3797 3797
  */
3798 3798
 function geodir_load_custom_field_translation($translation_texts = array()) {
3799
-    global $wpdb;
3799
+	global $wpdb;
3800 3800
 
3801
-    // Custom fields table
3802
-    $sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM " . GEODIR_CUSTOM_FIELDS_TABLE;
3803
-    $rows = $wpdb->get_results($sql);
3801
+	// Custom fields table
3802
+	$sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM " . GEODIR_CUSTOM_FIELDS_TABLE;
3803
+	$rows = $wpdb->get_results($sql);
3804 3804
 
3805
-    if (!empty($rows)) {
3806
-        foreach($rows as $row) {
3807
-            if (!empty($row->admin_title))
3808
-                $translation_texts[] = stripslashes_deep($row->admin_title);
3805
+	if (!empty($rows)) {
3806
+		foreach($rows as $row) {
3807
+			if (!empty($row->admin_title))
3808
+				$translation_texts[] = stripslashes_deep($row->admin_title);
3809 3809
 			
3810
-            if (!empty($row->admin_desc))
3811
-                $translation_texts[] = stripslashes_deep($row->admin_desc);
3810
+			if (!empty($row->admin_desc))
3811
+				$translation_texts[] = stripslashes_deep($row->admin_desc);
3812 3812
 
3813
-            if (!empty($row->site_title))
3814
-                $translation_texts[] = stripslashes_deep($row->site_title);
3813
+			if (!empty($row->site_title))
3814
+				$translation_texts[] = stripslashes_deep($row->site_title);
3815 3815
 
3816
-            if (!empty($row->clabels))
3817
-                $translation_texts[] = stripslashes_deep($row->clabels);
3816
+			if (!empty($row->clabels))
3817
+				$translation_texts[] = stripslashes_deep($row->clabels);
3818 3818
 
3819
-            if (!empty($row->required_msg))
3820
-                $translation_texts[] = stripslashes_deep($row->required_msg);
3819
+			if (!empty($row->required_msg))
3820
+				$translation_texts[] = stripslashes_deep($row->required_msg);
3821 3821
 			
3822 3822
 			if (!empty($row->default_value))
3823
-                $translation_texts[] = stripslashes_deep($row->default_value);
3823
+				$translation_texts[] = stripslashes_deep($row->default_value);
3824 3824
 			
3825 3825
 			if (!empty($row->option_values)) {
3826 3826
 				$option_values = geodir_string_values_to_options(stripslashes_deep($row->option_values));
@@ -3833,25 +3833,25 @@  discard block
 block discarded – undo
3833 3833
 					}
3834 3834
 				}
3835 3835
 			}
3836
-        }
3837
-    }
3836
+		}
3837
+	}
3838 3838
 	
3839
-    // Custom sorting fields table
3840
-    $sql = "SELECT site_title, asc_title, desc_title FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE;
3841
-    $rows = $wpdb->get_results($sql);
3842
-
3843
-    if (!empty($rows)) {
3844
-        foreach($rows as $row) {
3845
-            if (!empty($row->site_title))
3846
-                $translation_texts[] = stripslashes_deep($row->site_title);
3847
-
3848
-            if (!empty($row->asc_title))
3849
-                $translation_texts[] = stripslashes_deep($row->asc_title);
3850
-
3851
-            if (!empty($row->desc_title))
3852
-                $translation_texts[] = stripslashes_deep($row->desc_title);
3853
-        }
3854
-    }
3839
+	// Custom sorting fields table
3840
+	$sql = "SELECT site_title, asc_title, desc_title FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE;
3841
+	$rows = $wpdb->get_results($sql);
3842
+
3843
+	if (!empty($rows)) {
3844
+		foreach($rows as $row) {
3845
+			if (!empty($row->site_title))
3846
+				$translation_texts[] = stripslashes_deep($row->site_title);
3847
+
3848
+			if (!empty($row->asc_title))
3849
+				$translation_texts[] = stripslashes_deep($row->asc_title);
3850
+
3851
+			if (!empty($row->desc_title))
3852
+				$translation_texts[] = stripslashes_deep($row->desc_title);
3853
+		}
3854
+	}
3855 3855
 	
3856 3856
 	// Advance search filter fields table
3857 3857
 	if (defined('GEODIR_ADVANCE_SEARCH_TABLE')) {
@@ -3872,9 +3872,9 @@  discard block
 block discarded – undo
3872 3872
 		}
3873 3873
 	}
3874 3874
 
3875
-    $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
3875
+	$translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
3876 3876
 
3877
-    return $translation_texts;
3877
+	return $translation_texts;
3878 3878
 }
3879 3879
 
3880 3880
 /**
@@ -3886,71 +3886,71 @@  discard block
 block discarded – undo
3886 3886
  * @return array Array of mime types.
3887 3887
  */
3888 3888
 function geodir_allowed_mime_types() {
3889
-    /**
3890
-     * Filter the list of mime types and file extensions allowed for file upload.
3891
-     *
3892
-     * @since 1.4.7
3893
-     * @package GeoDirectory
3894
-     *
3895
-     * @param array $geodir_allowed_mime_types and file extensions.
3896
-     */
3897
-    return apply_filters( 'geodir_allowed_mime_types', array(
3898
-            'Image' => array( // Image formats.
3899
-                'jpg' => 'image/jpeg',
3900
-                'jpe' => 'image/jpeg',
3901
-                'jpeg' => 'image/jpeg',
3902
-                'gif' => 'image/gif',
3903
-                'png' => 'image/png',
3904
-                'bmp' => 'image/bmp',
3905
-                'ico' => 'image/x-icon',
3906
-            ),
3907
-            'Video' => array( // Video formats.
3908
-                'asf' => 'video/x-ms-asf',
3909
-                'avi' => 'video/avi',
3910
-                'flv' => 'video/x-flv',
3911
-                'mkv' => 'video/x-matroska',
3912
-                'mp4' => 'video/mp4',
3913
-                'mpeg' => 'video/mpeg',
3914
-                'mpg' => 'video/mpeg',
3915
-                'wmv' => 'video/x-ms-wmv',
3916
-                '3gp' => 'video/3gpp',
3917
-            ),
3918
-            'Audio' => array( // Audio formats.
3919
-                'ogg' => 'audio/ogg',
3920
-                'mp3' => 'audio/mpeg',
3921
-                'wav' => 'audio/wav',
3922
-                'wma' => 'audio/x-ms-wma',
3923
-            ),
3924
-            'Text' => array( // Text formats.
3925
-                'css' => 'text/css',
3926
-                'csv' => 'text/csv',
3927
-                'htm' => 'text/html',
3928
-                'html' => 'text/html',
3929
-                'txt' => 'text/plain',
3930
-                'rtx' => 'text/richtext',
3931
-                'vtt' => 'text/vtt',
3932
-            ),
3933
-            'Application' => array( // Application formats.
3934
-                'doc' => 'application/msword',
3935
-                'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
3936
-                'exe' => 'application/x-msdownload',
3937
-                'js' => 'application/javascript',
3938
-                'odt' => 'application/vnd.oasis.opendocument.text',
3939
-                'pdf' => 'application/pdf',
3940
-                'pot' => 'application/vnd.ms-powerpoint',
3941
-                'ppt' => 'application/vnd.ms-powerpoint',
3942
-                'pptx' => 'application/vnd.ms-powerpoint',
3943
-                'psd' => 'application/octet-stream',
3944
-                'rar' => 'application/rar',
3945
-                'rtf' => 'application/rtf',
3946
-                'swf' => 'application/x-shockwave-flash',
3947
-                'tar' => 'application/x-tar',
3948
-                'xls' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
3949
-                'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
3950
-                'zip' => 'application/zip',
3951
-            )
3952
-        )
3953
-    );
3889
+	/**
3890
+	 * Filter the list of mime types and file extensions allowed for file upload.
3891
+	 *
3892
+	 * @since 1.4.7
3893
+	 * @package GeoDirectory
3894
+	 *
3895
+	 * @param array $geodir_allowed_mime_types and file extensions.
3896
+	 */
3897
+	return apply_filters( 'geodir_allowed_mime_types', array(
3898
+			'Image' => array( // Image formats.
3899
+				'jpg' => 'image/jpeg',
3900
+				'jpe' => 'image/jpeg',
3901
+				'jpeg' => 'image/jpeg',
3902
+				'gif' => 'image/gif',
3903
+				'png' => 'image/png',
3904
+				'bmp' => 'image/bmp',
3905
+				'ico' => 'image/x-icon',
3906
+			),
3907
+			'Video' => array( // Video formats.
3908
+				'asf' => 'video/x-ms-asf',
3909
+				'avi' => 'video/avi',
3910
+				'flv' => 'video/x-flv',
3911
+				'mkv' => 'video/x-matroska',
3912
+				'mp4' => 'video/mp4',
3913
+				'mpeg' => 'video/mpeg',
3914
+				'mpg' => 'video/mpeg',
3915
+				'wmv' => 'video/x-ms-wmv',
3916
+				'3gp' => 'video/3gpp',
3917
+			),
3918
+			'Audio' => array( // Audio formats.
3919
+				'ogg' => 'audio/ogg',
3920
+				'mp3' => 'audio/mpeg',
3921
+				'wav' => 'audio/wav',
3922
+				'wma' => 'audio/x-ms-wma',
3923
+			),
3924
+			'Text' => array( // Text formats.
3925
+				'css' => 'text/css',
3926
+				'csv' => 'text/csv',
3927
+				'htm' => 'text/html',
3928
+				'html' => 'text/html',
3929
+				'txt' => 'text/plain',
3930
+				'rtx' => 'text/richtext',
3931
+				'vtt' => 'text/vtt',
3932
+			),
3933
+			'Application' => array( // Application formats.
3934
+				'doc' => 'application/msword',
3935
+				'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
3936
+				'exe' => 'application/x-msdownload',
3937
+				'js' => 'application/javascript',
3938
+				'odt' => 'application/vnd.oasis.opendocument.text',
3939
+				'pdf' => 'application/pdf',
3940
+				'pot' => 'application/vnd.ms-powerpoint',
3941
+				'ppt' => 'application/vnd.ms-powerpoint',
3942
+				'pptx' => 'application/vnd.ms-powerpoint',
3943
+				'psd' => 'application/octet-stream',
3944
+				'rar' => 'application/rar',
3945
+				'rtf' => 'application/rtf',
3946
+				'swf' => 'application/x-shockwave-flash',
3947
+				'tar' => 'application/x-tar',
3948
+				'xls' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
3949
+				'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
3950
+				'zip' => 'application/zip',
3951
+			)
3952
+		)
3953
+	);
3954 3954
 }
3955 3955
 
3956 3956
 /**
@@ -3962,21 +3962,21 @@  discard block
 block discarded – undo
3962 3962
  * @return string User display name.
3963 3963
  */
3964 3964
 function geodir_get_client_name($user_id) {
3965
-    $client_name = '';
3965
+	$client_name = '';
3966 3966
 
3967
-    $user_data = get_userdata($user_id);
3967
+	$user_data = get_userdata($user_id);
3968 3968
 
3969
-    if (!empty($user_data)) {
3970
-        if (isset($user_data->display_name) && trim($user_data->display_name) != '') {
3971
-            $client_name = trim($user_data->display_name);
3972
-        } else if (isset($user_data->user_nicename) && trim($user_data->user_nicename) != '') {
3973
-            $client_name = trim($user_data->user_nicename);
3974
-        } else {
3975
-            $client_name = trim($user_data->user_login);
3976
-        }
3977
-    }
3969
+	if (!empty($user_data)) {
3970
+		if (isset($user_data->display_name) && trim($user_data->display_name) != '') {
3971
+			$client_name = trim($user_data->display_name);
3972
+		} else if (isset($user_data->user_nicename) && trim($user_data->user_nicename) != '') {
3973
+			$client_name = trim($user_data->user_nicename);
3974
+		} else {
3975
+			$client_name = trim($user_data->user_login);
3976
+		}
3977
+	}
3978 3978
 
3979
-    return $client_name;
3979
+	return $client_name;
3980 3980
 }
3981 3981
 
3982 3982
 
@@ -3991,125 +3991,125 @@  discard block
 block discarded – undo
3991 3991
  */
3992 3992
 function geodir_wpseo_replacements($vars){
3993 3993
 
3994
-    global $wp;
3995
-    $title = '';
3996
-    // location variables
3997
-    $gd_post_type = geodir_get_current_posttype();
3998
-    $location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
3999
-    /**
4000
-     * Filter the title variables location variables array
4001
-     *
4002
-     * @since 1.5.5
4003
-     * @package GeoDirectory
4004
-     * @param array $location_array The array of location variables.
4005
-     * @param array $vars The page title variables.
4006
-     */
4007
-    $location_array = apply_filters('geodir_filter_title_variables_location_arr_seo',$location_array, $vars);
4008
-    $location_titles = array();
4009
-    if(get_query_var( 'gd_country_full' )){
4010
-        if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4011
-        if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4012
-        if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4013
-    }
4014
-    $location_single = '';
4015
-    $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
4016
-    $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
4017
-    $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
4018
-
4019
-    $gd_country_actual = $gd_region_actual = $gd_city_actual = '';
4020
-
4021
-    if (function_exists('get_actual_location_name')) {
4022
-        $gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
4023
-        $gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
4024
-        $gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
4025
-    }
4026
-
4027
-    if ($gd_city != '') {
4028
-        if ($gd_city_actual != '') {
4029
-            $gd_city = $gd_city_actual;
4030
-        } else {
4031
-            $gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
4032
-            $gd_city = preg_replace('/[_-]/', ' ', $gd_city);
4033
-            $gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
4034
-        }
4035
-        $location_single = $gd_city;
4036
-
4037
-    } else if ($gd_region != '') {
4038
-        if ($gd_region_actual != '') {
4039
-            $gd_region = $gd_region_actual;
4040
-        } else {
4041
-            $gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
4042
-            $gd_region = preg_replace('/[_-]/', ' ', $gd_region);
4043
-            $gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
4044
-        }
4045
-
4046
-        $location_single = $gd_region;
4047
-    } else if ($gd_country != '') {
4048
-        if ($gd_country_actual != '') {
4049
-            $gd_country = $gd_country_actual;
4050
-        } else {
4051
-            $gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
4052
-            $gd_country = preg_replace('/[_-]/', ' ', $gd_country);
4053
-            $gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
4054
-        }
4055
-
4056
-        $location_single = $gd_country;
4057
-    }
4058
-
4059
-    if (!empty($location_array)) {
4060
-
4061
-        $actual_location_name = function_exists('get_actual_location_name') ? true : false;
4062
-        $location_array = array_reverse($location_array);
4063
-
4064
-        foreach ($location_array as $location_type => $location) {
4065
-            $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
4066
-            $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
4067
-
4068
-            $location_name = geodir_ucwords($gd_location_link_text);
4069
-            $location_name = __($location_name, 'geodirectory');
4070
-
4071
-            if ($actual_location_name) {
4072
-                $location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type;
4073
-                $location_name = get_actual_location_name($location_type, $location, true);
4074
-            }
4075
-
4076
-            $location_titles[] = $location_name;
4077
-        }
4078
-        if (!empty($location_titles)) {
4079
-            $location_titles = array_unique($location_titles);
4080
-        }
4081
-    }
4082
-
4083
-
4084
-    if(!empty($location_titles)) {
4085
-        $vars['%%location%%'] = implode(", ", $location_titles);
4086
-    }
4087
-
4088
-
4089
-    if(!empty($location_titles)) {
4090
-        $vars['%%in_location%%'] = __('in ', 'geodirectory') . implode(", ", $location_titles);
4091
-    }
4092
-
4093
-
4094
-
4095
-    if($location_single) {
4096
-        $vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' .$location_single;
4097
-    }
4098
-
4099
-
4100
-    if($location_single) {
4101
-        $vars['%%location_single%%'] = $location_single;
4102
-    }
4103
-
4104
-    /**
4105
-     * Filter the title variables after standard ones have been filtered for wpseo.
4106
-     *
4107
-     * @since 1.5.7
4108
-     * @package GeoDirectory
4109
-     * @param string $vars The title with variables.
4110
-     * @param array $location_array The array of location variables.
4111
-     */
4112
-    return apply_filters('geodir_wpseo_replacements_vars',$vars,$location_array);
3994
+	global $wp;
3995
+	$title = '';
3996
+	// location variables
3997
+	$gd_post_type = geodir_get_current_posttype();
3998
+	$location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
3999
+	/**
4000
+	 * Filter the title variables location variables array
4001
+	 *
4002
+	 * @since 1.5.5
4003
+	 * @package GeoDirectory
4004
+	 * @param array $location_array The array of location variables.
4005
+	 * @param array $vars The page title variables.
4006
+	 */
4007
+	$location_array = apply_filters('geodir_filter_title_variables_location_arr_seo',$location_array, $vars);
4008
+	$location_titles = array();
4009
+	if(get_query_var( 'gd_country_full' )){
4010
+		if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4011
+		if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4012
+		if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4013
+	}
4014
+	$location_single = '';
4015
+	$gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
4016
+	$gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
4017
+	$gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
4018
+
4019
+	$gd_country_actual = $gd_region_actual = $gd_city_actual = '';
4020
+
4021
+	if (function_exists('get_actual_location_name')) {
4022
+		$gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
4023
+		$gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
4024
+		$gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
4025
+	}
4026
+
4027
+	if ($gd_city != '') {
4028
+		if ($gd_city_actual != '') {
4029
+			$gd_city = $gd_city_actual;
4030
+		} else {
4031
+			$gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
4032
+			$gd_city = preg_replace('/[_-]/', ' ', $gd_city);
4033
+			$gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
4034
+		}
4035
+		$location_single = $gd_city;
4036
+
4037
+	} else if ($gd_region != '') {
4038
+		if ($gd_region_actual != '') {
4039
+			$gd_region = $gd_region_actual;
4040
+		} else {
4041
+			$gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
4042
+			$gd_region = preg_replace('/[_-]/', ' ', $gd_region);
4043
+			$gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
4044
+		}
4045
+
4046
+		$location_single = $gd_region;
4047
+	} else if ($gd_country != '') {
4048
+		if ($gd_country_actual != '') {
4049
+			$gd_country = $gd_country_actual;
4050
+		} else {
4051
+			$gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
4052
+			$gd_country = preg_replace('/[_-]/', ' ', $gd_country);
4053
+			$gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
4054
+		}
4055
+
4056
+		$location_single = $gd_country;
4057
+	}
4058
+
4059
+	if (!empty($location_array)) {
4060
+
4061
+		$actual_location_name = function_exists('get_actual_location_name') ? true : false;
4062
+		$location_array = array_reverse($location_array);
4063
+
4064
+		foreach ($location_array as $location_type => $location) {
4065
+			$gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
4066
+			$gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
4067
+
4068
+			$location_name = geodir_ucwords($gd_location_link_text);
4069
+			$location_name = __($location_name, 'geodirectory');
4070
+
4071
+			if ($actual_location_name) {
4072
+				$location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type;
4073
+				$location_name = get_actual_location_name($location_type, $location, true);
4074
+			}
4075
+
4076
+			$location_titles[] = $location_name;
4077
+		}
4078
+		if (!empty($location_titles)) {
4079
+			$location_titles = array_unique($location_titles);
4080
+		}
4081
+	}
4082
+
4083
+
4084
+	if(!empty($location_titles)) {
4085
+		$vars['%%location%%'] = implode(", ", $location_titles);
4086
+	}
4087
+
4088
+
4089
+	if(!empty($location_titles)) {
4090
+		$vars['%%in_location%%'] = __('in ', 'geodirectory') . implode(", ", $location_titles);
4091
+	}
4092
+
4093
+
4094
+
4095
+	if($location_single) {
4096
+		$vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' .$location_single;
4097
+	}
4098
+
4099
+
4100
+	if($location_single) {
4101
+		$vars['%%location_single%%'] = $location_single;
4102
+	}
4103
+
4104
+	/**
4105
+	 * Filter the title variables after standard ones have been filtered for wpseo.
4106
+	 *
4107
+	 * @since 1.5.7
4108
+	 * @package GeoDirectory
4109
+	 * @param string $vars The title with variables.
4110
+	 * @param array $location_array The array of location variables.
4111
+	 */
4112
+	return apply_filters('geodir_wpseo_replacements_vars',$vars,$location_array);
4113 4113
 }
4114 4114
 
4115 4115
 
@@ -4119,10 +4119,10 @@  discard block
 block discarded – undo
4119 4119
 function geodir_filter_title_variables($title, $gd_page, $sep=''){
4120 4120
 
4121 4121
 
4122
-    if(!$gd_page || !$title){return $title;}// if no a GD page then bail.
4123
-    global $post;
4124
-    //print_r($post);
4125
-    /*
4122
+	if(!$gd_page || !$title){return $title;}// if no a GD page then bail.
4123
+	global $post;
4124
+	//print_r($post);
4125
+	/*
4126 4126
     %%date%%	                Replaced with the date of the post/page
4127 4127
     %%title%%	                Replaced with the title of the post/page
4128 4128
     %%sitename%%	            The site's name
@@ -4149,314 +4149,314 @@  discard block
 block discarded – undo
4149 4149
     %%pagenumber%%	            Replaced with the current page number
4150 4150
      */
4151 4151
 
4152
-    if ($sep == '') {
4153
-        /**
4154
-         * Filter the page title separator.
4155
-         *
4156
-         * @since 1.0.0
4157
-         * @package GeoDirectory
4158
-         * @param string $sep The separator, default: `|`.
4159
-         */
4160
-        $sep = apply_filters('geodir_page_title_separator', '|');
4161
-    }
4162
-
4163
-
4164
-    if(strpos($title,'%%title%%') !== false){
4165
-        $title = str_replace("%%title%%",$post->post_title,$title);
4166
-    }
4167
-
4168
-    if(strpos($title,'%%sitename%%') !== false){
4169
-        $title = str_replace("%%sitename%%",get_bloginfo('name'),$title);
4170
-    }
4171
-
4172
-    if(strpos($title,'%%sitedesc%%') !== false){
4173
-        $title = str_replace("%%sitedesc%%",get_bloginfo('description'),$title);
4174
-    }
4175
-
4176
-    if(strpos($title,'%%excerpt%%') !== false){
4177
-        $title = str_replace("%%excerpt%%",strip_tags(get_the_excerpt()),$title);
4178
-    }
4179
-
4180
-    if(strpos($title,'%%pt_single%%') !== false){
4181
-        $single_name = '';
4182
-        if($gd_page=='search' || $gd_page=='author'){
4183
-            $geodir_post_types = get_option('geodir_post_types');
4184
-            $spt = esc_attr($_REQUEST['stype']);
4185
-            if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
4186
-                $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
4187
-            }
4188
-        }elseif($gd_page=='add-listing'){
4189
-            $geodir_post_types = get_option('geodir_post_types');
4190
-            $spt = isset($_REQUEST['listing_type']) ? esc_attr($_REQUEST['listing_type']) : '';
4191
-            if(!$spt && isset($_REQUEST['pid'])){
4192
-                $spt = get_post_type( $_REQUEST['pid'] );
4193
-            }
4194
-            if(!$spt){$spt='gd_place';}
4195
-            if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
4196
-                $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
4197
-            }
4198
-        }
4199
-        elseif($post->post_type){
4200
-            $geodir_post_types = get_option('geodir_post_types');
4201
-            if(isset($geodir_post_types[$post->post_type]['labels']['singular_name'])){
4202
-                $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'],'geodirectory');
4203
-            }
4204
-
4205
-
4206
-        }
4207
-        $title = str_replace("%%pt_single%%",$single_name,$title);
4208
-    }
4209
-
4210
-    if(strpos($title,'%%pt_plural%%') !== false){
4211
-        $plural_name = '';
4212
-        if($gd_page=='search' || $gd_page=='author'){
4213
-            $geodir_post_types = get_option('geodir_post_types');
4214
-            $spt = esc_attr($_REQUEST['stype']);
4215
-            if(isset($geodir_post_types[$spt]['labels']['name'])){
4216
-                $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4217
-            }
4218
-        }elseif($gd_page=='add-listing'){
4219
-            $geodir_post_types = get_option('geodir_post_types');
4220
-            $spt = sanitize_text_field($_REQUEST['listing_type']);
4221
-            if(!$spt){$spt='gd_place';}
4222
-            if(isset($geodir_post_types[$spt]['labels']['name'])){
4223
-                $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4224
-            }
4225
-        }
4226
-        elseif(isset($post->post_type) && $post->post_type){
4227
-            $geodir_post_types = get_option('geodir_post_types');
4228
-            if(isset($geodir_post_types[$post->post_type]['labels']['name'])){
4229
-                $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'],'geodirectory');
4230
-            }
4231
-
4232
-        }
4233
-        $title = str_replace("%%pt_plural%%",$plural_name,$title);
4234
-    }
4235
-
4236
-
4237
-
4238
-    if(strpos($title,'%%category%%') !== false){
4239
-        $cat_name = '';
4240
-
4241
-        if($gd_page=='detail') {
4242
-            if ($post->default_category) {
4243
-                $cat = get_term($post->default_category, $post->post_type . 'category');
4244
-                $cat_name = (isset($cat->name)) ? $cat->name : '';
4245
-            }
4246
-        }elseif($gd_page=='listing'){
4247
-            $queried_object = get_queried_object();
4248
-            if(isset($queried_object->name)){
4249
-                $cat_name = $queried_object->name;
4250
-            }
4251
-        }
4252
-        $title = str_replace("%%category%%",$cat_name,$title);
4253
-    }
4254
-
4255
-    if(strpos($title,'%%tag%%') !== false){
4256
-        $cat_name = '';
4257
-
4258
-        if($gd_page=='detail') {
4259
-            if ($post->default_category) {
4260
-                $cat = get_term($post->default_category, $post->post_type . 'category');
4261
-                $cat_name = (isset($cat->name)) ? $cat->name : '';
4262
-            }
4263
-        }elseif($gd_page=='listing'){
4264
-            $queried_object = get_queried_object();
4265
-            if(isset($queried_object->name)){
4266
-                $cat_name = $queried_object->name;
4267
-            }
4268
-        }
4269
-        $title = str_replace("%%tag%%",$cat_name,$title);
4270
-    }
4271
-
4272
-
4273
-
4274
-    if(strpos($title,'%%id%%') !== false){
4275
-        $ID = (isset($post->ID)) ? $post->ID : '';
4276
-        $title = str_replace("%%id%%",$ID,$title);
4277
-    }
4278
-
4279
-    if(strpos($title,'%%sep%%') !== false){
4280
-        $title = str_replace("%%sep%%",$sep,$title);
4281
-    }
4282
-
4283
-
4284
-    global $wp;
4285
-    // location variables
4286
-    $gd_post_type = geodir_get_current_posttype();
4287
-    $location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
4288
-    /**
4289
-     * Filter the title variables location variables array
4290
-     *
4291
-     * @since 1.5.5
4292
-     * @package GeoDirectory
4293
-     * @param array $location_array The array of location variables.
4294
-     * @param string $title The title with variables..
4295
-     * @param string $gd_page The page being filtered.
4296
-     * @param string $sep The separator, default: `|`.
4297
-     */
4298
-    $location_array = apply_filters('geodir_filter_title_variables_location_arr',$location_array,$title, $gd_page, $sep);
4299
-    $location_titles = array();
4300
-    if($gd_page=='location' && get_query_var( 'gd_country_full' )){
4301
-        if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4302
-        if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4303
-        if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4304
-    }
4305
-    $location_single = '';
4306
-    $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
4307
-    $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
4308
-    $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
4309
-
4310
-    $gd_country_actual = $gd_region_actual = $gd_city_actual = '';
4311
-
4312
-    if (function_exists('get_actual_location_name')) {
4313
-        $gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
4314
-        $gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
4315
-        $gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
4316
-    }
4317
-
4318
-    if ($gd_city != '') {
4319
-        if ($gd_city_actual != '') {
4320
-            $gd_city = $gd_city_actual;
4321
-        } else {
4322
-            $gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
4323
-            $gd_city = preg_replace('/[_-]/', ' ', $gd_city);
4324
-            $gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
4325
-        }
4326
-        $location_single = $gd_city;
4327
-
4328
-    } else if ($gd_region != '') {
4329
-        if ($gd_region_actual != '') {
4330
-            $gd_region = $gd_region_actual;
4331
-        } else {
4332
-            $gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
4333
-            $gd_region = preg_replace('/[_-]/', ' ', $gd_region);
4334
-            $gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
4335
-        }
4336
-
4337
-        $location_single = $gd_region;
4338
-    } else if ($gd_country != '') {
4339
-        if ($gd_country_actual != '') {
4340
-            $gd_country = $gd_country_actual;
4341
-        } else {
4342
-            $gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
4343
-            $gd_country = preg_replace('/[_-]/', ' ', $gd_country);
4344
-            $gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
4345
-        }
4346
-
4347
-        $location_single = $gd_country;
4348
-    }
4349
-
4350
-    if (!empty($location_array)) {
4351
-
4352
-        $actual_location_name = function_exists('get_actual_location_name') ? true : false;
4353
-        $location_array = array_reverse($location_array);
4354
-
4355
-        foreach ($location_array as $location_type => $location) {
4356
-            $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
4357
-            $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
4358
-
4359
-            $location_name = geodir_ucwords($gd_location_link_text);
4360
-            $location_name = __($location_name, 'geodirectory');
4361
-
4362
-            if ($actual_location_name) {
4363
-                $location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type;
4364
-                $location_name = get_actual_location_name($location_type, $location, true);
4365
-            }
4366
-
4367
-            $location_titles[] = $location_name;
4368
-        }
4369
-        if (!empty($location_titles)) {
4370
-            $location_titles = array_unique($location_titles);
4371
-        }
4372
-    }
4373
-
4374
-
4375
-    if(strpos($title,'%%location%%') !== false){
4376
-        $location = '';
4377
-        if($location_titles) {
4378
-            $location = implode(", ", $location_titles);
4379
-        }
4380
-        $title = str_replace("%%location%%",$location,$title);
4381
-    }
4382
-
4383
-    if(strpos($title,'%%in_location%%') !== false){
4384
-        $location = '';
4385
-        if($location_titles) {
4386
-            $location = __('in ', 'geodirectory') . implode(", ", $location_titles);
4387
-        }
4388
-        $title = str_replace("%%in_location%%",$location,$title);
4389
-    }
4390
-
4391
-    if(strpos($title,'%%in_location_single%%') !== false){
4392
-        if($location_single) {
4393
-            $location_single = __('in', 'geodirectory') . ' ' .$location_single;
4394
-        }
4395
-        $title = str_replace("%%in_location_single%%",$location_single,$title);
4396
-    }
4397
-
4398
-    if(strpos($title,'%%location_single%%') !== false){
4399
-        $title = str_replace("%%location_single%%",$location_single,$title);
4400
-    }
4401
-
4402
-
4403
-    if(strpos($title,'%%search_term%%') !== false){
4404
-        $search_term = '';
4405
-        if(isset($_REQUEST['s'])){
4406
-            $search_term = esc_attr($_REQUEST['s']);
4407
-        }
4408
-        $title = str_replace("%%search_term%%",$search_term,$title);
4409
-    }
4410
-
4411
-    if(strpos($title,'%%search_near%%') !== false){
4412
-        $search_term = '';
4413
-        if(isset($_REQUEST['snear'])){
4414
-            $search_term = esc_attr($_REQUEST['snear']);
4415
-        }
4416
-        $title = str_replace("%%search_near%%",$search_term,$title);
4417
-    }
4418
-
4419
-    if(strpos($title,'%%name%%') !== false){
4420
-        $author_name = get_the_author();
4421
-        if (!$author_name || $author_name === '') {
4422
-            $queried_object = get_queried_object();
4152
+	if ($sep == '') {
4153
+		/**
4154
+		 * Filter the page title separator.
4155
+		 *
4156
+		 * @since 1.0.0
4157
+		 * @package GeoDirectory
4158
+		 * @param string $sep The separator, default: `|`.
4159
+		 */
4160
+		$sep = apply_filters('geodir_page_title_separator', '|');
4161
+	}
4162
+
4163
+
4164
+	if(strpos($title,'%%title%%') !== false){
4165
+		$title = str_replace("%%title%%",$post->post_title,$title);
4166
+	}
4167
+
4168
+	if(strpos($title,'%%sitename%%') !== false){
4169
+		$title = str_replace("%%sitename%%",get_bloginfo('name'),$title);
4170
+	}
4171
+
4172
+	if(strpos($title,'%%sitedesc%%') !== false){
4173
+		$title = str_replace("%%sitedesc%%",get_bloginfo('description'),$title);
4174
+	}
4175
+
4176
+	if(strpos($title,'%%excerpt%%') !== false){
4177
+		$title = str_replace("%%excerpt%%",strip_tags(get_the_excerpt()),$title);
4178
+	}
4179
+
4180
+	if(strpos($title,'%%pt_single%%') !== false){
4181
+		$single_name = '';
4182
+		if($gd_page=='search' || $gd_page=='author'){
4183
+			$geodir_post_types = get_option('geodir_post_types');
4184
+			$spt = esc_attr($_REQUEST['stype']);
4185
+			if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
4186
+				$single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
4187
+			}
4188
+		}elseif($gd_page=='add-listing'){
4189
+			$geodir_post_types = get_option('geodir_post_types');
4190
+			$spt = isset($_REQUEST['listing_type']) ? esc_attr($_REQUEST['listing_type']) : '';
4191
+			if(!$spt && isset($_REQUEST['pid'])){
4192
+				$spt = get_post_type( $_REQUEST['pid'] );
4193
+			}
4194
+			if(!$spt){$spt='gd_place';}
4195
+			if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
4196
+				$single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory');
4197
+			}
4198
+		}
4199
+		elseif($post->post_type){
4200
+			$geodir_post_types = get_option('geodir_post_types');
4201
+			if(isset($geodir_post_types[$post->post_type]['labels']['singular_name'])){
4202
+				$single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'],'geodirectory');
4203
+			}
4204
+
4205
+
4206
+		}
4207
+		$title = str_replace("%%pt_single%%",$single_name,$title);
4208
+	}
4209
+
4210
+	if(strpos($title,'%%pt_plural%%') !== false){
4211
+		$plural_name = '';
4212
+		if($gd_page=='search' || $gd_page=='author'){
4213
+			$geodir_post_types = get_option('geodir_post_types');
4214
+			$spt = esc_attr($_REQUEST['stype']);
4215
+			if(isset($geodir_post_types[$spt]['labels']['name'])){
4216
+				$plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4217
+			}
4218
+		}elseif($gd_page=='add-listing'){
4219
+			$geodir_post_types = get_option('geodir_post_types');
4220
+			$spt = sanitize_text_field($_REQUEST['listing_type']);
4221
+			if(!$spt){$spt='gd_place';}
4222
+			if(isset($geodir_post_types[$spt]['labels']['name'])){
4223
+				$plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory');
4224
+			}
4225
+		}
4226
+		elseif(isset($post->post_type) && $post->post_type){
4227
+			$geodir_post_types = get_option('geodir_post_types');
4228
+			if(isset($geodir_post_types[$post->post_type]['labels']['name'])){
4229
+				$plural_name = __($geodir_post_types[$post->post_type]['labels']['name'],'geodirectory');
4230
+			}
4231
+
4232
+		}
4233
+		$title = str_replace("%%pt_plural%%",$plural_name,$title);
4234
+	}
4235
+
4236
+
4237
+
4238
+	if(strpos($title,'%%category%%') !== false){
4239
+		$cat_name = '';
4240
+
4241
+		if($gd_page=='detail') {
4242
+			if ($post->default_category) {
4243
+				$cat = get_term($post->default_category, $post->post_type . 'category');
4244
+				$cat_name = (isset($cat->name)) ? $cat->name : '';
4245
+			}
4246
+		}elseif($gd_page=='listing'){
4247
+			$queried_object = get_queried_object();
4248
+			if(isset($queried_object->name)){
4249
+				$cat_name = $queried_object->name;
4250
+			}
4251
+		}
4252
+		$title = str_replace("%%category%%",$cat_name,$title);
4253
+	}
4254
+
4255
+	if(strpos($title,'%%tag%%') !== false){
4256
+		$cat_name = '';
4257
+
4258
+		if($gd_page=='detail') {
4259
+			if ($post->default_category) {
4260
+				$cat = get_term($post->default_category, $post->post_type . 'category');
4261
+				$cat_name = (isset($cat->name)) ? $cat->name : '';
4262
+			}
4263
+		}elseif($gd_page=='listing'){
4264
+			$queried_object = get_queried_object();
4265
+			if(isset($queried_object->name)){
4266
+				$cat_name = $queried_object->name;
4267
+			}
4268
+		}
4269
+		$title = str_replace("%%tag%%",$cat_name,$title);
4270
+	}
4271
+
4272
+
4273
+
4274
+	if(strpos($title,'%%id%%') !== false){
4275
+		$ID = (isset($post->ID)) ? $post->ID : '';
4276
+		$title = str_replace("%%id%%",$ID,$title);
4277
+	}
4278
+
4279
+	if(strpos($title,'%%sep%%') !== false){
4280
+		$title = str_replace("%%sep%%",$sep,$title);
4281
+	}
4282
+
4283
+
4284
+	global $wp;
4285
+	// location variables
4286
+	$gd_post_type = geodir_get_current_posttype();
4287
+	$location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
4288
+	/**
4289
+	 * Filter the title variables location variables array
4290
+	 *
4291
+	 * @since 1.5.5
4292
+	 * @package GeoDirectory
4293
+	 * @param array $location_array The array of location variables.
4294
+	 * @param string $title The title with variables..
4295
+	 * @param string $gd_page The page being filtered.
4296
+	 * @param string $sep The separator, default: `|`.
4297
+	 */
4298
+	$location_array = apply_filters('geodir_filter_title_variables_location_arr',$location_array,$title, $gd_page, $sep);
4299
+	$location_titles = array();
4300
+	if($gd_page=='location' && get_query_var( 'gd_country_full' )){
4301
+		if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
4302
+		if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
4303
+		if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
4304
+	}
4305
+	$location_single = '';
4306
+	$gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : '';
4307
+	$gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : '';
4308
+	$gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
4309
+
4310
+	$gd_country_actual = $gd_region_actual = $gd_city_actual = '';
4311
+
4312
+	if (function_exists('get_actual_location_name')) {
4313
+		$gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
4314
+		$gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
4315
+		$gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
4316
+	}
4317
+
4318
+	if ($gd_city != '') {
4319
+		if ($gd_city_actual != '') {
4320
+			$gd_city = $gd_city_actual;
4321
+		} else {
4322
+			$gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
4323
+			$gd_city = preg_replace('/[_-]/', ' ', $gd_city);
4324
+			$gd_city = __(geodir_ucwords($gd_city), 'geodirectory');
4325
+		}
4326
+		$location_single = $gd_city;
4327
+
4328
+	} else if ($gd_region != '') {
4329
+		if ($gd_region_actual != '') {
4330
+			$gd_region = $gd_region_actual;
4331
+		} else {
4332
+			$gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
4333
+			$gd_region = preg_replace('/[_-]/', ' ', $gd_region);
4334
+			$gd_region = __(geodir_ucwords($gd_region), 'geodirectory');
4335
+		}
4336
+
4337
+		$location_single = $gd_region;
4338
+	} else if ($gd_country != '') {
4339
+		if ($gd_country_actual != '') {
4340
+			$gd_country = $gd_country_actual;
4341
+		} else {
4342
+			$gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
4343
+			$gd_country = preg_replace('/[_-]/', ' ', $gd_country);
4344
+			$gd_country = __(geodir_ucwords($gd_country), 'geodirectory');
4345
+		}
4346
+
4347
+		$location_single = $gd_country;
4348
+	}
4349
+
4350
+	if (!empty($location_array)) {
4351
+
4352
+		$actual_location_name = function_exists('get_actual_location_name') ? true : false;
4353
+		$location_array = array_reverse($location_array);
4354
+
4355
+		foreach ($location_array as $location_type => $location) {
4356
+			$gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
4357
+			$gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
4358
+
4359
+			$location_name = geodir_ucwords($gd_location_link_text);
4360
+			$location_name = __($location_name, 'geodirectory');
4361
+
4362
+			if ($actual_location_name) {
4363
+				$location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type;
4364
+				$location_name = get_actual_location_name($location_type, $location, true);
4365
+			}
4366
+
4367
+			$location_titles[] = $location_name;
4368
+		}
4369
+		if (!empty($location_titles)) {
4370
+			$location_titles = array_unique($location_titles);
4371
+		}
4372
+	}
4373
+
4374
+
4375
+	if(strpos($title,'%%location%%') !== false){
4376
+		$location = '';
4377
+		if($location_titles) {
4378
+			$location = implode(", ", $location_titles);
4379
+		}
4380
+		$title = str_replace("%%location%%",$location,$title);
4381
+	}
4382
+
4383
+	if(strpos($title,'%%in_location%%') !== false){
4384
+		$location = '';
4385
+		if($location_titles) {
4386
+			$location = __('in ', 'geodirectory') . implode(", ", $location_titles);
4387
+		}
4388
+		$title = str_replace("%%in_location%%",$location,$title);
4389
+	}
4390
+
4391
+	if(strpos($title,'%%in_location_single%%') !== false){
4392
+		if($location_single) {
4393
+			$location_single = __('in', 'geodirectory') . ' ' .$location_single;
4394
+		}
4395
+		$title = str_replace("%%in_location_single%%",$location_single,$title);
4396
+	}
4397
+
4398
+	if(strpos($title,'%%location_single%%') !== false){
4399
+		$title = str_replace("%%location_single%%",$location_single,$title);
4400
+	}
4401
+
4402
+
4403
+	if(strpos($title,'%%search_term%%') !== false){
4404
+		$search_term = '';
4405
+		if(isset($_REQUEST['s'])){
4406
+			$search_term = esc_attr($_REQUEST['s']);
4407
+		}
4408
+		$title = str_replace("%%search_term%%",$search_term,$title);
4409
+	}
4410
+
4411
+	if(strpos($title,'%%search_near%%') !== false){
4412
+		$search_term = '';
4413
+		if(isset($_REQUEST['snear'])){
4414
+			$search_term = esc_attr($_REQUEST['snear']);
4415
+		}
4416
+		$title = str_replace("%%search_near%%",$search_term,$title);
4417
+	}
4418
+
4419
+	if(strpos($title,'%%name%%') !== false){
4420
+		$author_name = get_the_author();
4421
+		if (!$author_name || $author_name === '') {
4422
+			$queried_object = get_queried_object();
4423 4423
             
4424
-            if (isset($queried_object->data->user_nicename)) {
4425
-                $author_name = $queried_object->data->user_nicename;
4426
-            }
4427
-        }
4428
-        $title = str_replace("%%name%%", $author_name, $title);
4429
-    }
4424
+			if (isset($queried_object->data->user_nicename)) {
4425
+				$author_name = $queried_object->data->user_nicename;
4426
+			}
4427
+		}
4428
+		$title = str_replace("%%name%%", $author_name, $title);
4429
+	}
4430 4430
     
4431
-    if (strpos($title, '%%page%%') !== false) {
4432
-        $page = geodir_title_meta_page($sep);
4433
-        $title = str_replace("%%page%%", $page, $title);
4434
-    }
4435
-    if (strpos($title, '%%pagenumber%%') !== false) {
4436
-        $pagenumber = geodir_title_meta_pagenumber();
4437
-        $title = str_replace("%%pagenumber%%", $pagenumber, $title);
4438
-    }
4439
-    if (strpos($title, '%%pagetotal%%') !== false) {
4440
-        $pagetotal = geodir_title_meta_pagetotal();
4441
-        $title = str_replace("%%pagetotal%%", $pagetotal, $title);
4442
-    }
4443
-
4444
-    $title = wptexturize( $title );
4445
-    $title = convert_chars( $title );
4446
-    $title = esc_html( $title );
4447
-
4448
-    /**
4449
-     * Filter the title variables after standard ones have been filtered.
4450
-     *
4451
-     * @since 1.5.7
4452
-     * @package GeoDirectory
4453
-     * @param string $title The title with variables.
4454
-     * @param array $location_array The array of location variables.
4455
-     * @param string $gd_page The page being filtered.
4456
-     * @param string $sep The separator, default: `|`.
4457
-     */
4431
+	if (strpos($title, '%%page%%') !== false) {
4432
+		$page = geodir_title_meta_page($sep);
4433
+		$title = str_replace("%%page%%", $page, $title);
4434
+	}
4435
+	if (strpos($title, '%%pagenumber%%') !== false) {
4436
+		$pagenumber = geodir_title_meta_pagenumber();
4437
+		$title = str_replace("%%pagenumber%%", $pagenumber, $title);
4438
+	}
4439
+	if (strpos($title, '%%pagetotal%%') !== false) {
4440
+		$pagetotal = geodir_title_meta_pagetotal();
4441
+		$title = str_replace("%%pagetotal%%", $pagetotal, $title);
4442
+	}
4458 4443
 
4459
-    return apply_filters('geodir_filter_title_variables_vars',$title,$location_array, $gd_page, $sep);
4444
+	$title = wptexturize( $title );
4445
+	$title = convert_chars( $title );
4446
+	$title = esc_html( $title );
4447
+
4448
+	/**
4449
+	 * Filter the title variables after standard ones have been filtered.
4450
+	 *
4451
+	 * @since 1.5.7
4452
+	 * @package GeoDirectory
4453
+	 * @param string $title The title with variables.
4454
+	 * @param array $location_array The array of location variables.
4455
+	 * @param string $gd_page The page being filtered.
4456
+	 * @param string $sep The separator, default: `|`.
4457
+	 */
4458
+
4459
+	return apply_filters('geodir_filter_title_variables_vars',$title,$location_array, $gd_page, $sep);
4460 4460
 }
4461 4461
 
4462 4462
 /**
@@ -4469,65 +4469,65 @@  discard block
 block discarded – undo
4469 4469
  * @return array Translation texts.
4470 4470
  */
4471 4471
 function geodir_load_cpt_text_translation($translation_texts = array()) {
4472
-    $gd_post_types = geodir_get_posttypes('array');
4473
-
4474
-    if (!empty($gd_post_types)) {
4475
-        foreach ($gd_post_types as $post_type => $cpt_info) {
4476
-            $labels = isset($cpt_info['labels']) ? $cpt_info['labels'] : '';
4477
-            $description = isset($cpt_info['description']) ? $cpt_info['description'] : '';
4478
-            $seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : '';
4479
-
4480
-            if (!empty($labels)) {
4481
-                if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts))
4482
-                    $translation_texts[] = $labels['name'];
4483
-                if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts))
4484
-                    $translation_texts[] = $labels['singular_name'];
4485
-                if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts))
4486
-                    $translation_texts[] = $labels['add_new'];
4487
-                if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts))
4488
-                    $translation_texts[] = $labels['add_new_item'];
4489
-                if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts))
4490
-                    $translation_texts[] = $labels['edit_item'];
4491
-                if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts))
4492
-                    $translation_texts[] = $labels['new_item'];
4493
-                if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts))
4494
-                    $translation_texts[] = $labels['view_item'];
4495
-                if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts))
4496
-                    $translation_texts[] = $labels['search_items'];
4497
-                if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts))
4498
-                    $translation_texts[] = $labels['not_found'];
4499
-                if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts))
4500
-                    $translation_texts[] = $labels['not_found_in_trash'];
4501
-                if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts))
4502
-                    $translation_texts[] = $labels['label_post_profile'];
4503
-                if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts))
4504
-                    $translation_texts[] = $labels['label_post_info'];
4505
-                if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts))
4506
-                    $translation_texts[] = $labels['label_post_images'];
4507
-                if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts))
4508
-                    $translation_texts[] = $labels['label_post_map'];
4509
-                if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts))
4510
-                    $translation_texts[] = $labels['label_reviews'];
4511
-                if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts))
4512
-                    $translation_texts[] = $labels['label_related_listing'];
4513
-            }
4514
-
4515
-            if ($description != '' && !in_array($description, $translation_texts)) {
4516
-                $translation_texts[] = normalize_whitespace($description);
4517
-            }
4518
-
4519
-            if (!empty($seo)) {
4520
-                if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts))
4521
-                    $translation_texts[] = normalize_whitespace($seo['meta_keyword']);
4522
-
4523
-                if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts))
4524
-                    $translation_texts[] = normalize_whitespace($seo['meta_description']);
4525
-            }
4526
-        }
4527
-    }
4528
-    $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
4529
-
4530
-    return $translation_texts;
4472
+	$gd_post_types = geodir_get_posttypes('array');
4473
+
4474
+	if (!empty($gd_post_types)) {
4475
+		foreach ($gd_post_types as $post_type => $cpt_info) {
4476
+			$labels = isset($cpt_info['labels']) ? $cpt_info['labels'] : '';
4477
+			$description = isset($cpt_info['description']) ? $cpt_info['description'] : '';
4478
+			$seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : '';
4479
+
4480
+			if (!empty($labels)) {
4481
+				if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts))
4482
+					$translation_texts[] = $labels['name'];
4483
+				if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts))
4484
+					$translation_texts[] = $labels['singular_name'];
4485
+				if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts))
4486
+					$translation_texts[] = $labels['add_new'];
4487
+				if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts))
4488
+					$translation_texts[] = $labels['add_new_item'];
4489
+				if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts))
4490
+					$translation_texts[] = $labels['edit_item'];
4491
+				if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts))
4492
+					$translation_texts[] = $labels['new_item'];
4493
+				if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts))
4494
+					$translation_texts[] = $labels['view_item'];
4495
+				if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts))
4496
+					$translation_texts[] = $labels['search_items'];
4497
+				if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts))
4498
+					$translation_texts[] = $labels['not_found'];
4499
+				if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts))
4500
+					$translation_texts[] = $labels['not_found_in_trash'];
4501
+				if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts))
4502
+					$translation_texts[] = $labels['label_post_profile'];
4503
+				if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts))
4504
+					$translation_texts[] = $labels['label_post_info'];
4505
+				if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts))
4506
+					$translation_texts[] = $labels['label_post_images'];
4507
+				if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts))
4508
+					$translation_texts[] = $labels['label_post_map'];
4509
+				if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts))
4510
+					$translation_texts[] = $labels['label_reviews'];
4511
+				if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts))
4512
+					$translation_texts[] = $labels['label_related_listing'];
4513
+			}
4514
+
4515
+			if ($description != '' && !in_array($description, $translation_texts)) {
4516
+				$translation_texts[] = normalize_whitespace($description);
4517
+			}
4518
+
4519
+			if (!empty($seo)) {
4520
+				if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts))
4521
+					$translation_texts[] = normalize_whitespace($seo['meta_keyword']);
4522
+
4523
+				if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts))
4524
+					$translation_texts[] = normalize_whitespace($seo['meta_description']);
4525
+			}
4526
+		}
4527
+	}
4528
+	$translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts;
4529
+
4530
+	return $translation_texts;
4531 4531
 }
4532 4532
 
4533 4533
 /**
@@ -4540,27 +4540,27 @@  discard block
 block discarded – undo
4540 4540
  * @return array Location terms.
4541 4541
  */
4542 4542
 function geodir_remove_location_terms($location_terms = array()) {
4543
-    $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
4544
-
4545
-    if (!empty($location_terms) && $location_manager) {
4546
-        $hide_country_part = get_option('geodir_location_hide_country_part');
4547
-        $hide_region_part = get_option('geodir_location_hide_region_part');
4548
-
4549
-        if ($hide_region_part && $hide_country_part) {
4550
-            if (isset($location_terms['gd_country']))
4551
-                unset($location_terms['gd_country']);
4552
-            if (isset($location_terms['gd_region']))
4553
-                unset($location_terms['gd_region']);
4554
-        } else if ($hide_region_part && !$hide_country_part) {
4555
-            if (isset($location_terms['gd_region']))
4556
-                unset($location_terms['gd_region']);
4557
-        } else if (!$hide_region_part && $hide_country_part) {
4558
-            if (isset($location_terms['gd_country']))
4559
-                unset($location_terms['gd_country']);
4560
-        }
4561
-    }
4562
-
4563
-    return $location_terms;
4543
+	$location_manager = defined('POST_LOCATION_TABLE') ? true : false;
4544
+
4545
+	if (!empty($location_terms) && $location_manager) {
4546
+		$hide_country_part = get_option('geodir_location_hide_country_part');
4547
+		$hide_region_part = get_option('geodir_location_hide_region_part');
4548
+
4549
+		if ($hide_region_part && $hide_country_part) {
4550
+			if (isset($location_terms['gd_country']))
4551
+				unset($location_terms['gd_country']);
4552
+			if (isset($location_terms['gd_region']))
4553
+				unset($location_terms['gd_region']);
4554
+		} else if ($hide_region_part && !$hide_country_part) {
4555
+			if (isset($location_terms['gd_region']))
4556
+				unset($location_terms['gd_region']);
4557
+		} else if (!$hide_region_part && $hide_country_part) {
4558
+			if (isset($location_terms['gd_country']))
4559
+				unset($location_terms['gd_country']);
4560
+		}
4561
+	}
4562
+
4563
+	return $location_terms;
4564 4564
 }
4565 4565
 
4566 4566
 /**
@@ -4574,47 +4574,47 @@  discard block
 block discarded – undo
4574 4574
  * @param bool $update Whether this is an existing listing being updated or not.
4575 4575
  */
4576 4576
 function geodir_on_wp_insert_post($post_ID, $post, $update) {
4577
-    if (!$update) {
4578
-        return;
4579
-    }
4577
+	if (!$update) {
4578
+		return;
4579
+	}
4580 4580
     
4581
-    $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : '';
4582
-    $is_admin = is_admin() && ( !defined('DOING_AJAX' ) || ( defined('DOING_AJAX') && !DOING_AJAX ) )  ? true : false;
4583
-    $inline_save = $action == 'inline-save' ? true : false;
4581
+	$action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : '';
4582
+	$is_admin = is_admin() && ( !defined('DOING_AJAX' ) || ( defined('DOING_AJAX') && !DOING_AJAX ) )  ? true : false;
4583
+	$inline_save = $action == 'inline-save' ? true : false;
4584 4584
 
4585
-    if (empty($post->post_type) || $is_admin || $inline_save || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) {
4586
-        return;
4587
-    }
4585
+	if (empty($post->post_type) || $is_admin || $inline_save || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) {
4586
+		return;
4587
+	}
4588 4588
     
4589
-    if ($action != '' && in_array($action, array('geodir_import_export'))) {
4590
-        return;
4591
-    }
4589
+	if ($action != '' && in_array($action, array('geodir_import_export'))) {
4590
+		return;
4591
+	}
4592 4592
 
4593
-    $user_id = (int)get_current_user_id();
4593
+	$user_id = (int)get_current_user_id();
4594 4594
         
4595
-    if ($user_id > 0 && get_option('geodir_notify_post_edited') && !wp_is_post_revision($post_ID) && in_array($post->post_type, geodir_get_posttypes())) {
4596
-        $author_id = !empty($post->post_author) ? $post->post_author : 0;
4595
+	if ($user_id > 0 && get_option('geodir_notify_post_edited') && !wp_is_post_revision($post_ID) && in_array($post->post_type, geodir_get_posttypes())) {
4596
+		$author_id = !empty($post->post_author) ? $post->post_author : 0;
4597 4597
         
4598
-        if ($user_id == $author_id && !is_super_admin()) {
4599
-            $from_email = get_option('site_email');
4600
-            $from_name = get_site_emailName();
4601
-            $to_email = get_option('admin_email');
4602
-            $to_name = get_option('name');
4603
-            $message_type = 'listing_edited';
4598
+		if ($user_id == $author_id && !is_super_admin()) {
4599
+			$from_email = get_option('site_email');
4600
+			$from_name = get_site_emailName();
4601
+			$to_email = get_option('admin_email');
4602
+			$to_name = get_option('name');
4603
+			$message_type = 'listing_edited';
4604 4604
             
4605
-            $notify_edited = true;
4606
-            /**
4607
-             * Send notification when listing edited by author?
4608
-             *
4609
-             * @since 1.6.0
4610
-             * @param bool $notify_edited Notify on listing edited by author?
4611
-             * @param object $post The current post object.
4612
-             */
4613
-            $notify_edited = apply_filters('geodir_notify_on_listing_edited', $notify_edited, $post);
4605
+			$notify_edited = true;
4606
+			/**
4607
+			 * Send notification when listing edited by author?
4608
+			 *
4609
+			 * @since 1.6.0
4610
+			 * @param bool $notify_edited Notify on listing edited by author?
4611
+			 * @param object $post The current post object.
4612
+			 */
4613
+			$notify_edited = apply_filters('geodir_notify_on_listing_edited', $notify_edited, $post);
4614 4614
             
4615
-            geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID);
4616
-        }
4617
-    }
4615
+			geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID);
4616
+		}
4617
+	}
4618 4618
 }
4619 4619
 
4620 4620
 /**
@@ -4628,16 +4628,16 @@  discard block
 block discarded – undo
4628 4628
  * @return string|null The current page start & end numbering.
4629 4629
  */
4630 4630
 function geodir_title_meta_page($sep) {
4631
-    $replacement = null;
4631
+	$replacement = null;
4632 4632
 
4633
-    $max = geodir_title_meta_pagenumbering('max');
4634
-    $nr  = geodir_title_meta_pagenumbering('nr');
4633
+	$max = geodir_title_meta_pagenumbering('max');
4634
+	$nr  = geodir_title_meta_pagenumbering('nr');
4635 4635
 
4636
-    if ($max > 1 && $nr > 1) {
4637
-        $replacement = sprintf($sep . ' ' . __('Page %1$d of %2$d', 'geodirectory'), $nr, $max);
4638
-    }
4636
+	if ($max > 1 && $nr > 1) {
4637
+		$replacement = sprintf($sep . ' ' . __('Page %1$d of %2$d', 'geodirectory'), $nr, $max);
4638
+	}
4639 4639
 
4640
-    return $replacement;
4640
+	return $replacement;
4641 4641
 }
4642 4642
 
4643 4643
 /**
@@ -4649,14 +4649,14 @@  discard block
 block discarded – undo
4649 4649
  * @return string|null The current page number.
4650 4650
  */
4651 4651
 function geodir_title_meta_pagenumber() {
4652
-    $replacement = null;
4652
+	$replacement = null;
4653 4653
 
4654
-    $nr = geodir_title_meta_pagenumbering('nr');
4655
-    if (isset($nr) && $nr > 0) {
4656
-        $replacement = (string)$nr;
4657
-    }
4654
+	$nr = geodir_title_meta_pagenumbering('nr');
4655
+	if (isset($nr) && $nr > 0) {
4656
+		$replacement = (string)$nr;
4657
+	}
4658 4658
 
4659
-    return $replacement;
4659
+	return $replacement;
4660 4660
 }
4661 4661
 
4662 4662
 /**
@@ -4668,14 +4668,14 @@  discard block
 block discarded – undo
4668 4668
  * @return string|null The current page total.
4669 4669
  */
4670 4670
 function geodir_title_meta_pagetotal() {
4671
-    $replacement = null;
4671
+	$replacement = null;
4672 4672
 
4673
-    $max = geodir_title_meta_pagenumbering('max');
4674
-    if (isset($max) && $max > 0) {
4675
-        $replacement = (string)$max;
4676
-    }
4673
+	$max = geodir_title_meta_pagenumbering('max');
4674
+	if (isset($max) && $max > 0) {
4675
+		$replacement = (string)$max;
4676
+	}
4677 4677
 
4678
-    return $replacement;
4678
+	return $replacement;
4679 4679
 }
4680 4680
 
4681 4681
 /**
@@ -4692,44 +4692,44 @@  discard block
 block discarded – undo
4692 4692
  * @return int|null The current page numbering.
4693 4693
  */
4694 4694
 function geodir_title_meta_pagenumbering($request = 'nr') {
4695
-    global $wp_query, $post;
4696
-    $max_num_pages = null;
4697
-    $page_number   = null;
4698
-
4699
-    $max_num_pages = 1;
4700
-
4701
-    if (!is_singular()) {
4702
-        $page_number = get_query_var('paged');
4703
-        if ($page_number === 0 || $page_number === '') {
4704
-            $page_number = 1;
4705
-        }
4706
-
4707
-        if (isset($wp_query->max_num_pages) && ($wp_query->max_num_pages != '' && $wp_query->max_num_pages != 0)) {
4708
-            $max_num_pages = $wp_query->max_num_pages;
4709
-        }
4710
-    } else {
4711
-        $page_number = get_query_var('page');
4712
-        if ($page_number === 0 || $page_number === '') {
4713
-            $page_number = 1;
4714
-        }
4715
-
4716
-        if (isset($post->post_content)) {
4717
-            $max_num_pages = (substr_count($post->post_content, '<!--nextpage-->' ) + 1);
4718
-        }
4719
-    }
4720
-
4721
-    $return = null;
4722
-
4723
-    switch ($request) {
4724
-        case 'nr':
4725
-            $return = $page_number;
4726
-            break;
4727
-        case 'max':
4728
-            $return = $max_num_pages;
4729
-            break;
4730
-    }
4731
-
4732
-    return $return;
4695
+	global $wp_query, $post;
4696
+	$max_num_pages = null;
4697
+	$page_number   = null;
4698
+
4699
+	$max_num_pages = 1;
4700
+
4701
+	if (!is_singular()) {
4702
+		$page_number = get_query_var('paged');
4703
+		if ($page_number === 0 || $page_number === '') {
4704
+			$page_number = 1;
4705
+		}
4706
+
4707
+		if (isset($wp_query->max_num_pages) && ($wp_query->max_num_pages != '' && $wp_query->max_num_pages != 0)) {
4708
+			$max_num_pages = $wp_query->max_num_pages;
4709
+		}
4710
+	} else {
4711
+		$page_number = get_query_var('page');
4712
+		if ($page_number === 0 || $page_number === '') {
4713
+			$page_number = 1;
4714
+		}
4715
+
4716
+		if (isset($post->post_content)) {
4717
+			$max_num_pages = (substr_count($post->post_content, '<!--nextpage-->' ) + 1);
4718
+		}
4719
+	}
4720
+
4721
+	$return = null;
4722
+
4723
+	switch ($request) {
4724
+		case 'nr':
4725
+			$return = $page_number;
4726
+			break;
4727
+		case 'max':
4728
+			$return = $max_num_pages;
4729
+			break;
4730
+	}
4731
+
4732
+	return $return;
4733 4733
 }
4734 4734
 
4735 4735
 /**
@@ -4741,15 +4741,15 @@  discard block
 block discarded – undo
4741 4741
  * @return array Terms.
4742 4742
  */
4743 4743
 function geodir_filter_empty_terms($terms) {
4744
-    if (empty($terms)) {
4745
-        return $terms;
4746
-    }
4747
-
4748
-    $return = array();
4749
-    foreach ($terms as $term) {
4750
-        if (isset($term->count) && $term->count > 0) {
4751
-            $return[] = $term;
4752
-        }
4753
-    }
4754
-    return $return;
4744
+	if (empty($terms)) {
4745
+		return $terms;
4746
+	}
4747
+
4748
+	$return = array();
4749
+	foreach ($terms as $term) {
4750
+		if (isset($term->count) && $term->count > 0) {
4751
+			$return[] = $term;
4752
+		}
4753
+	}
4754
+	return $return;
4755 4755
 }
4756 4756
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory-functions/geodir-class-session.php 3 patches
Doc Comments   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -151,8 +151,7 @@  discard block
 block discarded – undo
151 151
 	 * @since 1.5.7
152 152
 	 *
153 153
 	 * @param string|array $key Session key.
154
-	 * @param integer $value Session variable.
155
-	 * @return string Session variable.
154
+	 * @return boolean Session variable.
156 155
 	 */
157 156
 	public function un_set( $key ) {
158 157
 		if ( empty( $key ) ) {
@@ -188,8 +187,7 @@  discard block
 block discarded – undo
188 187
 	 * @since 1.5.7
189 188
 	 *
190 189
 	 * @param string $key Session key.
191
-	 * @param integer $value Session variable.
192
-	 * @return string Session variable.
190
+	 * @return boolean Session variable.
193 191
 	 */
194 192
 	public function is_set( $key ) {
195 193
 		$key = sanitize_key( $key );
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly.
3
-if (!defined( 'ABSPATH' ) ) exit;
3
+if (!defined( 'ABSPATH' ) ) {
4
+	exit;
5
+}
4 6
 
5 7
 /**
6 8
  * Geodir_Session Class.
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly.
3
-if (!defined( 'ABSPATH' ) ) exit;
3
+if (!defined('ABSPATH')) exit;
4 4
 
5 5
 /**
6 6
  * Geodir_Session Class.
@@ -46,36 +46,36 @@  discard block
 block discarded – undo
46 46
 	public function __construct() {
47 47
 		$this->use_php_sessions = $this->use_php_sessions();
48 48
 
49
-		if ( $this->use_php_sessions ) {
50
-			if ( is_multisite() ) {
51
-				$this->prefix = '_' . get_current_blog_id();
49
+		if ($this->use_php_sessions) {
50
+			if (is_multisite()) {
51
+				$this->prefix = '_'.get_current_blog_id();
52 52
 			}
53 53
 
54 54
 			// Use PHP SESSION (must be enabled via the GEODIR_USE_PHP_SESSIONS constant)
55
-			add_action( 'init', array( $this, 'maybe_start_session' ), -2 );
55
+			add_action('init', array($this, 'maybe_start_session'), -2);
56 56
 		} else {
57 57
 			// Use WP_Session (default)
58
-			if ( !defined( 'WP_SESSION_COOKIE' ) ) {
59
-				define( 'WP_SESSION_COOKIE', 'geodir_wp_session' );
58
+			if (!defined('WP_SESSION_COOKIE')) {
59
+				define('WP_SESSION_COOKIE', 'geodir_wp_session');
60 60
 			}
61 61
 
62
-			if ( !class_exists( 'Recursive_ArrayAccess' ) ) {
63
-				require_once GEODIRECTORY_PLUGIN_DIR . 'geodirectory-functions/wp-session/class-recursive-arrayaccess.php';
62
+			if (!class_exists('Recursive_ArrayAccess')) {
63
+				require_once GEODIRECTORY_PLUGIN_DIR.'geodirectory-functions/wp-session/class-recursive-arrayaccess.php';
64 64
 			}
65 65
 
66
-			if ( !class_exists( 'WP_Session' ) ) {
67
-				require_once GEODIRECTORY_PLUGIN_DIR . 'geodirectory-functions/wp-session/class-wp-session.php';
68
-				require_once GEODIRECTORY_PLUGIN_DIR . 'geodirectory-functions/wp-session/wp-session.php';
66
+			if (!class_exists('WP_Session')) {
67
+				require_once GEODIRECTORY_PLUGIN_DIR.'geodirectory-functions/wp-session/class-wp-session.php';
68
+				require_once GEODIRECTORY_PLUGIN_DIR.'geodirectory-functions/wp-session/wp-session.php';
69 69
 			}
70 70
 
71
-			add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 );
72
-			add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 );
71
+			add_filter('wp_session_expiration_variant', array($this, 'set_expiration_variant_time'), 99999);
72
+			add_filter('wp_session_expiration', array($this, 'set_expiration_time'), 99999);
73 73
 		}
74 74
 
75
-		if ( empty( $this->session ) && ! $this->use_php_sessions ) {
76
-			add_action( 'plugins_loaded', array( $this, 'init' ), -1 );
75
+		if (empty($this->session) && !$this->use_php_sessions) {
76
+			add_action('plugins_loaded', array($this, 'init'), -1);
77 77
 		} else {
78
-			add_action( 'init', array( $this, 'init' ), -1 );
78
+			add_action('init', array($this, 'init'), -1);
79 79
 		}
80 80
 	}
81 81
 
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 	 * @return void
88 88
 	 */
89 89
 	public function init() {
90
-		if ( $this->use_php_sessions ) {
91
-			$this->session = isset( $_SESSION['gd' . $this->prefix ] ) && is_array( $_SESSION['gd' . $this->prefix ] ) ? $_SESSION['gd' . $this->prefix ] : array();
90
+		if ($this->use_php_sessions) {
91
+			$this->session = isset($_SESSION['gd'.$this->prefix]) && is_array($_SESSION['gd'.$this->prefix]) ? $_SESSION['gd'.$this->prefix] : array();
92 92
 		} else {
93 93
 			$this->session = WP_Session::get_instance();
94 94
 		}
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
 	 * @param string $key Session key
116 116
 	 * @return string Session variable
117 117
 	 */
118
-	public function get( $key ) {
119
-		$key = sanitize_key( $key );
120
-		return isset( $this->session[ $key ] ) ? maybe_unserialize( $this->session[ $key ] ) : false;
118
+	public function get($key) {
119
+		$key = sanitize_key($key);
120
+		return isset($this->session[$key]) ? maybe_unserialize($this->session[$key]) : false;
121 121
 	}
122 122
 
123 123
 	/**
@@ -129,20 +129,20 @@  discard block
 block discarded – undo
129 129
 	 * @param integer $value Session variable
130 130
 	 * @return string Session variable
131 131
 	 */
132
-	public function set( $key, $value ) {
133
-		$key = sanitize_key( $key );
132
+	public function set($key, $value) {
133
+		$key = sanitize_key($key);
134 134
 
135
-		if ( is_array( $value ) ) {
136
-			$this->session[ $key ] = maybe_serialize( $value );
135
+		if (is_array($value)) {
136
+			$this->session[$key] = maybe_serialize($value);
137 137
 		} else {
138
-			$this->session[ $key ] = $value;
138
+			$this->session[$key] = $value;
139 139
 		}
140 140
 
141
-		if ( $this->use_php_sessions ) {
142
-			$_SESSION['gd' . $this->prefix ] = $this->session;
141
+		if ($this->use_php_sessions) {
142
+			$_SESSION['gd'.$this->prefix] = $this->session;
143 143
 		}
144 144
 
145
-		return $this->session[ $key ];
145
+		return $this->session[$key];
146 146
 	}
147 147
 	
148 148
 	/**
@@ -154,29 +154,29 @@  discard block
 block discarded – undo
154 154
 	 * @param integer $value Session variable.
155 155
 	 * @return string Session variable.
156 156
 	 */
157
-	public function un_set( $key ) {
158
-		if ( empty( $key ) ) {
157
+	public function un_set($key) {
158
+		if (empty($key)) {
159 159
 			return false;
160 160
 		}
161 161
 		
162
-		if ( is_array( $key ) ) {
162
+		if (is_array($key)) {
163 163
 			foreach ($key as $index) {
164
-				$index = sanitize_key( $index );
164
+				$index = sanitize_key($index);
165 165
 			
166
-				if ( $index && isset( $this->session[ $index ] ) ) {
167
-					unset( $this->session[ $index ] );
166
+				if ($index && isset($this->session[$index])) {
167
+					unset($this->session[$index]);
168 168
 				}
169 169
 			}
170 170
 		} else {
171
-			$key = sanitize_key( $key );
171
+			$key = sanitize_key($key);
172 172
 			
173
-			if ( isset( $this->session[ $key ] ) ) {
174
-				unset( $this->session[ $key ] );
173
+			if (isset($this->session[$key])) {
174
+				unset($this->session[$key]);
175 175
 			}
176 176
 		}
177 177
 
178
-		if ( $this->use_php_sessions ) {
179
-			$_SESSION['gd' . $this->prefix ] = $this->session;
178
+		if ($this->use_php_sessions) {
179
+			$_SESSION['gd'.$this->prefix] = $this->session;
180 180
 		}
181 181
 
182 182
 		return true;
@@ -191,14 +191,14 @@  discard block
 block discarded – undo
191 191
 	 * @param integer $value Session variable.
192 192
 	 * @return string Session variable.
193 193
 	 */
194
-	public function is_set( $key ) {
195
-		$key = sanitize_key( $key );
194
+	public function is_set($key) {
195
+		$key = sanitize_key($key);
196 196
 		
197
-		if ( empty( $key ) ) {
197
+		if (empty($key)) {
198 198
 			return false;
199 199
 		}
200 200
 
201
-		if ( isset( $this->session[ $key ] ) ) {
201
+		if (isset($this->session[$key])) {
202 202
 			return true;
203 203
 		}
204 204
 
@@ -213,8 +213,8 @@  discard block
 block discarded – undo
213 213
 	 * @param int $exp Default expiration (1 hour)
214 214
 	 * @return int
215 215
 	 */
216
-	public function set_expiration_variant_time( $exp ) {
217
-		return ( 30 * 60 * 23 );
216
+	public function set_expiration_variant_time($exp) {
217
+		return (30 * 60 * 23);
218 218
 	}
219 219
 
220 220
 	/**
@@ -225,8 +225,8 @@  discard block
 block discarded – undo
225 225
 	 * @param int $exp Default expiration (1 hour)
226 226
 	 * @return int
227 227
 	 */
228
-	public function set_expiration_time( $exp ) {
229
-		return ( 30 * 60 * 24 );
228
+	public function set_expiration_time($exp) {
229
+		return (30 * 60 * 24);
230 230
 	}
231 231
 
232 232
 	/**
@@ -244,18 +244,18 @@  discard block
 block discarded – undo
244 244
 		$ret = false;
245 245
 
246 246
 		// If the database variable is already set, no need to run autodetection
247
-		$geodir_use_php_sessions = (bool)get_option( 'geodir_use_php_sessions' );
247
+		$geodir_use_php_sessions = (bool) get_option('geodir_use_php_sessions');
248 248
 
249
-		if (!$geodir_use_php_sessions ) {
249
+		if (!$geodir_use_php_sessions) {
250 250
 			// Attempt to detect if the server supports PHP sessions
251
-			if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) {
252
-				$this->set( 'geodir_use_php_sessions', 1 );
251
+			if (function_exists('session_start') && !ini_get('safe_mode')) {
252
+				$this->set('geodir_use_php_sessions', 1);
253 253
 				
254
-				if ( $this->get( 'geodir_use_php_sessions' ) ) {
254
+				if ($this->get('geodir_use_php_sessions')) {
255 255
 					$ret = true;
256 256
 
257 257
 					// Set the database option
258
-					update_option( 'geodir_use_php_sessions', true );
258
+					update_option('geodir_use_php_sessions', true);
259 259
 				}
260 260
 			}
261 261
 		} else {
@@ -263,20 +263,20 @@  discard block
 block discarded – undo
263 263
 		}
264 264
 
265 265
 		// Enable or disable PHP Sessions based on the GEODIR_USE_PHP_SESSIONS constant
266
-		if ( defined( 'GEODIR_USE_PHP_SESSIONS' ) && GEODIR_USE_PHP_SESSIONS ) {
266
+		if (defined('GEODIR_USE_PHP_SESSIONS') && GEODIR_USE_PHP_SESSIONS) {
267 267
 			$ret = true;
268
-		} else if ( defined( 'GEODIR_USE_PHP_SESSIONS' ) && ! GEODIR_USE_PHP_SESSIONS ) {
268
+		} else if (defined('GEODIR_USE_PHP_SESSIONS') && !GEODIR_USE_PHP_SESSIONS) {
269 269
 			$ret = false;
270 270
 		}
271 271
 
272
-		return (bool) apply_filters( 'geodir_use_php_sessions', $ret );
272
+		return (bool) apply_filters('geodir_use_php_sessions', $ret);
273 273
 	}
274 274
 
275 275
 	/**
276 276
 	 * Starts a new session if one hasn't started yet.
277 277
 	 */
278 278
 	public function maybe_start_session() {
279
-		if ( !session_id() && !headers_sent() ) {
279
+		if (!session_id() && !headers_sent()) {
280 280
 			session_start();
281 281
 		}
282 282
 	}
@@ -290,11 +290,11 @@  discard block
 block discarded – undo
290 290
 	public function use_cart_cookie() {
291 291
 		$ret = true;
292 292
 
293
-		if ( defined( 'GEODIR_USE_CART_COOKIE' ) && ! GEODIR_USE_CART_COOKIE ) {
293
+		if (defined('GEODIR_USE_CART_COOKIE') && !GEODIR_USE_CART_COOKIE) {
294 294
 			$ret = false;
295 295
 		}
296 296
 
297
-		return (bool) apply_filters( 'geodir_use_cart_cookie', $ret );
297
+		return (bool) apply_filters('geodir_use_cart_cookie', $ret);
298 298
 	}
299 299
 }
300 300
 
Please login to merge, or discard this patch.
geodirectory-functions/location_functions.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
  *
37 37
  * @since 1.0.0
38 38
  * @package GeoDirectory
39
- * @return object
39
+ * @return string
40 40
  */
41 41
 function geodir_get_default_location()
42 42
 {
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
  * @package GeoDirectory
324 324
  * @param int $min The minimum number. Default: 0.
325 325
  * @param int $max The maximum number. Default: 1.
326
- * @return float
326
+ * @return integer
327 327
  */
328 328
 function geodir_random_float($min = 0, $max = 1)
329 329
 {
Please login to merge, or discard this patch.
Braces   +31 added lines, -22 removed lines patch added patch discarded remove patch
@@ -61,11 +61,12 @@  discard block
 block discarded – undo
61 61
 function geodir_is_default_location_set()
62 62
 {
63 63
     $default_location = geodir_get_default_location();
64
-    if (!empty($default_location))
65
-        return true;
66
-    else
67
-        return false;
68
-}
64
+    if (!empty($default_location)) {
65
+            return true;
66
+    } else {
67
+            return false;
68
+    }
69
+    }
69 70
 
70 71
 /**
71 72
  * Returns location slug using location string.
@@ -258,8 +259,9 @@  discard block
 block discarded – undo
258 259
 
259 260
         }
260 261
 
261
-        if ($geodir_location->is_default)
262
-            update_option('geodir_default_location', $geodir_location);
262
+        if ($geodir_location->is_default) {
263
+                    update_option('geodir_default_location', $geodir_location);
264
+        }
263 265
 
264 266
         return $geodir_location->location_id;
265 267
 
@@ -307,9 +309,10 @@  discard block
 block discarded – undo
307 309
     $status = $data->status;
308 310
     if ($status == "OK") {
309 311
         return $data->results[0]->address_components;
310
-    } else
311
-        return false;
312
-}
312
+    } else {
313
+            return false;
314
+    }
315
+    }
313 316
 
314 317
 /**
315 318
  * Returns current location terms.
@@ -333,16 +336,19 @@  discard block
 block discarded – undo
333 336
         }
334 337
 
335 338
         $country = $gd_session->get('gd_country');
336
-        if ($country != '' && $country)
337
-            $location_array['gd_country'] = urldecode($country);
339
+        if ($country != '' && $country) {
340
+                    $location_array['gd_country'] = urldecode($country);
341
+        }
338 342
 
339 343
         $region = $gd_session->get('gd_region');
340
-        if ($region != '' && $region)
341
-            $location_array['gd_region'] = urldecode($region);
344
+        if ($region != '' && $region) {
345
+                    $location_array['gd_region'] = urldecode($region);
346
+        }
342 347
 
343 348
         $city = $gd_session->get('gd_city');
344
-        if ($city != '' && $city)
345
-            $location_array['gd_city'] = urldecode($city);
349
+        if ($city != '' && $city) {
350
+                    $location_array['gd_city'] = urldecode($city);
351
+        }
346 352
     } else {
347 353
         if ((isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] == 'me') || (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] == 'me') || (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] == 'me')) {
348 354
             return $location_array;
@@ -354,14 +360,17 @@  discard block
 block discarded – undo
354 360
 
355 361
         $city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : '';
356 362
 
357
-        if ($country != '')
358
-            $location_array['gd_country'] = urldecode($country);
363
+        if ($country != '') {
364
+                    $location_array['gd_country'] = urldecode($country);
365
+        }
359 366
 
360
-        if ($region != '')
361
-            $location_array['gd_region'] = urldecode($region);
367
+        if ($region != '') {
368
+                    $location_array['gd_region'] = urldecode($region);
369
+        }
362 370
 
363
-        if ($city != '')
364
-            $location_array['gd_city'] = urldecode($city);
371
+        if ($city != '') {
372
+                    $location_array['gd_city'] = urldecode($city);
373
+        }
365 374
 			
366 375
 		// Fix category link in ajax popular category widget on change post type
367 376
 		if (empty($location_array) && defined('DOING_AJAX') && DOING_AJAX) {
Please login to merge, or discard this patch.
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.