Test Failed
Push — master ( 2185f5...faf44c )
by Stiofan
04:27
created
geodirectory-functions/post_functions.php 1 patch
Braces   +168 added lines, -119 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)){
@@ -384,8 +385,9 @@  discard block
 block discarded – undo
384 385
             } elseif (trim($type) == 'file') {
385 386
                 if (isset($request_info[$name])) {
386 387
                     $request_files = array();
387
-                    if ($request_info[$name] != '')
388
-                        $request_files = explode(",", $request_info[$name]);
388
+                    if ($request_info[$name] != '') {
389
+                                            $request_files = explode(",", $request_info[$name]);
390
+                    }
389 391
 
390 392
                     $extrafields = $extrafields != '' ? maybe_unserialize($extrafields) : NULL;
391 393
                     geodir_save_post_file_fields($last_post_id, $name, $request_files, $extrafields);
@@ -412,7 +414,7 @@  discard block
 block discarded – undo
412 414
 
413 415
                             $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $request_info[$name]) : $request_info[$name];
414 416
 
415
-                        }else{
417
+                        } else{
416 418
                             $post_htmlvar_value = $request_info[$name];
417 419
                         }
418 420
 
@@ -452,15 +454,17 @@  discard block
 block discarded – undo
452 454
 
453 455
             foreach ($request_info['post_category'] as $taxonomy => $cat) {
454 456
 
455
-                if ($dummy)
456
-                    $post_category = $cat;
457
-                else {
457
+                if ($dummy) {
458
+                                    $post_category = $cat;
459
+                } else {
458 460
 
459
-                    if (!is_array($cat) && strstr($cat, ','))
460
-                        $cat = explode(',', $cat);
461
+                    if (!is_array($cat) && strstr($cat, ',')) {
462
+                                            $cat = explode(',', $cat);
463
+                    }
461 464
 
462
-                    if (!empty($cat) && is_array($cat))
463
-                        $post_category = array_map('intval', $cat);
465
+                    if (!empty($cat) && is_array($cat)) {
466
+                                            $post_category = array_map('intval', $cat);
467
+                    }
464 468
                 }
465 469
 
466 470
                 wp_set_object_terms($last_post_id, $post_category, $taxonomy);
@@ -478,11 +482,13 @@  discard block
 block discarded – undo
478 482
         if (isset($request_info['post_tags']) && !is_array($request_info['post_tags']) && !empty($request_info['post_tags'])) {
479 483
             $post_tags = explode(",", $request_info['post_tags']);
480 484
         } elseif (isset($request_info['post_tags']) && is_array($request_info['post_tags'])) {
481
-            if ($dummy)
482
-                $post_tags = $request_info['post_tags'];
485
+            if ($dummy) {
486
+                            $post_tags = $request_info['post_tags'];
487
+            }
483 488
         } else {
484
-            if ($dummy)
485
-                $post_tags = array($request_info['post_title']);
489
+            if ($dummy) {
490
+                            $post_tags = array($request_info['post_title']);
491
+            }
486 492
         }
487 493
 
488 494
         if (is_array($post_tags)) {
@@ -569,15 +575,17 @@  discard block
 block discarded – undo
569 575
 
570 576
     global $wpdb, $plugin_prefix, $post, $post_info;
571 577
 
572
-    if ($post_id == '' && !empty($post))
573
-        $post_id = $post->ID;
578
+    if ($post_id == '' && !empty($post)) {
579
+            $post_id = $post->ID;
580
+    }
574 581
 
575 582
     $post_type = get_post_type($post_id);
576 583
 
577 584
     $all_postypes = geodir_get_posttypes();
578 585
 
579
-    if (!in_array($post_type, $all_postypes))
580
-        return false;
586
+    if (!in_array($post_type, $all_postypes)) {
587
+            return false;
588
+    }
581 589
 
582 590
     $table = $plugin_prefix . $post_type . '_detail';
583 591
 
@@ -737,8 +745,9 @@  discard block
 block discarded – undo
737 745
             do_action('geodir_after_save_listinginfo', $postinfo_array, $post_id);
738 746
 
739 747
             return true;
740
-        } else
741
-            return false;
748
+        } else {
749
+                    return false;
750
+        }
742 751
 
743 752
     }
744 753
 }
@@ -792,8 +801,9 @@  discard block
 block discarded – undo
792 801
             }
793 802
 
794 803
 
795
-        } else
796
-            return false;
804
+        } else {
805
+                    return false;
806
+        }
797 807
     }
798 808
 }
799 809
 
@@ -824,8 +834,9 @@  discard block
 block discarded – undo
824 834
             $post_meta_set_query = '';
825 835
 
826 836
             foreach ($postmeta as $mkey) {
827
-                if ($mval != '')
828
-                    $post_meta_set_query .= $mkey . " = '', ";
837
+                if ($mval != '') {
838
+                                    $post_meta_set_query .= $mkey . " = '', ";
839
+                }
829 840
             }
830 841
 
831 842
             $post_meta_set_query = trim($post_meta_set_query, ", ");
@@ -859,8 +870,9 @@  discard block
 block discarded – undo
859 870
                 return true;
860 871
             }
861 872
 
862
-        } else
863
-            return false;
873
+        } else {
874
+                    return false;
875
+        }
864 876
     }
865 877
 }
866 878
 
@@ -890,8 +902,9 @@  discard block
 block discarded – undo
890 902
 
891 903
         $post_type = get_post_type($post_id);
892 904
 
893
-        if (!in_array($post_type, $all_postypes))
894
-            return false;
905
+        if (!in_array($post_type, $all_postypes)) {
906
+                    return false;
907
+        }
895 908
 
896 909
         $table = $plugin_prefix . $post_type . '_detail';
897 910
 
@@ -1046,7 +1059,7 @@  discard block
 block discarded – undo
1046 1059
                             if (isset($uploaded['error']) && empty($uploaded['error'])) {
1047 1060
                                 $new_name = basename($uploaded['file']);
1048 1061
                                 $uploaded_file = $uploaded;
1049
-                            }else{
1062
+                            } else{
1050 1063
                                 print_r($uploaded);exit;
1051 1064
                             }
1052 1065
                             $external_img = false;
@@ -1071,8 +1084,9 @@  discard block
 block discarded – undo
1071 1084
                                 $file_path = $curr_img_dir . '/' . $filename;
1072 1085
                             }
1073 1086
 
1074
-                            if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path))
1075
-                                unlink($img_path);
1087
+                            if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path)) {
1088
+                                                            unlink($img_path);
1089
+                            }
1076 1090
                         }
1077 1091
 
1078 1092
                         if (!empty($uploaded_file)) {
@@ -1101,8 +1115,9 @@  discard block
 block discarded – undo
1101 1115
                             $attachment_set = '';
1102 1116
 
1103 1117
                             foreach ($attachment as $key => $val) {
1104
-                                if ($val != '')
1105
-                                    $attachment_set .= $key . " = '" . $val . "', ";
1118
+                                if ($val != '') {
1119
+                                                                    $attachment_set .= $key . " = '" . $val . "', ";
1120
+                                }
1106 1121
                             }
1107 1122
 
1108 1123
                             $attachment_set = trim($attachment_set, ", ");
@@ -1127,8 +1142,9 @@  discard block
 block discarded – undo
1127 1142
                         )
1128 1143
                     );
1129 1144
 
1130
-                    if ($menu_order == 1)
1131
-                        $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
1145
+                    if ($menu_order == 1) {
1146
+                                            $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
1147
+                    }
1132 1148
 
1133 1149
                 }
1134 1150
 
@@ -1169,8 +1185,9 @@  discard block
 block discarded – undo
1169 1185
 
1170 1186
         $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE " . $valid_files_condition . " post_id = %d", $remove_files));
1171 1187
 
1172
-        if (!empty($invalid_files))
1173
-            geodir_remove_attachments($invalid_files);
1188
+        if (!empty($invalid_files)) {
1189
+                    geodir_remove_attachments($invalid_files);
1190
+        }
1174 1191
     }
1175 1192
 
1176 1193
 }
@@ -1223,16 +1240,19 @@  discard block
 block discarded – undo
1223 1240
 function geodir_delete_directory($dirname)
1224 1241
 {
1225 1242
     $dir_handle = '';
1226
-    if (is_dir($dirname))
1227
-        $dir_handle = opendir($dirname);
1228
-    if (!$dir_handle)
1229
-        return false;
1243
+    if (is_dir($dirname)) {
1244
+            $dir_handle = opendir($dirname);
1245
+    }
1246
+    if (!$dir_handle) {
1247
+            return false;
1248
+    }
1230 1249
     while ($file = readdir($dir_handle)) {
1231 1250
         if ($file != "." && $file != "..") {
1232
-            if (!is_dir($dirname . "/" . $file))
1233
-                unlink($dirname . "/" . $file);
1234
-            else
1235
-                geodir_delete_directory($dirname . '/' . $file);
1251
+            if (!is_dir($dirname . "/" . $file)) {
1252
+                            unlink($dirname . "/" . $file);
1253
+            } else {
1254
+                            geodir_delete_directory($dirname . '/' . $file);
1255
+            }
1236 1256
         }
1237 1257
     }
1238 1258
     closedir($dir_handle);
@@ -1261,8 +1281,9 @@  discard block
 block discarded – undo
1261 1281
             foreach ($postcurr_images as $postimg) {
1262 1282
                 $image_name_arr = explode('/', $postimg->src);
1263 1283
                 $filename = end($image_name_arr);
1264
-                if (file_exists($uploads_dir . '/' . $filename))
1265
-                    unlink($uploads_dir . '/' . $filename);
1284
+                if (file_exists($uploads_dir . '/' . $filename)) {
1285
+                                    unlink($uploads_dir . '/' . $filename);
1286
+                }
1266 1287
             }
1267 1288
 
1268 1289
         } // endif
