Test Failed
Push — master ( d370ce...8c40b8 )
by Stiofan
21:04
created
geodirectory-functions/post_functions.php 1 patch
Braces   +173 added lines, -122 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
@@ -1379,9 +1400,9 @@  discard block
 block discarded – undo
1379 1400
                 $default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1380 1401
             }
1381 1402
 
1382
-            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1383
-                $default_img = $default_catimg['src'];
1384
-            elseif ($no_image) {
1403
+            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) {
1404
+                            $default_img = $default_catimg['src'];
1405
+            } elseif ($no_image) {
1385 1406
                 $default_img = get_option('geodir_listing_no_img');
1386 1407
             }
1387 1408
 
@@ -1413,10 +1434,13 @@  discard block
 block discarded – undo
1413 1434
             }
1414 1435
         }
1415 1436
 
1416
-        if (!empty($img_arr))
1417
-            return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path );
1418
-        else
1419
-            return false;
1437
+        if (!empty($img_arr)) {
1438
+                    return (object)$img_arr;
1439
+        }
1440
+        //return (object)array( 'src' => $file_url, 'path' => $file_path );
1441
+        else {
1442
+                    return false;
1443
+        }
1420 1444
     }
1421 1445
 }
1422 1446
 
@@ -1443,8 +1467,9 @@  discard block
 block discarded – undo
1443 1467
             echo $html;
1444 1468
         } elseif (!empty($html)) {
1445 1469
             return $html;
1446
-        } else
1447
-            return false;
1470
+        } else {
1471
+                    return false;
1472
+        }
1448 1473
     }
1449 1474
 }
1450 1475
 
@@ -1472,8 +1497,9 @@  discard block
 block discarded – undo
1472 1497
         }
1473 1498
         $not_featured = '';
1474 1499
         $sub_dir = '';
1475
-        if (!$add_featured)
1476
-            $not_featured = " AND is_featured = 0 ";
1500
+        if (!$add_featured) {
1501
+                    $not_featured = " AND is_featured = 0 ";
1502
+        }
1477 1503
 
1478 1504
         $arrImages = $wpdb->get_results(
1479 1505
             $wpdb->prepare(
@@ -1494,8 +1520,9 @@  discard block
 block discarded – undo
1494 1520
 
1495 1521
                 $file_info = pathinfo($attechment->file);
1496 1522
 
1497
-                if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
1498
-                    $sub_dir = stripslashes_deep($file_info['dirname']);
1523
+                if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') {
1524
+                                    $sub_dir = stripslashes_deep($file_info['dirname']);
1525
+                }
1499 1526
 
1500 1527
                 $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1501 1528
                 $uploads_baseurl = $uploads['baseurl'];
@@ -1547,9 +1574,9 @@  discard block
 block discarded – undo
1547 1574
             $default_img = '';
1548 1575
             $default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1549 1576
             $post_type = get_post_type($post_id);
1550
-            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1551
-                $default_img = $default_catimg['src'];
1552
-            elseif ($no_images) {
1577
+            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) {
1578
+                            $default_img = $default_catimg['src'];
1579
+            } elseif ($no_images) {
1553 1580
                 $default_img = get_option('geodir_listing_no_img');
1554 1581
             }
1555 1582
 
@@ -1590,8 +1617,9 @@  discard block
 block discarded – undo
1590 1617
                  * @param array $return_arr The array of image objects.
1591 1618
                  */
1592 1619
                 return apply_filters('geodir_get_images_arr',$return_arr);
1593
-            } else
1594
-                return false;
1620
+            } else {
1621
+                            return false;
1622
+            }
1595 1623
         }
1596 1624
     }
1597 1625
 }
@@ -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 . '\');" title="'.$image->title.'" aria-label="'.$image->title.'" ></div>';
1666
-                    }else{
1695
+                    } else{
1667 1696
                         $html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" title="'.$image->title.'" aria-label="'.$image->title.'"></div>';
1668 1697
                     }
1669 1698
 
@@ -1675,8 +1704,9 @@  discard block
 block discarded – undo
1675 1704
             echo $html;
1676 1705
         } elseif (!empty($html)) {
1677 1706
             return $html;
1678
-        } else
1679
-            return false;
1707
+        } else {
1708
+                    return false;
1709
+        }
1680 1710
     }
1681 1711
 }
