Test Failed
Push — master ( a017c6...2185f5 )
by Stiofan
19:29
created
geodirectory-functions/post_functions.php 1 patch
Braces   +171 added lines, -121 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
 
@@ -899,8 +912,9 @@  discard block
 block discarded – undo
899 912
             $meta_value = $wpdb->get_var($wpdb->prepare("SELECT " . $meta_key . " from " . $table . " where post_id = %d", array($post_id)));
900 913
             if ($meta_value && $meta_value !== '') {
901 914
                 return maybe_serialize($meta_value);
902
-            } else
903
-                return $meta_value;
915
+            } else {
916
+                            return $meta_value;
917
+            }
904 918
         } else {
905 919
             return false;
906 920
         }
@@ -1034,7 +1048,7 @@  discard block
 block discarded – undo
1034 1048
                             if (isset($uploaded['error']) && empty($uploaded['error'])) {
1035 1049
                                 $new_name = basename($uploaded['file']);
1036 1050
                                 $uploaded_file = $uploaded;
1037
-                            }else{
1051
+                            } else{
1038 1052
                                 print_r($uploaded);exit;
1039 1053
                             }
1040 1054
                             $external_img = false;
@@ -1059,8 +1073,9 @@  discard block
 block discarded – undo
1059 1073
                                 $file_path = $curr_img_dir . '/' . $filename;
1060 1074
                             }
1061 1075
 
1062
-                            if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path))
1063
-                                unlink($img_path);
1076
+                            if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path)) {
1077
+                                                            unlink($img_path);
1078
+                            }
1064 1079
                         }
1065 1080
 
1066 1081
                         if (!empty($uploaded_file)) {
@@ -1089,8 +1104,9 @@  discard block
 block discarded – undo
1089 1104
                             $attachment_set = '';
1090 1105
 
1091 1106
                             foreach ($attachment as $key => $val) {
1092
-                                if ($val != '')
1093
-                                    $attachment_set .= $key . " = '" . $val . "', ";
1107
+                                if ($val != '') {
1108
+                                                                    $attachment_set .= $key . " = '" . $val . "', ";
1109
+                                }
1094 1110
                             }
1095 1111
 
1096 1112
                             $attachment_set = trim($attachment_set, ", ");
@@ -1115,8 +1131,9 @@  discard block
 block discarded – undo
1115 1131
                         )
1116 1132
                     );
1117 1133
 
1118
-                    if ($menu_order == 1)
1119
-                        $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
1134
+                    if ($menu_order == 1) {
1135
+                                            $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
1136
+                    }
1120 1137
 
1121 1138
                 }
1122 1139
 
@@ -1157,8 +1174,9 @@  discard block
 block discarded – undo
1157 1174
 
1158 1175
         $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE " . $valid_files_condition . " post_id = %d", $remove_files));
1159 1176
 
1160
-        if (!empty($invalid_files))
1161
-            geodir_remove_attachments($invalid_files);
1177
+        if (!empty($invalid_files)) {
1178
+                    geodir_remove_attachments($invalid_files);
1179
+        }
1162 1180
     }
1163 1181
 
1164 1182
 }
@@ -1211,16 +1229,19 @@  discard block
 block discarded – undo
1211 1229
 function geodir_delete_directory($dirname)