@@ -1381,9 +1402,9 @@  discard block
 block discarded – undo
1381 1402
                 $default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1382 1403
             }
1383 1404
 
1384
-            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1385
-                $default_img = $default_catimg['src'];
1386
-            elseif ($no_image) {
1405
+            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) {
1406
+                            $default_img = $default_catimg['src'];
1407
+            } elseif ($no_image) {
1387 1408
                 $default_img = get_option('geodir_listing_no_img');
1388 1409
             }
1389 1410
 
@@ -1415,10 +1436,13 @@  discard block
 block discarded – undo
1415 1436
             }
1416 1437
         }
1417 1438
 
1418
-        if (!empty($img_arr))
1419
-            return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path );
1420
-        else
1421
-            return false;
1439
+        if (!empty($img_arr)) {
1440
+                    return (object)$img_arr;
1441
+        }
1442
+        //return (object)array( 'src' => $file_url, 'path' => $file_path );
1443
+        else {
1444
+                    return false;
1445
+        }
1422 1446
     }
1423 1447
 }
1424 1448
 
@@ -1445,8 +1469,9 @@  discard block
 block discarded – undo
1445 1469
             echo $html;
1446 1470
         } elseif (!empty($html)) {
1447 1471
             return $html;
1448
-        } else
1449
-            return false;
1472
+        } else {
1473
+                    return false;
1474
+        }
1450 1475
     }
1451 1476
 }
1452 1477
 
@@ -1474,8 +1499,9 @@  discard block
 block discarded – undo
1474 1499
         }
1475 1500
         $not_featured = '';
1476 1501
         $sub_dir = '';
1477
-        if (!$add_featured)
1478
-            $not_featured = " AND is_featured = 0 ";
1502
+        if (!$add_featured) {
1503
+                    $not_featured = " AND is_featured = 0 ";
1504
+        }
1479 1505
 
1480 1506
         $arrImages = $wpdb->get_results(
1481 1507
             $wpdb->prepare(
@@ -1496,8 +1522,9 @@  discard block
 block discarded – undo
1496 1522
 
1497 1523
                 $file_info = pathinfo($attechment->file);
1498 1524
 
1499
-                if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
1500
-                    $sub_dir = stripslashes_deep($file_info['dirname']);
1525
+                if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') {
1526
+                                    $sub_dir = stripslashes_deep($file_info['dirname']);
1527
+                }
1501 1528
 
1502 1529
                 $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1503 1530
                 $uploads_baseurl = $uploads['baseurl'];
@@ -1549,9 +1576,9 @@  discard block
 block discarded – undo
1549 1576
             $default_img = '';
1550 1577
             $default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1551 1578
             $post_type = get_post_type($post_id);
1552
-            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1553
-                $default_img = $default_catimg['src'];
1554
-            elseif ($no_images) {
1579
+            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) {
1580
+                            $default_img = $default_catimg['src'];
1581
+            } elseif ($no_images) {
1555 1582
                 $default_img = get_option('geodir_listing_no_img');
1556 1583
             }
1557 1584
 
@@ -1592,8 +1619,9 @@  discard block
 block discarded – undo
1592 1619
                  * @param array $return_arr The array of image objects.
1593 1620
                  */
1594 1621
                 return apply_filters('geodir_get_images_arr',$return_arr);
1595
-            } else
1596
-                return false;
1622
+            } else {
1623
+                            return false;
1624
+            }
1597 1625
         }
1598 1626
     }
1599 1627
 }
@@ -1654,8 +1682,9 @@  discard block
 block discarded – undo
1654 1682
                         $width_per = round(((($image->width * ($max_size->h / $image->height)) / $max_size->w) * 100), 2);
1655 1683
                     } else if ($image->width < ($max_size->h)) {
1656 1684
                         $width_per = round((($image->width / $max_size->w) * 100), 2);
1657
-                    } else
1658
-                        $width_per = 100;
1685
+                    } else {
1686
+                                            $width_per = 100;
1687
+                    }
1659 1688
                 }
1660 1689
 
1661 1690
                 if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
@@ -1663,7 +1692,7 @@  discard block
 block discarded – undo
1663 1692
                 } else {
1664 1693
                     if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){
1665 1694
                         $html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1666
-                    }else{
1695
+                    } else{
1667 1696
                         //$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1668 1697
                         //$html = '<div data-src="'.$image->src.'" class="geodir_thumbnail" ></div>';
1669 1698
                         $html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>';
@@ -1678,8 +1707,9 @@  discard block
 block discarded – undo
1678 1707
             echo $html;
1679 1708
         } elseif (!empty($html)) {
1680 1709
             return $html;
1681
-        } else
1682
-            return false;
1710
+        } else {
1711
+                    return false;
1712
+        }
1683 1713
     }
1684 1714
 }
1685 1715
 
@@ -1717,8 +1747,9 @@  discard block
 block discarded – undo
1717 1747
                 $post_obj = get_post($post_id);
1718 1748
 
1719 1749
                 $cat_ids = array('0');
1720
-                if (is_array($tt_ids))
1721
-                    $cat_ids = $tt_ids;
1750
+                if (is_array($tt_ids)) {
1751
+                                    $cat_ids = $tt_ids;
1752
+                }
1722 1753
 
1723 1754
 
1724 1755
                 if (!empty($cat_ids)) {
@@ -1775,8 +1806,9 @@  discard block
 block discarded – undo
1775 1806
                         $json .= '}';
1776 1807
 
1777 1808
 
1778
-                        if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true))
1779
-                            $post_marker_json = $json;
1809
+                        if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true)) {
1810
+                                                    $post_marker_json = $json;
1811
+                        }
1780 1812
 
1781 1813
 
1782 1814
                         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)))) {
@@ -1807,10 +1839,13 @@  discard block
 block discarded – undo
1807 1839
                 if (!empty($post_term) && is_array($post_term)) {
1808 1840
                     $categories = implode(',', $post_term);
1809 1841
 
1810
-                    if ($categories != '' && $categories != 0) $categories = ',' . $categories . ',';
1842
+                    if ($categories != '' && $categories != 0) {
1843
+                    	$categories = ',' . $categories . ',';
1844
+                    }
1811 1845
 
1812
-                    if (empty($post_marker_json))
1813
-                        $post_marker_json = isset($json) ? $json : '';
1846
+                    if (empty($post_marker_json)) {
1847
+                                            $post_marker_json = isset($json) ? $json : '';
1848
+                    }
1814 1849
 
1815 1850
                     if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
1816 1851
 
@@ -1849,8 +1884,9 @@  discard block
 block discarded – undo
1849 1884
 
1850 1885
                                 }
1851 1886
 
1852
-                                if ($default_category == '')
1853
-                                    $default_category = $categories[0];
1887
+                                if ($default_category == '') {
1888
+                                                                    $default_category = $categories[0];
1889
+                                }
1854 1890
 
1855 1891
                                 geodir_set_postcat_structure($post_id, $taxonomy, $default_category, '');
1856 1892
 
@@ -1997,7 +2033,7 @@  discard block
 block discarded – undo
1997 2033
                                     } ?>"><img alt="bubble image" style="max-height:50px;"
1998 2034
                                                src="<?php echo $post_images[0]; ?>"/></a></div>
1999 2035
                             <?php
2000
-                            }else{
2036
+                            } else{
2001 2037
                                 echo '<div class="geodir-bubble_image"></div>';
2002 2038
                             }
2003 2039
                         } else {
@@ -2005,7 +2041,7 @@  discard block
 block discarded – undo
2005 2041
                                 ?>
2006 2042
                                 <div class="geodir-bubble_image"><a href="<?php echo $plink; ?>"><?php echo $image; ?></a></div>
2007 2043
                             <?php
2008
-                            }else{
2044
+                            } else{
2009 2045
                                 echo '<div class="geodir-bubble_image"></div>';
2010 2046
                             }
2011 2047
                         }
@@ -2086,10 +2122,11 @@  discard block
 block discarded – undo
2086 2122
      */
2087 2123
     function geodir_new_post_default_status()
2088 2124
     {
2089
-        if (get_option('geodir_new_post_default_status'))
2090
-            return get_option('geodir_new_post_default_status');
2091
-        else
2092
-            return 'publish';
2125
+        if (get_option('geodir_new_post_default_status')) {
2126
+                    return get_option('geodir_new_post_default_status');
2127
+        } else {
2128
+                    return 'publish';
2129
+        }
2093 2130
 
2094 2131
     }