1682 1712
 
@@ -1714,8 +1744,9 @@  discard block
 block discarded – undo
1714 1744
                 $post_obj = get_post($post_id);
1715 1745
 
1716 1746
                 $cat_ids = array('0');
1717
-                if (is_array($tt_ids))
1718
-                    $cat_ids = $tt_ids;
1747
+                if (is_array($tt_ids)) {
1748
+                                    $cat_ids = $tt_ids;
1749
+                }
1719 1750
 
1720 1751
 
1721 1752
                 if (!empty($cat_ids)) {
@@ -1772,8 +1803,9 @@  discard block
 block discarded – undo
1772 1803
                         $json .= '}';
1773 1804
 
1774 1805
 
1775
-                        if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true))
1776
-                            $post_marker_json = $json;
1806
+                        if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true)) {
1807
+                                                    $post_marker_json = $json;
1808
+                        }
1777 1809
 
1778 1810
 
1779 1811
                         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)))) {
@@ -1804,10 +1836,13 @@  discard block
 block discarded – undo
1804 1836
                 if (!empty($post_term) && is_array($post_term)) {
1805 1837
                     $categories = implode(',', $post_term);
1806 1838
 
1807
-                    if ($categories != '' && $categories != 0) $categories = ',' . $categories . ',';
1839
+                    if ($categories != '' && $categories != 0) {
1840
+                    	$categories = ',' . $categories . ',';
1841
+                    }
1808 1842
 
1809
-                    if (empty($post_marker_json))
1810
-                        $post_marker_json = isset($json) ? $json : '';
1843
+                    if (empty($post_marker_json)) {
1844
+                                            $post_marker_json = isset($json) ? $json : '';
1845
+                    }
1811 1846
 
1812 1847
                     if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
1813 1848
 
@@ -1846,8 +1881,9 @@  discard block
 block discarded – undo
1846 1881
 
1847 1882
                                 }
1848 1883
 
1849
-                                if ($default_category == '')
1850
-                                    $default_category = $categories[0];
1884
+                                if ($default_category == '') {
1885
+                                                                    $default_category = $categories[0];
1886
+                                }
1851 1887
 
1852 1888
                                 geodir_set_postcat_structure($post_id, $taxonomy, $default_category, '');
1853 1889
 
@@ -1994,7 +2030,7 @@  discard block
 block discarded – undo
1994 2030
                                     } ?>"><img alt="bubble image" style="max-height:50px;"
1995 2031
                                                src="<?php echo $post_images[0]; ?>"/></a></div>
1996 2032
                             <?php
1997
-                            }else{
2033
+                            } else{
1998 2034
                                 echo '<div class="geodir-bubble_image"></div>';
1999 2035
                             }
2000 2036
                         } else {
@@ -2002,7 +2038,7 @@  discard block
 block discarded – undo
2002 2038
                                 ?>
2003 2039
                                 <div class="geodir-bubble_image"><a href="<?php echo $plink; ?>"><?php echo $image; ?></a></div>
2004 2040
                             <?php
2005
-                            }else{
2041
+                            } else{
2006 2042
                                 echo '<div class="geodir-bubble_image"></div>';
2007 2043
                             }
2008 2044
                         }
@@ -2083,10 +2119,11 @@  discard block
 block discarded – undo
2083 2119
      */
2084 2120
     function geodir_new_post_default_status()
2085 2121
     {
2086
-        if (get_option('geodir_new_post_default_status'))
2087
-            return get_option('geodir_new_post_default_status');
2088
-        else
2089
-            return 'publish';
2122
+        if (get_option('geodir_new_post_default_status')) {
2123
+                    return get_option('geodir_new_post_default_status');
2124
+        } else {
2125
+                    return 'publish';
2126
+        }
2090 2127
 
2091 2128
     }
2092 2129
 }
@@ -2237,8 +2274,9 @@  discard block
 block discarded – undo
2237 2274
 
2238 2275
         $all_postypes = geodir_get_posttypes();
2239 2276
 
2240
-        if (!in_array($post_type, $all_postypes))
2241
-            return false;
2277
+        if (!in_array($post_type, $all_postypes)) {
2278
+                    return false;
2279
+        }
2242 2280
 
2243 2281
         $table = $plugin_prefix . $post_type . '_detail';
2244 2282
 
