Test Failed
Pull Request — master (#341)
by Kiran
32:58
created
geodirectory-functions/post_functions.php 4 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
      * @param int $post_id The post ID.
722 722
      * @param string $postmeta Detail table column name.
723 723
      * @param string $meta_value Detail table column value.
724
-     * @return void|bool
724
+     * @return null|false
725 725
      */
726 726
     function geodir_save_post_meta($post_id, $postmeta = '', $meta_value = '')
727 727
     {
@@ -775,7 +775,7 @@  discard block
 block discarded – undo
775 775
      * @param string $postmeta Detail table column name.
776 776
      * @todo check if this is depreciated
777 777
      * @todo Fix unknown variable mval
778
-     * @return bool
778
+     * @return boolean|null
779 779
      */
780 780
     function geodir_delete_post_meta($post_id, $postmeta)
781 781
     {
@@ -2124,7 +2124,7 @@  discard block
 block discarded – undo
2124 2124
      * @global string $plugin_prefix Geodirectory plugin table prefix.
2125 2125
      * @param int $deleted_postid The post ID.
2126 2126
      * @param bool $force Optional. Do you want to force delete it? Default: false.
2127
-     * @return bool|void
2127
+     * @return null|false
2128 2128
      */
2129 2129
     function geodir_delete_listing_info($deleted_postid, $force = false)
2130 2130
     {
@@ -2693,7 +2693,7 @@  discard block
 block discarded – undo
2693 2693
  * @since 1.0.0
2694 2694
  * @package GeoDirectory
2695 2695
  * @global object $current_user Current user object.
2696
- * @param int|string $listing_id The post ID.
2696
+ * @param integer $listing_id The post ID.
2697 2697
  * @param bool $exclude_admin Optional. Do you want to exclude admin from the check?. Default true.
2698 2698
  * @return bool
2699 2699
  */
Please login to merge, or discard this patch.
Braces   +174 added lines, -123 removed lines patch added patch discarded remove patch
@@ -21,12 +21,13 @@  discard block
 block discarded – undo
21 21
 {
22 22
 
23 23
     $post_cat_ids = geodir_get_post_meta($post_id, $taxonomy);
24
-    if (!empty($post_cat_ids))
25
-        $post_cat_array = explode(",", trim($post_cat_ids, ","));
24
+    if (!empty($post_cat_ids)) {
25
+            $post_cat_array = explode(",", trim($post_cat_ids, ","));
26
+    }
26 27
 
27 28
     if (!isset($default_cat) || empty($default_cat)) {
28 29
         $default_cat = isset($post_cat_array[0]) ? $post_cat_array[0] : '';
29
-    }else{
30
+    } else{
30 31
         if(!is_int($default_cat)){
31 32
             $category = get_term_by('name', $default_cat, $taxonomy);
32 33
             if(isset($category->term_id)){
@@ -383,8 +384,9 @@  discard block
 block discarded – undo
383 384
             } elseif (trim($type) == 'file') {
384 385
                 if (isset($request_info[$name])) {
385 386
                     $request_files = array();
386
-                    if ($request_info[$name] != '')
387
-                        $request_files = explode(",", $request_info[$name]);
387
+                    if ($request_info[$name] != '') {
388
+                                            $request_files = explode(",", $request_info[$name]);
389
+                    }
388 390
 
389 391
                     $extrafields = $extrafields != '' ? maybe_unserialize($extrafields) : NULL;
390 392
                     geodir_save_post_file_fields($last_post_id, $name, $request_files, $extrafields);
@@ -410,7 +412,7 @@  discard block
 block discarded – undo
410 412
 
411 413
                         $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $request_info[$name]) : $request_info[$name];
412 414
 
413
-                    }else{
415
+                    } else{
414 416
                         $post_htmlvar_value = $request_info[$name];
415 417
                     }
416 418
 
@@ -451,15 +453,17 @@  discard block
 block discarded – undo
451 453
 
452 454
             foreach ($request_info['post_category'] as $taxonomy => $cat) {
453 455
 
454
-                if ($dummy)
455
-                    $post_category = $cat;
456
-                else {
456
+                if ($dummy) {
457
+                                    $post_category = $cat;
458
+                } else {
457 459
 
458
-                    if (!is_array($cat) && strstr($cat, ','))
459
-                        $cat = explode(',', $cat);
460
+                    if (!is_array($cat) && strstr($cat, ',')) {
461
+                                            $cat = explode(',', $cat);
462
+                    }
460 463
 
461
-                    if (!empty($cat) && is_array($cat))
462
-                        $post_category = array_map('intval', $cat);
464
+                    if (!empty($cat) && is_array($cat)) {
465
+                                            $post_category = array_map('intval', $cat);
466
+                    }
463 467
                 }
464 468
 
465 469
                 wp_set_object_terms($last_post_id, $post_category, $taxonomy);
@@ -477,11 +481,13 @@  discard block
 block discarded – undo
477 481
         if (isset($request_info['post_tags']) && !is_array($request_info['post_tags']) && !empty($request_info['post_tags'])) {
478 482
             $post_tags = explode(",", $request_info['post_tags']);
479 483
         } elseif (isset($request_info['post_tags']) && is_array($request_info['post_tags'])) {
480
-            if ($dummy)
481
-                $post_tags = $request_info['post_tags'];
484
+            if ($dummy) {
485
+                            $post_tags = $request_info['post_tags'];
486
+            }
482 487
         } else {
483
-            if ($dummy)
484
-                $post_tags = array($request_info['post_title']);
488
+            if ($dummy) {
489
+                            $post_tags = array($request_info['post_title']);
490
+            }
485 491
         }
486 492
 
487 493
         if (is_array($post_tags)) {
@@ -568,15 +574,17 @@  discard block
 block discarded – undo
568 574
 
569 575
     global $wpdb, $plugin_prefix, $post, $post_info;
570 576
 
571
-    if ($post_id == '' && !empty($post))
572
-        $post_id = $post->ID;
577
+    if ($post_id == '' && !empty($post)) {
578
+            $post_id = $post->ID;
579
+    }
573 580
 
574 581
     $post_type = get_post_type($post_id);
575 582
 
576 583
     $all_postypes = geodir_get_posttypes();
577 584
 
578
-    if (!in_array($post_type, $all_postypes))
579
-        return false;
585
+    if (!in_array($post_type, $all_postypes)) {
586
+            return false;
587
+    }
580 588
 
581 589
     $table = $plugin_prefix . $post_type . '_detail';
582 590
 
@@ -736,8 +744,9 @@  discard block
 block discarded – undo
736 744
             do_action('geodir_after_save_listinginfo', $postinfo_array, $post_id);
737 745
 
738 746
             return true;
739
-        } else
740
-            return false;
747
+        } else {
748
+                    return false;
749
+        }
741 750
 
742 751
     }
743 752
 }
@@ -791,8 +800,9 @@  discard block
 block discarded – undo
791 800
             }
792 801
 
793 802
 
794
-        } else
795
-            return false;
803
+        } else {
804
+                    return false;
805
+        }
796 806
     }
797 807
 }
798 808
 
@@ -823,8 +833,9 @@  discard block
 block discarded – undo
823 833
             $post_meta_set_query = '';
824 834
 
825 835
             foreach ($postmeta as $mkey) {
826
-                if ($mval != '')
827
-                    $post_meta_set_query .= $mkey . " = '', ";
836
+                if ($mval != '') {
837
+                                    $post_meta_set_query .= $mkey . " = '', ";
838
+                }
828 839
             }
829 840
 
830 841
             $post_meta_set_query = trim($post_meta_set_query, ", ");
@@ -858,8 +869,9 @@  discard block
 block discarded – undo
858 869
                 return true;
859 870
             }
860 871
 
861
-        } else
862
-            return false;
872
+        } else {
873
+                    return false;
874
+        }
863 875
     }
864 876
 }
865 877
 
@@ -889,8 +901,9 @@  discard block
 block discarded – undo
889 901
 
890 902
         $post_type = get_post_type($post_id);
891 903
 
892
-        if (!in_array($post_type, $all_postypes))
893
-            return false;
904
+        if (!in_array($post_type, $all_postypes)) {
905
+                    return false;
906
+        }
894 907
 
895 908
         $table = $plugin_prefix . $post_type . '_detail';
896 909
 
@@ -898,8 +911,9 @@  discard block
 block discarded – undo
898 911
             $meta_value = $wpdb->get_var($wpdb->prepare("SELECT " . $meta_key . " from " . $table . " where post_id = %d", array($post_id)));
899 912
             if ($meta_value && $meta_value !== '') {
900 913
                 return maybe_serialize($meta_value);
901
-            } else
902
-                return $meta_value;
914
+            } else {
915
+                            return $meta_value;
916
+            }
903 917
         } else {
904 918
             return false;
905 919
         }
@@ -1033,7 +1047,7 @@  discard block
 block discarded – undo
1033 1047
                             if (isset($uploaded['error']) && empty($uploaded['error'])) {
1034 1048
                                 $new_name = basename($uploaded['file']);
1035 1049
                                 $uploaded_file = $uploaded;
1036
-                            }else{
1050
+                            } else{
1037 1051
                                 print_r($uploaded);exit;
1038 1052
                             }
1039 1053
                             $external_img = false;
@@ -1058,8 +1072,9 @@  discard block
 block discarded – undo
1058 1072
                                 $file_path = $curr_img_dir . '/' . $filename;
1059 1073
                             }
1060 1074
 
1061
-                            if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path))
1062
-                                unlink($img_path);
1075
+                            if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path)) {
1076
+                                                            unlink($img_path);
1077
+                            }
1063 1078
                         }
1064 1079
 
1065 1080
                         if (!empty($uploaded_file)) {
@@ -1088,8 +1103,9 @@  discard block
 block discarded – undo
1088 1103
                             $attachment_set = '';
1089 1104
 
1090 1105
                             foreach ($attachment as $key => $val) {
1091
-                                if ($val != '')
1092
-                                    $attachment_set .= $key . " = '" . $val . "', ";
1106
+                                if ($val != '') {
1107
+                                                                    $attachment_set .= $key . " = '" . $val . "', ";
1108
+                                }
1093 1109
                             }
1094 1110
 
1095 1111
                             $attachment_set = trim($attachment_set, ", ");
@@ -1114,8 +1130,9 @@  discard block
 block discarded – undo
1114 1130
                         )
1115 1131
                     );
1116 1132
 
1117
-                    if ($menu_order == 1)
1118
-                        $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
1133
+                    if ($menu_order == 1) {
1134
+                                            $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
1135
+                    }
1119 1136
 
1120 1137
                 }
1121 1138
 
@@ -1156,8 +1173,9 @@  discard block
 block discarded – undo
1156 1173
 
1157 1174
         $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE " . $valid_files_condition . " post_id = %d", $remove_files));
1158 1175
 
1159
-        if (!empty($invalid_files))
1160
-            geodir_remove_attachments($invalid_files);
1176
+        if (!empty($invalid_files)) {
1177
+                    geodir_remove_attachments($invalid_files);
1178
+        }
1161 1179
     }
1162 1180
 
1163 1181
 }
@@ -1210,16 +1228,19 @@  discard block
 block discarded – undo
1210 1228
 function geodir_delete_directory($dirname)
1211 1229
 {
1212 1230
     $dir_handle = '';
1213
-    if (is_dir($dirname))
1214
-        $dir_handle = opendir($dirname);
1215
-    if (!$dir_handle)
1216
-        return false;
1231
+    if (is_dir($dirname)) {
1232
+            $dir_handle = opendir($dirname);
1233
+    }
1234
+    if (!$dir_handle) {
1235
+            return false;
1236
+    }
1217 1237
     while ($file = readdir($dir_handle)) {
1218 1238
         if ($file != "." && $file != "..") {
1219
-            if (!is_dir($dirname . "/" . $file))
1220
-                unlink($dirname . "/" . $file);
1221
-            else
1222
-                geodir_delete_directory($dirname . '/' . $file);
1239
+            if (!is_dir($dirname . "/" . $file)) {
1240
+                            unlink($dirname . "/" . $file);
1241
+            } else {
1242
+                            geodir_delete_directory($dirname . '/' . $file);
1243
+            }
1223 1244
         }
1224 1245
     }
1225 1246
     closedir($dir_handle);
@@ -1248,8 +1269,9 @@  discard block
 block discarded – undo
1248 1269
             foreach ($postcurr_images as $postimg) {
1249 1270
                 $image_name_arr = explode('/', $postimg->src);
1250 1271
                 $filename = end($image_name_arr);
1251
-                if (file_exists($uploads_dir . '/' . $filename))
1252
-                    unlink($uploads_dir . '/' . $filename);
1272
+                if (file_exists($uploads_dir . '/' . $filename)) {
1273
+                                    unlink($uploads_dir . '/' . $filename);
1274
+                }
1253 1275
             }
1254 1276
 
1255 1277
         } // endif
@@ -1308,8 +1330,9 @@  discard block
 block discarded – undo
1308 1330
 
1309 1331
             $file_info = pathinfo($file);
1310 1332
             $sub_dir = '';
1311
-            if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
1312
-                $sub_dir = stripslashes_deep($file_info['dirname']);
1333
+            if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') {
1334
+                            $sub_dir = stripslashes_deep($file_info['dirname']);
1335
+            }
1313 1336
 
1314 1337
             $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1315 1338
             $uploads_baseurl = $uploads['baseurl'];
@@ -1353,9 +1376,9 @@  discard block
 block discarded – undo
1353 1376
                 $default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1354 1377
             }
1355 1378
 
1356
-            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1357
-                $default_img = $default_catimg['src'];
1358
-            elseif ($no_image) {
1379
+            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) {
1380
+                            $default_img = $default_catimg['src'];
1381
+            } elseif ($no_image) {
1359 1382
                 $default_img = get_option('geodir_listing_no_img');
1360 1383
             }
1361 1384
 
@@ -1387,10 +1410,13 @@  discard block
 block discarded – undo
1387 1410
             }
1388 1411
         }
1389 1412
 
1390
-        if (!empty($img_arr))
1391
-            return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path );
1392
-        else
1393
-            return false;
1413
+        if (!empty($img_arr)) {
1414
+                    return (object)$img_arr;
1415
+        }
1416
+        //return (object)array( 'src' => $file_url, 'path' => $file_path );
1417
+        else {
1418
+                    return false;
1419
+        }
1394 1420
     }
1395 1421
 }
1396 1422
 
@@ -1417,8 +1443,9 @@  discard block
 block discarded – undo
1417 1443
             echo $html;
1418 1444
         } elseif (!empty($html)) {
1419 1445
             return $html;
1420
-        } else
1421
-            return false;
1446
+        } else {
1447
+                    return false;
1448
+        }
1422 1449
     }
1423 1450
 }
1424 1451
 
@@ -1446,8 +1473,9 @@  discard block
 block discarded – undo
1446 1473
         }
1447 1474
         $not_featured = '';
1448 1475
         $sub_dir = '';
1449
-        if (!$add_featured)
1450
-            $not_featured = " AND is_featured = 0 ";
1476
+        if (!$add_featured) {
1477
+                    $not_featured = " AND is_featured = 0 ";
1478
+        }
1451 1479
 
1452 1480
         $arrImages = $wpdb->get_results(
1453 1481
             $wpdb->prepare(
@@ -1468,8 +1496,9 @@  discard block
 block discarded – undo
1468 1496
 
1469 1497
                 $file_info = pathinfo($attechment->file);
1470 1498
 
1471
-                if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
1472
-                    $sub_dir = stripslashes_deep($file_info['dirname']);
1499
+                if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') {
1500
+                                    $sub_dir = stripslashes_deep($file_info['dirname']);
1501
+                }
1473 1502
 
1474 1503
                 $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1475 1504
                 $uploads_baseurl = $uploads['baseurl'];
@@ -1514,9 +1543,9 @@  discard block
 block discarded – undo
1514 1543
             $default_img = '';
1515 1544
             $default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1516 1545
             $post_type = get_post_type($post_id);
1517
-            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1518
-                $default_img = $default_catimg['src'];
1519
-            elseif ($no_images) {
1546
+            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) {
1547
+                            $default_img = $default_catimg['src'];
1548
+            } elseif ($no_images) {
1520 1549
                 $default_img = get_option('geodir_listing_no_img');
1521 1550
             }
1522 1551
 
@@ -1551,8 +1580,9 @@  discard block
 block discarded – undo
1551 1580
                 $return_arr[] = (object)$img_arr;
1552 1581
 
1553 1582
                 return $return_arr;
1554
-            } else
1555
-                return false;
1583
+            } else {
1584
+                            return false;
1585
+            }
1556 1586
         }
1557 1587
     }
1558 1588
 }
@@ -1613,8 +1643,9 @@  discard block
 block discarded – undo
1613 1643
                         $width_per = round(((($image->width * ($max_size->h / $image->height)) / $max_size->w) * 100), 2);
1614 1644
                     } else if ($image->width < ($max_size->h)) {
1615 1645
                         $width_per = round((($image->width / $max_size->w) * 100), 2);
1616
-                    } else
1617
-                        $width_per = 100;
1646
+                    } else {
1647
+                                            $width_per = 100;
1648
+                    }
1618 1649
                 }
1619 1650
 
1620 1651
                 if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
@@ -1622,7 +1653,7 @@  discard block
 block discarded – undo
1622 1653
                 } else {
1623 1654
                     if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){
1624 1655
                         $html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1625
-                    }else{
1656
+                    } else{
1626 1657
                         //$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1627 1658
                         //$html = '<div data-src="'.$image->src.'" class="geodir_thumbnail" ></div>';
1628 1659
                         $html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>';
@@ -1637,8 +1668,9 @@  discard block
 block discarded – undo
1637 1668
             echo $html;
1638 1669
         } elseif (!empty($html)) {
1639 1670
             return $html;
1640
-        } else
1641
-            return false;
1671
+        } else {
1672
+                    return false;
1673
+        }
1642 1674
     }
1643 1675
 }
1644 1676
 
@@ -1676,8 +1708,9 @@  discard block
 block discarded – undo
1676 1708
                 $post_obj = get_post($post_id);
1677 1709
 
1678 1710
                 $cat_ids = array('0');
1679
-                if (is_array($tt_ids))
1680
-                    $cat_ids = $tt_ids;
1711
+                if (is_array($tt_ids)) {
1712
+                                    $cat_ids = $tt_ids;
1713
+                }
1681 1714
 
1682 1715
 
1683 1716
                 if (!empty($cat_ids)) {
@@ -1734,8 +1767,9 @@  discard block
 block discarded – undo
1734 1767
                         $json .= '}';
1735 1768
 
1736 1769
 
1737
-                        if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true))
1738
-                            $post_marker_json = $json;
1770
+                        if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true)) {
1771
+                                                    $post_marker_json = $json;
1772
+                        }
1739 1773
 
1740 1774
 
1741 1775
                         if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . GEODIR_ICON_TABLE . " WHERE post_id = %d AND cat_id = %d", array($post_id, $cat_id)))) {
@@ -1766,10 +1800,13 @@  discard block
 block discarded – undo
1766 1800
                 if (!empty($post_term) && is_array($post_term)) {
1767 1801
                     $categories = implode(',', $post_term);
1768 1802
 
1769
-                    if ($categories != '' && $categories != 0) $categories = ',' . $categories . ',';
1803
+                    if ($categories != '' && $categories != 0) {
1804
+                    	$categories = ',' . $categories . ',';
1805
+                    }
1770 1806
 
1771
-                    if (empty($post_marker_json))
1772
-                        $post_marker_json = isset($json) ? $json : '';
1807
+                    if (empty($post_marker_json)) {
1808
+                                            $post_marker_json = isset($json) ? $json : '';
1809
+                    }
1773 1810
 
1774 1811
                     if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
1775 1812
 
@@ -1808,8 +1845,9 @@  discard block
 block discarded – undo
1808 1845
 
1809 1846
                                 }
1810 1847
 
1811
-                                if ($default_category == '')
1812
-                                    $default_category = $categories[0];
1848
+                                if ($default_category == '') {
1849
+                                                                    $default_category = $categories[0];
1850
+                                }
1813 1851
 
1814 1852
                                 geodir_set_postcat_structure($post_id, $taxonomy, $default_category, '');
1815 1853
 
@@ -1948,7 +1986,7 @@  discard block
 block discarded – undo
1948 1986
                                     } ?>"><img alt="bubble image" style="max-height:50px;"
1949 1987
                                                src="<?php echo $post_images[0]; ?>"/></a></div>
1950 1988
                             <?php
1951
-                            }else{
1989
+                            } else{
1952 1990
                                 echo '<div class="geodir-bubble_image"></div>';
1953 1991
                             }
1954 1992
                         } else {
@@ -1956,7 +1994,7 @@  discard block
 block discarded – undo
1956 1994
                                 ?>
1957 1995
                                 <div class="geodir-bubble_image"><a href="<?php echo $plink; ?>"><?php echo $image; ?></a></div>
1958 1996
                             <?php
1959
-                            }else{
1997
+                            } else{
1960 1998
                                 echo '<div class="geodir-bubble_image"></div>';
1961 1999
                             }
1962 2000
                         }
@@ -2046,10 +2084,11 @@  discard block
 block discarded – undo
2046 2084
      */
2047 2085
     function geodir_new_post_default_status()
2048 2086
     {
2049
-        if (get_option('geodir_new_post_default_status'))
2050
-            return get_option('geodir_new_post_default_status');
2051
-        else
2052
-            return 'publish';
2087
+        if (get_option('geodir_new_post_default_status')) {
2088
+                    return get_option('geodir_new_post_default_status');
2089
+        } else {
2090
+                    return 'publish';
2091
+        }
2053 2092
 
2054 2093
     }
2055 2094
 }
@@ -2200,8 +2239,9 @@  discard block
 block discarded – undo
2200 2239
 
2201 2240
         $all_postypes = geodir_get_posttypes();
2202 2241
 
2203
-        if (!in_array($post_type, $all_postypes))
2204
-            return false;
2242
+        if (!in_array($post_type, $all_postypes)) {
2243
+                    return false;
2244
+        }
2205 2245
 
2206 2246
         $table = $plugin_prefix . $post_type . '_detail';
2207 2247
 
@@ -2469,8 +2509,9 @@  discard block
 block discarded – undo
2469 2509
         $unfavourite_icon = apply_filters('geodir_unfavourite_icon', 'fa fa-heart');
2470 2510
 
2471 2511
         $user_meta_data = '';
2472
-        if (isset($current_user->data->ID))
2473
-            $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2512
+        if (isset($current_user->data->ID)) {
2513
+                    $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2514
+        }
2474 2515
 
2475 2516
         if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
2476 2517
             ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"  ><a
@@ -2483,8 +2524,9 @@  discard block
 block discarded – undo
2483 2524
 
2484 2525
             if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
2485 2526
                 $script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\'';
2486
-            } else
2487
-                $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
2527
+            } else {
2528
+                            $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
2529
+            }
2488 2530
 
2489 2531
             ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon"
2490 2532
                                                                                         href="javascript:void(0);"
@@ -2547,14 +2589,16 @@  discard block
 block discarded – undo
2547 2589
 							WHERE pd.post_status='publish' AND FIND_IN_SET('" . $term->term_id . "'," . $term->taxonomy . ") " . $where;
2548 2590
 
2549 2591
             $cat_post_count = $wpdb->get_var($count_query);
2550
-            if (empty($cat_post_count) || is_wp_error($cat_post_count))
2551
-                $cat_post_count = 0;
2592
+            if (empty($cat_post_count) || is_wp_error($cat_post_count)) {
2593
+                            $cat_post_count = 0;
2594
+            }
2552 2595
 
2553 2596
             return $cat_post_count;
2554 2597
 
2555
-        } else
2556
-
2557
-            return $term->count;
2598
+        } else {
2599
+        
2600
+            return $term->count;
2601
+        }
2558 2602
     }
2559 2603
     return false;
2560 2604
 
@@ -2601,13 +2645,15 @@  discard block
 block discarded – undo
2601 2645
 		return $length;
2602 2646
 	}
2603 2647
 	
2604
-    if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit'))
2605
-        $length = get_option('geodir_desc_word_limit');
2606
-    elseif (get_query_var('excerpt_length'))
2607
-        $length = get_query_var('excerpt_length');
2648
+    if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit')) {
2649
+            $length = get_option('geodir_desc_word_limit');
2650
+    } elseif (get_query_var('excerpt_length')) {
2651
+            $length = get_query_var('excerpt_length');
2652
+    }
2608 2653
 
2609
-    if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit'))
2610
-        $length = get_option('geodir_author_desc_word_limit');
2654
+    if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit')) {
2655
+            $length = get_option('geodir_author_desc_word_limit');
2656
+    }
2611 2657
 
2612 2658
     return $length;
2613 2659
 }
@@ -2740,10 +2786,11 @@  discard block
 block discarded – undo
2740 2786
 function geodir_lisiting_belong_to_user($listing_id, $user_id)
2741 2787
 {
2742 2788
     $listing_author_id = geodir_get_listing_author($listing_id);
2743
-    if ($listing_author_id == $user_id)
2744
-        return true;
2745
-    else
2746
-        return false;
2789
+    if ($listing_author_id == $user_id) {
2790
+            return true;
2791
+    } else {
2792
+            return false;
2793
+    }
2747 2794
 
2748 2795
 }
2749 2796
 
@@ -2792,10 +2839,11 @@  discard block
 block discarded – undo
2792 2839
     $pattern = '/-\d+x\d+\./';
2793 2840
     preg_match($pattern, $file, $matches, PREG_OFFSET_CAPTURE);
2794 2841
 
2795
-    if (empty($matches))
2796
-        return '';
2797
-    else
2798
-        return $file;
2842
+    if (empty($matches)) {
2843
+            return '';
2844
+    } else {
2845
+            return $file;
2846
+    }
2799 2847
 
2800 2848
 }
2801 2849
 
@@ -2880,8 +2928,9 @@  discard block
 block discarded – undo
2880 2928
     } else {
2881 2929
         //set_post_thumbnail($post_id,-1);
2882 2930
 
2883
-        if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete'))
2884
-            wp_delete_attachment($post_thumbnail_id);
2931
+        if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) {
2932
+                    wp_delete_attachment($post_thumbnail_id);
2933
+        }
2885 2934
 
2886 2935
     }
2887 2936
 }
@@ -2966,8 +3015,9 @@  discard block
 block discarded – undo
2966 3015
 
2967 3016
     global $wpdb;
2968 3017
 
2969
-    if ($listing_type == '')
2970
-        $listing_type = 'gd_place';
3018
+    if ($listing_type == '') {
3019
+            $listing_type = 'gd_place';
3020
+    }
2971 3021
 
2972 3022
     $fields_info = array();
2973 3023
 
@@ -2990,8 +3040,9 @@  discard block
 block discarded – undo
2990 3040
 
2991 3041
                 $fields_info[$prefix . 'address'] = $data->field_type;
2992 3042
 
2993
-                if (isset($extra_fields['show_zip']) && $extra_fields['show_zip'])
2994
-                    $fields_info[$prefix . 'zip'] = $data->field_type;
3043
+                if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
3044
+                                    $fields_info[$prefix . 'zip'] = $data->field_type;
3045
+                }
2995 3046
 
2996 3047
             } else {
2997 3048
 
Please login to merge, or discard this patch.
Indentation   +2235 added lines, -2235 removed lines patch added patch discarded remove patch
@@ -20,491 +20,491 @@  discard block
 block discarded – undo
20 20
 function geodir_set_postcat_structure($post_id, $taxonomy, $default_cat = '', $category_str = '')
21 21
 {
22 22
 
23
-    $post_cat_ids = geodir_get_post_meta($post_id, $taxonomy);
24
-    if (!empty($post_cat_ids))
25
-        $post_cat_array = explode(",", trim($post_cat_ids, ","));
26
-
27
-    if (!isset($default_cat) || empty($default_cat)) {
28
-        $default_cat = isset($post_cat_array[0]) ? $post_cat_array[0] : '';
29
-    }else{
30
-        if(!is_int($default_cat)){
31
-            $category = get_term_by('name', $default_cat, $taxonomy);
32
-            if(isset($category->term_id)){
33
-                $default_cat =  $category->term_id;
34
-            }
35
-        }
23
+	$post_cat_ids = geodir_get_post_meta($post_id, $taxonomy);
24
+	if (!empty($post_cat_ids))
25
+		$post_cat_array = explode(",", trim($post_cat_ids, ","));
26
+
27
+	if (!isset($default_cat) || empty($default_cat)) {
28
+		$default_cat = isset($post_cat_array[0]) ? $post_cat_array[0] : '';
29
+	}else{
30
+		if(!is_int($default_cat)){
31
+			$category = get_term_by('name', $default_cat, $taxonomy);
32
+			if(isset($category->term_id)){
33
+				$default_cat =  $category->term_id;
34
+			}
35
+		}
36 36
 
37
-    }
37
+	}
38 38
 
39 39
 
40
-    geodir_save_post_meta($post_id, 'default_category', $default_cat);
40
+	geodir_save_post_meta($post_id, 'default_category', $default_cat);
41 41
 
42
-    if (isset($category_str) && empty($category_str)) {
42
+	if (isset($category_str) && empty($category_str)) {
43 43
 
44
-        $post_cat_str = '';
45
-        $post_categories = array();
46
-        if (isset($post_cat_array) && is_array($post_cat_array) && !empty($post_cat_array)) {
47
-            $post_cat_str = implode(",y:#", $post_cat_array);
48
-            $post_cat_str .= ",y:";
49
-            $post_cat_str = substr_replace($post_cat_str, ',y,d:', strpos($post_cat_str, ',y:'), strlen(',y:'));
50
-        }
51
-        $post_categories[$taxonomy] = $post_cat_str;
52
-        $category_str = $post_categories;
53
-    }
44
+		$post_cat_str = '';
45
+		$post_categories = array();
46
+		if (isset($post_cat_array) && is_array($post_cat_array) && !empty($post_cat_array)) {
47
+			$post_cat_str = implode(",y:#", $post_cat_array);
48
+			$post_cat_str .= ",y:";
49
+			$post_cat_str = substr_replace($post_cat_str, ',y,d:', strpos($post_cat_str, ',y:'), strlen(',y:'));
50
+		}
51
+		$post_categories[$taxonomy] = $post_cat_str;
52
+		$category_str = $post_categories;
53
+	}
54 54
 
55
-    $change_cat_str = $category_str[$taxonomy];
55
+	$change_cat_str = $category_str[$taxonomy];
56 56
 
57
-    $default_pos = strpos($change_cat_str, 'd:');
57
+	$default_pos = strpos($change_cat_str, 'd:');
58 58
 
59
-    if ($default_pos === false) {
59
+	if ($default_pos === false) {
60 60
 
61
-        $change_cat_str = str_replace($default_cat . ',y:', $default_cat . ',y,d:', $change_cat_str);
61
+		$change_cat_str = str_replace($default_cat . ',y:', $default_cat . ',y,d:', $change_cat_str);
62 62
 
63
-    }
63
+	}
64 64
 
65
-    $category_str[$taxonomy] = $change_cat_str;
65
+	$category_str[$taxonomy] = $change_cat_str;
66 66
 
67
-    update_post_meta($post_id, 'post_categories', $category_str);
67
+	update_post_meta($post_id, 'post_categories', $category_str);
68 68
 
69 69
 }
70 70
 
71 71
 
72 72
 if (!function_exists('geodir_save_listing')) {
73
-    /**
74
-     * Saves listing in the database using given information.
75
-     *
76
-     * @since 1.0.0
77
-     * @since 1.5.4 New parameter $wp_error added.
78
-     * @package GeoDirectory
79
-     * @global object $wpdb WordPress Database object.
80
-     * @global object $post The current post object.
81
-     * @global object $current_user Current user object.
73
+	/**
74
+	 * Saves listing in the database using given information.
75
+	 *
76
+	 * @since 1.0.0
77
+	 * @since 1.5.4 New parameter $wp_error added.
78
+	 * @package GeoDirectory
79
+	 * @global object $wpdb WordPress Database object.
80
+	 * @global object $post The current post object.
81
+	 * @global object $current_user Current user object.
82 82
 	 * @global object $gd_session GeoDirectory Session object.
83
-     * @param array $request_info {
84
-     *    Array of request info arguments.
85
-     *
86
-     *    @type string $action                                  Ajax action name.
87
-     *    @type string $geodir_ajax                             Ajax type.
88
-     *    @type string $ajax_action                             Ajax action.
89
-     *    @type string $listing_type                            Listing type.
90
-     *    @type string $pid                                     Default Post ID.
91
-     *    @type string $preview                                 Todo Desc needed.
92
-     *    @type string $add_listing_page_id                     Add listing page ID.
93
-     *    @type string $post_title                              Listing title.
94
-     *    @type string $post_desc                               Listing Description.
95
-     *    @type string $post_tags                               Listing tags.
96
-     *    @type array  $cat_limit                               Category limit.
97
-     *    @type array  $post_category                           Category IDs.
98
-     *    @type array  $post_category_str                       Category string.
99
-     *    @type string $post_default_category                   Default category ID.
100
-     *    @type string $post_address                            Listing address.
101
-     *    @type string $geodir_location_add_listing_country_val Add listing country value.
102
-     *    @type string $post_country                            Listing country.
103
-     *    @type string $geodir_location_add_listing_region_val  Add listing region value.
104
-     *    @type string $post_region                             Listing region.
105
-     *    @type string $geodir_location_add_listing_city_val    Add listing city value.
106
-     *    @type string $post_city                               Listing city.
107
-     *    @type string $post_zip                                Listing zip.
108
-     *    @type string $post_latitude                           Listing latitude.
109
-     *    @type string $post_longitude                          Listing longitude.
110
-     *    @type string $post_mapview                            Listing mapview. Default "ROADMAP".
111
-     *    @type string $post_mapzoom                            Listing mapzoom Default "9".
112
-     *    @type string $geodir_timing                           Business timing info.
113
-     *    @type string $geodir_contact                          Contact number.
114
-     *    @type string $geodir_email                            Business contact email.
115
-     *    @type string $geodir_website                          Business website.
116
-     *    @type string $geodir_twitter                          Twitter link.
117
-     *    @type string $geodir_facebook                         Facebook link.
118
-     *    @type string $geodir_video                            Video link.
119
-     *    @type string $geodir_special_offers                   Speacial offers.
120
-     *    @type string $post_images                             Post image urls.
121
-     *    @type string $post_imagesimage_limit                  Post images limit.
122
-     *    @type string $post_imagestotImg                       Todo Desc needed.
123
-     *    @type string $geodir_accept_term_condition            Has accepted terms and conditions?.
124
-     *    @type string $geodir_spamblocker                      Todo Desc needed.
125
-     *    @type string $geodir_filled_by_spam_bot               Todo Desc needed.
126
-     *
127
-     * }
128
-     * @param bool $dummy Optional. Is this a dummy listing? Default false.
129
-     * @param bool $wp_error Optional. Allow return of WP_Error on failure. Default false.
130
-     * @return int|string|WP_Error Created post id or WP_Error on failure.
131
-     */
132
-    function geodir_save_listing($request_info = array(), $dummy = false, $wp_error = false)
133
-    {
134
-        global $wpdb, $current_user, $gd_session;
135
-
136
-        $last_post_id = '';
137
-
138
-        if ($gd_session->get('listing') && !$dummy) {
139
-            $request_info = array();
140
-            $request_session = $gd_session->get('listing');
141
-            $request_info = array_merge($_REQUEST, $request_session);
142
-        } else if (!$gd_session->get('listing') && !$dummy) {
143
-            global $post;
83
+	 * @param array $request_info {
84
+	 *    Array of request info arguments.
85
+	 *
86
+	 *    @type string $action                                  Ajax action name.
87
+	 *    @type string $geodir_ajax                             Ajax type.
88
+	 *    @type string $ajax_action                             Ajax action.
89
+	 *    @type string $listing_type                            Listing type.
90
+	 *    @type string $pid                                     Default Post ID.
91
+	 *    @type string $preview                                 Todo Desc needed.
92
+	 *    @type string $add_listing_page_id                     Add listing page ID.
93
+	 *    @type string $post_title                              Listing title.
94
+	 *    @type string $post_desc                               Listing Description.
95
+	 *    @type string $post_tags                               Listing tags.
96
+	 *    @type array  $cat_limit                               Category limit.
97
+	 *    @type array  $post_category                           Category IDs.
98
+	 *    @type array  $post_category_str                       Category string.
99
+	 *    @type string $post_default_category                   Default category ID.
100
+	 *    @type string $post_address                            Listing address.
101
+	 *    @type string $geodir_location_add_listing_country_val Add listing country value.
102
+	 *    @type string $post_country                            Listing country.
103
+	 *    @type string $geodir_location_add_listing_region_val  Add listing region value.
104
+	 *    @type string $post_region                             Listing region.
105
+	 *    @type string $geodir_location_add_listing_city_val    Add listing city value.
106
+	 *    @type string $post_city                               Listing city.
107
+	 *    @type string $post_zip                                Listing zip.
108
+	 *    @type string $post_latitude                           Listing latitude.
109
+	 *    @type string $post_longitude                          Listing longitude.
110
+	 *    @type string $post_mapview                            Listing mapview. Default "ROADMAP".
111
+	 *    @type string $post_mapzoom                            Listing mapzoom Default "9".
112
+	 *    @type string $geodir_timing                           Business timing info.
113
+	 *    @type string $geodir_contact                          Contact number.
114
+	 *    @type string $geodir_email                            Business contact email.
115
+	 *    @type string $geodir_website                          Business website.
116
+	 *    @type string $geodir_twitter                          Twitter link.
117
+	 *    @type string $geodir_facebook                         Facebook link.
118
+	 *    @type string $geodir_video                            Video link.
119
+	 *    @type string $geodir_special_offers                   Speacial offers.
120
+	 *    @type string $post_images                             Post image urls.
121
+	 *    @type string $post_imagesimage_limit                  Post images limit.
122
+	 *    @type string $post_imagestotImg                       Todo Desc needed.
123
+	 *    @type string $geodir_accept_term_condition            Has accepted terms and conditions?.
124
+	 *    @type string $geodir_spamblocker                      Todo Desc needed.
125
+	 *    @type string $geodir_filled_by_spam_bot               Todo Desc needed.
126
+	 *
127
+	 * }
128
+	 * @param bool $dummy Optional. Is this a dummy listing? Default false.
129
+	 * @param bool $wp_error Optional. Allow return of WP_Error on failure. Default false.
130
+	 * @return int|string|WP_Error Created post id or WP_Error on failure.
131
+	 */
132
+	function geodir_save_listing($request_info = array(), $dummy = false, $wp_error = false)
133
+	{
134
+		global $wpdb, $current_user, $gd_session;
135
+
136
+		$last_post_id = '';
137
+
138
+		if ($gd_session->get('listing') && !$dummy) {
139
+			$request_info = array();
140
+			$request_session = $gd_session->get('listing');
141
+			$request_info = array_merge($_REQUEST, $request_session);
142
+		} else if (!$gd_session->get('listing') && !$dummy) {
143
+			global $post;
144 144
             
145
-            $gd_post = $post;
146
-            if (!empty($gd_post) && is_array($gd_post)) {
147
-                $gd_post = (object)$post;
145
+			$gd_post = $post;
146
+			if (!empty($gd_post) && is_array($gd_post)) {
147
+				$gd_post = (object)$post;
148 148
                 
149
-                // Fix WPML duplicate.
150
-                if (geodir_is_wpml() && !empty($request_info['action']) && $request_info['action'] == 'editpost' && !empty($request_info['icl_trid']) && !isset($post['post_date'])) {
151
-                    return false;
152
-                }
153
-            }
149
+				// Fix WPML duplicate.
150
+				if (geodir_is_wpml() && !empty($request_info['action']) && $request_info['action'] == 'editpost' && !empty($request_info['icl_trid']) && !isset($post['post_date'])) {
151
+					return false;
152
+				}
153
+			}
154 154
             
155
-            $request_info['pid'] = !empty($gd_post->ID) ? $gd_post->ID : (!empty($request_info['post_id']) ? $request_info['post_id'] : NULL);
156
-            $request_info['post_title'] = $request_info['post_title'];
157
-            $request_info['listing_type'] = !empty($gd_post->post_type) ? $gd_post->post_type : (!empty($request_info['post_type']) ? $request_info['post_type'] : get_post_type($request_info['pid']));
158
-            $request_info['post_desc'] = $request_info['content'];
159
-        } else if (!$dummy) {
160
-            return false;
161
-        }
162
-
163
-        /**
164
-         * Filter the request_info array.
165
-         *
166
-         * You can use this filter to modify request_info array.
167
-         *
168
-         * @since 1.0.0
169
-         * @package GeoDirectory
170
-         * @param array $request_info See {@see geodir_save_listing()} for accepted args.
171
-         */
172
-        $request_info = apply_filters('geodir_action_get_request_info', $request_info);
173
-
174
-        // Check if we need to save post location as new location
175
-        $location_result = geodir_get_default_location();
176
-
177
-        if ($location_result->location_id > 0) {
178
-            if (isset($request_info['post_city']) && isset($request_info['post_region'])) {
179
-                $request_info['post_location'] = array(
180
-                    'city' => $request_info['post_city'],
181
-                    'region' => isset($request_info['post_region']) ? $request_info['post_region'] : '',
182
-                    'country' => isset($request_info['post_country']) ? $request_info['post_country'] : '',
183
-                    'geo_lat' => isset($request_info['post_latitude']) ? $request_info['post_latitude'] : '',
184
-                    'geo_lng' => isset($request_info['post_longitude']) ? $request_info['post_longitude'] : ''
185
-                );
186
-
187
-                $post_location_info = $request_info['post_location'];
188
-
189
-                if ($location_id = geodir_add_new_location($post_location_info)) {
190
-                    $post_location_id = $location_id;
191
-                }
192
-            } else {
193
-                $post_location_id = $location_result->location_id;
194
-            }
195
-        } else {
196
-            $post_location_id = $location_result->location_id;
197
-        }
198
-
199
-        if ($dummy) {
200
-            $post_status = 'publish';
201
-        } else {
202
-            $post_status = geodir_new_post_default_status();
203
-        }
204
-
205
-        if (isset($request_info['pid']) && $request_info['pid'] != '') {
206
-            $post_status = get_post_status($request_info['pid']);
207
-        }
208
-
209
-        /* fix change of slug on every title edit */
210
-        if (!isset($request_info['post_name'])) {
211
-            $request_info['post_name'] = $request_info['post_title'];
212
-
213
-            if (!empty($request_info['pid'])) {
214
-                $post_info = get_post($request_info['pid']);
215
-
216
-                if (!empty($post_info) && isset($post_info->post_name)) {
217
-                    $request_info['post_name'] = $post_info->post_name;
218
-                }
219
-            }
220
-        }
221
-
222
-        $post = array(
223
-            'post_content' => $request_info['post_desc'],
224
-            'post_status' => $post_status,
225
-            'post_title' => $request_info['post_title'],
226
-            'post_name' => $request_info['post_name'],
227
-            'post_type' => $request_info['listing_type']
228
-        );
229
-
230
-        /**
231
-         * Called before a listing is saved to the database.
232
-         *
233
-         * @since 1.0.0
234
-         * @param object $post The post object.
235
-         */
236
-        do_action_ref_array('geodir_before_save_listing', $post);
155
+			$request_info['pid'] = !empty($gd_post->ID) ? $gd_post->ID : (!empty($request_info['post_id']) ? $request_info['post_id'] : NULL);
156
+			$request_info['post_title'] = $request_info['post_title'];
157
+			$request_info['listing_type'] = !empty($gd_post->post_type) ? $gd_post->post_type : (!empty($request_info['post_type']) ? $request_info['post_type'] : get_post_type($request_info['pid']));
158
+			$request_info['post_desc'] = $request_info['content'];
159
+		} else if (!$dummy) {
160
+			return false;
161
+		}
162
+
163
+		/**
164
+		 * Filter the request_info array.
165
+		 *
166
+		 * You can use this filter to modify request_info array.
167
+		 *
168
+		 * @since 1.0.0
169
+		 * @package GeoDirectory
170
+		 * @param array $request_info See {@see geodir_save_listing()} for accepted args.
171
+		 */
172
+		$request_info = apply_filters('geodir_action_get_request_info', $request_info);
173
+
174
+		// Check if we need to save post location as new location
175
+		$location_result = geodir_get_default_location();
176
+
177
+		if ($location_result->location_id > 0) {
178
+			if (isset($request_info['post_city']) && isset($request_info['post_region'])) {
179
+				$request_info['post_location'] = array(
180
+					'city' => $request_info['post_city'],
181
+					'region' => isset($request_info['post_region']) ? $request_info['post_region'] : '',
182
+					'country' => isset($request_info['post_country']) ? $request_info['post_country'] : '',
183
+					'geo_lat' => isset($request_info['post_latitude']) ? $request_info['post_latitude'] : '',
184
+					'geo_lng' => isset($request_info['post_longitude']) ? $request_info['post_longitude'] : ''
185
+				);
186
+
187
+				$post_location_info = $request_info['post_location'];
188
+
189
+				if ($location_id = geodir_add_new_location($post_location_info)) {
190
+					$post_location_id = $location_id;
191
+				}
192
+			} else {
193
+				$post_location_id = $location_result->location_id;
194
+			}
195
+		} else {
196
+			$post_location_id = $location_result->location_id;
197
+		}
237 198
 
238
-        $send_post_submit_mail = false;
199
+		if ($dummy) {
200
+			$post_status = 'publish';
201
+		} else {
202
+			$post_status = geodir_new_post_default_status();
203
+		}
239 204
 
240
-        // unhook this function so it doesn't loop infinitely
241
-        remove_action('save_post', 'geodir_post_information_save',10,2);
205
+		if (isset($request_info['pid']) && $request_info['pid'] != '') {
206
+			$post_status = get_post_status($request_info['pid']);
207
+		}
242 208
 
243
-        if (isset($request_info['pid']) && $request_info['pid'] != '') {
244
-            $post['ID'] = $request_info['pid'];
209
+		/* fix change of slug on every title edit */
210
+		if (!isset($request_info['post_name'])) {
211
+			$request_info['post_name'] = $request_info['post_title'];
245 212
 
246
-            $last_post_id = wp_update_post($post, $wp_error);
247
-        } else {
248
-            $last_post_id = wp_insert_post($post, $wp_error);
213
+			if (!empty($request_info['pid'])) {
214
+				$post_info = get_post($request_info['pid']);
249 215
 
250
-            if (!$dummy && $last_post_id) {
251
-                $send_post_submit_mail = true; // we move post_submit email from here so the rest of the variables are added to the db first(was breaking permalink in email)
252
-                //geodir_sendEmail('','',$current_user->user_email,$current_user->display_name,'','',$request_info,'post_submit',$last_post_id,$current_user->ID);
253
-            }
254
-        }
216
+				if (!empty($post_info) && isset($post_info->post_name)) {
217
+					$request_info['post_name'] = $post_info->post_name;
218
+				}
219
+			}
220
+		}
221
+
222
+		$post = array(
223
+			'post_content' => $request_info['post_desc'],
224
+			'post_status' => $post_status,
225
+			'post_title' => $request_info['post_title'],
226
+			'post_name' => $request_info['post_name'],
227
+			'post_type' => $request_info['listing_type']
228
+		);
229
+
230
+		/**
231
+		 * Called before a listing is saved to the database.
232
+		 *
233
+		 * @since 1.0.0
234
+		 * @param object $post The post object.
235
+		 */
236
+		do_action_ref_array('geodir_before_save_listing', $post);
237
+
238
+		$send_post_submit_mail = false;
239
+
240
+		// unhook this function so it doesn't loop infinitely
241
+		remove_action('save_post', 'geodir_post_information_save',10,2);
242
+
243
+		if (isset($request_info['pid']) && $request_info['pid'] != '') {
244
+			$post['ID'] = $request_info['pid'];
245
+
246
+			$last_post_id = wp_update_post($post, $wp_error);
247
+		} else {
248
+			$last_post_id = wp_insert_post($post, $wp_error);
249
+
250
+			if (!$dummy && $last_post_id) {
251
+				$send_post_submit_mail = true; // we move post_submit email from here so the rest of the variables are added to the db first(was breaking permalink in email)
252
+				//geodir_sendEmail('','',$current_user->user_email,$current_user->display_name,'','',$request_info,'post_submit',$last_post_id,$current_user->ID);
253
+			}
254
+		}
255 255
 
256
-        if ($wp_error && is_wp_error($last_post_id)) {
257
-            return $last_post_id; // Return WP_Error on save failure.
258
-        }
256
+		if ($wp_error && is_wp_error($last_post_id)) {
257
+			return $last_post_id; // Return WP_Error on save failure.
258
+		}
259 259
 
260
-        if (!$last_post_id) {
261
-            return false; // Save failure.
262
-        }
260
+		if (!$last_post_id) {
261
+			return false; // Save failure.
262
+		}
263 263
 
264
-        // re-hook this function
265
-        add_action('save_post', 'geodir_post_information_save',10,2);
264
+		// re-hook this function
265
+		add_action('save_post', 'geodir_post_information_save',10,2);
266 266
 
267
-        $post_tags = '';
268
-        if (!isset($request_info['post_tags'])) {
267
+		$post_tags = '';
268
+		if (!isset($request_info['post_tags'])) {
269 269
 
270
-            $post_type = $request_info['listing_type'];
271
-            $post_tags = implode(",", wp_get_object_terms($last_post_id, $post_type . '_tags', array('fields' => 'names')));
270
+			$post_type = $request_info['listing_type'];
271
+			$post_tags = implode(",", wp_get_object_terms($last_post_id, $post_type . '_tags', array('fields' => 'names')));
272 272
 
273
-        }
273
+		}
274 274
 
275
-        $gd_post_info = array(
276
-            "post_title" => $request_info['post_title'],
277
-            "post_tags" => isset($request_info['post_tags']) ? $request_info['post_tags'] : $post_tags,
278
-            "post_status" => $post_status,
279
-            "post_location_id" => $post_location_id,
280
-            "claimed" => isset($request_info['claimed']) ? $request_info['claimed'] : '',
281
-            "businesses" => isset($request_info['a_businesses']) ? $request_info['a_businesses'] : '',
282
-            "submit_time" => time(),
283
-            "submit_ip" => $_SERVER['REMOTE_ADDR'],
284
-        );
275
+		$gd_post_info = array(
276
+			"post_title" => $request_info['post_title'],
277
+			"post_tags" => isset($request_info['post_tags']) ? $request_info['post_tags'] : $post_tags,
278
+			"post_status" => $post_status,
279
+			"post_location_id" => $post_location_id,
280
+			"claimed" => isset($request_info['claimed']) ? $request_info['claimed'] : '',
281
+			"businesses" => isset($request_info['a_businesses']) ? $request_info['a_businesses'] : '',
282
+			"submit_time" => time(),
283
+			"submit_ip" => $_SERVER['REMOTE_ADDR'],
284
+		);
285 285
 
286
-        $payment_info = array();
287
-        $package_info = array();
286
+		$payment_info = array();
287
+		$package_info = array();
288 288
 
289
-        $package_info = (array)geodir_post_package_info($package_info, $post);
289
+		$package_info = (array)geodir_post_package_info($package_info, $post);
290 290
 
291
-        $post_package_id = geodir_get_post_meta($last_post_id, 'package_id');
291
+		$post_package_id = geodir_get_post_meta($last_post_id, 'package_id');
292 292
 
293
-        if (!empty($package_info) && !$post_package_id) {
294
-            if (isset($package_info['days']) && $package_info['days'] != 0) {
295
-                $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['days'] . " days"));
296
-            } else {
297
-                $payment_info['expire_date'] = 'Never';
298
-            }
293
+		if (!empty($package_info) && !$post_package_id) {
294
+			if (isset($package_info['days']) && $package_info['days'] != 0) {
295
+				$payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['days'] . " days"));
296
+			} else {
297
+				$payment_info['expire_date'] = 'Never';
298
+			}
299 299
 
300
-            $payment_info['package_id'] = $package_info['pid'];
301
-            $payment_info['alive_days'] = $package_info['days'];
302
-            $payment_info['is_featured'] = $package_info['is_featured'];
300
+			$payment_info['package_id'] = $package_info['pid'];
301
+			$payment_info['alive_days'] = $package_info['days'];
302
+			$payment_info['is_featured'] = $package_info['is_featured'];
303 303
 
304
-            $gd_post_info = array_merge($gd_post_info, $payment_info);
305
-        }
304
+			$gd_post_info = array_merge($gd_post_info, $payment_info);
305
+		}
306 306
 
307
-        $custom_metaboxes = geodir_post_custom_fields('', 'all', $request_info['listing_type']);
307
+		$custom_metaboxes = geodir_post_custom_fields('', 'all', $request_info['listing_type']);
308 308
 
309
-        foreach ($custom_metaboxes as $key => $val):
309
+		foreach ($custom_metaboxes as $key => $val):
310 310
 
311
-            $name = $val['name'];
312
-            $type = $val['type'];
313
-            $extrafields = $val['extra_fields'];
311
+			$name = $val['name'];
312
+			$type = $val['type'];
313
+			$extrafields = $val['extra_fields'];
314 314
 
315
-            if (trim($type) == 'address') {
316
-                $prefix = $name . '_';
317
-                $address = $prefix . 'address';
315
+			if (trim($type) == 'address') {
316
+				$prefix = $name . '_';
317
+				$address = $prefix . 'address';
318 318
 
319
-                if (isset($request_info[$address]) && $request_info[$address] != '') {
320
-                    $gd_post_info[$address] = wp_slash($request_info[$address]);
321
-                }
319
+				if (isset($request_info[$address]) && $request_info[$address] != '') {
320
+					$gd_post_info[$address] = wp_slash($request_info[$address]);
321
+				}
322 322
 
323
-                if ($extrafields != '') {
324
-                    $extrafields = unserialize($extrafields);
323
+				if ($extrafields != '') {
324
+					$extrafields = unserialize($extrafields);
325 325
 
326 326
 
327
-                    if (!isset($request_info[$prefix . 'city']) || $request_info[$prefix . 'city'] == '') {
327
+					if (!isset($request_info[$prefix . 'city']) || $request_info[$prefix . 'city'] == '') {
328 328
 
329
-                        $location_result = geodir_get_default_location();
329
+						$location_result = geodir_get_default_location();
330 330
 
331
-                        $gd_post_info[$prefix . 'city'] = $location_result->city;
332
-                        $gd_post_info[$prefix . 'region'] = $location_result->region;
333
-                        $gd_post_info[$prefix . 'country'] = $location_result->country;
331
+						$gd_post_info[$prefix . 'city'] = $location_result->city;
332
+						$gd_post_info[$prefix . 'region'] = $location_result->region;
333
+						$gd_post_info[$prefix . 'country'] = $location_result->country;
334 334
 
335
-                        $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location
335
+						$gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location
336 336
 
337
-                    } else {
337
+					} else {
338 338
 
339
-                        $gd_post_info[$prefix . 'city'] = $request_info[$prefix . 'city'];
340
-                        $gd_post_info[$prefix . 'region'] = $request_info[$prefix . 'region'];
341
-                        $gd_post_info[$prefix . 'country'] = $request_info[$prefix . 'country'];
339
+						$gd_post_info[$prefix . 'city'] = $request_info[$prefix . 'city'];
340
+						$gd_post_info[$prefix . 'region'] = $request_info[$prefix . 'region'];
341
+						$gd_post_info[$prefix . 'country'] = $request_info[$prefix . 'country'];
342 342
 
343
-                        //----------set post locations when import dummy data-------
344
-                        $location_result = geodir_get_default_location();
343
+						//----------set post locations when import dummy data-------
344
+						$location_result = geodir_get_default_location();
345 345
 
346
-                        $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location
347
-                        //-----------------------------------------------------------------
346
+						$gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location
347
+						//-----------------------------------------------------------------
348 348
 
349
-                    }
349
+					}
350 350
 
351 351
 
352
-                    if (isset($extrafields['show_zip']) && $extrafields['show_zip'] && isset($request_info[$prefix . 'zip'])) {
353
-                        $gd_post_info[$prefix . 'zip'] = $request_info[$prefix . 'zip'];
354
-                    }
352
+					if (isset($extrafields['show_zip']) && $extrafields['show_zip'] && isset($request_info[$prefix . 'zip'])) {
353
+						$gd_post_info[$prefix . 'zip'] = $request_info[$prefix . 'zip'];
354
+					}
355 355
 
356 356
 
357
-                    if (isset($extrafields['show_map']) && $extrafields['show_map']) {
357
+					if (isset($extrafields['show_map']) && $extrafields['show_map']) {
358 358
 
359
-                        if (isset($request_info[$prefix . 'latitude']) && $request_info[$prefix . 'latitude'] != '') {
360
-                            $gd_post_info[$prefix . 'latitude'] = $request_info[$prefix . 'latitude'];
361
-                        }
359
+						if (isset($request_info[$prefix . 'latitude']) && $request_info[$prefix . 'latitude'] != '') {
360
+							$gd_post_info[$prefix . 'latitude'] = $request_info[$prefix . 'latitude'];
361
+						}
362 362
 
363
-                        if (isset($request_info[$prefix . 'longitude']) && $request_info[$prefix . 'longitude'] != '') {
364
-                            $gd_post_info[$prefix . 'longitude'] = $request_info[$prefix . 'longitude'];
365
-                        }
363
+						if (isset($request_info[$prefix . 'longitude']) && $request_info[$prefix . 'longitude'] != '') {
364
+							$gd_post_info[$prefix . 'longitude'] = $request_info[$prefix . 'longitude'];
365
+						}
366 366
 
367
-                        if (isset($request_info[$prefix . 'mapview']) && $request_info[$prefix . 'mapview'] != '') {
368
-                            $gd_post_info[$prefix . 'mapview'] = $request_info[$prefix . 'mapview'];
369
-                        }
367
+						if (isset($request_info[$prefix . 'mapview']) && $request_info[$prefix . 'mapview'] != '') {
368
+							$gd_post_info[$prefix . 'mapview'] = $request_info[$prefix . 'mapview'];
369
+						}
370 370
 
371
-                        if (isset($request_info[$prefix . 'mapzoom']) && $request_info[$prefix . 'mapzoom'] != '') {
372
-                            $gd_post_info[$prefix . 'mapzoom'] = $request_info[$prefix . 'mapzoom'];
373
-                        }
371
+						if (isset($request_info[$prefix . 'mapzoom']) && $request_info[$prefix . 'mapzoom'] != '') {
372
+							$gd_post_info[$prefix . 'mapzoom'] = $request_info[$prefix . 'mapzoom'];
373
+						}
374 374
 
375
-                    }
375
+					}
376 376
 
377
-                    // show lat lng
378
-                    if (isset($extrafields['show_latlng']) && $extrafields['show_latlng'] && isset($request_info[$prefix . 'latlng'])) {
379
-                        $gd_post_info[$prefix . 'latlng'] = $request_info[$prefix . 'latlng'];
380
-                    }
381
-                }
377
+					// show lat lng
378
+					if (isset($extrafields['show_latlng']) && $extrafields['show_latlng'] && isset($request_info[$prefix . 'latlng'])) {
379
+						$gd_post_info[$prefix . 'latlng'] = $request_info[$prefix . 'latlng'];
380
+					}
381
+				}
382 382
 
383
-            } elseif (trim($type) == 'file') {
384
-                if (isset($request_info[$name])) {
385
-                    $request_files = array();
386
-                    if ($request_info[$name] != '')
387
-                        $request_files = explode(",", $request_info[$name]);
383
+			} elseif (trim($type) == 'file') {
384
+				if (isset($request_info[$name])) {
385
+					$request_files = array();
386
+					if ($request_info[$name] != '')
387
+						$request_files = explode(",", $request_info[$name]);
388 388
 
389
-                    $extrafields = $extrafields != '' ? maybe_unserialize($extrafields) : NULL;
390
-                    geodir_save_post_file_fields($last_post_id, $name, $request_files, $extrafields);
389
+					$extrafields = $extrafields != '' ? maybe_unserialize($extrafields) : NULL;
390
+					geodir_save_post_file_fields($last_post_id, $name, $request_files, $extrafields);
391 391
 
392
-                }
393
-            } elseif (trim($type) == 'datepicker') {
394
-                $datetime = '';
395
-                if (isset($request_info[$name]) && $request_info[$name] != '') {
396
-                    $date_format = geodir_default_date_format();
397
-                    if (isset($val['extra_fields']) && $val['extra_fields'] != '') {
398
-                        $extra_fields = unserialize($val['extra_fields']);
399
-                        $date_format = isset($extra_fields['date_format']) && $extra_fields['date_format'] != '' ? $extra_fields['date_format'] : $date_format;
400
-                    }
392
+				}
393
+			} elseif (trim($type) == 'datepicker') {
394
+				$datetime = '';
395
+				if (isset($request_info[$name]) && $request_info[$name] != '') {
396
+					$date_format = geodir_default_date_format();
397
+					if (isset($val['extra_fields']) && $val['extra_fields'] != '') {
398
+						$extra_fields = unserialize($val['extra_fields']);
399
+						$date_format = isset($extra_fields['date_format']) && $extra_fields['date_format'] != '' ? $extra_fields['date_format'] : $date_format;
400
+					}
401 401
 
402
-                    // check if we need to change the format or not
403
-                    $date_format_len = strlen(str_replace(' ', '', $date_format));
404
-                    if($date_format_len>5){// if greater then 5 then it's the old style format.
402
+					// check if we need to change the format or not
403
+					$date_format_len = strlen(str_replace(' ', '', $date_format));
404
+					if($date_format_len>5){// if greater then 5 then it's the old style format.
405 405
 
406
-                        $search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format
407
-                        $replace = array('d','j','l','m','n','F','Y');//PHP date format
406
+						$search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format
407
+						$replace = array('d','j','l','m','n','F','Y');//PHP date format
408 408
 
409
-                        $date_format = str_replace($search, $replace, $date_format);
409
+						$date_format = str_replace($search, $replace, $date_format);
410 410
 
411
-                        $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $request_info[$name]) : $request_info[$name];
411
+						$post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $request_info[$name]) : $request_info[$name];
412 412
 
413
-                    }else{
414
-                        $post_htmlvar_value = $request_info[$name];
415
-                    }
413
+					}else{
414
+						$post_htmlvar_value = $request_info[$name];
415
+					}
416 416
 
417
-                    $post_htmlvar_value = geodir_date($post_htmlvar_value, 'Y-m-d', $date_format); // save as sql format Y-m-d
418
-                    $datetime = geodir_maybe_untranslate_date($post_htmlvar_value); // maybe untranslate date string if it was translated
417
+					$post_htmlvar_value = geodir_date($post_htmlvar_value, 'Y-m-d', $date_format); // save as sql format Y-m-d
418
+					$datetime = geodir_maybe_untranslate_date($post_htmlvar_value); // maybe untranslate date string if it was translated
419 419
 
420
-                    //$datetime = date_i18n("Y-m-d", strtotime($post_htmlvar_value)); // save as sql format Y-m-d
420
+					//$datetime = date_i18n("Y-m-d", strtotime($post_htmlvar_value)); // save as sql format Y-m-d
421 421
 
422
-                }
423
-                $gd_post_info[$name] = $datetime;
424
-            } else if ($type == 'multiselect') {
425
-                if (isset($request_info[$name])) {
426
-                    $gd_post_info[$name] = $request_info[$name];
427
-                } else {
428
-                    if (isset($request_info['gd_field_' . $name])) {
429
-                        $gd_post_info[$name] = ''; /* fix de-select for multiselect */
430
-                    }
431
-                }
432
-            } else if (isset($request_info[$name])) {
433
-                $gd_post_info[$name] = $request_info[$name];
434
-            }
422
+				}
423
+				$gd_post_info[$name] = $datetime;
424
+			} else if ($type == 'multiselect') {
425
+				if (isset($request_info[$name])) {
426
+					$gd_post_info[$name] = $request_info[$name];
427
+				} else {
428
+					if (isset($request_info['gd_field_' . $name])) {
429
+						$gd_post_info[$name] = ''; /* fix de-select for multiselect */
430
+					}
431
+				}
432
+			} else if (isset($request_info[$name])) {
433
+				$gd_post_info[$name] = $request_info[$name];
434
+			}
435 435
 
436
-        endforeach;
436
+		endforeach;
437 437
 
438
-        if (isset($request_info['post_dummy']) && $request_info['post_dummy'] != '') {
439
-            $gd_post_info['post_dummy'] = $request_info['post_dummy'];
440
-        }
438
+		if (isset($request_info['post_dummy']) && $request_info['post_dummy'] != '') {
439
+			$gd_post_info['post_dummy'] = $request_info['post_dummy'];
440
+		}
441 441
 
442
-        // Save post detail info in detail table
443
-        if (!empty($gd_post_info)) {
444
-            geodir_save_post_info($last_post_id, $gd_post_info);
445
-        }
442
+		// Save post detail info in detail table
443
+		if (!empty($gd_post_info)) {
444
+			geodir_save_post_info($last_post_id, $gd_post_info);
445
+		}
446 446
 
447 447
 
448
-        // Set categories to the listing
449
-        if (isset($request_info['post_category']) && !empty($request_info['post_category'])) {
450
-            $post_category = array();
448
+		// Set categories to the listing
449
+		if (isset($request_info['post_category']) && !empty($request_info['post_category'])) {
450
+			$post_category = array();
451 451
 
452
-            foreach ($request_info['post_category'] as $taxonomy => $cat) {
452
+			foreach ($request_info['post_category'] as $taxonomy => $cat) {
453 453
 
454
-                if ($dummy)
455
-                    $post_category = $cat;
456
-                else {
454
+				if ($dummy)
455
+					$post_category = $cat;
456
+				else {
457 457
 
458
-                    if (!is_array($cat) && strstr($cat, ','))
459
-                        $cat = explode(',', $cat);
458
+					if (!is_array($cat) && strstr($cat, ','))
459
+						$cat = explode(',', $cat);
460 460
 
461
-                    if (!empty($cat) && is_array($cat))
462
-                        $post_category = array_map('intval', $cat);
463
-                }
461
+					if (!empty($cat) && is_array($cat))
462
+						$post_category = array_map('intval', $cat);
463
+				}
464 464
 
465
-                wp_set_object_terms($last_post_id, $post_category, $taxonomy);
466
-            }
465
+				wp_set_object_terms($last_post_id, $post_category, $taxonomy);
466
+			}
467 467
 
468
-            $post_default_category = isset($request_info['post_default_category']) ? $request_info['post_default_category'] : '';
468
+			$post_default_category = isset($request_info['post_default_category']) ? $request_info['post_default_category'] : '';
469 469
 
470
-            $post_category_str = isset($request_info['post_category_str']) ? $request_info['post_category_str'] : '';
471
-            geodir_set_postcat_structure($last_post_id, $taxonomy, $post_default_category, $post_category_str);
470
+			$post_category_str = isset($request_info['post_category_str']) ? $request_info['post_category_str'] : '';
471
+			geodir_set_postcat_structure($last_post_id, $taxonomy, $post_default_category, $post_category_str);
472 472
 
473
-        }
473
+		}
474 474
 
475
-        $post_tags = '';
476
-        // Set tags to the listing
477
-        if (isset($request_info['post_tags']) && !is_array($request_info['post_tags']) && !empty($request_info['post_tags'])) {
478
-            $post_tags = explode(",", $request_info['post_tags']);
479
-        } elseif (isset($request_info['post_tags']) && is_array($request_info['post_tags'])) {
480
-            if ($dummy)
481
-                $post_tags = $request_info['post_tags'];
482
-        } else {
483
-            if ($dummy)
484
-                $post_tags = array($request_info['post_title']);
485
-        }
475
+		$post_tags = '';
476
+		// Set tags to the listing
477
+		if (isset($request_info['post_tags']) && !is_array($request_info['post_tags']) && !empty($request_info['post_tags'])) {
478
+			$post_tags = explode(",", $request_info['post_tags']);
479
+		} elseif (isset($request_info['post_tags']) && is_array($request_info['post_tags'])) {
480
+			if ($dummy)
481
+				$post_tags = $request_info['post_tags'];
482
+		} else {
483
+			if ($dummy)
484
+				$post_tags = array($request_info['post_title']);
485
+		}
486 486
 
487
-        if (is_array($post_tags)) {
488
-            $taxonomy = $request_info['listing_type'] . '_tags';
489
-            wp_set_object_terms($last_post_id, $post_tags, $taxonomy);
490
-        }
487
+		if (is_array($post_tags)) {
488
+			$taxonomy = $request_info['listing_type'] . '_tags';
489
+			wp_set_object_terms($last_post_id, $post_tags, $taxonomy);
490
+		}
491 491
 
492 492
 
493
-        // Insert attechment
493
+		// Insert attechment
494 494
 
495
-        if (isset($request_info['post_images']) && !is_wp_error($last_post_id)) {
496
-            if (!$dummy) {
497
-                $tmpimgArr = trim($request_info['post_images'], ",");
498
-                $tmpimgArr = explode(",", $tmpimgArr);
499
-                geodir_save_post_images($last_post_id, $tmpimgArr, $dummy);
500
-            } else{
501
-                geodir_save_post_images($last_post_id, $request_info['post_images'], $dummy);
502
-            }
495
+		if (isset($request_info['post_images']) && !is_wp_error($last_post_id)) {
496
+			if (!$dummy) {
497
+				$tmpimgArr = trim($request_info['post_images'], ",");
498
+				$tmpimgArr = explode(",", $tmpimgArr);
499
+				geodir_save_post_images($last_post_id, $tmpimgArr, $dummy);
500
+			} else{
501
+				geodir_save_post_images($last_post_id, $request_info['post_images'], $dummy);
502
+			}
503 503
 
504 504
 
505
-        } elseif (!isset($request_info['post_images']) || $request_info['post_images'] == '') {
505
+		} elseif (!isset($request_info['post_images']) || $request_info['post_images'] == '') {
506 506
 
507
-            /* Delete Attachments
507
+			/* Delete Attachments
508 508
 			$postcurr_images = geodir_get_images($last_post_id);
509 509
 
510 510
 			$wpdb->query(
@@ -520,34 +520,34 @@  discard block
 block discarded – undo
520 520
 			geodir_save_post_info($last_post_id, $gd_post_featured_img);
521 521
 			*/
522 522
 
523
-        }
523
+		}
524 524
 
525
-        geodir_remove_temp_images();
526
-        geodir_set_wp_featured_image($last_post_id);
525
+		geodir_remove_temp_images();
526
+		geodir_set_wp_featured_image($last_post_id);
527 527
 
528
-        /**
529
-         * Called after a listing is saved to the database and before any email have been sent.
530
-         *
531
-         * @since 1.0.0
532
-         * @param int $last_post_id The saved post ID.
533
-         * @param array $request_info The post details in an array.
534
-         * @see 'geodir_after_save_listinginfo'
535
-         */
536
-        do_action('geodir_after_save_listing', $last_post_id, $request_info);
528
+		/**
529
+		 * Called after a listing is saved to the database and before any email have been sent.
530
+		 *
531
+		 * @since 1.0.0
532
+		 * @param int $last_post_id The saved post ID.
533
+		 * @param array $request_info The post details in an array.
534
+		 * @see 'geodir_after_save_listinginfo'
535
+		 */
536
+		do_action('geodir_after_save_listing', $last_post_id, $request_info);
537 537
 
538
-        //die;
538
+		//die;
539 539
 
540
-        if ($send_post_submit_mail) { // if new post send out email
541
-            $to_name = geodir_get_client_name($current_user->ID);
542
-            geodir_sendEmail('', '', $current_user->user_email, $to_name, '', '', $request_info, 'post_submit', $last_post_id, $current_user->ID);
543
-        }
544
-        /*
540
+		if ($send_post_submit_mail) { // if new post send out email
541
+			$to_name = geodir_get_client_name($current_user->ID);
542
+			geodir_sendEmail('', '', $current_user->user_email, $to_name, '', '', $request_info, 'post_submit', $last_post_id, $current_user->ID);
543
+		}
544
+		/*
545 545
          * Unset the session so we don't loop.
546 546
          */
547
-        $gd_session->un_set('listing');
548
-        return $last_post_id;
547
+		$gd_session->un_set('listing');
548
+		return $last_post_id;
549 549
 
550
-    }
550
+	}
551 551
 
552 552
 }
553 553
 
@@ -566,599 +566,599 @@  discard block
 block discarded – undo
566 566
 function geodir_get_post_info($post_id = '')
567 567
 {
568 568
 
569
-    global $wpdb, $plugin_prefix, $post, $post_info;
569
+	global $wpdb, $plugin_prefix, $post, $post_info;
570 570
 
571
-    if ($post_id == '' && !empty($post))
572
-        $post_id = $post->ID;
571
+	if ($post_id == '' && !empty($post))
572
+		$post_id = $post->ID;
573 573
 
574
-    $post_type = get_post_type($post_id);
574
+	$post_type = get_post_type($post_id);
575 575
 
576
-    $all_postypes = geodir_get_posttypes();
576
+	$all_postypes = geodir_get_posttypes();
577 577
 
578
-    if (!in_array($post_type, $all_postypes))
579
-        return false;
578
+	if (!in_array($post_type, $all_postypes))
579
+		return false;
580 580
 
581
-    $table = $plugin_prefix . $post_type . '_detail';
581
+	$table = $plugin_prefix . $post_type . '_detail';
582 582
 
583
-    /**
584
-     * Apply Filter to change Post info
585
-     *
586
-     * You can use this filter to change Post info.
587
-     *
588
-     * @since 1.0.0
589
-     * @package GeoDirectory
590
-     */
591
-    $query = apply_filters('geodir_post_info_query', "SELECT p.*,pd.* FROM " . $wpdb->posts . " p," . $table . " pd
583
+	/**
584
+	 * Apply Filter to change Post info
585
+	 *
586
+	 * You can use this filter to change Post info.
587
+	 *
588
+	 * @since 1.0.0
589
+	 * @package GeoDirectory
590
+	 */
591
+	$query = apply_filters('geodir_post_info_query', "SELECT p.*,pd.* FROM " . $wpdb->posts . " p," . $table . " pd
592 592
 			  WHERE p.ID = pd.post_id
593 593
 			  AND post_id = " . $post_id);
594 594
 
595
-    $post_detail = $wpdb->get_row($query);
595
+	$post_detail = $wpdb->get_row($query);
596 596
 
597
-    return (!empty($post_detail)) ? $post_info = $post_detail : $post_info = false;
597
+	return (!empty($post_detail)) ? $post_info = $post_detail : $post_info = false;
598 598
 
599 599
 }
600 600
 
601 601
 
602 602
 if (!function_exists('geodir_save_post_info')) {
603
-    /**
604
-     * Saves post detail info in detail table.
605
-     *
606
-     * @since 1.0.0
607
-     * @package GeoDirectory
608
-     * @global object $wpdb WordPress Database object.
609
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
610
-     * @param int $post_id The post ID.
611
-     * @param array $postinfo_array {
612
-     *    Post info that needs to be saved in detail table.
613
-     *
614
-     *    @type string $post_title              Listing title.
615
-     *    @type string $post_tags               Listing tags.
616
-     *    @type string $post_status             Listing post status.
617
-     *    @type string $post_location_id        Listing location ID.
618
-     *    @type string $claimed                 Todo Desc needed.
619
-     *    @type string $businesses              Todo Desc needed.
620
-     *    @type int    $submit_time             Submitted time in unix timestamp.
621
-     *    @type string $submit_ip               Submitted IP.
622
-     *    @type string $expire_date             Listing expiration date.
623
-     *    @type int    $package_id              Listing package ID.
624
-     *    @type int    $alive_days              Todo Desc needed.
625
-     *    @type int    $is_featured             Is this a featured listing?.
626
-     *    @type string $post_address            Listing address.
627
-     *    @type string $post_city               Listing city.
628
-     *    @type string $post_region             Listing region.
629
-     *    @type string $post_country            Listing country.
630
-     *    @type string $post_locations          Listing locations.
631
-     *    @type string $post_zip                Listing zip.
632
-     *    @type string $post_latitude           Listing latitude.
633
-     *    @type string $post_longitude          Listing longitude.
634
-     *    @type string $post_mapview            Listing mapview. Default "ROADMAP".
635
-     *    @type string $post_mapzoom            Listing mapzoom Default "9".
636
-     *    @type string $geodir_timing           Business timing info.
637
-     *    @type string $geodir_contact          Contact number.
638
-     *    @type string $geodir_email            Business contact email.
639
-     *    @type string $geodir_website          Business website.
640
-     *    @type string $geodir_twitter          Twitter link.
641
-     *    @type string $geodir_facebook         Facebook link.
642
-     *    @type string $geodir_video            Video link.
643
-     *    @type string $geodir_special_offers   Speacial offers.
644
-     *
645
-     * }
646
-     * @return bool
647
-     */
648
-    function geodir_save_post_info($post_id, $postinfo_array = array())
649
-    {
650
-        global $wpdb, $plugin_prefix;
651
-
652
-        $post_type = get_post_type($post_id);
653
-
654
-        $table = $plugin_prefix . $post_type . '_detail';
655
-
656
-        /**
657
-         * Filter to change Post info
658
-         *
659
-         * You can use this filter to change Post info.
660
-         *
661
-         * @since 1.0.0
662
-         * @package GeoDirectory
663
-         * @param array $postinfo_array See {@see geodir_save_post_info()} for accepted args.
664
-         * @param int $post_id The post ID.
665
-         */
666
-        $postmeta = apply_filters('geodir_listinginfo_request', $postinfo_array, $post_id);
603
+	/**
604
+	 * Saves post detail info in detail table.
605
+	 *
606
+	 * @since 1.0.0
607
+	 * @package GeoDirectory
608
+	 * @global object $wpdb WordPress Database object.
609
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
610
+	 * @param int $post_id The post ID.
611
+	 * @param array $postinfo_array {
612
+	 *    Post info that needs to be saved in detail table.
613
+	 *
614
+	 *    @type string $post_title              Listing title.
615
+	 *    @type string $post_tags               Listing tags.
616
+	 *    @type string $post_status             Listing post status.
617
+	 *    @type string $post_location_id        Listing location ID.
618
+	 *    @type string $claimed                 Todo Desc needed.
619
+	 *    @type string $businesses              Todo Desc needed.
620
+	 *    @type int    $submit_time             Submitted time in unix timestamp.
621
+	 *    @type string $submit_ip               Submitted IP.
622
+	 *    @type string $expire_date             Listing expiration date.
623
+	 *    @type int    $package_id              Listing package ID.
624
+	 *    @type int    $alive_days              Todo Desc needed.
625
+	 *    @type int    $is_featured             Is this a featured listing?.
626
+	 *    @type string $post_address            Listing address.
627
+	 *    @type string $post_city               Listing city.
628
+	 *    @type string $post_region             Listing region.
629
+	 *    @type string $post_country            Listing country.
630
+	 *    @type string $post_locations          Listing locations.
631
+	 *    @type string $post_zip                Listing zip.
632
+	 *    @type string $post_latitude           Listing latitude.
633
+	 *    @type string $post_longitude          Listing longitude.
634
+	 *    @type string $post_mapview            Listing mapview. Default "ROADMAP".
635
+	 *    @type string $post_mapzoom            Listing mapzoom Default "9".
636
+	 *    @type string $geodir_timing           Business timing info.
637
+	 *    @type string $geodir_contact          Contact number.
638
+	 *    @type string $geodir_email            Business contact email.
639
+	 *    @type string $geodir_website          Business website.
640
+	 *    @type string $geodir_twitter          Twitter link.
641
+	 *    @type string $geodir_facebook         Facebook link.
642
+	 *    @type string $geodir_video            Video link.
643
+	 *    @type string $geodir_special_offers   Speacial offers.
644
+	 *
645
+	 * }
646
+	 * @return bool
647
+	 */
648
+	function geodir_save_post_info($post_id, $postinfo_array = array())
649
+	{
650
+		global $wpdb, $plugin_prefix;
651
+
652
+		$post_type = get_post_type($post_id);
653
+
654
+		$table = $plugin_prefix . $post_type . '_detail';
655
+
656
+		/**
657
+		 * Filter to change Post info
658
+		 *
659
+		 * You can use this filter to change Post info.
660
+		 *
661
+		 * @since 1.0.0
662
+		 * @package GeoDirectory
663
+		 * @param array $postinfo_array See {@see geodir_save_post_info()} for accepted args.
664
+		 * @param int $post_id The post ID.
665
+		 */
666
+		$postmeta = apply_filters('geodir_listinginfo_request', $postinfo_array, $post_id);
667
+
668
+		$query_string_escaped = '';
669
+		$query_string_array = array();
670
+
671
+		if (!empty($postmeta) && $post_id) {
672
+
673
+			$columns = $wpdb->get_col("show columns from $table");
674
+			foreach ($postmeta as $mkey => $mval) {
675
+				if(in_array($mkey,$columns)) {
676
+					if (is_array($mval)) {
677
+						$mval = implode(",", $mval);
678
+					}
679
+					$query_string_escaped .= " $mkey = %s, "; // we can set the key here as we check if the column exists above
680
+					$query_string_array[] = stripslashes($mval); // we strip slashes as we are using wpdb prepare
667 681
 
668
-        $query_string_escaped = '';
669
-        $query_string_array = array();
682
+				}
683
+			}
670 684
 
671
-        if (!empty($postmeta) && $post_id) {
685
+			$query_string_escaped = trim($query_string_escaped, ", ");
672 686
 
673
-            $columns = $wpdb->get_col("show columns from $table");
674
-            foreach ($postmeta as $mkey => $mval) {
675
-                if(in_array($mkey,$columns)) {
676
-                    if (is_array($mval)) {
677
-                        $mval = implode(",", $mval);
678
-                    }
679
-                    $query_string_escaped .= " $mkey = %s, "; // we can set the key here as we check if the column exists above
680
-                    $query_string_array[] = stripslashes($mval); // we strip slashes as we are using wpdb prepare
687
+			if (empty($query_string_array) || trim($query_string_escaped) == '') {
688
+				return false;
689
+			}
681 690
 
682
-                }
683
-            }
691
+			$query_string_array = str_replace(array("'%", "%'"), array("'%%", "%%'"), $query_string_array);
684 692
 
685
-            $query_string_escaped = trim($query_string_escaped, ", ");
686 693
 
687
-            if (empty($query_string_array) || trim($query_string_escaped) == '') {
688
-                return false;
689
-            }
694
+			/**
695
+			 * Called before saving the listing info.
696
+			 *
697
+			 * @since 1.0.0
698
+			 * @package GeoDirectory
699
+			 * @param array $postinfo_array See {@see geodir_save_post_info()} for accepted args.
700
+			 * @param int $post_id The post ID.
701
+			 */
702
+			do_action('geodir_before_save_listinginfo', $postinfo_array, $post_id);
690 703
 
691
-            $query_string_array = str_replace(array("'%", "%'"), array("'%%", "%%'"), $query_string_array);
704
+			if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
692 705
 
706
+				$query_string_array[] = $post_id;
707
+				$wpdb->query(
708
+					$wpdb->prepare(
709
+						"UPDATE " . $table . " SET " . $query_string_escaped . " where post_id =%d",
710
+						$query_string_array
711
+					)
712
+				);
693 713
 
694
-            /**
695
-             * Called before saving the listing info.
696
-             *
697
-             * @since 1.0.0
698
-             * @package GeoDirectory
699
-             * @param array $postinfo_array See {@see geodir_save_post_info()} for accepted args.
700
-             * @param int $post_id The post ID.
701
-             */
702
-            do_action('geodir_before_save_listinginfo', $postinfo_array, $post_id);
703 714
 
704
-            if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
715
+			} else {
705 716
 
706
-                $query_string_array[] = $post_id;
707
-                $wpdb->query(
708
-                    $wpdb->prepare(
709
-                        "UPDATE " . $table . " SET " . $query_string_escaped . " where post_id =%d",
710
-                        $query_string_array
711
-                    )
712
-                );
717
+				array_unshift($query_string_array, $post_id);
718
+				$wpdb->query(
719
+					$wpdb->prepare(
720
+						"INSERT INTO " . $table . " SET post_id = %d," . $query_string_escaped,
721
+						$query_string_array
722
+					)
723
+				);
724
+                
725
+			}
713 726
 
727
+			/**
728
+			 * Called after saving the listing info.
729
+			 *
730
+			 * @since 1.0.0
731
+			 * @package GeoDirectory
732
+			 * @param array $postinfo_array Post info that needs to be saved in detail table.
733
+			 * @param int $post_id The post ID.
734
+			 * @see 'geodir_after_save_listing'
735
+			 */
736
+			do_action('geodir_after_save_listinginfo', $postinfo_array, $post_id);
737
+
738
+			return true;
739
+		} else
740
+			return false;
714 741
 
715
-            } else {
742
+	}
743
+}
716 744
 
717
-                array_unshift($query_string_array, $post_id);
718
-                $wpdb->query(
719
-                    $wpdb->prepare(
720
-                        "INSERT INTO " . $table . " SET post_id = %d," . $query_string_escaped,
721
-                        $query_string_array
722
-                    )
723
-                );
724
-                
725
-            }
726 745
 
727
-            /**
728
-             * Called after saving the listing info.
729
-             *
730
-             * @since 1.0.0
731
-             * @package GeoDirectory
732
-             * @param array $postinfo_array Post info that needs to be saved in detail table.
733
-             * @param int $post_id The post ID.
734
-             * @see 'geodir_after_save_listing'
735
-             */
736
-            do_action('geodir_after_save_listinginfo', $postinfo_array, $post_id);
746
+if (!function_exists('geodir_save_post_meta')) {
747
+	/**
748
+	 * Save or update post custom fields.
749
+	 *
750
+	 * @since 1.0.0
751
+	 * @package GeoDirectory
752
+	 * @global object $wpdb WordPress Database object.
753
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
754
+	 * @param int $post_id The post ID.
755
+	 * @param string $postmeta Detail table column name.
756
+	 * @param string $meta_value Detail table column value.
757
+	 * @return void|bool
758
+	 */
759
+	function geodir_save_post_meta($post_id, $postmeta = '', $meta_value = '')
760
+	{
761
+
762
+		global $wpdb, $plugin_prefix;
763
+
764
+		$post_type = get_post_type($post_id);
765
+
766
+		$table = $plugin_prefix . $post_type . '_detail';
767
+
768
+		if ($postmeta != '' && geodir_column_exist($table, $postmeta) && $post_id) {
769
+
770
+			if (is_array($meta_value)) {
771
+				$meta_value = implode(",", $meta_value);
772
+			}
737 773
 
738
-            return true;
739
-        } else
740
-            return false;
774
+			if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
741 775
 
742
-    }
743
-}
776
+				$wpdb->query(
777
+					$wpdb->prepare(
778
+						"UPDATE " . $table . " SET " . $postmeta . " = '" . $meta_value . "' where post_id =%d",
779
+						array($post_id)
780
+					)
781
+				);
744 782
 
783
+			} else {
745 784
 
746
-if (!function_exists('geodir_save_post_meta')) {
747
-    /**
748
-     * Save or update post custom fields.
749
-     *
750
-     * @since 1.0.0
751
-     * @package GeoDirectory
752
-     * @global object $wpdb WordPress Database object.
753
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
754
-     * @param int $post_id The post ID.
755
-     * @param string $postmeta Detail table column name.
756
-     * @param string $meta_value Detail table column value.
757
-     * @return void|bool
758
-     */
759
-    function geodir_save_post_meta($post_id, $postmeta = '', $meta_value = '')
760
-    {
761
-
762
-        global $wpdb, $plugin_prefix;
763
-
764
-        $post_type = get_post_type($post_id);
765
-
766
-        $table = $plugin_prefix . $post_type . '_detail';
767
-
768
-        if ($postmeta != '' && geodir_column_exist($table, $postmeta) && $post_id) {
769
-
770
-            if (is_array($meta_value)) {
771
-                $meta_value = implode(",", $meta_value);
772
-            }
773
-
774
-            if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
775
-
776
-                $wpdb->query(
777
-                    $wpdb->prepare(
778
-                        "UPDATE " . $table . " SET " . $postmeta . " = '" . $meta_value . "' where post_id =%d",
779
-                        array($post_id)
780
-                    )
781
-                );
782
-
783
-            } else {
784
-
785
-                $wpdb->query(
786
-                    $wpdb->prepare(
787
-                        "INSERT INTO " . $table . " SET post_id = %d, " . $postmeta . " = '" . $meta_value . "'",
788
-                        array($post_id)
789
-                    )
790
-                );
791
-            }
792
-
793
-
794
-        } else
795
-            return false;
796
-    }
785
+				$wpdb->query(
786
+					$wpdb->prepare(
787
+						"INSERT INTO " . $table . " SET post_id = %d, " . $postmeta . " = '" . $meta_value . "'",
788
+						array($post_id)
789
+					)
790
+				);
791
+			}
792
+
793
+
794
+		} else
795
+			return false;
796
+	}
797 797
 }
798 798
 
799 799
 if (!function_exists('geodir_delete_post_meta')) {
800
-    /**
801
-     * Delete post custom fields.
802
-     *
803
-     * @since 1.0.0
804
-     * @package GeoDirectory
805
-     * @global object $wpdb WordPress Database object.
806
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
807
-     * @param int $post_id The post ID.
808
-     * @param string $postmeta Detail table column name.
809
-     * @todo check if this is depreciated
810
-     * @todo Fix unknown variable mval
811
-     * @return bool
812
-     */
813
-    function geodir_delete_post_meta($post_id, $postmeta)
814
-    {
815
-
816
-        global $wpdb, $plugin_prefix;
817
-
818
-        $post_type = get_post_type($post_id);
819
-
820
-        $table = $plugin_prefix . $post_type . '_detail';
821
-
822
-        if (is_array($postmeta) && !empty($postmeta) && $post_id) {
823
-            $post_meta_set_query = '';
824
-
825
-            foreach ($postmeta as $mkey) {
826
-                if ($mval != '')
827
-                    $post_meta_set_query .= $mkey . " = '', ";
828
-            }
829
-
830
-            $post_meta_set_query = trim($post_meta_set_query, ", ");
800
+	/**
801
+	 * Delete post custom fields.
802
+	 *
803
+	 * @since 1.0.0
804
+	 * @package GeoDirectory
805
+	 * @global object $wpdb WordPress Database object.
806
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
807
+	 * @param int $post_id The post ID.
808
+	 * @param string $postmeta Detail table column name.
809
+	 * @todo check if this is depreciated
810
+	 * @todo Fix unknown variable mval
811
+	 * @return bool
812
+	 */
813
+	function geodir_delete_post_meta($post_id, $postmeta)
814
+	{
815
+
816
+		global $wpdb, $plugin_prefix;
817
+
818
+		$post_type = get_post_type($post_id);
819
+
820
+		$table = $plugin_prefix . $post_type . '_detail';
821
+
822
+		if (is_array($postmeta) && !empty($postmeta) && $post_id) {
823
+			$post_meta_set_query = '';
824
+
825
+			foreach ($postmeta as $mkey) {
826
+				if ($mval != '')
827
+					$post_meta_set_query .= $mkey . " = '', ";
828
+			}
829
+
830
+			$post_meta_set_query = trim($post_meta_set_query, ", ");
831 831
             
832
-            if (empty($post_meta_set_query) || trim($post_meta_set_query) == '') {
833
-                return false;
834
-            }
835
-
836
-            if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
837
-
838
-                $wpdb->query(
839
-                    $wpdb->prepare(
840
-                        "UPDATE " . $table . " SET " . $post_meta_set_query . " where post_id = %d",
841
-                        array($post_id)
842
-                    )
843
-                );
844
-
845
-                return true;
846
-            }
847
-
848
-        } elseif ($postmeta != '' && $post_id) {
849
-            if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
850
-
851
-                $wpdb->query(
852
-                    $wpdb->prepare(
853
-                        "UPDATE " . $table . " SET " . $postmeta . "= '' where post_id = %d",
854
-                        array($post_id)
855
-                    )
856
-                );
857
-
858
-                return true;
859
-            }
860
-
861
-        } else
862
-            return false;
863
-    }
832
+			if (empty($post_meta_set_query) || trim($post_meta_set_query) == '') {
833
+				return false;
834
+			}
835
+
836
+			if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
837
+
838
+				$wpdb->query(
839
+					$wpdb->prepare(
840
+						"UPDATE " . $table . " SET " . $post_meta_set_query . " where post_id = %d",
841
+						array($post_id)
842
+					)
843
+				);
844
+
845
+				return true;
846
+			}
847
+
848
+		} elseif ($postmeta != '' && $post_id) {
849
+			if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
850
+
851
+				$wpdb->query(
852
+					$wpdb->prepare(
853
+						"UPDATE " . $table . " SET " . $postmeta . "= '' where post_id = %d",
854
+						array($post_id)
855
+					)
856
+				);
857
+
858
+				return true;
859
+			}
860
+
861
+		} else
862
+			return false;
863
+	}
864 864
 }
865 865
 
866 866
 
867 867
 if (!function_exists('geodir_get_post_meta')) {
868
-    /**
869
-     * Get post custom meta.
870
-     *
871
-     * @since 1.0.0
872
-     * @package GeoDirectory
873
-     * @global object $wpdb WordPress Database object.
874
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
875
-     * @param int $post_id The post ID.
876
-     * @param string $meta_key The meta key to retrieve.
877
-     * @param bool $single Optional. Whether to return a single value. Default false.
878
-     * @todo single variable not yet implemented.
879
-     * @return bool|mixed|null|string Will be an array if $single is false. Will be value of meta data field if $single is true.
880
-     */
881
-    function geodir_get_post_meta($post_id, $meta_key, $single = false)
882
-    {
883
-        if (!$post_id) {
884
-            return false;
885
-        }
886
-        global $wpdb, $plugin_prefix;
887
-
888
-        $all_postypes = geodir_get_posttypes();
889
-
890
-        $post_type = get_post_type($post_id);
891
-
892
-        if (!in_array($post_type, $all_postypes))
893
-            return false;
894
-
895
-        $table = $plugin_prefix . $post_type . '_detail';
896
-
897
-        if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $meta_key . "'") != '') {
898
-            $meta_value = $wpdb->get_var($wpdb->prepare("SELECT " . $meta_key . " from " . $table . " where post_id = %d", array($post_id)));
899
-            if ($meta_value && $meta_value !== '') {
900
-                return maybe_serialize($meta_value);
901
-            } else
902
-                return $meta_value;
903
-        } else {
904
-            return false;
905
-        }
906
-    }
868
+	/**
869
+	 * Get post custom meta.
870
+	 *
871
+	 * @since 1.0.0
872
+	 * @package GeoDirectory
873
+	 * @global object $wpdb WordPress Database object.
874
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
875
+	 * @param int $post_id The post ID.
876
+	 * @param string $meta_key The meta key to retrieve.
877
+	 * @param bool $single Optional. Whether to return a single value. Default false.
878
+	 * @todo single variable not yet implemented.
879
+	 * @return bool|mixed|null|string Will be an array if $single is false. Will be value of meta data field if $single is true.
880
+	 */
881
+	function geodir_get_post_meta($post_id, $meta_key, $single = false)
882
+	{
883
+		if (!$post_id) {
884
+			return false;
885
+		}
886
+		global $wpdb, $plugin_prefix;
887
+
888
+		$all_postypes = geodir_get_posttypes();
889
+
890
+		$post_type = get_post_type($post_id);
891
+
892
+		if (!in_array($post_type, $all_postypes))
893
+			return false;
894
+
895
+		$table = $plugin_prefix . $post_type . '_detail';
896
+
897
+		if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $meta_key . "'") != '') {
898
+			$meta_value = $wpdb->get_var($wpdb->prepare("SELECT " . $meta_key . " from " . $table . " where post_id = %d", array($post_id)));
899
+			if ($meta_value && $meta_value !== '') {
900
+				return maybe_serialize($meta_value);
901
+			} else
902
+				return $meta_value;
903
+		} else {
904
+			return false;
905
+		}
906
+	}
907 907
 }
908 908
 
909 909
 
910 910
 if (!function_exists('geodir_save_post_images')) {
911
-    /**
912
-     * Save post attachments.
913
-     *
914
-     * @since 1.0.0
915
-     * @package GeoDirectory
916
-     * @global object $wpdb WordPress Database object.
917
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
918
-     * @global object $current_user Current user object.
919
-     * @param int $post_id The post ID.
920
-     * @param array $post_image Post image urls as an array.
921
-     * @param bool $dummy Optional. Is this a dummy listing? Default false.
922
-     */
923
-    function geodir_save_post_images($post_id = 0, $post_image = array(), $dummy = false)
924
-    {
911
+	/**
912
+	 * Save post attachments.
913
+	 *
914
+	 * @since 1.0.0
915
+	 * @package GeoDirectory
916
+	 * @global object $wpdb WordPress Database object.
917
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
918
+	 * @global object $current_user Current user object.
919
+	 * @param int $post_id The post ID.
920
+	 * @param array $post_image Post image urls as an array.
921
+	 * @param bool $dummy Optional. Is this a dummy listing? Default false.
922
+	 */
923
+	function geodir_save_post_images($post_id = 0, $post_image = array(), $dummy = false)
924
+	{
925 925
 
926 926
 
927
-        global $wpdb, $plugin_prefix, $current_user;
927
+		global $wpdb, $plugin_prefix, $current_user;
928 928
 
929
-        $post_type = get_post_type($post_id);
929
+		$post_type = get_post_type($post_id);
930 930
 
931
-        $table = $plugin_prefix . $post_type . '_detail';
931
+		$table = $plugin_prefix . $post_type . '_detail';
932 932
 
933
-        $post_images = geodir_get_images($post_id);
933
+		$post_images = geodir_get_images($post_id);
934 934
 
935
-        $wpdb->query(
936
-            $wpdb->prepare(
937
-                "UPDATE " . $table . " SET featured_image = '' where post_id =%d",
938
-                array($post_id)
939
-            )
940
-        );
935
+		$wpdb->query(
936
+			$wpdb->prepare(
937
+				"UPDATE " . $table . " SET featured_image = '' where post_id =%d",
938
+				array($post_id)
939
+			)
940
+		);
941 941
 
942
-        $invalid_files = $post_images;
943
-        $valid_file_ids = array();
944
-        $valid_files_condition = '';
945
-        $geodir_uploaddir = '';
942
+		$invalid_files = $post_images;
943
+		$valid_file_ids = array();
944
+		$valid_files_condition = '';
945
+		$geodir_uploaddir = '';
946 946
 
947
-        $remove_files = array();
947
+		$remove_files = array();
948 948
 
949
-        if (!empty($post_image)) {
949
+		if (!empty($post_image)) {
950 950
 
951
-            $uploads = wp_upload_dir();
952
-            $uploads_dir = $uploads['path'];
951
+			$uploads = wp_upload_dir();
952
+			$uploads_dir = $uploads['path'];
953 953
 
954
-            $geodir_uploadpath = $uploads['path'];
955
-            $geodir_uploadurl = $uploads['url'];
956
-            $sub_dir = isset($uploads['subdir']) ? $uploads['subdir'] : '';
954
+			$geodir_uploadpath = $uploads['path'];
955
+			$geodir_uploadurl = $uploads['url'];
956
+			$sub_dir = isset($uploads['subdir']) ? $uploads['subdir'] : '';
957 957
 
958
-            $invalid_files = array();
959
-            $postcurr_images = array();
958
+			$invalid_files = array();
959
+			$postcurr_images = array();
960 960
 
961
-            for ($m = 0; $m < count($post_image); $m++) {
962
-                $menu_order = $m + 1;
961
+			for ($m = 0; $m < count($post_image); $m++) {
962
+				$menu_order = $m + 1;
963 963
 
964
-                $file_path = '';
965
-                /* --------- start ------- */
964
+				$file_path = '';
965
+				/* --------- start ------- */
966 966
 
967
-                $split_img_path = explode(str_replace(array('http://','https://'),'',$uploads['baseurl']), str_replace(array('http://','https://'),'',$post_image[$m]));
967
+				$split_img_path = explode(str_replace(array('http://','https://'),'',$uploads['baseurl']), str_replace(array('http://','https://'),'',$post_image[$m]));
968 968
 
969
-                $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : '';
969
+				$split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : '';
970 970
 
971 971
 
972
-                if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT ID FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE file=%s AND post_id = %d", array($split_img_file_path, $post_id)))) {
972
+				if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT ID FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE file=%s AND post_id = %d", array($split_img_file_path, $post_id)))) {
973 973
 
974
-                    /* --------- end ------- */
975
-                    $curr_img_url = $post_image[$m];
974
+					/* --------- end ------- */
975
+					$curr_img_url = $post_image[$m];
976 976
 
977
-                    $image_name_arr = explode('/', $curr_img_url);
977
+					$image_name_arr = explode('/', $curr_img_url);
978 978
 
979
-                    $count_image_name_arr = count($image_name_arr) - 2;
979
+					$count_image_name_arr = count($image_name_arr) - 2;
980 980
 
981
-                    $count_image_name_arr = ($count_image_name_arr >= 0) ? $count_image_name_arr : 0;
981
+					$count_image_name_arr = ($count_image_name_arr >= 0) ? $count_image_name_arr : 0;
982 982
 
983
-                    $curr_img_dir = $image_name_arr[$count_image_name_arr];
983
+					$curr_img_dir = $image_name_arr[$count_image_name_arr];
984 984
 
985
-                    $filename = end($image_name_arr);
986
-                    if (strpos($filename, '?') !== false) {
987
-                        list($filename) = explode('?', $filename);
988
-                    }
985
+					$filename = end($image_name_arr);
986
+					if (strpos($filename, '?') !== false) {
987
+						list($filename) = explode('?', $filename);
988
+					}
989 989
 
990
-                    $curr_img_dir = str_replace($uploads['baseurl'], "", $curr_img_url);
991
-                    $curr_img_dir = str_replace($filename, "", $curr_img_dir);
990
+					$curr_img_dir = str_replace($uploads['baseurl'], "", $curr_img_url);
991
+					$curr_img_dir = str_replace($filename, "", $curr_img_dir);
992 992
 
993
-                    $img_name_arr = explode('.', $filename);
993
+					$img_name_arr = explode('.', $filename);
994 994
 
995
-                    $file_title = isset($img_name_arr[0]) ? $img_name_arr[0] : $filename;
996
-                    if (!empty($img_name_arr) && count($img_name_arr) > 2) {
997
-                        $new_img_name_arr = $img_name_arr;
998
-                        if (isset($new_img_name_arr[count($img_name_arr) - 1])) {
999
-                            unset($new_img_name_arr[count($img_name_arr) - 1]);
1000
-                            $file_title = implode('.', $new_img_name_arr);
1001
-                        }
1002
-                    }
1003
-                    $file_title = sanitize_file_name($file_title);
1004
-                    $file_name = sanitize_file_name($filename);
995
+					$file_title = isset($img_name_arr[0]) ? $img_name_arr[0] : $filename;
996
+					if (!empty($img_name_arr) && count($img_name_arr) > 2) {
997
+						$new_img_name_arr = $img_name_arr;
998
+						if (isset($new_img_name_arr[count($img_name_arr) - 1])) {
999
+							unset($new_img_name_arr[count($img_name_arr) - 1]);
1000
+							$file_title = implode('.', $new_img_name_arr);
1001
+						}
1002
+					}
1003
+					$file_title = sanitize_file_name($file_title);
1004
+					$file_name = sanitize_file_name($filename);
1005 1005
 
1006
-                    $arr_file_type = wp_check_filetype($filename);
1006
+					$arr_file_type = wp_check_filetype($filename);
1007 1007
 
1008
-                    $uploaded_file_type = $arr_file_type['type'];
1008
+					$uploaded_file_type = $arr_file_type['type'];
1009 1009
 
1010
-                    // Set an array containing a list of acceptable formats
1011
-                    $allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png');
1010
+					// Set an array containing a list of acceptable formats
1011
+					$allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png');
1012 1012
 
1013
-                    // If the uploaded file is the right format
1014
-                    if (in_array($uploaded_file_type, $allowed_file_types)) {
1015
-                        if (!function_exists('wp_handle_upload')) {
1016
-                            require_once(ABSPATH . 'wp-admin/includes/file.php');
1017
-                        }
1013
+					// If the uploaded file is the right format
1014
+					if (in_array($uploaded_file_type, $allowed_file_types)) {
1015
+						if (!function_exists('wp_handle_upload')) {
1016
+							require_once(ABSPATH . 'wp-admin/includes/file.php');
1017
+						}
1018 1018
 
1019
-                        if (!is_dir($geodir_uploadpath)) {
1020
-                            mkdir($geodir_uploadpath);
1021
-                        }
1019
+						if (!is_dir($geodir_uploadpath)) {
1020
+							mkdir($geodir_uploadpath);
1021
+						}
1022 1022
 
1023
-                        $external_img = false;
1024
-                        if (strpos( str_replace( array('http://','https://'),'',$curr_img_url ), str_replace(array('http://','https://'),'',$uploads['baseurl'] ) ) !== false) {
1025
-                        } else {
1026
-                            $external_img = true;
1027
-                        }
1023
+						$external_img = false;
1024
+						if (strpos( str_replace( array('http://','https://'),'',$curr_img_url ), str_replace(array('http://','https://'),'',$uploads['baseurl'] ) ) !== false) {
1025
+						} else {
1026
+							$external_img = true;
1027
+						}
1028 1028
 
1029
-                        if ($dummy || $external_img) {
1030
-                            $uploaded_file = array();
1031
-                            $uploaded = (array)fetch_remote_file($curr_img_url);
1029
+						if ($dummy || $external_img) {
1030
+							$uploaded_file = array();
1031
+							$uploaded = (array)fetch_remote_file($curr_img_url);
1032 1032
 
1033
-                            if (isset($uploaded['error']) && empty($uploaded['error'])) {
1034
-                                $new_name = basename($uploaded['file']);
1035
-                                $uploaded_file = $uploaded;
1036
-                            }else{
1037
-                                print_r($uploaded);exit;
1038
-                            }
1039
-                            $external_img = false;
1040
-                        } else {
1041
-                            $new_name = $post_id . '_' . $file_name;
1033
+							if (isset($uploaded['error']) && empty($uploaded['error'])) {
1034
+								$new_name = basename($uploaded['file']);
1035
+								$uploaded_file = $uploaded;
1036
+							}else{
1037
+								print_r($uploaded);exit;
1038
+							}
1039
+							$external_img = false;
1040
+						} else {
1041
+							$new_name = $post_id . '_' . $file_name;
1042 1042
 
1043
-                            if ($curr_img_dir == $sub_dir) {
1044
-                                $img_path = $geodir_uploadpath . '/' . $filename;
1045
-                                $img_url = $geodir_uploadurl . '/' . $filename;
1046
-                            } else {
1047
-                                $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1048
-                                $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename;
1049
-                            }
1043
+							if ($curr_img_dir == $sub_dir) {
1044
+								$img_path = $geodir_uploadpath . '/' . $filename;
1045
+								$img_url = $geodir_uploadurl . '/' . $filename;
1046
+							} else {
1047
+								$img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1048
+								$img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename;
1049
+							}
1050 1050
 
1051
-                            $uploaded_file = '';
1051
+							$uploaded_file = '';
1052 1052
 
1053
-                            if (file_exists($img_path)) {
1054
-                                $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name);
1055
-                                $file_path = '';
1056
-                            } else if (file_exists($uploads['basedir'] . $curr_img_dir . $filename)) {
1057
-                                $uploaded_file = true;
1058
-                                $file_path = $curr_img_dir . '/' . $filename;
1059
-                            }
1053
+							if (file_exists($img_path)) {
1054
+								$uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name);
1055
+								$file_path = '';
1056
+							} else if (file_exists($uploads['basedir'] . $curr_img_dir . $filename)) {
1057
+								$uploaded_file = true;
1058
+								$file_path = $curr_img_dir . '/' . $filename;
1059
+							}
1060 1060
 
1061
-                            if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path))
1062
-                                unlink($img_path);
1063
-                        }
1061
+							if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path))
1062
+								unlink($img_path);
1063
+						}
1064 1064
 
1065
-                        if (!empty($uploaded_file)) {
1066
-                            if (!isset($file_path) || !$file_path) {
1067
-                                $file_path = $sub_dir . '/' . $new_name;
1068
-                            }
1065
+						if (!empty($uploaded_file)) {
1066
+							if (!isset($file_path) || !$file_path) {
1067
+								$file_path = $sub_dir . '/' . $new_name;
1068
+							}
1069 1069
 
1070
-                            $postcurr_images[] = str_replace(array('http://','https://'),'',$uploads['baseurl'] . $file_path);
1070
+							$postcurr_images[] = str_replace(array('http://','https://'),'',$uploads['baseurl'] . $file_path);
1071 1071
 
1072
-                            if ($menu_order == 1) {
1072
+							if ($menu_order == 1) {
1073 1073
 
1074
-                                $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($file_path, $post_id)));
1074
+								$wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($file_path, $post_id)));
1075 1075
 
1076
-                            }
1076
+							}
1077 1077
 
1078
-                            // Set up options array to add this file as an attachment
1079
-                            $attachment = array();
1080
-                            $attachment['post_id'] = $post_id;
1081
-                            $attachment['title'] = $file_title;
1082
-                            $attachment['content'] = '';
1083
-                            $attachment['file'] = $file_path;
1084
-                            $attachment['mime_type'] = $uploaded_file_type;
1085
-                            $attachment['menu_order'] = $menu_order;
1086
-                            $attachment['is_featured'] = 0;
1078
+							// Set up options array to add this file as an attachment
1079
+							$attachment = array();
1080
+							$attachment['post_id'] = $post_id;
1081
+							$attachment['title'] = $file_title;
1082
+							$attachment['content'] = '';
1083
+							$attachment['file'] = $file_path;
1084
+							$attachment['mime_type'] = $uploaded_file_type;
1085
+							$attachment['menu_order'] = $menu_order;
1086
+							$attachment['is_featured'] = 0;
1087 1087
 
1088
-                            $attachment_set = '';
1088
+							$attachment_set = '';
1089 1089
 
1090
-                            foreach ($attachment as $key => $val) {
1091
-                                if ($val != '')
1092
-                                    $attachment_set .= $key . " = '" . $val . "', ";
1093
-                            }
1090
+							foreach ($attachment as $key => $val) {
1091
+								if ($val != '')
1092
+									$attachment_set .= $key . " = '" . $val . "', ";
1093
+							}
1094 1094
 
1095
-                            $attachment_set = trim($attachment_set, ", ");
1095
+							$attachment_set = trim($attachment_set, ", ");
1096
+
1097
+							$wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
1096 1098
 
1097
-                            $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
1099
+							$valid_file_ids[] = $wpdb->insert_id;
1100
+						}
1098 1101
 
1099
-                            $valid_file_ids[] = $wpdb->insert_id;
1100
-                        }
1102
+					}
1101 1103
 
1102
-                    }
1103 1104
 
1105
+				} else {
1106
+					$valid_file_ids[] = $find_image;
1104 1107
 
1105
-                } else {
1106
-                    $valid_file_ids[] = $find_image;
1107
-
1108
-                    $postcurr_images[] = str_replace(array('http://','https://'),'',$post_image[$m]);
1108
+					$postcurr_images[] = str_replace(array('http://','https://'),'',$post_image[$m]);
1109 1109
 
1110
-                    $wpdb->query(
1111
-                        $wpdb->prepare(
1112
-                            "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d where file =%s AND post_id =%d",
1113
-                            array($menu_order, $split_img_path[1], $post_id)
1114
-                        )
1115
-                    );
1110
+					$wpdb->query(
1111
+						$wpdb->prepare(
1112
+							"UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d where file =%s AND post_id =%d",
1113
+							array($menu_order, $split_img_path[1], $post_id)
1114
+						)
1115
+					);
1116 1116
 
1117
-                    if ($menu_order == 1)
1118
-                        $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
1117
+					if ($menu_order == 1)
1118
+						$wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
1119 1119
 
1120
-                }
1120
+				}
1121 1121
 
1122 1122
 
1123
-            }
1123
+			}
1124 1124
 
1125
-            if (!empty($valid_file_ids)) {
1125
+			if (!empty($valid_file_ids)) {
1126 1126
 
1127
-                $remove_files = $valid_file_ids;
1127
+				$remove_files = $valid_file_ids;
1128 1128
 
1129
-                $remove_files_length = count($remove_files);
1130
-                $remove_files_format = array_fill(0, $remove_files_length, '%d');
1131
-                $format = implode(',', $remove_files_format);
1132
-                $valid_files_condition = " ID NOT IN ($format) AND ";
1129
+				$remove_files_length = count($remove_files);
1130
+				$remove_files_format = array_fill(0, $remove_files_length, '%d');
1131
+				$format = implode(',', $remove_files_format);
1132
+				$valid_files_condition = " ID NOT IN ($format) AND ";
1133 1133
 
1134
-            }
1134
+			}
1135 1135
 
1136
-            //Get and remove all old images of post from database to set by new order
1136
+			//Get and remove all old images of post from database to set by new order
1137 1137
 
1138
-            if (!empty($post_images)) {
1138
+			if (!empty($post_images)) {
1139 1139
 
1140
-                foreach ($post_images as $img) {
1140
+				foreach ($post_images as $img) {
1141 1141
 
1142
-                    if (!in_array(str_replace(array('http://','https://'),'',$img->src), $postcurr_images)) {
1142
+					if (!in_array(str_replace(array('http://','https://'),'',$img->src), $postcurr_images)) {
1143 1143
 
1144
-                        $invalid_files[] = (object)array('src' => $img->src);
1144
+						$invalid_files[] = (object)array('src' => $img->src);
1145 1145
 
1146
-                    }
1146
+					}
1147 1147
 
1148
-                }
1148
+				}
1149 1149
 
1150
-            }
1150
+			}
1151 1151
 
1152
-            $invalid_files = (object)$invalid_files;
1153
-        }
1152
+			$invalid_files = (object)$invalid_files;
1153
+		}
1154 1154
 
1155
-        $remove_files[] = $post_id;
1155
+		$remove_files[] = $post_id;
1156 1156
 
1157
-        $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE " . $valid_files_condition . " post_id = %d", $remove_files));
1157
+		$wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE " . $valid_files_condition . " post_id = %d", $remove_files));
1158 1158
 
1159
-        if (!empty($invalid_files))
1160
-            geodir_remove_attachments($invalid_files);
1161
-    }
1159
+		if (!empty($invalid_files))
1160
+			geodir_remove_attachments($invalid_files);
1161
+	}
1162 1162
 
1163 1163
 }
1164 1164
 
@@ -1172,12 +1172,12 @@  discard block
 block discarded – undo
1172 1172
 function geodir_remove_temp_images()
1173 1173
 {
1174 1174
 
1175
-    global $current_user;
1175
+	global $current_user;
1176 1176
 
1177
-    $uploads = wp_upload_dir();
1178
-    $uploads_dir = $uploads['path'];
1177
+	$uploads = wp_upload_dir();
1178
+	$uploads_dir = $uploads['path'];
1179 1179
 
1180
-    /*	if(is_dir($uploads_dir.'/temp_'.$current_user->data->ID)){
1180
+	/*	if(is_dir($uploads_dir.'/temp_'.$current_user->data->ID)){
1181 1181
 
1182 1182
 			$dirPath = $uploads_dir.'/temp_'.$current_user->data->ID;
1183 1183
 			if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') {
@@ -1194,8 +1194,8 @@  discard block
 block discarded – undo
1194 1194
 			rmdir($dirPath);
1195 1195
 	}	*/
1196 1196
 
1197
-    $dirname = $uploads_dir . '/temp_' . $current_user->ID;
1198
-    geodir_delete_directory($dirname);
1197
+	$dirname = $uploads_dir . '/temp_' . $current_user->ID;
1198
+	geodir_delete_directory($dirname);
1199 1199
 }
1200 1200
 
1201 1201
 
@@ -1209,116 +1209,116 @@  discard block
 block discarded – undo
1209 1209
  */
1210 1210
 function geodir_delete_directory($dirname)
1211 1211
 {
1212
-    $dir_handle = '';
1213
-    if (is_dir($dirname))
1214
-        $dir_handle = opendir($dirname);
1215
-    if (!$dir_handle)
1216
-        return false;
1217
-    while ($file = readdir($dir_handle)) {
1218
-        if ($file != "." && $file != "..") {
1219
-            if (!is_dir($dirname . "/" . $file))
1220
-                unlink($dirname . "/" . $file);
1221
-            else
1222
-                geodir_delete_directory($dirname . '/' . $file);
1223
-        }
1224
-    }
1225
-    closedir($dir_handle);
1226
-    rmdir($dirname);
1227
-    return true;
1212
+	$dir_handle = '';
1213
+	if (is_dir($dirname))
1214
+		$dir_handle = opendir($dirname);
1215
+	if (!$dir_handle)
1216
+		return false;
1217
+	while ($file = readdir($dir_handle)) {
1218
+		if ($file != "." && $file != "..") {
1219
+			if (!is_dir($dirname . "/" . $file))
1220
+				unlink($dirname . "/" . $file);
1221
+			else
1222
+				geodir_delete_directory($dirname . '/' . $file);
1223
+		}
1224
+	}
1225
+	closedir($dir_handle);
1226
+	rmdir($dirname);
1227
+	return true;
1228 1228
 
1229 1229
 }
1230 1230
 
1231 1231
 
1232 1232
 if (!function_exists('geodir_remove_attachments')) {
1233
-    /**
1234
-     * Remove post attachments.
1235
-     *
1236
-     * @since 1.0.0
1237
-     * @package GeoDirectory
1238
-     * @param array $postcurr_images Array of image objects.
1239
-     */
1240
-    function geodir_remove_attachments($postcurr_images = array())
1241
-    {
1242
-        // Unlink all past images of post
1243
-        if (!empty($postcurr_images)) {
1244
-
1245
-            $uploads = wp_upload_dir();
1246
-            $uploads_dir = $uploads['path'];
1247
-
1248
-            foreach ($postcurr_images as $postimg) {
1249
-                $image_name_arr = explode('/', $postimg->src);
1250
-                $filename = end($image_name_arr);
1251
-                if (file_exists($uploads_dir . '/' . $filename))
1252
-                    unlink($uploads_dir . '/' . $filename);
1253
-            }
1254
-
1255
-        } // endif
1256
-        // Unlink all past images of post end
1257
-    }
1233
+	/**
1234
+	 * Remove post attachments.
1235
+	 *
1236
+	 * @since 1.0.0
1237
+	 * @package GeoDirectory
1238
+	 * @param array $postcurr_images Array of image objects.
1239
+	 */
1240
+	function geodir_remove_attachments($postcurr_images = array())
1241
+	{
1242
+		// Unlink all past images of post
1243
+		if (!empty($postcurr_images)) {
1244
+
1245
+			$uploads = wp_upload_dir();
1246
+			$uploads_dir = $uploads['path'];
1247
+
1248
+			foreach ($postcurr_images as $postimg) {
1249
+				$image_name_arr = explode('/', $postimg->src);
1250
+				$filename = end($image_name_arr);
1251
+				if (file_exists($uploads_dir . '/' . $filename))
1252
+					unlink($uploads_dir . '/' . $filename);
1253
+			}
1254
+
1255
+		} // endif
1256
+		// Unlink all past images of post end
1257
+	}
1258 1258
 }
1259 1259
 
1260 1260
 if (!function_exists('geodir_get_featured_image')) {
1261
-    /**
1262
-     * Gets the post featured image.
1263
-     *
1264
-     * @since 1.0.0
1265
-     * @package GeoDirectory
1266
-     * @global object $wpdb WordPress Database object.
1267
-     * @global object $post The current post object.
1268
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
1269
-     * @param int|string $post_id The post ID.
1270
-     * @param string $size Optional. Thumbnail size. Default: thumbnail.
1271
-     * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1272
-     * @param bool|string $file Optional. The file path from which you want to get the image details. Default: false.
1273
-     * @return bool|object Image details as an object.
1274
-     */
1275
-    function geodir_get_featured_image($post_id = '', $size = '', $no_image = false, $file = false)
1276
-    {
1277
-
1278
-        /*$img_arr['src'] = get_the_post_thumbnail_url( $post_id,  'medium');//medium/thumbnail
1261
+	/**
1262
+	 * Gets the post featured image.
1263
+	 *
1264
+	 * @since 1.0.0
1265
+	 * @package GeoDirectory
1266
+	 * @global object $wpdb WordPress Database object.
1267
+	 * @global object $post The current post object.
1268
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
1269
+	 * @param int|string $post_id The post ID.
1270
+	 * @param string $size Optional. Thumbnail size. Default: thumbnail.
1271
+	 * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1272
+	 * @param bool|string $file Optional. The file path from which you want to get the image details. Default: false.
1273
+	 * @return bool|object Image details as an object.
1274
+	 */
1275
+	function geodir_get_featured_image($post_id = '', $size = '', $no_image = false, $file = false)
1276
+	{
1277
+
1278
+		/*$img_arr['src'] = get_the_post_thumbnail_url( $post_id,  'medium');//medium/thumbnail
1279 1279
         $img_arr['path'] = '';
1280 1280
         $img_arr['width'] = '';
1281 1281
         $img_arr['height'] = '';
1282 1282
         $img_arr['title'] = '';
1283 1283
         return (object)$img_arr;*/
1284
-        global $wpdb, $plugin_prefix, $post;
1284
+		global $wpdb, $plugin_prefix, $post;
1285 1285
 
1286
-        if (isset($post->ID) && isset($post->post_type) && $post->ID == $post_id) {
1287
-            $post_type = $post->post_type;
1288
-        } else {
1289
-            $post_type = get_post_type($post_id);
1290
-        }
1286
+		if (isset($post->ID) && isset($post->post_type) && $post->ID == $post_id) {
1287
+			$post_type = $post->post_type;
1288
+		} else {
1289
+			$post_type = get_post_type($post_id);
1290
+		}
1291 1291
 
1292
-        if (!in_array($post_type, geodir_get_posttypes())) {
1293
-            return false;// if not a GD CPT return;
1294
-        }
1292
+		if (!in_array($post_type, geodir_get_posttypes())) {
1293
+			return false;// if not a GD CPT return;
1294
+		}
1295 1295
 
1296
-        $table = $plugin_prefix . $post_type . '_detail';
1296
+		$table = $plugin_prefix . $post_type . '_detail';
1297 1297
 
1298
-        if (!$file) {
1299
-            if (isset($post->featured_image)) {
1300
-                $file = $post->featured_image;
1301
-            } else {
1302
-                $file = $wpdb->get_var($wpdb->prepare("SELECT featured_image FROM " . $table . " WHERE post_id = %d", array($post_id)));
1303
-            }
1304
-        }
1298
+		if (!$file) {
1299
+			if (isset($post->featured_image)) {
1300
+				$file = $post->featured_image;
1301
+			} else {
1302
+				$file = $wpdb->get_var($wpdb->prepare("SELECT featured_image FROM " . $table . " WHERE post_id = %d", array($post_id)));
1303
+			}
1304
+		}
1305 1305
 
1306
-        if ($file != NULL && $file != '' && (($uploads = wp_upload_dir()) && false === $uploads['error'])) {
1307
-            $img_arr = array();
1306
+		if ($file != NULL && $file != '' && (($uploads = wp_upload_dir()) && false === $uploads['error'])) {
1307
+			$img_arr = array();
1308 1308
 
1309
-            $file_info = pathinfo($file);
1310
-            $sub_dir = '';
1311
-            if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
1312
-                $sub_dir = stripslashes_deep($file_info['dirname']);
1309
+			$file_info = pathinfo($file);
1310
+			$sub_dir = '';
1311
+			if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
1312
+				$sub_dir = stripslashes_deep($file_info['dirname']);
1313 1313
 
1314
-            $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1315
-            $uploads_baseurl = $uploads['baseurl'];
1316
-            $uploads_path = $uploads['path'];
1314
+			$uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1315
+			$uploads_baseurl = $uploads['baseurl'];
1316
+			$uploads_path = $uploads['path'];
1317 1317
 
1318
-            $file_name = $file_info['basename'];
1318
+			$file_name = $file_info['basename'];
1319 1319
 
1320
-            $uploads_url = $uploads_baseurl . $sub_dir;
1321
-            /*
1320
+			$uploads_url = $uploads_baseurl . $sub_dir;
1321
+			/*
1322 1322
              * Allows the filter of image src for such things as CDN change.
1323 1323
              *
1324 1324
              * @since 1.5.7
@@ -1327,158 +1327,158 @@  discard block
 block discarded – undo
1327 1327
              * @param string $uploads_url The server upload directory url.
1328 1328
              * @param string $uploads_baseurl The uploads dir base url.
1329 1329
              */
1330
-            $img_arr['src'] = apply_filters('geodir_get_featured_image_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1331
-            $img_arr['path'] = $uploads_path . '/' . $file_name;
1332
-            $width = 0;
1333
-            $height = 0;
1334
-            if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1335
-                $imagesize = getimagesize($img_arr['path']);
1336
-                $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1337
-                $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1338
-            }
1339
-            $img_arr['width'] = $width;
1340
-            $img_arr['height'] = $height;
1341
-            $img_arr['title'] = '';
1342
-        } elseif ($post_images = geodir_get_images($post_id, $size, $no_image, 1)) {
1343
-            foreach ($post_images as $image) {
1344
-                return $image;
1345
-            }
1346
-        } else if ($no_image) {
1347
-            $img_arr = array();
1348
-
1349
-            $default_img = '';
1350
-            if (isset($post->default_category) && $post->default_category) {
1351
-                $default_cat = $post->default_category;
1352
-            } else {
1353
-                $default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1354
-            }
1355
-
1356
-            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1357
-                $default_img = $default_catimg['src'];
1358
-            elseif ($no_image) {
1359
-                $default_img = get_option('geodir_listing_no_img');
1360
-            }
1361
-
1362
-            if (!empty($default_img)) {
1363
-                $uploads = wp_upload_dir(); // Array of key => value pairs
1364
-                $uploads_baseurl = $uploads['baseurl'];
1365
-                $uploads_path = $uploads['path'];
1366
-
1367
-                $img_arr = array();
1368
-
1369
-                $file_info = pathinfo($default_img);
1370
-
1371
-                $file_name = $file_info['basename'];
1372
-
1373
-                $img_arr['src'] = $default_img;
1374
-                $img_arr['path'] = $uploads_path . '/' . $file_name;
1375
-
1376
-                $width = 0;
1377
-                $height = 0;
1378
-                if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1379
-                    $imagesize = getimagesize($img_arr['path']);
1380
-                    $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1381
-                    $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1382
-                }
1383
-                $img_arr['width'] = $width;
1384
-                $img_arr['height'] = $height;
1385
-
1386
-                $img_arr['title'] = ''; // add the title to the array
1387
-            }
1388
-        }
1389
-
1390
-        if (!empty($img_arr))
1391
-            return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path );
1392
-        else
1393
-            return false;
1394
-    }
1330
+			$img_arr['src'] = apply_filters('geodir_get_featured_image_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1331
+			$img_arr['path'] = $uploads_path . '/' . $file_name;
1332
+			$width = 0;
1333
+			$height = 0;
1334
+			if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1335
+				$imagesize = getimagesize($img_arr['path']);
1336
+				$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1337
+				$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1338
+			}
1339
+			$img_arr['width'] = $width;
1340
+			$img_arr['height'] = $height;
1341
+			$img_arr['title'] = '';
1342
+		} elseif ($post_images = geodir_get_images($post_id, $size, $no_image, 1)) {
1343
+			foreach ($post_images as $image) {
1344
+				return $image;
1345
+			}
1346
+		} else if ($no_image) {
1347
+			$img_arr = array();
1348
+
1349
+			$default_img = '';
1350
+			if (isset($post->default_category) && $post->default_category) {
1351
+				$default_cat = $post->default_category;
1352
+			} else {
1353
+				$default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1354
+			}
1355
+
1356
+			if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1357
+				$default_img = $default_catimg['src'];
1358
+			elseif ($no_image) {
1359
+				$default_img = get_option('geodir_listing_no_img');
1360
+			}
1361
+
1362
+			if (!empty($default_img)) {
1363
+				$uploads = wp_upload_dir(); // Array of key => value pairs
1364
+				$uploads_baseurl = $uploads['baseurl'];
1365
+				$uploads_path = $uploads['path'];
1366
+
1367
+				$img_arr = array();
1368
+
1369
+				$file_info = pathinfo($default_img);
1370
+
1371
+				$file_name = $file_info['basename'];
1372
+
1373
+				$img_arr['src'] = $default_img;
1374
+				$img_arr['path'] = $uploads_path . '/' . $file_name;
1375
+
1376
+				$width = 0;
1377
+				$height = 0;
1378
+				if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1379
+					$imagesize = getimagesize($img_arr['path']);
1380
+					$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1381
+					$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1382
+				}
1383
+				$img_arr['width'] = $width;
1384
+				$img_arr['height'] = $height;
1385
+
1386
+				$img_arr['title'] = ''; // add the title to the array
1387
+			}
1388
+		}
1389
+
1390
+		if (!empty($img_arr))
1391
+			return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path );
1392
+		else
1393
+			return false;
1394
+	}
1395 1395
 }
1396 1396
 
1397 1397
 if (!function_exists('geodir_show_featured_image')) {
1398
-    /**
1399
-     * Gets the post featured image.
1400
-     *
1401
-     * @since 1.0.0
1402
-     * @package GeoDirectory
1403
-     * @param int|string $post_id The post ID.
1404
-     * @param string $size Optional. Thumbnail size. Default: thumbnail.
1405
-     * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1406
-     * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true.
1407
-     * @param bool|string $fimage Optional. The file path from which you want to get the image details. Default: false.
1408
-     * @return bool|string Returns image html.
1409
-     */
1410
-    function geodir_show_featured_image($post_id = '', $size = 'thumbnail', $no_image = false, $echo = true, $fimage = false)
1411
-    {
1412
-        $image = geodir_get_featured_image($post_id, $size, $no_image, $fimage);
1413
-
1414
-        $html = geodir_show_image($image, $size, $no_image, false);
1415
-
1416
-        if (!empty($html) && $echo) {
1417
-            echo $html;
1418
-        } elseif (!empty($html)) {
1419
-            return $html;
1420
-        } else
1421
-            return false;
1422
-    }
1398
+	/**
1399
+	 * Gets the post featured image.
1400
+	 *
1401
+	 * @since 1.0.0
1402
+	 * @package GeoDirectory
1403
+	 * @param int|string $post_id The post ID.
1404
+	 * @param string $size Optional. Thumbnail size. Default: thumbnail.
1405
+	 * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1406
+	 * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true.
1407
+	 * @param bool|string $fimage Optional. The file path from which you want to get the image details. Default: false.
1408
+	 * @return bool|string Returns image html.
1409
+	 */
1410
+	function geodir_show_featured_image($post_id = '', $size = 'thumbnail', $no_image = false, $echo = true, $fimage = false)
1411
+	{
1412
+		$image = geodir_get_featured_image($post_id, $size, $no_image, $fimage);
1413
+
1414
+		$html = geodir_show_image($image, $size, $no_image, false);
1415
+
1416
+		if (!empty($html) && $echo) {
1417
+			echo $html;
1418
+		} elseif (!empty($html)) {
1419
+			return $html;
1420
+		} else
1421
+			return false;
1422
+	}
1423 1423
 }
1424 1424
 
1425 1425
 if (!function_exists('geodir_get_images')) {
1426
-    /**
1427
-     * Gets the post images.
1428
-     *
1429
-     * @since 1.0.0
1430
-     * @package GeoDirectory
1431
-     * @global object $wpdb WordPress Database object.
1432
-     * @param int $post_id The post ID.
1433
-     * @param string $img_size Optional. Thumbnail size.
1434
-     * @param bool $no_images Optional. Do you want to return the default image when no image is available? Default: false.
1435
-     * @param bool $add_featured Optional. Do you want to include featured images too? Default: true.
1436
-     * @param int|string $limit Optional. Number of images.
1437
-     * @return array|bool Returns images as an array. Each item is an object.
1438
-     */
1439
-    function geodir_get_images($post_id = 0, $img_size = '', $no_images = false, $add_featured = true, $limit = '')
1440
-    {
1441
-        global $wpdb;
1442
-        if ($limit) {
1443
-            $limit_q = " LIMIT $limit ";
1444
-        } else {
1445
-            $limit_q = '';
1446
-        }
1447
-        $not_featured = '';
1448
-        $sub_dir = '';
1449
-        if (!$add_featured)
1450
-            $not_featured = " AND is_featured = 0 ";
1451
-
1452
-        $arrImages = $wpdb->get_results(
1453
-            $wpdb->prepare(
1454
-                "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d" . $not_featured . " ORDER BY menu_order ASC, ID DESC $limit_q ",
1455
-                array('%image%', $post_id)
1456
-            )
1457
-        );
1458
-
1459
-        $counter = 0;
1460
-        $return_arr = array();
1461
-
1462
-        if (!empty($arrImages)) {
1463
-            foreach ($arrImages as $attechment) {
1464
-
1465
-                $img_arr = array();
1466
-                $img_arr['id'] = $attechment->ID;
1467
-                $img_arr['user_id'] = isset($attechment->user_id) ? $attechment->user_id : 0;
1468
-
1469
-                $file_info = pathinfo($attechment->file);
1470
-
1471
-                if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
1472
-                    $sub_dir = stripslashes_deep($file_info['dirname']);
1473
-
1474
-                $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1475
-                $uploads_baseurl = $uploads['baseurl'];
1476
-                $uploads_path = $uploads['path'];
1477
-
1478
-                $file_name = $file_info['basename'];
1479
-
1480
-                $uploads_url = $uploads_baseurl . $sub_dir;
1481
-                /*
1426
+	/**
1427
+	 * Gets the post images.
1428
+	 *
1429
+	 * @since 1.0.0
1430
+	 * @package GeoDirectory
1431
+	 * @global object $wpdb WordPress Database object.
1432
+	 * @param int $post_id The post ID.
1433
+	 * @param string $img_size Optional. Thumbnail size.
1434
+	 * @param bool $no_images Optional. Do you want to return the default image when no image is available? Default: false.
1435
+	 * @param bool $add_featured Optional. Do you want to include featured images too? Default: true.
1436
+	 * @param int|string $limit Optional. Number of images.
1437
+	 * @return array|bool Returns images as an array. Each item is an object.
1438
+	 */
1439
+	function geodir_get_images($post_id = 0, $img_size = '', $no_images = false, $add_featured = true, $limit = '')
1440
+	{
1441
+		global $wpdb;
1442
+		if ($limit) {
1443
+			$limit_q = " LIMIT $limit ";
1444
+		} else {
1445
+			$limit_q = '';
1446
+		}
1447
+		$not_featured = '';
1448
+		$sub_dir = '';
1449
+		if (!$add_featured)
1450
+			$not_featured = " AND is_featured = 0 ";
1451
+
1452
+		$arrImages = $wpdb->get_results(
1453
+			$wpdb->prepare(
1454
+				"SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d" . $not_featured . " ORDER BY menu_order ASC, ID DESC $limit_q ",
1455
+				array('%image%', $post_id)
1456
+			)
1457
+		);
1458
+
1459
+		$counter = 0;
1460
+		$return_arr = array();
1461
+
1462
+		if (!empty($arrImages)) {
1463
+			foreach ($arrImages as $attechment) {
1464
+
1465
+				$img_arr = array();
1466
+				$img_arr['id'] = $attechment->ID;
1467
+				$img_arr['user_id'] = isset($attechment->user_id) ? $attechment->user_id : 0;
1468
+
1469
+				$file_info = pathinfo($attechment->file);
1470
+
1471
+				if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
1472
+					$sub_dir = stripslashes_deep($file_info['dirname']);
1473
+
1474
+				$uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1475
+				$uploads_baseurl = $uploads['baseurl'];
1476
+				$uploads_path = $uploads['path'];
1477
+
1478
+				$file_name = $file_info['basename'];
1479
+
1480
+				$uploads_url = $uploads_baseurl . $sub_dir;
1481
+				/*
1482 1482
                 * Allows the filter of image src for such things as CDN change.
1483 1483
                 *
1484 1484
                 * @since 1.5.7
@@ -1487,514 +1487,514 @@  discard block
 block discarded – undo
1487 1487
                 * @param string $uploads_url The server upload directory url.
1488 1488
                 * @param string $uploads_baseurl The uploads dir base url.
1489 1489
                 */
1490
-                $img_arr['src'] = apply_filters('geodir_get_images_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1491
-                $img_arr['path'] = $uploads_path . '/' . $file_name;
1492
-                $width = 0;
1493
-                $height = 0;
1494
-                if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1495
-                    $imagesize = getimagesize($img_arr['path']);
1496
-                    $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1497
-                    $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1498
-                }
1499
-                $img_arr['width'] = $width;
1500
-                $img_arr['height'] = $height;
1501
-
1502
-                $img_arr['file'] = $file_name; // add the title to the array
1503
-                $img_arr['title'] = $attechment->title; // add the title to the array
1504
-                $img_arr['caption'] = isset($attechment->caption) ? $attechment->caption : ''; // add the caption to the array
1505
-                $img_arr['content'] = $attechment->content; // add the description to the array
1506
-                $img_arr['is_approved'] = isset($attechment->is_approved) ? $attechment->is_approved : ''; // used for user image moderation. For backward compatibility Default value is 1.
1507
-
1508
-                $return_arr[] = (object)$img_arr;
1509
-
1510
-                $counter++;
1511
-            }
1512
-            return (object)$return_arr;
1513
-        } else if ($no_images) {
1514
-            $default_img = '';
1515
-            $default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1516
-            $post_type = get_post_type($post_id);
1517
-            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1518
-                $default_img = $default_catimg['src'];
1519
-            elseif ($no_images) {
1520
-                $default_img = get_option('geodir_listing_no_img');
1521
-            }
1522
-
1523
-            if (!empty($default_img)) {
1524
-                $uploads = wp_upload_dir(); // Array of key => value pairs
1490
+				$img_arr['src'] = apply_filters('geodir_get_images_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1491
+				$img_arr['path'] = $uploads_path . '/' . $file_name;
1492
+				$width = 0;
1493
+				$height = 0;
1494
+				if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
1495
+					$imagesize = getimagesize($img_arr['path']);
1496
+					$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1497
+					$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1498
+				}
1499
+				$img_arr['width'] = $width;
1500
+				$img_arr['height'] = $height;
1501
+
1502
+				$img_arr['file'] = $file_name; // add the title to the array
1503
+				$img_arr['title'] = $attechment->title; // add the title to the array
1504
+				$img_arr['caption'] = isset($attechment->caption) ? $attechment->caption : ''; // add the caption to the array
1505
+				$img_arr['content'] = $attechment->content; // add the description to the array
1506
+				$img_arr['is_approved'] = isset($attechment->is_approved) ? $attechment->is_approved : ''; // used for user image moderation. For backward compatibility Default value is 1.
1507
+
1508
+				$return_arr[] = (object)$img_arr;
1509
+
1510
+				$counter++;
1511
+			}
1512
+			return (object)$return_arr;
1513
+		} else if ($no_images) {
1514
+			$default_img = '';
1515
+			$default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1516
+			$post_type = get_post_type($post_id);
1517
+			if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1518
+				$default_img = $default_catimg['src'];
1519
+			elseif ($no_images) {
1520
+				$default_img = get_option('geodir_listing_no_img');
1521
+			}
1522
+
1523
+			if (!empty($default_img)) {
1524
+				$uploads = wp_upload_dir(); // Array of key => value pairs
1525 1525
                 
1526
-                $image_path = $default_img;
1527
-                if (!path_is_absolute($image_path)) {
1528
-                    $image_path = str_replace($uploads['baseurl'], $uploads['basedir'], $image_path);
1529
-                }
1530
-
1531
-                $file_info = pathinfo($default_img);
1532
-                $file_name = $file_info['basename'];
1533
-
1534
-                $width = '';
1535
-                $height = '';
1536
-                if (is_file($image_path) && file_exists($image_path)) {
1537
-                    $imagesize = getimagesize($image_path);
1538
-                    $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1539
-                    $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1540
-                }
1526
+				$image_path = $default_img;
1527
+				if (!path_is_absolute($image_path)) {
1528
+					$image_path = str_replace($uploads['baseurl'], $uploads['basedir'], $image_path);
1529
+				}
1530
+
1531
+				$file_info = pathinfo($default_img);
1532
+				$file_name = $file_info['basename'];
1533
+
1534
+				$width = '';
1535
+				$height = '';
1536
+				if (is_file($image_path) && file_exists($image_path)) {
1537
+					$imagesize = getimagesize($image_path);
1538
+					$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1539
+					$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1540
+				}
1541 1541
                 
1542
-                $img_arr = array();
1543
-                $img_arr['src'] = $default_img;
1544
-                $img_arr['path'] = $image_path;
1545
-                $img_arr['width'] = $width;
1546
-                $img_arr['height'] = $height;
1547
-                $img_arr['file'] = $file_name; // add the title to the array
1548
-                $img_arr['title'] = $file_info['filename']; // add the title to the array
1549
-                $img_arr['content'] = $file_info['filename']; // add the description to the array
1550
-
1551
-                $return_arr[] = (object)$img_arr;
1552
-
1553
-                return $return_arr;
1554
-            } else
1555
-                return false;
1556
-        }
1557
-    }
1542
+				$img_arr = array();
1543
+				$img_arr['src'] = $default_img;
1544
+				$img_arr['path'] = $image_path;
1545
+				$img_arr['width'] = $width;
1546
+				$img_arr['height'] = $height;
1547
+				$img_arr['file'] = $file_name; // add the title to the array
1548
+				$img_arr['title'] = $file_info['filename']; // add the title to the array
1549
+				$img_arr['content'] = $file_info['filename']; // add the description to the array
1550
+
1551
+				$return_arr[] = (object)$img_arr;
1552
+
1553
+				return $return_arr;
1554
+			} else
1555
+				return false;
1556
+		}
1557
+	}
1558 1558
 }
1559 1559
 
1560 1560
 if (!function_exists('geodir_show_image')) {
1561
-    /**
1562
-     * Show image using image details.
1563
-     *
1564
-     * @since 1.0.0
1565
-     * @package GeoDirectory
1566
-     * @param array|object $request Image info either as an array or object.
1567
-     * @param string $size Optional. Thumbnail size. Default: thumbnail.
1568
-     * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1569
-     * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true.
1570
-     * @return bool|string Returns image html.
1571
-     */
1572
-    function geodir_show_image($request = array(), $size = 'thumbnail', $no_image = false, $echo = true)
1573
-    {
1574
-        $image = new stdClass();
1575
-
1576
-        $html = '';
1577
-        if (!empty($request)) {
1578
-            if (!is_object($request)){
1579
-                $request = (object)$request;
1580
-            }
1581
-
1582
-            if (isset($request->src) && !isset($request->path)) {
1583
-                $request->path = $request->src;
1584
-            }
1585
-
1586
-            /*
1561
+	/**
1562
+	 * Show image using image details.
1563
+	 *
1564
+	 * @since 1.0.0
1565
+	 * @package GeoDirectory
1566
+	 * @param array|object $request Image info either as an array or object.
1567
+	 * @param string $size Optional. Thumbnail size. Default: thumbnail.
1568
+	 * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false.
1569
+	 * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true.
1570
+	 * @return bool|string Returns image html.
1571
+	 */
1572
+	function geodir_show_image($request = array(), $size = 'thumbnail', $no_image = false, $echo = true)
1573
+	{
1574
+		$image = new stdClass();
1575
+
1576
+		$html = '';
1577
+		if (!empty($request)) {
1578
+			if (!is_object($request)){
1579
+				$request = (object)$request;
1580
+			}
1581
+
1582
+			if (isset($request->src) && !isset($request->path)) {
1583
+				$request->path = $request->src;
1584
+			}
1585
+
1586
+			/*
1587 1587
              * getimagesize() works faster from path than url so we try and get path if we can.
1588 1588
              */
1589
-            $upload_dir = wp_upload_dir();
1590
-            $img_no_http = str_replace(array("http://", "https://"), "", $request->path);
1591
-            $upload_no_http = str_replace(array("http://", "https://"), "", $upload_dir['baseurl']);
1592
-            if (strpos($img_no_http, $upload_no_http) !== false) {
1593
-                $request->path = str_replace( $img_no_http,$upload_dir['basedir'], $request->path);
1594
-            }
1589
+			$upload_dir = wp_upload_dir();
1590
+			$img_no_http = str_replace(array("http://", "https://"), "", $request->path);
1591
+			$upload_no_http = str_replace(array("http://", "https://"), "", $upload_dir['baseurl']);
1592
+			if (strpos($img_no_http, $upload_no_http) !== false) {
1593
+				$request->path = str_replace( $img_no_http,$upload_dir['basedir'], $request->path);
1594
+			}
1595 1595
             
1596
-            $width = 0;
1597
-            $height = 0;
1598
-            if (is_file($request->path) && file_exists($request->path)) {
1599
-                $imagesize = getimagesize($request->path);
1600
-                $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1601
-                $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1602
-            }
1603
-
1604
-            $image->src = $request->src;
1605
-            $image->width = $width;
1606
-            $image->height = $height;
1607
-
1608
-            $max_size = (object)geodir_get_imagesize($size);
1609
-
1610
-            if (!is_wp_error($max_size)) {
1611
-                if ($image->width) {
1612
-                    if ($image->height >= $image->width) {
1613
-                        $width_per = round(((($image->width * ($max_size->h / $image->height)) / $max_size->w) * 100), 2);
1614
-                    } else if ($image->width < ($max_size->h)) {
1615
-                        $width_per = round((($image->width / $max_size->w) * 100), 2);
1616
-                    } else
1617
-                        $width_per = 100;
1618
-                }
1619
-
1620
-                if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
1621
-                    $html = '<div class="geodir_thumbnail"><img style="max-height:' . $max_size->h . 'px;" alt="place image" src="' . $image->src . '"  /></div>';
1622
-                } else {
1623
-                    if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){
1624
-                        $html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1625
-                    }else{
1626
-                        //$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1627
-                        //$html = '<div data-src="'.$image->src.'" class="geodir_thumbnail" ></div>';
1628
-                        $html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>';
1629
-
1630
-                    }
1631
-
1632
-                }
1633
-            }
1634
-        }
1635
-
1636
-        if (!empty($html) && $echo) {
1637
-            echo $html;
1638
-        } elseif (!empty($html)) {
1639
-            return $html;
1640
-        } else
1641
-            return false;
1642
-    }
1643
-}
1596
+			$width = 0;
1597
+			$height = 0;
1598
+			if (is_file($request->path) && file_exists($request->path)) {
1599
+				$imagesize = getimagesize($request->path);
1600
+				$width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : '';
1601
+				$height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : '';
1602
+			}
1644 1603
 
1645
-if (!function_exists('geodir_set_post_terms')) {
1646
-    /**
1647
-     * Set post Categories.
1648
-     *
1649
-     * @since 1.0.0
1650
-     * @package GeoDirectory
1651
-     * @global object $wpdb WordPress Database object.
1652
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
1653
-     * @param int $post_id The post ID.
1654
-     * @param array $terms An array of term objects.
1655
-     * @param array $tt_ids An array of term taxonomy IDs.
1656
-     * @param string $taxonomy Taxonomy slug.
1657
-     */
1658
-    function geodir_set_post_terms($post_id, $terms, $tt_ids, $taxonomy)
1659
-    {
1660
-        global $wpdb, $plugin_prefix;
1604
+			$image->src = $request->src;
1605
+			$image->width = $width;
1606
+			$image->height = $height;
1607
+
1608
+			$max_size = (object)geodir_get_imagesize($size);
1661 1609
 
1662
-        $post_type = get_post_type($post_id);
1610
+			if (!is_wp_error($max_size)) {
1611
+				if ($image->width) {
1612
+					if ($image->height >= $image->width) {
1613
+						$width_per = round(((($image->width * ($max_size->h / $image->height)) / $max_size->w) * 100), 2);
1614
+					} else if ($image->width < ($max_size->h)) {
1615
+						$width_per = round((($image->width / $max_size->w) * 100), 2);
1616
+					} else
1617
+						$width_per = 100;
1618
+				}
1619
+
1620
+				if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
1621
+					$html = '<div class="geodir_thumbnail"><img style="max-height:' . $max_size->h . 'px;" alt="place image" src="' . $image->src . '"  /></div>';
1622
+				} else {
1623
+					if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){
1624
+						$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1625
+					}else{
1626
+						//$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1627
+						//$html = '<div data-src="'.$image->src.'" class="geodir_thumbnail" ></div>';
1628
+						$html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>';
1663 1629
 
1664
-        $table = $plugin_prefix . $post_type . '_detail';
1630
+					}
1665 1631
 
1666
-        if (in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_id)) {
1632
+				}
1633
+			}
1634
+		}
1635
+
1636
+		if (!empty($html) && $echo) {
1637
+			echo $html;
1638
+		} elseif (!empty($html)) {
1639
+			return $html;
1640
+		} else
1641
+			return false;
1642
+	}
1643
+}
1667 1644
 
1668
-            if ($taxonomy == $post_type . '_tags') {
1669
-                if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
1670
-                    geodir_save_post_meta($post_id, 'post_tags', $terms);
1671
-                }
1672
-            } elseif ($taxonomy == $post_type . 'category') {
1673
-                $srcharr = array('"', '\\');
1674
-                $replarr = array("&quot;", '');
1645
+if (!function_exists('geodir_set_post_terms')) {
1646
+	/**
1647
+	 * Set post Categories.
1648
+	 *
1649
+	 * @since 1.0.0
1650
+	 * @package GeoDirectory
1651
+	 * @global object $wpdb WordPress Database object.
1652
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
1653
+	 * @param int $post_id The post ID.
1654
+	 * @param array $terms An array of term objects.
1655
+	 * @param array $tt_ids An array of term taxonomy IDs.
1656
+	 * @param string $taxonomy Taxonomy slug.
1657
+	 */
1658
+	function geodir_set_post_terms($post_id, $terms, $tt_ids, $taxonomy)
1659
+	{
1660
+		global $wpdb, $plugin_prefix;
1661
+
1662
+		$post_type = get_post_type($post_id);
1663
+
1664
+		$table = $plugin_prefix . $post_type . '_detail';
1665
+
1666
+		if (in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_id)) {
1667
+
1668
+			if ($taxonomy == $post_type . '_tags') {
1669
+				if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
1670
+					geodir_save_post_meta($post_id, 'post_tags', $terms);
1671
+				}
1672
+			} elseif ($taxonomy == $post_type . 'category') {
1673
+				$srcharr = array('"', '\\');
1674
+				$replarr = array("&quot;", '');
1675 1675
 
1676
-                $post_obj = get_post($post_id);
1676
+				$post_obj = get_post($post_id);
1677 1677
 
1678
-                $cat_ids = array('0');
1679
-                if (is_array($tt_ids))
1680
-                    $cat_ids = $tt_ids;
1678
+				$cat_ids = array('0');
1679
+				if (is_array($tt_ids))
1680
+					$cat_ids = $tt_ids;
1681 1681
 
1682 1682
 
1683
-                if (!empty($cat_ids)) {
1684
-                    $cat_ids_array = $cat_ids;
1685
-                    $cat_ids_length = count($cat_ids_array);
1686
-                    $cat_ids_format = array_fill(0, $cat_ids_length, '%d');
1687
-                    $format = implode(',', $cat_ids_format);
1683
+				if (!empty($cat_ids)) {
1684
+					$cat_ids_array = $cat_ids;
1685
+					$cat_ids_length = count($cat_ids_array);
1686
+					$cat_ids_format = array_fill(0, $cat_ids_length, '%d');
1687
+					$format = implode(',', $cat_ids_format);
1688 1688
 
1689
-                    $cat_ids_array_del = $cat_ids_array;
1690
-                    $cat_ids_array_del[] = $post_id;
1689
+					$cat_ids_array_del = $cat_ids_array;
1690
+					$cat_ids_array_del[] = $post_id;
1691 1691
 
1692
-                    $wpdb->get_var(
1693
-                        $wpdb->prepare(
1694
-                            "DELETE from " . GEODIR_ICON_TABLE . " WHERE cat_id NOT IN ($format) AND post_id = %d ",
1695
-                            $cat_ids_array_del
1696
-                        )
1697
-                    );
1692
+					$wpdb->get_var(
1693
+						$wpdb->prepare(
1694
+							"DELETE from " . GEODIR_ICON_TABLE . " WHERE cat_id NOT IN ($format) AND post_id = %d ",
1695
+							$cat_ids_array_del
1696
+						)
1697
+					);
1698 1698
 
1699 1699
 
1700
-                    $post_term = $wpdb->get_col(
1701
-                        $wpdb->prepare(
1702
-                            "SELECT term_id FROM " . $wpdb->term_taxonomy . " WHERE term_taxonomy_id IN($format) GROUP BY term_id",
1703
-                            $cat_ids_array
1704
-                        )
1705
-                    );
1700
+					$post_term = $wpdb->get_col(
1701
+						$wpdb->prepare(
1702
+							"SELECT term_id FROM " . $wpdb->term_taxonomy . " WHERE term_taxonomy_id IN($format) GROUP BY term_id",
1703
+							$cat_ids_array
1704
+						)
1705
+					);
1706 1706
 
1707
-                }
1707
+				}
1708 1708
 
1709
-                $post_marker_json = '';
1709
+				$post_marker_json = '';
1710 1710
 
1711
-                if (!empty($post_term)):
1711
+				if (!empty($post_term)):
1712 1712
 
1713
-                    foreach ($post_term as $cat_id):
1713
+					foreach ($post_term as $cat_id):
1714 1714
 
1715
-                        $term_icon_url = get_tax_meta($cat_id, 'ct_cat_icon', false, $post_type);
1716
-                        $term_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : '';
1715
+						$term_icon_url = get_tax_meta($cat_id, 'ct_cat_icon', false, $post_type);
1716
+						$term_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : '';
1717 1717
 
1718
-                        $post_title = $post_obj->title;
1719
-                        $title = str_replace($srcharr, $replarr, $post_title);
1718
+						$post_title = $post_obj->title;
1719
+						$title = str_replace($srcharr, $replarr, $post_title);
1720 1720
 
1721
-                        $lat = geodir_get_post_meta($post_id, 'post_latitude', true);
1722
-                        $lng = geodir_get_post_meta($post_id, 'post_longitude', true);
1721
+						$lat = geodir_get_post_meta($post_id, 'post_latitude', true);
1722
+						$lng = geodir_get_post_meta($post_id, 'post_longitude', true);
1723 1723
 
1724
-                        $timing = ' - ' . date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true)));
1725
-                        $timing .= ' - ' . geodir_get_post_meta($post_id, 'st_time', true);
1724
+						$timing = ' - ' . date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true)));
1725
+						$timing .= ' - ' . geodir_get_post_meta($post_id, 'st_time', true);
1726 1726
 
1727
-                        $json = '{';
1728
-                        $json .= '"id":"' . $post_id . '",';
1729
-                        $json .= '"lat_pos": "' . $lat . '",';
1730
-                        $json .= '"long_pos": "' . $lng . '",';
1731
-                        $json .= '"marker_id":"' . $post_id . '_' . $cat_id . '",';
1732
-                        $json .= '"icon":"' . $term_icon . '",';
1733
-                        $json .= '"group":"catgroup' . $cat_id . '"';
1734
-                        $json .= '}';
1727
+						$json = '{';
1728
+						$json .= '"id":"' . $post_id . '",';
1729
+						$json .= '"lat_pos": "' . $lat . '",';
1730
+						$json .= '"long_pos": "' . $lng . '",';
1731
+						$json .= '"marker_id":"' . $post_id . '_' . $cat_id . '",';
1732
+						$json .= '"icon":"' . $term_icon . '",';
1733
+						$json .= '"group":"catgroup' . $cat_id . '"';
1734
+						$json .= '}';
1735 1735
 
1736 1736
 
1737
-                        if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true))
1738
-                            $post_marker_json = $json;
1737
+						if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true))
1738
+							$post_marker_json = $json;
1739 1739
 
1740 1740
 
1741
-                        if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . GEODIR_ICON_TABLE . " WHERE post_id = %d AND cat_id = %d", array($post_id, $cat_id)))) {
1741
+						if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . GEODIR_ICON_TABLE . " WHERE post_id = %d AND cat_id = %d", array($post_id, $cat_id)))) {
1742 1742
 
1743
-                            $json_query = $wpdb->prepare("UPDATE " . GEODIR_ICON_TABLE . " SET
1743
+							$json_query = $wpdb->prepare("UPDATE " . GEODIR_ICON_TABLE . " SET
1744 1744
 										post_title = %s,
1745 1745
 										json = %s
1746 1746
 										WHERE post_id = %d AND cat_id = %d ",
1747
-                                array($post_title, $json, $post_id, $cat_id));
1747
+								array($post_title, $json, $post_id, $cat_id));
1748 1748
 
1749
-                        } else {
1749
+						} else {
1750 1750
 
1751
-                            $json_query = $wpdb->prepare("INSERT INTO " . GEODIR_ICON_TABLE . " SET
1751
+							$json_query = $wpdb->prepare("INSERT INTO " . GEODIR_ICON_TABLE . " SET
1752 1752
 										post_id = %d,
1753 1753
 										post_title = %s,
1754 1754
 										cat_id = %d,
1755 1755
 										json = %s",
1756
-                                array($post_id, $post_title, $cat_id, $json));
1756
+								array($post_id, $post_title, $cat_id, $json));
1757 1757
 
1758
-                        }
1758
+						}
1759 1759
 
1760
-                        $wpdb->query($json_query);
1760
+						$wpdb->query($json_query);
1761 1761
 
1762
-                    endforeach;
1762
+					endforeach;
1763 1763
 
1764
-                endif;
1764
+				endif;
1765 1765
 
1766
-                if (!empty($post_term) && is_array($post_term)) {
1767
-                    $categories = implode(',', $post_term);
1766
+				if (!empty($post_term) && is_array($post_term)) {
1767
+					$categories = implode(',', $post_term);
1768 1768
 
1769
-                    if ($categories != '' && $categories != 0) $categories = ',' . $categories . ',';
1769
+					if ($categories != '' && $categories != 0) $categories = ',' . $categories . ',';
1770 1770
 
1771
-                    if (empty($post_marker_json))
1772
-                        $post_marker_json = isset($json) ? $json : '';
1771
+					if (empty($post_marker_json))
1772
+						$post_marker_json = isset($json) ? $json : '';
1773 1773
 
1774
-                    if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
1774
+					if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
1775 1775
 
1776
-                        $wpdb->query(
1777
-                            $wpdb->prepare(
1778
-                                "UPDATE " . $table . " SET
1776
+						$wpdb->query(
1777
+							$wpdb->prepare(
1778
+								"UPDATE " . $table . " SET
1779 1779
 								" . $taxonomy . " = %s,
1780 1780
 								marker_json = %s
1781 1781
 								where post_id = %d",
1782
-                                array($categories, $post_marker_json, $post_id)
1783
-                            )
1784
-                        );
1782
+								array($categories, $post_marker_json, $post_id)
1783
+							)
1784
+						);
1785 1785
 
1786
-                        if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save') {
1786
+						if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save') {
1787 1787
 
1788
-                            $categories = trim($categories, ',');
1788
+							$categories = trim($categories, ',');
1789 1789
 
1790
-                            if ($categories) {
1790
+							if ($categories) {
1791 1791
 
1792
-                                $categories = explode(',', $categories);
1792
+								$categories = explode(',', $categories);
1793 1793
 
1794
-                                $default_category = geodir_get_post_meta($post_id, 'default_category', true);
1794
+								$default_category = geodir_get_post_meta($post_id, 'default_category', true);
1795 1795
 
1796
-                                if (!in_array($default_category, $categories)) {
1796
+								if (!in_array($default_category, $categories)) {
1797 1797
 
1798
-                                    $wpdb->query(
1799
-                                        $wpdb->prepare(
1800
-                                            "UPDATE " . $table . " SET
1798
+									$wpdb->query(
1799
+										$wpdb->prepare(
1800
+											"UPDATE " . $table . " SET
1801 1801
 											default_category = %s
1802 1802
 											where post_id = %d",
1803
-                                            array($categories[0], $post_id)
1804
-                                        )
1805
-                                    );
1803
+											array($categories[0], $post_id)
1804
+										)
1805
+									);
1806 1806
 
1807
-                                    $default_category = $categories[0];
1807
+									$default_category = $categories[0];
1808 1808
 
1809
-                                }
1809
+								}
1810 1810
 
1811
-                                if ($default_category == '')
1812
-                                    $default_category = $categories[0];
1811
+								if ($default_category == '')
1812
+									$default_category = $categories[0];
1813 1813
 
1814
-                                geodir_set_postcat_structure($post_id, $taxonomy, $default_category, '');
1814
+								geodir_set_postcat_structure($post_id, $taxonomy, $default_category, '');
1815 1815
 
1816
-                            }
1816
+							}
1817 1817
 
1818
-                        }
1818
+						}
1819 1819
 
1820 1820
 
1821
-                    } else {
1821
+					} else {
1822 1822
 
1823
-                        $wpdb->query(
1824
-                            $wpdb->prepare(
1825
-                                "INSERT INTO " . $table . " SET
1823
+						$wpdb->query(
1824
+							$wpdb->prepare(
1825
+								"INSERT INTO " . $table . " SET
1826 1826
 								post_id = %d,
1827 1827
 								" . $taxonomy . " = %s,
1828 1828
 								marker_json = %s ",
1829 1829
 
1830
-                                array($post_id, $categories, $post_marker_json)
1831
-                            )
1832
-                        );
1833
-                    }
1834
-                }
1835
-            }
1836
-        }
1837
-    }
1830
+								array($post_id, $categories, $post_marker_json)
1831
+							)
1832
+						);
1833
+					}
1834
+				}
1835
+			}
1836
+		}
1837
+	}
1838 1838
 }
1839 1839
 
1840 1840
 if (!function_exists('geodir_get_infowindow_html')) {
1841
-    /**
1842
-     * Set post Map Marker info html.
1843
-     *
1844
-     * @since 1.0.0
1845
-     * @since 1.5.4 Modified to add new action "geodir_infowindow_meta_before".
1846
-     * @since 1.6.16 Changes for disable review stars for certain post type.
1847
-     * @package GeoDirectory
1848
-     * @global array $geodir_addon_list List of active GeoDirectory extensions.
1849
-     * @global object $gd_session GeoDirectory Session object.
1850
-     * @param object $postinfo_obj The post details object.
1851
-     * @param string $post_preview Is this a post preview?.
1852
-     * @return mixed|string|void
1853
-     */
1854
-    function geodir_get_infowindow_html($postinfo_obj, $post_preview = '')
1855
-    {
1856
-        global $preview, $gd_session;
1857
-        $srcharr = array("'", "/", "-", '"', '\\');
1858
-        $replarr = array("&prime;", "&frasl;", "&ndash;", "&ldquo;", '');
1859
-
1860
-        if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
1861
-            $ID = '';
1862
-            $plink = '';
1863
-
1864
-            if (isset($postinfo_obj->pid)) {
1865
-                $ID = $postinfo_obj->pid;
1866
-                $plink = get_permalink($ID);
1867
-            }
1868
-
1869
-            $title = str_replace($srcharr, $replarr, ($postinfo_obj->post_title));
1870
-            $lat = $postinfo_obj->post_latitude;
1871
-            $lng = $postinfo_obj->post_longitude;
1872
-        } else {
1873
-            $ID = $postinfo_obj->post_id;
1874
-            $title = str_replace($srcharr, $replarr, htmlentities($postinfo_obj->post_title, ENT_COMPAT, 'UTF-8')); // fix by Stiofan
1875
-            $title = wp_specialchars_decode($title); // Fixed #post-320722 on 2016-12-08
1876
-            $plink = get_permalink($ID);
1877
-            $lat = htmlentities(geodir_get_post_meta($ID, 'post_latitude', true));
1878
-            $lng = htmlentities(geodir_get_post_meta($ID, 'post_longitude', true));
1879
-        }
1841
+	/**
1842
+	 * Set post Map Marker info html.
1843
+	 *
1844
+	 * @since 1.0.0
1845
+	 * @since 1.5.4 Modified to add new action "geodir_infowindow_meta_before".
1846
+	 * @since 1.6.16 Changes for disable review stars for certain post type.
1847
+	 * @package GeoDirectory
1848
+	 * @global array $geodir_addon_list List of active GeoDirectory extensions.
1849
+	 * @global object $gd_session GeoDirectory Session object.
1850
+	 * @param object $postinfo_obj The post details object.
1851
+	 * @param string $post_preview Is this a post preview?.
1852
+	 * @return mixed|string|void
1853
+	 */
1854
+	function geodir_get_infowindow_html($postinfo_obj, $post_preview = '')
1855
+	{
1856
+		global $preview, $gd_session;
1857
+		$srcharr = array("'", "/", "-", '"', '\\');
1858
+		$replarr = array("&prime;", "&frasl;", "&ndash;", "&ldquo;", '');
1859
+
1860
+		if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
1861
+			$ID = '';
1862
+			$plink = '';
1863
+
1864
+			if (isset($postinfo_obj->pid)) {
1865
+				$ID = $postinfo_obj->pid;
1866
+				$plink = get_permalink($ID);
1867
+			}
1868
+
1869
+			$title = str_replace($srcharr, $replarr, ($postinfo_obj->post_title));
1870
+			$lat = $postinfo_obj->post_latitude;
1871
+			$lng = $postinfo_obj->post_longitude;
1872
+		} else {
1873
+			$ID = $postinfo_obj->post_id;
1874
+			$title = str_replace($srcharr, $replarr, htmlentities($postinfo_obj->post_title, ENT_COMPAT, 'UTF-8')); // fix by Stiofan
1875
+			$title = wp_specialchars_decode($title); // Fixed #post-320722 on 2016-12-08
1876
+			$plink = get_permalink($ID);
1877
+			$lat = htmlentities(geodir_get_post_meta($ID, 'post_latitude', true));
1878
+			$lng = htmlentities(geodir_get_post_meta($ID, 'post_longitude', true));
1879
+		}
1880 1880
         
1881
-        $post_type = $ID ? get_post_type($ID) : '';
1882
-
1883
-        // filter field as per price package
1884
-        global $geodir_addon_list;
1885
-        if ($post_type && defined('GEODIRPAYMENT_VERSION')) {
1886
-            $package_id = isset($postinfo_obj->package_id) && $postinfo_obj->package_id ? $postinfo_obj->package_id : NULL;
1887
-            $field_name = 'geodir_contact';
1888
-            if (!check_field_visibility($package_id, $field_name, $post_type)) {
1889
-                $contact = '';
1890
-            }
1891
-
1892
-            $field_name = 'geodir_timing';
1893
-            if (!check_field_visibility($package_id, $field_name, $post_type)) {
1894
-                $timing = '';
1895
-            }
1896
-        }
1897
-
1898
-        if ($lat && $lng) {
1899
-            ob_start(); ?>
1881
+		$post_type = $ID ? get_post_type($ID) : '';
1882
+
1883
+		// filter field as per price package
1884
+		global $geodir_addon_list;
1885
+		if ($post_type && defined('GEODIRPAYMENT_VERSION')) {
1886
+			$package_id = isset($postinfo_obj->package_id) && $postinfo_obj->package_id ? $postinfo_obj->package_id : NULL;
1887
+			$field_name = 'geodir_contact';
1888
+			if (!check_field_visibility($package_id, $field_name, $post_type)) {
1889
+				$contact = '';
1890
+			}
1891
+
1892
+			$field_name = 'geodir_timing';
1893
+			if (!check_field_visibility($package_id, $field_name, $post_type)) {
1894
+				$timing = '';
1895
+			}
1896
+		}
1897
+
1898
+		if ($lat && $lng) {
1899
+			ob_start(); ?>
1900 1900
             <div class="gd-bubble" style="">
1901 1901
                 <div class="gd-bubble-inside">
1902 1902
                     <?php
1903
-                    $comment_count = '';
1904
-                    $rating_star = '';
1905
-                    if ($ID != '' && $post_type != '' && !geodir_cpt_has_rating_disabled($post_type)) {
1906
-                        $rating_star = '';
1907
-                        $comment_count = geodir_get_review_count_total($ID);
1908
-
1909
-                        if (!$preview) {
1910
-                            $post_avgratings = geodir_get_post_rating($ID);
1911
-
1912
-                            $rating_star = geodir_get_rating_stars($post_avgratings, $ID, false);
1913
-
1914
-                            /**
1915
-                             * Filter to change rating stars
1916
-                             *
1917
-                             * You can use this filter to change Rating stars.
1918
-                             *
1919
-                             * @since 1.0.0
1920
-                             * @package GeoDirectory
1921
-                             * @param string $rating_star Rating stars.
1922
-                             * @param float $post_avgratings Average ratings of the post.
1923
-                             * @param int $ID The post ID.
1924
-                             */
1925
-                            $rating_star = apply_filters('geodir_review_rating_stars_on_infowindow', $rating_star, $post_avgratings, $ID);
1926
-                        }
1927
-                    }
1928
-                    ?>
1903
+					$comment_count = '';
1904
+					$rating_star = '';
1905
+					if ($ID != '' && $post_type != '' && !geodir_cpt_has_rating_disabled($post_type)) {
1906
+						$rating_star = '';
1907
+						$comment_count = geodir_get_review_count_total($ID);
1908
+
1909
+						if (!$preview) {
1910
+							$post_avgratings = geodir_get_post_rating($ID);
1911
+
1912
+							$rating_star = geodir_get_rating_stars($post_avgratings, $ID, false);
1913
+
1914
+							/**
1915
+							 * Filter to change rating stars
1916
+							 *
1917
+							 * You can use this filter to change Rating stars.
1918
+							 *
1919
+							 * @since 1.0.0
1920
+							 * @package GeoDirectory
1921
+							 * @param string $rating_star Rating stars.
1922
+							 * @param float $post_avgratings Average ratings of the post.
1923
+							 * @param int $ID The post ID.
1924
+							 */
1925
+							$rating_star = apply_filters('geodir_review_rating_stars_on_infowindow', $rating_star, $post_avgratings, $ID);
1926
+						}
1927
+					}
1928
+					?>
1929 1929
                     <div class="geodir-bubble_desc">
1930 1930
                         <h4>
1931 1931
                             <a href="<?php if ($plink != '') {
1932
-                                echo $plink;
1933
-                            } else {
1934
-                                echo 'javascript:void(0);';
1935
-                            } ?>"><?php echo $title; ?></a>
1932
+								echo $plink;
1933
+							} else {
1934
+								echo 'javascript:void(0);';
1935
+							} ?>"><?php echo $title; ?></a>
1936 1936
                         </h4>
1937 1937
                         <?php
1938
-                        if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
1939
-                            $post_images = array();
1940
-                            if (!empty($postinfo_obj->post_images)) {
1941
-                                $post_images = explode(",", $postinfo_obj->post_images);
1942
-                            }
1943
-
1944
-                            if (!empty($post_images)) {
1945
-                                ?>
1938
+						if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
1939
+							$post_images = array();
1940
+							if (!empty($postinfo_obj->post_images)) {
1941
+								$post_images = explode(",", $postinfo_obj->post_images);
1942
+							}
1943
+
1944
+							if (!empty($post_images)) {
1945
+								?>
1946 1946
                                 <div class="geodir-bubble_image"><a href="<?php if ($plink != '') {
1947
-                                        echo $plink;
1948
-                                    } else {
1949
-                                        echo 'javascript:void(0);';
1950
-                                    } ?>"><img alt="bubble image" style="max-height:50px;"
1947
+										echo $plink;
1948
+									} else {
1949
+										echo 'javascript:void(0);';
1950
+									} ?>"><img alt="bubble image" style="max-height:50px;"
1951 1951
                                                src="<?php echo $post_images[0]; ?>"/></a></div>
1952 1952
                             <?php
1953
-                            }else{
1954
-                                echo '<div class="geodir-bubble_image"></div>';
1955
-                            }
1956
-                        } else {
1957
-                            if ($image = geodir_show_featured_image($ID, 'widget-thumb', true, false, $postinfo_obj->featured_image)) {
1958
-                                ?>
1953
+							}else{
1954
+								echo '<div class="geodir-bubble_image"></div>';
1955
+							}
1956
+						} else {
1957
+							if ($image = geodir_show_featured_image($ID, 'widget-thumb', true, false, $postinfo_obj->featured_image)) {
1958
+								?>
1959 1959
                                 <div class="geodir-bubble_image"><a href="<?php echo $plink; ?>"><?php echo $image; ?></a></div>
1960 1960
                             <?php
1961
-                            }else{
1962
-                                echo '<div class="geodir-bubble_image"></div>';
1963
-                            }
1964
-                        }
1965
-                        ?>
1961
+							}else{
1962
+								echo '<div class="geodir-bubble_image"></div>';
1963
+							}
1964
+						}
1965
+						?>
1966 1966
                         <div class="geodir-bubble-meta-side">
1967 1967
                             <?php
1968
-                            /**
1969
-                             * Fires before the meta info in the map info window.
1970
-                             *
1971
-                             * This can be used to add more info to the map info window before the normal meta info.
1972
-                             *
1973
-                             * @since 1.5.4
1974
-                             * @param int $ID The post id.
1975
-                             * @param object $postinfo_obj The posts info as an object.
1976
-                             * @param bool|string $post_preview True if currently in post preview page. Empty string if not.                           *
1977
-                             */
1978
-                            do_action('geodir_infowindow_meta_before', $ID, $postinfo_obj, $post_preview);
1979
-
1980
-                            echo geodir_show_listing_info('mapbubble');
1981
-
1982
-                            /**
1983
-                             * Fires after the meta info in the map info window.
1984
-                             *
1985
-                             * This can be used to add more info to the map info window after the normal meta info.
1986
-                             *
1987
-                             * @since 1.4.2
1988
-                             * @param object $postinfo_obj The posts info as an object.
1989
-                             * @param bool|string $post_preview True if currently in post preview page. Empty string if not.                           *
1990
-                             */
1991
-                            do_action('geodir_infowindow_meta_after',$postinfo_obj,$post_preview );
1992
-                            ?>
1968
+							/**
1969
+							 * Fires before the meta info in the map info window.
1970
+							 *
1971
+							 * This can be used to add more info to the map info window before the normal meta info.
1972
+							 *
1973
+							 * @since 1.5.4
1974
+							 * @param int $ID The post id.
1975
+							 * @param object $postinfo_obj The posts info as an object.
1976
+							 * @param bool|string $post_preview True if currently in post preview page. Empty string if not.                           *
1977
+							 */
1978
+							do_action('geodir_infowindow_meta_before', $ID, $postinfo_obj, $post_preview);
1979
+
1980
+							echo geodir_show_listing_info('mapbubble');
1981
+
1982
+							/**
1983
+							 * Fires after the meta info in the map info window.
1984
+							 *
1985
+							 * This can be used to add more info to the map info window after the normal meta info.
1986
+							 *
1987
+							 * @since 1.4.2
1988
+							 * @param object $postinfo_obj The posts info as an object.
1989
+							 * @param bool|string $post_preview True if currently in post preview page. Empty string if not.                           *
1990
+							 */
1991
+							do_action('geodir_infowindow_meta_after',$postinfo_obj,$post_preview );
1992
+							?>
1993 1993
                         </div>
1994 1994
                         <?php
1995
-                        if ($ID) {
1996
-                            $post_author = isset($postinfo_obj->post_author) ? $postinfo_obj->post_author : get_post_field('post_author', $ID);
1997
-                            ?>
1995
+						if ($ID) {
1996
+							$post_author = isset($postinfo_obj->post_author) ? $postinfo_obj->post_author : get_post_field('post_author', $ID);
1997
+							?>
1998 1998
                             <div class="geodir-bubble-meta-fade"></div>
1999 1999
                             <div class="geodir-bubble-meta-bottom">
2000 2000
                                 <?php if ($rating_star != '') { ?>
@@ -2010,69 +2010,69 @@  discard block
 block discarded – undo
2010 2010
                 </div>
2011 2011
             </div>
2012 2012
             <?php
2013
-            $html = ob_get_clean();
2014
-            /**
2015
-             * Filter to change infowindow html
2016
-             *
2017
-             * You can use this filter to change infowindow html.
2018
-             *
2019
-             * @since 1.0.0
2020
-             * @package GeoDirectory
2021
-             * @param string $html Infowindow html.
2022
-             * @param object $postinfo_obj The Post object.
2023
-             * @param bool|string $post_preview Is this a post preview?
2024
-             */
2025
-            $html = apply_filters('geodir_custom_infowindow_html', $html, $postinfo_obj, $post_preview);
2026
-            return $html;
2027
-        }
2028
-    }
2013
+			$html = ob_get_clean();
2014
+			/**
2015
+			 * Filter to change infowindow html
2016
+			 *
2017
+			 * You can use this filter to change infowindow html.
2018
+			 *
2019
+			 * @since 1.0.0
2020
+			 * @package GeoDirectory
2021
+			 * @param string $html Infowindow html.
2022
+			 * @param object $postinfo_obj The Post object.
2023
+			 * @param bool|string $post_preview Is this a post preview?
2024
+			 */
2025
+			$html = apply_filters('geodir_custom_infowindow_html', $html, $postinfo_obj, $post_preview);
2026
+			return $html;
2027
+		}
2028
+	}
2029 2029
 }
2030 2030
 
2031 2031
 
2032 2032
 if (!function_exists('geodir_new_post_default_status')) {
2033
-    /**
2034
-     * Default post status for new posts.
2035
-     *
2036
-     * @since 1.0.0
2037
-     * @package GeoDirectory
2038
-     * @return string Returns the default post status for new posts. Ex: draft, publish etc.
2039
-     */
2040
-    function geodir_new_post_default_status()
2041
-    {
2042
-        if (get_option('geodir_new_post_default_status'))
2043
-            return get_option('geodir_new_post_default_status');
2044
-        else
2045
-            return 'publish';
2046
-
2047
-    }
2033
+	/**
2034
+	 * Default post status for new posts.
2035
+	 *
2036
+	 * @since 1.0.0
2037
+	 * @package GeoDirectory
2038
+	 * @return string Returns the default post status for new posts. Ex: draft, publish etc.
2039
+	 */
2040
+	function geodir_new_post_default_status()
2041
+	{
2042
+		if (get_option('geodir_new_post_default_status'))
2043
+			return get_option('geodir_new_post_default_status');
2044
+		else
2045
+			return 'publish';
2046
+
2047
+	}
2048 2048
 }
2049 2049
 
2050 2050
 if (!function_exists('geodir_change_post_status')) {
2051
-    /**
2052
-     * Change post status of a post.
2053
-     *
2054
-     * @global object $wpdb WordPress Database object.
2055
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
2056
-     * @param int|string $post_id The post ID.
2057
-     * @param string $status New post status. Ex: draft, publish etc.
2058
-     */
2059
-    function geodir_change_post_status($post_id = '', $status = '')
2060
-    {
2061
-        global $wpdb, $plugin_prefix;
2062
-
2063
-        $post_type = get_post_type($post_id);
2064
-
2065
-        $table = $plugin_prefix . $post_type . '_detail';
2066
-
2067
-        $wpdb->query(
2068
-            $wpdb->prepare(
2069
-                "UPDATE " . $table . " SET post_status=%s WHERE post_id=%d",
2070
-                array($status, $post_id)
2071
-            )
2072
-        );
2073
-
2074
-
2075
-    }
2051
+	/**
2052
+	 * Change post status of a post.
2053
+	 *
2054
+	 * @global object $wpdb WordPress Database object.
2055
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
2056
+	 * @param int|string $post_id The post ID.
2057
+	 * @param string $status New post status. Ex: draft, publish etc.
2058
+	 */
2059
+	function geodir_change_post_status($post_id = '', $status = '')
2060
+	{
2061
+		global $wpdb, $plugin_prefix;
2062
+
2063
+		$post_type = get_post_type($post_id);
2064
+
2065
+		$table = $plugin_prefix . $post_type . '_detail';
2066
+
2067
+		$wpdb->query(
2068
+			$wpdb->prepare(
2069
+				"UPDATE " . $table . " SET post_status=%s WHERE post_id=%d",
2070
+				array($status, $post_id)
2071
+			)
2072
+		);
2073
+
2074
+
2075
+	}
2076 2076
 }
2077 2077
 
2078 2078
 /**
@@ -2086,13 +2086,13 @@  discard block
 block discarded – undo
2086 2086
  */
2087 2087
 function geodir_set_post_status($pid, $status)
2088 2088
 {
2089
-    if ($pid) {
2090
-        global $wpdb;
2091
-        $my_post = array();
2092
-        $my_post['post_status'] = $status;
2093
-        $my_post['ID'] = $pid;
2094
-        $last_postid = wp_update_post($my_post);
2095
-    }
2089
+	if ($pid) {
2090
+		global $wpdb;
2091
+		$my_post = array();
2092
+		$my_post['post_status'] = $status;
2093
+		$my_post['ID'] = $pid;
2094
+		$last_postid = wp_update_post($my_post);
2095
+	}
2096 2096
 }
2097 2097
 
2098 2098
 
@@ -2108,384 +2108,384 @@  discard block
 block discarded – undo
2108 2108
  */
2109 2109
 function geodir_update_poststatus($new_status, $old_status, $post)
2110 2110
 {
2111
-    global $wpdb;
2111
+	global $wpdb;
2112 2112
 
2113
-    $geodir_posttypes = geodir_get_posttypes();
2113
+	$geodir_posttypes = geodir_get_posttypes();
2114 2114
 
2115
-    if (!wp_is_post_revision($post->ID) && in_array($post->post_type, $geodir_posttypes)) {
2115
+	if (!wp_is_post_revision($post->ID) && in_array($post->post_type, $geodir_posttypes)) {
2116 2116
 
2117
-        geodir_change_post_status($post->ID, $new_status);
2118
-    }
2117
+		geodir_change_post_status($post->ID, $new_status);
2118
+	}
2119 2119
 }
2120 2120
 
2121 2121
 
2122 2122
 if (!function_exists('geodir_update_listing_info')) {
2123
-    /**
2124
-     * Update post info.
2125
-     *
2126
-     * @since 1.0.0
2127
-     * @package GeoDirectory
2128
-     * @global object $wpdb WordPress Database object.
2129
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
2130
-     * @param int $updatingpost The updating post ID.
2131
-     * @param int $temppost The temporary post ID.
2132
-     * @todo fix post_id variable
2133
-     */
2134
-    function geodir_update_listing_info($updatingpost, $temppost)
2135
-    {
2136
-
2137
-        global $wpdb, $plugin_prefix;
2138
-
2139
-        $post_type = get_post_type($post_id);
2140
-
2141
-        $table = $plugin_prefix . $post_type . '_detail';
2142
-
2143
-        $wpdb->query(
2144
-            $wpdb->prepare(
2145
-                "UPDATE " . $table . " SET `post_id` = %d WHERE `post_id` = %d",
2146
-                array($updatingpost, $temppost)
2147
-            )
2148
-        );
2149
-
2150
-        $wpdb->query(
2151
-            $wpdb->prepare(
2152
-                "UPDATE " . GEODIR_ICON_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2153
-                array($updatingpost, $temppost)
2154
-            )
2155
-        );
2156
-
2157
-        /* Update Attachments*/
2158
-
2159
-        $wpdb->query(
2160
-            $wpdb->prepare(
2161
-                "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2162
-                array($updatingpost, $temppost)
2163
-            )
2164
-        );
2165
-
2166
-    }
2123
+	/**
2124
+	 * Update post info.
2125
+	 *
2126
+	 * @since 1.0.0
2127
+	 * @package GeoDirectory
2128
+	 * @global object $wpdb WordPress Database object.
2129
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
2130
+	 * @param int $updatingpost The updating post ID.
2131
+	 * @param int $temppost The temporary post ID.
2132
+	 * @todo fix post_id variable
2133
+	 */
2134
+	function geodir_update_listing_info($updatingpost, $temppost)
2135
+	{
2136
+
2137
+		global $wpdb, $plugin_prefix;
2138
+
2139
+		$post_type = get_post_type($post_id);
2140
+
2141
+		$table = $plugin_prefix . $post_type . '_detail';
2142
+
2143
+		$wpdb->query(
2144
+			$wpdb->prepare(
2145
+				"UPDATE " . $table . " SET `post_id` = %d WHERE `post_id` = %d",
2146
+				array($updatingpost, $temppost)
2147
+			)
2148
+		);
2149
+
2150
+		$wpdb->query(
2151
+			$wpdb->prepare(
2152
+				"UPDATE " . GEODIR_ICON_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2153
+				array($updatingpost, $temppost)
2154
+			)
2155
+		);
2156
+
2157
+		/* Update Attachments*/
2158
+
2159
+		$wpdb->query(
2160
+			$wpdb->prepare(
2161
+				"UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2162
+				array($updatingpost, $temppost)
2163
+			)
2164
+		);
2165
+
2166
+	}
2167 2167
 }
2168 2168
 
2169 2169
 
2170 2170
 if (!function_exists('geodir_delete_listing_info')) {
2171
-    /**
2172
-     * Delete Listing info from details table for the given post id.
2173
-     *
2174
-     * @since 1.0.0
2175
-     * @package GeoDirectory
2176
-     * @global object $wpdb WordPress Database object.
2177
-     * @global string $plugin_prefix Geodirectory plugin table prefix.
2178
-     * @param int $deleted_postid The post ID.
2179
-     * @param bool $force Optional. Do you want to force delete it? Default: false.
2180
-     * @return bool|void
2181
-     */
2182
-    function geodir_delete_listing_info($deleted_postid, $force = false)
2183
-    {
2184
-        global $wpdb, $plugin_prefix;
2185
-
2186
-        // check for multisite deletions
2187
-        if (strpos($plugin_prefix, $wpdb->prefix) !== false) {
2188
-        } else {
2189
-            return;
2190
-        }
2191
-
2192
-        $post_type = get_post_type($deleted_postid);
2193
-
2194
-        $all_postypes = geodir_get_posttypes();
2195
-
2196
-        if (!in_array($post_type, $all_postypes))
2197
-            return false;
2198
-
2199
-        $table = $plugin_prefix . $post_type . '_detail';
2200
-
2201
-        /* Delete custom post meta*/
2202
-        $wpdb->query(
2203
-            $wpdb->prepare(
2204
-                "DELETE FROM " . $table . " WHERE `post_id` = %d",
2205
-                array($deleted_postid)
2206
-            )
2207
-        );
2208
-
2209
-        /* Delete post map icons*/
2210
-
2211
-        $wpdb->query(
2212
-            $wpdb->prepare(
2213
-                "DELETE FROM " . GEODIR_ICON_TABLE . " WHERE `post_id` = %d",
2214
-                array($deleted_postid)
2215
-            )
2216
-        );
2217
-
2218
-        /* Delete Attachments*/
2219
-        $postcurr_images = geodir_get_images($deleted_postid);
2220
-
2221
-        $wpdb->query(
2222
-            $wpdb->prepare(
2223
-                "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE `post_id` = %d",
2224
-                array($deleted_postid)
2225
-            )
2226
-        );
2227
-        geodir_remove_attachments($postcurr_images);
2228
-
2229
-    }
2171
+	/**
2172
+	 * Delete Listing info from details table for the given post id.
2173
+	 *
2174
+	 * @since 1.0.0
2175
+	 * @package GeoDirectory
2176
+	 * @global object $wpdb WordPress Database object.
2177
+	 * @global string $plugin_prefix Geodirectory plugin table prefix.
2178
+	 * @param int $deleted_postid The post ID.
2179
+	 * @param bool $force Optional. Do you want to force delete it? Default: false.
2180
+	 * @return bool|void
2181
+	 */
2182
+	function geodir_delete_listing_info($deleted_postid, $force = false)
2183
+	{
2184
+		global $wpdb, $plugin_prefix;
2185
+
2186
+		// check for multisite deletions
2187
+		if (strpos($plugin_prefix, $wpdb->prefix) !== false) {
2188
+		} else {
2189
+			return;
2190
+		}
2191
+
2192
+		$post_type = get_post_type($deleted_postid);
2193
+
2194
+		$all_postypes = geodir_get_posttypes();
2195
+
2196
+		if (!in_array($post_type, $all_postypes))
2197
+			return false;
2198
+
2199
+		$table = $plugin_prefix . $post_type . '_detail';
2200
+
2201
+		/* Delete custom post meta*/
2202
+		$wpdb->query(
2203
+			$wpdb->prepare(
2204
+				"DELETE FROM " . $table . " WHERE `post_id` = %d",
2205
+				array($deleted_postid)
2206
+			)
2207
+		);
2208
+
2209
+		/* Delete post map icons*/
2210
+
2211
+		$wpdb->query(
2212
+			$wpdb->prepare(
2213
+				"DELETE FROM " . GEODIR_ICON_TABLE . " WHERE `post_id` = %d",
2214
+				array($deleted_postid)
2215
+			)
2216
+		);
2217
+
2218
+		/* Delete Attachments*/
2219
+		$postcurr_images = geodir_get_images($deleted_postid);
2220
+
2221
+		$wpdb->query(
2222
+			$wpdb->prepare(
2223
+				"DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE `post_id` = %d",
2224
+				array($deleted_postid)
2225
+			)
2226
+		);
2227
+		geodir_remove_attachments($postcurr_images);
2228
+
2229
+	}
2230 2230
 }
2231 2231
 
2232 2232
 
2233 2233
 if (!function_exists('geodir_add_to_favorite')) {
2234
-    /**
2235
-     * This function would add listing to favorite listing.
2236
-     *
2237
-     * @since 1.0.0
2238
-     * @package GeoDirectory
2239
-     * @global object $current_user Current user object.
2240
-     * @param int $post_id The post ID.
2241
-     */
2242
-    function geodir_add_to_favorite($post_id)
2243
-    {
2244
-
2245
-        global $current_user;
2246
-
2247
-        /**
2248
-         * Filter to modify "Unfavorite" text
2249
-         *
2250
-         * You can use this filter to rename "Unfavorite" text to something else.
2251
-         *
2252
-         * @since 1.0.0
2253
-         * @package GeoDirectory
2254
-         */
2255
-        $remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
2256
-
2257
-        /**
2258
-         * Filter to modify "Remove from Favorites" text
2259
-         *
2260
-         * You can use this filter to rename "Remove from Favorites" text to something else.
2261
-         *
2262
-         * @since 1.0.0
2263
-         * @package GeoDirectory
2264
-         */
2265
-        $unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
2266
-
2267
-        /**
2268
-         * Filter to modify "fa fa-heart" icon
2269
-         *
2270
-         * You can use this filter to change "fa fa-heart" icon to something else.
2271
-         *
2272
-         * @since 1.0.0
2273
-         * @package GeoDirectory
2274
-         */
2275
-        $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2276
-
2277
-        $user_meta_data = array();
2278
-        $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2279
-
2280
-        if (empty($user_meta_data) || (!empty($user_meta_data) && !in_array($post_id, $user_meta_data))) {
2281
-            $user_meta_data[] = $post_id;
2282
-        }
2283
-
2284
-        update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data);
2285
-
2286
-        /**
2287
-         * Called before adding the post from favourites.
2288
-         *
2289
-         * @since 1.0.0
2290
-         * @package GeoDirectory
2291
-         * @param int $post_id The post ID.
2292
-         */
2293
-        do_action('geodir_before_add_from_favorite', $post_id);
2294
-
2295
-        echo '<a href="javascript:void(0);" title="' . $remove_favourite_text . '" class="geodir-removetofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'remove\');"><i class="'. $favourite_icon .'"></i> ' . $unfavourite_text . '</a>';
2234
+	/**
2235
+	 * This function would add listing to favorite listing.
2236
+	 *
2237
+	 * @since 1.0.0
2238
+	 * @package GeoDirectory
2239
+	 * @global object $current_user Current user object.
2240
+	 * @param int $post_id The post ID.
2241
+	 */
2242
+	function geodir_add_to_favorite($post_id)
2243
+	{
2244
+
2245
+		global $current_user;
2246
+
2247
+		/**
2248
+		 * Filter to modify "Unfavorite" text
2249
+		 *
2250
+		 * You can use this filter to rename "Unfavorite" text to something else.
2251
+		 *
2252
+		 * @since 1.0.0
2253
+		 * @package GeoDirectory
2254
+		 */
2255
+		$remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
2256
+
2257
+		/**
2258
+		 * Filter to modify "Remove from Favorites" text
2259
+		 *
2260
+		 * You can use this filter to rename "Remove from Favorites" text to something else.
2261
+		 *
2262
+		 * @since 1.0.0
2263
+		 * @package GeoDirectory
2264
+		 */
2265
+		$unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
2266
+
2267
+		/**
2268
+		 * Filter to modify "fa fa-heart" icon
2269
+		 *
2270
+		 * You can use this filter to change "fa fa-heart" icon to something else.
2271
+		 *
2272
+		 * @since 1.0.0
2273
+		 * @package GeoDirectory
2274
+		 */
2275
+		$favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2276
+
2277
+		$user_meta_data = array();
2278
+		$user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2279
+
2280
+		if (empty($user_meta_data) || (!empty($user_meta_data) && !in_array($post_id, $user_meta_data))) {
2281
+			$user_meta_data[] = $post_id;
2282
+		}
2283
+
2284
+		update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data);
2285
+
2286
+		/**
2287
+		 * Called before adding the post from favourites.
2288
+		 *
2289
+		 * @since 1.0.0
2290
+		 * @package GeoDirectory
2291
+		 * @param int $post_id The post ID.
2292
+		 */
2293
+		do_action('geodir_before_add_from_favorite', $post_id);
2294
+
2295
+		echo '<a href="javascript:void(0);" title="' . $remove_favourite_text . '" class="geodir-removetofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'remove\');"><i class="'. $favourite_icon .'"></i> ' . $unfavourite_text . '</a>';
2296
+
2297
+		/**
2298
+		 * Called after adding the post from favourites.
2299
+		 *
2300
+		 * @since 1.0.0
2301
+		 * @package GeoDirectory
2302
+		 * @param int $post_id The post ID.
2303
+		 */
2304
+		do_action('geodir_after_add_from_favorite', $post_id);
2296 2305
 
2297
-        /**
2298
-         * Called after adding the post from favourites.
2299
-         *
2300
-         * @since 1.0.0
2301
-         * @package GeoDirectory
2302
-         * @param int $post_id The post ID.
2303
-         */
2304
-        do_action('geodir_after_add_from_favorite', $post_id);
2305
-
2306
-    }
2306
+	}
2307 2307
 }
2308 2308
 
2309 2309
 if (!function_exists('geodir_remove_from_favorite')) {
2310
-    /**
2311
-     * This function would remove the favourited property earlier.
2312
-     *
2313
-     * @since 1.0.0
2314
-     * @package GeoDirectory
2315
-     * @global object $current_user Current user object.
2316
-     * @param int $post_id The post ID.
2317
-     */
2318
-    function geodir_remove_from_favorite($post_id)
2319
-    {
2320
-        global $current_user;
2321
-
2322
-        /**
2323
-         * Filter to modify "Add to Favorites" text
2324
-         *
2325
-         * You can use this filter to rename "Add to Favorites" text to something else.
2326
-         *
2327
-         * @since 1.0.0
2328
-         * @package GeoDirectory
2329
-         */
2330
-        $add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
2331
-
2332
-        /**
2333
-         * Filter to modify "Favourite" text
2334
-         *
2335
-         * You can use this filter to rename "Favourite" text to something else.
2336
-         *
2337
-         * @since 1.0.0
2338
-         * @package GeoDirectory
2339
-         */
2340
-        $favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
2341
-
2342
-        /**
2343
-         * Filter to modify "fa fa-heart" icon
2344
-         *
2345
-         * You can use this filter to change "fa fa-heart" icon to something else.
2346
-         *
2347
-         * @since 1.0.0
2348
-         * @package GeoDirectory
2349
-         */
2350
-        $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2351
-
2352
-        $user_meta_data = array();
2353
-        $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2354
-
2355
-        if (!empty($user_meta_data)) {
2310
+	/**
2311
+	 * This function would remove the favourited property earlier.
2312
+	 *
2313
+	 * @since 1.0.0
2314
+	 * @package GeoDirectory
2315
+	 * @global object $current_user Current user object.
2316
+	 * @param int $post_id The post ID.
2317
+	 */
2318
+	function geodir_remove_from_favorite($post_id)
2319
+	{
2320
+		global $current_user;
2321
+
2322
+		/**
2323
+		 * Filter to modify "Add to Favorites" text
2324
+		 *
2325
+		 * You can use this filter to rename "Add to Favorites" text to something else.
2326
+		 *
2327
+		 * @since 1.0.0
2328
+		 * @package GeoDirectory
2329
+		 */
2330
+		$add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
2331
+
2332
+		/**
2333
+		 * Filter to modify "Favourite" text
2334
+		 *
2335
+		 * You can use this filter to rename "Favourite" text to something else.
2336
+		 *
2337
+		 * @since 1.0.0
2338
+		 * @package GeoDirectory
2339
+		 */
2340
+		$favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
2341
+
2342
+		/**
2343
+		 * Filter to modify "fa fa-heart" icon
2344
+		 *
2345
+		 * You can use this filter to change "fa fa-heart" icon to something else.
2346
+		 *
2347
+		 * @since 1.0.0
2348
+		 * @package GeoDirectory
2349
+		 */
2350
+		$favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2351
+
2352
+		$user_meta_data = array();
2353
+		$user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2354
+
2355
+		if (!empty($user_meta_data)) {
2356
+
2357
+			if (($key = array_search($post_id, $user_meta_data)) !== false) {
2358
+				unset($user_meta_data[$key]);
2359
+			}
2356 2360
 
2357
-            if (($key = array_search($post_id, $user_meta_data)) !== false) {
2358
-                unset($user_meta_data[$key]);
2359
-            }
2361
+		}
2360 2362
 
2361
-        }
2363
+		update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data);
2362 2364
 
2363
-        update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data);
2365
+		/**
2366
+		 * Called before removing the post from favourites.
2367
+		 *
2368
+		 * @since 1.0.0
2369
+		 * @package GeoDirectory
2370
+		 * @param int $post_id The post ID.
2371
+		 */
2372
+		do_action('geodir_before_remove_from_favorite', $post_id);
2364 2373
 
2365
-        /**
2366
-         * Called before removing the post from favourites.
2367
-         *
2368
-         * @since 1.0.0
2369
-         * @package GeoDirectory
2370
-         * @param int $post_id The post ID.
2371
-         */
2372
-        do_action('geodir_before_remove_from_favorite', $post_id);
2374
+		echo '<a href="javascript:void(0);"  title="' . $add_favourite_text . '" class="geodir-addtofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'add\');"><i class="'. $favourite_icon .'"></i> ' . $favourite_text . '</a>';
2373 2375
 
2374
-        echo '<a href="javascript:void(0);"  title="' . $add_favourite_text . '" class="geodir-addtofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'add\');"><i class="'. $favourite_icon .'"></i> ' . $favourite_text . '</a>';
2376
+		/**
2377
+		 * Called after removing the post from favourites.
2378
+		 *
2379
+		 * @since 1.0.0
2380
+		 * @package GeoDirectory
2381
+		 * @param int $post_id The post ID.
2382
+		 */
2383
+		do_action('geodir_after_remove_from_favorite', $post_id);
2375 2384
 
2376
-        /**
2377
-         * Called after removing the post from favourites.
2378
-         *
2379
-         * @since 1.0.0
2380
-         * @package GeoDirectory
2381
-         * @param int $post_id The post ID.
2382
-         */
2383
-        do_action('geodir_after_remove_from_favorite', $post_id);
2384
-
2385
-    }
2385
+	}
2386 2386
 }
2387 2387
 
2388 2388
 if (!function_exists('geodir_favourite_html')) {
2389
-    /**
2390
-     * This function would display the html content for add to favorite or remove from favorite.
2391
-     *
2392
-     * @since 1.0.0
2393
-     * @package GeoDirectory
2394
-     * @global object $current_user Current user object.
2395
-     * @global object $post The current post object.
2396
-     * @param int $user_id The user ID.
2397
-     * @param int $post_id The post ID.
2398
-     */
2399
-    function geodir_favourite_html($user_id, $post_id)
2400
-    {
2401
-
2402
-        global $current_user, $post;
2403
-
2404
-        /**
2405
-         * Filter to modify "Add to Favorites" text
2406
-         *
2407
-         * You can use this filter to rename "Add to Favorites" text to something else.
2408
-         *
2409
-         * @since 1.0.0
2410
-         * @package GeoDirectory
2411
-         */
2412
-        $add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
2413
-
2414
-        /**
2415
-         * Filter to modify "Favourite" text
2416
-         *
2417
-         * You can use this filter to rename "Favourite" text to something else.
2418
-         *
2419
-         * @since 1.0.0
2420
-         * @package GeoDirectory
2421
-         */
2422
-        $favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
2423
-
2424
-        /**
2425
-         * Filter to modify "Unfavorite" text
2426
-         *
2427
-         * You can use this filter to rename "Unfavorite" text to something else.
2428
-         *
2429
-         * @since 1.0.0
2430
-         * @package GeoDirectory
2431
-         */
2432
-        $remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
2433
-
2434
-        /**
2435
-         * Filter to modify "Remove from Favorites" text
2436
-         *
2437
-         * You can use this filter to rename "Remove from Favorites" text to something else.
2438
-         *
2439
-         * @since 1.0.0
2440
-         * @package GeoDirectory
2441
-         */
2442
-        $unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
2443
-
2444
-        /**
2445
-         * Filter to modify "fa fa-heart" icon
2446
-         *
2447
-         * You can use this filter to change "fa fa-heart" icon to something else.
2448
-         *
2449
-         * @since 1.0.0
2450
-         * @package GeoDirectory
2451
-         */
2452
-        $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2453
-
2454
-        /**
2455
-         * Filter to modify "fa fa-heart" icon for "remove from favorites" link
2456
-         *
2457
-         * You can use this filter to change "fa fa-heart" icon to something else.
2458
-         *
2459
-         * @since 1.0.0
2460
-         * @package GeoDirectory
2461
-         */
2462
-        $unfavourite_icon = apply_filters('geodir_unfavourite_icon', 'fa fa-heart');
2463
-
2464
-        $user_meta_data = '';
2465
-        if (isset($current_user->data->ID))
2466
-            $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2467
-
2468
-        if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
2469
-            ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"  ><a
2389
+	/**
2390
+	 * This function would display the html content for add to favorite or remove from favorite.
2391
+	 *
2392
+	 * @since 1.0.0
2393
+	 * @package GeoDirectory
2394
+	 * @global object $current_user Current user object.
2395
+	 * @global object $post The current post object.
2396
+	 * @param int $user_id The user ID.
2397
+	 * @param int $post_id The post ID.
2398
+	 */
2399
+	function geodir_favourite_html($user_id, $post_id)
2400
+	{
2401
+
2402
+		global $current_user, $post;
2403
+
2404
+		/**
2405
+		 * Filter to modify "Add to Favorites" text
2406
+		 *
2407
+		 * You can use this filter to rename "Add to Favorites" text to something else.
2408
+		 *
2409
+		 * @since 1.0.0
2410
+		 * @package GeoDirectory
2411
+		 */
2412
+		$add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
2413
+
2414
+		/**
2415
+		 * Filter to modify "Favourite" text
2416
+		 *
2417
+		 * You can use this filter to rename "Favourite" text to something else.
2418
+		 *
2419
+		 * @since 1.0.0
2420
+		 * @package GeoDirectory
2421
+		 */
2422
+		$favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
2423
+
2424
+		/**
2425
+		 * Filter to modify "Unfavorite" text
2426
+		 *
2427
+		 * You can use this filter to rename "Unfavorite" text to something else.
2428
+		 *
2429
+		 * @since 1.0.0
2430
+		 * @package GeoDirectory
2431
+		 */
2432
+		$remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
2433
+
2434
+		/**
2435
+		 * Filter to modify "Remove from Favorites" text
2436
+		 *
2437
+		 * You can use this filter to rename "Remove from Favorites" text to something else.
2438
+		 *
2439
+		 * @since 1.0.0
2440
+		 * @package GeoDirectory
2441
+		 */
2442
+		$unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
2443
+
2444
+		/**
2445
+		 * Filter to modify "fa fa-heart" icon
2446
+		 *
2447
+		 * You can use this filter to change "fa fa-heart" icon to something else.
2448
+		 *
2449
+		 * @since 1.0.0
2450
+		 * @package GeoDirectory
2451
+		 */
2452
+		$favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
2453
+
2454
+		/**
2455
+		 * Filter to modify "fa fa-heart" icon for "remove from favorites" link
2456
+		 *
2457
+		 * You can use this filter to change "fa fa-heart" icon to something else.
2458
+		 *
2459
+		 * @since 1.0.0
2460
+		 * @package GeoDirectory
2461
+		 */
2462
+		$unfavourite_icon = apply_filters('geodir_unfavourite_icon', 'fa fa-heart');
2463
+
2464
+		$user_meta_data = '';
2465
+		if (isset($current_user->data->ID))
2466
+			$user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2467
+
2468
+		if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
2469
+			?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"  ><a
2470 2470
                 class="geodir-removetofav-icon" href="javascript:void(0);"
2471 2471
                 onclick="javascript:addToFavourite(<?php echo $post_id;?>,'remove');"
2472 2472
                 title="<?php echo $remove_favourite_text;?>"><i class="<?php echo $unfavourite_icon; ?>"></i> <?php echo $unfavourite_text;?>
2473 2473
             </a>   </span><?php
2474 2474
 
2475
-        } else {
2475
+		} else {
2476 2476
 
2477
-            if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
2478
-                $script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\'';
2479
-            } else
2480
-                $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
2477
+			if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
2478
+				$script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\'';
2479
+			} else
2480
+				$script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
2481 2481
 
2482
-            ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon"
2482
+			?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon"
2483 2483
                                                                                         href="javascript:void(0);"
2484 2484
                                                                                         onclick="<?php echo $script_text;?>"
2485 2485
                                                                                         title="<?php echo $add_favourite_text;?>"><i
2486 2486
                     class="<?php echo $favourite_icon; ?>"></i> <?php echo $favourite_text;?></a></span>
2487 2487
         <?php }
2488
-    }
2488
+	}
2489 2489
 }
2490 2490
 
2491 2491
 
@@ -2502,54 +2502,54 @@  discard block
 block discarded – undo
2502 2502
 function geodir_get_cat_postcount($term = array())
2503 2503
 {
2504 2504
 
2505
-    if (!empty($term)) {
2505
+	if (!empty($term)) {
2506 2506
 
2507
-        global $wpdb, $plugin_prefix;
2507
+		global $wpdb, $plugin_prefix;
2508 2508
 
2509
-        $where = '';
2510
-        $join = '';
2511
-        if (get_query_var('gd_country') != '' || get_query_var('gd_region') != '' || get_query_var('gd_city') != '') {
2512
-            $taxonomy_obj = get_taxonomy($term->taxonomy);
2509
+		$where = '';
2510
+		$join = '';
2511
+		if (get_query_var('gd_country') != '' || get_query_var('gd_region') != '' || get_query_var('gd_city') != '') {
2512
+			$taxonomy_obj = get_taxonomy($term->taxonomy);
2513 2513
 
2514
-            $post_type = $taxonomy_obj->object_type[0];
2514
+			$post_type = $taxonomy_obj->object_type[0];
2515 2515
 
2516
-            $table = $plugin_prefix . $post_type . '_detail';
2516
+			$table = $plugin_prefix . $post_type . '_detail';
2517 2517
 
2518
-            /**
2519
-             * Filter to modify the 'join' query
2520
-             *
2521
-             * @since 1.0.0
2522
-             * @package GeoDirectory
2523
-             * @param object|array $term category / term object that need to be processed.
2524
-             * @param string $join The join query.
2525
-             */
2526
-            $join = apply_filters('geodir_cat_post_count_join', $join, $term);
2518
+			/**
2519
+			 * Filter to modify the 'join' query
2520
+			 *
2521
+			 * @since 1.0.0
2522
+			 * @package GeoDirectory
2523
+			 * @param object|array $term category / term object that need to be processed.
2524
+			 * @param string $join The join query.
2525
+			 */
2526
+			$join = apply_filters('geodir_cat_post_count_join', $join, $term);
2527 2527
 
2528
-            /**
2529
-             * Filter to modify the 'where' query
2530
-             *
2531
-             * @since 1.0.0
2532
-             * @package GeoDirectory
2533
-             * @param object|array $term category / term object that need to be processed.
2534
-             * @param string $where The where query.
2535
-             */
2536
-            $where = apply_filters('geodir_cat_post_count_where', $where, $term);
2528
+			/**
2529
+			 * Filter to modify the 'where' query
2530
+			 *
2531
+			 * @since 1.0.0
2532
+			 * @package GeoDirectory
2533
+			 * @param object|array $term category / term object that need to be processed.
2534
+			 * @param string $where The where query.
2535
+			 */
2536
+			$where = apply_filters('geodir_cat_post_count_where', $where, $term);
2537 2537
 
2538
-            $count_query = "SELECT count(post_id) FROM
2538
+			$count_query = "SELECT count(post_id) FROM
2539 2539
 							" . $table . " as pd " . $join . "
2540 2540
 							WHERE pd.post_status='publish' AND FIND_IN_SET('" . $term->term_id . "'," . $term->taxonomy . ") " . $where;
2541 2541
 
2542
-            $cat_post_count = $wpdb->get_var($count_query);
2543
-            if (empty($cat_post_count) || is_wp_error($cat_post_count))
2544
-                $cat_post_count = 0;
2542
+			$cat_post_count = $wpdb->get_var($count_query);
2543
+			if (empty($cat_post_count) || is_wp_error($cat_post_count))
2544
+				$cat_post_count = 0;
2545 2545
 
2546
-            return $cat_post_count;
2546
+			return $cat_post_count;
2547 2547
 
2548
-        } else
2548
+		} else
2549 2549
 
2550
-            return $term->count;
2551
-    }
2552
-    return false;
2550
+			return $term->count;
2551
+	}
2552
+	return false;
2553 2553
 
2554 2554
 }
2555 2555
 
@@ -2562,17 +2562,17 @@  discard block
 block discarded – undo
2562 2562
  */
2563 2563
 function geodir_allow_post_type_frontend()
2564 2564
 {
2565
-    $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
2565
+	$geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
2566 2566
 
2567
-    if (!is_admin() && isset($_REQUEST['listing_type'])
2568
-        && !empty($geodir_allow_posttype_frontend)
2569
-        && !in_array($_REQUEST['listing_type'], $geodir_allow_posttype_frontend)
2570
-    ) {
2567
+	if (!is_admin() && isset($_REQUEST['listing_type'])
2568
+		&& !empty($geodir_allow_posttype_frontend)
2569
+		&& !in_array($_REQUEST['listing_type'], $geodir_allow_posttype_frontend)
2570
+	) {
2571 2571
 
2572
-        wp_redirect(home_url());
2573
-        exit;
2572
+		wp_redirect(home_url());
2573
+		exit;
2574 2574
 
2575
-    }
2575
+	}
2576 2576
 
2577 2577
 }
2578 2578
 
@@ -2589,20 +2589,20 @@  discard block
 block discarded – undo
2589 2589
  */
2590 2590
 function geodir_excerpt_length($length)
2591 2591
 {
2592
-    global $wp_query, $geodir_is_widget_listing;
2592
+	global $wp_query, $geodir_is_widget_listing;
2593 2593
 	if ($geodir_is_widget_listing) {
2594 2594
 		return $length;
2595 2595
 	}
2596 2596
 	
2597
-    if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit'))
2598
-        $length = get_option('geodir_desc_word_limit');
2599
-    elseif (get_query_var('excerpt_length'))
2600
-        $length = get_query_var('excerpt_length');
2597
+	if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit'))
2598
+		$length = get_option('geodir_desc_word_limit');
2599
+	elseif (get_query_var('excerpt_length'))
2600
+		$length = get_query_var('excerpt_length');
2601 2601
 
2602
-    if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit'))
2603
-        $length = get_option('geodir_author_desc_word_limit');
2602
+	if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit'))
2603
+		$length = get_option('geodir_author_desc_word_limit');
2604 2604
 
2605
-    return $length;
2605
+	return $length;
2606 2606
 }
2607 2607
 
2608 2608
 /**
@@ -2617,13 +2617,13 @@  discard block
 block discarded – undo
2617 2617
  */
2618 2618
 function geodir_excerpt_more($more)
2619 2619
 {
2620
-    global $post;
2621
-    $all_postypes = geodir_get_posttypes();
2622
-    if (is_array($all_postypes) && in_array($post->post_type, $all_postypes)) {
2623
-        return ' <a href="' . get_permalink($post->ID) . '">' . READ_MORE_TXT . '</a>';
2624
-    }
2620
+	global $post;
2621
+	$all_postypes = geodir_get_posttypes();
2622
+	if (is_array($all_postypes) && in_array($post->post_type, $all_postypes)) {
2623
+		return ' <a href="' . get_permalink($post->ID) . '">' . READ_MORE_TXT . '</a>';
2624
+	}
2625 2625
 
2626
-    return $more;
2626
+	return $more;
2627 2627
 }
2628 2628
 
2629 2629
 
@@ -2640,63 +2640,63 @@  discard block
 block discarded – undo
2640 2640
  */
2641 2641
 function geodir_update_markers_oncatedit($term_id, $tt_id, $taxonomy)
2642 2642
 {
2643
-    global $plugin_prefix, $wpdb;
2643
+	global $plugin_prefix, $wpdb;
2644 2644
 
2645
-    $gd_taxonomies = geodir_get_taxonomies();
2645
+	$gd_taxonomies = geodir_get_taxonomies();
2646 2646
 
2647
-    if (is_array($gd_taxonomies) && in_array($taxonomy, $gd_taxonomies)) {
2647
+	if (is_array($gd_taxonomies) && in_array($taxonomy, $gd_taxonomies)) {
2648 2648
 
2649
-        $geodir_post_type = geodir_get_taxonomy_posttype($taxonomy);
2650
-        $table = $plugin_prefix . $geodir_post_type . '_detail';
2649
+		$geodir_post_type = geodir_get_taxonomy_posttype($taxonomy);
2650
+		$table = $plugin_prefix . $geodir_post_type . '_detail';
2651 2651
 
2652
-        $path_parts = pathinfo($_REQUEST['ct_cat_icon']['src']);
2653
-        $term_icon = $path_parts['dirname'] . '/cat_icon_' . $term_id . '.png';
2652
+		$path_parts = pathinfo($_REQUEST['ct_cat_icon']['src']);
2653
+		$term_icon = $path_parts['dirname'] . '/cat_icon_' . $term_id . '.png';
2654 2654
 
2655
-        $posts = $wpdb->get_results(
2656
-            $wpdb->prepare(
2657
-                "SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM " . $table . " WHERE FIND_IN_SET(%s,%1\$s ) ",
2658
-                array($term_id, $taxonomy)
2659
-            )
2660
-        );
2655
+		$posts = $wpdb->get_results(
2656
+			$wpdb->prepare(
2657
+				"SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM " . $table . " WHERE FIND_IN_SET(%s,%1\$s ) ",
2658
+				array($term_id, $taxonomy)
2659
+			)
2660
+		);
2661 2661
 
2662
-        if (!empty($posts)):
2663
-            foreach ($posts as $post_obj) {
2662
+		if (!empty($posts)):
2663
+			foreach ($posts as $post_obj) {
2664 2664
 
2665
-                $lat = $post_obj->post_latitude;
2666
-                $lng = $post_obj->post_longitude;
2665
+				$lat = $post_obj->post_latitude;
2666
+				$lng = $post_obj->post_longitude;
2667 2667
 
2668
-                $json = '{';
2669
-                $json .= '"id":"' . $post_obj->post_id . '",';
2670
-                $json .= '"lat_pos": "' . $lat . '",';
2671
-                $json .= '"long_pos": "' . $lng . '",';
2672
-                $json .= '"marker_id":"' . $post_obj->post_id . '_' . $term_id . '",';
2673
-                $json .= '"icon":"' . $term_icon . '",';
2674
-                $json .= '"group":"catgroup' . $term_id . '"';
2675
-                $json .= '}';
2668
+				$json = '{';
2669
+				$json .= '"id":"' . $post_obj->post_id . '",';
2670
+				$json .= '"lat_pos": "' . $lat . '",';
2671
+				$json .= '"long_pos": "' . $lng . '",';
2672
+				$json .= '"marker_id":"' . $post_obj->post_id . '_' . $term_id . '",';
2673
+				$json .= '"icon":"' . $term_icon . '",';
2674
+				$json .= '"group":"catgroup' . $term_id . '"';
2675
+				$json .= '}';
2676 2676
 
2677
-                if ($post_obj->default_category == $term_id) {
2677
+				if ($post_obj->default_category == $term_id) {
2678 2678
 
2679
-                    $wpdb->query(
2680
-                        $wpdb->prepare(
2681
-                            "UPDATE " . $table . " SET marker_json = %s where post_id = %d",
2682
-                            array($json, $post_obj->post_id)
2683
-                        )
2684
-                    );
2685
-                }
2679
+					$wpdb->query(
2680
+						$wpdb->prepare(
2681
+							"UPDATE " . $table . " SET marker_json = %s where post_id = %d",
2682
+							array($json, $post_obj->post_id)
2683
+						)
2684
+					);
2685
+				}
2686 2686
 
2687
-                $wpdb->query(
2688
-                    $wpdb->prepare(
2689
-                        "UPDATE " . GEODIR_ICON_TABLE . " SET json = %s WHERE post_id = %d AND cat_id = %d",
2690
-                        array($json, $post_obj->post_id, $term_id)
2691
-                    )
2692
-                );
2687
+				$wpdb->query(
2688
+					$wpdb->prepare(
2689
+						"UPDATE " . GEODIR_ICON_TABLE . " SET json = %s WHERE post_id = %d AND cat_id = %d",
2690
+						array($json, $post_obj->post_id, $term_id)
2691
+					)
2692
+				);
2693 2693
 
2694
-            }
2694
+			}
2695 2695
 
2696 2696
 
2697
-        endif;
2697
+		endif;
2698 2698
 
2699
-    }
2699
+	}
2700 2700
 
2701 2701
 }
2702 2702
 
@@ -2710,14 +2710,14 @@  discard block
 block discarded – undo
2710 2710
  */
2711 2711
 function geodir_get_listing_author($listing_id = '')
2712 2712
 {
2713
-    if ($listing_id == '') {
2714
-        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
2715
-            $listing_id = $_REQUEST['pid'];
2716
-        }
2717
-    }
2718
-    $listing = get_post(strip_tags($listing_id));
2719
-    $listing_author_id = $listing->post_author;
2720
-    return $listing_author_id;
2713
+	if ($listing_id == '') {
2714
+		if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
2715
+			$listing_id = $_REQUEST['pid'];
2716
+		}
2717
+	}
2718
+	$listing = get_post(strip_tags($listing_id));
2719
+	$listing_author_id = $listing->post_author;
2720
+	return $listing_author_id;
2721 2721
 }
2722 2722
 
2723 2723
 
@@ -2732,11 +2732,11 @@  discard block
 block discarded – undo
2732 2732
  */
2733 2733
 function geodir_lisiting_belong_to_user($listing_id, $user_id)
2734 2734
 {
2735
-    $listing_author_id = geodir_get_listing_author($listing_id);
2736
-    if ($listing_author_id == $user_id)
2737
-        return true;
2738
-    else
2739
-        return false;
2735
+	$listing_author_id = geodir_get_listing_author($listing_id);
2736
+	if ($listing_author_id == $user_id)
2737
+		return true;
2738
+	else
2739
+		return false;
2740 2740
 
2741 2741
 }
2742 2742
 
@@ -2752,17 +2752,17 @@  discard block
 block discarded – undo
2752 2752
  */
2753 2753
 function geodir_listing_belong_to_current_user($listing_id = '', $exclude_admin = true)
2754 2754
 {
2755
-    global $current_user;
2756
-    if ($exclude_admin) {
2757
-        foreach ($current_user->caps as $key => $caps) {
2758
-            if (geodir_strtolower($key) == 'administrator') {
2759
-                return true;
2760
-                break;
2761
-            }
2762
-        }
2763
-    }
2764
-
2765
-    return geodir_lisiting_belong_to_user($listing_id, $current_user->ID);
2755
+	global $current_user;
2756
+	if ($exclude_admin) {
2757
+		foreach ($current_user->caps as $key => $caps) {
2758
+			if (geodir_strtolower($key) == 'administrator') {
2759
+				return true;
2760
+				break;
2761
+			}
2762
+		}
2763
+	}
2764
+
2765
+	return geodir_lisiting_belong_to_user($listing_id, $current_user->ID);
2766 2766
 }
2767 2767
 
2768 2768
 
@@ -2778,17 +2778,17 @@  discard block
 block discarded – undo
2778 2778
 function geodir_only_supportable_attachments_remove($file)
2779 2779
 {
2780 2780
 
2781
-    global $wpdb;
2781
+	global $wpdb;
2782 2782
 
2783
-    $matches = array();
2783
+	$matches = array();
2784 2784
 
2785
-    $pattern = '/-\d+x\d+\./';
2786
-    preg_match($pattern, $file, $matches, PREG_OFFSET_CAPTURE);
2785
+	$pattern = '/-\d+x\d+\./';
2786
+	preg_match($pattern, $file, $matches, PREG_OFFSET_CAPTURE);
2787 2787
 
2788
-    if (empty($matches))
2789
-        return '';
2790
-    else
2791
-        return $file;
2788
+	if (empty($matches))
2789
+		return '';
2790
+	else
2791
+		return $file;
2792 2792
 
2793 2793
 }
2794 2794
 
@@ -2805,78 +2805,78 @@  discard block
 block discarded – undo
2805 2805
 function geodir_set_wp_featured_image($post_id)
2806 2806
 {
2807 2807
 
2808
-    global $wpdb, $plugin_prefix;
2809
-    $uploads = wp_upload_dir();
2808
+	global $wpdb, $plugin_prefix;
2809
+	$uploads = wp_upload_dir();
2810 2810
 //	print_r($uploads ) ;
2811
-    $post_first_image = $wpdb->get_results(
2812
-        $wpdb->prepare(
2813
-            "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d and menu_order = 1  ", array($post_id)
2814
-        )
2815
-    );
2816
-
2817
-    $old_attachment_name = '';
2818
-    $post_thumbnail_id = '';
2819
-    if (has_post_thumbnail($post_id)) {
2811
+	$post_first_image = $wpdb->get_results(
2812
+		$wpdb->prepare(
2813
+			"SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d and menu_order = 1  ", array($post_id)
2814
+		)
2815
+	);
2820 2816
 
2821
-        if (has_post_thumbnail($post_id)) {
2817
+	$old_attachment_name = '';
2818
+	$post_thumbnail_id = '';
2819
+	if (has_post_thumbnail($post_id)) {
2822 2820
 
2823
-            $post_thumbnail_id = get_post_thumbnail_id($post_id);
2821
+		if (has_post_thumbnail($post_id)) {
2824 2822
 
2825
-            $old_attachment_name = basename(get_attached_file($post_thumbnail_id));
2823
+			$post_thumbnail_id = get_post_thumbnail_id($post_id);
2826 2824
 
2827
-        }
2828
-    }
2825
+			$old_attachment_name = basename(get_attached_file($post_thumbnail_id));
2829 2826
 
2830
-    if (!empty($post_first_image)) {
2827
+		}
2828
+	}
2831 2829
 
2832
-        $post_type = get_post_type($post_id);
2830
+	if (!empty($post_first_image)) {
2833 2831
 
2834
-        $table_name = $plugin_prefix . $post_type . '_detail';
2832
+		$post_type = get_post_type($post_id);
2835 2833
 
2836
-        $wpdb->query("UPDATE " . $table_name . " SET featured_image='" . $post_first_image[0]->file . "' WHERE post_id =" . $post_id);
2834
+		$table_name = $plugin_prefix . $post_type . '_detail';
2837 2835
 
2838
-        $new_attachment_name = basename($post_first_image[0]->file);
2836
+		$wpdb->query("UPDATE " . $table_name . " SET featured_image='" . $post_first_image[0]->file . "' WHERE post_id =" . $post_id);
2839 2837
 
2840
-        if (geodir_strtolower($new_attachment_name) != geodir_strtolower($old_attachment_name)) {
2838
+		$new_attachment_name = basename($post_first_image[0]->file);
2841 2839
 
2842
-            if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) {
2840
+		if (geodir_strtolower($new_attachment_name) != geodir_strtolower($old_attachment_name)) {
2843 2841
 
2844
-                add_filter('wp_delete_file', 'geodir_only_supportable_attachments_remove');
2842
+			if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) {
2845 2843
 
2846
-                wp_delete_attachment($post_thumbnail_id);
2844
+				add_filter('wp_delete_file', 'geodir_only_supportable_attachments_remove');
2847 2845
 
2848
-            }
2849
-            $filename = $uploads['basedir'] . $post_first_image[0]->file;
2846
+				wp_delete_attachment($post_thumbnail_id);
2850 2847
 
2851
-            $attachment = array(
2852
-                'post_mime_type' => $post_first_image[0]->mime_type,
2853
-                'guid' => $uploads['baseurl'] . $post_first_image[0]->file,
2854
-                'post_parent' => $post_id,
2855
-                'post_title' => preg_replace('/\.[^.]+$/', '', $post_first_image[0]->title),
2856
-                'post_content' => ''
2857
-            );
2848
+			}
2849
+			$filename = $uploads['basedir'] . $post_first_image[0]->file;
2850
+
2851
+			$attachment = array(
2852
+				'post_mime_type' => $post_first_image[0]->mime_type,
2853
+				'guid' => $uploads['baseurl'] . $post_first_image[0]->file,
2854
+				'post_parent' => $post_id,
2855
+				'post_title' => preg_replace('/\.[^.]+$/', '', $post_first_image[0]->title),
2856
+				'post_content' => ''
2857
+			);
2858 2858
 
2859 2859
 
2860
-            $id = wp_insert_attachment($attachment, $filename, $post_id);
2860
+			$id = wp_insert_attachment($attachment, $filename, $post_id);
2861 2861
 
2862
-            if (!is_wp_error($id)) {
2862
+			if (!is_wp_error($id)) {
2863 2863
 
2864
-                set_post_thumbnail($post_id, $id);
2864
+				set_post_thumbnail($post_id, $id);
2865 2865
 
2866
-                require_once(ABSPATH . 'wp-admin/includes/image.php');
2867
-                wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename));
2866
+				require_once(ABSPATH . 'wp-admin/includes/image.php');
2867
+				wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename));
2868 2868
 
2869
-            }
2869
+			}
2870 2870
 
2871
-        }
2871
+		}
2872 2872
 
2873
-    } else {
2874
-        //set_post_thumbnail($post_id,-1);
2873
+	} else {
2874
+		//set_post_thumbnail($post_id,-1);
2875 2875
 
2876
-        if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete'))
2877
-            wp_delete_attachment($post_thumbnail_id);
2876
+		if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete'))
2877
+			wp_delete_attachment($post_thumbnail_id);
2878 2878
 
2879
-    }
2879
+	}
2880 2880
 }
2881 2881
 
2882 2882
 
@@ -2891,53 +2891,53 @@  discard block
 block discarded – undo
2891 2891
  */
2892 2892
 function gd_copy_original_translation()
2893 2893
 {
2894
-    if (function_exists('icl_object_id')) {
2895
-        global $wpdb, $table_prefix, $plugin_prefix;
2896
-        $post_id = absint($_POST['post_id']);
2897
-        $upload_dir = wp_upload_dir();
2898
-        $post_type = get_post_type($_POST['post_id']);
2899
-        $table = $plugin_prefix . $post_type . '_detail';
2900
-
2901
-        $post_arr = $wpdb->get_results($wpdb->prepare(
2902
-            "SELECT * FROM $wpdb->posts p JOIN " . $table . " gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1",
2903
-            array($post_id)
2904
-        )
2905
-            , ARRAY_A);
2906
-
2907
-        $arrImages = $wpdb->get_results(
2908
-            $wpdb->prepare(
2909
-                "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ",
2910
-                array('%image%', $post_id)
2911
-            )
2912
-        );
2913
-        if ($arrImages) {
2914
-            $image_arr = array();
2915
-            foreach ($arrImages as $img) {
2916
-                $image_arr[] = $upload_dir['baseurl'] . $img->file;
2917
-            }
2918
-            $comma_separated = implode(",", $image_arr);
2919
-            $post_arr[0]['post_images'] = $comma_separated;
2920
-        }
2921
-
2922
-
2923
-        $cats = $post_arr[0][$post_arr[0]['post_type'] . 'category'];
2924
-        $cat_arr = array_filter(explode(",", $cats));
2925
-        $trans_cat = array();
2926
-        foreach ($cat_arr as $cat) {
2927
-            $trans_cat[] = icl_object_id($cat, $post_arr[0]['post_type'] . 'category', false);
2928
-        }
2929
-
2930
-
2931
-        $post_arr[0]['categories'] = array_filter($trans_cat);
2894
+	if (function_exists('icl_object_id')) {
2895
+		global $wpdb, $table_prefix, $plugin_prefix;
2896
+		$post_id = absint($_POST['post_id']);
2897
+		$upload_dir = wp_upload_dir();
2898
+		$post_type = get_post_type($_POST['post_id']);
2899
+		$table = $plugin_prefix . $post_type . '_detail';
2900
+
2901
+		$post_arr = $wpdb->get_results($wpdb->prepare(
2902
+			"SELECT * FROM $wpdb->posts p JOIN " . $table . " gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1",
2903
+			array($post_id)
2904
+		)
2905
+			, ARRAY_A);
2906
+
2907
+		$arrImages = $wpdb->get_results(
2908
+			$wpdb->prepare(
2909
+				"SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ",
2910
+				array('%image%', $post_id)
2911
+			)
2912
+		);
2913
+		if ($arrImages) {
2914
+			$image_arr = array();
2915
+			foreach ($arrImages as $img) {
2916
+				$image_arr[] = $upload_dir['baseurl'] . $img->file;
2917
+			}
2918
+			$comma_separated = implode(",", $image_arr);
2919
+			$post_arr[0]['post_images'] = $comma_separated;
2920
+		}
2921
+
2922
+
2923
+		$cats = $post_arr[0][$post_arr[0]['post_type'] . 'category'];
2924
+		$cat_arr = array_filter(explode(",", $cats));
2925
+		$trans_cat = array();
2926
+		foreach ($cat_arr as $cat) {
2927
+			$trans_cat[] = icl_object_id($cat, $post_arr[0]['post_type'] . 'category', false);
2928
+		}
2929
+
2930
+
2931
+		$post_arr[0]['categories'] = array_filter($trans_cat);
2932 2932
 //print_r($image_arr);
2933
-        //print_r($arrImages);
2934
-        //echo $_REQUEST['lang'];
2933
+		//print_r($arrImages);
2934
+		//echo $_REQUEST['lang'];
2935 2935
 //print_r($post_arr);
2936 2936
 //print_r($trans_cat);
2937
-        echo json_encode($post_arr[0]);
2937
+		echo json_encode($post_arr[0]);
2938 2938
 
2939
-    }
2940
-    die();
2939
+	}
2940
+	die();
2941 2941
 }
2942 2942
 
2943 2943
 
@@ -2957,54 +2957,54 @@  discard block
 block discarded – undo
2957 2957
 function geodir_get_custom_fields_type($listing_type = '')
2958 2958
 {
2959 2959
 
2960
-    global $wpdb;
2960
+	global $wpdb;
2961 2961
 
2962
-    if ($listing_type == '')
2963
-        $listing_type = 'gd_place';
2962
+	if ($listing_type == '')
2963
+		$listing_type = 'gd_place';
2964 2964
 
2965
-    $fields_info = array();
2965
+	$fields_info = array();
2966 2966
 
2967
-    $get_data = $wpdb->get_results(
2968
-        $wpdb->prepare(
2969
-            "SELECT htmlvar_name, field_type, extra_fields FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1'",
2970
-            array($listing_type)
2971
-        )
2972
-    );
2967
+	$get_data = $wpdb->get_results(
2968
+		$wpdb->prepare(
2969
+			"SELECT htmlvar_name, field_type, extra_fields FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1'",
2970
+			array($listing_type)
2971
+		)
2972
+	);
2973 2973
 
2974
-    if (!empty($get_data)) {
2974
+	if (!empty($get_data)) {
2975 2975
 
2976
-        foreach ($get_data as $data) {
2976
+		foreach ($get_data as $data) {
2977 2977
 
2978
-            if ($data->field_type == 'address') {
2978
+			if ($data->field_type == 'address') {
2979 2979
 
2980
-                $extra_fields = unserialize($data->extra_fields);
2980
+				$extra_fields = unserialize($data->extra_fields);
2981 2981
 
2982
-                $prefix = $data->htmlvar_name . '_';
2982
+				$prefix = $data->htmlvar_name . '_';
2983 2983
 
2984
-                $fields_info[$prefix . 'address'] = $data->field_type;
2984
+				$fields_info[$prefix . 'address'] = $data->field_type;
2985 2985
 
2986
-                if (isset($extra_fields['show_zip']) && $extra_fields['show_zip'])
2987
-                    $fields_info[$prefix . 'zip'] = $data->field_type;
2986
+				if (isset($extra_fields['show_zip']) && $extra_fields['show_zip'])
2987
+					$fields_info[$prefix . 'zip'] = $data->field_type;
2988 2988
 
2989
-            } else {
2989
+			} else {
2990 2990
 
2991
-                $fields_info[$data->htmlvar_name] = $data->field_type;
2991
+				$fields_info[$data->htmlvar_name] = $data->field_type;
2992 2992
 
2993
-            }
2993
+			}
2994 2994
 
2995
-        }
2995
+		}
2996 2996
 
2997
-    }
2997
+	}
2998 2998
 
2999
-    /**
3000
-     * Filter to modify custom fields info using listing post type.
3001
-     *
3002
-     * @since 1.0.0
3003
-     * @package GeoDirectory
3004
-     * @return array $fields_info Custom fields info.
3005
-     * @param string $listing_type The listing post type.
3006
-     */
3007
-    return apply_filters('geodir_get_custom_fields_type', $fields_info, $listing_type);
2999
+	/**
3000
+	 * Filter to modify custom fields info using listing post type.
3001
+	 *
3002
+	 * @since 1.0.0
3003
+	 * @package GeoDirectory
3004
+	 * @return array $fields_info Custom fields info.
3005
+	 * @param string $listing_type The listing post type.
3006
+	 */
3007
+	return apply_filters('geodir_get_custom_fields_type', $fields_info, $listing_type);
3008 3008
 }
3009 3009
 
3010 3010
 
@@ -3019,58 +3019,58 @@  discard block
 block discarded – undo
3019 3019
  */
3020 3020
 function geodir_function_post_updated($post_ID, $post_after, $post_before)
3021 3021
 {
3022
-    $post_type = get_post_type($post_ID);
3022
+	$post_type = get_post_type($post_ID);
3023 3023
 
3024
-    if ($post_type != '' && in_array($post_type, geodir_get_posttypes())) {
3025
-        // send notification to client when post moves from draft to publish
3026
-        if (!empty($post_after->post_status) && $post_after->post_status == 'publish' && !empty($post_before->post_status) && ($post_before->post_status == 'draft' || $post_before->post_status == 'auto-draft')) {
3027
-            $post_author_id = !empty($post_after->post_author) ? $post_after->post_author : NULL;
3028
-            $post_author_data = get_userdata($post_author_id);
3024
+	if ($post_type != '' && in_array($post_type, geodir_get_posttypes())) {
3025
+		// send notification to client when post moves from draft to publish
3026
+		if (!empty($post_after->post_status) && $post_after->post_status == 'publish' && !empty($post_before->post_status) && ($post_before->post_status == 'draft' || $post_before->post_status == 'auto-draft')) {
3027
+			$post_author_id = !empty($post_after->post_author) ? $post_after->post_author : NULL;
3028
+			$post_author_data = get_userdata($post_author_id);
3029 3029
 
3030
-            $to_name = geodir_get_client_name($post_author_id);
3030
+			$to_name = geodir_get_client_name($post_author_id);
3031 3031
 
3032
-            $from_email = geodir_get_site_email_id();
3033
-            $from_name = get_site_emailName();
3034
-            $to_email = $post_author_data->user_email;
3032
+			$from_email = geodir_get_site_email_id();
3033
+			$from_name = get_site_emailName();
3034
+			$to_email = $post_author_data->user_email;
3035 3035
 
3036
-            if (!is_email($to_email) && !empty($post_author_data->user_email)) {
3037
-                $to_email = $post_author_data->user_email;
3038
-            }
3036
+			if (!is_email($to_email) && !empty($post_author_data->user_email)) {
3037
+				$to_email = $post_author_data->user_email;
3038
+			}
3039 3039
 
3040
-            $message_type = 'listing_published';
3040
+			$message_type = 'listing_published';
3041 3041
 
3042
-            if (get_option('geodir_post_published_email_subject') == '') {
3043
-                update_option('geodir_post_published_email_subject', __('Listing Published Successfully', 'geodirectory'));
3044
-            }
3042
+			if (get_option('geodir_post_published_email_subject') == '') {
3043
+				update_option('geodir_post_published_email_subject', __('Listing Published Successfully', 'geodirectory'));
3044
+			}
3045 3045
 
3046
-            if (get_option('geodir_post_published_email_content') == '') {
3047
-                update_option('geodir_post_published_email_content', __("<p>Dear [#client_name#],</p><p>Your listing [#listing_link#] has been published. This email is just for your information.</p><p>[#listing_link#]</p><br><p>Thank you for your contribution.</p><p>[#site_name#]</p>", 'geodirectory'));
3048
-            }
3046
+			if (get_option('geodir_post_published_email_content') == '') {
3047
+				update_option('geodir_post_published_email_content', __("<p>Dear [#client_name#],</p><p>Your listing [#listing_link#] has been published. This email is just for your information.</p><p>[#listing_link#]</p><br><p>Thank you for your contribution.</p><p>[#site_name#]</p>", 'geodirectory'));
3048
+			}
3049 3049
 
3050
-            /**
3051
-             * Called before sending the email when listing gets published.
3052
-             *
3053
-             * @since 1.0.0
3054
-             * @package GeoDirectory
3055
-             * @param object $post_after The post object after update.
3056
-             * @param object $post_before The post object before update.
3057
-             */
3058
-            do_action('geodir_before_listing_published_email', $post_after, $post_before);
3059
-            if (is_email($to_email)) {
3060
-                geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID);
3061
-            }
3050
+			/**
3051
+			 * Called before sending the email when listing gets published.
3052
+			 *
3053
+			 * @since 1.0.0
3054
+			 * @package GeoDirectory
3055
+			 * @param object $post_after The post object after update.
3056
+			 * @param object $post_before The post object before update.
3057
+			 */
3058
+			do_action('geodir_before_listing_published_email', $post_after, $post_before);
3059
+			if (is_email($to_email)) {
3060
+				geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID);
3061
+			}
3062 3062
 
3063
-            /**
3064
-             * Called after sending the email when listing gets published.
3065
-             *
3066
-             * @since 1.0.0
3067
-             * @package GeoDirectory
3068
-             * @param object $post_after The post object after update.
3069
-             * @param object $post_before The post object before update.
3070
-             */
3071
-            do_action('geodir_after_listing_published_email', $post_after, $post_before);
3072
-        }
3073
-    }
3063
+			/**
3064
+			 * Called after sending the email when listing gets published.
3065
+			 *
3066
+			 * @since 1.0.0
3067
+			 * @package GeoDirectory
3068
+			 * @param object $post_after The post object after update.
3069
+			 * @param object $post_before The post object before update.
3070
+			 */
3071
+			do_action('geodir_after_listing_published_email', $post_after, $post_before);
3072
+		}
3073
+	}
3074 3074
 }
3075 3075
 
3076 3076
 add_action('wp_head', 'geodir_fb_like_thumbnail');
@@ -3084,14 +3084,14 @@  discard block
 block discarded – undo
3084 3084
  */
3085 3085
 function geodir_fb_like_thumbnail(){
3086 3086
 
3087
-    // return if not a single post
3088
-    if(!is_single()){return;}
3087
+	// return if not a single post
3088
+	if(!is_single()){return;}
3089 3089
 
3090
-    global $post;
3091
-    if(isset($post->featured_image) && $post->featured_image){
3092
-        $upload_dir = wp_upload_dir();
3093
-        $thumb = $upload_dir['baseurl'].$post->featured_image;
3094
-        echo "\n\n<!-- GD Facebook Like Thumbnail -->\n<link rel=\"image_src\" href=\"$thumb\" />\n<!-- End GD Facebook Like Thumbnail -->\n\n";
3090
+	global $post;
3091
+	if(isset($post->featured_image) && $post->featured_image){
3092
+		$upload_dir = wp_upload_dir();
3093
+		$thumb = $upload_dir['baseurl'].$post->featured_image;
3094
+		echo "\n\n<!-- GD Facebook Like Thumbnail -->\n<link rel=\"image_src\" href=\"$thumb\" />\n<!-- End GD Facebook Like Thumbnail -->\n\n";
3095 3095
 
3096
-    }
3096
+	}
3097 3097
 }
3098 3098
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +204 added lines, -204 removed lines patch added patch discarded remove patch
@@ -26,11 +26,11 @@  discard block
 block discarded – undo
26 26
 
27 27
     if (!isset($default_cat) || empty($default_cat)) {
28 28
         $default_cat = isset($post_cat_array[0]) ? $post_cat_array[0] : '';
29
-    }else{
30
-        if(!is_int($default_cat)){
29
+    } else {
30
+        if (!is_int($default_cat)) {
31 31
             $category = get_term_by('name', $default_cat, $taxonomy);
32
-            if(isset($category->term_id)){
33
-                $default_cat =  $category->term_id;
32
+            if (isset($category->term_id)) {
33
+                $default_cat = $category->term_id;
34 34
             }
35 35
         }
36 36
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 
59 59
     if ($default_pos === false) {
60 60
 
61
-        $change_cat_str = str_replace($default_cat . ',y:', $default_cat . ',y,d:', $change_cat_str);
61
+        $change_cat_str = str_replace($default_cat.',y:', $default_cat.',y,d:', $change_cat_str);
62 62
 
63 63
     }
64 64
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
             
145 145
             $gd_post = $post;
146 146
             if (!empty($gd_post) && is_array($gd_post)) {
147
-                $gd_post = (object)$post;
147
+                $gd_post = (object) $post;
148 148
                 
149 149
                 // Fix WPML duplicate.
150 150
                 if (geodir_is_wpml() && !empty($request_info['action']) && $request_info['action'] == 'editpost' && !empty($request_info['icl_trid']) && !isset($post['post_date'])) {
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
         $send_post_submit_mail = false;
239 239
 
240 240
         // unhook this function so it doesn't loop infinitely
241
-        remove_action('save_post', 'geodir_post_information_save',10,2);
241
+        remove_action('save_post', 'geodir_post_information_save', 10, 2);
242 242
 
243 243
         if (isset($request_info['pid']) && $request_info['pid'] != '') {
244 244
             $post['ID'] = $request_info['pid'];
@@ -262,13 +262,13 @@  discard block
 block discarded – undo
262 262
         }
263 263
 
264 264
         // re-hook this function
265
-        add_action('save_post', 'geodir_post_information_save',10,2);
265
+        add_action('save_post', 'geodir_post_information_save', 10, 2);
266 266
 
267 267
         $post_tags = '';
268 268
         if (!isset($request_info['post_tags'])) {
269 269
 
270 270
             $post_type = $request_info['listing_type'];
271
-            $post_tags = implode(",", wp_get_object_terms($last_post_id, $post_type . '_tags', array('fields' => 'names')));
271
+            $post_tags = implode(",", wp_get_object_terms($last_post_id, $post_type.'_tags', array('fields' => 'names')));
272 272
 
273 273
         }
274 274
 
@@ -286,13 +286,13 @@  discard block
 block discarded – undo
286 286
         $payment_info = array();
287 287
         $package_info = array();
288 288
 
289
-        $package_info = (array)geodir_post_package_info($package_info, $post);
289
+        $package_info = (array) geodir_post_package_info($package_info, $post);
290 290
 
291 291
         $post_package_id = geodir_get_post_meta($last_post_id, 'package_id');
292 292
 
293 293
         if (!empty($package_info) && !$post_package_id) {
294 294
             if (isset($package_info['days']) && $package_info['days'] != 0) {
295
-                $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['days'] . " days"));
295
+                $payment_info['expire_date'] = date('Y-m-d', strtotime("+".$package_info['days']." days"));
296 296
             } else {
297 297
                 $payment_info['expire_date'] = 'Never';
298 298
             }
@@ -313,8 +313,8 @@  discard block
 block discarded – undo
313 313
             $extrafields = $val['extra_fields'];
314 314
 
315 315
             if (trim($type) == 'address') {
316
-                $prefix = $name . '_';
317
-                $address = $prefix . 'address';
316
+                $prefix = $name.'_';
317
+                $address = $prefix.'address';
318 318
 
319 319
                 if (isset($request_info[$address]) && $request_info[$address] != '') {
320 320
                     $gd_post_info[$address] = wp_slash($request_info[$address]);
@@ -324,59 +324,59 @@  discard block
 block discarded – undo
324 324
                     $extrafields = unserialize($extrafields);
325 325
 
326 326
 
327
-                    if (!isset($request_info[$prefix . 'city']) || $request_info[$prefix . 'city'] == '') {
327
+                    if (!isset($request_info[$prefix.'city']) || $request_info[$prefix.'city'] == '') {
328 328
 
329 329
                         $location_result = geodir_get_default_location();
330 330
 
331
-                        $gd_post_info[$prefix . 'city'] = $location_result->city;
332
-                        $gd_post_info[$prefix . 'region'] = $location_result->region;
333
-                        $gd_post_info[$prefix . 'country'] = $location_result->country;
331
+                        $gd_post_info[$prefix.'city'] = $location_result->city;
332
+                        $gd_post_info[$prefix.'region'] = $location_result->region;
333
+                        $gd_post_info[$prefix.'country'] = $location_result->country;
334 334
 
335
-                        $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location
335
+                        $gd_post_info['post_locations'] = '['.$location_result->city_slug.'],['.$location_result->region_slug.'],['.$location_result->country_slug.']'; // set all overall post location
336 336
 
337 337
                     } else {
338 338
 
339
-                        $gd_post_info[$prefix . 'city'] = $request_info[$prefix . 'city'];
340
-                        $gd_post_info[$prefix . 'region'] = $request_info[$prefix . 'region'];
341
-                        $gd_post_info[$prefix . 'country'] = $request_info[$prefix . 'country'];
339
+                        $gd_post_info[$prefix.'city'] = $request_info[$prefix.'city'];
340
+                        $gd_post_info[$prefix.'region'] = $request_info[$prefix.'region'];
341
+                        $gd_post_info[$prefix.'country'] = $request_info[$prefix.'country'];
342 342
 
343 343
                         //----------set post locations when import dummy data-------
344 344
                         $location_result = geodir_get_default_location();
345 345
 
346
-                        $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location
346
+                        $gd_post_info['post_locations'] = '['.$location_result->city_slug.'],['.$location_result->region_slug.'],['.$location_result->country_slug.']'; // set all overall post location
347 347
                         //-----------------------------------------------------------------
348 348
 
349 349
                     }
350 350
 
351 351
 
352
-                    if (isset($extrafields['show_zip']) && $extrafields['show_zip'] && isset($request_info[$prefix . 'zip'])) {
353
-                        $gd_post_info[$prefix . 'zip'] = $request_info[$prefix . 'zip'];
352
+                    if (isset($extrafields['show_zip']) && $extrafields['show_zip'] && isset($request_info[$prefix.'zip'])) {
353
+                        $gd_post_info[$prefix.'zip'] = $request_info[$prefix.'zip'];
354 354
                     }
355 355
 
356 356
 
357 357
                     if (isset($extrafields['show_map']) && $extrafields['show_map']) {
358 358
 
359
-                        if (isset($request_info[$prefix . 'latitude']) && $request_info[$prefix . 'latitude'] != '') {
360
-                            $gd_post_info[$prefix . 'latitude'] = $request_info[$prefix . 'latitude'];
359
+                        if (isset($request_info[$prefix.'latitude']) && $request_info[$prefix.'latitude'] != '') {
360
+                            $gd_post_info[$prefix.'latitude'] = $request_info[$prefix.'latitude'];
361 361
                         }
362 362
 
363
-                        if (isset($request_info[$prefix . 'longitude']) && $request_info[$prefix . 'longitude'] != '') {
364
-                            $gd_post_info[$prefix . 'longitude'] = $request_info[$prefix . 'longitude'];
363
+                        if (isset($request_info[$prefix.'longitude']) && $request_info[$prefix.'longitude'] != '') {
364
+                            $gd_post_info[$prefix.'longitude'] = $request_info[$prefix.'longitude'];
365 365
                         }
366 366
 
367
-                        if (isset($request_info[$prefix . 'mapview']) && $request_info[$prefix . 'mapview'] != '') {
368
-                            $gd_post_info[$prefix . 'mapview'] = $request_info[$prefix . 'mapview'];
367
+                        if (isset($request_info[$prefix.'mapview']) && $request_info[$prefix.'mapview'] != '') {
368
+                            $gd_post_info[$prefix.'mapview'] = $request_info[$prefix.'mapview'];
369 369
                         }
370 370
 
371
-                        if (isset($request_info[$prefix . 'mapzoom']) && $request_info[$prefix . 'mapzoom'] != '') {
372
-                            $gd_post_info[$prefix . 'mapzoom'] = $request_info[$prefix . 'mapzoom'];
371
+                        if (isset($request_info[$prefix.'mapzoom']) && $request_info[$prefix.'mapzoom'] != '') {
372
+                            $gd_post_info[$prefix.'mapzoom'] = $request_info[$prefix.'mapzoom'];
373 373
                         }
374 374
 
375 375
                     }
376 376
 
377 377
                     // show lat lng
378
-                    if (isset($extrafields['show_latlng']) && $extrafields['show_latlng'] && isset($request_info[$prefix . 'latlng'])) {
379
-                        $gd_post_info[$prefix . 'latlng'] = $request_info[$prefix . 'latlng'];
378
+                    if (isset($extrafields['show_latlng']) && $extrafields['show_latlng'] && isset($request_info[$prefix.'latlng'])) {
379
+                        $gd_post_info[$prefix.'latlng'] = $request_info[$prefix.'latlng'];
380 380
                     }
381 381
                 }
382 382
 
@@ -401,16 +401,16 @@  discard block
 block discarded – undo
401 401
 
402 402
                     // check if we need to change the format or not
403 403
                     $date_format_len = strlen(str_replace(' ', '', $date_format));
404
-                    if($date_format_len>5){// if greater then 5 then it's the old style format.
404
+                    if ($date_format_len > 5) {// if greater then 5 then it's the old style format.
405 405
 
406
-                        $search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format
407
-                        $replace = array('d','j','l','m','n','F','Y');//PHP date format
406
+                        $search = array('dd', 'd', 'DD', 'mm', 'm', 'MM', 'yy'); //jQuery UI datepicker format
407
+                        $replace = array('d', 'j', 'l', 'm', 'n', 'F', 'Y'); //PHP date format
408 408
 
409 409
                         $date_format = str_replace($search, $replace, $date_format);
410 410
 
411 411
                         $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $request_info[$name]) : $request_info[$name];
412 412
 
413
-                    }else{
413
+                    } else {
414 414
                         $post_htmlvar_value = $request_info[$name];
415 415
                     }
416 416
 
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
                 if (isset($request_info[$name])) {
426 426
                     $gd_post_info[$name] = $request_info[$name];
427 427
                 } else {
428
-                    if (isset($request_info['gd_field_' . $name])) {
428
+                    if (isset($request_info['gd_field_'.$name])) {
429 429
                         $gd_post_info[$name] = ''; /* fix de-select for multiselect */
430 430
                     }
431 431
                 }
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
         }
486 486
 
487 487
         if (is_array($post_tags)) {
488
-            $taxonomy = $request_info['listing_type'] . '_tags';
488
+            $taxonomy = $request_info['listing_type'].'_tags';
489 489
             wp_set_object_terms($last_post_id, $post_tags, $taxonomy);
490 490
         }
491 491
 
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
                 $tmpimgArr = trim($request_info['post_images'], ",");
498 498
                 $tmpimgArr = explode(",", $tmpimgArr);
499 499
                 geodir_save_post_images($last_post_id, $tmpimgArr, $dummy);
500
-            } else{
500
+            } else {
501 501
                 geodir_save_post_images($last_post_id, $request_info['post_images'], $dummy);
502 502
             }
503 503
 
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
     if (!in_array($post_type, $all_postypes))
579 579
         return false;
580 580
 
581
-    $table = $plugin_prefix . $post_type . '_detail';
581
+    $table = $plugin_prefix.$post_type.'_detail';
582 582
 
583 583
     /**
584 584
      * Apply Filter to change Post info
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
      * @since 1.0.0
589 589
      * @package GeoDirectory
590 590
      */
591
-    $query = apply_filters('geodir_post_info_query', "SELECT p.*,pd.* FROM " . $wpdb->posts . " p," . $table . " pd
591
+    $query = apply_filters('geodir_post_info_query', "SELECT p.*,pd.* FROM ".$wpdb->posts." p,".$table." pd
592 592
 			  WHERE p.ID = pd.post_id
593 593
 			  AND post_id = " . $post_id);
594 594
 
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
 
652 652
         $post_type = get_post_type($post_id);
653 653
 
654
-        $table = $plugin_prefix . $post_type . '_detail';
654
+        $table = $plugin_prefix.$post_type.'_detail';
655 655
 
656 656
         /**
657 657
          * Filter to change Post info
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
 
673 673
             $columns = $wpdb->get_col("show columns from $table");
674 674
             foreach ($postmeta as $mkey => $mval) {
675
-                if(in_array($mkey,$columns)) {
675
+                if (in_array($mkey, $columns)) {
676 676
                     if (is_array($mval)) {
677 677
                         $mval = implode(",", $mval);
678 678
                     }
@@ -701,12 +701,12 @@  discard block
 block discarded – undo
701 701
              */
702 702
             do_action('geodir_before_save_listinginfo', $postinfo_array, $post_id);
703 703
 
704
-            if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
704
+            if ($wpdb->get_var($wpdb->prepare("SELECT post_id from ".$table." where post_id = %d", array($post_id)))) {
705 705
 
706 706
                 $query_string_array[] = $post_id;
707 707
                 $wpdb->query(
708 708
                     $wpdb->prepare(
709
-                        "UPDATE " . $table . " SET " . $query_string_escaped . " where post_id =%d",
709
+                        "UPDATE ".$table." SET ".$query_string_escaped." where post_id =%d",
710 710
                         $query_string_array
711 711
                     )
712 712
                 );
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
                 array_unshift($query_string_array, $post_id);
718 718
                 $wpdb->query(
719 719
                     $wpdb->prepare(
720
-                        "INSERT INTO " . $table . " SET post_id = %d," . $query_string_escaped,
720
+                        "INSERT INTO ".$table." SET post_id = %d,".$query_string_escaped,
721 721
                         $query_string_array
722 722
                     )
723 723
                 );
@@ -763,7 +763,7 @@  discard block
 block discarded – undo
763 763
 
764 764
         $post_type = get_post_type($post_id);
765 765
 
766
-        $table = $plugin_prefix . $post_type . '_detail';
766
+        $table = $plugin_prefix.$post_type.'_detail';
767 767
 
768 768
         if ($postmeta != '' && geodir_column_exist($table, $postmeta) && $post_id) {
769 769
 
@@ -771,11 +771,11 @@  discard block
 block discarded – undo
771 771
                 $meta_value = implode(",", $meta_value);
772 772
             }
773 773
 
774
-            if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
774
+            if ($wpdb->get_var($wpdb->prepare("SELECT post_id from ".$table." where post_id = %d", array($post_id)))) {
775 775
 
776 776
                 $wpdb->query(
777 777
                     $wpdb->prepare(
778
-                        "UPDATE " . $table . " SET " . $postmeta . " = '" . $meta_value . "' where post_id =%d",
778
+                        "UPDATE ".$table." SET ".$postmeta." = '".$meta_value."' where post_id =%d",
779 779
                         array($post_id)
780 780
                     )
781 781
                 );
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
 
785 785
                 $wpdb->query(
786 786
                     $wpdb->prepare(
787
-                        "INSERT INTO " . $table . " SET post_id = %d, " . $postmeta . " = '" . $meta_value . "'",
787
+                        "INSERT INTO ".$table." SET post_id = %d, ".$postmeta." = '".$meta_value."'",
788 788
                         array($post_id)
789 789
                     )
790 790
                 );
@@ -817,14 +817,14 @@  discard block
 block discarded – undo
817 817
 
818 818
         $post_type = get_post_type($post_id);
819 819
 
820
-        $table = $plugin_prefix . $post_type . '_detail';
820
+        $table = $plugin_prefix.$post_type.'_detail';
821 821
 
822 822
         if (is_array($postmeta) && !empty($postmeta) && $post_id) {
823 823
             $post_meta_set_query = '';
824 824
 
825 825
             foreach ($postmeta as $mkey) {
826 826
                 if ($mval != '')
827
-                    $post_meta_set_query .= $mkey . " = '', ";
827
+                    $post_meta_set_query .= $mkey." = '', ";
828 828
             }
829 829
 
830 830
             $post_meta_set_query = trim($post_meta_set_query, ", ");
@@ -833,11 +833,11 @@  discard block
 block discarded – undo
833 833
                 return false;
834 834
             }
835 835
 
836
-            if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
836
+            if ($wpdb->get_var("SHOW COLUMNS FROM ".$table." WHERE field = '".$postmeta."'") != '') {
837 837
 
838 838
                 $wpdb->query(
839 839
                     $wpdb->prepare(
840
-                        "UPDATE " . $table . " SET " . $post_meta_set_query . " where post_id = %d",
840
+                        "UPDATE ".$table." SET ".$post_meta_set_query." where post_id = %d",
841 841
                         array($post_id)
842 842
                     )
843 843
                 );
@@ -846,11 +846,11 @@  discard block
 block discarded – undo
846 846
             }
847 847
 
848 848
         } elseif ($postmeta != '' && $post_id) {
849
-            if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
849
+            if ($wpdb->get_var("SHOW COLUMNS FROM ".$table." WHERE field = '".$postmeta."'") != '') {
850 850
 
851 851
                 $wpdb->query(
852 852
                     $wpdb->prepare(
853
-                        "UPDATE " . $table . " SET " . $postmeta . "= '' where post_id = %d",
853
+                        "UPDATE ".$table." SET ".$postmeta."= '' where post_id = %d",
854 854
                         array($post_id)
855 855
                     )
856 856
                 );
@@ -892,10 +892,10 @@  discard block
 block discarded – undo
892 892
         if (!in_array($post_type, $all_postypes))
893 893
             return false;
894 894
 
895
-        $table = $plugin_prefix . $post_type . '_detail';
895
+        $table = $plugin_prefix.$post_type.'_detail';
896 896
 
897
-        if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $meta_key . "'") != '') {
898
-            $meta_value = $wpdb->get_var($wpdb->prepare("SELECT " . $meta_key . " from " . $table . " where post_id = %d", array($post_id)));
897
+        if ($wpdb->get_var("SHOW COLUMNS FROM ".$table." WHERE field = '".$meta_key."'") != '') {
898
+            $meta_value = $wpdb->get_var($wpdb->prepare("SELECT ".$meta_key." from ".$table." where post_id = %d", array($post_id)));
899 899
             if ($meta_value && $meta_value !== '') {
900 900
                 return maybe_serialize($meta_value);
901 901
             } else
@@ -928,13 +928,13 @@  discard block
 block discarded – undo
928 928
 
929 929
         $post_type = get_post_type($post_id);
930 930
 
931
-        $table = $plugin_prefix . $post_type . '_detail';
931
+        $table = $plugin_prefix.$post_type.'_detail';
932 932
 
933 933
         $post_images = geodir_get_images($post_id);
934 934
 
935 935
         $wpdb->query(
936 936
             $wpdb->prepare(
937
-                "UPDATE " . $table . " SET featured_image = '' where post_id =%d",
937
+                "UPDATE ".$table." SET featured_image = '' where post_id =%d",
938 938
                 array($post_id)
939 939
             )
940 940
         );
@@ -964,12 +964,12 @@  discard block
 block discarded – undo
964 964
                 $file_path = '';
965 965
                 /* --------- start ------- */
966 966
 
967
-                $split_img_path = explode(str_replace(array('http://','https://'),'',$uploads['baseurl']), str_replace(array('http://','https://'),'',$post_image[$m]));
967
+                $split_img_path = explode(str_replace(array('http://', 'https://'), '', $uploads['baseurl']), str_replace(array('http://', 'https://'), '', $post_image[$m]));
968 968
 
969 969
                 $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : '';
970 970
 
971 971
 
972
-                if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT ID FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE file=%s AND post_id = %d", array($split_img_file_path, $post_id)))) {
972
+                if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT ID FROM ".GEODIR_ATTACHMENT_TABLE." WHERE file=%s AND post_id = %d", array($split_img_file_path, $post_id)))) {
973 973
 
974 974
                     /* --------- end ------- */
975 975
                     $curr_img_url = $post_image[$m];
@@ -1013,7 +1013,7 @@  discard block
 block discarded – undo
1013 1013
                     // If the uploaded file is the right format
1014 1014
                     if (in_array($uploaded_file_type, $allowed_file_types)) {
1015 1015
                         if (!function_exists('wp_handle_upload')) {
1016
-                            require_once(ABSPATH . 'wp-admin/includes/file.php');
1016
+                            require_once(ABSPATH.'wp-admin/includes/file.php');
1017 1017
                         }
1018 1018
 
1019 1019
                         if (!is_dir($geodir_uploadpath)) {
@@ -1021,41 +1021,41 @@  discard block
 block discarded – undo
1021 1021
                         }
1022 1022
 
1023 1023
                         $external_img = false;
1024
-                        if (strpos( str_replace( array('http://','https://'),'',$curr_img_url ), str_replace(array('http://','https://'),'',$uploads['baseurl'] ) ) !== false) {
1024
+                        if (strpos(str_replace(array('http://', 'https://'), '', $curr_img_url), str_replace(array('http://', 'https://'), '', $uploads['baseurl'])) !== false) {
1025 1025
                         } else {
1026 1026
                             $external_img = true;
1027 1027
                         }
1028 1028
 
1029 1029
                         if ($dummy || $external_img) {
1030 1030
                             $uploaded_file = array();
1031
-                            $uploaded = (array)fetch_remote_file($curr_img_url);
1031
+                            $uploaded = (array) fetch_remote_file($curr_img_url);
1032 1032
 
1033 1033
                             if (isset($uploaded['error']) && empty($uploaded['error'])) {
1034 1034
                                 $new_name = basename($uploaded['file']);
1035 1035
                                 $uploaded_file = $uploaded;
1036
-                            }else{
1037
-                                print_r($uploaded);exit;
1036
+                            } else {
1037
+                                print_r($uploaded); exit;
1038 1038
                             }
1039 1039
                             $external_img = false;
1040 1040
                         } else {
1041
-                            $new_name = $post_id . '_' . $file_name;
1041
+                            $new_name = $post_id.'_'.$file_name;
1042 1042
 
1043 1043
                             if ($curr_img_dir == $sub_dir) {
1044
-                                $img_path = $geodir_uploadpath . '/' . $filename;
1045
-                                $img_url = $geodir_uploadurl . '/' . $filename;
1044
+                                $img_path = $geodir_uploadpath.'/'.$filename;
1045
+                                $img_url = $geodir_uploadurl.'/'.$filename;
1046 1046
                             } else {
1047
-                                $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename;
1048
-                                $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename;
1047
+                                $img_path = $uploads_dir.'/temp_'.$current_user->data->ID.'/'.$filename;
1048
+                                $img_url = $uploads['url'].'/temp_'.$current_user->data->ID.'/'.$filename;
1049 1049
                             }
1050 1050
 
1051 1051
                             $uploaded_file = '';
1052 1052
 
1053 1053
                             if (file_exists($img_path)) {
1054
-                                $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name);
1054
+                                $uploaded_file = copy($img_path, $geodir_uploadpath.'/'.$new_name);
1055 1055
                                 $file_path = '';
1056
-                            } else if (file_exists($uploads['basedir'] . $curr_img_dir . $filename)) {
1056
+                            } else if (file_exists($uploads['basedir'].$curr_img_dir.$filename)) {
1057 1057
                                 $uploaded_file = true;
1058
-                                $file_path = $curr_img_dir . '/' . $filename;
1058
+                                $file_path = $curr_img_dir.'/'.$filename;
1059 1059
                             }
1060 1060
 
1061 1061
                             if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path))
@@ -1064,14 +1064,14 @@  discard block
 block discarded – undo
1064 1064
 
1065 1065
                         if (!empty($uploaded_file)) {
1066 1066
                             if (!isset($file_path) || !$file_path) {
1067
-                                $file_path = $sub_dir . '/' . $new_name;
1067
+                                $file_path = $sub_dir.'/'.$new_name;
1068 1068
                             }
1069 1069
 
1070
-                            $postcurr_images[] = str_replace(array('http://','https://'),'',$uploads['baseurl'] . $file_path);
1070
+                            $postcurr_images[] = str_replace(array('http://', 'https://'), '', $uploads['baseurl'].$file_path);
1071 1071
 
1072 1072
                             if ($menu_order == 1) {
1073 1073
 
1074
-                                $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($file_path, $post_id)));
1074
+                                $wpdb->query($wpdb->prepare("UPDATE ".$table." SET featured_image = %s where post_id =%d", array($file_path, $post_id)));
1075 1075
 
1076 1076
                             }
1077 1077
 
@@ -1089,12 +1089,12 @@  discard block
 block discarded – undo
1089 1089
 
1090 1090
                             foreach ($attachment as $key => $val) {
1091 1091
                                 if ($val != '')
1092
-                                    $attachment_set .= $key . " = '" . $val . "', ";
1092
+                                    $attachment_set .= $key." = '".$val."', ";
1093 1093
                             }
1094 1094
 
1095 1095
                             $attachment_set = trim($attachment_set, ", ");
1096 1096
 
1097
-                            $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
1097
+                            $wpdb->query("INSERT INTO ".GEODIR_ATTACHMENT_TABLE." SET ".$attachment_set);
1098 1098
 
1099 1099
                             $valid_file_ids[] = $wpdb->insert_id;
1100 1100
                         }
@@ -1105,17 +1105,17 @@  discard block
 block discarded – undo
1105 1105
                 } else {
1106 1106
                     $valid_file_ids[] = $find_image;
1107 1107
 
1108
-                    $postcurr_images[] = str_replace(array('http://','https://'),'',$post_image[$m]);
1108
+                    $postcurr_images[] = str_replace(array('http://', 'https://'), '', $post_image[$m]);
1109 1109
 
1110 1110
                     $wpdb->query(
1111 1111
                         $wpdb->prepare(
1112
-                            "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d where file =%s AND post_id =%d",
1112
+                            "UPDATE ".GEODIR_ATTACHMENT_TABLE." SET menu_order = %d where file =%s AND post_id =%d",
1113 1113
                             array($menu_order, $split_img_path[1], $post_id)
1114 1114
                         )
1115 1115
                     );
1116 1116
 
1117 1117
                     if ($menu_order == 1)
1118
-                        $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
1118
+                        $wpdb->query($wpdb->prepare("UPDATE ".$table." SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
1119 1119
 
1120 1120
                 }
1121 1121
 
@@ -1139,9 +1139,9 @@  discard block
 block discarded – undo
1139 1139
 
1140 1140
                 foreach ($post_images as $img) {
1141 1141
 
1142
-                    if (!in_array(str_replace(array('http://','https://'),'',$img->src), $postcurr_images)) {
1142
+                    if (!in_array(str_replace(array('http://', 'https://'), '', $img->src), $postcurr_images)) {
1143 1143
 
1144
-                        $invalid_files[] = (object)array('src' => $img->src);
1144
+                        $invalid_files[] = (object) array('src' => $img->src);
1145 1145
 
1146 1146
                     }
1147 1147
 
@@ -1149,12 +1149,12 @@  discard block
 block discarded – undo
1149 1149
 
1150 1150
             }
1151 1151
 
1152
-            $invalid_files = (object)$invalid_files;
1152
+            $invalid_files = (object) $invalid_files;
1153 1153
         }
1154 1154
 
1155 1155
         $remove_files[] = $post_id;
1156 1156
 
1157
-        $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE " . $valid_files_condition . " post_id = %d", $remove_files));
1157
+        $wpdb->query($wpdb->prepare("DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE ".$valid_files_condition." post_id = %d", $remove_files));
1158 1158
 
1159 1159
         if (!empty($invalid_files))
1160 1160
             geodir_remove_attachments($invalid_files);
@@ -1194,7 +1194,7 @@  discard block
 block discarded – undo
1194 1194
 			rmdir($dirPath);
1195 1195
 	}	*/
1196 1196
 
1197
-    $dirname = $uploads_dir . '/temp_' . $current_user->ID;
1197
+    $dirname = $uploads_dir.'/temp_'.$current_user->ID;
1198 1198
     geodir_delete_directory($dirname);
1199 1199
 }
1200 1200
 
@@ -1216,10 +1216,10 @@  discard block
 block discarded – undo
1216 1216
         return false;
1217 1217
     while ($file = readdir($dir_handle)) {
1218 1218
         if ($file != "." && $file != "..") {
1219
-            if (!is_dir($dirname . "/" . $file))
1220
-                unlink($dirname . "/" . $file);
1219
+            if (!is_dir($dirname."/".$file))
1220
+                unlink($dirname."/".$file);
1221 1221
             else
1222
-                geodir_delete_directory($dirname . '/' . $file);
1222
+                geodir_delete_directory($dirname.'/'.$file);
1223 1223
         }
1224 1224
     }
1225 1225
     closedir($dir_handle);
@@ -1248,8 +1248,8 @@  discard block
 block discarded – undo
1248 1248
             foreach ($postcurr_images as $postimg) {
1249 1249
                 $image_name_arr = explode('/', $postimg->src);
1250 1250
                 $filename = end($image_name_arr);
1251
-                if (file_exists($uploads_dir . '/' . $filename))
1252
-                    unlink($uploads_dir . '/' . $filename);
1251
+                if (file_exists($uploads_dir.'/'.$filename))
1252
+                    unlink($uploads_dir.'/'.$filename);
1253 1253
             }
1254 1254
 
1255 1255
         } // endif
@@ -1290,16 +1290,16 @@  discard block
 block discarded – undo
1290 1290
         }
1291 1291
 
1292 1292
         if (!in_array($post_type, geodir_get_posttypes())) {
1293
-            return false;// if not a GD CPT return;
1293
+            return false; // if not a GD CPT return;
1294 1294
         }
1295 1295
 
1296
-        $table = $plugin_prefix . $post_type . '_detail';
1296
+        $table = $plugin_prefix.$post_type.'_detail';
1297 1297
 
1298 1298
         if (!$file) {
1299 1299
             if (isset($post->featured_image)) {
1300 1300
                 $file = $post->featured_image;
1301 1301
             } else {
1302
-                $file = $wpdb->get_var($wpdb->prepare("SELECT featured_image FROM " . $table . " WHERE post_id = %d", array($post_id)));
1302
+                $file = $wpdb->get_var($wpdb->prepare("SELECT featured_image FROM ".$table." WHERE post_id = %d", array($post_id)));
1303 1303
             }
1304 1304
         }
1305 1305
 
@@ -1317,7 +1317,7 @@  discard block
 block discarded – undo
1317 1317
 
1318 1318
             $file_name = $file_info['basename'];
1319 1319
 
1320
-            $uploads_url = $uploads_baseurl . $sub_dir;
1320
+            $uploads_url = $uploads_baseurl.$sub_dir;
1321 1321
             /*
1322 1322
              * Allows the filter of image src for such things as CDN change.
1323 1323
              *
@@ -1327,8 +1327,8 @@  discard block
 block discarded – undo
1327 1327
              * @param string $uploads_url The server upload directory url.
1328 1328
              * @param string $uploads_baseurl The uploads dir base url.
1329 1329
              */
1330
-            $img_arr['src'] = apply_filters('geodir_get_featured_image_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1331
-            $img_arr['path'] = $uploads_path . '/' . $file_name;
1330
+            $img_arr['src'] = apply_filters('geodir_get_featured_image_src', $uploads_url.'/'.$file_name, $file_name, $uploads_url, $uploads_baseurl);
1331
+            $img_arr['path'] = $uploads_path.'/'.$file_name;
1332 1332
             $width = 0;
1333 1333
             $height = 0;
1334 1334
             if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
@@ -1371,7 +1371,7 @@  discard block
 block discarded – undo
1371 1371
                 $file_name = $file_info['basename'];
1372 1372
 
1373 1373
                 $img_arr['src'] = $default_img;
1374
-                $img_arr['path'] = $uploads_path . '/' . $file_name;
1374
+                $img_arr['path'] = $uploads_path.'/'.$file_name;
1375 1375
 
1376 1376
                 $width = 0;
1377 1377
                 $height = 0;
@@ -1388,7 +1388,7 @@  discard block
 block discarded – undo
1388 1388
         }
1389 1389
 
1390 1390
         if (!empty($img_arr))
1391
-            return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path );
1391
+            return (object) $img_arr; //return (object)array( 'src' => $file_url, 'path' => $file_path );
1392 1392
         else
1393 1393
             return false;
1394 1394
     }
@@ -1451,7 +1451,7 @@  discard block
 block discarded – undo
1451 1451
 
1452 1452
         $arrImages = $wpdb->get_results(
1453 1453
             $wpdb->prepare(
1454
-                "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d" . $not_featured . " ORDER BY menu_order ASC, ID DESC $limit_q ",
1454
+                "SELECT * FROM ".GEODIR_ATTACHMENT_TABLE." WHERE mime_type like %s AND post_id = %d".$not_featured." ORDER BY menu_order ASC, ID DESC $limit_q ",
1455 1455
                 array('%image%', $post_id)
1456 1456
             )
1457 1457
         );
@@ -1477,7 +1477,7 @@  discard block
 block discarded – undo
1477 1477
 
1478 1478
                 $file_name = $file_info['basename'];
1479 1479
 
1480
-                $uploads_url = $uploads_baseurl . $sub_dir;
1480
+                $uploads_url = $uploads_baseurl.$sub_dir;
1481 1481
                 /*
1482 1482
                 * Allows the filter of image src for such things as CDN change.
1483 1483
                 *
@@ -1487,8 +1487,8 @@  discard block
 block discarded – undo
1487 1487
                 * @param string $uploads_url The server upload directory url.
1488 1488
                 * @param string $uploads_baseurl The uploads dir base url.
1489 1489
                 */
1490
-                $img_arr['src'] = apply_filters('geodir_get_images_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
1491
-                $img_arr['path'] = $uploads_path . '/' . $file_name;
1490
+                $img_arr['src'] = apply_filters('geodir_get_images_src', $uploads_url.'/'.$file_name, $file_name, $uploads_url, $uploads_baseurl);
1491
+                $img_arr['path'] = $uploads_path.'/'.$file_name;
1492 1492
                 $width = 0;
1493 1493
                 $height = 0;
1494 1494
                 if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
@@ -1505,11 +1505,11 @@  discard block
 block discarded – undo
1505 1505
                 $img_arr['content'] = $attechment->content; // add the description to the array
1506 1506
                 $img_arr['is_approved'] = isset($attechment->is_approved) ? $attechment->is_approved : ''; // used for user image moderation. For backward compatibility Default value is 1.
1507 1507
 
1508
-                $return_arr[] = (object)$img_arr;
1508
+                $return_arr[] = (object) $img_arr;
1509 1509
 
1510 1510
                 $counter++;
1511 1511
             }
1512
-            return (object)$return_arr;
1512
+            return (object) $return_arr;
1513 1513
         } else if ($no_images) {
1514 1514
             $default_img = '';
1515 1515
             $default_cat = geodir_get_post_meta($post_id, 'default_category', true);
@@ -1548,7 +1548,7 @@  discard block
 block discarded – undo
1548 1548
                 $img_arr['title'] = $file_info['filename']; // add the title to the array
1549 1549
                 $img_arr['content'] = $file_info['filename']; // add the description to the array
1550 1550
 
1551
-                $return_arr[] = (object)$img_arr;
1551
+                $return_arr[] = (object) $img_arr;
1552 1552
 
1553 1553
                 return $return_arr;
1554 1554
             } else
@@ -1575,8 +1575,8 @@  discard block
 block discarded – undo
1575 1575
 
1576 1576
         $html = '';
1577 1577
         if (!empty($request)) {
1578
-            if (!is_object($request)){
1579
-                $request = (object)$request;
1578
+            if (!is_object($request)) {
1579
+                $request = (object) $request;
1580 1580
             }
1581 1581
 
1582 1582
             if (isset($request->src) && !isset($request->path)) {
@@ -1590,7 +1590,7 @@  discard block
 block discarded – undo
1590 1590
             $img_no_http = str_replace(array("http://", "https://"), "", $request->path);
1591 1591
             $upload_no_http = str_replace(array("http://", "https://"), "", $upload_dir['baseurl']);
1592 1592
             if (strpos($img_no_http, $upload_no_http) !== false) {
1593
-                $request->path = str_replace( $img_no_http,$upload_dir['basedir'], $request->path);
1593
+                $request->path = str_replace($img_no_http, $upload_dir['basedir'], $request->path);
1594 1594
             }
1595 1595
             
1596 1596
             $width = 0;
@@ -1605,7 +1605,7 @@  discard block
 block discarded – undo
1605 1605
             $image->width = $width;
1606 1606
             $image->height = $height;
1607 1607
 
1608
-            $max_size = (object)geodir_get_imagesize($size);
1608
+            $max_size = (object) geodir_get_imagesize($size);
1609 1609
 
1610 1610
             if (!is_wp_error($max_size)) {
1611 1611
                 if ($image->width) {
@@ -1617,15 +1617,15 @@  discard block
 block discarded – undo
1617 1617
                         $width_per = 100;
1618 1618
                 }
1619 1619
 
1620
-                if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
1621
-                    $html = '<div class="geodir_thumbnail"><img style="max-height:' . $max_size->h . 'px;" alt="place image" src="' . $image->src . '"  /></div>';
1620
+                if (is_admin() && !isset($_REQUEST['geodir_ajax'])) {
1621
+                    $html = '<div class="geodir_thumbnail"><img style="max-height:'.$max_size->h.'px;" alt="place image" src="'.$image->src.'"  /></div>';
1622 1622
                 } else {
1623
-                    if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){
1624
-                        $html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1625
-                    }else{
1623
+                    if ($size == 'widget-thumb' || !get_option('geodir_lazy_load', 1)) {
1624
+                        $html = '<div class="geodir_thumbnail" style="background-image:url(\''.$image->src.'\');"></div>';
1625
+                    } else {
1626 1626
                         //$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1627 1627
                         //$html = '<div data-src="'.$image->src.'" class="geodir_thumbnail" ></div>';
1628
-                        $html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>';
1628
+                        $html = '<div data-src="'.str_replace(' ', '%20', $image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>';
1629 1629
 
1630 1630
                     }
1631 1631
 
@@ -1661,15 +1661,15 @@  discard block
 block discarded – undo
1661 1661
 
1662 1662
         $post_type = get_post_type($post_id);
1663 1663
 
1664
-        $table = $plugin_prefix . $post_type . '_detail';
1664
+        $table = $plugin_prefix.$post_type.'_detail';
1665 1665
 
1666 1666
         if (in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_id)) {
1667 1667
 
1668
-            if ($taxonomy == $post_type . '_tags') {
1668
+            if ($taxonomy == $post_type.'_tags') {
1669 1669
                 if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
1670 1670
                     geodir_save_post_meta($post_id, 'post_tags', $terms);
1671 1671
                 }
1672
-            } elseif ($taxonomy == $post_type . 'category') {
1672
+            } elseif ($taxonomy == $post_type.'category') {
1673 1673
                 $srcharr = array('"', '\\');
1674 1674
                 $replarr = array("&quot;", '');
1675 1675
 
@@ -1691,7 +1691,7 @@  discard block
 block discarded – undo
1691 1691
 
1692 1692
                     $wpdb->get_var(
1693 1693
                         $wpdb->prepare(
1694
-                            "DELETE from " . GEODIR_ICON_TABLE . " WHERE cat_id NOT IN ($format) AND post_id = %d ",
1694
+                            "DELETE from ".GEODIR_ICON_TABLE." WHERE cat_id NOT IN ($format) AND post_id = %d ",
1695 1695
                             $cat_ids_array_del
1696 1696
                         )
1697 1697
                     );
@@ -1699,7 +1699,7 @@  discard block
 block discarded – undo
1699 1699
 
1700 1700
                     $post_term = $wpdb->get_col(
1701 1701
                         $wpdb->prepare(
1702
-                            "SELECT term_id FROM " . $wpdb->term_taxonomy . " WHERE term_taxonomy_id IN($format) GROUP BY term_id",
1702
+                            "SELECT term_id FROM ".$wpdb->term_taxonomy." WHERE term_taxonomy_id IN($format) GROUP BY term_id",
1703 1703
                             $cat_ids_array
1704 1704
                         )
1705 1705
                     );
@@ -1721,16 +1721,16 @@  discard block
 block discarded – undo
1721 1721
                         $lat = geodir_get_post_meta($post_id, 'post_latitude', true);
1722 1722
                         $lng = geodir_get_post_meta($post_id, 'post_longitude', true);
1723 1723
 
1724
-                        $timing = ' - ' . date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true)));
1725
-                        $timing .= ' - ' . geodir_get_post_meta($post_id, 'st_time', true);
1724
+                        $timing = ' - '.date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true)));
1725
+                        $timing .= ' - '.geodir_get_post_meta($post_id, 'st_time', true);
1726 1726
 
1727 1727
                         $json = '{';
1728
-                        $json .= '"id":"' . $post_id . '",';
1729
-                        $json .= '"lat_pos": "' . $lat . '",';
1730
-                        $json .= '"long_pos": "' . $lng . '",';
1731
-                        $json .= '"marker_id":"' . $post_id . '_' . $cat_id . '",';
1732
-                        $json .= '"icon":"' . $term_icon . '",';
1733
-                        $json .= '"group":"catgroup' . $cat_id . '"';
1728
+                        $json .= '"id":"'.$post_id.'",';
1729
+                        $json .= '"lat_pos": "'.$lat.'",';
1730
+                        $json .= '"long_pos": "'.$lng.'",';
1731
+                        $json .= '"marker_id":"'.$post_id.'_'.$cat_id.'",';
1732
+                        $json .= '"icon":"'.$term_icon.'",';
1733
+                        $json .= '"group":"catgroup'.$cat_id.'"';
1734 1734
                         $json .= '}';
1735 1735
 
1736 1736
 
@@ -1738,9 +1738,9 @@  discard block
 block discarded – undo
1738 1738
                             $post_marker_json = $json;
1739 1739
 
1740 1740
 
1741
-                        if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . GEODIR_ICON_TABLE . " WHERE post_id = %d AND cat_id = %d", array($post_id, $cat_id)))) {
1741
+                        if ($wpdb->get_var($wpdb->prepare("SELECT post_id from ".GEODIR_ICON_TABLE." WHERE post_id = %d AND cat_id = %d", array($post_id, $cat_id)))) {
1742 1742
 
1743
-                            $json_query = $wpdb->prepare("UPDATE " . GEODIR_ICON_TABLE . " SET
1743
+                            $json_query = $wpdb->prepare("UPDATE ".GEODIR_ICON_TABLE." SET
1744 1744
 										post_title = %s,
1745 1745
 										json = %s
1746 1746
 										WHERE post_id = %d AND cat_id = %d ",
@@ -1748,7 +1748,7 @@  discard block
 block discarded – undo
1748 1748
 
1749 1749
                         } else {
1750 1750
 
1751
-                            $json_query = $wpdb->prepare("INSERT INTO " . GEODIR_ICON_TABLE . " SET
1751
+                            $json_query = $wpdb->prepare("INSERT INTO ".GEODIR_ICON_TABLE." SET
1752 1752
 										post_id = %d,
1753 1753
 										post_title = %s,
1754 1754
 										cat_id = %d,
@@ -1766,17 +1766,17 @@  discard block
 block discarded – undo
1766 1766
                 if (!empty($post_term) && is_array($post_term)) {
1767 1767
                     $categories = implode(',', $post_term);
1768 1768
 
1769
-                    if ($categories != '' && $categories != 0) $categories = ',' . $categories . ',';
1769
+                    if ($categories != '' && $categories != 0) $categories = ','.$categories.',';
1770 1770
 
1771 1771
                     if (empty($post_marker_json))
1772 1772
                         $post_marker_json = isset($json) ? $json : '';
1773 1773
 
1774
-                    if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
1774
+                    if ($wpdb->get_var($wpdb->prepare("SELECT post_id from ".$table." where post_id = %d", array($post_id)))) {
1775 1775
 
1776 1776
                         $wpdb->query(
1777 1777
                             $wpdb->prepare(
1778
-                                "UPDATE " . $table . " SET
1779
-								" . $taxonomy . " = %s,
1778
+                                "UPDATE ".$table." SET
1779
+								" . $taxonomy." = %s,
1780 1780
 								marker_json = %s
1781 1781
 								where post_id = %d",
1782 1782
                                 array($categories, $post_marker_json, $post_id)
@@ -1797,7 +1797,7 @@  discard block
 block discarded – undo
1797 1797
 
1798 1798
                                     $wpdb->query(
1799 1799
                                         $wpdb->prepare(
1800
-                                            "UPDATE " . $table . " SET
1800
+                                            "UPDATE ".$table." SET
1801 1801
 											default_category = %s
1802 1802
 											where post_id = %d",
1803 1803
                                             array($categories[0], $post_id)
@@ -1822,9 +1822,9 @@  discard block
 block discarded – undo
1822 1822
 
1823 1823
                         $wpdb->query(
1824 1824
                             $wpdb->prepare(
1825
-                                "INSERT INTO " . $table . " SET
1825
+                                "INSERT INTO ".$table." SET
1826 1826
 								post_id = %d,
1827
-								" . $taxonomy . " = %s,
1827
+								" . $taxonomy." = %s,
1828 1828
 								marker_json = %s ",
1829 1829
 
1830 1830
                                 array($post_id, $categories, $post_marker_json)
@@ -1950,7 +1950,7 @@  discard block
 block discarded – undo
1950 1950
                                     } ?>"><img alt="bubble image" style="max-height:50px;"
1951 1951
                                                src="<?php echo $post_images[0]; ?>"/></a></div>
1952 1952
                             <?php
1953
-                            }else{
1953
+                            } else {
1954 1954
                                 echo '<div class="geodir-bubble_image"></div>';
1955 1955
                             }
1956 1956
                         } else {
@@ -1958,7 +1958,7 @@  discard block
 block discarded – undo
1958 1958
                                 ?>
1959 1959
                                 <div class="geodir-bubble_image"><a href="<?php echo $plink; ?>"><?php echo $image; ?></a></div>
1960 1960
                             <?php
1961
-                            }else{
1961
+                            } else {
1962 1962
                                 echo '<div class="geodir-bubble_image"></div>';
1963 1963
                             }
1964 1964
                         }
@@ -1988,7 +1988,7 @@  discard block
 block discarded – undo
1988 1988
                              * @param object $postinfo_obj The posts info as an object.
1989 1989
                              * @param bool|string $post_preview True if currently in post preview page. Empty string if not.                           *
1990 1990
                              */
1991
-                            do_action('geodir_infowindow_meta_after',$postinfo_obj,$post_preview );
1991
+                            do_action('geodir_infowindow_meta_after', $postinfo_obj, $post_preview);
1992 1992
                             ?>
1993 1993
                         </div>
1994 1994
                         <?php
@@ -1998,9 +1998,9 @@  discard block
 block discarded – undo
1998 1998
                             <div class="geodir-bubble-meta-fade"></div>
1999 1999
                             <div class="geodir-bubble-meta-bottom">
2000 2000
                                 <?php if ($rating_star != '') { ?>
2001
-                                <span class="geodir-bubble-rating"><?php echo $rating_star;?></span>
2001
+                                <span class="geodir-bubble-rating"><?php echo $rating_star; ?></span>
2002 2002
                                 <?php } ?>
2003
-                                <span class="geodir-bubble-fav"><?php echo geodir_favourite_html($post_author, $ID);?></span>
2003
+                                <span class="geodir-bubble-fav"><?php echo geodir_favourite_html($post_author, $ID); ?></span>
2004 2004
                                 <span class="geodir-bubble-reviews">
2005 2005
                                     <a href="<?php echo get_comments_link($ID); ?>" class="geodir-pcomments"><i class="fa fa-comments"></i> <?php echo get_comments_number($ID); ?></a>
2006 2006
                                 </span>
@@ -2062,11 +2062,11 @@  discard block
 block discarded – undo
2062 2062
 
2063 2063
         $post_type = get_post_type($post_id);
2064 2064
 
2065
-        $table = $plugin_prefix . $post_type . '_detail';
2065
+        $table = $plugin_prefix.$post_type.'_detail';
2066 2066
 
2067 2067
         $wpdb->query(
2068 2068
             $wpdb->prepare(
2069
-                "UPDATE " . $table . " SET post_status=%s WHERE post_id=%d",
2069
+                "UPDATE ".$table." SET post_status=%s WHERE post_id=%d",
2070 2070
                 array($status, $post_id)
2071 2071
             )
2072 2072
         );
@@ -2138,18 +2138,18 @@  discard block
 block discarded – undo
2138 2138
 
2139 2139
         $post_type = get_post_type($post_id);
2140 2140
 
2141
-        $table = $plugin_prefix . $post_type . '_detail';
2141
+        $table = $plugin_prefix.$post_type.'_detail';
2142 2142
 
2143 2143
         $wpdb->query(
2144 2144
             $wpdb->prepare(
2145
-                "UPDATE " . $table . " SET `post_id` = %d WHERE `post_id` = %d",
2145
+                "UPDATE ".$table." SET `post_id` = %d WHERE `post_id` = %d",
2146 2146
                 array($updatingpost, $temppost)
2147 2147
             )
2148 2148
         );
2149 2149
 
2150 2150
         $wpdb->query(
2151 2151
             $wpdb->prepare(
2152
-                "UPDATE " . GEODIR_ICON_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2152
+                "UPDATE ".GEODIR_ICON_TABLE." SET `post_id` = %d WHERE `post_id` = %d",
2153 2153
                 array($updatingpost, $temppost)
2154 2154
             )
2155 2155
         );
@@ -2158,7 +2158,7 @@  discard block
 block discarded – undo
2158 2158
 
2159 2159
         $wpdb->query(
2160 2160
             $wpdb->prepare(
2161
-                "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET `post_id` = %d WHERE `post_id` = %d",
2161
+                "UPDATE ".GEODIR_ATTACHMENT_TABLE." SET `post_id` = %d WHERE `post_id` = %d",
2162 2162
                 array($updatingpost, $temppost)
2163 2163
             )
2164 2164
         );
@@ -2196,12 +2196,12 @@  discard block
 block discarded – undo
2196 2196
         if (!in_array($post_type, $all_postypes))
2197 2197
             return false;
2198 2198
 
2199
-        $table = $plugin_prefix . $post_type . '_detail';
2199
+        $table = $plugin_prefix.$post_type.'_detail';
2200 2200
 
2201 2201
         /* Delete custom post meta*/
2202 2202
         $wpdb->query(
2203 2203
             $wpdb->prepare(
2204
-                "DELETE FROM " . $table . " WHERE `post_id` = %d",
2204
+                "DELETE FROM ".$table." WHERE `post_id` = %d",
2205 2205
                 array($deleted_postid)
2206 2206
             )
2207 2207
         );
@@ -2210,7 +2210,7 @@  discard block
 block discarded – undo
2210 2210
 
2211 2211
         $wpdb->query(
2212 2212
             $wpdb->prepare(
2213
-                "DELETE FROM " . GEODIR_ICON_TABLE . " WHERE `post_id` = %d",
2213
+                "DELETE FROM ".GEODIR_ICON_TABLE." WHERE `post_id` = %d",
2214 2214
                 array($deleted_postid)
2215 2215
             )
2216 2216
         );
@@ -2220,7 +2220,7 @@  discard block
 block discarded – undo
2220 2220
 
2221 2221
         $wpdb->query(
2222 2222
             $wpdb->prepare(
2223
-                "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE `post_id` = %d",
2223
+                "DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE `post_id` = %d",
2224 2224
                 array($deleted_postid)
2225 2225
             )
2226 2226
         );
@@ -2292,7 +2292,7 @@  discard block
 block discarded – undo
2292 2292
          */
2293 2293
         do_action('geodir_before_add_from_favorite', $post_id);
2294 2294
 
2295
-        echo '<a href="javascript:void(0);" title="' . $remove_favourite_text . '" class="geodir-removetofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'remove\');"><i class="'. $favourite_icon .'"></i> ' . $unfavourite_text . '</a>';
2295
+        echo '<a href="javascript:void(0);" title="'.$remove_favourite_text.'" class="geodir-removetofav-icon" onclick="javascript:addToFavourite(\''.$post_id.'\',\'remove\');"><i class="'.$favourite_icon.'"></i> '.$unfavourite_text.'</a>';
2296 2296
 
2297 2297
         /**
2298 2298
          * Called after adding the post from favourites.
@@ -2371,7 +2371,7 @@  discard block
 block discarded – undo
2371 2371
          */
2372 2372
         do_action('geodir_before_remove_from_favorite', $post_id);
2373 2373
 
2374
-        echo '<a href="javascript:void(0);"  title="' . $add_favourite_text . '" class="geodir-addtofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'add\');"><i class="'. $favourite_icon .'"></i> ' . $favourite_text . '</a>';
2374
+        echo '<a href="javascript:void(0);"  title="'.$add_favourite_text.'" class="geodir-addtofav-icon" onclick="javascript:addToFavourite(\''.$post_id.'\',\'add\');"><i class="'.$favourite_icon.'"></i> '.$favourite_text.'</a>';
2375 2375
 
2376 2376
         /**
2377 2377
          * Called after removing the post from favourites.
@@ -2466,24 +2466,24 @@  discard block
 block discarded – undo
2466 2466
             $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2467 2467
 
2468 2468
         if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
2469
-            ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"  ><a
2469
+            ?><span class="geodir-addtofav favorite_property_<?php echo $post_id; ?>"  ><a
2470 2470
                 class="geodir-removetofav-icon" href="javascript:void(0);"
2471
-                onclick="javascript:addToFavourite(<?php echo $post_id;?>,'remove');"
2472
-                title="<?php echo $remove_favourite_text;?>"><i class="<?php echo $unfavourite_icon; ?>"></i> <?php echo $unfavourite_text;?>
2471
+                onclick="javascript:addToFavourite(<?php echo $post_id; ?>,'remove');"
2472
+                title="<?php echo $remove_favourite_text; ?>"><i class="<?php echo $unfavourite_icon; ?>"></i> <?php echo $unfavourite_text; ?>
2473 2473
             </a>   </span><?php
2474 2474
 
2475 2475
         } else {
2476 2476
 
2477 2477
             if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
2478
-                $script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\'';
2478
+                $script_text = 'javascript:window.location.href=\''.geodir_login_url().'\'';
2479 2479
             } else
2480
-                $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
2480
+                $script_text = 'javascript:addToFavourite('.$post_id.',\'add\')';
2481 2481
 
2482
-            ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon"
2482
+            ?><span class="geodir-addtofav favorite_property_<?php echo $post_id; ?>"><a class="geodir-addtofav-icon"
2483 2483
                                                                                         href="javascript:void(0);"
2484
-                                                                                        onclick="<?php echo $script_text;?>"
2485
-                                                                                        title="<?php echo $add_favourite_text;?>"><i
2486
-                    class="<?php echo $favourite_icon; ?>"></i> <?php echo $favourite_text;?></a></span>
2484
+                                                                                        onclick="<?php echo $script_text; ?>"
2485
+                                                                                        title="<?php echo $add_favourite_text; ?>"><i
2486
+                    class="<?php echo $favourite_icon; ?>"></i> <?php echo $favourite_text; ?></a></span>
2487 2487
         <?php }
2488 2488
     }
2489 2489
 }
@@ -2513,7 +2513,7 @@  discard block
 block discarded – undo
2513 2513
 
2514 2514
             $post_type = $taxonomy_obj->object_type[0];
2515 2515
 
2516
-            $table = $plugin_prefix . $post_type . '_detail';
2516
+            $table = $plugin_prefix.$post_type.'_detail';
2517 2517
 
2518 2518
             /**
2519 2519
              * Filter to modify the 'join' query
@@ -2536,8 +2536,8 @@  discard block
 block discarded – undo
2536 2536
             $where = apply_filters('geodir_cat_post_count_where', $where, $term);
2537 2537
 
2538 2538
             $count_query = "SELECT count(post_id) FROM
2539
-							" . $table . " as pd " . $join . "
2540
-							WHERE pd.post_status='publish' AND FIND_IN_SET('" . $term->term_id . "'," . $term->taxonomy . ") " . $where;
2539
+							" . $table." as pd ".$join."
2540
+							WHERE pd.post_status='publish' AND FIND_IN_SET('" . $term->term_id."',".$term->taxonomy.") ".$where;
2541 2541
 
2542 2542
             $cat_post_count = $wpdb->get_var($count_query);
2543 2543
             if (empty($cat_post_count) || is_wp_error($cat_post_count))
@@ -2620,7 +2620,7 @@  discard block
 block discarded – undo
2620 2620
     global $post;
2621 2621
     $all_postypes = geodir_get_posttypes();
2622 2622
     if (is_array($all_postypes) && in_array($post->post_type, $all_postypes)) {
2623
-        return ' <a href="' . get_permalink($post->ID) . '">' . READ_MORE_TXT . '</a>';
2623
+        return ' <a href="'.get_permalink($post->ID).'">'.READ_MORE_TXT.'</a>';
2624 2624
     }
2625 2625
 
2626 2626
     return $more;
@@ -2647,14 +2647,14 @@  discard block
 block discarded – undo
2647 2647
     if (is_array($gd_taxonomies) && in_array($taxonomy, $gd_taxonomies)) {
2648 2648
 
2649 2649
         $geodir_post_type = geodir_get_taxonomy_posttype($taxonomy);
2650
-        $table = $plugin_prefix . $geodir_post_type . '_detail';
2650
+        $table = $plugin_prefix.$geodir_post_type.'_detail';
2651 2651
 
2652 2652
         $path_parts = pathinfo($_REQUEST['ct_cat_icon']['src']);
2653
-        $term_icon = $path_parts['dirname'] . '/cat_icon_' . $term_id . '.png';
2653
+        $term_icon = $path_parts['dirname'].'/cat_icon_'.$term_id.'.png';
2654 2654
 
2655 2655
         $posts = $wpdb->get_results(
2656 2656
             $wpdb->prepare(
2657
-                "SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM " . $table . " WHERE FIND_IN_SET(%s,%1\$s ) ",
2657
+                "SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM ".$table." WHERE FIND_IN_SET(%s,%1\$s ) ",
2658 2658
                 array($term_id, $taxonomy)
2659 2659
             )
2660 2660
         );
@@ -2666,19 +2666,19 @@  discard block
 block discarded – undo
2666 2666
                 $lng = $post_obj->post_longitude;
2667 2667
 
2668 2668
                 $json = '{';
2669
-                $json .= '"id":"' . $post_obj->post_id . '",';
2670
-                $json .= '"lat_pos": "' . $lat . '",';
2671
-                $json .= '"long_pos": "' . $lng . '",';
2672
-                $json .= '"marker_id":"' . $post_obj->post_id . '_' . $term_id . '",';
2673
-                $json .= '"icon":"' . $term_icon . '",';
2674
-                $json .= '"group":"catgroup' . $term_id . '"';
2669
+                $json .= '"id":"'.$post_obj->post_id.'",';
2670
+                $json .= '"lat_pos": "'.$lat.'",';
2671
+                $json .= '"long_pos": "'.$lng.'",';
2672
+                $json .= '"marker_id":"'.$post_obj->post_id.'_'.$term_id.'",';
2673
+                $json .= '"icon":"'.$term_icon.'",';
2674
+                $json .= '"group":"catgroup'.$term_id.'"';
2675 2675
                 $json .= '}';
2676 2676
 
2677 2677
                 if ($post_obj->default_category == $term_id) {
2678 2678
 
2679 2679
                     $wpdb->query(
2680 2680
                         $wpdb->prepare(
2681
-                            "UPDATE " . $table . " SET marker_json = %s where post_id = %d",
2681
+                            "UPDATE ".$table." SET marker_json = %s where post_id = %d",
2682 2682
                             array($json, $post_obj->post_id)
2683 2683
                         )
2684 2684
                     );
@@ -2686,7 +2686,7 @@  discard block
 block discarded – undo
2686 2686
 
2687 2687
                 $wpdb->query(
2688 2688
                     $wpdb->prepare(
2689
-                        "UPDATE " . GEODIR_ICON_TABLE . " SET json = %s WHERE post_id = %d AND cat_id = %d",
2689
+                        "UPDATE ".GEODIR_ICON_TABLE." SET json = %s WHERE post_id = %d AND cat_id = %d",
2690 2690
                         array($json, $post_obj->post_id, $term_id)
2691 2691
                     )
2692 2692
                 );
@@ -2810,7 +2810,7 @@  discard block
 block discarded – undo
2810 2810
 //	print_r($uploads ) ;
2811 2811
     $post_first_image = $wpdb->get_results(
2812 2812
         $wpdb->prepare(
2813
-            "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d and menu_order = 1  ", array($post_id)
2813
+            "SELECT * FROM ".GEODIR_ATTACHMENT_TABLE." WHERE post_id = %d and menu_order = 1  ", array($post_id)
2814 2814
         )
2815 2815
     );
2816 2816
 
@@ -2831,9 +2831,9 @@  discard block
 block discarded – undo
2831 2831
 
2832 2832
         $post_type = get_post_type($post_id);
2833 2833
 
2834
-        $table_name = $plugin_prefix . $post_type . '_detail';
2834
+        $table_name = $plugin_prefix.$post_type.'_detail';
2835 2835
 
2836
-        $wpdb->query("UPDATE " . $table_name . " SET featured_image='" . $post_first_image[0]->file . "' WHERE post_id =" . $post_id);
2836
+        $wpdb->query("UPDATE ".$table_name." SET featured_image='".$post_first_image[0]->file."' WHERE post_id =".$post_id);
2837 2837
 
2838 2838
         $new_attachment_name = basename($post_first_image[0]->file);
2839 2839
 
@@ -2846,11 +2846,11 @@  discard block
 block discarded – undo
2846 2846
                 wp_delete_attachment($post_thumbnail_id);
2847 2847
 
2848 2848
             }
2849
-            $filename = $uploads['basedir'] . $post_first_image[0]->file;
2849
+            $filename = $uploads['basedir'].$post_first_image[0]->file;
2850 2850
 
2851 2851
             $attachment = array(
2852 2852
                 'post_mime_type' => $post_first_image[0]->mime_type,
2853
-                'guid' => $uploads['baseurl'] . $post_first_image[0]->file,
2853
+                'guid' => $uploads['baseurl'].$post_first_image[0]->file,
2854 2854
                 'post_parent' => $post_id,
2855 2855
                 'post_title' => preg_replace('/\.[^.]+$/', '', $post_first_image[0]->title),
2856 2856
                 'post_content' => ''
@@ -2863,7 +2863,7 @@  discard block
 block discarded – undo
2863 2863
 
2864 2864
                 set_post_thumbnail($post_id, $id);
2865 2865
 
2866
-                require_once(ABSPATH . 'wp-admin/includes/image.php');
2866
+                require_once(ABSPATH.'wp-admin/includes/image.php');
2867 2867
                 wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename));
2868 2868
 
2869 2869
             }
@@ -2896,35 +2896,35 @@  discard block
 block discarded – undo
2896 2896
         $post_id = absint($_POST['post_id']);
2897 2897
         $upload_dir = wp_upload_dir();
2898 2898
         $post_type = get_post_type($_POST['post_id']);
2899
-        $table = $plugin_prefix . $post_type . '_detail';
2899
+        $table = $plugin_prefix.$post_type.'_detail';
2900 2900
 
2901 2901
         $post_arr = $wpdb->get_results($wpdb->prepare(
2902
-            "SELECT * FROM $wpdb->posts p JOIN " . $table . " gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1",
2902
+            "SELECT * FROM $wpdb->posts p JOIN ".$table." gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1",
2903 2903
             array($post_id)
2904 2904
         )
2905 2905
             , ARRAY_A);
2906 2906
 
2907 2907
         $arrImages = $wpdb->get_results(
2908 2908
             $wpdb->prepare(
2909
-                "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ",
2909
+                "SELECT * FROM ".GEODIR_ATTACHMENT_TABLE." WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ",
2910 2910
                 array('%image%', $post_id)
2911 2911
             )
2912 2912
         );
2913 2913
         if ($arrImages) {
2914 2914
             $image_arr = array();
2915 2915
             foreach ($arrImages as $img) {
2916
-                $image_arr[] = $upload_dir['baseurl'] . $img->file;
2916
+                $image_arr[] = $upload_dir['baseurl'].$img->file;
2917 2917
             }
2918 2918
             $comma_separated = implode(",", $image_arr);
2919 2919
             $post_arr[0]['post_images'] = $comma_separated;
2920 2920
         }
2921 2921
 
2922 2922
 
2923
-        $cats = $post_arr[0][$post_arr[0]['post_type'] . 'category'];
2923
+        $cats = $post_arr[0][$post_arr[0]['post_type'].'category'];
2924 2924
         $cat_arr = array_filter(explode(",", $cats));
2925 2925
         $trans_cat = array();
2926 2926
         foreach ($cat_arr as $cat) {
2927
-            $trans_cat[] = icl_object_id($cat, $post_arr[0]['post_type'] . 'category', false);
2927
+            $trans_cat[] = icl_object_id($cat, $post_arr[0]['post_type'].'category', false);
2928 2928
         }
2929 2929
 
2930 2930
 
@@ -2966,7 +2966,7 @@  discard block
 block discarded – undo
2966 2966
 
2967 2967
     $get_data = $wpdb->get_results(
2968 2968
         $wpdb->prepare(
2969
-            "SELECT htmlvar_name, field_type, extra_fields FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1'",
2969
+            "SELECT htmlvar_name, field_type, extra_fields FROM ".GEODIR_CUSTOM_FIELDS_TABLE." WHERE post_type=%s AND is_active='1'",
2970 2970
             array($listing_type)
2971 2971
         )
2972 2972
     );
@@ -2979,12 +2979,12 @@  discard block
 block discarded – undo
2979 2979
 
2980 2980
                 $extra_fields = unserialize($data->extra_fields);
2981 2981
 
2982
-                $prefix = $data->htmlvar_name . '_';
2982
+                $prefix = $data->htmlvar_name.'_';
2983 2983
 
2984
-                $fields_info[$prefix . 'address'] = $data->field_type;
2984
+                $fields_info[$prefix.'address'] = $data->field_type;
2985 2985
 
2986 2986
                 if (isset($extra_fields['show_zip']) && $extra_fields['show_zip'])
2987
-                    $fields_info[$prefix . 'zip'] = $data->field_type;
2987
+                    $fields_info[$prefix.'zip'] = $data->field_type;
2988 2988
 
2989 2989
             } else {
2990 2990
 
@@ -3082,13 +3082,13 @@  discard block
 block discarded – undo
3082 3082
  * @since 1.4.9
3083 3083
  * @package GeoDirectory
3084 3084
  */
3085
-function geodir_fb_like_thumbnail(){
3085
+function geodir_fb_like_thumbnail() {
3086 3086
 
3087 3087
     // return if not a single post
3088
-    if(!is_single()){return;}
3088
+    if (!is_single()) {return; }
3089 3089
 
3090 3090
     global $post;
3091
-    if(isset($post->featured_image) && $post->featured_image){
3091
+    if (isset($post->featured_image) && $post->featured_image) {
3092 3092
         $upload_dir = wp_upload_dir();
3093 3093
         $thumb = $upload_dir['baseurl'].$post->featured_image;
3094 3094
         echo "\n\n<!-- GD Facebook Like Thumbnail -->\n<link rel=\"image_src\" href=\"$thumb\" />\n<!-- End GD Facebook Like Thumbnail -->\n\n";
Please login to merge, or discard this patch.
geodirectory-admin/admin_db_install.php 3 patches
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,12 @@
 block discarded – undo
23 23
 
24 24
         $collate = '';
25 25
         if ($wpdb->has_cap('collation')) {
26
-            if (!empty($wpdb->charset)) $collate = "DEFAULT CHARACTER SET $wpdb->charset";
27
-            if (!empty($wpdb->collate)) $collate .= " COLLATE $wpdb->collate";
26
+            if (!empty($wpdb->charset)) {
27
+            	$collate = "DEFAULT CHARACTER SET $wpdb->charset";
28
+            }
29
+            if (!empty($wpdb->collate)) {
30
+            	$collate .= " COLLATE $wpdb->collate";
31
+            }
28 32
         }
29 33
 
30 34
 		/**
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -32,35 +32,35 @@  discard block
 block discarded – undo
32 32
 		 *
33 33
 		 * @since 1.0.0
34 34
 		 */
35
-		require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
35
+		require_once(ABSPATH.'wp-admin/includes/upgrade.php');
36 36
 
37 37
 
38 38
 // rename tables if we need to
39
-        if ($wpdb->query("SHOW TABLES LIKE 'geodir_countries'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_countries'") == 0) {
40
-            $wpdb->query("RENAME TABLE geodir_countries TO " . $wpdb->prefix . "geodir_countries");
39
+        if ($wpdb->query("SHOW TABLES LIKE 'geodir_countries'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."geodir_countries'") == 0) {
40
+            $wpdb->query("RENAME TABLE geodir_countries TO ".$wpdb->prefix."geodir_countries");
41 41
         }
42
-        if ($wpdb->query("SHOW TABLES LIKE 'geodir_custom_fields'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_custom_fields'") == 0) {
43
-            $wpdb->query("RENAME TABLE geodir_custom_fields TO " . $wpdb->prefix . "geodir_custom_fields");
42
+        if ($wpdb->query("SHOW TABLES LIKE 'geodir_custom_fields'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."geodir_custom_fields'") == 0) {
43
+            $wpdb->query("RENAME TABLE geodir_custom_fields TO ".$wpdb->prefix."geodir_custom_fields");
44 44
         }
45
-        if ($wpdb->query("SHOW TABLES LIKE 'geodir_post_icon'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_post_icon'") == 0) {
46
-            $wpdb->query("RENAME TABLE geodir_post_icon TO " . $wpdb->prefix . "geodir_post_icon");
45
+        if ($wpdb->query("SHOW TABLES LIKE 'geodir_post_icon'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."geodir_post_icon'") == 0) {
46
+            $wpdb->query("RENAME TABLE geodir_post_icon TO ".$wpdb->prefix."geodir_post_icon");
47 47
         }
48
-        if ($wpdb->query("SHOW TABLES LIKE 'geodir_attachments'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_attachments'") == 0) {
49
-            $wpdb->query("RENAME TABLE geodir_attachments TO " . $wpdb->prefix . "geodir_attachments");
48
+        if ($wpdb->query("SHOW TABLES LIKE 'geodir_attachments'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."geodir_attachments'") == 0) {
49
+            $wpdb->query("RENAME TABLE geodir_attachments TO ".$wpdb->prefix."geodir_attachments");
50 50
         }
51
-        if ($wpdb->query("SHOW TABLES LIKE 'geodir_post_review'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_post_review'") == 0) {
52
-            $wpdb->query("RENAME TABLE geodir_post_review TO " . $wpdb->prefix . "geodir_post_review");
51
+        if ($wpdb->query("SHOW TABLES LIKE 'geodir_post_review'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."geodir_post_review'") == 0) {
52
+            $wpdb->query("RENAME TABLE geodir_post_review TO ".$wpdb->prefix."geodir_post_review");
53 53
         }
54
-        if ($wpdb->query("SHOW TABLES LIKE 'geodir_custom_sort_fields'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_custom_sort_fields'") == 0) {
55
-            $wpdb->query("RENAME TABLE geodir_custom_sort_fields TO " . $wpdb->prefix . "geodir_custom_sort_fields");
54
+        if ($wpdb->query("SHOW TABLES LIKE 'geodir_custom_sort_fields'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."geodir_custom_sort_fields'") == 0) {
55
+            $wpdb->query("RENAME TABLE geodir_custom_sort_fields TO ".$wpdb->prefix."geodir_custom_sort_fields");
56 56
         }
57
-        if ($wpdb->query("SHOW TABLES LIKE 'geodir_gd_place_detail'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_gd_place_detail'") == 0) {
58
-            $wpdb->query("RENAME TABLE geodir_gd_place_detail TO " . $wpdb->prefix . "geodir_gd_place_detail");
57
+        if ($wpdb->query("SHOW TABLES LIKE 'geodir_gd_place_detail'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."geodir_gd_place_detail'") == 0) {
58
+            $wpdb->query("RENAME TABLE geodir_gd_place_detail TO ".$wpdb->prefix."geodir_gd_place_detail");
59 59
         }
60 60
 
61 61
 
62 62
         // Table for storing Countries
63
-        $GEODIR_COUNTRIES_TABLE = "CREATE TABLE " . GEODIR_COUNTRIES_TABLE . " (
63
+        $GEODIR_COUNTRIES_TABLE = "CREATE TABLE ".GEODIR_COUNTRIES_TABLE." (
64 64
 						CountryId smallint AUTO_INCREMENT NOT NULL ,
65 65
 						Country varchar (50) NOT NULL ,
66 66
 						FIPS104 varchar (2) NOT NULL ,
@@ -89,11 +89,11 @@  discard block
 block discarded – undo
89 89
         dbDelta($GEODIR_COUNTRIES_TABLE);
90 90
 
91 91
 
92
-        $country_table_empty = $wpdb->get_var("SELECT COUNT(CountryId) FROM " . GEODIR_COUNTRIES_TABLE . "");
92
+        $country_table_empty = $wpdb->get_var("SELECT COUNT(CountryId) FROM ".GEODIR_COUNTRIES_TABLE."");
93 93
 
94 94
         if ($country_table_empty == 0) {
95 95
 
96
-            $countries_insert = "INSERT INTO " . GEODIR_COUNTRIES_TABLE . " (`CountryId`, `Country`, `FIPS104`, `ISO2`, `ISO3`, `ISON`, `Internet`, `Capital`, `MapReference`, `NationalitySingular`, `NationalityPlural`, `Currency`, `CurrencyCode`, `Population`, `Title`, `COMMENT`) VALUES
96
+            $countries_insert = "INSERT INTO ".GEODIR_COUNTRIES_TABLE." (`CountryId`, `Country`, `FIPS104`, `ISO2`, `ISO3`, `ISON`, `Internet`, `Capital`, `MapReference`, `NationalitySingular`, `NationalityPlural`, `Currency`, `CurrencyCode`, `Population`, `Title`, `COMMENT`) VALUES
97 97
 	(1, 'Afghanistan', 'AF', 'AF', 'AFG', '4', 'AF', 'Kabul ', 'Asia ', 'Afghan', 'Afghans', 'Afghani ', 'AFA', 26813057, 'Afghanistan', ''),
98 98
 	(2, 'Albania', 'AL', 'AL', 'ALB', '8', 'AL', 'Tirana ', 'Europe ', 'Albanian', 'Albanians', 'Lek ', 'ALL', 3510484, 'Albania', ''),
99 99
 	(3, 'Algeria', 'AG', 'DZ', 'DZA', '12', 'DZ', 'Algiers ', 'Africa ', 'Algerian', 'Algerians', 'Algerian Dinar ', 'DZD', 31736053, 'Algeria', ''),
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 
383 383
         // Table for storing location attribute - these are user defined
384 384
 
385
-        $icon_table = "CREATE TABLE " . GEODIR_ICON_TABLE . " (
385
+        $icon_table = "CREATE TABLE ".GEODIR_ICON_TABLE." (
386 386
 						id int NOT NULL AUTO_INCREMENT,
387 387
 						post_id int( 10 ) NOT NULL,
388 388
 						post_title varchar(254) NOT NULL,
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 
404 404
         // Table for storing post custom fields - these are user defined
405 405
 
406
-        $post_custom_fields = "CREATE TABLE " . GEODIR_CUSTOM_FIELDS_TABLE . " (
406
+        $post_custom_fields = "CREATE TABLE ".GEODIR_CUSTOM_FIELDS_TABLE." (
407 407
 							  id int(11) NOT NULL AUTO_INCREMENT,
408 408
 							  post_type varchar(100) NULL,
409 409
 							  data_type varchar(100) NULL DEFAULT NULL,
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
         dbDelta($post_custom_fields);
449 449
 
450 450
         // Table for storing place attribute - these are user defined
451
-        $post_detail = "CREATE TABLE " . $plugin_prefix . "gd_place_detail (
451
+        $post_detail = "CREATE TABLE ".$plugin_prefix."gd_place_detail (
452 452
 						post_id int(11) NOT NULL,
453 453
 						post_title text NULL DEFAULT NULL,
454 454
 						post_status varchar(20) NULL DEFAULT NULL,
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 
490 490
         // Table for storing place images - these are user defined
491 491
 
492
-        $attechment_table = "CREATE TABLE " . GEODIR_ATTACHMENT_TABLE . " (
492
+        $attechment_table = "CREATE TABLE ".GEODIR_ATTACHMENT_TABLE." (
493 493
 						ID int(11) NOT NULL AUTO_INCREMENT,
494 494
 						post_id int(11) NOT NULL,
495 495
 						user_id int(11) DEFAULT NULL,
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
         dbDelta($attechment_table);
517 517
 
518 518
 
519
-        $custom_sort_fields_table = "CREATE TABLE " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " (
519
+        $custom_sort_fields_table = "CREATE TABLE ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." (
520 520
 			id int(11) NOT NULL AUTO_INCREMENT,
521 521
 			post_type varchar(255) NOT NULL,
522 522
 			data_type varchar(255) NOT NULL,
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
         dbDelta($custom_sort_fields_table);
546 546
 
547 547
 
548
-            $review_table = "CREATE TABLE " . GEODIR_REVIEW_TABLE . " (
548
+            $review_table = "CREATE TABLE ".GEODIR_REVIEW_TABLE." (
549 549
 			id int(11) NOT NULL AUTO_INCREMENT,
550 550
 			post_id int(11) DEFAULT NULL,
551 551
 			post_title varchar( 255 ) NULL DEFAULT NULL,
Please login to merge, or discard this patch.
Indentation   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -6,26 +6,26 @@  discard block
 block discarded – undo
6 6
  * @package GeoDirectory
7 7
  */
8 8
 if (!function_exists('geodir_create_tables')) {
9
-    /**
10
-     * Creates custom db tables for storing GeoDirectory plugin data.
11
-     *
12
-     * @since 1.0.0
13
-     * @package GeoDirectory
14
-     * @global object $wpdb WordPress Database object.
15
-     * @global string $plugin_prefix GeoDirectory plugin table prefix.
16
-     */
17
-    function geodir_create_tables()
18
-    {
19
-
20
-        global $wpdb, $plugin_prefix;
21
-
22
-        $wpdb->hide_errors();
23
-
24
-        $collate = '';
25
-        if ($wpdb->has_cap('collation')) {
26
-            if (!empty($wpdb->charset)) $collate = "DEFAULT CHARACTER SET $wpdb->charset";
27
-            if (!empty($wpdb->collate)) $collate .= " COLLATE $wpdb->collate";
28
-        }
9
+	/**
10
+	 * Creates custom db tables for storing GeoDirectory plugin data.
11
+	 *
12
+	 * @since 1.0.0
13
+	 * @package GeoDirectory
14
+	 * @global object $wpdb WordPress Database object.
15
+	 * @global string $plugin_prefix GeoDirectory plugin table prefix.
16
+	 */
17
+	function geodir_create_tables()
18
+	{
19
+
20
+		global $wpdb, $plugin_prefix;
21
+
22
+		$wpdb->hide_errors();
23
+
24
+		$collate = '';
25
+		if ($wpdb->has_cap('collation')) {
26
+			if (!empty($wpdb->charset)) $collate = "DEFAULT CHARACTER SET $wpdb->charset";
27
+			if (!empty($wpdb->collate)) $collate .= " COLLATE $wpdb->collate";
28
+		}
29 29
 
30 30
 		/**
31 31
 		 * Include any functions needed for upgrades.
@@ -36,31 +36,31 @@  discard block
 block discarded – undo
36 36
 
37 37
 
38 38
 // rename tables if we need to
39
-        if ($wpdb->query("SHOW TABLES LIKE 'geodir_countries'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_countries'") == 0) {
40
-            $wpdb->query("RENAME TABLE geodir_countries TO " . $wpdb->prefix . "geodir_countries");
41
-        }
42
-        if ($wpdb->query("SHOW TABLES LIKE 'geodir_custom_fields'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_custom_fields'") == 0) {
43
-            $wpdb->query("RENAME TABLE geodir_custom_fields TO " . $wpdb->prefix . "geodir_custom_fields");
44
-        }
45
-        if ($wpdb->query("SHOW TABLES LIKE 'geodir_post_icon'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_post_icon'") == 0) {
46
-            $wpdb->query("RENAME TABLE geodir_post_icon TO " . $wpdb->prefix . "geodir_post_icon");
47
-        }
48
-        if ($wpdb->query("SHOW TABLES LIKE 'geodir_attachments'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_attachments'") == 0) {
49
-            $wpdb->query("RENAME TABLE geodir_attachments TO " . $wpdb->prefix . "geodir_attachments");
50
-        }
51
-        if ($wpdb->query("SHOW TABLES LIKE 'geodir_post_review'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_post_review'") == 0) {
52
-            $wpdb->query("RENAME TABLE geodir_post_review TO " . $wpdb->prefix . "geodir_post_review");
53
-        }
54
-        if ($wpdb->query("SHOW TABLES LIKE 'geodir_custom_sort_fields'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_custom_sort_fields'") == 0) {
55
-            $wpdb->query("RENAME TABLE geodir_custom_sort_fields TO " . $wpdb->prefix . "geodir_custom_sort_fields");
56
-        }
57
-        if ($wpdb->query("SHOW TABLES LIKE 'geodir_gd_place_detail'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_gd_place_detail'") == 0) {
58
-            $wpdb->query("RENAME TABLE geodir_gd_place_detail TO " . $wpdb->prefix . "geodir_gd_place_detail");
59
-        }
60
-
61
-
62
-        // Table for storing Countries
63
-        $GEODIR_COUNTRIES_TABLE = "CREATE TABLE " . GEODIR_COUNTRIES_TABLE . " (
39
+		if ($wpdb->query("SHOW TABLES LIKE 'geodir_countries'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_countries'") == 0) {
40
+			$wpdb->query("RENAME TABLE geodir_countries TO " . $wpdb->prefix . "geodir_countries");
41
+		}
42
+		if ($wpdb->query("SHOW TABLES LIKE 'geodir_custom_fields'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_custom_fields'") == 0) {
43
+			$wpdb->query("RENAME TABLE geodir_custom_fields TO " . $wpdb->prefix . "geodir_custom_fields");
44
+		}
45
+		if ($wpdb->query("SHOW TABLES LIKE 'geodir_post_icon'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_post_icon'") == 0) {
46
+			$wpdb->query("RENAME TABLE geodir_post_icon TO " . $wpdb->prefix . "geodir_post_icon");
47
+		}
48
+		if ($wpdb->query("SHOW TABLES LIKE 'geodir_attachments'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_attachments'") == 0) {
49
+			$wpdb->query("RENAME TABLE geodir_attachments TO " . $wpdb->prefix . "geodir_attachments");
50
+		}
51
+		if ($wpdb->query("SHOW TABLES LIKE 'geodir_post_review'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_post_review'") == 0) {
52
+			$wpdb->query("RENAME TABLE geodir_post_review TO " . $wpdb->prefix . "geodir_post_review");
53
+		}
54
+		if ($wpdb->query("SHOW TABLES LIKE 'geodir_custom_sort_fields'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_custom_sort_fields'") == 0) {
55
+			$wpdb->query("RENAME TABLE geodir_custom_sort_fields TO " . $wpdb->prefix . "geodir_custom_sort_fields");
56
+		}
57
+		if ($wpdb->query("SHOW TABLES LIKE 'geodir_gd_place_detail'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "geodir_gd_place_detail'") == 0) {
58
+			$wpdb->query("RENAME TABLE geodir_gd_place_detail TO " . $wpdb->prefix . "geodir_gd_place_detail");
59
+		}
60
+
61
+
62
+		// Table for storing Countries
63
+		$GEODIR_COUNTRIES_TABLE = "CREATE TABLE " . GEODIR_COUNTRIES_TABLE . " (
64 64
 						CountryId smallint AUTO_INCREMENT NOT NULL ,
65 65
 						Country varchar (50) NOT NULL ,
66 66
 						FIPS104 varchar (2) NOT NULL ,
@@ -79,21 +79,21 @@  discard block
 block discarded – undo
79 79
 						Comment varchar (255) NULL ,
80 80
 						PRIMARY KEY  (CountryId)) $collate ";
81 81
 
82
-        /**
83
-         * Filter the SQL query that creates/updates the country DB table structure.
84
-         *
85
-         * @since 1.0.0
86
-         * @param string $sql The SQL insert query string.
87
-         */
88
-        $GEODIR_COUNTRIES_TABLE = apply_filters('geodir_before_country_table_create', $GEODIR_COUNTRIES_TABLE);
89
-        dbDelta($GEODIR_COUNTRIES_TABLE);
82
+		/**
83
+		 * Filter the SQL query that creates/updates the country DB table structure.
84
+		 *
85
+		 * @since 1.0.0
86
+		 * @param string $sql The SQL insert query string.
87
+		 */
88
+		$GEODIR_COUNTRIES_TABLE = apply_filters('geodir_before_country_table_create', $GEODIR_COUNTRIES_TABLE);
89
+		dbDelta($GEODIR_COUNTRIES_TABLE);
90 90
 
91 91
 
92
-        $country_table_empty = $wpdb->get_var("SELECT COUNT(CountryId) FROM " . GEODIR_COUNTRIES_TABLE . "");
92
+		$country_table_empty = $wpdb->get_var("SELECT COUNT(CountryId) FROM " . GEODIR_COUNTRIES_TABLE . "");
93 93
 
94
-        if ($country_table_empty == 0) {
94
+		if ($country_table_empty == 0) {
95 95
 
96
-            $countries_insert = "INSERT INTO " . GEODIR_COUNTRIES_TABLE . " (`CountryId`, `Country`, `FIPS104`, `ISO2`, `ISO3`, `ISON`, `Internet`, `Capital`, `MapReference`, `NationalitySingular`, `NationalityPlural`, `Currency`, `CurrencyCode`, `Population`, `Title`, `COMMENT`) VALUES
96
+			$countries_insert = "INSERT INTO " . GEODIR_COUNTRIES_TABLE . " (`CountryId`, `Country`, `FIPS104`, `ISO2`, `ISO3`, `ISON`, `Internet`, `Capital`, `MapReference`, `NationalitySingular`, `NationalityPlural`, `Currency`, `CurrencyCode`, `Population`, `Title`, `COMMENT`) VALUES
97 97
 	(1, 'Afghanistan', 'AF', 'AF', 'AFG', '4', 'AF', 'Kabul ', 'Asia ', 'Afghan', 'Afghans', 'Afghani ', 'AFA', 26813057, 'Afghanistan', ''),
98 98
 	(2, 'Albania', 'AL', 'AL', 'ALB', '8', 'AL', 'Tirana ', 'Europe ', 'Albanian', 'Albanians', 'Lek ', 'ALL', 3510484, 'Albania', ''),
99 99
 	(3, 'Algeria', 'AG', 'DZ', 'DZA', '12', 'DZ', 'Algiers ', 'Africa ', 'Algerian', 'Algerians', 'Algerian Dinar ', 'DZD', 31736053, 'Algeria', ''),
@@ -370,21 +370,21 @@  discard block
 block discarded – undo
370 370
     (280, 'São Tomé and Príncipe', '--', 'ST', '-- ', '--', 'ST', '', '', '', '', 'Dobra', 'STD', 190428, 'São Tomé', ''),
371 371
     (281, 'South Sudan', '--', 'SS', '-- ', '--', 'SS', '', '', '', '', 'South Sudanese pound', 'SSP', 12340000, 'South Sudan', '')";
372 372
 
373
-            /**
374
-             * Filter the SQL query that inserts the country DB table data.
375
-             *
376
-             * @since 1.0.0
377
-             * @param string $sql The SQL insert query string.
378
-             */
379
-            $countries_insert = apply_filters('geodir_before_country_data_insert', $countries_insert);
380
-            $wpdb->query($countries_insert);
373
+			/**
374
+			 * Filter the SQL query that inserts the country DB table data.
375
+			 *
376
+			 * @since 1.0.0
377
+			 * @param string $sql The SQL insert query string.
378
+			 */
379
+			$countries_insert = apply_filters('geodir_before_country_data_insert', $countries_insert);
380
+			$wpdb->query($countries_insert);
381 381
 
382
-        }
382
+		}
383 383
 
384 384
 
385
-        // Table for storing location attribute - these are user defined
385
+		// Table for storing location attribute - these are user defined
386 386
 
387
-        $icon_table = "CREATE TABLE " . GEODIR_ICON_TABLE . " (
387
+		$icon_table = "CREATE TABLE " . GEODIR_ICON_TABLE . " (
388 388
 						id int NOT NULL AUTO_INCREMENT,
389 389
 						post_id int( 10 ) NOT NULL,
390 390
 						post_title varchar(254) NOT NULL,
@@ -393,19 +393,19 @@  discard block
 block discarded – undo
393 393
 						PRIMARY KEY  (id)
394 394
 						) $collate ";
395 395
 
396
-        /**
397
-         * Filter the SQL query that creates/updates the post_icon DB table structure.
398
-         *
399
-         * @since 1.0.0
400
-         * @param string $sql The SQL insert query string.
401
-         */
402
-        $icon_table = apply_filters('geodir_before_icon_table_create', $icon_table);
396
+		/**
397
+		 * Filter the SQL query that creates/updates the post_icon DB table structure.
398
+		 *
399
+		 * @since 1.0.0
400
+		 * @param string $sql The SQL insert query string.
401
+		 */
402
+		$icon_table = apply_filters('geodir_before_icon_table_create', $icon_table);
403 403
 
404
-        dbDelta($icon_table);
404
+		dbDelta($icon_table);
405 405
 
406
-        // Table for storing post custom fields - these are user defined
406
+		// Table for storing post custom fields - these are user defined
407 407
 
408
-        $post_custom_fields = "CREATE TABLE " . GEODIR_CUSTOM_FIELDS_TABLE . " (
408
+		$post_custom_fields = "CREATE TABLE " . GEODIR_CUSTOM_FIELDS_TABLE . " (
409 409
 							  id int(11) NOT NULL AUTO_INCREMENT,
410 410
 							  post_type varchar(100) NULL,
411 411
 							  data_type varchar(100) NULL DEFAULT NULL,
@@ -441,18 +441,18 @@  discard block
 block discarded – undo
441 441
 							  PRIMARY KEY  (id)
442 442
 							  ) $collate";
443 443
 
444
-        /**
445
-         * Filter the SQL query that creates/updates the custom_fields DB table structure.
446
-         *
447
-         * @since 1.0.0
448
-         * @param string $sql The SQL insert query string.
449
-         */
450
-        $post_custom_fields = apply_filters('geodir_before_custom_field_table_create', $post_custom_fields);
444
+		/**
445
+		 * Filter the SQL query that creates/updates the custom_fields DB table structure.
446
+		 *
447
+		 * @since 1.0.0
448
+		 * @param string $sql The SQL insert query string.
449
+		 */
450
+		$post_custom_fields = apply_filters('geodir_before_custom_field_table_create', $post_custom_fields);
451 451
 
452
-        dbDelta($post_custom_fields);
452
+		dbDelta($post_custom_fields);
453 453
 
454
-        // Table for storing place attribute - these are user defined
455
-        $post_detail = "CREATE TABLE " . $plugin_prefix . "gd_place_detail (
454
+		// Table for storing place attribute - these are user defined
455
+		$post_detail = "CREATE TABLE " . $plugin_prefix . "gd_place_detail (
456 456
 						post_id int(11) NOT NULL,
457 457
 						post_title text NULL DEFAULT NULL,
458 458
 						post_status varchar(20) NULL DEFAULT NULL,
@@ -481,22 +481,22 @@  discard block
 block discarded – undo
481 481
 						KEY is_featured (is_featured)
482 482
 						) $collate ";
483 483
 
484
-        /**
485
-         * Filter the SQL query that creates/updates the post_detail DB table structure.
486
-         *
487
-         * @since 1.0.0
488
-         * @param string $sql The SQL insert query string.
489
-         */
490
-        $post_detail = apply_filters('geodir_before_post_detail_table_create', $post_detail);
484
+		/**
485
+		 * Filter the SQL query that creates/updates the post_detail DB table structure.
486
+		 *
487
+		 * @since 1.0.0
488
+		 * @param string $sql The SQL insert query string.
489
+		 */
490
+		$post_detail = apply_filters('geodir_before_post_detail_table_create', $post_detail);
491 491
 
492
-        dbDelta($post_detail);
492
+		dbDelta($post_detail);
493 493
 
494
-        // alter post_title
495
-        //$wpdb->query("ALTER TABLE ".$wpdb->prefix."geodir_gd_place_detail MODIFY `post_title` text NULL");
494
+		// alter post_title
495
+		//$wpdb->query("ALTER TABLE ".$wpdb->prefix."geodir_gd_place_detail MODIFY `post_title` text NULL");
496 496
 
497
-        // Table for storing place images - these are user defined
497
+		// Table for storing place images - these are user defined
498 498
 
499
-        $attechment_table = "CREATE TABLE " . GEODIR_ATTACHMENT_TABLE . " (
499
+		$attechment_table = "CREATE TABLE " . GEODIR_ATTACHMENT_TABLE . " (
500 500
 						ID int(11) NOT NULL AUTO_INCREMENT,
501 501
 						post_id int(11) NOT NULL,
502 502
 						user_id int(11) DEFAULT NULL,
@@ -512,18 +512,18 @@  discard block
 block discarded – undo
512 512
 						PRIMARY KEY  (ID)
513 513
 						) $collate ";
514 514
 
515
-        /**
516
-         * Filter the SQL query that creates/updates the attachments DB table structure.
517
-         *
518
-         * @since 1.0.0
519
-         * @param string $sql The SQL insert query string.
520
-         */
521
-        $attechment_table = apply_filters('geodir_before_attachment_table_create', $attechment_table);
515
+		/**
516
+		 * Filter the SQL query that creates/updates the attachments DB table structure.
517
+		 *
518
+		 * @since 1.0.0
519
+		 * @param string $sql The SQL insert query string.
520
+		 */
521
+		$attechment_table = apply_filters('geodir_before_attachment_table_create', $attechment_table);
522 522
 
523
-        dbDelta($attechment_table);
523
+		dbDelta($attechment_table);
524 524
 
525 525
 
526
-        $custom_sort_fields_table = "CREATE TABLE " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " (
526
+		$custom_sort_fields_table = "CREATE TABLE " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " (
527 527
 			id int(11) NOT NULL AUTO_INCREMENT,
528 528
 			post_type varchar(255) NOT NULL,
529 529
 			data_type varchar(255) NOT NULL,
@@ -541,18 +541,18 @@  discard block
 block discarded – undo
541 541
 			PRIMARY KEY  (id)
542 542
 			) $collate ";
543 543
 
544
-        /**
545
-         * Filter the SQL query that creates/updates the custom_sort_fields DB table structure.
546
-         *
547
-         * @since 1.0.0
548
-         * @param string $sql The SQL insert query string.
549
-         */
550
-        $custom_sort_fields_table = apply_filters('geodir_before_sort_fields_table_create', $custom_sort_fields_table);
544
+		/**
545
+		 * Filter the SQL query that creates/updates the custom_sort_fields DB table structure.
546
+		 *
547
+		 * @since 1.0.0
548
+		 * @param string $sql The SQL insert query string.
549
+		 */
550
+		$custom_sort_fields_table = apply_filters('geodir_before_sort_fields_table_create', $custom_sort_fields_table);
551 551
 
552
-        dbDelta($custom_sort_fields_table);
552
+		dbDelta($custom_sort_fields_table);
553 553
 
554 554
 
555
-            $review_table = "CREATE TABLE " . GEODIR_REVIEW_TABLE . " (
555
+			$review_table = "CREATE TABLE " . GEODIR_REVIEW_TABLE . " (
556 556
 			id int(11) NOT NULL AUTO_INCREMENT,
557 557
 			post_id int(11) DEFAULT NULL,
558 558
 			post_title varchar( 255 ) NULL DEFAULT NULL,
@@ -576,51 +576,51 @@  discard block
 block discarded – undo
576 576
 			PRIMARY KEY  (id)
577 577
 			) $collate  ";
578 578
 
579
-            /**
580
-             * Filter the SQL query that creates the review DB table structure.
581
-             *
582
-             * @since 1.0.0
583
-             * @param string $sql The SQL insert query string.
584
-             */
585
-            $review_table = apply_filters('geodir_before_review_table_create', $review_table);
586
-            dbDelta($review_table);
579
+			/**
580
+			 * Filter the SQL query that creates the review DB table structure.
581
+			 *
582
+			 * @since 1.0.0
583
+			 * @param string $sql The SQL insert query string.
584
+			 */
585
+			$review_table = apply_filters('geodir_before_review_table_create', $review_table);
586
+			dbDelta($review_table);
587 587
 
588 588
 
589 589
 
590
-        // Alter terms table
591
-        $term_icon_column = $wpdb->get_var("SHOW COLUMNS FROM $wpdb->terms where field='term_icon'");
592
-        if (!$term_icon_column) {
593
-            $wpdb->query("ALTER TABLE $wpdb->terms ADD `term_icon` TEXT NULL DEFAULT NULL");
594
-        }
590
+		// Alter terms table
591
+		$term_icon_column = $wpdb->get_var("SHOW COLUMNS FROM $wpdb->terms where field='term_icon'");
592
+		if (!$term_icon_column) {
593
+			$wpdb->query("ALTER TABLE $wpdb->terms ADD `term_icon` TEXT NULL DEFAULT NULL");
594
+		}
595 595
 
596
-        //require_once(geodir_plugin_path() . '/upgrade.php');
596
+		//require_once(geodir_plugin_path() . '/upgrade.php');
597 597
 
598 598
 
599
-    }
599
+	}
600 600
 } // END MAIN FUNCTION geodir_tables_install
601 601
 
602 602
 if (!function_exists('geodir_create_default_fields')) {
603
-    /**
604
-     * Inserts default custom fields table data into database.
605
-     *
606
-     * @since 1.0.0
607
-     * @package GeoDirectory
608
-     */
609
-    function geodir_create_default_fields()
610
-    {
611
-
612
-        $fields = geodir_default_custom_fields('gd_place');
613
-
614
-        /**
615
-         * Filter the array of default custom fields DB table data.
616
-         *
617
-         * @since 1.0.0
618
-         * @param string $fields The default custom fields as an array.
619
-         */
620
-        $fields = apply_filters('geodir_before_default_custom_fields_saved', $fields);
621
-        foreach ($fields as $field_index => $field) {
622
-            geodir_custom_field_save($field);
623
-
624
-        }
625
-    }
603
+	/**
604
+	 * Inserts default custom fields table data into database.
605
+	 *
606
+	 * @since 1.0.0
607
+	 * @package GeoDirectory
608
+	 */
609
+	function geodir_create_default_fields()
610
+	{
611
+
612
+		$fields = geodir_default_custom_fields('gd_place');
613
+
614
+		/**
615
+		 * Filter the array of default custom fields DB table data.
616
+		 *
617
+		 * @since 1.0.0
618
+		 * @param string $fields The default custom fields as an array.
619
+		 */
620
+		$fields = apply_filters('geodir_before_default_custom_fields_saved', $fields);
621
+		foreach ($fields as $field_index => $field) {
622
+			geodir_custom_field_save($field);
623
+
624
+		}
625
+	}
626 626
 }
627 627
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory-admin/option-pages/permalink_settings_array.php 1 patch
Indentation   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -16,184 +16,184 @@
 block discarded – undo
16 16
  */
17 17
 $geodir_settings['permalink_settings'] = apply_filters('geodir_permalink_settings', array(
18 18
 
19
-    /* Listing Permalink Settings start */
20
-    array('name' => __('Permalink', 'geodirectory'), 'type' => 'no_tabs', 'desc' => 'Settings to set permalink', 'id' => 'geodir_permalink_settings '),
21
-
22
-
23
-    array('name' => __('Listing Detail Permalink Settings', 'geodirectory'),
24
-        'type' => 'sectionstart',
25
-        'desc' => '',
26
-        'id' => 'geodir_permalink'),
27
-
28
-    array(
29
-        'name' => __('Add location in urls', 'geodirectory'),
30
-        'desc' => __('Add location slug in listing urls', 'geodirectory'),
31
-        'id' => 'geodir_add_location_url',
32
-        'type' => 'checkbox',
33
-        'std' => '1',
34
-        'checkboxgroup' => 'start'
35
-    ),
36
-
37
-    array(
38
-        'name' => __('Add full location in listing urls', 'geodirectory'),
39
-        'desc' => __('Add full location info with country, region and city slug in listing urls', 'geodirectory'),
40
-        'id' => 'geodir_show_location_url',
41
-        'type' => 'radio',
42
-        'value' => 'all',
43
-        'std' => 'all',
44
-        'radiogroup' => ''
45
-    ),
46
-
47
-	array(
48
-        'name' => __('Add country and city slug in listing urls', 'geodirectory'),
49
-        'desc' => __('Add country and city slug in listing urls (/country/city/)', 'geodirectory'),
50
-        'id' => 'geodir_show_location_url',
51
-        'type' => 'radio',
52
-        'std' => 'all',
53
-        'value' => 'country_city',
54
-        'radiogroup' => ''
55
-    ),
56
-	array(
57
-        'name' => __('Add region and city slug in listing urls', 'geodirectory'),
58
-        'desc' => __('Add region and city slug in listing urls (/region/city/)', 'geodirectory'),
59
-        'id' => 'geodir_show_location_url',
60
-        'type' => 'radio',
61
-        'std' => 'all',
62
-        'value' => 'region_city',
63
-        'radiogroup' => ''
64
-    ),
65
-    array(
66
-        'name' => __('Add only city in listing urls', 'geodirectory'),
67
-        'desc' => __('Add city slug in listing urls', 'geodirectory'),
68
-        'id' => 'geodir_show_location_url',
69
-        'type' => 'radio',
70
-        'std' => 'all',
71
-        'value' => 'city',
72
-        'radiogroup' => 'end'
73
-    ),
74
-
75
-
76
-
77
-    array(
78
-        'name' => __('Add category in listing urls', 'geodirectory'),
79
-        'desc' => __('Add requested category slugs in listing urls', 'geodirectory'),
80
-        'id' => 'geodir_add_categories_url',
81
-        'type' => 'checkbox',
82
-        'std' => '1',
83
-    ),
84
-
85
-    array(
86
-        'name' => __('Listing url prefix', 'geodirectory'),
87
-        'desc' => __('Listing prefix to show in url', 'geodirectory'),
88
-        'id' => 'geodir_listing_prefix',
89
-        'type' => 'text',
90
-        'css' => 'min-width:300px;',
91
-        'std' => 'places'
92
-    ),
93
-
94
-    array(
95
-        'name' => __('Location url prefix', 'geodirectory'),
96
-        'desc' => __('Depreciated, now uses the location page slug', 'geodirectory'),
97
-        'id' => 'geodir_location_prefix',
98
-        'type' => 'text',
99
-        'css' => 'min-width:300px;',
100
-        'std' => 'location' // Default value to show home top section
101
-    ),
102
-
103
-    array(
104
-        'name' => __('Location and category url separator', 'geodirectory'),
105
-        'desc' => __('Separator to show between location and category url slugs in listing urls', 'geodirectory'),
106
-        'id' => 'geodir_listingurl_separator',
107
-        'type' => 'text',
108
-        'css' => 'min-width:300px;',
109
-        'std' => 'C' // Default value to show home top section
110
-    ),
111
-
112
-    array(
113
-        'name' => __('Listing detail url separator', 'geodirectory'),
114
-        'desc' => __('Separator to show before listing slug in listing detail urls', 'geodirectory'),
115
-        'id' => 'geodir_detailurl_separator',
116
-        'type' => 'text',
117
-        'css' => 'min-width:300px;',
118
-        'std' => 'info' // Default value to show home top section
119
-    ),
120
-
121
-
122
-    array('type' => 'sectionend', 'id' => 'geodir_permalink'),
123
-
124
-    array('name' => __('GeoDirectory Pages', 'geodirectory'),
125
-        'type' => 'sectionstart',
126
-        'desc' => '',
127
-        'id' => 'geodir_pages'),
128
-
129
-    array(
130
-        'name' => __('GD Home page', 'geodirectory'),
131
-        'desc' => __('Select the page to use for the GD homepage (you must also set this page in Settings>Reading>Front page for it to work)', 'geodirectory'),
132
-        'id' => 'geodir_home_page',
133
-        'type' => 'single_select_page',
134
-        'class' => 'chosen_select'
135
-    ),
136
-
137
-    array(
138
-        'name' => __('Add listing page', 'geodirectory'),
139
-        'desc' => __('Select the page to use for adding listings', 'geodirectory'),
140
-        'id' => 'geodir_add_listing_page',
141
-        'type' => 'single_select_page',
142
-        'class' => 'chosen_select'
143
-    ),
144
-
145
-    array(
146
-        'name' => __('Listing preview page', 'geodirectory'),
147
-        'desc' => __('Select the page to use for listing preview', 'geodirectory'),
148
-        'id' => 'geodir_preview_page',
149
-        'type' => 'single_select_page',
150
-        'class' => 'chosen_select'
151
-    ),
152
-
153
-    array(
154
-        'name' => __('Listing success page', 'geodirectory'),
155
-        'desc' => __('Select the page to use for listing success', 'geodirectory'),
156
-        'id' => 'geodir_success_page',
157
-        'type' => 'single_select_page',
158
-        'class' => 'chosen_select'
159
-    ),
160
-
161
-    array(
162
-        'name' => __('Location page', 'geodirectory'),
163
-        'desc' => __('Select the page to use for locations', 'geodirectory'),
164
-        'id' => 'geodir_location_page',
165
-        'type' => 'single_select_page',
166
-        'class' => 'chosen_select'
167
-    ),
168
-
169
-    array(
170
-        'name' => __('Terms and Conditions page', 'geodirectory'),
171
-        'desc' => __('Select the page to use for Terms and Conditions (if enabled)', 'geodirectory'),
172
-        'id' => 'geodir_term_condition_page',
173
-        'type' => 'single_select_page',
174
-        'class' => 'chosen_select'
175
-    ),
176
-
177
-    array(
178
-        'name' => __('Info page', 'geodirectory'),
179
-        'desc' => __('Select the page to use for Gd general Info', 'geodirectory'),
180
-        'id' => 'geodir_info_page',
181
-        'type' => 'single_select_page',
182
-        'class' => 'chosen_select'
183
-    ),
184
-
185
-    array(
186
-        'name' => __('Login page', 'geodirectory'),
187
-        'desc' => __('Select the page to use for Login / Register', 'geodirectory'),
188
-        'id' => 'geodir_login_page',
189
-        'type' => 'single_select_page',
190
-        'class' => 'chosen_select'
191
-    ),
192
-
193
-
194
-    array('type' => 'sectionend', 'id' => 'geodir_pages'),
195
-
196
-    /* Listing Detail Permalink Settings End */
19
+	/* Listing Permalink Settings start */
20
+	array('name' => __('Permalink', 'geodirectory'), 'type' => 'no_tabs', 'desc' => 'Settings to set permalink', 'id' => 'geodir_permalink_settings '),
21
+
22
+
23
+	array('name' => __('Listing Detail Permalink Settings', 'geodirectory'),
24
+		'type' => 'sectionstart',
25
+		'desc' => '',
26
+		'id' => 'geodir_permalink'),
27
+
28
+	array(
29
+		'name' => __('Add location in urls', 'geodirectory'),
30
+		'desc' => __('Add location slug in listing urls', 'geodirectory'),
31
+		'id' => 'geodir_add_location_url',
32
+		'type' => 'checkbox',
33
+		'std' => '1',
34
+		'checkboxgroup' => 'start'
35
+	),
36
+
37
+	array(
38
+		'name' => __('Add full location in listing urls', 'geodirectory'),
39
+		'desc' => __('Add full location info with country, region and city slug in listing urls', 'geodirectory'),
40
+		'id' => 'geodir_show_location_url',
41
+		'type' => 'radio',
42
+		'value' => 'all',
43
+		'std' => 'all',
44
+		'radiogroup' => ''
45
+	),
46
+
47
+	array(
48
+		'name' => __('Add country and city slug in listing urls', 'geodirectory'),
49
+		'desc' => __('Add country and city slug in listing urls (/country/city/)', 'geodirectory'),
50
+		'id' => 'geodir_show_location_url',
51
+		'type' => 'radio',
52
+		'std' => 'all',
53
+		'value' => 'country_city',
54
+		'radiogroup' => ''
55
+	),
56
+	array(
57
+		'name' => __('Add region and city slug in listing urls', 'geodirectory'),
58
+		'desc' => __('Add region and city slug in listing urls (/region/city/)', 'geodirectory'),
59
+		'id' => 'geodir_show_location_url',
60
+		'type' => 'radio',
61
+		'std' => 'all',
62
+		'value' => 'region_city',
63
+		'radiogroup' => ''
64
+	),
65
+	array(
66
+		'name' => __('Add only city in listing urls', 'geodirectory'),
67
+		'desc' => __('Add city slug in listing urls', 'geodirectory'),
68
+		'id' => 'geodir_show_location_url',
69
+		'type' => 'radio',
70
+		'std' => 'all',
71
+		'value' => 'city',
72
+		'radiogroup' => 'end'
73
+	),
74
+
75
+
76
+
77
+	array(
78
+		'name' => __('Add category in listing urls', 'geodirectory'),
79
+		'desc' => __('Add requested category slugs in listing urls', 'geodirectory'),
80
+		'id' => 'geodir_add_categories_url',
81
+		'type' => 'checkbox',
82
+		'std' => '1',
83
+	),
84
+
85
+	array(
86
+		'name' => __('Listing url prefix', 'geodirectory'),
87
+		'desc' => __('Listing prefix to show in url', 'geodirectory'),
88
+		'id' => 'geodir_listing_prefix',
89
+		'type' => 'text',
90
+		'css' => 'min-width:300px;',
91
+		'std' => 'places'
92
+	),
93
+
94
+	array(
95
+		'name' => __('Location url prefix', 'geodirectory'),
96
+		'desc' => __('Depreciated, now uses the location page slug', 'geodirectory'),
97
+		'id' => 'geodir_location_prefix',
98
+		'type' => 'text',
99
+		'css' => 'min-width:300px;',
100
+		'std' => 'location' // Default value to show home top section
101
+	),
102
+
103
+	array(
104
+		'name' => __('Location and category url separator', 'geodirectory'),
105
+		'desc' => __('Separator to show between location and category url slugs in listing urls', 'geodirectory'),
106
+		'id' => 'geodir_listingurl_separator',
107
+		'type' => 'text',
108
+		'css' => 'min-width:300px;',
109
+		'std' => 'C' // Default value to show home top section
110
+	),
111
+
112
+	array(
113
+		'name' => __('Listing detail url separator', 'geodirectory'),
114
+		'desc' => __('Separator to show before listing slug in listing detail urls', 'geodirectory'),
115
+		'id' => 'geodir_detailurl_separator',
116
+		'type' => 'text',
117
+		'css' => 'min-width:300px;',
118
+		'std' => 'info' // Default value to show home top section
119
+	),
120
+
121
+
122
+	array('type' => 'sectionend', 'id' => 'geodir_permalink'),
123
+
124
+	array('name' => __('GeoDirectory Pages', 'geodirectory'),
125
+		'type' => 'sectionstart',
126
+		'desc' => '',
127
+		'id' => 'geodir_pages'),
128
+
129
+	array(
130
+		'name' => __('GD Home page', 'geodirectory'),
131
+		'desc' => __('Select the page to use for the GD homepage (you must also set this page in Settings>Reading>Front page for it to work)', 'geodirectory'),
132
+		'id' => 'geodir_home_page',
133
+		'type' => 'single_select_page',
134
+		'class' => 'chosen_select'
135
+	),
136
+
137
+	array(
138
+		'name' => __('Add listing page', 'geodirectory'),
139
+		'desc' => __('Select the page to use for adding listings', 'geodirectory'),
140
+		'id' => 'geodir_add_listing_page',
141
+		'type' => 'single_select_page',
142
+		'class' => 'chosen_select'
143
+	),
144
+
145
+	array(
146
+		'name' => __('Listing preview page', 'geodirectory'),
147
+		'desc' => __('Select the page to use for listing preview', 'geodirectory'),
148
+		'id' => 'geodir_preview_page',
149
+		'type' => 'single_select_page',
150
+		'class' => 'chosen_select'
151
+	),
152
+
153
+	array(
154
+		'name' => __('Listing success page', 'geodirectory'),
155
+		'desc' => __('Select the page to use for listing success', 'geodirectory'),
156
+		'id' => 'geodir_success_page',
157
+		'type' => 'single_select_page',
158
+		'class' => 'chosen_select'
159
+	),
160
+
161
+	array(
162
+		'name' => __('Location page', 'geodirectory'),
163
+		'desc' => __('Select the page to use for locations', 'geodirectory'),
164
+		'id' => 'geodir_location_page',
165
+		'type' => 'single_select_page',
166
+		'class' => 'chosen_select'
167
+	),
168
+
169
+	array(
170
+		'name' => __('Terms and Conditions page', 'geodirectory'),
171
+		'desc' => __('Select the page to use for Terms and Conditions (if enabled)', 'geodirectory'),
172
+		'id' => 'geodir_term_condition_page',
173
+		'type' => 'single_select_page',
174
+		'class' => 'chosen_select'
175
+	),
176
+
177
+	array(
178
+		'name' => __('Info page', 'geodirectory'),
179
+		'desc' => __('Select the page to use for Gd general Info', 'geodirectory'),
180
+		'id' => 'geodir_info_page',
181
+		'type' => 'single_select_page',
182
+		'class' => 'chosen_select'
183
+	),
184
+
185
+	array(
186
+		'name' => __('Login page', 'geodirectory'),
187
+		'desc' => __('Select the page to use for Login / Register', 'geodirectory'),
188
+		'id' => 'geodir_login_page',
189
+		'type' => 'single_select_page',
190
+		'class' => 'chosen_select'
191
+	),
192
+
193
+
194
+	array('type' => 'sectionend', 'id' => 'geodir_pages'),
195
+
196
+	/* Listing Detail Permalink Settings End */
197 197
 
198 198
 
199 199
 )); // End Design settings
Please login to merge, or discard this patch.
geodirectory-functions/compatibility/Divi.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -18,11 +18,11 @@  discard block
 block discarded – undo
18 18
  */
19 19
 function geodir_divi_signup_body_class($classes)
20 20
 {
21
-    if (geodir_is_page('login')) {
22
-        $classes = str_replace('et_right_sidebar', 'et_full_width_page', $classes);
23
-        $classes[] = 'divi-gd-signup';
24
-    }
25
-    return $classes;
21
+	if (geodir_is_page('login')) {
22
+		$classes = str_replace('et_right_sidebar', 'et_full_width_page', $classes);
23
+		$classes[] = 'divi-gd-signup';
24
+	}
25
+	return $classes;
26 26
 }
27 27
 
28 28
 add_action('geodir_wrapper_close', 'geodir_divi_action_wrapper_close', 11);
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
  */
35 35
 function geodir_divi_action_wrapper_close()
36 36
 {
37
-    if (geodir_is_page('login')) {
38
-        // We need to close extra divs generated by WRAPPER BEFORE MAIN CONTENT (below) because there is no sidebar on this page
39
-        echo '</div></div>';
40
-    }
37
+	if (geodir_is_page('login')) {
38
+		// We need to close extra divs generated by WRAPPER BEFORE MAIN CONTENT (below) because there is no sidebar on this page
39
+		echo '</div></div>';
40
+	}
41 41
 }
42 42
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory-functions/compatibility/Multi_News.php 3 patches
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -126,8 +126,10 @@
 block discarded – undo
126 126
     $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>";
127 127
     if (preg_match_all("/$regexp/siU", $crums, $matches)) {
128 128
         return $matches[0];
129
-    } else return '';
130
-}
129
+    } else {
130
+    	return '';
131
+    }
132
+    }
131 133
 
132 134
 
133 135
 /**
Please login to merge, or discard this patch.
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -16,36 +16,36 @@  discard block
 block discarded – undo
16 16
  */
17 17
 function multi_news_action_calls()
18 18
 {
19
-    // REMOVE BREADCRUMB
20
-    remove_action('geodir_detail_before_main_content', 'geodir_breadcrumb', 20);
21
-    remove_action('geodir_listings_before_main_content', 'geodir_breadcrumb', 20);
22
-    remove_action('geodir_author_before_main_content', 'geodir_breadcrumb', 20);
23
-    remove_action('geodir_search_before_main_content', 'geodir_breadcrumb', 20);
24
-    remove_action('geodir_home_before_main_content', 'geodir_breadcrumb', 20);
25
-    remove_action('geodir_location_before_main_content', 'geodir_breadcrumb', 20);
26
-
27
-    //ADD BREADCRUMS
28
-    add_action('geodir_detail_before_main_content', 'gd_mn_replace_breadcrums', 20);
29
-    add_action('geodir_listings_before_main_content', 'gd_mn_replace_breadcrums', 20);
30
-    add_action('geodir_author_before_main_content', 'gd_mn_replace_breadcrums', 20);
31
-    add_action('geodir_search_before_main_content', 'gd_mn_replace_breadcrums', 20);
32
-    //add_action('geodir_home_before_main_content', 'gd_mn_replace_breadcrums', 20);
33
-    add_action('geodir_location_before_main_content', 'gd_mn_replace_breadcrums', 20);
34
-
35
-
36
-    // fix breadcrums
37
-    add_filter('breadcrumbs_plus_items', 'gd_breadcrumbs_plus_items', 1);
38
-
39
-    // REMOVE PAGE TITLES
40
-    remove_action('geodir_listings_page_title', 'geodir_action_listings_title', 10);
41
-    // remove_action( 'geodir_add_listing_page_title', 'geodir_action_add_listing_page_title',10);
42
-    remove_action('geodir_details_main_content', 'geodir_action_page_title', 20);
43
-    remove_action('geodir_search_page_title', 'geodir_action_search_page_title', 10);
44
-    remove_action('geodir_author_page_title', 'geodir_action_author_page_title', 10);
45
-
46
-
47
-    add_action('geodir_wrapper_content_open', 'gd_mn_extra_wrap', 30, 1);
48
-    add_action('geodir_wrapper_content_close', 'gd_mn_extra_wrap_end', 3, 1);
19
+	// REMOVE BREADCRUMB
20
+	remove_action('geodir_detail_before_main_content', 'geodir_breadcrumb', 20);
21
+	remove_action('geodir_listings_before_main_content', 'geodir_breadcrumb', 20);
22
+	remove_action('geodir_author_before_main_content', 'geodir_breadcrumb', 20);
23
+	remove_action('geodir_search_before_main_content', 'geodir_breadcrumb', 20);
24
+	remove_action('geodir_home_before_main_content', 'geodir_breadcrumb', 20);
25
+	remove_action('geodir_location_before_main_content', 'geodir_breadcrumb', 20);
26
+
27
+	//ADD BREADCRUMS
28
+	add_action('geodir_detail_before_main_content', 'gd_mn_replace_breadcrums', 20);
29
+	add_action('geodir_listings_before_main_content', 'gd_mn_replace_breadcrums', 20);
30
+	add_action('geodir_author_before_main_content', 'gd_mn_replace_breadcrums', 20);
31
+	add_action('geodir_search_before_main_content', 'gd_mn_replace_breadcrums', 20);
32
+	//add_action('geodir_home_before_main_content', 'gd_mn_replace_breadcrums', 20);
33
+	add_action('geodir_location_before_main_content', 'gd_mn_replace_breadcrums', 20);
34
+
35
+
36
+	// fix breadcrums
37
+	add_filter('breadcrumbs_plus_items', 'gd_breadcrumbs_plus_items', 1);
38
+
39
+	// REMOVE PAGE TITLES
40
+	remove_action('geodir_listings_page_title', 'geodir_action_listings_title', 10);
41
+	// remove_action( 'geodir_add_listing_page_title', 'geodir_action_add_listing_page_title',10);
42
+	remove_action('geodir_details_main_content', 'geodir_action_page_title', 20);
43
+	remove_action('geodir_search_page_title', 'geodir_action_search_page_title', 10);
44
+	remove_action('geodir_author_page_title', 'geodir_action_author_page_title', 10);
45
+
46
+
47
+	add_action('geodir_wrapper_content_open', 'gd_mn_extra_wrap', 30, 1);
48
+	add_action('geodir_wrapper_content_close', 'gd_mn_extra_wrap_end', 3, 1);
49 49
 }
50 50
 
51 51
 /**
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
  */
58 58
 function gd_mn_extra_wrap($page)
59 59
 {
60
-    if ($page == 'add-listing-page') {
61
-        echo '<div class="site-content page-wrap">';
62
-    } elseif ($page == 'signup-page') {
63
-        echo '</div><div class="section full-width-section" style="float: left;width:100%;">';
64
-    }
60
+	if ($page == 'add-listing-page') {
61
+		echo '<div class="site-content page-wrap">';
62
+	} elseif ($page == 'signup-page') {
63
+		echo '</div><div class="section full-width-section" style="float: left;width:100%;">';
64
+	}
65 65
 
66 66
 }
67 67
 
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
  */
76 76
 function gd_mn_extra_wrap_end($page)
77 77
 {
78
-    if ($page == 'add-listing-page') {
79
-        echo '</div>';
80
-    }
78
+	if ($page == 'add-listing-page') {
79
+		echo '</div>';
80
+	}
81 81
 
82 82
 }
83 83
 
@@ -91,13 +91,13 @@  discard block
 block discarded – undo
91 91
 function gd_mn_replace_breadcrums()
92 92
 {
93 93
 
94
-    if (mom_option('breadcrumb') != 0) { ?>
94
+	if (mom_option('breadcrumb') != 0) { ?>
95 95
         <?php if (mom_option('cats_bread')) {
96
-            $cclass = '';
97
-            if (mom_option('cat_slider') == false) {
98
-                $cclass = 'post-crumbs ';
99
-            }
100
-            ?>
96
+			$cclass = '';
97
+			if (mom_option('cat_slider') == false) {
98
+				$cclass = 'post-crumbs ';
99
+			}
100
+			?>
101 101
             <div class="<?php echo $cclass; ?>entry-crumbs" xmlns:v="http://rdf.data-vocabulary.org/#">
102 102
 
103 103
                 <?php mom_breadcrumb(); ?>
@@ -119,14 +119,14 @@  discard block
 block discarded – undo
119 119
  */
120 120
 function gd_get_breadcrum_links()
121 121
 {
122
-    ob_start();
123
-    geodir_breadcrumb();
124
-    $crums = ob_get_contents();
125
-    ob_get_clean();
126
-    $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>";
127
-    if (preg_match_all("/$regexp/siU", $crums, $matches)) {
128
-        return $matches[0];
129
-    } else return '';
122
+	ob_start();
123
+	geodir_breadcrumb();
124
+	$crums = ob_get_contents();
125
+	ob_get_clean();
126
+	$regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>";
127
+	if (preg_match_all("/$regexp/siU", $crums, $matches)) {
128
+		return $matches[0];
129
+	} else return '';
130 130
 }
131 131
 
132 132
 
@@ -140,30 +140,30 @@  discard block
 block discarded – undo
140 140
  */
141 141
 function gd_breadcrumbs_plus_items($items)
142 142
 {   //print_r($items);exit;
143
-    $bits = array();
144
-    $pieces = gd_get_breadcrum_links();
145
-    //unset($pieces[0]);
146
-    $bits = $pieces;
143
+	$bits = array();
144
+	$pieces = gd_get_breadcrum_links();
145
+	//unset($pieces[0]);
146
+	$bits = $pieces;
147 147
 
148
-    $title = $items['last'];
149
-    if (is_page_geodir_home() || geodir_is_page('location')) {
148
+	$title = $items['last'];
149
+	if (is_page_geodir_home() || geodir_is_page('location')) {
150 150
 
151
-    } elseif (geodir_is_page('listing')) {
151
+	} elseif (geodir_is_page('listing')) {
152 152
 
153
-    } elseif (geodir_is_page('detail')) {
154
-        ob_start();
155
-        geodir_action_page_title();
156
-        $title = ob_get_contents();
157
-        ob_end_clean();
158
-    } elseif (geodir_is_page('search')) {
159
-    } elseif (geodir_is_page('author')) {
160
-    }
153
+	} elseif (geodir_is_page('detail')) {
154
+		ob_start();
155
+		geodir_action_page_title();
156
+		$title = ob_get_contents();
157
+		ob_end_clean();
158
+	} elseif (geodir_is_page('search')) {
159
+	} elseif (geodir_is_page('author')) {
160
+	}
161 161
 
162
-    $title = strip_tags($title);
163
-    $items = gd_breadcrumbs_plus_items_add($items, $bits, $title);
162
+	$title = strip_tags($title);
163
+	$items = gd_breadcrumbs_plus_items_add($items, $bits, $title);
164 164
 
165 165
 
166
-    return $items;
166
+	return $items;
167 167
 }
168 168
 
169 169
 
@@ -179,28 +179,28 @@  discard block
 block discarded – undo
179 179
  */
180 180
 function gd_breadcrumbs_plus_items_add($items, $bits, $last)
181 181
 {
182
-    //$pieces = explode("</div>", $items[0]);
183
-    if (is_array($bits)) {
184
-        $items = array();
185
-        $pieces = '';
186
-        foreach ($bits as $bit) {
187
-            $pieces .= $bit;
188
-        }
189
-        $items[0] = '<div class="vbreadcrumb" typeof="v:Breadcrumb">' . $pieces . "</div>";
190
-        if (isset($last) && $last) {
191
-            $items['last'] = $last;
192
-        }
193
-    }
194
-
195
-    //print_r($items);
196
-    return $items;
182
+	//$pieces = explode("</div>", $items[0]);
183
+	if (is_array($bits)) {
184
+		$items = array();
185
+		$pieces = '';
186
+		foreach ($bits as $bit) {
187
+			$pieces .= $bit;
188
+		}
189
+		$items[0] = '<div class="vbreadcrumb" typeof="v:Breadcrumb">' . $pieces . "</div>";
190
+		if (isset($last) && $last) {
191
+			$items['last'] = $last;
192
+		}
193
+	}
194
+
195
+	//print_r($items);
196
+	return $items;
197 197
 
198 198
 }
199 199
 
200 200
 add_filter('geodir_menu_after_sub_ul','gd_multinews_mobile_menu_caret',10,1);
201 201
 add_filter('geodir_location_switcher_menu_after_sub_ul','gd_multinews_mobile_menu_caret',10,1);
202 202
 function gd_multinews_mobile_menu_caret($html){
203
-    $html .= '<i class="responsive-caret"></i>';
204
-    return $html;
203
+	$html .= '<i class="responsive-caret"></i>';
204
+	return $html;
205 205
 
206 206
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
         foreach ($bits as $bit) {
187 187
             $pieces .= $bit;
188 188
         }
189
-        $items[0] = '<div class="vbreadcrumb" typeof="v:Breadcrumb">' . $pieces . "</div>";
189
+        $items[0] = '<div class="vbreadcrumb" typeof="v:Breadcrumb">'.$pieces."</div>";
190 190
         if (isset($last) && $last) {
191 191
             $items['last'] = $last;
192 192
         }
@@ -197,9 +197,9 @@  discard block
 block discarded – undo
197 197
 
198 198
 }
199 199
 
200
-add_filter('geodir_menu_after_sub_ul','gd_multinews_mobile_menu_caret',10,1);
201
-add_filter('geodir_location_switcher_menu_after_sub_ul','gd_multinews_mobile_menu_caret',10,1);
202
-function gd_multinews_mobile_menu_caret($html){
200
+add_filter('geodir_menu_after_sub_ul', 'gd_multinews_mobile_menu_caret', 10, 1);
201
+add_filter('geodir_location_switcher_menu_after_sub_ul', 'gd_multinews_mobile_menu_caret', 10, 1);
202
+function gd_multinews_mobile_menu_caret($html) {
203 203
     $html .= '<i class="responsive-caret"></i>';
204 204
     return $html;
205 205
 
Please login to merge, or discard this patch.
geodirectory-templates/geodir-signup.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,8 +13,8 @@
 block discarded – undo
13 13
  * If user is not signed in, redirect home.
14 14
  */
15 15
 if (get_current_user_id()) {
16
-    wp_redirect(home_url(), 302);
17
-    exit;
16
+	wp_redirect(home_url(), 302);
17
+	exit;
18 18
 }
19 19
 
20 20
 // call header
Please login to merge, or discard this patch.
geodirectory-templates/preview-success.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -15,29 +15,29 @@  discard block
 block discarded – undo
15 15
     <?php
16 16
 
17 17
 
18
-    global $wpdb;
18
+	global $wpdb;
19 19
 
20
-    $post_id = $_REQUEST['pid'];
21
-    $post_info = get_post($post_id);
20
+	$post_id = $_REQUEST['pid'];
21
+	$post_info = get_post($post_id);
22 22
 
23
-    $posted_date = $post_info->post_date;
24
-    $productlink = get_permalink($post_id);
25
-    $siteName = get_bloginfo('name');
26
-    $siteurl = home_url();
27
-    $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
23
+	$posted_date = $post_info->post_date;
24
+	$productlink = get_permalink($post_id);
25
+	$siteName = get_bloginfo('name');
26
+	$siteurl = home_url();
27
+	$siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
28 28
 
29
-    $loginurl = geodir_login_url();
30
-    $loginurl_link = '<a href="' . $loginurl . '">login</a>';
29
+	$loginurl = geodir_login_url();
30
+	$loginurl_link = '<a href="' . $loginurl . '">login</a>';
31 31
 
32
-    $post_author = $post_info->post_author;
32
+	$post_author = $post_info->post_author;
33 33
 
34
-    $user_info = get_userdata($post_author);
35
-    $username = $user_info->user_login;
36
-    $user_email = $user_info->user_email;
34
+	$user_info = get_userdata($post_author);
35
+	$username = $user_info->user_login;
36
+	$user_email = $user_info->user_email;
37 37
 
38
-    $message = wpautop(__(stripslashes_deep(get_option('geodir_post_added_success_msg_content')),'geodirectory'));
38
+	$message = wpautop(__(stripslashes_deep(get_option('geodir_post_added_success_msg_content')),'geodirectory'));
39 39
 
40
-    /*
40
+	/*
41 41
      * Filter the success page message before variable replacements.
42 42
      *
43 43
      * @since 1.5.7
@@ -45,13 +45,13 @@  discard block
 block discarded – undo
45 45
      * @param object $post_info Post object.
46 46
      * @param object $user_info User object.
47 47
      */
48
-    $message = apply_filters('geodir_success_page_msg_before_var_replace', $message,$post_info, $user_info);
48
+	$message = apply_filters('geodir_success_page_msg_before_var_replace', $message,$post_info, $user_info);
49 49
 
50
-    $search_array = array('[#submited_information_link#]', '[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#user_email#]', '[#username#]', '[#login_url#]', '[#posted_date#]');
51
-    $replace_array = array($productlink, $productlink, $siteurl_link, $post_id, $siteName, $user_email, $username, $loginurl_link, $posted_date);
52
-    $message = str_replace($search_array, $replace_array, $message);
50
+	$search_array = array('[#submited_information_link#]', '[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#user_email#]', '[#username#]', '[#login_url#]', '[#posted_date#]');
51
+	$replace_array = array($productlink, $productlink, $siteurl_link, $post_id, $siteName, $user_email, $username, $loginurl_link, $posted_date);
52
+	$message = str_replace($search_array, $replace_array, $message);
53 53
 
54
-    /*
54
+	/*
55 55
      * Filter the success page message after variable replacements.
56 56
      *
57 57
      * @since 1.5.7
@@ -59,15 +59,15 @@  discard block
 block discarded – undo
59 59
      * @param object $post_info Post object.
60 60
      * @param object $user_info User object.
61 61
      */
62
-    $message = apply_filters('geodir_success_page_msg_after_var_replace', $message,$post_info, $user_info);
62
+	$message = apply_filters('geodir_success_page_msg_after_var_replace', $message,$post_info, $user_info);
63 63
 
64 64
 
65 65
 
66
-    ?>
66
+	?>
67 67
 
68 68
     <?php
69 69
 
70
-    /*
70
+	/*
71 71
      * Action called before the success page message wrapper.
72 72
      *
73 73
      * @since 1.5.7
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
      * @param object $post_info Post object.
76 76
      * @param object $user_info User object.
77 77
      */
78
-    do_action('geodir_before_success_page_msg_wrapper', $message,$post_info, $user_info);
79
-    echo '<h5 class="geodir_information">';
80
-    echo $message;
81
-    echo '</h5>';
82
-    /*
78
+	do_action('geodir_before_success_page_msg_wrapper', $message,$post_info, $user_info);
79
+	echo '<h5 class="geodir_information">';
80
+	echo $message;
81
+	echo '</h5>';
82
+	/*
83 83
      * Action called after the success page message wrapper.
84 84
      *
85 85
      * @since 1.5.7
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
      * @param object $post_info Post object.
88 88
      * @param object $user_info User object.
89 89
      */
90
-    do_action('geodir_after_success_page_msg_wrapper', $message,$post_info, $user_info);
90
+	do_action('geodir_after_success_page_msg_wrapper', $message,$post_info, $user_info);
91 91
 
92
-    ?>
92
+	?>
93 93
 
94 94
 </div>
95 95
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
     $productlink = get_permalink($post_id);
25 25
     $siteName = get_bloginfo('name');
26 26
     $siteurl = home_url();
27
-    $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
27
+    $siteurl_link = '<a href="'.$siteurl.'">'.$siteurl.'</a>';
28 28
 
29 29
     $loginurl = geodir_login_url();
30
-    $loginurl_link = '<a href="' . $loginurl . '">login</a>';
30
+    $loginurl_link = '<a href="'.$loginurl.'">login</a>';
31 31
 
32 32
     $post_author = $post_info->post_author;
33 33
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     $username = $user_info->user_login;
36 36
     $user_email = $user_info->user_email;
37 37
 
38
-    $message = wpautop(__(stripslashes_deep(get_option('geodir_post_added_success_msg_content')),'geodirectory'));
38
+    $message = wpautop(__(stripslashes_deep(get_option('geodir_post_added_success_msg_content')), 'geodirectory'));
39 39
 
40 40
     /*
41 41
      * Filter the success page message before variable replacements.
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
      * @param object $post_info Post object.
46 46
      * @param object $user_info User object.
47 47
      */
48
-    $message = apply_filters('geodir_success_page_msg_before_var_replace', $message,$post_info, $user_info);
48
+    $message = apply_filters('geodir_success_page_msg_before_var_replace', $message, $post_info, $user_info);
49 49
 
50 50
     $search_array = array('[#submited_information_link#]', '[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#user_email#]', '[#username#]', '[#login_url#]', '[#posted_date#]');
51 51
     $replace_array = array($productlink, $productlink, $siteurl_link, $post_id, $siteName, $user_email, $username, $loginurl_link, $posted_date);
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      * @param object $post_info Post object.
60 60
      * @param object $user_info User object.
61 61
      */
62
-    $message = apply_filters('geodir_success_page_msg_after_var_replace', $message,$post_info, $user_info);
62
+    $message = apply_filters('geodir_success_page_msg_after_var_replace', $message, $post_info, $user_info);
63 63
 
64 64
 
65 65
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
      * @param object $post_info Post object.
76 76
      * @param object $user_info User object.
77 77
      */
78
-    do_action('geodir_before_success_page_msg_wrapper', $message,$post_info, $user_info);
78
+    do_action('geodir_before_success_page_msg_wrapper', $message, $post_info, $user_info);
79 79
     echo '<h5 class="geodir_information">';
80 80
     echo $message;
81 81
     echo '</h5>';
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
      * @param object $post_info Post object.
88 88
      * @param object $user_info User object.
89 89
      */
90
-    do_action('geodir_after_success_page_msg_wrapper', $message,$post_info, $user_info);
90
+    do_action('geodir_after_success_page_msg_wrapper', $message, $post_info, $user_info);
91 91
 
92 92
     ?>
93 93
 
Please login to merge, or discard this patch.
geodirectory-widgets/geodirectory_bestof_widget.php 3 patches
Braces   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -356,10 +356,11 @@  discard block
 block discarded – undo
356 356
         $instance['character_count'] = $new_instance['character_count'];
357 357
         $instance['tab_layout'] = $new_instance['tab_layout'];
358 358
         $instance['excerpt_type'] = $new_instance['excerpt_type'];
359
-        if (isset($new_instance['add_location_filter']) && $new_instance['add_location_filter'] != '')
360
-            $instance['add_location_filter'] = strip_tags($new_instance['add_location_filter']);
361
-        else
362
-            $instance['add_location_filter'] = '0';
359
+        if (isset($new_instance['add_location_filter']) && $new_instance['add_location_filter'] != '') {
360
+                    $instance['add_location_filter'] = strip_tags($new_instance['add_location_filter']);
361
+        } else {
362
+                    $instance['add_location_filter'] = '0';
363
+        }
363 364
         $instance['use_viewing_post_type'] = isset($new_instance['use_viewing_post_type']) && $new_instance['use_viewing_post_type'] ? 1 : 0;
364 365
         return $instance;
365 366
     }
@@ -510,7 +511,10 @@  discard block
 block discarded – undo
510 511
             <label for="<?php echo $this->get_field_id('add_location_filter'); ?>">
511 512
                 <?php _e('Enable Location Filter:', 'geodirectory');?>
512 513
                 <input type="checkbox" id="<?php echo $this->get_field_id('add_location_filter'); ?>"
513
-                       name="<?php echo $this->get_field_name('add_location_filter'); ?>" <?php if ($add_location_filter) echo 'checked="checked"';?>
514
+                       name="<?php echo $this->get_field_name('add_location_filter'); ?>" <?php if ($add_location_filter) {
515
+	echo 'checked="checked"';
516
+}
517
+?>
514 518
                        value="1"/>
515 519
             </label>
516 520
         </p>
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
          * @param string $instance ['tab_layout'] Best of widget tab layout name.
52 52
          */
53 53
         $tab_layout = empty($instance['tab_layout']) ? 'bestof-tabs-on-top' : apply_filters('bestof_widget_tab_layout', $instance['tab_layout']);
54
-        echo '<div class="bestof-widget-tab-layout ' . $tab_layout . '">';
54
+        echo '<div class="bestof-widget-tab-layout '.$tab_layout.'">';
55 55
         echo $before_widget;
56 56
         $loc_terms = geodir_get_current_location_terms();
57 57
         if (!empty($loc_terms)) {
58
-            $cur_location = ' : ' . geodir_ucwords(str_replace('-', ' ', end($loc_terms)));
58
+            $cur_location = ' : '.geodir_ucwords(str_replace('-', ' ', end($loc_terms)));
59 59
         } else {
60 60
             $cur_location = '';
61 61
         }
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
          *
77 77
          * @param string $instance ['title'] The widget title.
78 78
          */
79
-        $title = empty($instance['title']) ? wp_sprintf(__('Best of %s', 'geodirectory'), get_bloginfo('name') . $cur_location) : apply_filters('bestof_widget_title', __($instance['title'], 'geodirectory'));
79
+        $title = empty($instance['title']) ? wp_sprintf(__('Best of %s', 'geodirectory'), get_bloginfo('name').$cur_location) : apply_filters('bestof_widget_title', __($instance['title'], 'geodirectory'));
80 80
 
81 81
         /**
82 82
          * Filter the post type.
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
         }
203 203
 
204 204
 
205
-        echo $before_title . __($title,'geodirectory') . $after_title;
205
+        echo $before_title.__($title, 'geodirectory').$after_title;
206 206
 
207 207
         //term navigation - start
208 208
         echo '<div class="geodir-tabs gd-bestof-tabs" id="gd-bestof-tabs" style="position:relative;">';
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
             $is_dropdown = ($tab_layout == 'bestof-tabs-as-dropdown') ? true : false;
214 214
 
215 215
             if ($is_dropdown) {
216
-                $nav_html .= '<select id="geodir_bestof_tab_dd" class="chosen_select" name="geodir_bestof_tab_dd" data-placeholder="' . esc_attr(__('Select Category', 'geodirectory')) . '">';
216
+                $nav_html .= '<select id="geodir_bestof_tab_dd" class="chosen_select" name="geodir_bestof_tab_dd" data-placeholder="'.esc_attr(__('Select Category', 'geodirectory')).'">';
217 217
             } else {
218 218
                 $nav_html .= '<dl class="geodir-tab-head geodir-bestof-cat-list">';
219 219
                 $nav_html .= '<dt></dt>';
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
                     }
231 231
                     if ($is_dropdown) {
232 232
                         $selected = ($cat_count == 1) ? 'selected="selected"' : '';
233
-                        $nav_html .= '<option ' . $selected . ' value="' . $cat->term_id . '">' . geodir_ucwords($cat->name) . '</option>';
233
+                        $nav_html .= '<option '.$selected.' value="'.$cat->term_id.'">'.geodir_ucwords($cat->name).'</option>';
234 234
                     } else {
235 235
                         if ($cat_count == 1) {
236 236
                             $nav_html .= '<dd class="geodir-tab-active">';
@@ -238,8 +238,8 @@  discard block
 block discarded – undo
238 238
                             $nav_html .= '<dd class="">';
239 239
                         }
240 240
                         $term_icon_url = !empty($term_icon) && isset($term_icon[$cat->term_id]) ? $term_icon[$cat->term_id] : '';
241
-                        $nav_html .= '<a data-termid="' . $cat->term_id . '" href="' . get_term_link($cat, $cat->taxonomy) . '">';
242
-                        $nav_html .= '<img alt="' . $cat->name . ' icon" class="bestof-cat-icon" src="' . $term_icon_url . '"/>';
241
+                        $nav_html .= '<a data-termid="'.$cat->term_id.'" href="'.get_term_link($cat, $cat->taxonomy).'">';
242
+                        $nav_html .= '<img alt="'.$cat->name.' icon" class="bestof-cat-icon" src="'.$term_icon_url.'"/>';
243 243
                         $nav_html .= '<span>';
244 244
                         $nav_html .= geodir_ucwords($cat->name);
245 245
                         $nav_html .= '<small>';
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
                             if ($num_reviews == 0) {
249 249
                                 $reviews = __('No Reviews', 'geodirectory');
250 250
                             } elseif ($num_reviews > 1) {
251
-                                $reviews = $num_reviews . __(' Reviews', 'geodirectory');
251
+                                $reviews = $num_reviews.__(' Reviews', 'geodirectory');
252 252
                             } else {
253 253
                                 $reviews = __('1 Review', 'geodirectory');
254 254
                             }
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
                  */
322 322
                 $view_all_link = apply_filters('geodir_bestof_widget_view_all_link', $view_all_link, $post_type, $first_term);
323 323
 
324
-                echo '<h3 class="bestof-cat-title">' . wp_sprintf(__('Best of %s', 'geodirectory'), $first_term->name) . '<a href="' . esc_url($view_all_link) . '">' . __("View all", 'geodirectory') . '</a></h3>';
324
+                echo '<h3 class="bestof-cat-title">'.wp_sprintf(__('Best of %s', 'geodirectory'), $first_term->name).'<a href="'.esc_url($view_all_link).'">'.__("View all", 'geodirectory').'</a></h3>';
325 325
             }
326 326
             if ($excerpt_type == 'show-reviews') {
327 327
                 add_filter('get_the_excerpt', 'best_of_show_review_in_excerpt');
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
      */
379 379
     public function form($instance)
380 380
     {
381
-        $instance = wp_parse_args((array)$instance,
381
+        $instance = wp_parse_args((array) $instance,
382 382
             array(
383 383
                 'title' => '',
384 384
                 'post_type' => '',
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 
404 404
         ?>
405 405
         <p>
406
-            <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'geodirectory');?>
406
+            <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'geodirectory'); ?>
407 407
 
408 408
                 <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>"
409 409
                        name="<?php echo $this->get_field_name('title'); ?>" type="text"
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
 
414 414
         <p>
415 415
             <label
416
-                for="<?php echo $this->get_field_id('post_type'); ?>"><?php _e('Post Type:', 'geodirectory');?>
416
+                for="<?php echo $this->get_field_id('post_type'); ?>"><?php _e('Post Type:', 'geodirectory'); ?>
417 417
 
418 418
                 <?php $postypes = geodir_get_posttypes();
419 419
                 /**
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
         <p>
446 446
 
447 447
             <label
448
-                for="<?php echo $this->get_field_id('post_limit'); ?>"><?php _e('Number of posts:', 'geodirectory');?>
448
+                for="<?php echo $this->get_field_id('post_limit'); ?>"><?php _e('Number of posts:', 'geodirectory'); ?>
449 449
 
450 450
                 <input class="widefat" id="<?php echo $this->get_field_id('post_limit'); ?>"
451 451
                        name="<?php echo $this->get_field_name('post_limit'); ?>" type="text"
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
         <p>
457 457
 
458 458
             <label
459
-                for="<?php echo $this->get_field_id('categ_limit'); ?>"><?php _e('Number of categories:', 'geodirectory');?>
459
+                for="<?php echo $this->get_field_id('categ_limit'); ?>"><?php _e('Number of categories:', 'geodirectory'); ?>
460 460
 
461 461
                 <input class="widefat" id="<?php echo $this->get_field_id('categ_limit'); ?>"
462 462
                        name="<?php echo $this->get_field_name('categ_limit'); ?>" type="text"
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 
467 467
         <p>
468 468
             <label
469
-                for="<?php echo $this->get_field_id('character_count'); ?>"><?php _e('Post Content excerpt character count :', 'geodirectory');?>
469
+                for="<?php echo $this->get_field_id('character_count'); ?>"><?php _e('Post Content excerpt character count :', 'geodirectory'); ?>
470 470
                 <input class="widefat" id="<?php echo $this->get_field_id('character_count'); ?>"
471 471
                        name="<?php echo $this->get_field_name('character_count'); ?>" type="text"
472 472
                        value="<?php echo esc_attr($character_count); ?>"/>
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
         </p>
475 475
         <p>
476 476
             <label
477
-                for="<?php echo $this->get_field_id('tab_layout'); ?>"><?php _e('Tab Layout:', 'geodirectory');?>
477
+                for="<?php echo $this->get_field_id('tab_layout'); ?>"><?php _e('Tab Layout:', 'geodirectory'); ?>
478 478
 
479 479
                 <select class="widefat" id="<?php echo $this->get_field_id('tab_layout'); ?>"
480 480
                         name="<?php echo $this->get_field_name('tab_layout'); ?>">
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 
496 496
         <p>
497 497
             <label
498
-                for="<?php echo $this->get_field_id('excerpt_type'); ?>"><?php _e('Excerpt Type:', 'geodirectory');?>
498
+                for="<?php echo $this->get_field_id('excerpt_type'); ?>"><?php _e('Excerpt Type:', 'geodirectory'); ?>
499 499
 
500 500
                 <select class="widefat" id="<?php echo $this->get_field_id('excerpt_type'); ?>"
501 501
                         name="<?php echo $this->get_field_name('excerpt_type'); ?>">
@@ -512,9 +512,9 @@  discard block
 block discarded – undo
512 512
 
513 513
         <p>
514 514
             <label for="<?php echo $this->get_field_id('add_location_filter'); ?>">
515
-                <?php _e('Enable Location Filter:', 'geodirectory');?>
515
+                <?php _e('Enable Location Filter:', 'geodirectory'); ?>
516 516
                 <input type="checkbox" id="<?php echo $this->get_field_id('add_location_filter'); ?>"
517
-                       name="<?php echo $this->get_field_name('add_location_filter'); ?>" <?php if ($add_location_filter) echo 'checked="checked"';?>
517
+                       name="<?php echo $this->get_field_name('add_location_filter'); ?>" <?php if ($add_location_filter) echo 'checked="checked"'; ?>
518 518
                        value="1"/>
519 519
             </label>
520 520
         </p>
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
         /** This filter is documented in geodirectory-widgets/geodirectory_bestof_widget.php */
663 663
         $view_all_link = apply_filters('geodir_bestof_widget_view_all_link', $view_all_link, $post_type, $term);
664 664
 
665
-        echo '<h3 class="bestof-cat-title">' . wp_sprintf(__('Best of %s', 'geodirectory'), $term->name) . '<a href="' . esc_url($view_all_link) . '">' . __("View all", 'geodirectory') . '</a></h3>';
665
+        echo '<h3 class="bestof-cat-title">'.wp_sprintf(__('Best of %s', 'geodirectory'), $term->name).'<a href="'.esc_url($view_all_link).'">'.__("View all", 'geodirectory').'</a></h3>';
666 666
     }
667 667
     if ($excerpt_type == 'show-reviews') {
668 668
         add_filter('get_the_excerpt', 'best_of_show_review_in_excerpt');
Please login to merge, or discard this patch.
Indentation   +519 added lines, -519 removed lines patch added patch discarded remove patch
@@ -14,282 +14,282 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class geodir_bestof_widget extends WP_Widget
16 16
 {
17
-    /**
18
-     * Register the best of widget with WordPress.
19
-     *
20
-     * @since 1.3.9
21
-     * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct.
22
-     */
23
-    public function __construct()
24
-    {
25
-        $widget_ops = array('classname' => 'geodir_bestof_widget', 'description' => __('GD > Best of widget', 'geodirectory'));
26
-        parent::__construct(
27
-            'bestof_widget', // Base ID
28
-            __('GD > Best of widget', 'geodirectory'), // Name
29
-            $widget_ops// Args
30
-        );
31
-    }
32
-
33
-    /**
34
-     * Front-end display content for best of widget.
35
-     *
36
-     * @since 1.3.9
37
-     * @since 1.5.1 Added filter to view all link.
38
-     * @since 1.5.1 Declare function public.
39
-     *
40
-     * @param array $args Widget arguments.
41
-     * @param array $instance Saved values from database.
42
-     */
43
-    public function widget($args, $instance)
44
-    {
45
-        extract($args);
46
-        /**
47
-         * Filter the best of widget tab layout.
48
-         *
49
-         * @since 1.3.9
50
-         *
51
-         * @param string $instance ['tab_layout'] Best of widget tab layout name.
52
-         */
53
-        $tab_layout = empty($instance['tab_layout']) ? 'bestof-tabs-on-top' : apply_filters('bestof_widget_tab_layout', $instance['tab_layout']);
54
-        echo '<div class="bestof-widget-tab-layout ' . $tab_layout . '">';
55
-        echo $before_widget;
56
-        $loc_terms = geodir_get_current_location_terms();
57
-        if (!empty($loc_terms)) {
58
-            $cur_location = ' : ' . geodir_ucwords(str_replace('-', ' ', end($loc_terms)));
59
-        } else {
60
-            $cur_location = '';
61
-        }
62
-
63
-        /**
64
-         * Filter the current location name.
65
-         *
66
-         * @since 1.3.9
67
-         *
68
-         * @param string $cur_location Current location name.
69
-         */
70
-        $cur_location = apply_filters('bestof_widget_cur_location', $cur_location);
71
-
72
-        /**
73
-         * Filter the widget title.
74
-         *
75
-         * @since 1.3.9
76
-         *
77
-         * @param string $instance ['title'] The widget title.
78
-         */
79
-        $title = empty($instance['title']) ? wp_sprintf(__('Best of %s', 'geodirectory'), get_bloginfo('name') . $cur_location) : apply_filters('bestof_widget_title', __($instance['title'], 'geodirectory'));
80
-
81
-        /**
82
-         * Filter the post type.
83
-         *
84
-         * @since 1.3.9
85
-         *
86
-         * @param string $instance ['post_type'] The post type.
87
-         */
88
-        $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('bestof_widget_post_type', $instance['post_type']);
89
-
90
-        /**
91
-         * Filter the excerpt type.
92
-         *
93
-         * @since 1.5.4
94
-         *
95
-         * @param string $instance ['excerpt_type'] The excerpt type.
96
-         */
97
-        $excerpt_type = empty($instance['excerpt_type']) ? 'show-desc' : apply_filters('bestof_widget_excerpt_type', $instance['excerpt_type']);
98
-
99
-
100
-        /**
101
-         * Filter the listing limit.
102
-         *
103
-         * @since 1.3.9
104
-         *
105
-         * @param int $instance ['post_limit'] No. of posts to display.
106
-         */
107
-        $post_limit = empty($instance['post_limit']) ? '5' : apply_filters('bestof_widget_post_limit', $instance['post_limit']);
108
-
109
-        /**
110
-         * Filter the category limit.
111
-         *
112
-         * @since 1.3.9
113
-         *
114
-         * @param int $instance ['categ_limit'] No. of categories to display.
115
-         */
116
-        $categ_limit = empty($instance['categ_limit']) ? '3' : apply_filters('bestof_widget_categ_limit', $instance['categ_limit']);
117
-        $use_viewing_post_type = !empty($instance['use_viewing_post_type']) ? true : false;
118
-
119
-        /**
120
-         * Filter the use of location filter.
121
-         *
122
-         * @since 1.3.9
123
-         *
124
-         * @param int|bool $instance ['add_location_filter'] Filter listings using current location.
125
-         */
126
-        $add_location_filter = empty($instance['add_location_filter']) ? '1' : apply_filters('bestof_widget_location_filter', $instance['add_location_filter']);
127
-
128
-        // set post type to current viewing post type
129
-        if ($use_viewing_post_type) {
130
-            $current_post_type = geodir_get_current_posttype();
131
-            if ($current_post_type != '' && $current_post_type != $post_type) {
132
-                $post_type = $current_post_type;
133
-            }
134
-        }
135
-
136
-        if (isset($instance['character_count'])) {
137
-            /**
138
-             * Filter the widget's excerpt character count.
139
-             *
140
-             * @since 1.3.9
141
-             *
142
-             * @param int $instance ['character_count'] Excerpt character count.
143
-             */
144
-            $character_count = apply_filters('bestof_widget_list_character_count', $instance['character_count']);
145
-        } else {
146
-            $character_count = '';
147
-        }
148
-
149
-        $category_taxonomy = geodir_get_taxonomies($post_type);
150
-
151
-        $term_args = array(
152
-            'hide_empty' => true,
153
-            'parent' => 0
154
-        );
155
-
156
-        $term_args = apply_filters('bestof_widget_term_args', $term_args);
157
-
158
-        if (is_tax()) {
159
-            $taxonomy = get_query_var('taxonomy');
160
-            $cur_term = get_query_var('term');
161
-            $term_data = get_term_by('name', $cur_term, $taxonomy);
162
-            $term_args['parent'] = $term_data->term_id;
163
-        }
164
-
165
-        $terms = get_terms($category_taxonomy[0], $term_args);
166
-
167
-        $term_reviews = geodir_count_reviews_by_terms();
168
-        $a_terms = array();
169
-        foreach ($terms as $term) {
170
-
171
-
172
-            if ($term->count > 0) {
173
-                if (isset($term_reviews[$term->term_id])) {
174
-                    $term->review_count = $term_reviews[$term->term_id];
175
-                } else {
176
-                    $term->review_count = '0';
177
-                }
178
-
179
-                $a_terms[] = $term;
180
-            }
181
-
182
-        }
183
-
184
-
185
-        $terms = apply_filters('bestof_widget_sort_terms', geodir_sort_terms($a_terms, 'review_count'), $a_terms);
186
-
187
-        $query_args = array(
188
-            'posts_per_page' => $post_limit,
189
-            'is_geodir_loop' => true,
190
-            'post_type' => $post_type,
191
-            'gd_location' => $add_location_filter ? true : false,
192
-            'order_by' => 'high_review'
193
-        );
194
-        if ($character_count >= 0) {
195
-            $query_args['excerpt_length'] = $character_count;
196
-        }
197
-
198
-        $layout = array();
199
-        if ($tab_layout == 'bestof-tabs-as-dropdown') {
200
-            $layout[] = $tab_layout;
201
-        } else {
202
-            $layout[] = 'bestof-tabs-as-dropdown';
203
-            $layout[] = $tab_layout;
204
-        }
205
-
206
-
207
-        echo $before_title . __($title,'geodirectory') . $after_title;
208
-
209
-        //term navigation - start
210
-        echo '<div class="geodir-tabs gd-bestof-tabs" id="gd-bestof-tabs" style="position:relative;">';
211
-
212
-        $final_html = '';
213
-        foreach ($layout as $tab_layout) {
214
-            $nav_html = '';
215
-            $is_dropdown = ($tab_layout == 'bestof-tabs-as-dropdown') ? true : false;
216
-
217
-            if ($is_dropdown) {
218
-                $nav_html .= '<select id="geodir_bestof_tab_dd" class="chosen_select" name="geodir_bestof_tab_dd" data-placeholder="' . esc_attr(__('Select Category', 'geodirectory')) . '">';
219
-            } else {
220
-                $nav_html .= '<dl class="geodir-tab-head geodir-bestof-cat-list">';
221
-                $nav_html .= '<dt></dt>';
222
-            }
223
-
224
-
225
-            $term_icon = geodir_get_term_icon();
226
-            $cat_count = 0;
227
-            if (!empty($terms)) {
228
-                foreach ($terms as $cat) {
229
-                    $cat_count++;
230
-                    if ($cat_count > $categ_limit) {
231
-                        break;
232
-                    }
233
-                    if ($is_dropdown) {
234
-                        $selected = ($cat_count == 1) ? 'selected="selected"' : '';
235
-                        $nav_html .= '<option ' . $selected . ' value="' . $cat->term_id . '">' . geodir_ucwords($cat->name) . '</option>';
236
-                    } else {
237
-                        if ($cat_count == 1) {
238
-                            $nav_html .= '<dd class="geodir-tab-active">';
239
-                        } else {
240
-                            $nav_html .= '<dd class="">';
241
-                        }
242
-                        $term_icon_url = !empty($term_icon) && isset($term_icon[$cat->term_id]) ? $term_icon[$cat->term_id] : '';
243
-                        $nav_html .= '<a data-termid="' . $cat->term_id . '" href="' . get_term_link($cat, $cat->taxonomy) . '">';
244
-                        $nav_html .= '<img alt="' . $cat->name . ' icon" class="bestof-cat-icon" src="' . $term_icon_url . '"/>';
245
-                        $nav_html .= '<span>';
246
-                        $nav_html .= geodir_ucwords($cat->name);
247
-                        $nav_html .= '<small>';
248
-                        if (isset($cat->review_count)) {
249
-                            $num_reviews = $cat->review_count;
250
-                            if ($num_reviews == 0) {
251
-                                $reviews = __('No Reviews', 'geodirectory');
252
-                            } elseif ($num_reviews > 1) {
253
-                                $reviews = $num_reviews . __(' Reviews', 'geodirectory');
254
-                            } else {
255
-                                $reviews = __('1 Review', 'geodirectory');
256
-                            }
257
-                            $nav_html .= $reviews;
258
-                        }
259
-                        $nav_html .= '</small>';
260
-                        $nav_html .= '</span>';
261
-                        $nav_html .= '</a>';
262
-                        $nav_html .= '</dd>';
263
-                    }
264
-                }
265
-            }
266
-
267
-            if ($is_dropdown) {
268
-                $nav_html .= '</select>';
269
-            } else {
270
-                $nav_html .= '</dl>';
271
-            }
272
-            $final_html .= $nav_html;
273
-        }
274
-        if ($terms) {
275
-            echo $final_html;
276
-        }
277
-        echo '</div>';
278
-        //term navigation - end
279
-
280
-        //first term listings by default - start
281
-        $first_term = '';
282
-        if ($terms) {
283
-            $first_term = $terms[0];
284
-            $tax_query = array(
285
-                'taxonomy' => $category_taxonomy[0],
286
-                'field' => 'id',
287
-                'terms' => $first_term->term_id
288
-            );
289
-            $query_args['tax_query'] = array($tax_query);
290
-        }
291
-
292
-        ?>
17
+	/**
18
+	 * Register the best of widget with WordPress.
19
+	 *
20
+	 * @since 1.3.9
21
+	 * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct.
22
+	 */
23
+	public function __construct()
24
+	{
25
+		$widget_ops = array('classname' => 'geodir_bestof_widget', 'description' => __('GD > Best of widget', 'geodirectory'));
26
+		parent::__construct(
27
+			'bestof_widget', // Base ID
28
+			__('GD > Best of widget', 'geodirectory'), // Name
29
+			$widget_ops// Args
30
+		);
31
+	}
32
+
33
+	/**
34
+	 * Front-end display content for best of widget.
35
+	 *
36
+	 * @since 1.3.9
37
+	 * @since 1.5.1 Added filter to view all link.
38
+	 * @since 1.5.1 Declare function public.
39
+	 *
40
+	 * @param array $args Widget arguments.
41
+	 * @param array $instance Saved values from database.
42
+	 */
43
+	public function widget($args, $instance)
44
+	{
45
+		extract($args);
46
+		/**
47
+		 * Filter the best of widget tab layout.
48
+		 *
49
+		 * @since 1.3.9
50
+		 *
51
+		 * @param string $instance ['tab_layout'] Best of widget tab layout name.
52
+		 */
53
+		$tab_layout = empty($instance['tab_layout']) ? 'bestof-tabs-on-top' : apply_filters('bestof_widget_tab_layout', $instance['tab_layout']);
54
+		echo '<div class="bestof-widget-tab-layout ' . $tab_layout . '">';
55
+		echo $before_widget;
56
+		$loc_terms = geodir_get_current_location_terms();
57
+		if (!empty($loc_terms)) {
58
+			$cur_location = ' : ' . geodir_ucwords(str_replace('-', ' ', end($loc_terms)));
59
+		} else {
60
+			$cur_location = '';
61
+		}
62
+
63
+		/**
64
+		 * Filter the current location name.
65
+		 *
66
+		 * @since 1.3.9
67
+		 *
68
+		 * @param string $cur_location Current location name.
69
+		 */
70
+		$cur_location = apply_filters('bestof_widget_cur_location', $cur_location);
71
+
72
+		/**
73
+		 * Filter the widget title.
74
+		 *
75
+		 * @since 1.3.9
76
+		 *
77
+		 * @param string $instance ['title'] The widget title.
78
+		 */
79
+		$title = empty($instance['title']) ? wp_sprintf(__('Best of %s', 'geodirectory'), get_bloginfo('name') . $cur_location) : apply_filters('bestof_widget_title', __($instance['title'], 'geodirectory'));
80
+
81
+		/**
82
+		 * Filter the post type.
83
+		 *
84
+		 * @since 1.3.9
85
+		 *
86
+		 * @param string $instance ['post_type'] The post type.
87
+		 */
88
+		$post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('bestof_widget_post_type', $instance['post_type']);
89
+
90
+		/**
91
+		 * Filter the excerpt type.
92
+		 *
93
+		 * @since 1.5.4
94
+		 *
95
+		 * @param string $instance ['excerpt_type'] The excerpt type.
96
+		 */
97
+		$excerpt_type = empty($instance['excerpt_type']) ? 'show-desc' : apply_filters('bestof_widget_excerpt_type', $instance['excerpt_type']);
98
+
99
+
100
+		/**
101
+		 * Filter the listing limit.
102
+		 *
103
+		 * @since 1.3.9
104
+		 *
105
+		 * @param int $instance ['post_limit'] No. of posts to display.
106
+		 */
107
+		$post_limit = empty($instance['post_limit']) ? '5' : apply_filters('bestof_widget_post_limit', $instance['post_limit']);
108
+
109
+		/**
110
+		 * Filter the category limit.
111
+		 *
112
+		 * @since 1.3.9
113
+		 *
114
+		 * @param int $instance ['categ_limit'] No. of categories to display.
115
+		 */
116
+		$categ_limit = empty($instance['categ_limit']) ? '3' : apply_filters('bestof_widget_categ_limit', $instance['categ_limit']);
117
+		$use_viewing_post_type = !empty($instance['use_viewing_post_type']) ? true : false;
118
+
119
+		/**
120
+		 * Filter the use of location filter.
121
+		 *
122
+		 * @since 1.3.9
123
+		 *
124
+		 * @param int|bool $instance ['add_location_filter'] Filter listings using current location.
125
+		 */
126
+		$add_location_filter = empty($instance['add_location_filter']) ? '1' : apply_filters('bestof_widget_location_filter', $instance['add_location_filter']);
127
+
128
+		// set post type to current viewing post type
129
+		if ($use_viewing_post_type) {
130
+			$current_post_type = geodir_get_current_posttype();
131
+			if ($current_post_type != '' && $current_post_type != $post_type) {
132
+				$post_type = $current_post_type;
133
+			}
134
+		}
135
+
136
+		if (isset($instance['character_count'])) {
137
+			/**
138
+			 * Filter the widget's excerpt character count.
139
+			 *
140
+			 * @since 1.3.9
141
+			 *
142
+			 * @param int $instance ['character_count'] Excerpt character count.
143
+			 */
144
+			$character_count = apply_filters('bestof_widget_list_character_count', $instance['character_count']);
145
+		} else {
146
+			$character_count = '';
147
+		}
148
+
149
+		$category_taxonomy = geodir_get_taxonomies($post_type);
150
+
151
+		$term_args = array(
152
+			'hide_empty' => true,
153
+			'parent' => 0
154
+		);
155
+
156
+		$term_args = apply_filters('bestof_widget_term_args', $term_args);
157
+
158
+		if (is_tax()) {
159
+			$taxonomy = get_query_var('taxonomy');
160
+			$cur_term = get_query_var('term');
161
+			$term_data = get_term_by('name', $cur_term, $taxonomy);
162
+			$term_args['parent'] = $term_data->term_id;
163
+		}
164
+
165
+		$terms = get_terms($category_taxonomy[0], $term_args);
166
+
167
+		$term_reviews = geodir_count_reviews_by_terms();
168
+		$a_terms = array();
169
+		foreach ($terms as $term) {
170
+
171
+
172
+			if ($term->count > 0) {
173
+				if (isset($term_reviews[$term->term_id])) {
174
+					$term->review_count = $term_reviews[$term->term_id];
175
+				} else {
176
+					$term->review_count = '0';
177
+				}
178
+
179
+				$a_terms[] = $term;
180
+			}
181
+
182
+		}
183
+
184
+
185
+		$terms = apply_filters('bestof_widget_sort_terms', geodir_sort_terms($a_terms, 'review_count'), $a_terms);
186
+
187
+		$query_args = array(
188
+			'posts_per_page' => $post_limit,
189
+			'is_geodir_loop' => true,
190
+			'post_type' => $post_type,
191
+			'gd_location' => $add_location_filter ? true : false,
192
+			'order_by' => 'high_review'
193
+		);
194
+		if ($character_count >= 0) {
195
+			$query_args['excerpt_length'] = $character_count;
196
+		}
197
+
198
+		$layout = array();
199
+		if ($tab_layout == 'bestof-tabs-as-dropdown') {
200
+			$layout[] = $tab_layout;
201
+		} else {
202
+			$layout[] = 'bestof-tabs-as-dropdown';
203
+			$layout[] = $tab_layout;
204
+		}
205
+
206
+
207
+		echo $before_title . __($title,'geodirectory') . $after_title;
208
+
209
+		//term navigation - start
210
+		echo '<div class="geodir-tabs gd-bestof-tabs" id="gd-bestof-tabs" style="position:relative;">';
211
+
212
+		$final_html = '';
213
+		foreach ($layout as $tab_layout) {
214
+			$nav_html = '';
215
+			$is_dropdown = ($tab_layout == 'bestof-tabs-as-dropdown') ? true : false;
216
+
217
+			if ($is_dropdown) {
218
+				$nav_html .= '<select id="geodir_bestof_tab_dd" class="chosen_select" name="geodir_bestof_tab_dd" data-placeholder="' . esc_attr(__('Select Category', 'geodirectory')) . '">';
219
+			} else {
220
+				$nav_html .= '<dl class="geodir-tab-head geodir-bestof-cat-list">';
221
+				$nav_html .= '<dt></dt>';
222
+			}
223
+
224
+
225
+			$term_icon = geodir_get_term_icon();
226
+			$cat_count = 0;
227
+			if (!empty($terms)) {
228
+				foreach ($terms as $cat) {
229
+					$cat_count++;
230
+					if ($cat_count > $categ_limit) {
231
+						break;
232
+					}
233
+					if ($is_dropdown) {
234
+						$selected = ($cat_count == 1) ? 'selected="selected"' : '';
235
+						$nav_html .= '<option ' . $selected . ' value="' . $cat->term_id . '">' . geodir_ucwords($cat->name) . '</option>';
236
+					} else {
237
+						if ($cat_count == 1) {
238
+							$nav_html .= '<dd class="geodir-tab-active">';
239
+						} else {
240
+							$nav_html .= '<dd class="">';
241
+						}
242
+						$term_icon_url = !empty($term_icon) && isset($term_icon[$cat->term_id]) ? $term_icon[$cat->term_id] : '';
243
+						$nav_html .= '<a data-termid="' . $cat->term_id . '" href="' . get_term_link($cat, $cat->taxonomy) . '">';
244
+						$nav_html .= '<img alt="' . $cat->name . ' icon" class="bestof-cat-icon" src="' . $term_icon_url . '"/>';
245
+						$nav_html .= '<span>';
246
+						$nav_html .= geodir_ucwords($cat->name);
247
+						$nav_html .= '<small>';
248
+						if (isset($cat->review_count)) {
249
+							$num_reviews = $cat->review_count;
250
+							if ($num_reviews == 0) {
251
+								$reviews = __('No Reviews', 'geodirectory');
252
+							} elseif ($num_reviews > 1) {
253
+								$reviews = $num_reviews . __(' Reviews', 'geodirectory');
254
+							} else {
255
+								$reviews = __('1 Review', 'geodirectory');
256
+							}
257
+							$nav_html .= $reviews;
258
+						}
259
+						$nav_html .= '</small>';
260
+						$nav_html .= '</span>';
261
+						$nav_html .= '</a>';
262
+						$nav_html .= '</dd>';
263
+					}
264
+				}
265
+			}
266
+
267
+			if ($is_dropdown) {
268
+				$nav_html .= '</select>';
269
+			} else {
270
+				$nav_html .= '</dl>';
271
+			}
272
+			$final_html .= $nav_html;
273
+		}
274
+		if ($terms) {
275
+			echo $final_html;
276
+		}
277
+		echo '</div>';
278
+		//term navigation - end
279
+
280
+		//first term listings by default - start
281
+		$first_term = '';
282
+		if ($terms) {
283
+			$first_term = $terms[0];
284
+			$tax_query = array(
285
+				'taxonomy' => $category_taxonomy[0],
286
+				'field' => 'id',
287
+				'terms' => $first_term->term_id
288
+			);
289
+			$query_args['tax_query'] = array($tax_query);
290
+		}
291
+
292
+		?>
293 293
         <input type="hidden" id="bestof_widget_post_type" name="bestof_widget_post_type"
294 294
                value="<?php echo $post_type; ?>">
295 295
         <input type="hidden" id="bestof_widget_excerpt_type" name="bestof_widget_excerpt_type"
@@ -300,110 +300,110 @@  discard block
 block discarded – undo
300 300
                value="<?php echo $category_taxonomy[0]; ?>">
301 301
         <input type="hidden" id="bestof_widget_location_filter" name="bestof_widget_location_filter"
302 302
                value="<?php if ($add_location_filter) {
303
-                   echo 1;
304
-               } else {
305
-                   echo 0;
306
-               } ?>">
303
+				   echo 1;
304
+			   } else {
305
+				   echo 0;
306
+			   } ?>">
307 307
         <input type="hidden" id="bestof_widget_char_count" name="bestof_widget_char_count"
308 308
                value="<?php echo $character_count; ?>">
309 309
         <div class="geo-bestof-contentwrap geodir-tabs-content" style="position: relative; z-index: 0;">
310 310
             <p id="geodir-bestof-loading" class="geodir-bestof-loading"><i class="fa fa-cog fa-spin"></i></p>
311 311
             <?php
312
-            echo '<div id="geodir-bestof-places">';
313
-            if ($terms) {
314
-                $view_all_link = add_query_arg(array('sort_by' => 'rating_count_desc'), get_term_link($first_term, $first_term->taxonomy));
315
-                /**
316
-                 * Filter the page link to view all lisitngs.
317
-                 *
318
-                 * @since 1.5.1
319
-                 *
320
-                 * @param array $view_all_link View all listings page link.
321
-                 * @param array $post_type The Post type.
322
-                 * @param array $first_term The category term object.
323
-                 */
324
-                $view_all_link = apply_filters('geodir_bestof_widget_view_all_link', $view_all_link, $post_type, $first_term);
325
-
326
-                echo '<h3 class="bestof-cat-title">' . wp_sprintf(__('Best of %s', 'geodirectory'), $first_term->name) . '<a href="' . esc_url($view_all_link) . '">' . __("View all", 'geodirectory') . '</a></h3>';
327
-            }
328
-            if ($excerpt_type == 'show-reviews') {
329
-                add_filter('get_the_excerpt', 'best_of_show_review_in_excerpt');
330
-            }
331
-            geodir_bestof_places_by_term($query_args);
332
-            if ($excerpt_type == 'show-reviews') {
333
-                remove_filter('get_the_excerpt', 'best_of_show_review_in_excerpt');
334
-            }
335
-            echo "</div>";
336
-            ?>
312
+			echo '<div id="geodir-bestof-places">';
313
+			if ($terms) {
314
+				$view_all_link = add_query_arg(array('sort_by' => 'rating_count_desc'), get_term_link($first_term, $first_term->taxonomy));
315
+				/**
316
+				 * Filter the page link to view all lisitngs.
317
+				 *
318
+				 * @since 1.5.1
319
+				 *
320
+				 * @param array $view_all_link View all listings page link.
321
+				 * @param array $post_type The Post type.
322
+				 * @param array $first_term The category term object.
323
+				 */
324
+				$view_all_link = apply_filters('geodir_bestof_widget_view_all_link', $view_all_link, $post_type, $first_term);
325
+
326
+				echo '<h3 class="bestof-cat-title">' . wp_sprintf(__('Best of %s', 'geodirectory'), $first_term->name) . '<a href="' . esc_url($view_all_link) . '">' . __("View all", 'geodirectory') . '</a></h3>';
327
+			}
328
+			if ($excerpt_type == 'show-reviews') {
329
+				add_filter('get_the_excerpt', 'best_of_show_review_in_excerpt');
330
+			}
331
+			geodir_bestof_places_by_term($query_args);
332
+			if ($excerpt_type == 'show-reviews') {
333
+				remove_filter('get_the_excerpt', 'best_of_show_review_in_excerpt');
334
+			}
335
+			echo "</div>";
336
+			?>
337 337
         </div>
338 338
         <?php //first term listings by default - end
339
-        ?>
339
+		?>
340 340
         <?php echo $after_widget;
341
-        echo "</div>";
342
-    }
343
-
344
-    /**
345
-     * Sanitize best of widget form values as they are saved.
346
-     *
347
-     * @since 1.3.9
348
-     * @since 1.5.1 Declare function public.
349
-     *
350
-     * @param array $new_instance Values just sent to be saved.
351
-     * @param array $old_instance Previously saved values from database.
352
-     *
353
-     * @return array Updated safe values to be saved.
354
-     */
355
-    public function update($new_instance, $old_instance)
356
-    {
357
-        $instance = $old_instance;
358
-        $instance['title'] = strip_tags($new_instance['title']);
359
-        $instance['post_type'] = strip_tags($new_instance['post_type']);
360
-        $instance['post_limit'] = strip_tags($new_instance['post_limit']);
361
-        $instance['categ_limit'] = strip_tags($new_instance['categ_limit']);
362
-        $instance['character_count'] = $new_instance['character_count'];
363
-        $instance['tab_layout'] = $new_instance['tab_layout'];
364
-        $instance['excerpt_type'] = $new_instance['excerpt_type'];
365
-        if (isset($new_instance['add_location_filter']) && $new_instance['add_location_filter'] != '')
366
-            $instance['add_location_filter'] = strip_tags($new_instance['add_location_filter']);
367
-        else
368
-            $instance['add_location_filter'] = '0';
369
-        $instance['use_viewing_post_type'] = isset($new_instance['use_viewing_post_type']) && $new_instance['use_viewing_post_type'] ? 1 : 0;
370
-        return $instance;
371
-    }
372
-
373
-    /**
374
-     * Back-end best of widget settings form.
375
-     *
376
-     * @since 1.3.9
377
-     * @since 1.5.1 Declare function public.
378
-     *
379
-     * @param array $instance Previously saved values from database.
380
-     */
381
-    public function form($instance)
382
-    {
383
-        $instance = wp_parse_args((array)$instance,
384
-            array(
385
-                'title' => '',
386
-                'post_type' => '',
387
-                'post_limit' => '5',
388
-                'categ_limit' => '3',
389
-                'character_count' => '20',
390
-                'add_location_filter' => '1',
391
-                'tab_layout' => 'bestof-tabs-on-top',
392
-                'excerpt_type' => 'show-desc',
393
-                'use_viewing_post_type' => ''
394
-            )
395
-        );
396
-        $title = strip_tags($instance['title']);
397
-        $post_type = strip_tags($instance['post_type']);
398
-        $post_limit = strip_tags($instance['post_limit']);
399
-        $categ_limit = strip_tags($instance['categ_limit']);
400
-        $character_count = strip_tags($instance['character_count']);
401
-        $tab_layout = strip_tags($instance['tab_layout']);
402
-        $excerpt_type = strip_tags($instance['excerpt_type']);
403
-        $add_location_filter = strip_tags($instance['add_location_filter']);
404
-        $use_viewing_post_type = isset($instance['use_viewing_post_type']) && $instance['use_viewing_post_type'] ? true : false;
405
-
406
-        ?>
341
+		echo "</div>";
342
+	}
343
+
344
+	/**
345
+	 * Sanitize best of widget form values as they are saved.
346
+	 *
347
+	 * @since 1.3.9
348
+	 * @since 1.5.1 Declare function public.
349
+	 *
350
+	 * @param array $new_instance Values just sent to be saved.
351
+	 * @param array $old_instance Previously saved values from database.
352
+	 *
353
+	 * @return array Updated safe values to be saved.
354
+	 */
355
+	public function update($new_instance, $old_instance)
356
+	{
357
+		$instance = $old_instance;
358
+		$instance['title'] = strip_tags($new_instance['title']);
359
+		$instance['post_type'] = strip_tags($new_instance['post_type']);
360
+		$instance['post_limit'] = strip_tags($new_instance['post_limit']);
361
+		$instance['categ_limit'] = strip_tags($new_instance['categ_limit']);
362
+		$instance['character_count'] = $new_instance['character_count'];
363
+		$instance['tab_layout'] = $new_instance['tab_layout'];
364
+		$instance['excerpt_type'] = $new_instance['excerpt_type'];
365
+		if (isset($new_instance['add_location_filter']) && $new_instance['add_location_filter'] != '')
366
+			$instance['add_location_filter'] = strip_tags($new_instance['add_location_filter']);
367
+		else
368
+			$instance['add_location_filter'] = '0';
369
+		$instance['use_viewing_post_type'] = isset($new_instance['use_viewing_post_type']) && $new_instance['use_viewing_post_type'] ? 1 : 0;
370
+		return $instance;
371
+	}
372
+
373
+	/**
374
+	 * Back-end best of widget settings form.
375
+	 *
376
+	 * @since 1.3.9
377
+	 * @since 1.5.1 Declare function public.
378
+	 *
379
+	 * @param array $instance Previously saved values from database.
380
+	 */
381
+	public function form($instance)
382
+	{
383
+		$instance = wp_parse_args((array)$instance,
384
+			array(
385
+				'title' => '',
386
+				'post_type' => '',
387
+				'post_limit' => '5',
388
+				'categ_limit' => '3',
389
+				'character_count' => '20',
390
+				'add_location_filter' => '1',
391
+				'tab_layout' => 'bestof-tabs-on-top',
392
+				'excerpt_type' => 'show-desc',
393
+				'use_viewing_post_type' => ''
394
+			)
395
+		);
396
+		$title = strip_tags($instance['title']);
397
+		$post_type = strip_tags($instance['post_type']);
398
+		$post_limit = strip_tags($instance['post_limit']);
399
+		$categ_limit = strip_tags($instance['categ_limit']);
400
+		$character_count = strip_tags($instance['character_count']);
401
+		$tab_layout = strip_tags($instance['tab_layout']);
402
+		$excerpt_type = strip_tags($instance['excerpt_type']);
403
+		$add_location_filter = strip_tags($instance['add_location_filter']);
404
+		$use_viewing_post_type = isset($instance['use_viewing_post_type']) && $instance['use_viewing_post_type'] ? true : false;
405
+
406
+		?>
407 407
         <p>
408 408
             <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'geodirectory');?>
409 409
 
@@ -418,14 +418,14 @@  discard block
 block discarded – undo
418 418
                 for="<?php echo $this->get_field_id('post_type'); ?>"><?php _e('Post Type:', 'geodirectory');?>
419 419
 
420 420
                 <?php $postypes = geodir_get_posttypes();
421
-                /**
422
-                 * Filter the post types to display in widget.
423
-                 *
424
-                 * @since 1.3.9
425
-                 *
426
-                 * @param array $postypes Post types array.
427
-                 */
428
-                $postypes = apply_filters('geodir_post_type_list_in_p_widget', $postypes); ?>
421
+				/**
422
+				 * Filter the post types to display in widget.
423
+				 *
424
+				 * @since 1.3.9
425
+				 *
426
+				 * @param array $postypes Post types array.
427
+				 */
428
+				$postypes = apply_filters('geodir_post_type_list_in_p_widget', $postypes); ?>
429 429
 
430 430
                 <select class="widefat" id="<?php echo $this->get_field_id('post_type'); ?>"
431 431
                         name="<?php echo $this->get_field_name('post_type'); ?>"
@@ -434,9 +434,9 @@  discard block
 block discarded – undo
434 434
                     <?php foreach ($postypes as $postypes_obj) { ?>
435 435
 
436 436
                         <option <?php if ($post_type == $postypes_obj) {
437
-                            echo 'selected="selected"';
438
-                        } ?> value="<?php echo $postypes_obj; ?>"><?php $extvalue = explode('_', $postypes_obj);
439
-                            echo ucfirst($extvalue[1]); ?></option>
437
+							echo 'selected="selected"';
438
+						} ?> value="<?php echo $postypes_obj; ?>"><?php $extvalue = explode('_', $postypes_obj);
439
+							echo ucfirst($extvalue[1]); ?></option>
440 440
 
441 441
                     <?php } ?>
442 442
 
@@ -482,14 +482,14 @@  discard block
 block discarded – undo
482 482
                         name="<?php echo $this->get_field_name('tab_layout'); ?>">
483 483
 
484 484
                     <option <?php if ($tab_layout == 'bestof-tabs-on-top') {
485
-                        echo 'selected="selected"';
486
-                    } ?> value="bestof-tabs-on-top"><?php _e('Tabs on Top', 'geodirectory'); ?></option>
485
+						echo 'selected="selected"';
486
+					} ?> value="bestof-tabs-on-top"><?php _e('Tabs on Top', 'geodirectory'); ?></option>
487 487
                     <option <?php if ($tab_layout == 'bestof-tabs-on-left') {
488
-                        echo 'selected="selected"';
489
-                    } ?> value="bestof-tabs-on-left"><?php _e('Tabs on Left', 'geodirectory'); ?></option>
488
+						echo 'selected="selected"';
489
+					} ?> value="bestof-tabs-on-left"><?php _e('Tabs on Left', 'geodirectory'); ?></option>
490 490
                     <option <?php if ($tab_layout == 'bestof-tabs-as-dropdown') {
491
-                        echo 'selected="selected"';
492
-                    } ?>
491
+						echo 'selected="selected"';
492
+					} ?>
493 493
                         value="bestof-tabs-as-dropdown"><?php _e('Tabs as Dropdown', 'geodirectory'); ?></option>
494 494
                 </select>
495 495
             </label>
@@ -503,11 +503,11 @@  discard block
 block discarded – undo
503 503
                         name="<?php echo $this->get_field_name('excerpt_type'); ?>">
504 504
 
505 505
                     <option <?php if ($excerpt_type == 'show-desc') {
506
-                        echo 'selected="selected"';
507
-                    } ?> value="show-desc"><?php _e('Show Description', 'geodirectory'); ?></option>
506
+						echo 'selected="selected"';
507
+					} ?> value="show-desc"><?php _e('Show Description', 'geodirectory'); ?></option>
508 508
                     <option <?php if ($excerpt_type == 'show-reviews') {
509
-                        echo 'selected="selected"';
510
-                    } ?> value="show-reviews"><?php _e('Show Reviews if Available', 'geodirectory'); ?></option>
509
+						echo 'selected="selected"';
510
+					} ?> value="show-reviews"><?php _e('Show Reviews if Available', 'geodirectory'); ?></option>
511 511
                 </select>
512 512
             </label>
513 513
         </p>
@@ -526,12 +526,12 @@  discard block
 block discarded – undo
526 526
                 for="<?php echo $this->get_field_id('use_viewing_post_type'); ?>"><?php _e('Use current viewing post type:', 'geodirectory'); ?>
527 527
                 <input type="checkbox" id="<?php echo $this->get_field_id('use_viewing_post_type'); ?>"
528 528
                        name="<?php echo $this->get_field_name('use_viewing_post_type'); ?>" <?php if ($use_viewing_post_type) {
529
-                    echo 'checked="checked"';
530
-                } ?>  value="1"/>
529
+					echo 'checked="checked"';
530
+				} ?>  value="1"/>
531 531
             </label>
532 532
         </p>
533 533
     <?php
534
-    }
534
+	}
535 535
 } // class geodir_bestof_widget
536 536
 
537 537
 register_widget('geodir_bestof_widget');
@@ -551,68 +551,68 @@  discard block
 block discarded – undo
551 551
  */
552 552
 function geodir_bestof_places_by_term($query_args)
553 553
 {
554
-    global $gd_session;
555
-
556
-    /**
557
-     * This action called before querying widget listings.
558
-     *
559
-     * @since 1.0.0
560
-     */
561
-    do_action('geodir_bestof_get_widget_listings_before');
562
-
563
-    $widget_listings = geodir_get_widget_listings($query_args);
564
-
565
-    /**
566
-     * This action called after querying widget listings.
567
-     *
568
-     * @since 1.0.0
569
-     */
570
-    do_action('geodir_bestof_get_widget_listings_after');
571
-
572
-    $character_count = isset($query_args['excerpt_length']) ? $query_args['excerpt_length'] : '';
573
-
574
-    if (!isset($character_count)) {
575
-        /** This filter is documented in geodirectory-widgets/geodirectory_bestof_widget.php */
576
-        $character_count = $character_count == '' ? 50 : apply_filters('bestof_widget_character_count', $character_count);
577
-    }
578
-
579
-    /** This filter is documented in geodirectory-functions/general_functions.php */
580
-    $template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview'));
581
-
582
-    global $post, $map_jason, $map_canvas_arr, $gridview_columns_widget, $geodir_is_widget_listing;
583
-    $current_post = $post;
584
-    $current_map_jason = $map_jason;
585
-    $current_map_canvas_arr = $map_canvas_arr;
586
-    $current_grid_view = $gridview_columns_widget;
587
-    $gridview_columns_widget = null;
588
-
589
-    $gd_listing_view_set = $gd_session->get('gd_listing_view') ? true : false;
590
-    $gd_listing_view_old = $gd_listing_view_set ? $gd_session->get('gd_listing_view') : '';
591
-
592
-    $gd_session->set('gd_listing_view', '1');
593
-    $geodir_is_widget_listing = true;
594
-
595
-    /**
596
-     * Includes the template for the listing listview.
597
-     *
598
-     * @since 1.3.9
599
-     */
600
-    include($template);
601
-
602
-    $geodir_is_widget_listing = false;
603
-
604
-    $GLOBALS['post'] = $current_post;
605
-    if (!empty($current_post)) {
606
-        setup_postdata($current_post);
607
-    }
608
-    if ($gd_listing_view_set) { // Set back previous value
609
-        $gd_session->set('gd_listing_view', $gd_listing_view_old);
610
-    } else {
611
-        $gd_session->un_set('gd_listing_view');
612
-    }
613
-    $map_jason = $current_map_jason;
614
-    $map_canvas_arr = $current_map_canvas_arr;
615
-    $gridview_columns_widget = $current_grid_view;
554
+	global $gd_session;
555
+
556
+	/**
557
+	 * This action called before querying widget listings.
558
+	 *
559
+	 * @since 1.0.0
560
+	 */
561
+	do_action('geodir_bestof_get_widget_listings_before');
562
+
563
+	$widget_listings = geodir_get_widget_listings($query_args);
564
+
565
+	/**
566
+	 * This action called after querying widget listings.
567
+	 *
568
+	 * @since 1.0.0
569
+	 */
570
+	do_action('geodir_bestof_get_widget_listings_after');
571
+
572
+	$character_count = isset($query_args['excerpt_length']) ? $query_args['excerpt_length'] : '';
573
+
574
+	if (!isset($character_count)) {
575
+		/** This filter is documented in geodirectory-widgets/geodirectory_bestof_widget.php */
576
+		$character_count = $character_count == '' ? 50 : apply_filters('bestof_widget_character_count', $character_count);
577
+	}
578
+
579
+	/** This filter is documented in geodirectory-functions/general_functions.php */
580
+	$template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview'));
581
+
582
+	global $post, $map_jason, $map_canvas_arr, $gridview_columns_widget, $geodir_is_widget_listing;
583
+	$current_post = $post;
584
+	$current_map_jason = $map_jason;
585
+	$current_map_canvas_arr = $map_canvas_arr;
586
+	$current_grid_view = $gridview_columns_widget;
587
+	$gridview_columns_widget = null;
588
+
589
+	$gd_listing_view_set = $gd_session->get('gd_listing_view') ? true : false;
590
+	$gd_listing_view_old = $gd_listing_view_set ? $gd_session->get('gd_listing_view') : '';
591
+
592
+	$gd_session->set('gd_listing_view', '1');
593
+	$geodir_is_widget_listing = true;
594
+
595
+	/**
596
+	 * Includes the template for the listing listview.
597
+	 *
598
+	 * @since 1.3.9
599
+	 */
600
+	include($template);
601
+
602
+	$geodir_is_widget_listing = false;
603
+
604
+	$GLOBALS['post'] = $current_post;
605
+	if (!empty($current_post)) {
606
+		setup_postdata($current_post);
607
+	}
608
+	if ($gd_listing_view_set) { // Set back previous value
609
+		$gd_session->set('gd_listing_view', $gd_listing_view_old);
610
+	} else {
611
+		$gd_session->un_set('gd_listing_view');
612
+	}
613
+	$map_jason = $current_map_jason;
614
+	$map_canvas_arr = $current_map_canvas_arr;
615
+	$gridview_columns_widget = $current_grid_view;
616 616
 }
617 617
 
618 618
 //Ajax functions
@@ -629,51 +629,51 @@  discard block
 block discarded – undo
629 629
  */
630 630
 function geodir_bestof_callback()
631 631
 {
632
-    check_ajax_referer('geodir-bestof-nonce', 'geodir_bestof_nonce');
633
-    //set variables
634
-    $post_type = strip_tags(esc_sql($_POST['post_type']));
635
-    $post_limit = strip_tags(esc_sql($_POST['post_limit']));
636
-    $character_count = strip_tags(esc_sql($_POST['char_count']));
637
-    $taxonomy = strip_tags(esc_sql($_POST['taxonomy']));
638
-    $add_location_filter = strip_tags(esc_sql($_POST['add_location_filter']));
639
-    $term_id = strip_tags(esc_sql($_POST['term_id']));
640
-    $excerpt_type = strip_tags(esc_sql($_POST['excerpt_type']));
641
-
642
-    $query_args = array(
643
-        'posts_per_page' => $post_limit,
644
-        'is_geodir_loop' => true,
645
-        'post_type' => $post_type,
646
-        'gd_location' => $add_location_filter ? true : false,
647
-        'order_by' => 'high_review'
648
-    );
649
-
650
-    if ($character_count >= 0) {
651
-        $query_args['excerpt_length'] = $character_count;
652
-    }
653
-
654
-    $tax_query = array(
655
-        'taxonomy' => $taxonomy,
656
-        'field' => 'id',
657
-        'terms' => $term_id
658
-    );
659
-
660
-    $query_args['tax_query'] = array($tax_query);
661
-    if ($term_id && $taxonomy) {
662
-        $term = get_term_by('id', $term_id, $taxonomy);
663
-        $view_all_link = add_query_arg(array('sort_by' => 'rating_count_desc'), get_term_link($term));
664
-        /** This filter is documented in geodirectory-widgets/geodirectory_bestof_widget.php */
665
-        $view_all_link = apply_filters('geodir_bestof_widget_view_all_link', $view_all_link, $post_type, $term);
666
-
667
-        echo '<h3 class="bestof-cat-title">' . wp_sprintf(__('Best of %s', 'geodirectory'), $term->name) . '<a href="' . esc_url($view_all_link) . '">' . __("View all", 'geodirectory') . '</a></h3>';
668
-    }
669
-    if ($excerpt_type == 'show-reviews') {
670
-        add_filter('get_the_excerpt', 'best_of_show_review_in_excerpt');
671
-    }
672
-    geodir_bestof_places_by_term($query_args);
673
-    if ($excerpt_type == 'show-reviews') {
674
-        remove_filter('get_the_excerpt', 'best_of_show_review_in_excerpt');
675
-    }
676
-    gd_die();
632
+	check_ajax_referer('geodir-bestof-nonce', 'geodir_bestof_nonce');
633
+	//set variables
634
+	$post_type = strip_tags(esc_sql($_POST['post_type']));
635
+	$post_limit = strip_tags(esc_sql($_POST['post_limit']));
636
+	$character_count = strip_tags(esc_sql($_POST['char_count']));
637
+	$taxonomy = strip_tags(esc_sql($_POST['taxonomy']));
638
+	$add_location_filter = strip_tags(esc_sql($_POST['add_location_filter']));
639
+	$term_id = strip_tags(esc_sql($_POST['term_id']));
640
+	$excerpt_type = strip_tags(esc_sql($_POST['excerpt_type']));
641
+
642
+	$query_args = array(
643
+		'posts_per_page' => $post_limit,
644
+		'is_geodir_loop' => true,
645
+		'post_type' => $post_type,
646
+		'gd_location' => $add_location_filter ? true : false,
647
+		'order_by' => 'high_review'
648
+	);
649
+
650
+	if ($character_count >= 0) {
651
+		$query_args['excerpt_length'] = $character_count;
652
+	}
653
+
654
+	$tax_query = array(
655
+		'taxonomy' => $taxonomy,
656
+		'field' => 'id',
657
+		'terms' => $term_id
658
+	);
659
+
660
+	$query_args['tax_query'] = array($tax_query);
661
+	if ($term_id && $taxonomy) {
662
+		$term = get_term_by('id', $term_id, $taxonomy);
663
+		$view_all_link = add_query_arg(array('sort_by' => 'rating_count_desc'), get_term_link($term));
664
+		/** This filter is documented in geodirectory-widgets/geodirectory_bestof_widget.php */
665
+		$view_all_link = apply_filters('geodir_bestof_widget_view_all_link', $view_all_link, $post_type, $term);
666
+
667
+		echo '<h3 class="bestof-cat-title">' . wp_sprintf(__('Best of %s', 'geodirectory'), $term->name) . '<a href="' . esc_url($view_all_link) . '">' . __("View all", 'geodirectory') . '</a></h3>';
668
+	}
669
+	if ($excerpt_type == 'show-reviews') {
670
+		add_filter('get_the_excerpt', 'best_of_show_review_in_excerpt');
671
+	}
672
+	geodir_bestof_places_by_term($query_args);
673
+	if ($excerpt_type == 'show-reviews') {
674
+		remove_filter('get_the_excerpt', 'best_of_show_review_in_excerpt');
675
+	}
676
+	gd_die();
677 677
 }
678 678
 
679 679
 //Javascript
@@ -686,8 +686,8 @@  discard block
 block discarded – undo
686 686
  */
687 687
 function geodir_bestof_js()
688 688
 {
689
-    $ajax_nonce = wp_create_nonce("geodir-bestof-nonce");
690
-    ?>
689
+	$ajax_nonce = wp_create_nonce("geodir-bestof-nonce");
690
+	?>
691 691
     <script type="text/javascript">
692 692
         jQuery(document).ready(function () {
693 693
             jQuery('.geodir-bestof-cat-list a, #geodir_bestof_tab_dd').on("click change", function (e) {
@@ -766,18 +766,18 @@  discard block
 block discarded – undo
766 766
 
767 767
 function best_of_show_review_in_excerpt($excerpt)
768 768
 {
769
-    global $wpdb, $post;
770
-    $review_table = GEODIR_REVIEW_TABLE;
771
-    $request = "SELECT comment_ID FROM $review_table WHERE post_id = $post->ID ORDER BY post_date DESC, id DESC LIMIT 1";
772
-    $comments = $wpdb->get_results($request);
773
-
774
-    if ($comments) {
775
-        foreach ($comments as $comment) {
776
-            // Set the extra comment info needed.
777
-            $comment_extra = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID");
778
-            $comment_content = $comment_extra->comment_content;
779
-            $excerpt = strip_tags($comment_content);
780
-        }
781
-    }
782
-    return $excerpt;
769
+	global $wpdb, $post;
770
+	$review_table = GEODIR_REVIEW_TABLE;
771
+	$request = "SELECT comment_ID FROM $review_table WHERE post_id = $post->ID ORDER BY post_date DESC, id DESC LIMIT 1";
772
+	$comments = $wpdb->get_results($request);
773
+
774
+	if ($comments) {
775
+		foreach ($comments as $comment) {
776
+			// Set the extra comment info needed.
777
+			$comment_extra = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID");
778
+			$comment_content = $comment_extra->comment_content;
779
+			$excerpt = strip_tags($comment_content);
780
+		}
781
+	}
782
+	return $excerpt;
783 783
 }
784 784
\ No newline at end of file
Please login to merge, or discard this patch.
geodirectory-widgets/geodirectory_popular_widget.php 3 patches
Braces   +37 added lines, -14 removed lines patch added patch discarded remove patch
@@ -190,10 +190,11 @@  discard block
 block discarded – undo
190 190
         $instance['listing_width'] = strip_tags($new_instance['listing_width']);
191 191
         $instance['list_sort'] = strip_tags($new_instance['list_sort']);
192 192
         $instance['character_count'] = $new_instance['character_count'];
193
-        if (isset($new_instance['add_location_filter']) && $new_instance['add_location_filter'] != '')
194
-            $instance['add_location_filter'] = strip_tags($new_instance['add_location_filter']);
195
-        else
196
-            $instance['add_location_filter'] = '0';
193
+        if (isset($new_instance['add_location_filter']) && $new_instance['add_location_filter'] != '') {
194
+                    $instance['add_location_filter'] = strip_tags($new_instance['add_location_filter']);
195
+        } else {
196
+                    $instance['add_location_filter'] = '0';
197
+        }
197 198
 
198 199
         $instance['show_featured_only'] = isset($new_instance['show_featured_only']) && $new_instance['show_featured_only'] ? 1 : 0;
199 200
         $instance['show_special_only'] = isset($new_instance['show_special_only']) && $new_instance['show_special_only'] ? 1 : 0;
@@ -319,8 +320,9 @@  discard block
 block discarded – undo
319 320
 
320 321
                 $all_postypes = geodir_get_posttypes();
321 322
 
322
-                if (!in_array($post_type, $all_postypes))
323
-                    $post_type = 'gd_place';
323
+                if (!in_array($post_type, $all_postypes)) {
324
+                                    $post_type = 'gd_place';
325
+                }
324 326
 
325 327
                 $category_taxonomy = geodir_get_taxonomies($post_type);
326 328
                 $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC'));
@@ -335,8 +337,9 @@  discard block
 block discarded – undo
335 337
                     } ?> value="0"><?php _e('All', 'geodirectory'); ?></option>
336 338
                     <?php foreach ($categories as $category_obj) {
337 339
                         $selected = '';
338
-                        if (is_array($category) && in_array($category_obj->term_id, $category))
339
-                            echo $selected = 'selected="selected"';
340
+                        if (is_array($category) && in_array($category_obj->term_id, $category)) {
341
+                                                    echo $selected = 'selected="selected"';
342
+                        }
340 343
 
341 344
                         ?>
342 345
 
@@ -350,7 +353,12 @@  discard block
 block discarded – undo
350 353
 
351 354
                 <input type="hidden" name="<?php echo $this->get_field_name('category_title'); ?>"
352 355
                        id="<?php echo $this->get_field_id('category_title'); ?>"
353
-                       value="<?php if ($category_title != '') echo $category_title; else echo __('All', 'geodirectory');?>"/>
356
+                       value="<?php if ($category_title != '') {
357
+	echo $category_title;
358
+} else {
359
+	echo __('All', 'geodirectory');
360
+}
361
+?>"/>
354 362
 
355 363
             </label>
356 364
         </p>
@@ -453,7 +461,10 @@  discard block
 block discarded – undo
453 461
             <label for="<?php echo $this->get_field_id('add_location_filter'); ?>">
454 462
                 <?php _e('Enable Location Filter:', 'geodirectory');?>
455 463
                 <input type="checkbox" id="<?php echo $this->get_field_id('add_location_filter'); ?>"
456
-                       name="<?php echo $this->get_field_name('add_location_filter'); ?>" <?php if ($add_location_filter) echo 'checked="checked"';?>
464
+                       name="<?php echo $this->get_field_name('add_location_filter'); ?>" <?php if ($add_location_filter) {
465
+	echo 'checked="checked"';
466
+}
467
+?>
457 468
                        value="1"/>
458 469
             </label>
459 470
         </p>
@@ -461,7 +472,10 @@  discard block
 block discarded – undo
461 472
             <label for="<?php echo $this->get_field_id('show_featured_only'); ?>">
462 473
                 <?php _e('Show only featured listings:', 'geodirectory');?> <input type="checkbox"
463 474
                                                                                             id="<?php echo $this->get_field_id('show_featured_only'); ?>"
464
-                                                                                            name="<?php echo $this->get_field_name('show_featured_only'); ?>" <?php if ($show_featured_only) echo 'checked="checked"';?>
475
+                                                                                            name="<?php echo $this->get_field_name('show_featured_only'); ?>" <?php if ($show_featured_only) {
476
+	echo 'checked="checked"';
477
+}
478
+?>
465 479
                                                                                             value="1"/>
466 480
             </label>
467 481
         </p>
@@ -469,7 +483,10 @@  discard block
 block discarded – undo
469 483
             <label for="<?php echo $this->get_field_id('show_special_only'); ?>">
470 484
                 <?php _e('Show only listings with special offers:', 'geodirectory');?> <input type="checkbox"
471 485
                                                                                                        id="<?php echo $this->get_field_id('show_special_only'); ?>"
472
-                                                                                                       name="<?php echo $this->get_field_name('show_special_only'); ?>" <?php if ($show_special_only) echo 'checked="checked"';?>
486
+                                                                                                       name="<?php echo $this->get_field_name('show_special_only'); ?>" <?php if ($show_special_only) {
487
+	echo 'checked="checked"';
488
+}
489
+?>
473 490
                                                                                                        value="1"/>
474 491
             </label>
475 492
         </p>
@@ -477,7 +494,10 @@  discard block
 block discarded – undo
477 494
             <label for="<?php echo $this->get_field_id('with_pics_only'); ?>">
478 495
                 <?php _e('Show only listings with pics:', 'geodirectory');?> <input type="checkbox"
479 496
                                                                                              id="<?php echo $this->get_field_id('with_pics_only'); ?>"
480
-                                                                                             name="<?php echo $this->get_field_name('with_pics_only'); ?>" <?php if ($with_pics_only) echo 'checked="checked"';?>
497
+                                                                                             name="<?php echo $this->get_field_name('with_pics_only'); ?>" <?php if ($with_pics_only) {
498
+	echo 'checked="checked"';
499
+}
500
+?>
481 501
                                                                                              value="1"/>
482 502
             </label>
483 503
         </p>
@@ -485,7 +505,10 @@  discard block
 block discarded – undo
485 505
             <label for="<?php echo $this->get_field_id('with_videos_only'); ?>">
486 506
                 <?php _e('Show only listings with videos:', 'geodirectory');?> <input type="checkbox"
487 507
                                                                                                id="<?php echo $this->get_field_id('with_videos_only'); ?>"
488
-                                                                                               name="<?php echo $this->get_field_name('with_videos_only'); ?>" <?php if ($with_videos_only) echo 'checked="checked"';?>
508
+                                                                                               name="<?php echo $this->get_field_name('with_videos_only'); ?>" <?php if ($with_videos_only) {
509
+	echo 'checked="checked"';
510
+}
511
+?>
489 512
                                                                                                value="1"/>
490 513
             </label>
491 514
         </p>
Please login to merge, or discard this patch.
Indentation   +204 added lines, -204 removed lines patch added patch discarded remove patch
@@ -14,83 +14,83 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class geodir_popular_post_category extends WP_Widget
16 16
 {
17
-    /**
18
-     * Register the popular post category widget.
19
-     *
20
-     * @since 1.0.0
21
-     * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct.
22
-     */
23
-    public function __construct() {
24
-        $widget_ops = array('classname' => 'geodir_popular_post_category', 'description' => __('GD > Popular Post Category', 'geodirectory'));
25
-        parent::__construct(
26
-            'popular_post_category', // Base ID
27
-            __('GD > Popular Post Category', 'geodirectory'), // Name
28
-            $widget_ops// Args
29
-        );
30
-    }
31
-
32
-    /**
33
-     * Front-end display content for popular post category widget.
34
-     *
35
-     * @since 1.0.0
36
-     * @since 1.5.1 Declare function public.
37
-     *
38
-     * @param array $args     Widget arguments.
39
-     * @param array $instance Saved values from database.
40
-     */
41
-    public function widget($args, $instance)
42
-    {
43
-        geodir_popular_post_category_output($args, $instance);
44
-    }
45
-
46
-    /**
47
-     * Sanitize popular post category widget form values as they are saved.
48
-     *
49
-     * @since 1.0.0
50
-     * @since 1.5.1 Declare function public.
51
-     * @since 1.5.1 Added default_post_type parameter.
52
-     * @since 1.6.9 Added parent_only parameter.
53
-     *
54
-     * @param array $new_instance Values just sent to be saved.
55
-     * @param array $old_instance Previously saved values from database.
56
-     *
57
-     * @return array Updated safe values to be saved.
58
-     */ 
59
-    public function update($new_instance, $old_instance)
60
-    {
61
-        //save the widget
62
-        $instance = $old_instance;
63
-        $instance['title'] = strip_tags($new_instance['title']);
64
-        $category_limit = (int)$new_instance['category_limit'];
65
-        $instance['category_limit'] = $category_limit > 0 ? $category_limit : 15;
66
-        $instance['default_post_type'] = isset($new_instance['default_post_type']) ? $new_instance['default_post_type'] : '';
67
-        $instance['parent_only'] = !empty($new_instance['parent_only']) ? true : false;
68
-        return $instance;
69
-    }
70
-
71
-    /**
72
-     * Back-end popular post category widget settings form.
73
-     *
74
-     * @since 1.0.0
75
-     * @since 1.5.1 Declare function public.
76
-     * @since 1.5.1 Added option to set default post type.
77
-     * @since 1.6.9 Added option to show parent categories only.
78
-     *
79
-     * @param array $instance Previously saved values from database.
80
-     */
81
-    public function form($instance) 
82
-    {
83
-        //widgetform in backend
84
-        $instance = wp_parse_args((array)$instance, array('title' => '', 'category_limit' => 15, 'default_post_type' => '', 'parent_only' => false));
85
-
86
-        $title = strip_tags($instance['title']);
87
-        $category_limit = (int)$instance['category_limit'];
88
-        $category_limit = $category_limit > 0 ? $category_limit : 15;
89
-        $default_post_type = isset($instance['default_post_type']) ? $instance['default_post_type'] : '';
90
-        $parent_only = !empty($instance['parent_only']) ? true: false;
17
+	/**
18
+	 * Register the popular post category widget.
19
+	 *
20
+	 * @since 1.0.0
21
+	 * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct.
22
+	 */
23
+	public function __construct() {
24
+		$widget_ops = array('classname' => 'geodir_popular_post_category', 'description' => __('GD > Popular Post Category', 'geodirectory'));
25
+		parent::__construct(
26
+			'popular_post_category', // Base ID
27
+			__('GD > Popular Post Category', 'geodirectory'), // Name
28
+			$widget_ops// Args
29
+		);
30
+	}
31
+
32
+	/**
33
+	 * Front-end display content for popular post category widget.
34
+	 *
35
+	 * @since 1.0.0
36
+	 * @since 1.5.1 Declare function public.
37
+	 *
38
+	 * @param array $args     Widget arguments.
39
+	 * @param array $instance Saved values from database.
40
+	 */
41
+	public function widget($args, $instance)
42
+	{
43
+		geodir_popular_post_category_output($args, $instance);
44
+	}
45
+
46
+	/**
47
+	 * Sanitize popular post category widget form values as they are saved.
48
+	 *
49
+	 * @since 1.0.0
50
+	 * @since 1.5.1 Declare function public.
51
+	 * @since 1.5.1 Added default_post_type parameter.
52
+	 * @since 1.6.9 Added parent_only parameter.
53
+	 *
54
+	 * @param array $new_instance Values just sent to be saved.
55
+	 * @param array $old_instance Previously saved values from database.
56
+	 *
57
+	 * @return array Updated safe values to be saved.
58
+	 */ 
59
+	public function update($new_instance, $old_instance)
60
+	{
61
+		//save the widget
62
+		$instance = $old_instance;
63
+		$instance['title'] = strip_tags($new_instance['title']);
64
+		$category_limit = (int)$new_instance['category_limit'];
65
+		$instance['category_limit'] = $category_limit > 0 ? $category_limit : 15;
66
+		$instance['default_post_type'] = isset($new_instance['default_post_type']) ? $new_instance['default_post_type'] : '';
67
+		$instance['parent_only'] = !empty($new_instance['parent_only']) ? true : false;
68
+		return $instance;
69
+	}
70
+
71
+	/**
72
+	 * Back-end popular post category widget settings form.
73
+	 *
74
+	 * @since 1.0.0
75
+	 * @since 1.5.1 Declare function public.
76
+	 * @since 1.5.1 Added option to set default post type.
77
+	 * @since 1.6.9 Added option to show parent categories only.
78
+	 *
79
+	 * @param array $instance Previously saved values from database.
80
+	 */
81
+	public function form($instance) 
82
+	{
83
+		//widgetform in backend
84
+		$instance = wp_parse_args((array)$instance, array('title' => '', 'category_limit' => 15, 'default_post_type' => '', 'parent_only' => false));
85
+
86
+		$title = strip_tags($instance['title']);
87
+		$category_limit = (int)$instance['category_limit'];
88
+		$category_limit = $category_limit > 0 ? $category_limit : 15;
89
+		$default_post_type = isset($instance['default_post_type']) ? $instance['default_post_type'] : '';
90
+		$parent_only = !empty($instance['parent_only']) ? true: false;
91 91
         
92
-        $post_type_options = geodir_get_posttypes('options');
93
-        ?>
92
+		$post_type_options = geodir_get_posttypes('options');
93
+		?>
94 94
         <p>
95 95
             <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'geodirectory'); ?>
96 96
                 <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>"/>
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
             <label for="<?php echo $this->get_field_id('parent_only'); ?>"><?php _e( 'Show parent categories only', 'geodirectory' ); ?></label>
117 117
         </p>
118 118
     <?php
119
-    }
119
+	}
120 120
 } // class geodir_popular_post_category
121 121
 
122 122
 register_widget('geodir_popular_post_category');
@@ -130,40 +130,40 @@  discard block
 block discarded – undo
130 130
 class geodir_popular_postview extends WP_Widget
131 131
 {
132 132
 
133
-    /**
133
+	/**
134 134
 	 * Register the popular posts widget.
135 135
 	 *
136 136
 	 * @since 1.0.0
137
-     * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct.
137
+	 * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct.
138 138
 	 */
139
-    public function __construct() {
140
-        $widget_ops = array('classname' => 'geodir_popular_post_view', 'description' => __('GD > Popular Post View', 'geodirectory'));
141
-        parent::__construct(
142
-            'popular_post_view', // Base ID
143
-            __('GD > Popular Post View', 'geodirectory'), // Name
144
-            $widget_ops// Args
145
-        );
146
-    }
139
+	public function __construct() {
140
+		$widget_ops = array('classname' => 'geodir_popular_post_view', 'description' => __('GD > Popular Post View', 'geodirectory'));
141
+		parent::__construct(
142
+			'popular_post_view', // Base ID
143
+			__('GD > Popular Post View', 'geodirectory'), // Name
144
+			$widget_ops// Args
145
+		);
146
+	}
147 147
 
148 148
 	/**
149 149
 	 * Front-end display content for popular posts widget.
150 150
 	 *
151 151
 	 * @since 1.0.0
152
-     * @since 1.5.1 Declare function public.
152
+	 * @since 1.5.1 Declare function public.
153 153
 	 *
154 154
 	 * @param array $args     Widget arguments.
155 155
 	 * @param array $instance Saved values from database.
156 156
 	 */
157 157
 	public function widget($args, $instance)
158
-    {
159
-        geodir_popular_postview_output($args, $instance);
160
-    }
158
+	{
159
+		geodir_popular_postview_output($args, $instance);
160
+	}
161 161
 
162 162
 	/**
163 163
 	 * Sanitize popular posts widget form values as they are saved.
164 164
 	 *
165 165
 	 * @since 1.0.0
166
-     * @since 1.5.1 Declare function public.
166
+	 * @since 1.5.1 Declare function public.
167 167
 	 *
168 168
 	 * @param array $new_instance Values just sent to be saved.
169 169
 	 * @param array $old_instance Previously saved values from database.
@@ -171,99 +171,99 @@  discard block
 block discarded – undo
171 171
 	 * @return array Updated safe values to be saved.
172 172
 	 */
173 173
 	public function update($new_instance, $old_instance)
174
-    {
175
-        //save the widget
176
-        $instance = $old_instance;
177
-
178
-        if ($new_instance['title'] == '') {
179
-            $title = geodir_ucwords(strip_tags($new_instance['category_title']));
180
-            //$instance['title'] = $title;
181
-        }
182
-        $instance['title'] = strip_tags($new_instance['title']);
183
-
184
-        $instance['post_type'] = strip_tags($new_instance['post_type']);
185
-        //$instance['category'] = strip_tags($new_instance['category']);
186
-        $instance['category'] = isset($new_instance['category']) ? $new_instance['category'] : '';
187
-        $instance['category_title'] = strip_tags($new_instance['category_title']);
188
-        $instance['post_number'] = strip_tags($new_instance['post_number']);
189
-        $instance['layout'] = strip_tags($new_instance['layout']);
190
-        $instance['listing_width'] = strip_tags($new_instance['listing_width']);
191
-        $instance['list_sort'] = strip_tags($new_instance['list_sort']);
192
-        $instance['character_count'] = $new_instance['character_count'];
193
-        if (isset($new_instance['add_location_filter']) && $new_instance['add_location_filter'] != '')
194
-            $instance['add_location_filter'] = strip_tags($new_instance['add_location_filter']);
195
-        else
196
-            $instance['add_location_filter'] = '0';
197
-
198
-        $instance['show_featured_only'] = isset($new_instance['show_featured_only']) && $new_instance['show_featured_only'] ? 1 : 0;
199
-        $instance['show_special_only'] = isset($new_instance['show_special_only']) && $new_instance['show_special_only'] ? 1 : 0;
200
-        $instance['with_pics_only'] = isset($new_instance['with_pics_only']) && $new_instance['with_pics_only'] ? 1 : 0;
201
-        $instance['with_videos_only'] = isset($new_instance['with_videos_only']) && $new_instance['with_videos_only'] ? 1 : 0;
202
-        $instance['use_viewing_post_type'] = isset($new_instance['use_viewing_post_type']) && $new_instance['use_viewing_post_type'] ? 1 : 0;
203
-
204
-        return $instance;
205
-    }
174
+	{
175
+		//save the widget
176
+		$instance = $old_instance;
177
+
178
+		if ($new_instance['title'] == '') {
179
+			$title = geodir_ucwords(strip_tags($new_instance['category_title']));
180
+			//$instance['title'] = $title;
181
+		}
182
+		$instance['title'] = strip_tags($new_instance['title']);
183
+
184
+		$instance['post_type'] = strip_tags($new_instance['post_type']);
185
+		//$instance['category'] = strip_tags($new_instance['category']);
186
+		$instance['category'] = isset($new_instance['category']) ? $new_instance['category'] : '';
187
+		$instance['category_title'] = strip_tags($new_instance['category_title']);
188
+		$instance['post_number'] = strip_tags($new_instance['post_number']);
189
+		$instance['layout'] = strip_tags($new_instance['layout']);
190
+		$instance['listing_width'] = strip_tags($new_instance['listing_width']);
191
+		$instance['list_sort'] = strip_tags($new_instance['list_sort']);
192
+		$instance['character_count'] = $new_instance['character_count'];
193
+		if (isset($new_instance['add_location_filter']) && $new_instance['add_location_filter'] != '')
194
+			$instance['add_location_filter'] = strip_tags($new_instance['add_location_filter']);
195
+		else
196
+			$instance['add_location_filter'] = '0';
197
+
198
+		$instance['show_featured_only'] = isset($new_instance['show_featured_only']) && $new_instance['show_featured_only'] ? 1 : 0;
199
+		$instance['show_special_only'] = isset($new_instance['show_special_only']) && $new_instance['show_special_only'] ? 1 : 0;
200
+		$instance['with_pics_only'] = isset($new_instance['with_pics_only']) && $new_instance['with_pics_only'] ? 1 : 0;
201
+		$instance['with_videos_only'] = isset($new_instance['with_videos_only']) && $new_instance['with_videos_only'] ? 1 : 0;
202
+		$instance['use_viewing_post_type'] = isset($new_instance['use_viewing_post_type']) && $new_instance['use_viewing_post_type'] ? 1 : 0;
203
+
204
+		return $instance;
205
+	}
206 206
 
207 207
 	/**
208 208
 	 * Back-end popular posts widget settings form.
209 209
 	 *
210 210
 	 * @since 1.0.0
211
-     * @since 1.5.1 Declare function public.
211
+	 * @since 1.5.1 Declare function public.
212 212
 	 *
213 213
 	 * @param array $instance Previously saved values from database.
214 214
 	 */
215 215
 	public function form($instance)
216
-    {
217
-        //widgetform in backend
218
-        $instance = wp_parse_args((array)$instance,
219
-            array('title' => '',
220
-                'post_type' => '',
221
-                'category' => array(),
222
-                'category_title' => '',
223
-                'list_sort' => '',
224
-                'list_order' => '',
225
-                'post_number' => '5',
226
-                'layout' => 'gridview_onehalf',
227
-                'listing_width' => '',
228
-                'add_location_filter' => '1',
229
-                'character_count' => '20',
230
-                'show_featured_only' => '',
231
-                'show_special_only' => '',
232
-                'with_pics_only' => '',
233
-                'with_videos_only' => '',
234
-                'use_viewing_post_type' => ''
235
-            )
236
-        );
216
+	{
217
+		//widgetform in backend
218
+		$instance = wp_parse_args((array)$instance,
219
+			array('title' => '',
220
+				'post_type' => '',
221
+				'category' => array(),
222
+				'category_title' => '',
223
+				'list_sort' => '',
224
+				'list_order' => '',
225
+				'post_number' => '5',
226
+				'layout' => 'gridview_onehalf',
227
+				'listing_width' => '',
228
+				'add_location_filter' => '1',
229
+				'character_count' => '20',
230
+				'show_featured_only' => '',
231
+				'show_special_only' => '',
232
+				'with_pics_only' => '',
233
+				'with_videos_only' => '',
234
+				'use_viewing_post_type' => ''
235
+			)
236
+		);
237 237
 
238
-        $title = strip_tags($instance['title']);
238
+		$title = strip_tags($instance['title']);
239 239
 
240
-        $post_type = strip_tags($instance['post_type']);
240
+		$post_type = strip_tags($instance['post_type']);
241 241
 
242
-        $category = $instance['category'];
242
+		$category = $instance['category'];
243 243
 
244
-        $category_title = strip_tags($instance['category_title']);
244
+		$category_title = strip_tags($instance['category_title']);
245 245
 
246
-        $list_sort = strip_tags($instance['list_sort']);
246
+		$list_sort = strip_tags($instance['list_sort']);
247 247
 
248
-        $list_order = strip_tags($instance['list_order']);
248
+		$list_order = strip_tags($instance['list_order']);
249 249
 
250
-        $post_number = strip_tags($instance['post_number']);
250
+		$post_number = strip_tags($instance['post_number']);
251 251
 
252
-        $layout = strip_tags($instance['layout']);
252
+		$layout = strip_tags($instance['layout']);
253 253
 
254
-        $listing_width = strip_tags($instance['listing_width']);
254
+		$listing_width = strip_tags($instance['listing_width']);
255 255
 
256
-        $add_location_filter = strip_tags($instance['add_location_filter']);
256
+		$add_location_filter = strip_tags($instance['add_location_filter']);
257 257
 
258
-        $character_count = $instance['character_count'];
258
+		$character_count = $instance['character_count'];
259 259
 
260
-        $show_featured_only = isset($instance['show_featured_only']) && $instance['show_featured_only'] ? true : false;
261
-        $show_special_only = isset($instance['show_special_only']) && $instance['show_special_only'] ? true : false;
262
-        $with_pics_only = isset($instance['with_pics_only']) && $instance['with_pics_only'] ? true : false;
263
-        $with_videos_only = isset($instance['with_videos_only']) && $instance['with_videos_only'] ? true : false;
264
-        $use_viewing_post_type = isset($instance['use_viewing_post_type']) && $instance['use_viewing_post_type'] ? true : false;
260
+		$show_featured_only = isset($instance['show_featured_only']) && $instance['show_featured_only'] ? true : false;
261
+		$show_special_only = isset($instance['show_special_only']) && $instance['show_special_only'] ? true : false;
262
+		$with_pics_only = isset($instance['with_pics_only']) && $instance['with_pics_only'] ? true : false;
263
+		$with_videos_only = isset($instance['with_videos_only']) && $instance['with_videos_only'] ? true : false;
264
+		$use_viewing_post_type = isset($instance['use_viewing_post_type']) && $instance['use_viewing_post_type'] ? true : false;
265 265
 
266
-        ?>
266
+		?>
267 267
 
268 268
         <p>
269 269
             <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'geodirectory');?>
@@ -298,9 +298,9 @@  discard block
 block discarded – undo
298 298
                     <?php foreach ($postypes as $postypes_obj) { ?>
299 299
 
300 300
                         <option <?php if ($post_type == $postypes_obj) {
301
-                            echo 'selected="selected"';
302
-                        } ?> value="<?php echo $postypes_obj; ?>"><?php $extvalue = explode('_', $postypes_obj);
303
-                            echo ucfirst($extvalue[1]); ?></option>
301
+							echo 'selected="selected"';
302
+						} ?> value="<?php echo $postypes_obj; ?>"><?php $extvalue = explode('_', $postypes_obj);
303
+							echo ucfirst($extvalue[1]); ?></option>
304 304
 
305 305
                     <?php } ?>
306 306
 
@@ -315,30 +315,30 @@  discard block
 block discarded – undo
315 315
 
316 316
                 <?php
317 317
 
318
-                $post_type = ($post_type != '') ? $post_type : 'gd_place';
318
+				$post_type = ($post_type != '') ? $post_type : 'gd_place';
319 319
 
320
-                $all_postypes = geodir_get_posttypes();
320
+				$all_postypes = geodir_get_posttypes();
321 321
 
322
-                if (!in_array($post_type, $all_postypes))
323
-                    $post_type = 'gd_place';
322
+				if (!in_array($post_type, $all_postypes))
323
+					$post_type = 'gd_place';
324 324
 
325
-                $category_taxonomy = geodir_get_taxonomies($post_type);
326
-                $categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC'));
325
+				$category_taxonomy = geodir_get_taxonomies($post_type);
326
+				$categories = get_terms($category_taxonomy, array('orderby' => 'count', 'order' => 'DESC'));
327 327
 
328
-                ?>
328
+				?>
329 329
 
330 330
                 <select multiple="multiple" class="widefat" name="<?php echo $this->get_field_name('category'); ?>[]"
331 331
                         onchange="geodir_popular_widget_cat_title(this)">
332 332
 
333 333
                     <option <?php if (!is_array($category) || (is_array($category) && in_array('0', $category))) {
334
-                        echo 'selected="selected"';
335
-                    } ?> value="0"><?php _e('All', 'geodirectory'); ?></option>
334
+						echo 'selected="selected"';
335
+					} ?> value="0"><?php _e('All', 'geodirectory'); ?></option>
336 336
                     <?php foreach ($categories as $category_obj) {
337
-                        $selected = '';
338
-                        if (is_array($category) && in_array($category_obj->term_id, $category))
339
-                            echo $selected = 'selected="selected"';
337
+						$selected = '';
338
+						if (is_array($category) && in_array($category_obj->term_id, $category))
339
+							echo $selected = 'selected="selected"';
340 340
 
341
-                        ?>
341
+						?>
342 342
 
343 343
                         <option <?php echo $selected; ?>
344 344
                             value="<?php echo $category_obj->term_id; ?>"><?php echo ucfirst($category_obj->name); ?></option>
@@ -363,28 +363,28 @@  discard block
 block discarded – undo
363 363
                         name="<?php echo $this->get_field_name('list_sort'); ?>">
364 364
 
365 365
                     <option <?php if ($list_sort == 'az') {
366
-                        echo 'selected="selected"';
367
-                    } ?> value="az"><?php _e('A-Z', 'geodirectory'); ?></option>
366
+						echo 'selected="selected"';
367
+					} ?> value="az"><?php _e('A-Z', 'geodirectory'); ?></option>
368 368
 
369 369
                     <option <?php if ($list_sort == 'latest') {
370
-                        echo 'selected="selected"';
371
-                    } ?> value="latest"><?php _e('Latest', 'geodirectory'); ?></option>
370
+						echo 'selected="selected"';
371
+					} ?> value="latest"><?php _e('Latest', 'geodirectory'); ?></option>
372 372
 
373 373
                     <option <?php if ($list_sort == 'featured') {
374
-                        echo 'selected="selected"';
375
-                    } ?> value="featured"><?php _e('Featured', 'geodirectory'); ?></option>
374
+						echo 'selected="selected"';
375
+					} ?> value="featured"><?php _e('Featured', 'geodirectory'); ?></option>
376 376
 
377 377
                     <option <?php if ($list_sort == 'high_review') {
378
-                        echo 'selected="selected"';
379
-                    } ?> value="high_review"><?php _e('Review', 'geodirectory'); ?></option>
378
+						echo 'selected="selected"';
379
+					} ?> value="high_review"><?php _e('Review', 'geodirectory'); ?></option>
380 380
 
381 381
                     <option <?php if ($list_sort == 'high_rating') {
382
-                        echo 'selected="selected"';
383
-                    } ?> value="high_rating"><?php _e('Rating', 'geodirectory'); ?></option>
382
+						echo 'selected="selected"';
383
+					} ?> value="high_rating"><?php _e('Rating', 'geodirectory'); ?></option>
384 384
 
385 385
                     <option <?php if ($list_sort == 'random') {
386
-                        echo 'selected="selected"';
387
-                    } ?> value="random"><?php _e('Random', 'geodirectory'); ?></option>
386
+						echo 'selected="selected"';
387
+					} ?> value="random"><?php _e('Random', 'geodirectory'); ?></option>
388 388
 
389 389
                 </select>
390 390
             </label>
@@ -407,24 +407,24 @@  discard block
 block discarded – undo
407 407
                 <select class="widefat" id="<?php echo $this->get_field_id('layout'); ?>"
408 408
                         name="<?php echo $this->get_field_name('layout'); ?>">
409 409
                     <option <?php if ($layout == 'gridview_onehalf') {
410
-                        echo 'selected="selected"';
411
-                    } ?>
410
+						echo 'selected="selected"';
411
+					} ?>
412 412
                         value="gridview_onehalf"><?php _e('Grid View (Two Columns)', 'geodirectory'); ?></option>
413 413
                     <option <?php if ($layout == 'gridview_onethird') {
414
-                        echo 'selected="selected"';
415
-                    } ?>
414
+						echo 'selected="selected"';
415
+					} ?>
416 416
                         value="gridview_onethird"><?php _e('Grid View (Three Columns)', 'geodirectory'); ?></option>
417 417
                     <option <?php if ($layout == 'gridview_onefourth') {
418
-                        echo 'selected="selected"';
419
-                    } ?>
418
+						echo 'selected="selected"';
419
+					} ?>
420 420
                         value="gridview_onefourth"><?php _e('Grid View (Four Columns)', 'geodirectory'); ?></option>
421 421
                     <option <?php if ($layout == 'gridview_onefifth') {
422
-                        echo 'selected="selected"';
423
-                    } ?>
422
+						echo 'selected="selected"';
423
+					} ?>
424 424
                         value="gridview_onefifth"><?php _e('Grid View (Five Columns)', 'geodirectory'); ?></option>
425 425
                     <option <?php if ($layout == 'list') {
426
-                        echo 'selected="selected"';
427
-                    } ?> value="list"><?php _e('List view', 'geodirectory'); ?></option>
426
+						echo 'selected="selected"';
427
+					} ?> value="list"><?php _e('List view', 'geodirectory'); ?></option>
428 428
 
429 429
                 </select>
430 430
             </label>
@@ -494,8 +494,8 @@  discard block
 block discarded – undo
494 494
                 for="<?php echo $this->get_field_id('use_viewing_post_type'); ?>"><?php _e('Use current viewing post type:', 'geodirectory'); ?>
495 495
                 <input type="checkbox" id="<?php echo $this->get_field_id('use_viewing_post_type'); ?>"
496 496
                        name="<?php echo $this->get_field_name('use_viewing_post_type'); ?>" <?php if ($use_viewing_post_type) {
497
-                    echo 'checked="checked"';
498
-                } ?>  value="1"/>
497
+					echo 'checked="checked"';
498
+				} ?>  value="1"/>
499 499
             </label>
500 500
         </p>
501 501
 
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
         </script>
540 540
 
541 541
     <?php
542
-    }
542
+	}
543 543
 } // class geodir_popular_postview
544 544
 
545 545
 register_widget('geodir_popular_postview');
546 546
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
         //save the widget
62 62
         $instance = $old_instance;
63 63
         $instance['title'] = strip_tags($new_instance['title']);
64
-        $category_limit = (int)$new_instance['category_limit'];
64
+        $category_limit = (int) $new_instance['category_limit'];
65 65
         $instance['category_limit'] = $category_limit > 0 ? $category_limit : 15;
66 66
         $instance['default_post_type'] = isset($new_instance['default_post_type']) ? $new_instance['default_post_type'] : '';
67 67
         $instance['parent_only'] = !empty($new_instance['parent_only']) ? true : false;
@@ -81,13 +81,13 @@  discard block
 block discarded – undo
81 81
     public function form($instance) 
82 82
     {
83 83
         //widgetform in backend
84
-        $instance = wp_parse_args((array)$instance, array('title' => '', 'category_limit' => 15, 'default_post_type' => '', 'parent_only' => false));
84
+        $instance = wp_parse_args((array) $instance, array('title' => '', 'category_limit' => 15, 'default_post_type' => '', 'parent_only' => false));
85 85
 
86 86
         $title = strip_tags($instance['title']);
87
-        $category_limit = (int)$instance['category_limit'];
87
+        $category_limit = (int) $instance['category_limit'];
88 88
         $category_limit = $category_limit > 0 ? $category_limit : 15;
89 89
         $default_post_type = isset($instance['default_post_type']) ? $instance['default_post_type'] : '';
90
-        $parent_only = !empty($instance['parent_only']) ? true: false;
90
+        $parent_only = !empty($instance['parent_only']) ? true : false;
91 91
         
92 92
         $post_type_options = geodir_get_posttypes('options');
93 93
         ?>
@@ -97,23 +97,23 @@  discard block
 block discarded – undo
97 97
             </label>
98 98
         </p>
99 99
         <p>
100
-            <label for="<?php echo $this->get_field_id('post_type'); ?>"><?php _e('Default post type to use (if not set by page)', 'geodirectory');?>
100
+            <label for="<?php echo $this->get_field_id('post_type'); ?>"><?php _e('Default post type to use (if not set by page)', 'geodirectory'); ?>
101 101
                 <select class="widefat" id="<?php echo $this->get_field_id('default_post_type'); ?>" name="<?php echo $this->get_field_name('default_post_type'); ?>">
102 102
                 <?php foreach ($post_type_options as $name => $title) { ?>
103
-                    <option value="<?php echo $name;?>" <?php selected($name, $default_post_type);?>><?php echo $title; ?></option>
103
+                    <option value="<?php echo $name; ?>" <?php selected($name, $default_post_type); ?>><?php echo $title; ?></option>
104 104
                 <?php } ?>
105 105
                 </select>
106 106
             </label>
107 107
         </p>
108 108
         <p>
109 109
             <label for="<?php echo $this->get_field_id('category_limit'); ?>"><?php _e('Customize categories count to appear by default:', 'geodirectory'); ?>
110
-                <input class="widefat" id="<?php echo $this->get_field_id('category_limit'); ?>" name="<?php echo $this->get_field_name('category_limit'); ?>" type="text" value="<?php echo (int)esc_attr($category_limit); ?>"/>
110
+                <input class="widefat" id="<?php echo $this->get_field_id('category_limit'); ?>" name="<?php echo $this->get_field_name('category_limit'); ?>" type="text" value="<?php echo (int) esc_attr($category_limit); ?>"/>
111 111
                 <p class="description" style="padding:0"><?php _e('After categories count reaches this limit option More Categories / Less Categoris will be displayed to show/hide categories. Default: 15', 'geodirectory'); ?></p>
112 112
             </label>
113 113
         </p>
114 114
         <p>
115
-            <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('parent_only'); ?>" name="<?php echo $this->get_field_name('parent_only'); ?>"<?php checked( $parent_only ); ?> value="1" />
116
-            <label for="<?php echo $this->get_field_id('parent_only'); ?>"><?php _e( 'Show parent categories only', 'geodirectory' ); ?></label>
115
+            <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('parent_only'); ?>" name="<?php echo $this->get_field_name('parent_only'); ?>"<?php checked($parent_only); ?> value="1" />
116
+            <label for="<?php echo $this->get_field_id('parent_only'); ?>"><?php _e('Show parent categories only', 'geodirectory'); ?></label>
117 117
         </p>
118 118
     <?php
119 119
     }
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	public function form($instance)
216 216
     {
217 217
         //widgetform in backend
218
-        $instance = wp_parse_args((array)$instance,
218
+        $instance = wp_parse_args((array) $instance,
219 219
             array('title' => '',
220 220
                 'post_type' => '',
221 221
                 'category' => array(),
@@ -266,9 +266,9 @@  discard block
 block discarded – undo
266 266
         ?>
267 267
 
268 268
         <p>
269
-            <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'geodirectory');?>
269
+            <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'geodirectory'); ?>
270 270
                 <small>(%posttype_singular_label% ,
271
-                    %posttype_plural_label% <?php _e('can be used', 'geodirectory');?>)
271
+                    %posttype_plural_label% <?php _e('can be used', 'geodirectory'); ?>)
272 272
                 </small>
273 273
 
274 274
                 <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>"
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 
280 280
         <p>
281 281
             <label
282
-                for="<?php echo $this->get_field_id('post_type'); ?>"><?php _e('Post Type:', 'geodirectory');?>
282
+                for="<?php echo $this->get_field_id('post_type'); ?>"><?php _e('Post Type:', 'geodirectory'); ?>
283 283
 
284 284
                 <?php $postypes = geodir_get_posttypes();
285 285
 				/**
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 
312 312
         <p id="post_type_cats">
313 313
             <label
314
-                for="<?php echo $this->get_field_id('category'); ?>"><?php _e('Post Category:', 'geodirectory');?>
314
+                for="<?php echo $this->get_field_id('category'); ?>"><?php _e('Post Category:', 'geodirectory'); ?>
315 315
 
316 316
                 <?php
317 317
 
@@ -350,14 +350,14 @@  discard block
 block discarded – undo
350 350
 
351 351
                 <input type="hidden" name="<?php echo $this->get_field_name('category_title'); ?>"
352 352
                        id="<?php echo $this->get_field_id('category_title'); ?>"
353
-                       value="<?php if ($category_title != '') echo $category_title; else echo __('All', 'geodirectory');?>"/>
353
+                       value="<?php if ($category_title != '') echo $category_title; else echo __('All', 'geodirectory'); ?>"/>
354 354
 
355 355
             </label>
356 356
         </p>
357 357
 
358 358
         <p>
359 359
             <label
360
-                for="<?php echo $this->get_field_id('list_sort'); ?>"><?php _e('Sort by:', 'geodirectory');?>
360
+                for="<?php echo $this->get_field_id('list_sort'); ?>"><?php _e('Sort by:', 'geodirectory'); ?>
361 361
 
362 362
                 <select class="widefat" id="<?php echo $this->get_field_id('list_sort'); ?>"
363 363
                         name="<?php echo $this->get_field_name('list_sort'); ?>">
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
         <p>
394 394
 
395 395
             <label
396
-                for="<?php echo $this->get_field_id('post_number'); ?>"><?php _e('Number of posts:', 'geodirectory');?>
396
+                for="<?php echo $this->get_field_id('post_number'); ?>"><?php _e('Number of posts:', 'geodirectory'); ?>
397 397
 
398 398
                 <input class="widefat" id="<?php echo $this->get_field_id('post_number'); ?>"
399 399
                        name="<?php echo $this->get_field_name('post_number'); ?>" type="text"
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 
404 404
         <p>
405 405
             <label for="<?php echo $this->get_field_id('layout'); ?>">
406
-                <?php _e('Layout:', 'geodirectory');?>
406
+                <?php _e('Layout:', 'geodirectory'); ?>
407 407
                 <select class="widefat" id="<?php echo $this->get_field_id('layout'); ?>"
408 408
                         name="<?php echo $this->get_field_name('layout'); ?>">
409 409
                     <option <?php if ($layout == 'gridview_onehalf') {
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 
433 433
         <p>
434 434
             <label
435
-                for="<?php echo $this->get_field_id('listing_width'); ?>"><?php _e('Listing width:', 'geodirectory');?>
435
+                for="<?php echo $this->get_field_id('listing_width'); ?>"><?php _e('Listing width:', 'geodirectory'); ?>
436 436
 
437 437
                 <input class="widefat" id="<?php echo $this->get_field_id('listing_width'); ?>"
438 438
                        name="<?php echo $this->get_field_name('listing_width'); ?>" type="text"
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 
443 443
         <p>
444 444
             <label
445
-                for="<?php echo $this->get_field_id('character_count'); ?>"><?php _e('Post Content excerpt character count :', 'geodirectory');?>
445
+                for="<?php echo $this->get_field_id('character_count'); ?>"><?php _e('Post Content excerpt character count :', 'geodirectory'); ?>
446 446
                 <input class="widefat" id="<?php echo $this->get_field_id('character_count'); ?>"
447 447
                        name="<?php echo $this->get_field_name('character_count'); ?>" type="text"
448 448
                        value="<?php echo esc_attr($character_count); ?>"/>
@@ -451,41 +451,41 @@  discard block
 block discarded – undo
451 451
 
452 452
         <p>
453 453
             <label for="<?php echo $this->get_field_id('add_location_filter'); ?>">
454
-                <?php _e('Enable Location Filter:', 'geodirectory');?>
454
+                <?php _e('Enable Location Filter:', 'geodirectory'); ?>
455 455
                 <input type="checkbox" id="<?php echo $this->get_field_id('add_location_filter'); ?>"
456
-                       name="<?php echo $this->get_field_name('add_location_filter'); ?>" <?php if ($add_location_filter) echo 'checked="checked"';?>
456
+                       name="<?php echo $this->get_field_name('add_location_filter'); ?>" <?php if ($add_location_filter) echo 'checked="checked"'; ?>
457 457
                        value="1"/>
458 458
             </label>
459 459
         </p>
460 460
         <p>
461 461
             <label for="<?php echo $this->get_field_id('show_featured_only'); ?>">
462
-                <?php _e('Show only featured listings:', 'geodirectory');?> <input type="checkbox"
462
+                <?php _e('Show only featured listings:', 'geodirectory'); ?> <input type="checkbox"
463 463
                                                                                             id="<?php echo $this->get_field_id('show_featured_only'); ?>"
464
-                                                                                            name="<?php echo $this->get_field_name('show_featured_only'); ?>" <?php if ($show_featured_only) echo 'checked="checked"';?>
464
+                                                                                            name="<?php echo $this->get_field_name('show_featured_only'); ?>" <?php if ($show_featured_only) echo 'checked="checked"'; ?>
465 465
                                                                                             value="1"/>
466 466
             </label>
467 467
         </p>
468 468
         <p>
469 469
             <label for="<?php echo $this->get_field_id('show_special_only'); ?>">
470
-                <?php _e('Show only listings with special offers:', 'geodirectory');?> <input type="checkbox"
470
+                <?php _e('Show only listings with special offers:', 'geodirectory'); ?> <input type="checkbox"
471 471
                                                                                                        id="<?php echo $this->get_field_id('show_special_only'); ?>"
472
-                                                                                                       name="<?php echo $this->get_field_name('show_special_only'); ?>" <?php if ($show_special_only) echo 'checked="checked"';?>
472
+                                                                                                       name="<?php echo $this->get_field_name('show_special_only'); ?>" <?php if ($show_special_only) echo 'checked="checked"'; ?>
473 473
                                                                                                        value="1"/>
474 474
             </label>
475 475
         </p>
476 476
         <p>
477 477
             <label for="<?php echo $this->get_field_id('with_pics_only'); ?>">
478
-                <?php _e('Show only listings with pics:', 'geodirectory');?> <input type="checkbox"
478
+                <?php _e('Show only listings with pics:', 'geodirectory'); ?> <input type="checkbox"
479 479
                                                                                              id="<?php echo $this->get_field_id('with_pics_only'); ?>"
480
-                                                                                             name="<?php echo $this->get_field_name('with_pics_only'); ?>" <?php if ($with_pics_only) echo 'checked="checked"';?>
480
+                                                                                             name="<?php echo $this->get_field_name('with_pics_only'); ?>" <?php if ($with_pics_only) echo 'checked="checked"'; ?>
481 481
                                                                                              value="1"/>
482 482
             </label>
483 483
         </p>
484 484
         <p>
485 485
             <label for="<?php echo $this->get_field_id('with_videos_only'); ?>">
486
-                <?php _e('Show only listings with videos:', 'geodirectory');?> <input type="checkbox"
486
+                <?php _e('Show only listings with videos:', 'geodirectory'); ?> <input type="checkbox"
487 487
                                                                                                id="<?php echo $this->get_field_id('with_videos_only'); ?>"
488
-                                                                                               name="<?php echo $this->get_field_name('with_videos_only'); ?>" <?php if ($with_videos_only) echo 'checked="checked"';?>
488
+                                                                                               name="<?php echo $this->get_field_name('with_videos_only'); ?>" <?php if ($with_videos_only) echo 'checked="checked"'; ?>
489 489
                                                                                                value="1"/>
490 490
             </label>
491 491
         </p>
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
 
532 532
             }
533 533
 
534
-            <?php if(is_active_widget( false, false, $this->id_base, true )){ ?>
534
+            <?php if (is_active_widget(false, false, $this->id_base, true)) { ?>
535 535
             var post_type = jQuery('#<?php echo $this->get_field_id('post_type'); ?>').val();
536 536
 
537 537
             <?php } ?>
Please login to merge, or discard this patch.