2095 2132
 }
@@ -2240,8 +2277,9 @@  discard block
 block discarded – undo
2240 2277
 
2241 2278
         $all_postypes = geodir_get_posttypes();
2242 2279
 
2243
-        if (!in_array($post_type, $all_postypes))
2244
-            return false;
2280
+        if (!in_array($post_type, $all_postypes)) {
2281
+                    return false;
2282
+        }
2245 2283
 
2246 2284
         $table = $plugin_prefix . $post_type . '_detail';
2247 2285
 
@@ -2509,8 +2547,9 @@  discard block
 block discarded – undo
2509 2547
         $unfavourite_icon = apply_filters('geodir_unfavourite_icon', 'fa fa-heart');
2510 2548
 
2511 2549
         $user_meta_data = '';
2512
-        if (isset($current_user->data->ID))
2513
-            $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2550
+        if (isset($current_user->data->ID)) {
2551
+                    $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2552
+        }
2514 2553
 
2515 2554
         if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
2516 2555
             ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"  ><a
@@ -2523,8 +2562,9 @@  discard block
 block discarded – undo
2523 2562
 
2524 2563
             if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
2525 2564
                 $script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\'';
2526
-            } else
2527
-                $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
2565
+            } else {
2566
+                            $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
2567
+            }
2528 2568
 
2529 2569
             ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon"
2530 2570
                                                                                         href="javascript:void(0);"
@@ -2587,14 +2627,16 @@  discard block
 block discarded – undo
2587 2627
 							WHERE pd.post_status='publish' AND FIND_IN_SET('" . $term->term_id . "'," . $term->taxonomy . ") " . $where;
2588 2628
 
2589 2629
             $cat_post_count = $wpdb->get_var($count_query);
2590
-            if (empty($cat_post_count) || is_wp_error($cat_post_count))
2591
-                $cat_post_count = 0;
2630
+            if (empty($cat_post_count) || is_wp_error($cat_post_count)) {
2631
+                            $cat_post_count = 0;
2632
+            }
2592 2633
 
2593 2634
             return $cat_post_count;
2594 2635
 
2595
-        } else
2596
-
2597
-            return $term->count;
2636
+        } else {
2637
+        
2638
+            return $term->count;
2639
+        }
2598 2640
     }
2599 2641
     return false;
2600 2642
 
@@ -2641,13 +2683,15 @@  discard block
 block discarded – undo
2641 2683
 		return $length;
2642 2684
 	}
2643 2685
 	
2644
-    if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit'))
2645
-        $length = get_option('geodir_desc_word_limit');
2646
-    elseif (get_query_var('excerpt_length'))
2647
-        $length = get_query_var('excerpt_length');
2686
+    if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit')) {
2687
+            $length = get_option('geodir_desc_word_limit');
2688
+    } elseif (get_query_var('excerpt_length')) {
2689
+            $length = get_query_var('excerpt_length');
2690
+    }
2648 2691
 
2649
-    if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit'))
2650
-        $length = get_option('geodir_author_desc_word_limit');
2692
+    if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit')) {
2693
+            $length = get_option('geodir_author_desc_word_limit');
2694
+    }
2651 2695
 
2652 2696
     return $length;
2653 2697
 }
@@ -2780,10 +2824,11 @@  discard block
 block discarded – undo
2780 2824
 function geodir_lisiting_belong_to_user($listing_id, $user_id)
2781 2825
 {
2782 2826
     $listing_author_id = geodir_get_listing_author($listing_id);
2783
-    if ($listing_author_id == $user_id)
2784
-        return true;
2785
-    else
2786
-        return false;
2827
+    if ($listing_author_id == $user_id) {
2828
+            return true;
2829
+    } else {
2830
+            return false;
2831
+    }
2787 2832
 
2788 2833
 }
2789 2834
 
@@ -2832,10 +2877,11 @@  discard block
 block discarded – undo
2832 2877
     $pattern = '/-\d+x\d+\./';
2833 2878
     preg_match($pattern, $file, $matches, PREG_OFFSET_CAPTURE);
2834 2879
 
2835
-    if (empty($matches))
2836
-        return '';
2837
-    else
2838
-        return $file;
2880
+    if (empty($matches)) {
2881
+            return '';
2882
+    } else {
2883
+            return $file;
2884
+    }
2839 2885
 
2840 2886
 }
2841 2887
 
@@ -2920,8 +2966,9 @@  discard block
 block discarded – undo
2920 2966
     } else {
2921 2967
         //set_post_thumbnail($post_id,-1);
2922 2968
 
2923
-        if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete'))
2924
-            wp_delete_attachment($post_thumbnail_id);
2969
+        if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) {
2970
+                    wp_delete_attachment($post_thumbnail_id);
2971
+        }
2925 2972
 
2926 2973
     }
2927 2974
 }
@@ -3006,8 +3053,9 @@  discard block
 block discarded – undo
3006 3053
 
3007 3054
     global $wpdb;
3008 3055
 
3009
-    if ($listing_type == '')
3010
-        $listing_type = 'gd_place';
3056
+    if ($listing_type == '') {
3057
+            $listing_type = 'gd_place';
3058
+    }
3011 3059
 
3012 3060
     $fields_info = array();
3013 3061
 
@@ -3030,8 +3078,9 @@  discard block
 block discarded – undo
3030 3078
 
3031 3079
                 $fields_info[$prefix . 'address'] = $data->field_type;
3032 3080
 
3033
-                if (isset($extra_fields['show_zip']) && $extra_fields['show_zip'])
3034
-                    $fields_info[$prefix . 'zip'] = $data->field_type;
3081
+                if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
3082
+                                    $fields_info[$prefix . 'zip'] = $data->field_type;
3083
+                }
3035 3084
 
3036 3085
             } else {
3037 3086
 
Please login to merge, or discard this patch.
geodirectory-functions/custom_fields_functions.php 1 patch
Braces   +133 added lines, -92 removed lines patch added patch discarded remove patch
@@ -51,8 +51,9 @@  discard block
 block discarded – undo
51 51
         global $wpdb;
52 52
         $result = 0;// no rows affected
53 53
         if (!geodir_column_exist($db, $column)) {
54
-            if (!empty($db) && !empty($column))
55
-                $result = $wpdb->query("ALTER TABLE `$db` ADD `$column`  $column_attr");
54
+            if (!empty($db) && !empty($column)) {
55
+                            $result = $wpdb->query("ALTER TABLE `$db` ADD `$column`  $column_attr");
56
+            }
56 57
         }
57 58
         return $result;
58 59
     }
@@ -82,10 +83,11 @@  discard block
 block discarded – undo
82 83
 
83 84
     $default_query = '';
84 85
 
85
-    if ($default == 'default')
86
-        $default_query .= " and is_admin IN ('1') ";
87
-    elseif ($default == 'custom')
88
-        $default_query .= " and is_admin = '0' ";
86
+    if ($default == 'default') {
87
+            $default_query .= " and is_admin IN ('1') ";
88
+    } elseif ($default == 'custom') {
89
+            $default_query .= " and is_admin = '0' ";
90
+    }
89 91
 
90 92
     if ($fields_location == 'none') {
91 93
     } else{
@@ -239,10 +241,12 @@  discard block
 block discarded – undo
239 241
                 }
240 242
 
241 243
                 return $field_id;
242
-            } else
243
-                return 0;
244
-        } else
245
-            return 0;
244
+            } else {
245
+                            return 0;
246
+            }
247
+        } else {
248
+                    return 0;
249
+        }
246 250
     }
247 251
 }
248 252
 
@@ -350,7 +354,9 @@  discard block
 block discarded – undo
350 354
 
351 355
 
352 356
 
353
-            if ($post_type == '') $post_type = 'gd_place';
357
+            if ($post_type == '') {
358
+            	$post_type = 'gd_place';
359
+            }
354 360
 
355 361
 
356 362
             $detail_table = $plugin_prefix . $post_type . '_detail';
@@ -390,16 +396,17 @@  discard block
 block discarded – undo
390 396
             }
391 397
 
392 398
             $option_values = '';
393
-            if (isset($request_field['option_values']))
394
-                $option_values = $request_field['option_values'];
399
+            if (isset($request_field['option_values'])) {
400
+                            $option_values = $request_field['option_values'];
401
+            }
395 402
 
396 403
             $cat_sort = isset($request_field['cat_sort']) ? $request_field['cat_sort'] : '0';
397 404
 
398 405
             $cat_filter = isset($request_field['cat_filter']) ? $request_field['cat_filter'] : '0';
399 406
 