@@ -2506,8 +2544,9 @@  discard block
 block discarded – undo
2506 2544
         $unfavourite_icon = apply_filters('geodir_unfavourite_icon', 'fa fa-heart');
2507 2545
 
2508 2546
         $user_meta_data = '';
2509
-        if (isset($current_user->data->ID))
2510
-            $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2547
+        if (isset($current_user->data->ID)) {
2548
+                    $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2549
+        }
2511 2550
 
2512 2551
         if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
2513 2552
             ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"  ><a
@@ -2520,8 +2559,9 @@  discard block
 block discarded – undo
2520 2559
 
2521 2560
             if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
2522 2561
                 $script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\'';
2523
-            } else
2524
-                $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
2562
+            } else {
2563
+                            $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
2564
+            }
2525 2565
 
2526 2566
             ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon"
2527 2567
                                                                                         href="javascript:void(0);"
@@ -2584,14 +2624,16 @@  discard block
 block discarded – undo
2584 2624
 							WHERE pd.post_status='publish' AND FIND_IN_SET('" . $term->term_id . "'," . $term->taxonomy . ") " . $where;
2585 2625
 
2586 2626
             $cat_post_count = $wpdb->get_var($count_query);
2587
-            if (empty($cat_post_count) || is_wp_error($cat_post_count))
2588
-                $cat_post_count = 0;
2627
+            if (empty($cat_post_count) || is_wp_error($cat_post_count)) {
2628
+                            $cat_post_count = 0;
2629
+            }
2589 2630
 
2590 2631
             return $cat_post_count;
2591 2632
 
2592
-        } else
2593
-
2594
-            return $term->count;
2633
+        } else {
2634
+        
2635
+            return $term->count;
2636
+        }
2595 2637
     }
2596 2638
     return false;
2597 2639
 
@@ -2638,13 +2680,15 @@  discard block
 block discarded – undo
2638 2680
 		return $length;
2639 2681
 	}
2640 2682
 	
2641
-    if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit'))
2642
-        $length = get_option('geodir_desc_word_limit');
2643
-    elseif (get_query_var('excerpt_length'))
2644
-        $length = get_query_var('excerpt_length');
2683
+    if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit')) {
2684
+            $length = get_option('geodir_desc_word_limit');
2685
+    } elseif (get_query_var('excerpt_length')) {
2686
+            $length = get_query_var('excerpt_length');
2687
+    }
2645 2688
 
2646
-    if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit'))
2647
-        $length = get_option('geodir_author_desc_word_limit');
2689
+    if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit')) {
2690
+            $length = get_option('geodir_author_desc_word_limit');
2691
+    }
2648 2692
 
2649 2693
     return $length;
2650 2694
 }
@@ -2785,10 +2829,11 @@  discard block
 block discarded – undo
2785 2829
 function geodir_lisiting_belong_to_user($listing_id, $user_id)
2786 2830
 {
2787 2831
     $listing_author_id = geodir_get_listing_author($listing_id);
2788
-    if ($listing_author_id == $user_id)
2789
-        return true;
2790
-    else
2791
-        return false;
2832
+    if ($listing_author_id == $user_id) {
2833
+            return true;
2834
+    } else {
2835
+            return false;
2836
+    }
2792 2837
 
2793 2838
 }
2794 2839
 
@@ -2837,10 +2882,11 @@  discard block
 block discarded – undo
2837 2882
     $pattern = '/-\d+x\d+\./';
2838 2883
     preg_match($pattern, $file, $matches, PREG_OFFSET_CAPTURE);
2839 2884
 
2840
-    if (empty($matches))
2841
-        return '';
2842
-    else
2843
-        return $file;
2885
+    if (empty($matches)) {
2886
+            return '';
2887
+    } else {
2888
+            return $file;
2889
+    }
2844 2890
 
2845 2891
 }
2846 2892
 
@@ -2925,8 +2971,9 @@  discard block
 block discarded – undo
2925 2971
     } else {
2926 2972
         //set_post_thumbnail($post_id,-1);
2927 2973
 
2928
-        if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete'))
2929
-            wp_delete_attachment($post_thumbnail_id);
2974
+        if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) {
2975
+                    wp_delete_attachment($post_thumbnail_id);
2976
+        }
2930 2977
 
2931 2978
     }
2932 2979
 }
@@ -3011,8 +3058,9 @@  discard block
 block discarded – undo
