Test Failed
Push — master ( 5c367d...c1a3f2 )
by
unknown
04:20
created
geodirectory-functions/taxonomy_functions.php 1 patch
Braces   +169 added lines, -121 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
 
@@ -406,24 +413,28 @@  discard block
 block discarded – undo
406 413
     $geodir_post_type = get_query_var('post_type');
407 414
 
408 415
     if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
409
-        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '')
410
-            $geodir_post_type = get_post_type((int)$_REQUEST['pid']);
411
-        elseif (isset($_REQUEST['listing_type']))
412
-            $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']);
416
+        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
417
+                    $geodir_post_type = get_post_type((int)$_REQUEST['pid']);
418
+        } elseif (isset($_REQUEST['listing_type'])) {
419
+                    $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']);
420
+        }
413 421
     }
414 422
 
415
-    if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype']))
416
-        $geodir_post_type = sanitize_text_field($_REQUEST['stype']);
423
+    if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype'])) {
424
+            $geodir_post_type = sanitize_text_field($_REQUEST['stype']);
425
+    }
417 426
 
418
-    if (is_tax())
419
-        $geodir_post_type = geodir_get_taxonomy_posttype();
427
+    if (is_tax()) {
428
+            $geodir_post_type = geodir_get_taxonomy_posttype();
429
+    }
420 430
 
421 431
 
422 432
     $all_postypes = geodir_get_posttypes();
423 433
     $all_postypes = stripslashes_deep($all_postypes);
424 434
 
425
-    if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes))
426
-        $geodir_post_type = '';
435
+    if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes)) {
436
+            $geodir_post_type = '';
437
+    }
427 438
 
428 439
     if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){
429 440
         $geodir_post_type = sanitize_text_field($_REQUEST['stype']);
@@ -508,11 +519,12 @@  discard block
 block discarded – undo
508 519
         endswitch;
509 520
     }
510 521
 
511
-    if (!empty($post_types))
512
-        return $post_types;
513
-    else
514
-        return array();
515
-}
522
+    if (!empty($post_types)) {
523
+            return $post_types;
524
+    } else {
525
+            return array();
526
+    }
527
+    }
516 528
 