1212 1230
 {
1213 1231
     $dir_handle = '';
1214
-    if (is_dir($dirname))
1215
-        $dir_handle = opendir($dirname);
1216
-    if (!$dir_handle)
1217
-        return false;
1232
+    if (is_dir($dirname)) {
1233
+            $dir_handle = opendir($dirname);
1234
+    }
1235
+    if (!$dir_handle) {
1236
+            return false;
1237
+    }
1218 1238
     while ($file = readdir($dir_handle)) {
1219 1239
         if ($file != "." && $file != "..") {
1220
-            if (!is_dir($dirname . "/" . $file))
1221
-                unlink($dirname . "/" . $file);
1222
-            else
1223
-                geodir_delete_directory($dirname . '/' . $file);
1240
+            if (!is_dir($dirname . "/" . $file)) {
1241
+                            unlink($dirname . "/" . $file);
1242
+            } else {
1243
+                            geodir_delete_directory($dirname . '/' . $file);
1244
+            }
1224 1245
         }
1225 1246
     }
1226 1247
     closedir($dir_handle);
@@ -1249,8 +1270,9 @@  discard block
 block discarded – undo
1249 1270
             foreach ($postcurr_images as $postimg) {
1250 1271
                 $image_name_arr = explode('/', $postimg->src);
1251 1272
                 $filename = end($image_name_arr);
1252
-                if (file_exists($uploads_dir . '/' . $filename))
1253
-                    unlink($uploads_dir . '/' . $filename);
1273
+                if (file_exists($uploads_dir . '/' . $filename)) {
1274
+                                    unlink($uploads_dir . '/' . $filename);
1275
+                }
1254 1276
             }
1255 1277
 
1256 1278
         } // endif
@@ -1369,9 +1391,9 @@  discard block
 block discarded – undo
1369 1391
                 $default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1370 1392
             }
1371 1393
 
1372
-            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1373
-                $default_img = $default_catimg['src'];
1374
-            elseif ($no_image) {
1394
+            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) {
1395
+                            $default_img = $default_catimg['src'];
1396
+            } elseif ($no_image) {
1375 1397
                 $default_img = get_option('geodir_listing_no_img');
1376 1398
             }
1377 1399
 
@@ -1403,10 +1425,13 @@  discard block
 block discarded – undo
1403 1425
             }
1404 1426
         }
1405 1427
 
1406
-        if (!empty($img_arr))
1407
-            return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path );
1408
-        else
1409
-            return false;
1428
+        if (!empty($img_arr)) {
1429
+                    return (object)$img_arr;
1430
+        }
1431
+        //return (object)array( 'src' => $file_url, 'path' => $file_path );
1432
+        else {
1433
+                    return false;
1434
+        }
1410 1435
     }
1411 1436
 }
1412 1437
 
@@ -1433,8 +1458,9 @@  discard block
 block discarded – undo
1433 1458
             echo $html;
1434 1459
         } elseif (!empty($html)) {
1435 1460
             return $html;
1436
-        } else
1437
-            return false;
1461
+        } else {
1462
+                    return false;
1463
+        }
1438 1464
     }
1439 1465
 }
1440 1466
 
@@ -1462,8 +1488,9 @@  discard block
 block discarded – undo
1462 1488
         }
1463 1489
         $not_featured = '';
1464 1490
         $sub_dir = '';
1465
-        if (!$add_featured)
1466
-            $not_featured = " AND is_featured = 0 ";
1491
+        if (!$add_featured) {
1492
+                    $not_featured = " AND is_featured = 0 ";
1493
+        }
1467 1494
 
1468 1495
         $arrImages = $wpdb->get_results(
1469 1496
             $wpdb->prepare(
@@ -1484,8 +1511,9 @@  discard block
 block discarded – undo
1484 1511
 
1485 1512
                 $file_info = pathinfo($attechment->file);
1486 1513
 
1487
-                if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..')
1488
-                    $sub_dir = stripslashes_deep($file_info['dirname']);
1514
+                if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') {
1515
+                                    $sub_dir = stripslashes_deep($file_info['dirname']);
1516
+                }
1489 1517
 
1490 1518
                 $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs
1491 1519
                 $uploads_baseurl = $uploads['baseurl'];
@@ -1537,9 +1565,9 @@  discard block
 block discarded – undo
1537 1565
             $default_img = '';
1538 1566
             $default_cat = geodir_get_post_meta($post_id, 'default_category', true);
1539 1567
             $post_type = get_post_type($post_id);
1540
-            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type))
1541
-                $default_img = $default_catimg['src'];
1542
-            elseif ($no_images) {
1568
+            if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) {
1569
+                            $default_img = $default_catimg['src'];
1570
+            } elseif ($no_images) {
1543 1571
                 $default_img = get_option('geodir_listing_no_img');
1544 1572
             }