400
-            if (isset($request_field['show_on_pkg']) && !empty($request_field['show_on_pkg']))
401
-                $price_pkg = implode(",", $request_field['show_on_pkg']);
402
-            else {
407
+            if (isset($request_field['show_on_pkg']) && !empty($request_field['show_on_pkg'])) {
408
+                            $price_pkg = implode(",", $request_field['show_on_pkg']);
409
+            } else {
403 410
                 $package_info = array();
404 411
 
405 412
                 $package_info = geodir_post_package_info($package_info, '', $post_type);
@@ -407,22 +414,29 @@  discard block
 block discarded – undo
407 414
             }
408 415
 
409 416
 
410
-            if (isset($request_field['extra']) && !empty($request_field['extra']))
411
-                $extra_fields = $request_field['extra'];
417
+            if (isset($request_field['extra']) && !empty($request_field['extra'])) {
418
+                            $extra_fields = $request_field['extra'];
419
+            }
412 420
 
413
-            if (isset($request_field['is_default']) && $request_field['is_default'] != '')
414
-                $is_default = $request_field['is_default'];
415
-            else
416
-                $is_default = '0';
421
+            if (isset($request_field['is_default']) && $request_field['is_default'] != '') {
422
+                            $is_default = $request_field['is_default'];
423
+            } else {
424
+                            $is_default = '0';
425
+            }
417 426
 
418
-            if (isset($request_field['is_admin']) && $request_field['is_admin'] != '')
419
-                $is_admin = $request_field['is_admin'];
420
-            else
421
-                $is_admin = '0';
427
+            if (isset($request_field['is_admin']) && $request_field['is_admin'] != '') {
428
+                            $is_admin = $request_field['is_admin'];
429
+            } else {
430
+                            $is_admin = '0';
431
+            }
422 432
 
423 433
 
424
-            if ($is_active == '') $is_active = 1;
425
-            if ($is_required == '') $is_required = 0;
434
+            if ($is_active == '') {
435
+            	$is_active = 1;
436
+            }
437
+            if ($is_required == '') {
438
+            	$is_required = 0;
439
+            }
426 440
 
427 441
 
428 442
             if ($sort_order == '') {
@@ -691,7 +705,7 @@  discard block
 block discarded – undo
691 705
                                 }
692 706
                                 if($op_max){$op_size =$op_max; }
693 707
                             }
694
-                        }elseif(isset($option_values) && $option_values && $field_type=='multiselect'){
708
+                        } elseif(isset($option_values) && $option_values && $field_type=='multiselect'){
695 709
                             if(strlen($option_values)){
696 710
                                 $op_size =  strlen($option_values);
697 711
                             }
@@ -708,11 +722,13 @@  discard block
 block discarded – undo
708 722
                             return __('Column change failed, you may have too many columns.','geodirectory');
709 723
                         }
710 724
 
711
-                        if (isset($request_field['cat_display_type']))
712
-                            $extra_fields = $request_field['cat_display_type'];
725
+                        if (isset($request_field['cat_display_type'])) {
726
+                                                    $extra_fields = $request_field['cat_display_type'];
727
+                        }
713 728
 
714
-                        if (isset($request_field['multi_display_type']))
715
-                            $extra_fields = $request_field['multi_display_type'];
729
+                        if (isset($request_field['multi_display_type'])) {
730
+                                                    $extra_fields = $request_field['multi_display_type'];
731
+                        }
716 732
 
717 733
 
718 734
                         break;
@@ -726,8 +742,9 @@  discard block
 block discarded – undo
726 742
                         if($alter_result===false){
727 743
                             return __('Column change failed, you may have too many columns.','geodirectory');
728 744
                         }
729
-                        if (isset($request_field['advanced_editor']))
730
-                            $extra_fields = $request_field['advanced_editor'];
745
+                        if (isset($request_field['advanced_editor'])) {
746
+                                                    $extra_fields = $request_field['advanced_editor'];
747
+                        }
731 748
 
732 749
                         break;
733 750
 
@@ -823,8 +840,9 @@  discard block
 block discarded – undo
823 840
                 );
824 841
 
825 842
 
826
-                if ($cat_sort == '')
827
-                    $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type = %s and htmlvar_name = %s", array($post_type, $htmlvar_name)));
843
+                if ($cat_sort == '') {
844
+                                    $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type = %s and htmlvar_name = %s", array($post_type, $htmlvar_name)));
845
+                }
828 846
 
829 847
 
830 848
                 /**
@@ -1194,8 +1212,10 @@  discard block
 block discarded – undo
1194 1212
         }
1195 1213
 
1196 1214
         return $post_meta_info;
1197
-    else:
1198
-        return false;
1215
+    else {
1216
+    	:
1217
+        return false;
1218
+    }
1199 1219
     endif;
1200 1220
 }
1201 1221
 
@@ -1272,8 +1292,9 @@  discard block
 block discarded – undo
1272 1292
         if (is_admin()) {
1273 1293
             global $post;
1274 1294
 
1275
-            if (isset($_REQUEST['post']))
1276
-                $_REQUEST['pid'] = $_REQUEST['post'];
1295
+            if (isset($_REQUEST['post'])) {
1296
+                            $_REQUEST['pid'] = $_REQUEST['post'];
1297
+            }
1277 1298
         }
1278 1299
 
1279 1300
         
@@ -1365,7 +1386,7 @@  discard block
 block discarded – undo
1365 1386
         $field_icon = ' background: url(' . $cf['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;';
1366 1387
     } elseif (strpos($cf['field_icon'], 'fa fa-') !== false) {
1367 1388
         $field_icon = '<i class="' . $cf['field_icon'] . '"></i>';
1368
-    }else{
1389
+    } else{
1369 1390
         $field_icon = $cf['field_icon'];
1370 1391
     }
1371 1392
 
@@ -1437,8 +1458,9 @@  discard block
 block discarded – undo
1437 1458
                     $variables_array['post_id'] = !empty($post->ID) ? $post->ID : (!empty($post->pid) ? $post->pid : NULL);
1438 1459
                     $variables_array['label'] = __($type['site_title'], 'geodirectory');
1439 1460
                     $variables_array['value'] = '';
1440
-                    if (isset($post->{$type['htmlvar_name']}))
1441
-                        $variables_array['value'] = $post->{$type['htmlvar_name']};
1461
+                    if (isset($post->{$type['htmlvar_name']})) {
1462
+                                            $variables_array['value'] = $post->{$type['htmlvar_name']};
1463
+                    }
1442 1464
                 endif;
1443 1465
 
1444 1466
 
@@ -1460,7 +1482,9 @@  discard block
 block discarded – undo
1460 1482
                      * @param string $html Custom field unfiltered HTML.
1461 1483
                      * @param array $variables_array Custom field variables array.
1462 1484
                      */
1463
-                    if ($html) echo apply_filters("geodir_show_{$html_var}", $html, $variables_array);
1485
+                    if ($html) {
1486
+                    	echo apply_filters("geodir_show_{$html_var}", $html, $variables_array);
1487
+                    }
1464 1488
 
1465 1489
                     /**
1466 1490
                      * Called after a custom fields is output on the frontend.
@@ -1503,10 +1527,11 @@  discard block
 block discarded – undo
1503 1527
      */
1504 1528
     function geodir_default_date_format()
1505 1529
     {
1506
-        if ($format = get_option('date_format'))
1507
-            return $format;
1508
-        else
1509
-            return 'dd-mm-yy';
1530
+        if ($format = get_option('date_format')) {
1531
+                    return $format;
1532
+        } else {
1533
+                    return 'dd-mm-yy';
1534
+        }
1510 1535
     }
1511 1536
 }
1512 1537
 
@@ -1613,11 +1638,13 @@  discard block
 block discarded – undo
1613 1638
                     // Set an array containing a list of acceptable formats
1614 1639
                     //$allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/octet-stream', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain');
1615 1640
 
1616
-                    if (!function_exists('wp_handle_upload'))
1617
-                        require_once(ABSPATH . 'wp-admin/includes/file.php');
1641
+                    if (!function_exists('wp_handle_upload')) {
1642
+                                            require_once(ABSPATH . 'wp-admin/includes/file.php');
1643
+                    }
1618 1644
 
1619
-                    if (!is_dir($geodir_uploadpath))
1620
-                        mkdir($geodir_uploadpath);
1645
+                    if (!is_dir($geodir_uploadpath)) {
1646
+                                            mkdir($geodir_uploadpath);
1647
+                    }
1621 1648
 
1622 1649
                     $new_name = $post_id . '_' . $field_id . '_' . $img_name_arr[0] . '.' . $img_name_arr[1];
1623 1650
                     $explode_sub_dir = explode("/", $sub_dir);
@@ -1630,16 +1657,19 @@  discard block
 block discarded – undo
1630 1657
                     }
1631 1658
 
1632 1659
                     $uploaded_file = '';
1633
-                    if (file_exists($img_path))
1634
-                        $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name);
1660
+                    if (file_exists($img_path)) {
1661
+                                            $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name);
1662
+                    }
1635 1663
 
1636 1664
                     if ($curr_img_dir != $geodir_uploaddir) {
1637
-                        if (file_exists($img_path))
1638
-                            unlink($img_path);
1665
+                        if (file_exists($img_path)) {
1666
+                                                    unlink($img_path);
1667
+                        }
1639 1668
                     }
1640 1669
 
