Completed
Pull Request — master (#206)
by Kiran
05:47
created
geodirectory-functions/custom_functions.php 1 patch
Braces   +61 added lines, -50 removed lines patch added patch discarded remove patch
@@ -526,13 +526,15 @@  discard block
 block discarded – undo
526 526
 
527 527
         $all_postypes = geodir_get_posttypes();
528 528
 
529
-        if (!in_array($post_type, $all_postypes))
530
-            return false;
529
+        if (!in_array($post_type, $all_postypes)) {
530
+                    return false;
531
+        }
531 532
 
532 533
         $sort_field_info = $wpdb->get_var($wpdb->prepare("select default_order from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where	post_type= %s and is_active=%d and is_default=%d", array($post_type, 1, 1)));
533 534
 
534
-        if (!empty($sort_field_info))
535
-            return $sort_field_info;
535
+        if (!empty($sort_field_info)) {
536
+                    return $sort_field_info;
537
+        }
536 538
 
537 539
     }
538 540
 
@@ -554,8 +556,9 @@  discard block
 block discarded – undo
554 556
     if ($post_type != '') {
555 557
         $all_postypes = geodir_get_posttypes();
556 558
 
557
-        if (!in_array($post_type, $all_postypes))
558
-            return false;
559
+        if (!in_array($post_type, $all_postypes)) {
560
+                    return false;
561
+        }
559 562
 
560 563
         $sort_field_info = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type=%s AND is_active=%d AND (sort_asc=1 || sort_desc=1 || field_type='random') AND field_type != 'address' ORDER BY sort_order ASC", array($post_type, 1)));
561 564
         /**
@@ -593,7 +596,9 @@  discard block
 block discarded – undo
593 596
 
594 597
     $sort_by = '';
595 598
 
596
-    if (isset($_REQUEST['sort_by'])) $sort_by = $_REQUEST['sort_by'];
599
+    if (isset($_REQUEST['sort_by'])) {
600
+    	$sort_by = $_REQUEST['sort_by'];
601
+    }
597 602
 
598 603
     $gd_post_type = geodir_get_current_posttype();
599 604
 
@@ -621,8 +626,9 @@  discard block
 block discarded – undo
621 626
             if ($sort->sort_asc) {
622 627
                 $key = $sort->htmlvar_name . '_asc';
623 628
                 $label = $sort->site_title;
624
-                if ($sort->asc_title)
625
-                    $label = $sort->asc_title;
629
+                if ($sort->asc_title) {
630
+                                    $label = $sort->asc_title;
631
+                }
626 632
                 ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
627 633
                 $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
628 634
             }
@@ -630,8 +636,9 @@  discard block
 block discarded – undo
630 636
             if ($sort->sort_desc) {
631 637
                 $key = $sort->htmlvar_name . '_desc';
632 638
                 $label = $sort->site_title;
633
-                if ($sort->desc_title)
634
-                    $label = $sort->desc_title;
639
+                if ($sort->desc_title) {
640
+                                    $label = $sort->desc_title;
641
+                }
635 642
                 ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = '';
636 643
                 $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
637 644
             }
@@ -648,7 +655,10 @@  discard block
 block discarded – undo
648 655
             <select name="sort_by" id="sort_by" onchange="javascript:window.location=this.value;">
649 656
 
650 657
                 <option
651
-                    value="<?php echo esc_url( add_query_arg('sort_by', '') );?>" <?php if ($sort_by == '') echo 'selected="selected"';?>><?php _e('Sort By', 'geodirectory');?></option><?php
658
+                    value="<?php echo esc_url( add_query_arg('sort_by', '') );?>" <?php if ($sort_by == '') {
659
+	echo 'selected="selected"';
660
+}
661
+?>><?php _e('Sort By', 'geodirectory');?></option><?php
652 662
 
653 663
                 echo $sort_field_options;?>
654 664
 
@@ -721,8 +731,9 @@  discard block
 block discarded – undo
721 731
         if (isset($_REQUEST['backandedit'])) {
722 732
             $post = (object)$gd_session->get('listing');
723 733
             $post_type = $post->listing_type;
724
-            if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
725
-                $post_id = $_REQUEST['pid'];
734
+            if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
735
+                            $post_id = $_REQUEST['pid'];
736
+            }
726 737
         } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
727 738
             $post = geodir_get_post_info($_REQUEST['pid']);
728 739
             $post_type = $post->post_type;
@@ -735,25 +746,29 @@  discard block
 block discarded – undo
735 746
         if ($relate_to == 'category') {
736 747
 
737 748
             $category_taxonomy = $post_type . $relate_to;
738
-            if (isset($post->$category_taxonomy) && $post->$category_taxonomy != '')
739
-                $category = explode(',', trim($post->$category_taxonomy, ','));
749
+            if (isset($post->$category_taxonomy) && $post->$category_taxonomy != '') {
750
+                            $category = explode(',', trim($post->$category_taxonomy, ','));
751
+            }
740 752
 
741 753
         } elseif ($relate_to == 'tags') {
742 754
 
743 755
             $category_taxonomy = $post_type . '_' . $relate_to;
744
-            if ($post->post_tags != '')
745
-                $category = explode(',', trim($post->post_tags, ','));
756
+            if ($post->post_tags != '') {
757
+                            $category = explode(',', trim($post->post_tags, ','));
758
+            }
746 759
             $tax_field = 'name';
747 760
         }
748 761
 
749 762
         /* --- return false in invalid request --- */
750
-        if (empty($category))
751
-            return false;
763
+        if (empty($category)) {
764
+                    return false;
765
+        }
752 766
 
753 767
         $all_postypes = geodir_get_posttypes();
754 768
 
755
-        if (!in_array($post_type, $all_postypes))
756
-            return false;
769
+        if (!in_array($post_type, $all_postypes)) {
770
+                    return false;
771
+        }
757 772
 
758 773
         /* --- return false in invalid request --- */
759 774
 
@@ -911,8 +926,9 @@  discard block
 block discarded – undo
911 926
 function geodir_get_map_default_language()
912 927
 {
913 928
     $geodir_default_map_language = get_option('geodir_default_map_language');
914
-    if (empty($geodir_default_map_language))
915
-        $geodir_default_map_language = 'en';
929
+    if (empty($geodir_default_map_language)) {
930
+            $geodir_default_map_language = 'en';
931
+    }
916 932
     /**
917 933
      * Filter default map language.
918 934
      *
@@ -1090,42 +1106,33 @@  discard block
 block discarded – undo
1090 1106
     if(geodir_is_page('home')){
1091 1107
         $gd_page = 'home';
1092 1108
         $meta_desc = (get_option('geodir_meta_desc_homepage')) ? get_option('geodir_meta_desc_homepage') : $meta_desc;
1093
-    }
1094
-    elseif(geodir_is_page('detail')){
1109
+    } elseif(geodir_is_page('detail')){
1095 1110
         $gd_page = 'detail';
1096 1111
         $meta_desc = (get_option('geodir_meta_desc_detail')) ? get_option('geodir_meta_desc_detail') : $meta_desc;
1097
-    }
1098
-    elseif(geodir_is_page('pt')){
1112
+    } elseif(geodir_is_page('pt')){
1099 1113
         $gd_page = 'pt';
1100 1114
         $meta_desc = (get_option('geodir_meta_desc_pt')) ? get_option('geodir_meta_desc_pt') : $meta_desc;
1101
-    }
1102
-    elseif(geodir_is_page('listing')){
1115
+    } elseif(geodir_is_page('listing')){
1103 1116
         $gd_page = 'listing';
1104 1117
         $meta_desc = (get_option('geodir_meta_desc_listing')) ? get_option('geodir_meta_desc_listing') : $meta_desc;
1105
-    }
1106
-    elseif(geodir_is_page('location')){
1118
+    } elseif(geodir_is_page('location')){
1107 1119
         $gd_page = 'location';
1108 1120
         $meta_desc = (get_option('geodir_meta_desc_location')) ? get_option('geodir_meta_desc_location') : $meta_desc;
1109 1121
         $meta_desc = apply_filters('geodir_seo_meta_location_description', $meta_desc);
1110 1122
 
1111
-    }
1112
-    elseif(geodir_is_page('search')){
1123
+    } elseif(geodir_is_page('search')){
1113 1124
         $gd_page = 'search';
1114 1125
         $meta_desc = (get_option('geodir_meta_desc_search')) ? get_option('geodir_meta_desc_search') : $meta_desc;
1115
-    }
1116
-    elseif(geodir_is_page('add-listing')){
1126
+    } elseif(geodir_is_page('add-listing')){
1117 1127
         $gd_page = 'add-listing';
1118 1128
         $meta_desc = (get_option('geodir_meta_desc_add-listing')) ? get_option('geodir_meta_desc_add-listing') : $meta_desc;
1119
-    }
1120
-    elseif(geodir_is_page('author')){
1129
+    } elseif(geodir_is_page('author')){
1121 1130
         $gd_page = 'author';
1122 1131
         $meta_desc = (get_option('geodir_meta_desc_author')) ? get_option('geodir_meta_desc_author') : $meta_desc;
1123
-    }
1124
-    elseif(geodir_is_page('login')){
1132
+    } elseif(geodir_is_page('login')){
1125 1133
         $gd_page = 'login';
1126 1134
         $meta_desc = (get_option('geodir_meta_desc_login')) ? get_option('geodir_meta_desc_login') : $meta_desc;
1127
-    }
1128
-    elseif(geodir_is_page('listing-success')){
1135
+    } elseif(geodir_is_page('listing-success')){
1129 1136
         $gd_page = 'listing-success';
1130 1137
         $meta_desc = (get_option('geodir_meta_desc_listing-success')) ? get_option('geodir_meta_desc_listing-success') : $meta_desc;
1131 1138
     }
@@ -1333,8 +1340,9 @@  discard block
 block discarded – undo
1333 1340
     $tabs_array = geodir_detail_page_tabs_array();
1334 1341
     if (!empty($tabs_excluded)) {
1335 1342
         foreach ($tabs_excluded as $tab) {
1336
-            if (array_key_exists($tab, $tabs_array))
1337
-                unset($tabs_array[$tab]);
1343
+            if (array_key_exists($tab, $tabs_array)) {
1344
+                            unset($tabs_array[$tab]);
1345
+            }
1338 1346
         }
1339 1347
     }
1340 1348
     return $tabs_array;
@@ -1375,8 +1383,9 @@  discard block
 block discarded – undo
1375 1383
         $video = geodir_get_video($post->ID);
1376 1384
         $special_offers = geodir_get_special_offers($post->ID);
1377 1385
         $related_listing_array = array();
1378
-        if (get_option('geodir_add_related_listing_posttypes'))
1379
-            $related_listing_array = get_option('geodir_add_related_listing_posttypes');
1386
+        if (get_option('geodir_add_related_listing_posttypes')) {
1387
+                    $related_listing_array = get_option('geodir_add_related_listing_posttypes');
1388
+        }
1380 1389
 
1381 1390
         $related_listing = '';
1382 1391
         if (in_array($post->post_type, $related_listing_array)) {
@@ -1425,11 +1434,13 @@  discard block
 block discarded – undo
1425 1434
         $video = isset($post->geodir_video) ? $post->geodir_video : '';
1426 1435
         $special_offers = isset($post->geodir_special_offers) ? $post->geodir_special_offers : '';
1427 1436
 
1428
-        if (isset($post->post_images))
1429
-            $post->post_images = trim($post->post_images, ",");
1437
+        if (isset($post->post_images)) {
1438
+                    $post->post_images = trim($post->post_images, ",");
1439
+        }
1430 1440
 
1431
-        if (isset($post->post_images) && !empty($post->post_images))
1432
-            $post_images = explode(",", $post->post_images);
1441
+        if (isset($post->post_images) && !empty($post->post_images)) {
1442
+                    $post_images = explode(",", $post->post_images);
1443
+        }
1433 1444
 
1434 1445
         $thumb_image = '';
1435 1446
         if (!empty($post_images)) {
Please login to merge, or discard this patch.