1545 1573
 
@@ -1580,8 +1608,9 @@  discard block
 block discarded – undo
1580 1608
                  * @param array $return_arr The array of image objects.
1581 1609
                  */
1582 1610
                 return apply_filters('geodir_get_images_arr',$return_arr);
1583
-            } else
1584
-                return false;
1611
+            } else {
1612
+                            return false;
1613
+            }
1585 1614
         }
1586 1615
     }
1587 1616
 }
@@ -1642,8 +1671,9 @@  discard block
 block discarded – undo
1642 1671
                         $width_per = round(((($image->width * ($max_size->h / $image->height)) / $max_size->w) * 100), 2);
1643 1672
                     } else if ($image->width < ($max_size->h)) {
1644 1673
                         $width_per = round((($image->width / $max_size->w) * 100), 2);
1645
-                    } else
1646
-                        $width_per = 100;
1674
+                    } else {
1675
+                                            $width_per = 100;
1676
+                    }
1647 1677
                 }
1648 1678
 
1649 1679
                 if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
@@ -1651,7 +1681,7 @@  discard block
 block discarded – undo
1651 1681
                 } else {
1652 1682
                     if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){
1653 1683
                         $html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1654
-                    }else{
1684
+                    } else{
1655 1685
                         //$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>';
1656 1686
                         //$html = '<div data-src="'.$image->src.'" class="geodir_thumbnail" ></div>';
1657 1687
                         $html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>';
@@ -1666,8 +1696,9 @@  discard block
 block discarded – undo
1666 1696
             echo $html;
1667 1697
         } elseif (!empty($html)) {
1668 1698
             return $html;
1669
-        } else
1670
-            return false;
1699
+        } else {
1700
+                    return false;
1701
+        }
1671 1702
     }
1672 1703
 }
1673 1704
 
@@ -1705,8 +1736,9 @@  discard block
 block discarded – undo
1705 1736
                 $post_obj = get_post($post_id);
1706 1737
 
1707 1738
                 $cat_ids = array('0');
1708
-                if (is_array($tt_ids))
1709
-                    $cat_ids = $tt_ids;
1739
+                if (is_array($tt_ids)) {
1740
+                                    $cat_ids = $tt_ids;
1741
+                }
1710 1742
 
1711 1743
 
1712 1744
                 if (!empty($cat_ids)) {
@@ -1763,8 +1795,9 @@  discard block
 block discarded – undo
1763 1795
                         $json .= '}';
1764 1796
 
1765 1797
 
1766
-                        if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true))
1767
-                            $post_marker_json = $json;
1798
+                        if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true)) {
1799
+                                                    $post_marker_json = $json;
1800
+                        }
1768 1801
 
1769 1802
 
1770 1803
                         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)))) {
@@ -1795,10 +1828,13 @@  discard block
 block discarded – undo
1795 1828
                 if (!empty($post_term) && is_array($post_term)) {
1796 1829
                     $categories = implode(',', $post_term);
1797 1830
 
1798
-                    if ($categories != '' && $categories != 0) $categories = ',' . $categories . ',';
1831
+                    if ($categories != '' && $categories != 0) {
1832
+                    	$categories = ',' . $categories . ',';
1833
+                    }
1799 1834
 
1800
-                    if (empty($post_marker_json))
1801
-                        $post_marker_json = isset($json) ? $json : '';
1835
+                    if (empty($post_marker_json)) {
1836
+                                            $post_marker_json = isset($json) ? $json : '';
1837
+                    }
1802 1838
 
1803 1839
                     if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
1804 1840
 
@@ -1837,8 +1873,9 @@  discard block
 block discarded – undo
1837 1873
 
1838 1874
                                 }
1839 1875
 
1840
-                                if ($default_category == '')
1841
-                                    $default_category = $categories[0];
1876
+                                if ($default_category == '') {
1877
+                                                                    $default_category = $categories[0];
1878
+                                }
1842 1879
 
1843 1880
                                 geodir_set_postcat_structure($post_id, $taxonomy, $default_category, '');
1844 1881
 
@@ -1985,7 +2022,7 @@  discard block
 block discarded – undo
1985 2022
                                     } ?>"><img alt="bubble image" style="max-height:50px;"