1641
-                    if (!empty($uploaded_file))
1642
-                        $file_urls = $geodir_uploadurl . '/' . $new_name;
1670
+                    if (!empty($uploaded_file)) {
1671
+                                            $file_urls = $geodir_uploadurl . '/' . $new_name;
1672
+                    }
1643 1673
 
1644 1674
                 } else {
1645 1675
                     $file_urls = $post_image[$m];
@@ -1660,8 +1690,9 @@  discard block
 block discarded – undo
1660 1690
 
1661 1691
         geodir_save_post_meta($post_id, $field_id, $file_urls);
1662 1692
 
1663
-        if (!empty($invalid_files))
1664
-            geodir_remove_attachments($invalid_files);
1693
+        if (!empty($invalid_files)) {
1694
+                    geodir_remove_attachments($invalid_files);
1695
+        }
1665 1696
 
1666 1697
     }
1667 1698
 }
@@ -1887,8 +1918,9 @@  discard block
 block discarded – undo
1887 1918
 
1888 1919
         $all_postypes = geodir_get_posttypes();
1889 1920
 
1890
-        if (!in_array($post_type, $all_postypes))
1891
-            return false;
1921
+        if (!in_array($post_type, $all_postypes)) {
1922
+                    return false;
1923
+        }
1892 1924
 
1893 1925
         $fields = array();
1894 1926
 
@@ -1986,8 +2018,10 @@  discard block
 block discarded – undo
1986 2018
         }
1987 2019
 
1988 2020
         return $field_ids;
1989
-    else:
1990
-        return false;
2021
+    else {
2022
+    	:
2023
+        return false;
2024
+    }
1991 2025
     endif;
1992 2026
 }
1993 2027
 
@@ -2160,8 +2194,9 @@  discard block
 block discarded – undo
2160 2194
 
2161 2195
             return $field_id;
2162 2196
 
2163
-        } else
2164
-            return 0;
2197
+        } else {
2198
+                    return 0;
2199
+        }
2165 2200
 
2166 2201
     }
2167 2202
 }
@@ -2202,8 +2237,9 @@  discard block
 block discarded – undo
2202 2237
         $htmlvar_name = isset($field_type_key) ? $field_type_key : '';
2203 2238
 
2204 2239
         $site_title = '';
2205
-        if ($site_title == '')
2206
-            $site_title = isset($field_info->site_title) ? $field_info->site_title : '';
2240
+        if ($site_title == '') {
2241
+                    $site_title = isset($field_info->site_title) ? $field_info->site_title : '';
2242
+        }
2207 2243
 
2208 2244
         if ($site_title == '') {
2209 2245
             $fields = geodir_get_custom_sort_options($post_type);
@@ -2217,8 +2253,9 @@  discard block
 block discarded – undo
2217 2253
             }
2218 2254
         }
2219 2255
 
2220
-        if ($htmlvar_name == '')
2221
-            $htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : '';
2256
+        if ($htmlvar_name == '') {
2257
+                    $htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : '';
2258
+        }
2222 2259
 
2223 2260
         $nonce = wp_create_nonce('custom_fields_' . $result_str);
2224 2261
 
@@ -2231,7 +2268,7 @@  discard block
 block discarded – undo
2231 2268
 
2232 2269
                 if (isset($cso['field_icon']) && strpos($cso['field_icon'], 'fa fa-') !== false) {
2233 2270
                     $field_icon = '<i class="'.$cso['field_icon'].'" aria-hidden="true"></i>';
2234
-                }elseif(isset($cso['field_icon']) && $cso['field_icon']){
2271
+                } elseif(isset($cso['field_icon']) && $cso['field_icon']){
2235 2272
                     $field_icon = '<b style="background-image: url("'.$cso['field_icon'].'")"></b>';
2236 2273
                 }
2237 2274
 
@@ -2667,7 +2704,7 @@  discard block
 block discarded – undo
2667 2704
     $dt_value = '';
2668 2705
     if (isset($field_info->data_type)) {
2669 2706
         $dt_value  = esc_attr($field_info->data_type);
2670
-    }elseif(isset($cf['defaults']['data_type']) && $cf['defaults']['data_type']){
2707
+    } elseif(isset($cf['defaults']['data_type']) && $cf['defaults']['data_type']){
2671 2708
         $dt_value  = $cf['defaults']['data_type'];
2672 2709
     }
2673 2710
     ?>
@@ -2699,7 +2736,7 @@  discard block
 block discarded – undo
2699 2736
     $value = '';
2700 2737
     if (isset($field_info->decimal_point)) {
2701 2738
         $value = esc_attr($field_info->decimal_point);
2702
-    }elseif(isset($cf['defaults']['decimal_point']) && $cf['defaults']['decimal_point']){
2739
+    } elseif(isset($cf['defaults']['decimal_point']) && $cf['defaults']['decimal_point']){
2703 2740
         $value = $cf['defaults']['decimal_point'];
2704 2741
     }
2705 2742
     ?>
@@ -2771,11 +2808,13 @@  discard block
 block discarded – undo
2771 2808
 
2772 2809
             <?php
2773 2810
             $selected = '';
2774
-            if (isset($field_info->extra_fields))
2775
-                $advanced_editor = unserialize($field_info->extra_fields);
2811
+            if (isset($field_info->extra_fields)) {
2812
+                            $advanced_editor = unserialize($field_info->extra_fields);
2813
+            }
2776 2814
 
2777
-            if (!empty($advanced_editor) && is_array($advanced_editor) && in_array('1', $advanced_editor))
2778
-                $selected = 'checked="checked"';
2815
+            if (!empty($advanced_editor) && is_array($advanced_editor) && in_array('1', $advanced_editor)) {
2816
+                            $selected = 'checked="checked"';
2817
+            }
2779 2818
             ?>
2780 2819
 
2781 2820
             <input type="checkbox" name="advanced_editor[]" id="advanced_editor"
@@ -2797,7 +2836,7 @@  discard block
 block discarded – undo
2797 2836
     $value = '';
2798 2837
     if (isset($field_info->validation_pattern)) {
2799 2838
         $value = esc_attr($field_info->validation_pattern);
2800
-    }elseif(isset($cf['defaults']['validation_pattern']) && $cf['defaults']['validation_pattern']){
2839
+    } elseif(isset($cf['defaults']['validation_pattern']) && $cf['defaults']['validation_pattern']){
2801 2840
         $value = esc_attr($cf['defaults']['validation_pattern']);
2802 2841
     }
2803 2842
     ?>
@@ -2817,7 +2856,7 @@  discard block
 block discarded – undo
2817 2856
     $value = '';
2818 2857
     if (isset($field_info->validation_msg)) {
2819 2858
         $value = esc_attr($field_info->validation_msg);
2820
-    }elseif(isset($cf['defaults']['validation_msg']) && $cf['defaults']['validation_msg']){
2859
+    } elseif(isset($cf['defaults']['validation_msg']) && $cf['defaults']['validation_msg']){
2821 2860
         $value = esc_attr($cf['defaults']['validation_msg']);
2822 2861
     }
2823 2862
     ?>
@@ -2847,8 +2886,9 @@  discard block
 block discarded – undo
2847 2886
 
2848 2887
     if (!isset($field_info->post_type)) {
2849 2888
         $post_type = sanitize_text_field($_REQUEST['listing_type']);
2850
-    } else
2851
-        $post_type = $field_info->post_type;
2889
+    } else {
2890
+            $post_type = $field_info->post_type;
2891
+    }
2852 2892
     ?>
2853 2893
     <li style="display: none;">
2854 2894
         <label for="htmlvar_name" class="gd-cf-tooltip-wrap">
@@ -3122,7 +3162,7 @@  discard block
 block discarded – undo
3122 3162
     $value = '';
3123 3163
     if (isset($field_info->option_values)) {
3124 3164
         $value = esc_attr($field_info->option_values);
3125
-    }elseif(isset($cf['defaults']['option_values']) && $cf['defaults']['option_values']){
3165
+    } elseif(isset($cf['defaults']['option_values']) && $cf['defaults']['option_values']){
3126 3166
         $value = esc_attr($cf['defaults']['option_values']);
3127 3167
     }
3128 3168
 
@@ -3265,7 +3305,7 @@  discard block
 block discarded – undo
3265 3305
     $value = '';
3266 3306
     if ($extra_fields && isset($extra_fields['is_price'])) {
3267 3307
     $value = esc_attr($extra_fields['is_price']);
3268
-    }elseif(isset($cf['defaults']['extra_fields']['is_price']) && $cf['defaults']['extra_fields']['is_price']){
3308
+    } elseif(isset($cf['defaults']['extra_fields']['is_price']) && $cf['defaults']['extra_fields']['is_price']){
3269 3309
     $value = esc_attr($cf['defaults']['extra_fields']['is_price']);
3270 3310
     }
3271 3311
 
@@ -3302,7 +3342,7 @@  discard block
 block discarded – undo
3302 3342
     $value = '';