3011 3058
 
3012 3059
     global $wpdb;
3013 3060
 
3014
-    if ($listing_type == '')
3015
-        $listing_type = 'gd_place';
3061
+    if ($listing_type == '') {
3062
+            $listing_type = 'gd_place';
3063
+    }
3016 3064
 
3017 3065
     $fields_info = array();
3018 3066
 
@@ -3035,8 +3083,9 @@  discard block
 block discarded – undo
3035 3083
 
3036 3084
                 $fields_info[$prefix . 'address'] = $data->field_type;
3037 3085
 
3038
-                if (isset($extra_fields['show_zip']) && $extra_fields['show_zip'])
3039
-                    $fields_info[$prefix . 'zip'] = $data->field_type;
3086
+                if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
3087
+                                    $fields_info[$prefix . 'zip'] = $data->field_type;
3088
+                }
3040 3089
 
3041 3090
             } else {
3042 3091
 
@@ -3146,7 +3195,7 @@  discard block
 block discarded – undo
3146 3195
             $facebook_image = $upload_dir['baseurl'].$post->featured_image;
3147 3196
 
3148 3197
         }
3149
-    }elseif(geodir_is_page('location')){// location page
3198
+    } elseif(geodir_is_page('location')){// location page
3150 3199
         if (function_exists('geodir_get_location_seo')) {
3151 3200
             $seo = geodir_get_location_seo();
3152 3201
             if (isset($seo->seo_image) && $seo->seo_image) {
@@ -3192,8 +3241,10 @@  discard block
 block discarded – undo
3192 3241
 function geodir_delete_map_cache(){
3193 3242
     $files = glob(realpath(dirname(__FILE__))."/map-functions/map-cache/*.json"); // get all file names
3194 3243
     foreach($files as $file){ // iterate files
3195
-        if(is_file($file))
3196
-            unlink($file); // delete file
3244
+        if(is_file($file)) {
3245
+                    unlink($file);
3246
+        }
3247
+        // delete file
3197 3248
     }
3198 3249
 }
3199 3250
 
Please login to merge, or discard this patch.
geodirectory-functions/map-functions/get_markers.php 1 patch
Braces   +10 added lines, -8 removed lines patch added patch discarded remove patch
@@ -247,11 +247,13 @@  discard block
 block discarded – undo
247 247
         }
248 248
     }
249 249
 
250
-    if (!empty($field_default_cat))
251
-        $field_default_cat = '';
250
+    if (!empty($field_default_cat)) {
251
+            $field_default_cat = '';
252
+    }
252 253
 
253
-    if (!empty($cat_find_array))
254
-        $search .= "AND (" . implode(' OR ', $cat_find_array) . ")";
254
+    if (!empty($cat_find_array)) {
255
+            $search .= "AND (" . implode(' OR ', $cat_find_array) . ")";
256
+    }
255 257
 
256 258
     $main_query_array = $map_cat_ids_array;
257 259
   
@@ -283,8 +285,9 @@  discard block
 block discarded – undo
283 285
         $gd_posttype = " AND p.post_type = %s";
284 286
         $main_query_array[] = $_REQUEST['gd_posttype'];
285 287
 
286
-    } else
287
-        $table = $plugin_prefix . 'gd_place_detail';
288
+    } else {
289
+            $table = $plugin_prefix . 'gd_place_detail';
290
+    }
288 291
 
289 292
     $join = ", " . $table . " AS pd ";
290 293
 
@@ -606,8 +609,7 @@  discard block
 block discarded – undo
606 609
 
607 610
     if (!empty($cat_content_info)) {
608 611
         $map_json = '[{"totalcount":"' . $totalcount . '",' . substr(implode(',', $cat_content_info), 1) . ']';
609
-    }
610
-    else {
612
+    } else {
611 613
         $map_json =  '[{"totalcount":"0"}]';
612 614
     }
613 615
 
Please login to merge, or discard this patch.
geodirectory_hooks_actions.php 1 patch
Braces   +89 added lines, -72 removed lines patch added patch discarded remove patch
@@ -86,8 +86,9 @@  discard block
 block discarded – undo
86 86
 add_filter('query_vars', 'geodir_add_location_var');
87 87
 add_filter('query_vars', 'geodir_add_geodir_page_var');
