@@ -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 | |
@@ -407,17 +414,20 @@ discard block |
||
| 407 | 414 | $geodir_post_type = get_query_var('post_type');
|
| 408 | 415 | |
| 409 | 416 | if (geodir_is_page('add-listing') || geodir_is_page('preview')) {
|
| 410 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 411 | - $geodir_post_type = get_post_type((int)$_REQUEST['pid']); |
|
| 412 | - elseif (isset($_REQUEST['listing_type'])) |
|
| 413 | - $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
| 417 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
|
| 418 | + $geodir_post_type = get_post_type((int)$_REQUEST['pid']); |
|
| 419 | + } elseif (isset($_REQUEST['listing_type'])) { |
|
| 420 | + $geodir_post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
| 421 | + } |
|
| 414 | 422 | } |
| 415 | 423 | |
| 416 | - if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype']))
|
|
| 417 | - $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
| 424 | + if ((geodir_is_page('search') || geodir_is_page('author')) && isset($_REQUEST['stype'])) { |
|
| 425 | + $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
|
| 426 | + } |
|
| 418 | 427 | |
| 419 | - if (is_tax()) |
|
| 420 | - $geodir_post_type = geodir_get_taxonomy_posttype(); |
|
| 428 | + if (is_tax()) { |
|
| 429 | + $geodir_post_type = geodir_get_taxonomy_posttype(); |
|
| 430 | + } |
|
| 421 | 431 | |
| 422 | 432 | // Retrive post type for map marker html ajax request on preview page. |
| 423 | 433 | if (empty($geodir_post_type) && defined('DOING_AJAX') && !empty($post)) {
|
@@ -431,8 +441,9 @@ discard block |
||
| 431 | 441 | $all_postypes = geodir_get_posttypes(); |
| 432 | 442 | $all_postypes = stripslashes_deep($all_postypes); |
| 433 | 443 | |
| 434 | - if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes)) |
|
| 435 | - $geodir_post_type = ''; |
|
| 444 | + if (is_array($all_postypes) && !in_array($geodir_post_type, $all_postypes)) { |
|
| 445 | + $geodir_post_type = ''; |
|
| 446 | + } |
|
| 436 | 447 | |
| 437 | 448 | if( defined( 'DOING_AJAX' ) && isset($_REQUEST['stype'])){
|
| 438 | 449 | $geodir_post_type = sanitize_text_field($_REQUEST['stype']); |
@@ -517,11 +528,12 @@ discard block |
||
| 517 | 528 | endswitch; |
| 518 | 529 | } |
| 519 | 530 | |
| 520 | - if (!empty($post_types)) |
|
| 521 | - return $post_types; |
|
| 522 | - else |
|
| 523 | - return array(); |
|
| 524 | -} |
|
| 531 | + if (!empty($post_types)) { |
|
| 532 | + return $post_types; |
|
| 533 | + } else { |
|
| 534 | + return array(); |
|
| 535 | + } |
|
| 536 | + } |
|
| 525 | 537 | |
| 526 | 538 | /** |
| 527 | 539 | * Get Custom Post Type info. |
@@ -538,9 +550,10 @@ discard block |
||
| 538 | 550 | $post_types = stripslashes_deep($post_types); |
| 539 | 551 | if (!empty($post_types) && $post_type != '') {
|
| 540 | 552 | return $post_types[$post_type]; |
| 541 | - } else |
|
| 542 | - return false; |
|
| 543 | -} |
|
| 553 | + } else { |
|
| 554 | + return false; |
|
| 555 | + } |
|
| 556 | + } |
|
| 544 | 557 | |
| 545 | 558 | if (!function_exists('geodir_get_taxonomies')) {
|
| 546 | 559 | /** |
@@ -626,10 +639,11 @@ discard block |
||
| 626 | 639 | . geodir_utf8_ucfirst($category_obj->name) . '</option>'; |
| 627 | 640 | } |
| 628 | 641 | |
| 629 | - if ($echo) |
|
| 630 | - echo $html; |
|
| 631 | - else |
|
| 632 | - return $html; |
|
| 642 | + if ($echo) { |
|
| 643 | + echo $html; |
|
| 644 | + } else { |
|
| 645 | + return $html; |
|
| 646 | + } |
|
| 633 | 647 | } |
| 634 | 648 | } |
| 635 | 649 | |
@@ -663,11 +677,12 @@ discard block |
||
| 663 | 677 | |
| 664 | 678 | } |
| 665 | 679 | |
| 666 | - if (!empty($listing_slug)) |
|
| 667 | - return $listing_slug; |
|
| 668 | - else |
|
| 669 | - return false; |
|
| 670 | -} |
|
| 680 | + if (!empty($listing_slug)) { |
|
| 681 | + return $listing_slug; |
|
| 682 | + } else { |
|
| 683 | + return false; |
|
| 684 | + } |
|
| 685 | + } |
|
| 671 | 686 | |
| 672 | 687 | |
| 673 | 688 | /** |
@@ -698,16 +713,18 @@ discard block |
||
| 698 | 713 | if (!empty($taxonomies)) {
|
| 699 | 714 | foreach (geodir_get_posttypes() as $pt) {
|
| 700 | 715 | $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies($pt); |
| 701 | - if (array_intersect($taxonomies, $object_taxonomies)) |
|
| 702 | - $post_type[] = $pt; |
|
| 716 | + if (array_intersect($taxonomies, $object_taxonomies)) { |
|
| 717 | + $post_type[] = $pt; |
|
| 718 | + } |
|
| 703 | 719 | } |
| 704 | 720 | } |
| 705 | 721 | |
| 706 | - if (!empty($post_type)) |
|
| 707 | - return $post_type[0]; |
|
| 708 | - else |
|
| 709 | - return false; |
|
| 710 | -} |
|
| 722 | + if (!empty($post_type)) { |
|
| 723 | + return $post_type[0]; |
|
| 724 | + } else { |
|
| 725 | + return false; |
|
| 726 | + } |
|
| 727 | + } |
|
| 711 | 728 | |
| 712 | 729 | if (!function_exists('geodir_custom_taxonomy_walker')) {
|
| 713 | 730 | /** |
@@ -763,18 +780,18 @@ discard block |
||
| 763 | 780 | $checked = ''; |
| 764 | 781 | |
| 765 | 782 | if (in_array($cat_term->term_id, $search_terms)) {
|
| 766 | - if ($cat_display == 'select' || $cat_display == 'multiselect') |
|
| 767 | - $checked = 'selected="selected"'; |
|
| 768 | - else |
|
| 769 | - $checked = 'checked="checked"'; |
|
| 783 | + if ($cat_display == 'select' || $cat_display == 'multiselect') { |
|
| 784 | + $checked = 'selected="selected"'; |
|
| 785 | + } else { |
|
| 786 | + $checked = 'checked="checked"'; |
|
| 787 | + } |
|
| 770 | 788 | } |
| 771 | 789 | |
| 772 | - if ($cat_display == 'radio') |
|
| 773 | - $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>'; |
|
| 774 | - elseif ($cat_display == 'select' || $cat_display == 'multiselect') |
|
| 775 | - $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>'; |
|
| 776 | - |
|
| 777 | - else {
|
|
| 790 | + if ($cat_display == 'radio') { |
|
| 791 | + $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>'; |
|
| 792 | + } elseif ($cat_display == 'select' || $cat_display == 'multiselect') { |
|
| 793 | + $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>'; |
|
| 794 | + } else {
|
|
| 778 | 795 | $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>'; |
| 779 | 796 | } |
| 780 | 797 | |
@@ -783,8 +800,9 @@ discard block |
||
| 783 | 800 | |
| 784 | 801 | } |
| 785 | 802 | |
| 786 | - if ($cat_display == 'checkbox' || $cat_display == 'radio') |
|
| 787 | - $out .= '</div>'; |
|
| 803 | + if ($cat_display == 'checkbox' || $cat_display == 'radio') { |
|
| 804 | + $out .= '</div>'; |
|
| 805 | + } |
|
| 788 | 806 | |
| 789 | 807 | return $out; |
| 790 | 808 | } |
@@ -810,18 +828,21 @@ discard block |
||
| 810 | 828 | global $exclude_cats, $gd_session; |
| 811 | 829 | |
| 812 | 830 | $cat_exclude = ''; |
| 813 | - if (is_array($exclude_cats) && !empty($exclude_cats)) |
|
| 814 | - $cat_exclude = serialize($exclude_cats); |
|
| 831 | + if (is_array($exclude_cats) && !empty($exclude_cats)) { |
|
| 832 | + $cat_exclude = serialize($exclude_cats); |
|
| 833 | + } |
|
| 815 | 834 | |
| 816 | 835 | if (isset($_REQUEST['backandedit'])) {
|
| 817 | 836 | $post = (object)$gd_session->get('listing');
|
| 818 | 837 | |
| 819 | - if (!is_array($post->post_category[$cat_taxonomy])) |
|
| 820 | - $post_category = $post->post_category[$cat_taxonomy]; |
|
| 838 | + if (!is_array($post->post_category[$cat_taxonomy])) { |
|
| 839 | + $post_category = $post->post_category[$cat_taxonomy]; |
|
| 840 | + } |
|
| 821 | 841 | |
| 822 | 842 | $post_categories = $post->post_category_str; |
| 823 | - if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) |
|
| 824 | - $post_category_str = $post_categories[$cat_taxonomy]; |
|
| 843 | + if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) { |
|
| 844 | + $post_category_str = $post_categories[$cat_taxonomy]; |
|
| 845 | + } |
|
| 825 | 846 | |
| 826 | 847 | } elseif ((geodir_is_page('add-listing') && isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') || (is_admin())) {
|
| 827 | 848 | global $post; |
@@ -1012,8 +1033,9 @@ discard block |
||
| 1012 | 1033 | if (!empty($post_categories) && array_key_exists($cat_taxonomy, $post_categories)) {
|
| 1013 | 1034 | $post_cat_str = $post_categories[$cat_taxonomy]; |
| 1014 | 1035 | $post_cat_array = explode("#", $post_cat_str);
|
| 1015 | - if (count($post_cat_array) >= $cat_limit && $cat_limit != 0) |
|
| 1016 | - $style = "display:none;"; |
|
| 1036 | + if (count($post_cat_array) >= $cat_limit && $cat_limit != 0) { |
|
| 1037 | + $style = "display:none;"; |
|
| 1038 | + } |
|
| 1017 | 1039 | } |
| 1018 | 1040 | ?> |
| 1019 | 1041 | <div class="main_cat_list" style=" <?php if (isset($style)) {
|
@@ -1048,7 +1070,7 @@ discard block |
||
| 1048 | 1070 | |
| 1049 | 1071 | if(is_array( $exclude_cats)){
|
| 1050 | 1072 | $exclude_cats = array_map( 'intval', $exclude_cats ); |
| 1051 | - }else{
|
|
| 1073 | + } else{
|
|
| 1052 | 1074 | $exclude_cats = intval($exclude_cats); |
| 1053 | 1075 | } |
| 1054 | 1076 | |
@@ -1078,7 +1100,10 @@ discard block |
||
| 1078 | 1100 | |
| 1079 | 1101 | <div class="post_default_category"> |
| 1080 | 1102 | <input type="radio" name="post_default_category" value="<?php echo $main_cat->term_id;?>" |
| 1081 | - onchange="update_listing_cat()" <?php if ($default) echo ' checked="checked" ';?> /> |
|
| 1103 | + onchange="update_listing_cat()" <?php if ($default) { |
|
| 1104 | + echo ' checked="checked" '; |
|
| 1105 | +} |
|
| 1106 | +?> /> |
|
| 1082 | 1107 | <span> |
| 1083 | 1108 | <?php printf(__('Set %s as default category', 'geodirectory'), geodir_ucwords($main_cat->name));?>
|
| 1084 | 1109 | </span> |
@@ -1178,8 +1203,9 @@ discard block |
||
| 1178 | 1203 | $onchange = ' onchange="show_subcatlist(this.value, this)" '; |
| 1179 | 1204 | |
| 1180 | 1205 | $option_selected = ''; |
| 1181 | - if (!$selected) |
|
| 1182 | - $option_slected = ' selected="selected" '; |
|
| 1206 | + if (!$selected) { |
|
| 1207 | + $option_slected = ' selected="selected" '; |
|
| 1208 | + } |
|
| 1183 | 1209 | |
| 1184 | 1210 | echo '<select field_type="select" id="' . sanitize_text_field($cat_taxonomy) . '" class="chosen_select" ' . $onchange . ' option-ajaxChosen="false" >'; |
| 1185 | 1211 | |
@@ -1187,8 +1213,9 @@ discard block |
||
| 1187 | 1213 | |
| 1188 | 1214 | foreach ($cat_terms as $cat_term) {
|
| 1189 | 1215 | $option_selected = ''; |
| 1190 | - if ($selected == $cat_term->term_id) |
|
| 1191 | - $option_selected = ' selected="selected" '; |
|
| 1216 | + if ($selected == $cat_term->term_id) { |
|
| 1217 | + $option_selected = ' selected="selected" '; |
|
| 1218 | + } |
|
| 1192 | 1219 | |
| 1193 | 1220 | // Count child terms |
| 1194 | 1221 | $child_terms = get_terms( $cat_taxonomy, array( 'parent' => $cat_term->term_id, 'hide_empty' => false, 'exclude' => $exclude_cats, 'number' => 1 ) ); |
@@ -1253,8 +1280,9 @@ discard block |
||
| 1253 | 1280 | |
| 1254 | 1281 | $menu_icon = geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico'; |
| 1255 | 1282 | |
| 1256 | - if (!$listing_slug = get_option('geodir_listing_prefix'))
|
|
| 1257 | - $listing_slug = 'places'; |
|
| 1283 | + if (!$listing_slug = get_option('geodir_listing_prefix')) { |
|
| 1284 | + $listing_slug = 'places'; |
|
| 1285 | + } |
|
| 1258 | 1286 | |
| 1259 | 1287 | /** |
| 1260 | 1288 | * Taxonomies |
@@ -1566,8 +1594,9 @@ discard block |
||
| 1566 | 1594 | 'city_slug' => $post->city_slug |
| 1567 | 1595 | ); |
| 1568 | 1596 | |
| 1569 | - } else |
|
| 1570 | - $post_location = geodir_get_location(); |
|
| 1597 | + } else { |
|
| 1598 | + $post_location = geodir_get_location(); |
|
| 1599 | + } |
|
| 1571 | 1600 | |
| 1572 | 1601 | |
| 1573 | 1602 | } else {
|
@@ -1596,8 +1625,9 @@ discard block |
||
| 1596 | 1625 | ); |
| 1597 | 1626 | |
| 1598 | 1627 | } |
| 1599 | - } else |
|
| 1600 | - $post_location = geodir_get_location(); |
|
| 1628 | + } else { |
|
| 1629 | + $post_location = geodir_get_location(); |
|
| 1630 | + } |
|
| 1601 | 1631 | } |
| 1602 | 1632 | |
| 1603 | 1633 | |
@@ -1636,16 +1666,17 @@ discard block |
||
| 1636 | 1666 | |
| 1637 | 1667 | if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
|
| 1638 | 1668 | $post_terms = absint($_POST['post_default_category']); |
| 1639 | - }elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
|
|
| 1669 | + } elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]) {
|
|
| 1640 | 1670 | $post_terms = is_array($_POST['post_category'][$taxonomies]) ? $_POST['post_category'][$taxonomies] : explode(",", trim($_POST['post_category'][$taxonomies], ","));
|
| 1641 | 1671 | $post_terms = !empty($post_terms) ? absint($post_terms[0]) : 0; |
| 1642 | - }elseif (isset($post->{$taxonomies})) {
|
|
| 1672 | + } elseif (isset($post->{$taxonomies})) {
|
|
| 1643 | 1673 | $post_terms = explode(",", trim($post->{$taxonomies}, ","));
|
| 1644 | 1674 | $post_terms = $post_terms[0]; |
| 1645 | 1675 | } |
| 1646 | 1676 | |
| 1647 | - if (!$post_terms) |
|
| 1648 | - $post_terms = geodir_get_post_meta($post->ID, 'default_category', true); |
|
| 1677 | + if (!$post_terms) { |
|
| 1678 | + $post_terms = geodir_get_post_meta($post->ID, 'default_category', true); |
|
| 1679 | + } |
|
| 1649 | 1680 | |
| 1650 | 1681 | if (!$post_terms) {
|
| 1651 | 1682 | $post_terms = geodir_get_post_meta($post->ID, $taxonomies, true); |
@@ -1659,8 +1690,9 @@ discard block |
||
| 1659 | 1690 | |
| 1660 | 1691 | $term = get_term_by('id', $post_terms, $taxonomies);
|
| 1661 | 1692 | |
| 1662 | - if (!empty($term)) |
|
| 1663 | - $term_request = $term->slug; |
|
| 1693 | + if (!empty($term)) { |
|
| 1694 | + $term_request = $term->slug; |
|
| 1695 | + } |
|
| 1664 | 1696 | //$term_request = $term->slug.'/'; |
| 1665 | 1697 | } |
| 1666 | 1698 | |
@@ -1675,9 +1707,13 @@ discard block |
||
| 1675 | 1707 | $request_term .= $term_request; |
| 1676 | 1708 | |
| 1677 | 1709 | } else {
|
| 1678 | - if (isset($location_request) && $location_request != '') $request_term = $location_request; |
|
| 1710 | + if (isset($location_request) && $location_request != '') { |
|
| 1711 | + $request_term = $location_request; |
|
| 1712 | + } |
|
| 1679 | 1713 | |
| 1680 | - if (isset($term_request) && $term_request != '') $request_term .= $term_request; |
|
| 1714 | + if (isset($term_request) && $term_request != '') { |
|
| 1715 | + $request_term .= $term_request; |
|
| 1716 | + } |
|
| 1681 | 1717 | } |
| 1682 | 1718 | $request_term = trim($request_term, '/'); |
| 1683 | 1719 | |
@@ -1686,10 +1722,11 @@ discard block |
||
| 1686 | 1722 | $post_link = str_replace('%gd_taxonomy%/', '', $post_link);
|
| 1687 | 1723 | } |
| 1688 | 1724 | |
| 1689 | - if (!empty($request_term)) |
|
| 1690 | - $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
|
|
| 1691 | - else |
|
| 1692 | - $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
|
|
| 1725 | + if (!empty($request_term)) { |
|
| 1726 | + $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link); |
|
| 1727 | + } else { |
|
| 1728 | + $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link); |
|
| 1729 | + } |
|
| 1693 | 1730 | //echo $post_link ; |
| 1694 | 1731 | } |
| 1695 | 1732 | // temp cache the permalink |
@@ -1881,11 +1918,12 @@ discard block |
||
| 1881 | 1918 | |
| 1882 | 1919 | $label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name; |
| 1883 | 1920 | |
| 1884 | - if ($echo) |
|
| 1885 | - echo $label; |
|
| 1886 | - else |
|
| 1887 | - return $label; |
|
| 1888 | -} |
|
| 1921 | + if ($echo) { |
|
| 1922 | + echo $label; |
|
| 1923 | + } else { |
|
| 1924 | + return $label; |
|
| 1925 | + } |
|
| 1926 | + } |
|
| 1889 | 1927 | |
| 1890 | 1928 | /** |
| 1891 | 1929 | * Print or Get post type plural label. |
@@ -1901,18 +1939,20 @@ discard block |
||
| 1901 | 1939 | function get_post_type_plural_label($post_type, $echo = false, $translate = false) {
|
| 1902 | 1940 | $all_postypes = geodir_get_posttypes(); |
| 1903 | 1941 | |
| 1904 | - if (!in_array($post_type, $all_postypes)) |
|
| 1905 | - return false; |
|
| 1942 | + if (!in_array($post_type, $all_postypes)) { |
|
| 1943 | + return false; |
|
| 1944 | + } |
|
| 1906 | 1945 | |
| 1907 | 1946 | $obj_post_type = get_post_type_object($post_type); |
| 1908 | 1947 | |
| 1909 | 1948 | $label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name; |
| 1910 | 1949 | |
| 1911 | - if ($echo) |
|
| 1912 | - echo $label; |
|
| 1913 | - else |
|
| 1914 | - return $label; |
|
| 1915 | -} |
|
| 1950 | + if ($echo) { |
|
| 1951 | + echo $label; |
|
| 1952 | + } else { |
|
| 1953 | + return $label; |
|
| 1954 | + } |
|
| 1955 | + } |
|
| 1916 | 1956 | |
| 1917 | 1957 | /** |
| 1918 | 1958 | * Checks whether a term exists or not. |
@@ -1935,19 +1975,22 @@ discard block |
||
| 1935 | 1975 | $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 "; |
| 1936 | 1976 | |
| 1937 | 1977 | if (is_int($term)) {
|
| 1938 | - if (0 == $term) |
|
| 1939 | - return 0; |
|
| 1978 | + if (0 == $term) { |
|
| 1979 | + return 0; |
|
| 1980 | + } |
|
| 1940 | 1981 | $where = 't.term_id = %d'; |
| 1941 | - if (!empty($taxonomy)) |
|
| 1942 | - return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); |
|
| 1943 | - else |
|
| 1944 | - return $wpdb->get_var($wpdb->prepare($select . $where, $term)); |
|
| 1982 | + if (!empty($taxonomy)) { |
|
| 1983 | + return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); |
|
| 1984 | + } else { |
|
| 1985 | + return $wpdb->get_var($wpdb->prepare($select . $where, $term)); |
|
| 1986 | + } |
|
| 1945 | 1987 | } |
| 1946 | 1988 | |
| 1947 | 1989 | $term = trim(wp_unslash($term)); |
| 1948 | 1990 | |
| 1949 | - if ('' === $slug = sanitize_title($term))
|
|
| 1950 | - return 0; |
|
| 1991 | + if ('' === $slug = sanitize_title($term)) { |
|
| 1992 | + return 0; |
|
| 1993 | + } |
|
| 1951 | 1994 | |
| 1952 | 1995 | $where = 't.slug = %s'; |
| 1953 | 1996 | |
@@ -1964,14 +2007,16 @@ discard block |
||
| 1964 | 2007 | $where_fields[] = $taxonomy; |
| 1965 | 2008 | |
| 1966 | 2009 | |
| 1967 | - 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))
|
|
| 1968 | - return $result; |
|
| 2010 | + 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)) { |
|
| 2011 | + return $result; |
|
| 2012 | + } |
|
| 1969 | 2013 | |
| 1970 | 2014 | return false; |
| 1971 | 2015 | } |
| 1972 | 2016 | |
| 1973 | - if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields)))
|
|
| 1974 | - return $result; |
|
| 2017 | + if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields))) { |
|
| 2018 | + return $result; |
|
| 2019 | + } |
|
| 1975 | 2020 | |
| 1976 | 2021 | return false; |
| 1977 | 2022 | } |