3303 3343
     if ($extra_fields && isset($extra_fields['thousand_separator'])) {
3304 3344
         $value = esc_attr($extra_fields['thousand_separator']);
3305
-    }elseif(isset($cf['defaults']['extra_fields']['thousand_separator']) && $cf['defaults']['extra_fields']['thousand_separator']){
3345
+    } elseif(isset($cf['defaults']['extra_fields']['thousand_separator']) && $cf['defaults']['extra_fields']['thousand_separator']){
3306 3346
         $value = esc_attr($cf['defaults']['extra_fields']['thousand_separator']);
3307 3347
     }
3308 3348
     ?>
@@ -3329,7 +3369,7 @@  discard block
 block discarded – undo
3329 3369
     $value = '';
3330 3370
     if ($extra_fields && isset($extra_fields['decimal_separator'])) {
3331 3371
         $value = esc_attr($extra_fields['decimal_separator']);
3332
-    }elseif(isset($cf['defaults']['extra_fields']['decimal_separator']) && $cf['defaults']['extra_fields']['decimal_separator']){
3372
+    } elseif(isset($cf['defaults']['extra_fields']['decimal_separator']) && $cf['defaults']['extra_fields']['decimal_separator']){
3333 3373
         $value = esc_attr($cf['defaults']['extra_fields']['decimal_separator']);
3334 3374
     }
3335 3375
     ?>
@@ -3352,7 +3392,7 @@  discard block
 block discarded – undo
3352 3392
     $value = '';
3353 3393
     if ($extra_fields && isset($extra_fields['decimal_display'])) {
3354 3394
         $value = esc_attr($extra_fields['decimal_display']);
3355
-    }elseif(isset($cf['defaults']['extra_fields']['decimal_display']) && $cf['defaults']['extra_fields']['decimal_display']){
3395
+    } elseif(isset($cf['defaults']['extra_fields']['decimal_display']) && $cf['defaults']['extra_fields']['decimal_display']){
3356 3396
         $value = esc_attr($cf['defaults']['extra_fields']['decimal_display']);
3357 3397
     }
3358 3398
     ?>
@@ -3375,7 +3415,7 @@  discard block
 block discarded – undo
3375 3415
     $value = '';
3376 3416
     if ($extra_fields && isset($extra_fields['currency_symbol'])) {
3377 3417
         $value = esc_attr($extra_fields['currency_symbol']);
3378
-    }elseif(isset($cf['defaults']['extra_fields']['currency_symbol']) && $cf['defaults']['extra_fields']['currency_symbol']){
3418
+    } elseif(isset($cf['defaults']['extra_fields']['currency_symbol']) && $cf['defaults']['extra_fields']['currency_symbol']){
3379 3419
         $value = esc_attr($cf['defaults']['extra_fields']['currency_symbol']);
3380 3420
     }
3381 3421
     ?>
@@ -3396,7 +3436,7 @@  discard block
 block discarded – undo
3396 3436
     $value = '';
3397 3437
     if ($extra_fields && isset($extra_fields['currency_symbol_placement'])) {
3398 3438
         $value = esc_attr($extra_fields['currency_symbol_placement']);
3399
-    }elseif(isset($cf['defaults']['extra_fields']['currency_symbol_placement']) && $cf['defaults']['extra_fields']['currency_symbol_placement']){
3439
+    } elseif(isset($cf['defaults']['extra_fields']['currency_symbol_placement']) && $cf['defaults']['extra_fields']['currency_symbol_placement']){
3400 3440
         $value = esc_attr($cf['defaults']['extra_fields']['currency_symbol_placement']);
3401 3441
     }
3402 3442
     ?>
@@ -3623,8 +3663,9 @@  discard block
 block discarded – undo
3623 3663
     $currency_symbol_placement = isset($cs['currency_symbol_placement']) ? $cs['currency_symbol_placement'] : 'left';
3624 3664
 
3625 3665
     if($decimals>0 && $decimal_display=='if'){
3626
-        if(is_int($number) || floor( $number ) == $number)
3627
-            $decimals = 0;
3666
+        if(is_int($number) || floor( $number ) == $number) {
3667
+                    $decimals = 0;
3668
+        }
3628 3669
     }
3629 3670
 
3630 3671
     $number = number_format($number,$decimals,$decimalpoint,$separator);
@@ -3633,7 +3674,7 @@  discard block
 block discarded – undo
3633 3674
 
3634 3675
     if($currency_symbol_placement=='left'){
3635 3676
         $number = $symbol . $number;
3636
-    }else{
3677
+    } else{
3637 3678
         $number = $number . $symbol;
3638 3679
     }
3639 3680
 
Please login to merge, or discard this patch.
geodirectory-functions/taxonomy_functions.php 1 patch
Braces   +170 added lines, -122 removed lines patch added patch discarded remove patch
@@ -39,8 +39,9 @@  discard block
 block discarded – undo