517 529
 /**
518 530
  * Get Custom Post Type info.
@@ -529,9 +541,10 @@  discard block
 block discarded – undo
529 541
     $post_types = stripslashes_deep($post_types);
530 542
     if (!empty($post_types) && $post_type != '') {
531 543
         return $post_types[$post_type];
532
-    } else
533
-        return false;
534
-}
544
+    } else {
545
+            return false;
546
+    }
547
+    }
535 548
 
536 549
 if (!function_exists('geodir_get_taxonomies')) {
537 550
     /**
@@ -555,18 +568,21 @@  discard block
 block discarded – undo
555 568
             $gd_taxonomies = array_keys($taxonomies);
556 569
 
557 570
 
558
-            if ($post_type != '')
559
-                $gd_taxonomies = array();
571
+            if ($post_type != '') {
572
+                            $gd_taxonomies = array();
573
+            }
560 574
 
561 575
             $i = 0;
562 576
             foreach ($taxonomies as $taxonomy => $args) {
563 577
 
564
-                if ($post_type != '' && $args['object_type'] == $post_type)
565
-                    $gd_taxonomies[] = $taxonomy;
578
+                if ($post_type != '' && $args['object_type'] == $post_type) {
579
+                                    $gd_taxonomies[] = $taxonomy;
580
+                }
566 581
 
567 582
                 if ($tages_taxonomies === false && strpos($taxonomy, '_tag') !== false) {
568
-                    if (array_search($taxonomy, $gd_taxonomies) !== false)
569
-                        unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]);
583
+                    if (array_search($taxonomy, $gd_taxonomies) !== false) {
584
+                                            unset($gd_taxonomies[array_search($taxonomy, $gd_taxonomies)]);
585
+                    }
570 586
                 }
571 587
 
572 588
             }
@@ -621,10 +637,11 @@  discard block
 block discarded – undo
621 637
                 . ucfirst($category_obj->name) . '</option>';
622 638
         }
623 639
 
624
-        if ($echo)
625
-            echo $html;
626
-        else
627
-            return $html;
640
+        if ($echo) {
641
+                    echo $html;
642
+        } else {
643
+                    return $html;
644
+        }
628 645
     }
629 646
 }
630 647
 
@@ -658,11 +675,12 @@  discard block
 block discarded – undo
658 675
 
659 676
     }
660 677
 
661
-    if (!empty($listing_slug))
662
-        return $listing_slug;
663
-    else
664
-        return false;
665
-}
678
+    if (!empty($listing_slug)) {
679
+            return $listing_slug;
680
+    } else {
681
+            return false;
682
+    }
683
+    }
666 684
 
667 685
 
668 686
 /**
@@ -693,16 +711,18 @@  discard block
 block discarded – undo
693 711
     if (!empty($taxonomies)) {
694 712
         foreach (geodir_get_posttypes() as $pt) {
695 713
             $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt);
696
-            if (array_intersect($taxonomies, $object_taxonomies))
697
-                $post_type[] = $pt;
714
+            if (array_intersect($taxonomies, $object_taxonomies)) {
715
+                            $post_type[] = $pt;
716
+            }
698 717
         }
699 718
     }
700 719
 
701
-    if (!empty($post_type))
702
-        return $post_type[0];
703
-    else
704
-        return false;
705
-}
720
+    if (!empty($post_type)) {
721
+            return $post_type[0];
722
+    } else {
723
+            return false;
724
+    }
725
+    }
706 726
 
707 727
 if (!function_exists('geodir_custom_taxonomy_walker')) {
708 728
     /**
@@ -758,18 +778,18 @@  discard block
 block discarded – undo
758 778
                 $checked = '';
759 779
 
760 780
                 if (in_array($cat_term->term_id, $search_terms)) {
761
-                    if ($cat_display == 'select' || $cat_display == 'multiselect')
762
-                        $checked = 'selected="selected"';
763
-                    else
764
-                        $checked = 'checked="checked"';
781
+                    if ($cat_display == 'select' || $cat_display == 'multiselect') {
782
+                                            $checked = 'selected="selected"';
783
+                    } else {
784
+                                            $checked = 'checked="checked"';
785
+                    }
765 786
                 }
766 787
 
767
-                if ($cat_display == 'radio')
768
-                    $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="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . ucfirst($cat_term->name) . '</span>';
769
-                elseif ($cat_display == 'select' || $cat_display == 'multiselect')
770
-                    $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . ucfirst($cat_term->name) . '</option>';
771
-
772
-                else {
788
+                if ($cat_display == 'radio') {
789
+                                    $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="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . ucfirst($cat_term->name) . '</span>';
790
+                } elseif ($cat_display == 'select' || $cat_display == 'multiselect') {
791
+                                    $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . ucfirst($cat_term->name) . '</option>';
792
+                } else {
773 793
                     $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="' . ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . ucfirst($cat_term->name) . '</span>';
774 794
                 }
775 795
 
@@ -778,8 +798,9 @@  discard block
 block discarded – undo
778 798
 
779 799
             }
780 800
 
781
-            if ($cat_display == 'checkbox' || $cat_display == 'radio')
782
-                $out .= '</div>';
801
+            if ($cat_display == 'checkbox' || $cat_display == 'radio') {
802
+                            $out .= '</div>';
803
+            }
783 804
 
784 805
             return $out;
785 806
         }
@@ -805,18 +826,21 @@  discard block
 block discarded – undo
805 826
         global $exclude_cats, $gd_session;
806 827
 
807 828
         $cat_exclude = '';
808
-        if (is_array($exclude_cats) && !empty($exclude_cats))
809
-            $cat_exclude = serialize($exclude_cats);
829
+        if (is_array($exclude_cats) && !empty($exclude_cats)) {
830
+                    $cat_exclude = serialize($exclude_cats);
831
+        }
810 832
 
811 833
         if (isset($_REQUEST['backandedit'])) {
812 834
             $post = (object)$gd_session->get('listing');
813 835
 
814
-            if (!is_array($post->post_category[$cat_taxonomy]))
815
-                $post_category = $post->post_category[$cat_taxonomy];
836
+            if (!is_array($post->post_category[$cat_taxonomy])) {
837
+                            $post_category = $post->post_category[$cat_taxonomy];
838
+            }
816 839
 
817 840
             $post_categories = $post->post_category_str;
818
-            if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories))
819
-                $post_category_str = $post_categories[$cat_taxonomy];
841
+            if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
842
+                            $post_category_str = $post_categories[$cat_taxonomy];
843
+            }
820 844
 
821 845
         } elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) {
822 846
             global $post;
@@ -1007,8 +1031,9 @@  discard block
 block discarded – undo
1007 1031
         if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
1008 1032
             $post_cat_str = $post_categories[$cat_taxonomy];
1009 1033
             $post_cat_array = explode("#", $post_cat_str);
1010
-            if (count($post_cat_array) >= $cat_limit && $cat_limit != 0)
1011
-                $style = "display:none;";
1034
+            if (count($post_cat_array) >= $cat_limit && $cat_limit != 0) {
1035
+                            $style = "display:none;";
1036
+            }
1012 1037
         }
1013 1038
         ?>
1014 1039
         <div class="main_cat_list" style=" <?php if (isset($style)) {
@@ -1043,7 +1068,7 @@  discard block
 block discarded – undo
1043 1068
 
1044 1069
         if(is_array( $exclude_cats)){
1045 1070
             $exclude_cats = array_map( 'intval', $exclude_cats );
1046
-        }else{
1071
+        } else{
1047 1072
             $exclude_cats = intval($exclude_cats);
1048 1073
         }
1049 1074
 
@@ -1073,7 +1098,10 @@  discard block
 block discarded – undo
1073 1098
 
1074 1099
             <div class="post_default_category">
1075 1100
                 <input type="radio" name="post_default_category" value="<?php echo $main_cat->term_id;?>"
1076
-                       onchange="update_listing_cat()" <?php if ($default) echo ' checked="checked" ';?>   />
1101
+                       onchange="update_listing_cat()" <?php if ($default) {
1102
+	echo ' checked="checked" ';
1103
+}
1104
+?>   />
1077 1105
         <span> 
1078 1106
         <?php printf(__('Set %s as default category', 'geodirectory'), geodir_ucwords($main_cat->name));?>
1079 1107
         </span>
@@ -1173,8 +1201,9 @@  discard block
 block discarded – undo
1173 1201
         $onchange = ' onchange="show_subcatlist(this.value, this)" ';
1174 1202
 
1175 1203
         $option_selected = '';
1176
-        if (!$selected)
1177
-            $option_slected = ' selected="selected" ';
1204
+        if (!$selected) {
1205
+                    $option_slected = ' selected="selected" ';
1206
+        }
1178 1207
 
1179 1208
         echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >';
1180 1209
 
@@ -1182,8 +1211,9 @@  discard block
 block discarded – undo
1182 1211
 
1183 1212
         foreach ($cat_terms as $cat_term) {
1184 1213
             $option_selected = '';
1185
-            if ($selected == $cat_term->term_id)
1186
-                $option_selected = ' selected="selected" ';
1214
+            if ($selected == $cat_term->term_id) {
1215
+                            $option_selected = ' selected="selected" ';
1216
+            }
1187 1217
 
1188 1218
             // Count child terms
1189 1219
             $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) );
@@ -1248,8 +1278,9 @@  discard block
 block discarded – undo
1248 1278
 
1249 1279
     $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico';
1250 1280
 
1251
-    if (!$listing_slug = get_option('geodir_listing_prefix'))
1252
-        $listing_slug = 'places';
1281
+    if (!$listing_slug = get_option('geodir_listing_prefix')) {
1282
+            $listing_slug = 'places';
1283
+    }
1253 1284
 
1254 1285
     /**
1255 1286
      * Taxonomies
@@ -1399,7 +1430,7 @@  discard block
 block discarded – undo
1399 1430
     //print_r( $segments);
1400 1431
     if($gd_wpml_get_languages){
1401 1432
         $langs = $gd_wpml_get_languages;
1402
-    }else{
1433
+    } else{
1403 1434
         global $sitepress;
1404 1435
         $gd_wpml_get_languages = $sitepress->get_active_languages();
1405 1436
     }
@@ -1552,8 +1583,9 @@  discard block
 block discarded – undo
1552 1583
                             'city_slug' => $post->city_slug
1553 1584
                         );
1554 1585
 
1555
-                    } else
1556
-                        $post_location = geodir_get_location();
1586
+                    } else {
1587
+                                            $post_location = geodir_get_location();
1588
+                    }
1557 1589
 
1558 1590
 
1559 1591
                 } else {
@@ -1582,8 +1614,9 @@  discard block
 block discarded – undo
1582 1614
                             );
1583 1615
 
1584 1616
                         }
1585
-                    } else
1586
-                        $post_location = geodir_get_location();
1617
+                    } else {
1618
+                                            $post_location = geodir_get_location();
1619
+                    }
1587 1620
                 }
1588 1621
 
1589 1622
 
@@ -1626,8 +1659,9 @@  discard block
 block discarded – undo
1626 1659
                         $post_terms = $post_terms[0];
1627 1660
                     }
1628 1661
 
1629
-                    if (!$post_terms)
1630
-                        $post_terms = geodir_get_post_meta($post->ID, 'default_category', true);
1662
+                    if (!$post_terms) {
1663
+                                            $post_terms = geodir_get_post_meta($post->ID, 'default_category', true);
1664
+                    }
1631 1665
 
1632 1666
                     if (!$post_terms) {
1633 1667
                         $post_terms = geodir_get_post_meta($post->ID, $taxonomies, true);
@@ -1641,8 +1675,9 @@  discard block
 block discarded – undo
1641 1675
 
1642 1676
                 $term = get_term_by('id', $post_terms, $taxonomies);
1643 1677
 
1644
-                if (!empty($term))
1645
-                    $term_request = $term->slug;
1678
+                if (!empty($term)) {
1679
+                                    $term_request = $term->slug;
1680
+                }
1646 1681
                 //$term_request = $term->slug.'/';
1647 1682
             }
1648 1683
 
@@ -1657,15 +1692,20 @@  discard block
 block discarded – undo
1657 1692
                 $request_term .= $term_request;
1658 1693
 
1659 1694
             } else {
1660
-                if (isset($location_request) && $location_request != '') $request_term = $location_request;
1695
+                if (isset($location_request) && $location_request != '') {
1696
+                	$request_term = $location_request;
1697
+                }
1661 1698
 
1662
-                if (isset($term_request) && $term_request != '') $request_term .= $term_request;
1699
+                if (isset($term_request) && $term_request != '') {
1700
+                	$request_term .= $term_request;
1701
+                }
1663 1702
             }
1664 1703
             $request_term = trim($request_term, '/');
1665
-            if (!empty($request_term))
1666
-                $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1667
-            else
1668
-                $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1704
+            if (!empty($request_term)) {
1705
+                            $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1706
+            } else {
1707
+                            $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
1708
+            }
1669 1709
             //echo $post_link ;
1670 1710
         }
1671 1711
         // temp cache the permalink
@@ -1857,11 +1897,12 @@  discard block
 block discarded – undo
1857 1897
     
1858 1898
     $label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name;
1859 1899
     
1860
-    if ($echo)
1861
-        echo $label;
1862
-    else
1863
-        return $label;
1864
-}
1900
+    if ($echo) {
1901
+            echo $label;
1902
+    } else {
1903
+            return $label;
1904
+    }
1905
+    }
1865 1906
 
1866 1907
 /**
1867 1908
  * Print or Get post type plural label.
@@ -1877,18 +1918,20 @@  discard block
 block discarded – undo
1877 1918
 function get_post_type_plural_label($post_type, $echo = false, $translate = false) {
1878 1919
     $all_postypes = geodir_get_posttypes();
1879 1920
 
1880
-    if (!in_array($post_type, $all_postypes))
1881
-        return false;
1921
+    if (!in_array($post_type, $all_postypes)) {
1922
+            return false;
1923
+    }
1882 1924
 
1883 1925
     $obj_post_type = get_post_type_object($post_type);
1884 1926
     
1885 1927
     $label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name;
1886 1928
     
1887
-    if ($echo)
1888
-        echo $label;
1889
-    else
1890
-        return $label;
1891
-}
1929
+    if ($echo) {
1930
+            echo $label;
1931
+    } else {
1932
+            return $label;
1933
+    }
1934
+    }
1892 1935
 
1893 1936
 /**
1894 1937
  * Checks whether a term exists or not.
@@ -1911,19 +1954,22 @@  discard block
 block discarded – undo
1911 1954
     $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 ";
1912 1955
 
1913 1956
     if (is_int($term)) {
1914
-        if (0 == $term)
1915
-            return 0;
1957
+        if (0 == $term) {
1958
+                    return 0;
1959
+        }
1916 1960
         $where = 't.term_id = %d';
1917
-        if (!empty($taxonomy))
1918
-            return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1919
-        else
1920
-            return $wpdb->get_var($wpdb->prepare($select . $where, $term));
1961
+        if (!empty($taxonomy)) {
1962
+                    return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
1963
+        } else {
1964
+                    return $wpdb->get_var($wpdb->prepare($select . $where, $term));
1965
+        }
1921 1966
     }
1922 1967
 
1923 1968
     $term = trim(wp_unslash($term));
1924 1969
 
1925
-    if ('' === $slug = sanitize_title($term))
1926
-        return 0;
1970
+    if ('' === $slug = sanitize_title($term)) {
1971
+            return 0;
1972
+    }
1927 1973
 
1928 1974
     $where = 't.slug = %s';
1929 1975
 
@@ -1940,14 +1986,16 @@  discard block
 block discarded – undo
1940 1986
         $where_fields[] = $taxonomy;
1941 1987
 
1942 1988
 
1943
-        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))
1944
-            return $result;
1989
+        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)) {
1990
+                    return $result;
1991
+        }
1945 1992
 
1946 1993
         return false;
1947 1994
     }
1948 1995
 
1949
-    if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields)))
1950
-        return $result;
1996
+    if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields))) {
1997
+            return $result;
1998
+    }
1951 1999
 
1952 2000
     return false;
1953 2001
 }
Please login to merge, or discard this patch.