1986 2023
                                                src="<?php echo $post_images[0]; ?>"/></a></div>
1987 2024
                             <?php
1988
-                            }else{
2025
+                            } else{
1989 2026
                                 echo '<div class="geodir-bubble_image"></div>';
1990 2027
                             }
1991 2028
                         } else {
@@ -1993,7 +2030,7 @@  discard block
 block discarded – undo
1993 2030
                                 ?>
1994 2031
                                 <div class="geodir-bubble_image"><a href="<?php echo $plink; ?>"><?php echo $image; ?></a></div>
1995 2032
                             <?php
1996
-                            }else{
2033
+                            } else{
1997 2034
                                 echo '<div class="geodir-bubble_image"></div>';
1998 2035
                             }
1999 2036
                         }
@@ -2074,10 +2111,11 @@  discard block
 block discarded – undo
2074 2111
      */
2075 2112
     function geodir_new_post_default_status()
2076 2113
     {
2077
-        if (get_option('geodir_new_post_default_status'))
2078
-            return get_option('geodir_new_post_default_status');
2079
-        else
2080
-            return 'publish';
2114
+        if (get_option('geodir_new_post_default_status')) {
2115
+                    return get_option('geodir_new_post_default_status');
2116
+        } else {
2117
+                    return 'publish';
2118
+        }
2081 2119
 
2082 2120
     }
2083 2121
 }
@@ -2228,8 +2266,9 @@  discard block
 block discarded – undo
2228 2266
 
2229 2267
         $all_postypes = geodir_get_posttypes();
2230 2268
 
2231
-        if (!in_array($post_type, $all_postypes))
2232
-            return false;
2269
+        if (!in_array($post_type, $all_postypes)) {
2270
+                    return false;
2271
+        }
2233 2272
 
2234 2273
         $table = $plugin_prefix . $post_type . '_detail';
2235 2274
 
@@ -2497,8 +2536,9 @@  discard block
 block discarded – undo
2497 2536
         $unfavourite_icon = apply_filters('geodir_unfavourite_icon', 'fa fa-heart');
2498 2537
 
2499 2538
         $user_meta_data = '';
2500
-        if (isset($current_user->data->ID))
2501
-            $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2539
+        if (isset($current_user->data->ID)) {
2540
+                    $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true);
2541
+        }
2502 2542
 
2503 2543
         if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
2504 2544
             ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"  ><a
@@ -2511,8 +2551,9 @@  discard block
 block discarded – undo
2511 2551
 
2512 2552
             if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
2513 2553
                 $script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\'';
2514
-            } else
2515
-                $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
2554
+            } else {
2555
+                            $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
2556
+            }
2516 2557
 
2517 2558
             ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon"
2518 2559
                                                                                         href="javascript:void(0);"
@@ -2575,14 +2616,16 @@  discard block
 block discarded – undo
2575 2616
 							WHERE pd.post_status='publish' AND FIND_IN_SET('" . $term->term_id . "'," . $term->taxonomy . ") " . $where;
2576 2617
 
2577 2618
             $cat_post_count = $wpdb->get_var($count_query);
2578
-            if (empty($cat_post_count) || is_wp_error($cat_post_count))
2579
-                $cat_post_count = 0;
2619
+            if (empty($cat_post_count) || is_wp_error($cat_post_count)) {
2620
+                            $cat_post_count = 0;
2621
+            }
2580 2622
 