39 39
     if (get_option('geodir_show_listing_nav')) {
40 40
 
41 41
         $menu_class = '';
42
-        if (geodir_is_page('listing'))
43
-            $menu_class = 'current-menu-item';
42
+        if (geodir_is_page('listing')) {
43
+                    $menu_class = 'current-menu-item';
44
+        }
44 45
 
45 46
 
46 47
         //SHOW LISTING OF POST TYPE IN MAIN NAVIGATION
@@ -52,8 +53,9 @@  discard block
 block discarded – undo
52 53
                     if (in_array($post_type, $show_post_type_main_nav)) {
53 54
                         if (get_post_type_archive_link($post_type)) {
54 55
                             $menu_class = '';
55
-                            if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
56
-                                $menu_class = 'current-menu-item';
56
+                            if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing')) {
57
+                                                            $menu_class = 'current-menu-item';
58
+                            }
57 59
                             /**
58 60
                              * Filter the menu li class.
59 61
                              *
@@ -130,8 +132,9 @@  discard block
 block discarded – undo
130 132
                             if (get_post_type_archive_link($post_type)) {
131 133
 
132 134
                                 $menu_class = '';
133
-                                if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing'))
134
-                                    $menu_class = 'current-menu-item';
135
+                                if (geodir_get_current_posttype() == $post_type && geodir_is_page('listing')) {
136
+                                                                    $menu_class = 'current-menu-item';
137
+                                }
135 138
 
136 139
                                 $items .= '<li class="' . $sub_li_class . '">
137 140
 														<a href="' . get_post_type_archive_link($post_type) . '" class="' . $sub_a_class . '">
@@ -159,8 +162,9 @@  discard block
 block discarded – undo
159 162
     if (get_option('geodir_show_addlisting_nav')) {
160 163
 
161 164
         $menu_class = '';
162
-        if (geodir_is_page('add-listing'))
163
-            $menu_class = 'current-menu-item';
165
+        if (geodir_is_page('add-listing')) {
166
+                    $menu_class = 'current-menu-item';
167
+        }
164 168
 
165 169
         //SHOW ADD LISTING POST TYPE IN MAIN NAVIGATION
166 170
         $post_types = geodir_get_posttypes('object');
@@ -176,8 +180,9 @@  discard block
 block discarded – undo
176 180
                                 if (geodir_get_addlisting_link($post_type)) {
177 181
 
178 182
                                     $menu_class = '';
179
-                                    if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
180
-                                        $menu_class = 'current-menu-item';
183
+                                    if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing')) {
184
+                                                                            $menu_class = 'current-menu-item';
185
+                                    }
181 186
                                     /**
182 187
                                      * Filter the menu li class.
183 188
                                      *
@@ -261,8 +266,9 @@  discard block
 block discarded – undo
261 266
                                     if (geodir_get_addlisting_link($post_type)) {
262 267
 
263 268
                                         $menu_class = '';
264
-                                        if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing'))
265
-                                            $menu_class = 'current-menu-item';
269
+                                        if (geodir_get_current_posttype() == $post_type && geodir_is_page('add-listing')) {
270
+                                                                                    $menu_class = 'current-menu-item';
271
+                                        }
266 272
                                         /**
267 273
                                          * Filter the menu li class.
268 274
                                          *
@@ -319,8 +325,9 @@  discard block
 block discarded – undo
319 325
     }
320 326
     //else if(empty($geodir_theme_location)) // It means 'Show geodirectory navigation in selected menu locations' is not set yet.
321 327
 //		$menu = str_replace("</ul></div>",geodir_add_nav_menu_items()."</ul></div>",$menu);
322
-    else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location))
323
-        $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
328
+    else if (is_array($geodir_theme_location) && isset($args['theme_location']) && in_array($args['theme_location'], $geodir_theme_location)) {
329
+            $menu = str_replace("</ul></div>", geodir_add_nav_menu_items() . "</ul></div>", $menu);
330
+    }
324 331
 
325 332
     return $menu;
326 333
 
@@ -407,17 +414,20 @@  discard block
 block discarded – undo
407 414
     $geodir_post_type = get_query_var('post_type');
408 415
 
409 416
     if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
410
-        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
411
-            $geodir_post_type = get_post_type((int)$_REQUEST['pid']);
412
-        elseif (isset($_REQUEST['listing_type']))
413
-            $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']);
417
+        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
418
+                    $geodir_post_type = get_post_type((int)$_REQUEST['pid']);
419
+        } elseif (isset($_REQUEST['listing_type'])) {
420
+                    $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']);
421
+        }
414 422
     }
415 423
 
416
-    if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype']))
417
-        $geodir_post_type = sanitize_text_field($_REQUEST['stype']);
424
+    if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype'])) {
425
+            $geodir_post_type = sanitize_text_field($_REQUEST['stype']);
426
+    }
418 427
 
419
-    if (is_tax())
420
-        $geodir_post_type = geodir_get_taxonomy_posttype();
428
+    if (is_tax()) {
429
+            $geodir_post_type = geodir_get_taxonomy_posttype();
430
+    }
421 431
 
422 432
     // Retrive post type for map marker html ajax request on preview page.
423 433
     if (empty($geodir_post_type) && defined('DOING_AJAX') && !empty($post)) {
@@ -431,8 +441,9 @@  discard block
 block discarded – undo
431 441
     $all_postypes = geodir_get_posttypes();
432 442
     $all_postypes = stripslashes_deep($all_postypes);
433 443
 
434
-    if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes))
435
-        $geodir_post_type = '';
444
+    if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes)) {
445
+            $geodir_post_type = '';
446
+    }
436 447
 
437 448
     if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){
438 449
         $geodir_post_type = sanitize_text_field($_REQUEST['stype']);
@@ -517,11 +528,12 @@  discard block
 block discarded – undo
517 528
         endswitch;
518 529
     }
519 530
 
520
-    if (!empty($post_types))
521
-        return $post_types;
522
-    else
523
-        return array();
524
-}
531
+    if (!empty($post_types)) {
532
+            return $post_types;
533
+    } else {
534
+            return array();
535
+    }
536
+    }
525 537
 
526 538
 /**
527 539
  * Get Custom Post Type info.
@@ -538,9 +550,10 @@  discard block
 block discarded – undo
538 550
     $post_types = stripslashes_deep($post_types);
539 551
     if (!empty($post_types) && $post_type != '') {
540 552
         return $post_types[$post_type];
541
-    } else
542
-        return false;
543
-}
553
+    } else {
554
+            return false;
555
+    }
556
+    }
544 557
 
545 558
 if (!function_exists('geodir_get_taxonomies')) {
546 559
     /**
@@ -564,18 +577,21 @@  discard block
 block discarded – undo
564 577
             $gd_taxonomies = array_keys($taxonomies);
565 578
 
566 579
 
567
-            if ($post_type != '')
568
-                $gd_taxonomies = array();
580
+            if ($post_type != '') {
581
+                            $gd_taxonomies = array();
582
+            }
569 583
 
570 584
             $i = 0;
571 585
             foreach ($taxonomies as $taxonomy => $args) {
572 586
 
573
-                if ($post_type != '' && $args['object_type'] == $post_type)
574
-                    $gd_taxonomies[] = $taxonomy;
587
+                if ($post_type != '' && $args['object_type'] == $post_type) {
588
+                                    $gd_taxonomies[] = $taxonomy;
589
+                }
575 590
 
576 591
                 if ($tages_taxonomies === false && strpos($taxonomy, '_tag') !== false) {
577
-                    if (array_search($taxonomy, $gd_taxonomies) !== false)
578
-                        unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]);
592
+                    if (array_search($taxonomy, $gd_taxonomies) !== false) {
593
+                                            unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]);
594
+                    }
579 595
                 }
580 596
 
581 597
             }
@@ -630,10 +646,11 @@  discard block
 block discarded – undo
630 646
                 . geodir_utf8_ucfirst($category_obj->name) . '</option>';
631 647
         }
632 648
 
633
-        if ($echo)
634
-            echo $html;
635
-        else
636
-            return $html;
649
+        if ($echo) {
650
+                    echo $html;
651
+        } else {
652
+                    return $html;
653
+        }
637 654
     }
638 655
 }
639 656
 
@@ -667,11 +684,12 @@  discard block
 block discarded – undo
667 684
 
668 685
     }
669 686
 
670
-    if (!empty($listing_slug))
671
-        return $listing_slug;
672
-    else
673
-        return false;
674
-}
687
+    if (!empty($listing_slug)) {
688
+            return $listing_slug;
689
+    } else {
690
+            return false;
691
+    }
692
+    }
675 693
 
676 694
 
677 695
 /**
@@ -702,16 +720,18 @@  discard block
 block discarded – undo
702 720
     if (!empty($taxonomies)) {
703 721
         foreach (geodir_get_posttypes() as $pt) {
704 722
             $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt);
705
-            if (array_intersect($taxonomies, $object_taxonomies))
706
-                $post_type[] = $pt;
723
+            if (array_intersect($taxonomies, $object_taxonomies)) {
724
+                            $post_type[] = $pt;
725
+            }
707 726
         }
708 727
     }
709 728
 
710
-    if (!empty($post_type))
711
-        return $post_type[0];
712
-    else
713
-        return false;
714
-}
729
+    if (!empty($post_type)) {
730
+            return $post_type[0];
731
+    } else {
732
+            return false;
733
+    }
734
+    }
715 735
 
716 736
 if (!function_exists('geodir_custom_taxonomy_walker')) {
717 737
     /**
@@ -767,18 +787,18 @@  discard block
 block discarded – undo
767 787
                 $checked = '';
768 788
 
769 789
                 if (in_array($cat_term->term_id, $search_terms)) {
770
-                    if ($cat_display == 'select' || $cat_display == 'multiselect')
771
-                        $checked = 'selected="selected"';
772
-                    else
773
-                        $checked = 'checked="checked"';
790
+                    if ($cat_display == 'select' || $cat_display == 'multiselect') {
791
+                                            $checked = 'selected="selected"';
792
+                    } else {
793
+                                            $checked = 'checked="checked"';
794
+                    }
774 795
                 }
775 796
 
776
-                if ($cat_display == 'radio')
777
-                    $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
778
-                elseif ($cat_display == 'select' || $cat_display == 'multiselect')
779
-                    $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>';
780
-
781
-                else {
797
+                if ($cat_display == 'radio') {
798
+                                    $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
799
+                } elseif ($cat_display == 'select' || $cat_display == 'multiselect') {
800
+                                    $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>';
801
+                } else {
782 802
                     $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>';
783 803
                 }
784 804
 
@@ -787,8 +807,9 @@  discard block
 block discarded – undo
787 807
 
788 808
             }
789 809
 
790
-            if ($cat_display == 'checkbox' || $cat_display == 'radio')
791
-                $out .= '</div>';
810
+            if ($cat_display == 'checkbox' || $cat_display == 'radio') {
811
+                            $out .= '</div>';
812
+            }
792 813
 
793 814
             return $out;
794 815
         }
@@ -814,18 +835,21 @@  discard block
 block discarded – undo
814 835
         global $exclude_cats, $gd_session;
815 836
 
816 837
         $cat_exclude = '';
817
-        if (is_array($exclude_cats) && !empty($exclude_cats))
818
-            $cat_exclude = serialize($exclude_cats);
838
+        if (is_array($exclude_cats) && !empty($exclude_cats)) {
839
+                    $cat_exclude = serialize($exclude_cats);
840
+        }
819 841
 
820 842
         if (isset($_REQUEST['backandedit'])) {
821 843
             $post = (object)$gd_session->get('listing');
822 844
 
823
-            if (!is_array($post->post_category[$cat_taxonomy]))
824
-                $post_category = $post->post_category[$cat_taxonomy];
845
+            if (!is_array($post->post_category[$cat_taxonomy])) {
846
+                            $post_category = $post->post_category[$cat_taxonomy];
847
+            }
825 848
 
826 849
             $post_categories = $post->post_category_str;
827
-            if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories))
828
-                $post_category_str = $post_categories[$cat_taxonomy];
850
+            if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
851
+                            $post_category_str = $post_categories[$cat_taxonomy];
852
+            }
829 853
 
830 854
         } elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) {
831 855
             global $post;
@@ -1016,8 +1040,9 @@  discard block
 block discarded – undo
1016 1040
         if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
1017 1041
             $post_cat_str = $post_categories[$cat_taxonomy];
1018 1042
             $post_cat_array = explode("#", $post_cat_str);
1019
-            if (count($post_cat_array) >= $cat_limit && $cat_limit != 0)
1020
-                $style = "display:none;";
1043
+            if (count($post_cat_array) >= $cat_limit && $cat_limit != 0) {
1044
+                            $style = "display:none;";
1045
+            }
1021 1046
         }
1022 1047
         ?>
1023 1048
         <div class="main_cat_list" style=" <?php if (isset($style)) {
@@ -1052,7 +1077,7 @@  discard block
 block discarded – undo
1052 1077
 
1053 1078
         if(is_array( $exclude_cats)){
1054 1079
             $exclude_cats = array_map( 'intval', $exclude_cats );
1055
-        }else{
1080
+        } else{
1056 1081
             $exclude_cats = intval($exclude_cats);
1057 1082
         }
1058 1083
 
@@ -1082,7 +1107,10 @@  discard block
 block discarded – undo
1082 1107
 
1083 1108
             <div class="post_default_category">
1084 1109
                 <input type="radio" name="post_default_category" value="<?php echo $main_cat->term_id;?>"
1085
-                       onchange="update_listing_cat()" <?php if ($default) echo ' checked="checked" ';?>   />
1110
+                       onchange="update_listing_cat()" <?php if ($default) {
1111
+	echo ' checked="checked" ';
1112
+}
1113
+?>   />
1086 1114
         <span> 
1087 1115
         <?php printf(__('Set %s as default category', 'geodirectory'), geodir_ucwords($main_cat->name));?>
1088 1116
         </span>
@@ -1182,8 +1210,9 @@  discard block
 block discarded – undo
1182 1210
         $onchange = ' onchange="show_subcatlist(this.value, this)" ';
1183 1211
 
1184 1212
         $option_selected = '';
1185
-        if (!$selected)
1186
-            $option_slected = ' selected="selected" ';
1213
+        if (!$selected) {
1214
+                    $option_slected = ' selected="selected" ';
1215
+        }
1187 1216
 
1188 1217
         echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >';
1189 1218
 
@@ -1191,8 +1220,9 @@  discard block
 block discarded – undo
1191 1220
 
1192 1221
         foreach ($cat_terms as $cat_term) {
1193 1222
             $option_selected = '';
1194
-            if ($selected == $cat_term->term_id)
1195
-                $option_selected = ' selected="selected" ';
1223
+            if ($selected == $cat_term->term_id) {
1224
+                            $option_selected = ' selected="selected" ';
1225
+            }
1196 1226
 
1197 1227
             // Count child terms
1198 1228
             $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) );
@@ -1257,8 +1287,9 @@  discard block
 block discarded – undo
1257 1287
 
1258 1288
     $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico';
1259 1289
 
1260
-    if (!$listing_slug = get_option('geodir_listing_prefix'))
1261
-        $listing_slug = 'places';
1290
+    if (!$listing_slug = get_option('geodir_listing_prefix')) {
1291
+            $listing_slug = 'places';
1292
+    }
1262 1293
 
1263 1294
     /**
1264 1295
      * Taxonomies
@@ -1570,8 +1601,9 @@  discard block
 block discarded – undo
1570 1601
                             'city_slug' => $post->city_slug
1571 1602
                         );
1572 1603
 
1573
-                    } else
1574
-                        $post_location = geodir_get_location();
1604
+                    } else {
1605
+                                            $post_location = geodir_get_location();
1606
+                    }
1575 1607
 
1576 1608
 
1577 1609
                 } else {
@@ -1600,8 +1632,9 @@  discard block
 block discarded – undo
1600 1632
                             );
1601 1633
 
1602 1634
                         }
1603
-                    } else
1604
-                        $post_location = geodir_get_location();
1635
+                    } else {
1636
+                                            $post_location = geodir_get_location();
1637
+                    }
1605 1638
                 }
1606 1639
 
1607 1640
 
@@ -1641,16 +1674,17 @@  discard block
 block discarded – undo
1641 1674
 
1642 1675
                     if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
1643 1676
                         $post_terms = absint($_POST['post_default_category']);
1644
-                    }elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
1677
+                    } elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
1645 1678
                         $post_terms = is_array($_POST['post_category'][$taxonomies]) ? $_POST['post_category'][$taxonomies] : explode(",", trim($_POST['post_category'][$taxonomies], ","));
1646 1679
                         $post_terms = !empty($post_terms) ? absint($post_terms[0]) : 0;
1647
-                    }elseif (isset($post->{$taxonomies})) {
1680
+                    } elseif (isset($post->{$taxonomies})) {
1648 1681
                         $post_terms = explode(",", trim($post->{$taxonomies}, ","));
1649 1682
                         $post_terms = $post_terms[0];
1650 1683
                     }
1651 1684
 
1652
-                    if (!$post_terms)
1653
-                        $post_terms = geodir_get_post_meta($post->ID, 'default_category', true);
1685
+                    if (!$post_terms) {
1686
+                                            $post_terms = geodir_get_post_meta($post->ID, 'default_category', true);
1687
+                    }
1654 1688
 
1655 1689
                     if (!$post_terms) {
1656 1690
                         $post_terms = geodir_get_post_meta($post->ID, $taxonomies, true);
@@ -1664,8 +1698,9 @@  discard block
 block discarded – undo
1664 1698
 
1665 1699
                 $term = get_term_by('id', $post_terms, $taxonomies);
1666 1700
 
1667
-                if (!empty($term))
1668
-                    $term_request = $term->slug;
1701
+                if (!empty($term)) {
1702
+                                    $term_request = $term->slug;
1703
+                }
1669 1704
                 //$term_request = $term->slug.'/';
1670 1705
             }
1671 1706
 
@@ -1680,9 +1715,13 @@  discard block
 block discarded – undo
1680 1715
                 $request_term .= $term_request;
1681 1716
 
1682 1717
             } else {
1683
-                if (isset($location_request) && $location_request != '') $request_term = $location_request;
1718
+                if (isset($location_request) && $location_request != '') {
1719
+                	$request_term = $location_request;
1720
+                }
1684 1721
 
1685
-                if (isset($term_request) && $term_request != '') $request_term .= $term_request;
1722
+                if (isset($term_request) && $term_request != '') {
1723
+                	$request_term .= $term_request;
1724
+                }
1686 1725
             }
1687 1726
             $request_term = trim($request_term, '/');
1688 1727
             
@@ -1691,10 +1730,11 @@  discard block
 block discarded – undo
1691 1730
                 $post_link = str_replace('%gd_taxonomy%/', '', $post_link);
1692 1731
             }
1693 1732
             
1694
-            if (!empty($request_term))
1695
-                $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1696
-            else
1697
-                $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1733
+            if (!empty($request_term)) {
1734
+                            $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1735
+            } else {
1736
+                            $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1737
+            }
1698 1738
             //echo $post_link ;
1699 1739
         }
1700 1740
         // temp cache the permalink
@@ -1886,11 +1926,12 @@  discard block
 block discarded – undo
1886 1926
     
1887 1927
     $label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name;
1888 1928
     
1889
-    if ($echo)
1890
-        echo $label;
1891
-    else
1892
-        return $label;
1893
-}
1929
+    if ($echo) {
1930
+            echo $label;
1931
+    } else {
1932
+            return $label;
1933
+    }
1934
+    }
1894 1935
 
1895 1936
 /**
1896 1937
  * Print or Get post type plural label.
@@ -1906,18 +1947,20 @@  discard block
 block discarded – undo
1906 1947
 function get_post_type_plural_label($post_type, $echo = false, $translate = false) {
1907 1948
     $all_postypes = geodir_get_posttypes();
1908 1949
 
1909
-    if (!in_array($post_type, $all_postypes))
1910
-        return false;
1950
+    if (!in_array($post_type, $all_postypes)) {
1951
+            return false;
1952
+    }
1911 1953
 
1912 1954
     $obj_post_type = get_post_type_object($post_type);
1913 1955
     
1914 1956
     $label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name;
1915 1957
     
1916
-    if ($echo)
1917
-        echo $label;
1918
-    else
1919
-        return $label;
1920
-}
1958
+    if ($echo) {
1959
+            echo $label;
1960
+    } else {
1961
+            return $label;
1962
+    }
1963
+    }
1921 1964
 
1922 1965
 /**
1923 1966
  * Checks whether a term exists or not.
@@ -1940,19 +1983,22 @@  discard block
 block discarded – undo
1940 1983
     $tax_select = "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE ";
1941 1984
 
1942 1985
     if (is_int($term)) {
1943
-        if (0 == $term)
1944
-            return 0;
1986
+        if (0 == $term) {
1987
+                    return 0;
1988
+        }
1945 1989
         $where = 't.term_id = %d';
1946
-        if (!empty($taxonomy))
1947
-            return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1948
-        else
1949
-            return $wpdb->get_var($wpdb->prepare($select . $where, $term));
1990
+        if (!empty($taxonomy)) {
1991
+                    return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1992
+        } else {
1993
+                    return $wpdb->get_var($wpdb->prepare($select . $where, $term));
1994
+        }
1950 1995
     }
1951 1996
 
1952 1997
     $term = trim(wp_unslash($term));
1953 1998
 
1954
-    if ('' === $slug = sanitize_title($term))
1955
-        return 0;
1999
+    if ('' === $slug = sanitize_title($term)) {
2000
+            return 0;
2001
+    }
1956 2002
 
1957 2003
     $where = 't.slug = %s';
1958 2004
 
@@ -1969,14 +2015,16 @@  discard block
 block discarded – undo
1969 2015
         $where_fields[] = $taxonomy;
1970 2016
 
1971 2017
 
1972
-        if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A))
1973
-            return $result;
2018
+        if ($result = $wpdb->get_row($wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $where_fields), ARRAY_A)) {
2019
+                    return $result;
2020
+        }
1974 2021
 
1975 2022
         return false;
1976 2023
     }
1977 2024
 
1978
-    if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields)))
1979
-        return $result;
2025
+    if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields))) {
2026
+            return $result;
2027
+    }
1980 2028
 
1981 2029
     return false;
1982 2030
 }
Please login to merge, or discard this patch.