88 88
 add_action('wp', 'geodir_add_page_id_in_query_var'); // problem fix in wordpress 3.8
89
-if (get_option('permalink_structure') != '')
90
-    add_filter('parse_request', 'geodir_set_location_var_in_session_in_core');
89
+if (get_option('permalink_structure') != '') {
90
+    add_filter('parse_request', 'geodir_set_location_var_in_session_in_core');
91
+}
91 92
 
92 93
 add_filter('parse_query', 'geodir_modified_query');
93 94
 
@@ -431,8 +432,9 @@  discard block
 block discarded – undo
431 432
      */
432 433
     do_action('geodir_after_social_sharing_buttons');
433 434
     $content_html = ob_get_clean();
434
-    if (trim($content_html) != '')
435
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-social-sharing">' . $content_html . '</div>';
435
+    if (trim($content_html) != '') {
436
+            $content_html = '<div class="geodir-company_info geodir-details-sidebar-social-sharing">' . $content_html . '</div>';
437
+    }
436 438
     if ((int)get_option('geodir_disable_tfg_buttons_section') != 1) {
437 439
         /**
438 440
          * Filter the geodir_social_sharing_buttons() function content.
@@ -488,8 +490,9 @@  discard block
 block discarded – undo
488 490
      */
489 491
     do_action('geodir_after_edit_post_link');
490 492
     $content_html = ob_get_clean();
491
-    if (trim($content_html) != '')
492
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-user-links">' . $content_html . '</div>';
493
+    if (trim($content_html) != '') {
494
+            $content_html = '<div class="geodir-company_info geodir-details-sidebar-user-links">' . $content_html . '</div>';
495
+    }
493 496
     if ((int)get_option('geodir_disable_user_links_section') != 1) {
494 497
         /**
495 498
          * Filter the geodir_edit_post_link() function content.
@@ -1063,8 +1066,9 @@  discard block
 block discarded – undo
1063 1066
      */
1064 1067
     do_action('geodir_after_google_analytics');
1065 1068
     $content_html = ob_get_clean();
1066
-    if (trim($content_html) != '')
1067
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-google-analytics">' . $content_html . '</div>';
1069
+    if (trim($content_html) != '') {
1070
+            $content_html = '<div class="geodir-company_info geodir-details-sidebar-google-analytics">' . $content_html . '</div>';
1071
+    }
1068 1072
     if ((int)get_option('geodir_disable_google_analytics_section') != 1) {
1069 1073
         /**
1070 1074
          * Filter the geodir_edit_post_link() function content.
@@ -1206,8 +1210,9 @@  discard block
 block discarded – undo
1206 1210
     do_action('geodir_after_detail_page_more_info');
1207 1211
 
1208 1212
     $content_html = ob_get_clean();
1209
-    if (trim($content_html) != '')
1210
-        $content_html = '<div class="geodir-company_info geodir-details-sidebar-listing-info">' . $content_html . '</div>';
1213
+    if (trim($content_html) != '') {
1214
+            $content_html = '<div class="geodir-company_info geodir-details-sidebar-listing-info">' . $content_html . '</div>';
1215
+    }
1211 1216
     if ((int)get_option('geodir_disable_listing_info_section') != 1) {
1212 1217
         /**
1213 1218
          * Filter the output html for function geodir_detail_page_more_info().
@@ -1334,8 +1339,9 @@  discard block
 block discarded – undo
1334 1339
     $arr_alert_msg = apply_filters('geodir_all_js_msg', $arr_alert_msg);
1335 1340
 
1336 1341
     foreach ($arr_alert_msg as $key => $value) {
1337
-        if (!is_scalar($value))
1338
-            continue;
1342
+        if (!is_scalar($value)) {
1343
+                    continue;
1344
+        }
1339 1345
         $arr_alert_msg[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8');
1340 1346
     }
1341 1347
 
@@ -1391,17 +1397,19 @@  discard block
 block discarded – undo
1391 1397
     global $geodir_sidebars;
1392 1398
     global $sidebars_widgets;
1393 1399
 
1394
-    if (!is_array($sidebars_widgets))
1395
-        $sidebars_widgets = wp_get_sidebars_widgets();
1400
+    if (!is_array($sidebars_widgets)) {
1401
+            $sidebars_widgets = wp_get_sidebars_widgets();
1402
+    }
1396 1403
     $geodir_old_sidebars = array();
1397 1404
 
1398 1405
     if (is_array($geodir_sidebars)) {
1399 1406
         foreach ($geodir_sidebars as $val) {
1400 1407
             if (is_array($sidebars_widgets)) {
1401
-                if (array_key_exists($val, $sidebars_widgets))
1402
-                    $geodir_old_sidebars[$val] = $sidebars_widgets[$val];
1403
-                else
1404
-                    $geodir_old_sidebars[$val] = array();
1408
+                if (array_key_exists($val, $sidebars_widgets)) {
1409
+                                    $geodir_old_sidebars[$val] = $sidebars_widgets[$val];
1410
+                } else {
1411
+                                    $geodir_old_sidebars[$val] = array();
1412
+                }
1405 1413
             }
1406 1414
         }
1407 1415
     }
@@ -1422,16 +1430,19 @@  discard block
 block discarded – undo
1422 1430
 {
1423 1431
     global $sidebars_widgets;
1424 1432
 
1425
-    if (!is_array($sidebars_widgets))
1426
-        $sidebars_widgets = wp_get_sidebars_widgets();
1433
+    if (!is_array($sidebars_widgets)) {
1434
+            $sidebars_widgets = wp_get_sidebars_widgets();
1435
+    }
1427 1436
 
1428 1437
     if (is_array($sidebars_widgets)) {
1429 1438
         $geodir_old_sidebars = get_option('geodir_sidebars');
1430 1439
         if (is_array($geodir_old_sidebars)) {
1431 1440
             foreach ($geodir_old_sidebars as $key => $val) {
1432
-                if(0 === strpos($key, 'geodir_'))// if gd widget
1441
+                if(0 === strpos($key, 'geodir_')) {
1442
+                	// if gd widget
1433 1443
                 {
1434
-                    $sidebars_widgets[$key] = $geodir_old_sidebars[$key];
1444
+                    $sidebars_widgets[$key] = $geodir_old_sidebars[$key];
1445
+                }
1435 1446
                 }
1436 1447
 
1437 1448
 
@@ -1567,20 +1578,25 @@  discard block
 block discarded – undo
1567 1578
         }
1568 1579
     }
1569 1580
     
1570
-    if ($tab == 'post_info')
1571
-        $is_display = (!empty($geodir_post_detail_fields)) ? true : false;
1581
+    if ($tab == 'post_info') {
1582
+            $is_display = (!empty($geodir_post_detail_fields)) ? true : false;
1583
+    }
1572 1584
     
1573
-    if ($tab == 'post_images')
1574
-        $is_display = (!empty($post_images)) ? true : false;
1585
+    if ($tab == 'post_images') {
1586
+            $is_display = (!empty($post_images)) ? true : false;
1587
+    }
1575 1588
 
1576
-    if ($tab == 'post_video')
1577
-        $is_display = (!empty($video)) ? true : false;
1589
+    if ($tab == 'post_video') {
1590
+            $is_display = (!empty($video)) ? true : false;
1591
+    }
1578 1592
 
1579
-    if ($tab == 'special_offers')
1580
-        $is_display = (!empty($special_offers)) ? true : false;
1593
+    if ($tab == 'special_offers') {
1594
+            $is_display = (!empty($special_offers)) ? true : false;
1595
+    }
1581 1596
 
1582
-    if ($tab == 'reviews')
1583
-        $is_display = (geodir_is_page('detail')) ? true : false;
1597
+    if ($tab == 'reviews') {
1598
+            $is_display = (geodir_is_page('detail')) ? true : false;
1599
+    }
1584 1600
 
1585 1601
     if ($tab == 'related_listing') {
1586 1602
        $message = __('No listings found which match your selection.', 'geodirectory');
@@ -1814,11 +1830,13 @@  discard block
 block discarded – undo
1814 1830
     $region_slug = $default_location->region_slug;
1815 1831
     $city_slug = $default_location->city_slug;
1816 1832
 
1817
-    if ($country_slug == $slug || $region_slug == $slug || $city_slug == $slug)
1818
-        return $slug_exists = true;
1833
+    if ($country_slug == $slug || $region_slug == $slug || $city_slug == $slug) {
1834
+            return $slug_exists = true;
1835
+    }
1819 1836
 
1820
-    if ($wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s AND term_id != %d", array($slug, $term_id))))
1821
-        return $slug_exists = true;
1837
+    if ($wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s AND term_id != %d", array($slug, $term_id)))) {
1838
+            return $slug_exists = true;
1839
+    }
1822 1840
 
1823 1841
     return $slug_exists;
1824 1842
 }
@@ -1861,40 +1879,31 @@  discard block
 block discarded – undo
1861 1879
     if(geodir_is_page('home')){
1862 1880
         $gd_page = 'home';
1863 1881
         $title = (get_option('geodir_meta_title_homepage')) ? get_option('geodir_meta_title_homepage') : $title;
1864
-    }
1865
-    elseif(geodir_is_page('detail')){
1882
+    } elseif(geodir_is_page('detail')){
1866 1883
         $gd_page = 'detail';
1867 1884
         $title = (get_option('geodir_meta_title_detail')) ? get_option('geodir_meta_title_detail') : $title;
1868
-    }
1869
-    elseif(geodir_is_page('pt')){
1885
+    } elseif(geodir_is_page('pt')){
1870 1886
         $gd_page = 'pt';
1871 1887
         $title = (get_option('geodir_meta_title_pt')) ? get_option('geodir_meta_title_pt') : $title;
1872
-    }
1873
-    elseif(geodir_is_page('listing')){
1888
+    } elseif(geodir_is_page('listing')){
1874 1889
         $gd_page = 'listing';
1875 1890
         $title = (get_option('geodir_meta_title_listing')) ? get_option('geodir_meta_title_listing') : $title;
1876
-    }
1877
-    elseif(geodir_is_page('location')){
1891
+    } elseif(geodir_is_page('location')){
1878 1892
         $gd_page = 'location';
1879 1893
         $title = (get_option('geodir_meta_title_location')) ? get_option('geodir_meta_title_location') : $title;
1880
-    }
1881
-    elseif(geodir_is_page('search')){
1894
+    } elseif(geodir_is_page('search')){
1882 1895
         $gd_page = 'search';
1883 1896
         $title = (get_option('geodir_meta_title_search')) ? get_option('geodir_meta_title_search') : $title;
1884
-    }
1885
-    elseif(geodir_is_page('add-listing')){
1897
+    } elseif(geodir_is_page('add-listing')){
1886 1898
         $gd_page = 'add-listing';
1887 1899
         $title = (get_option('geodir_meta_title_add-listing')) ? get_option('geodir_meta_title_add-listing') : $title;
1888
-    }
1889
-    elseif(geodir_is_page('author')){
1900
+    } elseif(geodir_is_page('author')){
1890 1901
         $gd_page = 'author';
1891 1902
         $title = (get_option('geodir_meta_title_author')) ? get_option('geodir_meta_title_author') : $title;
1892
-    }
1893
-    elseif(geodir_is_page('login')){
1903
+    } elseif(geodir_is_page('login')){
1894 1904
         $gd_page = 'login';
1895 1905
         $title = (get_option('geodir_meta_title_login')) ? get_option('geodir_meta_title_login') : $title;
1896
-    }
1897
-    elseif(geodir_is_page('listing-success')){
1906
+    } elseif(geodir_is_page('listing-success')){
1898 1907
         $gd_page = 'listing-success';
1899 1908
         $title = (get_option('geodir_meta_title_listing-success')) ? get_option('geodir_meta_title_listing-success') : $title;
1900 1909
     }
@@ -1972,11 +1981,13 @@  discard block
 block discarded – undo
1972 1981
 
1973 1982
     if (!get_option('geodir_remove_url_seperator')) {
1974 1983
 
1975
-        if (get_option('geodir_listingurl_separator'))
1976
-            delete_option('geodir_listingurl_separator');
1984
+        if (get_option('geodir_listingurl_separator')) {
1985
+                    delete_option('geodir_listingurl_separator');
1986
+        }
1977 1987
 
1978
-        if (get_option('geodir_detailurl_separator'))
1979
-            delete_option('geodir_detailurl_separator');
1988
+        if (get_option('geodir_detailurl_separator')) {
1989
+                    delete_option('geodir_detailurl_separator');
1990
+        }
1980 1991
 
1981 1992
         flush_rewrite_rules(false);
1982 1993
 
@@ -2000,8 +2011,9 @@  discard block
 block discarded – undo
2000 2011
 {
2001 2012
     foreach ($permalink_arr as $key => $value) {
2002 2013
 
2003
-        if ($value['id'] == 'geodir_listingurl_separator' || $value['id'] == 'geodir_detailurl_separator')
2004
-            unset($permalink_arr[$key]);
2014
+        if ($value['id'] == 'geodir_listingurl_separator' || $value['id'] == 'geodir_detailurl_separator') {
2015
+                    unset($permalink_arr[$key]);
2016
+        }
2005 2017
 
2006 2018
     }
2007 2019
 
@@ -2136,16 +2148,18 @@  discard block
 block discarded – undo
2136 2148
 
2137 2149
             $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_video', $post_type)));
2138 2150
 
2139
-            if (isset($tabs_arr['post_video']['heading_text']) && $field_title != '')
2140
-                $tabs_arr['post_video']['heading_text'] = $field_title;
2151
+            if (isset($tabs_arr['post_video']['heading_text']) && $field_title != '') {
2152
+                            $tabs_arr['post_video']['heading_text'] = $field_title;
2153
+            }
2141 2154
         }
2142 2155
 
2143 2156
         if (array_key_exists('special_offers', $tabs_arr)) {
2144 2157
 
2145 2158
             $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_special_offers', $post_type)));
2146 2159
 
2147
-            if (isset($tabs_arr['special_offers']['heading_text']) && $field_title != '')
2148
-                $tabs_arr['special_offers']['heading_text'] = $field_title;
2160
+            if (isset($tabs_arr['special_offers']['heading_text']) && $field_title != '') {
2161
+                            $tabs_arr['special_offers']['heading_text'] = $field_title;
2162
+            }
2149 2163
         }
2150 2164
 
2151 2165
     }
@@ -2200,8 +2214,9 @@  discard block
 block discarded – undo
2200 2214
 
2201 2215
         $all_postypes = geodir_get_posttypes();
2202 2216
 
2203
-        if (!in_array($post_type, $all_postypes) || !is_admin())
2204
-            return false;
2217
+        if (!in_array($post_type, $all_postypes) || !is_admin()) {
2218
+                    return false;
2219
+        }
2205 2220
 
2206 2221
         $uploads = wp_upload_dir();
2207 2222
 
@@ -2275,8 +2290,9 @@  discard block
 block discarded – undo
2275 2290
                         $file_info = pathinfo($attach->file);
2276 2291
 
2277 2292
                         $sub_dir = '';
2278
-                        if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
2279
-                            $sub_dir = stripslashes_deep($file_info['dirname']);
2293
+                        if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') {
2294
+                                                    $sub_dir = stripslashes_deep($file_info['dirname']);
2295
+                        }
2280 2296
 
2281 2297
                         $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
2282 2298
                         $uploads_path = $uploads['basedir'];
@@ -2297,8 +2313,9 @@  discard block
 block discarded – undo
2297 2313
 
2298 2314
                     if (!empty($attachment_data)) {
2299 2315
 
2300
-                        if ($attachment_data->ID)
2301
-                            $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID);
2316
+                        if ($attachment_data->ID) {
2317
+                                                    $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID);
2318
+                        }
2302 2319
 
2303 2320
                     } else {
2304 2321
 
@@ -2489,7 +2506,7 @@  discard block
 block discarded – undo
2489 2506
                         $variables_array['label'] = __($type['site_title'], 'geodirectory');
2490 2507
                         $variables_array['value'] = isset($post->{$type['htmlvar_name']}) ? $post->{$type['htmlvar_name']} : '';
2491 2508
 
2492
-                    }else{
2509
+                    } else{
2493 2510
                         $i = 0;
2494 2511
                         $fieldset_count++;
2495 2512
                         $field_set_start = 1;
@@ -2618,7 +2635,7 @@  discard block
 block discarded – undo
2618 2635
             $status_icon = '<i class="fa fa-play"></i>';
2619 2636
             if ($real_status == 'publish') {
2620 2637
                 $status .= __('Published', 'geodirectory');
2621
-            }elseif ($real_status == 'pending') {
2638
+            } elseif ($real_status == 'pending') {
2622 2639
                 $status .= __('Awaiting Review', 'geodirectory');
2623 2640
             } else {
2624 2641
                 $status .= __('Not published', 'geodirectory');
Please login to merge, or discard this patch.