2581 2623
             return $cat_post_count;
2582 2624
 
2583
-        } else
2584
-
2585
-            return $term->count;
2625
+        } else {
2626
+        
2627
+            return $term->count;
2628
+        }
2586 2629
     }
2587 2630
     return false;
2588 2631
 
@@ -2629,13 +2672,15 @@  discard block
 block discarded – undo
2629 2672
 		return $length;
2630 2673
 	}
2631 2674
 	
2632
-    if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit'))
2633
-        $length = get_option('geodir_desc_word_limit');
2634
-    elseif (get_query_var('excerpt_length'))
2635
-        $length = get_query_var('excerpt_length');
2675
+    if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit')) {
2676
+            $length = get_option('geodir_desc_word_limit');
2677
+    } elseif (get_query_var('excerpt_length')) {
2678
+            $length = get_query_var('excerpt_length');
2679
+    }
2636 2680
 
2637
-    if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit'))
2638
-        $length = get_option('geodir_author_desc_word_limit');
2681
+    if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit')) {
2682
+            $length = get_option('geodir_author_desc_word_limit');
2683
+    }
2639 2684
 
2640 2685
     return $length;
2641 2686
 }
@@ -2768,10 +2813,11 @@  discard block
 block discarded – undo
2768 2813
 function geodir_lisiting_belong_to_user($listing_id, $user_id)
2769 2814
 {
2770 2815
     $listing_author_id = geodir_get_listing_author($listing_id);
2771
-    if ($listing_author_id == $user_id)
2772
-        return true;
2773
-    else
2774
-        return false;
2816
+    if ($listing_author_id == $user_id) {
2817
+            return true;
2818
+    } else {
2819
+            return false;
2820
+    }
2775 2821
 
2776 2822
 }
2777 2823
 
@@ -2820,10 +2866,11 @@  discard block
 block discarded – undo
2820 2866
     $pattern = '/-\d+x\d+\./';
2821 2867
     preg_match($pattern, $file, $matches, PREG_OFFSET_CAPTURE);
2822 2868
 
2823
-    if (empty($matches))
2824
-        return '';
2825
-    else
2826
-        return $file;
2869
+    if (empty($matches)) {
2870
+            return '';
2871
+    } else {
2872
+            return $file;
2873
+    }
2827 2874
 
2828 2875
 }
2829 2876
 
@@ -2908,8 +2955,9 @@  discard block
 block discarded – undo
2908 2955
     } else {
2909 2956
         //set_post_thumbnail($post_id,-1);
2910 2957
 
2911
-        if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete'))
2912
-            wp_delete_attachment($post_thumbnail_id);
2958
+        if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) {
2959
+                    wp_delete_attachment($post_thumbnail_id);
2960
+        }
2913 2961
 
2914 2962
     }
2915 2963
 }
@@ -2994,8 +3042,9 @@  discard block
 block discarded – undo
2994 3042
 
2995 3043
     global $wpdb;
2996 3044
 
2997
-    if ($listing_type == '')
2998
-        $listing_type = 'gd_place';
3045
+    if ($listing_type == '') {
3046
+            $listing_type = 'gd_place';
3047
+    }
2999 3048
 
3000 3049
     $fields_info = array();
3001 3050
 
@@ -3018,8 +3067,9 @@  discard block
 block discarded – undo
3018 3067
 
3019 3068
                 $fields_info[$prefix . 'address'] = $data->field_type;
3020 3069
 
3021
-                if (isset($extra_fields['show_zip']) && $extra_fields['show_zip'])
3022
-                    $fields_info[$prefix . 'zip'] = $data->field_type;
3070
+                if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
3071
+                                    $fields_info[$prefix . 'zip'] = $data->field_type;
3072
+                }
3023 3073
 
3024 3074
             } else {
3025 3075
 
Please login to merge, or discard this patch.