@@ -39,8 +39,9 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -410,17 +417,20 @@ discard block |
||
| 410 | 417 | } |
| 411 | 418 | |
| 412 | 419 | if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
|
| 413 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 414 | - $geodir_post_type = get_post_type((int)$_REQUEST['pid']); |
|
| 415 | - elseif (isset($_REQUEST['listing_type'])) |
|
| 416 | - $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
| 420 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
|
| 421 | + $geodir_post_type = get_post_type((int)$_REQUEST['pid']); |
|
| 422 | + } elseif (isset($_REQUEST['listing_type'])) { |
|
| 423 | + $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
| 424 | + } |
|
| 417 | 425 | } |
| 418 | 426 | |
| 419 | - if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype']))
|
|
| 420 | - $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
| 427 | + if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype'])) { |
|
| 428 | + $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
| 429 | + } |
|
| 421 | 430 | |
| 422 | - if (is_tax()) |
|
| 423 | - $geodir_post_type = geodir_get_taxonomy_posttype(); |
|
| 431 | + if (is_tax()) { |
|
| 432 | + $geodir_post_type = geodir_get_taxonomy_posttype(); |
|
| 433 | + } |
|
| 424 | 434 | |
| 425 | 435 | // Retrive post type for map marker html ajax request on preview page. |
| 426 | 436 | if (empty($geodir_post_type) && defined('DOING_AJAX') && !empty($post)) {
|
@@ -434,8 +444,9 @@ discard block |
||
| 434 | 444 | $all_postypes = geodir_get_posttypes(); |
| 435 | 445 | $all_postypes = stripslashes_deep($all_postypes); |
| 436 | 446 | |
| 437 | - if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes)) |
|
| 438 | - $geodir_post_type = ''; |
|
| 447 | + if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes)) { |
|
| 448 | + $geodir_post_type = ''; |
|
| 449 | + } |
|
| 439 | 450 | |
| 440 | 451 | if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){
|
| 441 | 452 | $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
@@ -520,11 +531,12 @@ discard block |
||
| 520 | 531 | endswitch; |
| 521 | 532 | } |
| 522 | 533 | |
| 523 | - if (!empty($post_types)) |
|
| 524 | - return $post_types; |
|
| 525 | - else |
|
| 526 | - return array(); |
|
| 527 | -} |
|
| 534 | + if (!empty($post_types)) { |
|
| 535 | + return $post_types; |
|
| 536 | + } else { |
|
| 537 | + return array(); |
|
| 538 | + } |
|
| 539 | + } |
|
| 528 | 540 | |
| 529 | 541 | /** |
| 530 | 542 | * Get Custom Post Type info. |
@@ -541,9 +553,10 @@ discard block |
||
| 541 | 553 | $post_types = stripslashes_deep($post_types); |
| 542 | 554 | if (!empty($post_types) && $post_type != '') {
|
| 543 | 555 | return $post_types[$post_type]; |
| 544 | - } else |
|
| 545 | - return false; |
|
| 546 | -} |
|
| 556 | + } else { |
|
| 557 | + return false; |
|
| 558 | + } |
|
| 559 | + } |
|
| 547 | 560 | |
| 548 | 561 | if (!function_exists('geodir_get_taxonomies')) {
|
| 549 | 562 | /** |
@@ -629,10 +642,11 @@ discard block |
||
| 629 | 642 | . geodir_utf8_ucfirst($category_obj->name) . '</option>'; |
| 630 | 643 | } |
| 631 | 644 | |
| 632 | - if ($echo) |
|
| 633 | - echo $html; |
|
| 634 | - else |
|
| 635 | - return $html; |
|
| 645 | + if ($echo) { |
|
| 646 | + echo $html; |
|
| 647 | + } else { |
|
| 648 | + return $html; |
|
| 649 | + } |
|
| 636 | 650 | } |
| 637 | 651 | } |
| 638 | 652 | |
@@ -666,11 +680,12 @@ discard block |
||
| 666 | 680 | |
| 667 | 681 | } |
| 668 | 682 | |
| 669 | - if (!empty($listing_slug)) |
|
| 670 | - return $listing_slug; |
|
| 671 | - else |
|
| 672 | - return false; |
|
| 673 | -} |
|
| 683 | + if (!empty($listing_slug)) { |
|
| 684 | + return $listing_slug; |
|
| 685 | + } else { |
|
| 686 | + return false; |
|
| 687 | + } |
|
| 688 | + } |
|
| 674 | 689 | |
| 675 | 690 | |
| 676 | 691 | /** |
@@ -701,16 +716,18 @@ discard block |
||
| 701 | 716 | if (!empty($taxonomies)) {
|
| 702 | 717 | foreach (geodir_get_posttypes() as $pt) {
|
| 703 | 718 | $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt); |
| 704 | - if (array_intersect($taxonomies, $object_taxonomies)) |
|
| 705 | - $post_type[] = $pt; |
|
| 719 | + if (array_intersect($taxonomies, $object_taxonomies)) { |
|
| 720 | + $post_type[] = $pt; |
|
| 721 | + } |
|
| 706 | 722 | } |
| 707 | 723 | } |
| 708 | 724 | |
| 709 | - if (!empty($post_type)) |
|
| 710 | - return $post_type[0]; |
|
| 711 | - else |
|
| 712 | - return false; |
|
| 713 | -} |
|
| 725 | + if (!empty($post_type)) { |
|
| 726 | + return $post_type[0]; |
|
| 727 | + } else { |
|
| 728 | + return false; |
|
| 729 | + } |
|
| 730 | + } |
|
| 714 | 731 | |
| 715 | 732 | if (!function_exists('geodir_custom_taxonomy_walker')) {
|
| 716 | 733 | /** |
@@ -766,18 +783,18 @@ discard block |
||
| 766 | 783 | $checked = ''; |
| 767 | 784 | |
| 768 | 785 | if (in_array($cat_term->term_id, $search_terms)) {
|
| 769 | - if ($cat_display == 'select' || $cat_display == 'multiselect') |
|
| 770 | - $checked = 'selected="selected"'; |
|
| 771 | - else |
|
| 772 | - $checked = 'checked="checked"'; |
|
| 786 | + if ($cat_display == 'select' || $cat_display == 'multiselect') { |
|
| 787 | + $checked = 'selected="selected"'; |
|
| 788 | + } else { |
|
| 789 | + $checked = 'checked="checked"'; |
|
| 790 | + } |
|
| 773 | 791 | } |
| 774 | 792 | |
| 775 | - if ($cat_display == 'radio') |
|
| 776 | - $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>'; |
|
| 777 | - elseif ($cat_display == 'select' || $cat_display == 'multiselect') |
|
| 778 | - $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>'; |
|
| 779 | - |
|
| 780 | - else {
|
|
| 793 | + if ($cat_display == 'radio') { |
|
| 794 | + $out .= '<span style="display:block" ><input type="radio" field_type="radio" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>'; |
|
| 795 | + } elseif ($cat_display == 'select' || $cat_display == 'multiselect') { |
|
| 796 | + $out .= '<option ' . $main_list_class . ' style="margin-left:' . $p . 'px;" alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</option>'; |
|
| 797 | + } else {
|
|
| 781 | 798 | $out .= '<span style="display:block"><input style="display:inline-block" type="checkbox" field_type="checkbox" name="post_category[' . $cat_term->taxonomy . '][]" ' . $main_list_class . ' alt="' . $cat_term->taxonomy . '" title="' . geodir_utf8_ucfirst($cat_term->name) . '" value="' . $cat_term->term_id . '" ' . $checked . $onchange . ' id="gd-cat-' . $cat_term->term_id . '" >' . $term_check . geodir_utf8_ucfirst($cat_term->name) . '</span>'; |
| 782 | 799 | } |
| 783 | 800 | |
@@ -786,8 +803,9 @@ discard block |
||
| 786 | 803 | |
| 787 | 804 | } |
| 788 | 805 | |
| 789 | - if ($cat_display == 'checkbox' || $cat_display == 'radio') |
|
| 790 | - $out .= '</div>'; |
|
| 806 | + if ($cat_display == 'checkbox' || $cat_display == 'radio') { |
|
| 807 | + $out .= '</div>'; |
|
| 808 | + } |
|
| 791 | 809 | |
| 792 | 810 | return $out; |
| 793 | 811 | } |
@@ -813,18 +831,21 @@ discard block |
||
| 813 | 831 | global $exclude_cats, $gd_session; |
| 814 | 832 | |
| 815 | 833 | $cat_exclude = ''; |
| 816 | - if (is_array($exclude_cats) && !empty($exclude_cats)) |
|
| 817 | - $cat_exclude = serialize($exclude_cats); |
|
| 834 | + if (is_array($exclude_cats) && !empty($exclude_cats)) { |
|
| 835 | + $cat_exclude = serialize($exclude_cats); |
|
| 836 | + } |
|
| 818 | 837 | |
| 819 | 838 | if (isset($_REQUEST['backandedit'])) {
|
| 820 | 839 | $post = (object)$gd_session->get('listing');
|
| 821 | 840 | |
| 822 | - if (!is_array($post->post_category[$cat_taxonomy])) |
|
| 823 | - $post_category = $post->post_category[$cat_taxonomy]; |
|
| 841 | + if (!is_array($post->post_category[$cat_taxonomy])) { |
|
| 842 | + $post_category = $post->post_category[$cat_taxonomy]; |
|
| 843 | + } |
|
| 824 | 844 | |
| 825 | 845 | $post_categories = $post->post_category_str; |
| 826 | - if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) |
|
| 827 | - $post_category_str = $post_categories[$cat_taxonomy]; |
|
| 846 | + if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) { |
|
| 847 | + $post_category_str = $post_categories[$cat_taxonomy]; |
|
| 848 | + } |
|
| 828 | 849 | |
| 829 | 850 | } elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) {
|
| 830 | 851 | global $post; |
@@ -1015,8 +1036,9 @@ discard block |
||
| 1015 | 1036 | if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
|
| 1016 | 1037 | $post_cat_str = $post_categories[$cat_taxonomy]; |
| 1017 | 1038 | $post_cat_array = explode("#", $post_cat_str);
|
| 1018 | - if (count($post_cat_array) >= $cat_limit && $cat_limit != 0) |
|
| 1019 | - $style = "display:none;"; |
|
| 1039 | + if (count($post_cat_array) >= $cat_limit && $cat_limit != 0) { |
|
| 1040 | + $style = "display:none;"; |
|
| 1041 | + } |
|
| 1020 | 1042 | } |
| 1021 | 1043 | ?> |
| 1022 | 1044 | <div class="main_cat_list" style=" <?php if (isset($style)) {
|
@@ -1051,7 +1073,7 @@ discard block |
||
| 1051 | 1073 | |
| 1052 | 1074 | if(is_array( $exclude_cats)){
|
| 1053 | 1075 | $exclude_cats = array_map( 'intval', $exclude_cats ); |
| 1054 | - }else{
|
|
| 1076 | + } else{
|
|
| 1055 | 1077 | $exclude_cats = intval($exclude_cats); |
| 1056 | 1078 | } |
| 1057 | 1079 | |
@@ -1081,7 +1103,10 @@ discard block |
||
| 1081 | 1103 | |
| 1082 | 1104 | <div class="post_default_category"> |
| 1083 | 1105 | <input type="radio" name="post_default_category" value="<?php echo $main_cat->term_id;?>" |
| 1084 | - onchange="update_listing_cat()" <?php if ($default) echo ' checked="checked" ';?> /> |
|
| 1106 | + onchange="update_listing_cat()" <?php if ($default) { |
|
| 1107 | + echo ' checked="checked" '; |
|
| 1108 | +} |
|
| 1109 | +?> /> |
|
| 1085 | 1110 | <span> |
| 1086 | 1111 | <?php printf(__('Set %s as default category', 'geodirectory'), geodir_ucwords($main_cat->name));?>
|
| 1087 | 1112 | </span> |
@@ -1181,8 +1206,9 @@ discard block |
||
| 1181 | 1206 | $onchange = ' onchange="show_subcatlist(this.value, this)" '; |
| 1182 | 1207 | |
| 1183 | 1208 | $option_selected = ''; |
| 1184 | - if (!$selected) |
|
| 1185 | - $option_slected = ' selected="selected" '; |
|
| 1209 | + if (!$selected) { |
|
| 1210 | + $option_slected = ' selected="selected" '; |
|
| 1211 | + } |
|
| 1186 | 1212 | |
| 1187 | 1213 | echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >'; |
| 1188 | 1214 | |
@@ -1190,8 +1216,9 @@ discard block |
||
| 1190 | 1216 | |
| 1191 | 1217 | foreach ($cat_terms as $cat_term) {
|
| 1192 | 1218 | $option_selected = ''; |
| 1193 | - if ($selected == $cat_term->term_id) |
|
| 1194 | - $option_selected = ' selected="selected" '; |
|
| 1219 | + if ($selected == $cat_term->term_id) { |
|
| 1220 | + $option_selected = ' selected="selected" '; |
|
| 1221 | + } |
|
| 1195 | 1222 | |
| 1196 | 1223 | // Count child terms |
| 1197 | 1224 | $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) ); |
@@ -1256,8 +1283,9 @@ discard block |
||
| 1256 | 1283 | |
| 1257 | 1284 | $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico'; |
| 1258 | 1285 | |
| 1259 | - if (!$listing_slug = get_option('geodir_listing_prefix'))
|
|
| 1260 | - $listing_slug = 'places'; |
|
| 1286 | + if (!$listing_slug = get_option('geodir_listing_prefix')) { |
|
| 1287 | + $listing_slug = 'places'; |
|
| 1288 | + } |
|
| 1261 | 1289 | |
| 1262 | 1290 | /** |
| 1263 | 1291 | * Taxonomies |
@@ -1573,8 +1601,9 @@ discard block |
||
| 1573 | 1601 | 'city_slug' => $post->city_slug |
| 1574 | 1602 | ); |
| 1575 | 1603 | |
| 1576 | - } else |
|
| 1577 | - $post_location = geodir_get_location(); |
|
| 1604 | + } else { |
|
| 1605 | + $post_location = geodir_get_location(); |
|
| 1606 | + } |
|
| 1578 | 1607 | |
| 1579 | 1608 | |
| 1580 | 1609 | } else {
|
@@ -1603,8 +1632,9 @@ discard block |
||
| 1603 | 1632 | ); |
| 1604 | 1633 | |
| 1605 | 1634 | } |
| 1606 | - } else |
|
| 1607 | - $post_location = geodir_get_location(); |
|
| 1635 | + } else { |
|
| 1636 | + $post_location = geodir_get_location(); |
|
| 1637 | + } |
|
| 1608 | 1638 | } |
| 1609 | 1639 | |
| 1610 | 1640 | |
@@ -1643,16 +1673,17 @@ discard block |
||
| 1643 | 1673 | |
| 1644 | 1674 | if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
|
| 1645 | 1675 | $post_terms = absint($_POST['post_default_category']); |
| 1646 | - }elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
|
|
| 1676 | + } elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
|
|
| 1647 | 1677 | $post_terms = is_array($_POST['post_category'][$taxonomies]) ? $_POST['post_category'][$taxonomies] : explode(",", trim($_POST['post_category'][$taxonomies], ","));
|
| 1648 | 1678 | $post_terms = !empty($post_terms) ? absint($post_terms[0]) : 0; |
| 1649 | - }elseif (isset($post->{$taxonomies})) {
|
|
| 1679 | + } elseif (isset($post->{$taxonomies})) {
|
|
| 1650 | 1680 | $post_terms = explode(",", trim($post->{$taxonomies}, ","));
|
| 1651 | 1681 | $post_terms = $post_terms[0]; |
| 1652 | 1682 | } |
| 1653 | 1683 | |
| 1654 | - if (!$post_terms) |
|
| 1655 | - $post_terms = geodir_get_post_meta($post->ID, 'default_category', true); |
|
| 1684 | + if (!$post_terms) { |
|
| 1685 | + $post_terms = geodir_get_post_meta($post->ID, 'default_category', true); |
|
| 1686 | + } |
|
| 1656 | 1687 | |
| 1657 | 1688 | if (!$post_terms) {
|
| 1658 | 1689 | $post_terms = geodir_get_post_meta($post->ID, $taxonomies, true); |
@@ -1666,8 +1697,9 @@ discard block |
||
| 1666 | 1697 | |
| 1667 | 1698 | $term = get_term_by('id', $post_terms, $taxonomies);
|
| 1668 | 1699 | |
| 1669 | - if (!empty($term)) |
|
| 1670 | - $term_request = $term->slug; |
|
| 1700 | + if (!empty($term)) { |
|
| 1701 | + $term_request = $term->slug; |
|
| 1702 | + } |
|
| 1671 | 1703 | //$term_request = $term->slug.'/'; |
| 1672 | 1704 | } |
| 1673 | 1705 | |
@@ -1682,9 +1714,13 @@ discard block |
||
| 1682 | 1714 | $request_term .= $term_request; |
| 1683 | 1715 | |
| 1684 | 1716 | } else {
|
| 1685 | - if (isset($location_request) && $location_request != '') $request_term = $location_request; |
|
| 1717 | + if (isset($location_request) && $location_request != '') { |
|
| 1718 | + $request_term = $location_request; |
|
| 1719 | + } |
|
| 1686 | 1720 | |
| 1687 | - if (isset($term_request) && $term_request != '') $request_term .= $term_request; |
|
| 1721 | + if (isset($term_request) && $term_request != '') { |
|
| 1722 | + $request_term .= $term_request; |
|
| 1723 | + } |
|
| 1688 | 1724 | } |
| 1689 | 1725 | $request_term = trim($request_term, '/'); |
| 1690 | 1726 | |
@@ -1693,10 +1729,11 @@ discard block |
||
| 1693 | 1729 | $post_link = str_replace('%gd_taxonomy%/', '', $post_link);
|
| 1694 | 1730 | } |
| 1695 | 1731 | |
| 1696 | - if (!empty($request_term)) |
|
| 1697 | - $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
|
|
| 1698 | - else |
|
| 1699 | - $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
|
|
| 1732 | + if (!empty($request_term)) { |
|
| 1733 | + $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link); |
|
| 1734 | + } else { |
|
| 1735 | + $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link); |
|
| 1736 | + } |
|
| 1700 | 1737 | //echo $post_link ; |
| 1701 | 1738 | } |
| 1702 | 1739 | // temp cache the permalink |
@@ -1939,11 +1976,12 @@ discard block |
||
| 1939 | 1976 | |
| 1940 | 1977 | $label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name; |
| 1941 | 1978 | |
| 1942 | - if ($echo) |
|
| 1943 | - echo $label; |
|
| 1944 | - else |
|
| 1945 | - return $label; |
|
| 1946 | -} |
|
| 1979 | + if ($echo) { |
|
| 1980 | + echo $label; |
|
| 1981 | + } else { |
|
| 1982 | + return $label; |
|
| 1983 | + } |
|
| 1984 | + } |
|
| 1947 | 1985 | |
| 1948 | 1986 | /** |
| 1949 | 1987 | * Print or Get post type plural label. |
@@ -1959,18 +1997,20 @@ discard block |
||
| 1959 | 1997 | function get_post_type_plural_label($post_type, $echo = false, $translate = false) {
|
| 1960 | 1998 | $all_postypes = geodir_get_posttypes(); |
| 1961 | 1999 | |
| 1962 | - if (!in_array($post_type, $all_postypes)) |
|
| 1963 | - return false; |
|
| 2000 | + if (!in_array($post_type, $all_postypes)) { |
|
| 2001 | + return false; |
|
| 2002 | + } |
|
| 1964 | 2003 | |
| 1965 | 2004 | $obj_post_type = get_post_type_object($post_type); |
| 1966 | 2005 | |
| 1967 | 2006 | $label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name; |
| 1968 | 2007 | |
| 1969 | - if ($echo) |
|
| 1970 | - echo $label; |
|
| 1971 | - else |
|
| 1972 | - return $label; |
|
| 1973 | -} |
|
| 2008 | + if ($echo) { |
|
| 2009 | + echo $label; |
|
| 2010 | + } else { |
|
| 2011 | + return $label; |
|
| 2012 | + } |
|
| 2013 | + } |
|
| 1974 | 2014 | |
| 1975 | 2015 | /** |
| 1976 | 2016 | * Checks whether a term exists or not. |
@@ -1993,19 +2033,22 @@ discard block |
||
| 1993 | 2033 | $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 "; |
| 1994 | 2034 | |
| 1995 | 2035 | if (is_int($term)) {
|
| 1996 | - if (0 == $term) |
|
| 1997 | - return 0; |
|
| 2036 | + if (0 == $term) { |
|
| 2037 | + return 0; |
|
| 2038 | + } |
|
| 1998 | 2039 | $where = 't.term_id = %d'; |
| 1999 | - if (!empty($taxonomy)) |
|
| 2000 | - return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); |
|
| 2001 | - else |
|
| 2002 | - return $wpdb->get_var($wpdb->prepare($select . $where, $term)); |
|
| 2040 | + if (!empty($taxonomy)) { |
|
| 2041 | + return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); |
|
| 2042 | + } else { |
|
| 2043 | + return $wpdb->get_var($wpdb->prepare($select . $where, $term)); |
|
| 2044 | + } |
|
| 2003 | 2045 | } |
| 2004 | 2046 | |
| 2005 | 2047 | $term = trim(wp_unslash($term)); |
| 2006 | 2048 | |
| 2007 | - if ('' === $slug = sanitize_title($term))
|
|
| 2008 | - return 0; |
|
| 2049 | + if ('' === $slug = sanitize_title($term)) { |
|
| 2050 | + return 0; |
|
| 2051 | + } |
|
| 2009 | 2052 | |
| 2010 | 2053 | $where = 't.slug = %s'; |
| 2011 | 2054 | |
@@ -2022,14 +2065,16 @@ discard block |
||
| 2022 | 2065 | $where_fields[] = $taxonomy; |
| 2023 | 2066 | |
| 2024 | 2067 | |
| 2025 | - 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))
|
|
| 2026 | - return $result; |
|
| 2068 | + 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)) { |
|
| 2069 | + return $result; |
|
| 2070 | + } |
|
| 2027 | 2071 | |
| 2028 | 2072 | return false; |
| 2029 | 2073 | } |
| 2030 | 2074 | |
| 2031 | - if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields)))
|
|
| 2032 | - return $result; |
|
| 2075 | + if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields))) { |
|
| 2076 | + return $result; |
|
| 2077 | + } |
|
| 2033 | 2078 | |
| 2034 | 2079 | return false; |
| 2035 | 2080 | } |
@@ -16,7 +16,9 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | function geodir_session_start() |
| 18 | 18 | {
|
| 19 | - if (!session_id()) session_start(); |
|
| 19 | + if (!session_id()) { |
|
| 20 | + session_start(); |
|
| 21 | + } |
|
| 20 | 22 | global $geodir_add_location_url; |
| 21 | 23 | |
| 22 | 24 | $geodir_add_location_url = NULL; |
@@ -86,7 +88,9 @@ discard block |
||
| 86 | 88 | |
| 87 | 89 | if ((is_search() && isset($_REQUEST['geodir_search']) && $_REQUEST['geodir_search'] != '')): |
| 88 | 90 | |
| 89 | - if (isset($_REQUEST['scat']) && $_REQUEST['scat'] == 'all') $_REQUEST['scat'] = ''; |
|
| 91 | + if (isset($_REQUEST['scat']) && $_REQUEST['scat'] == 'all') { |
|
| 92 | + $_REQUEST['scat'] = ''; |
|
| 93 | + } |
|
| 90 | 94 | //if(isset($_REQUEST['s']) && $_REQUEST['s'] == '+') $_REQUEST['s'] = ''; |
| 91 | 95 | |
| 92 | 96 | if (isset($_REQUEST['sdist'])) {
|
@@ -198,8 +202,9 @@ discard block |
||
| 198 | 202 | add_filter('posts_fields', 'geodir_posts_fields', 1);
|
| 199 | 203 | add_filter('posts_join', 'geodir_posts_join', 1);
|
| 200 | 204 | geodir_post_where(); |
| 201 | - if (!is_admin()) |
|
| 202 | - add_filter('posts_orderby', 'geodir_posts_orderby', 1);
|
|
| 205 | + if (!is_admin()) { |
|
| 206 | + add_filter('posts_orderby', 'geodir_posts_orderby', 1); |
|
| 207 | + } |
|
| 203 | 208 | |
| 204 | 209 | // advanced filter for popular post view widget |
| 205 | 210 | global $wp_query; |
@@ -349,8 +354,9 @@ discard block |
||
| 349 | 354 | $sort_by = ''; |
| 350 | 355 | $orderby = ' '; |
| 351 | 356 | |
| 352 | - if (get_query_var('order_by'))
|
|
| 353 | - $sort_by = get_query_var('order_by');
|
|
| 357 | + if (get_query_var('order_by')) { |
|
| 358 | + $sort_by = get_query_var('order_by'); |
|
| 359 | + } |
|
| 354 | 360 | |
| 355 | 361 | /*if(isset($wp_query->tax_query->queries) && $wp_query->tax_query->queries){
|
| 356 | 362 | $current_term = $wp_query->get_queried_object(); |
@@ -370,14 +376,16 @@ discard block |
||
| 370 | 376 | $orderby .= " distance,"; |
| 371 | 377 | } |
| 372 | 378 | |
| 373 | - if (isset($_REQUEST['sort_by']) && $_REQUEST['sort_by'] != '' && is_main_query()) |
|
| 374 | - $sort_by = esc_attr($_REQUEST['sort_by']); |
|
| 379 | + if (isset($_REQUEST['sort_by']) && $_REQUEST['sort_by'] != '' && is_main_query()) { |
|
| 380 | + $sort_by = esc_attr($_REQUEST['sort_by']); |
|
| 381 | + } |
|
| 375 | 382 | |
| 376 | 383 | |
| 377 | 384 | if ($sort_by == '') {
|
| 378 | 385 | $default_sort = geodir_get_posts_default_sort($geodir_post_type); |
| 379 | - if (!empty($default_sort)) |
|
| 380 | - $sort_by = $default_sort; |
|
| 386 | + if (!empty($default_sort)) { |
|
| 387 | + $sort_by = $default_sort; |
|
| 388 | + } |
|
| 381 | 389 | } |
| 382 | 390 | |
| 383 | 391 | /* |
@@ -562,7 +570,7 @@ discard block |
||
| 562 | 570 | $orderby = " (( $avg_num_votes * $avg_rating ) + (" . $table . ".rating_count * " . $table . ".overall_rating )) / ( $avg_num_votes + " . $table . ".rating_count ) $order , ";
|
| 563 | 571 | |
| 564 | 572 | //$orderby = " ( " . $table . ".rating_count * " . $table . ".overall_rating ) + (" . $table . ".rating_count * " . $table . ".overall_rating ) / ( " . $table . ".rating_count + " . $table . ".rating_count ) $order , "; // seems to work mostly with no extra overheads
|
| 565 | - }else{
|
|
| 573 | + } else{
|
|
| 566 | 574 | $orderby = " " . $table . "." . $sort_by . " " . $order . ", " . $table . ".rating_count " . $order . ", "; |
| 567 | 575 | } |
| 568 | 576 | |
@@ -607,8 +615,9 @@ discard block |
||
| 607 | 615 | |
| 608 | 616 | add_filter('posts_where', 'searching_filter_where', 1);
|
| 609 | 617 | |
| 610 | - if ($snear != '') |
|
| 611 | - add_filter('posts_where', 'searching_filter_where', 1);
|
|
| 618 | + if ($snear != '') { |
|
| 619 | + add_filter('posts_where', 'searching_filter_where', 1); |
|
| 620 | + } |
|
| 612 | 621 | |
| 613 | 622 | add_filter('posts_orderby', 'geodir_posts_orderby', 1);
|
| 614 | 623 | add_filter( 'posts_where', 'geodir_posts_having', 10000, 2 ); // make sure its the last WHERE param |
@@ -763,10 +772,11 @@ discard block |
||
| 763 | 772 | |
| 764 | 773 | $where = ''; |
| 765 | 774 | $better_search_terms = ''; |
| 766 | - if (isset($_REQUEST['stype'])) |
|
| 767 | - $post_types = esc_attr(wp_strip_all_tags($_REQUEST['stype'])); |
|
| 768 | - else |
|
| 769 | - $post_types = 'gd_place'; |
|
| 775 | + if (isset($_REQUEST['stype'])) { |
|
| 776 | + $post_types = esc_attr(wp_strip_all_tags($_REQUEST['stype'])); |
|
| 777 | + } else { |
|
| 778 | + $post_types = 'gd_place'; |
|
| 779 | + } |
|
| 770 | 780 | |
| 771 | 781 | if ($s != '') {
|
| 772 | 782 | $keywords = explode(" ", $s);
|
@@ -803,7 +813,7 @@ discard block |
||
| 803 | 813 | if($taxonomies) {
|
| 804 | 814 | $taxonomies = implode("','", $taxonomies);
|
| 805 | 815 | $taxonomies = "'" . $taxonomies . "'"; |
| 806 | - }else{$taxonomies='';}
|
|
| 816 | + } else{$taxonomies='';}
|
|
| 807 | 817 | |
| 808 | 818 | $content_where = $terms_where = ''; |
| 809 | 819 | $terms_sql = ''; |
@@ -944,8 +954,9 @@ discard block |
||
| 944 | 954 | $user_fav_posts = geodir_get_user_favourites($user_id); |
| 945 | 955 | $user_fav_posts = !empty($user_fav_posts) && is_array($user_fav_posts) ? implode("','", $user_fav_posts) : '-1';
|
| 946 | 956 | $where .= " AND $wpdb->posts.ID IN ('$user_fav_posts')";
|
| 947 | - } else |
|
| 948 | - $where .= " AND $wpdb->posts.post_author = $user_id"; |
|
| 957 | + } else { |
|
| 958 | + $where .= " AND $wpdb->posts.post_author = $user_id"; |
|
| 959 | + } |
|
| 949 | 960 | |
| 950 | 961 | if ($user_id == (int)get_current_user_id()) {
|
| 951 | 962 | $where .= " AND $wpdb->posts.post_status IN ('publish','draft','pending') ";
|
@@ -1208,7 +1219,7 @@ discard block |
||
| 1208 | 1219 | |
| 1209 | 1220 | if(isset($query->query->gd_is_geodir_page) && $query->query->gd_is_geodir_page) {
|
| 1210 | 1221 | $is_main_query = true; |
| 1211 | - }elseif(isset($query->query['gd_is_geodir_page']) && $query->query['gd_is_geodir_page']) {
|
|
| 1222 | + } elseif(isset($query->query['gd_is_geodir_page']) && $query->query['gd_is_geodir_page']) {
|
|
| 1212 | 1223 | $is_main_query = true; |
| 1213 | 1224 | } |
| 1214 | 1225 | |