@@ -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 | |
@@ -406,24 +413,28 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
@@ -1553,8 +1584,9 @@ discard block |
||
| 1553 | 1584 | 'city_slug' => $post->city_slug |
| 1554 | 1585 | ); |
| 1555 | 1586 | |
| 1556 | - } else |
|
| 1557 | - $post_location = geodir_get_location(); |
|
| 1587 | + } else { |
|
| 1588 | + $post_location = geodir_get_location(); |
|
| 1589 | + } |
|
| 1558 | 1590 | |
| 1559 | 1591 | |
| 1560 | 1592 | } else {
|
@@ -1583,8 +1615,9 @@ discard block |
||
| 1583 | 1615 | ); |
| 1584 | 1616 | |
| 1585 | 1617 | } |
| 1586 | - } else |
|
| 1587 | - $post_location = geodir_get_location(); |
|
| 1618 | + } else { |
|
| 1619 | + $post_location = geodir_get_location(); |
|
| 1620 | + } |
|
| 1588 | 1621 | } |
| 1589 | 1622 | |
| 1590 | 1623 | |
@@ -1624,16 +1657,17 @@ discard block |
||
| 1624 | 1657 | |
| 1625 | 1658 | if(isset($_POST['post_default_category']) && $_POST['post_default_category']){
|
| 1626 | 1659 | $post_terms = absint($_POST['post_default_category']); |
| 1627 | - }elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]){
|
|
| 1660 | + } elseif(isset($_POST['post_category'][$taxonomies]) && $_POST['post_category'][$taxonomies]){
|
|
| 1628 | 1661 | $post_terms = explode(",", trim($_POST['post_category'][$taxonomies], ","));
|
| 1629 | 1662 | $post_terms = absint($post_terms[0]); |
| 1630 | - }elseif (isset($post->{$taxonomies})) {
|
|
| 1663 | + } elseif (isset($post->{$taxonomies})) {
|
|
| 1631 | 1664 | $post_terms = explode(",", trim($post->{$taxonomies}, ","));
|
| 1632 | 1665 | $post_terms = $post_terms[0]; |
| 1633 | 1666 | } |
| 1634 | 1667 | |
| 1635 | - if (!$post_terms) |
|
| 1636 | - $post_terms = geodir_get_post_meta($post->ID, 'default_category', true); |
|
| 1668 | + if (!$post_terms) { |
|
| 1669 | + $post_terms = geodir_get_post_meta($post->ID, 'default_category', true); |
|
| 1670 | + } |
|
| 1637 | 1671 | |
| 1638 | 1672 | if (!$post_terms) {
|
| 1639 | 1673 | $post_terms = geodir_get_post_meta($post->ID, $taxonomies, true); |
@@ -1647,8 +1681,9 @@ discard block |
||
| 1647 | 1681 | |
| 1648 | 1682 | $term = get_term_by('id', $post_terms, $taxonomies);
|
| 1649 | 1683 | |
| 1650 | - if (!empty($term)) |
|
| 1651 | - $term_request = $term->slug; |
|
| 1684 | + if (!empty($term)) { |
|
| 1685 | + $term_request = $term->slug; |
|
| 1686 | + } |
|
| 1652 | 1687 | //$term_request = $term->slug.'/'; |
| 1653 | 1688 | } |
| 1654 | 1689 | |
@@ -1663,9 +1698,13 @@ discard block |
||
| 1663 | 1698 | $request_term .= $term_request; |
| 1664 | 1699 | |
| 1665 | 1700 | } else {
|
| 1666 | - if (isset($location_request) && $location_request != '') $request_term = $location_request; |
|
| 1701 | + if (isset($location_request) && $location_request != '') { |
|
| 1702 | + $request_term = $location_request; |
|
| 1703 | + } |
|
| 1667 | 1704 | |
| 1668 | - if (isset($term_request) && $term_request != '') $request_term .= $term_request; |
|
| 1705 | + if (isset($term_request) && $term_request != '') { |
|
| 1706 | + $request_term .= $term_request; |
|
| 1707 | + } |
|
| 1669 | 1708 | } |
| 1670 | 1709 | $request_term = trim($request_term, '/'); |
| 1671 | 1710 | |
@@ -1674,10 +1713,11 @@ discard block |
||
| 1674 | 1713 | $post_link = str_replace('%gd_taxonomy%/', '', $post_link);
|
| 1675 | 1714 | } |
| 1676 | 1715 | |
| 1677 | - if (!empty($request_term)) |
|
| 1678 | - $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
|
|
| 1679 | - else |
|
| 1680 | - $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link);
|
|
| 1716 | + if (!empty($request_term)) { |
|
| 1717 | + $post_link = str_replace('%gd_taxonomy%', $request_term . $detailurl_separator, $post_link); |
|
| 1718 | + } else { |
|
| 1719 | + $post_link = str_replace('/%gd_taxonomy%', $request_term . $detailurl_separator, $post_link); |
|
| 1720 | + } |
|
| 1681 | 1721 | //echo $post_link ; |
| 1682 | 1722 | } |
| 1683 | 1723 | // temp cache the permalink |
@@ -1869,11 +1909,12 @@ discard block |
||
| 1869 | 1909 | |
| 1870 | 1910 | $label = $translate ? __($obj_post_type->labels->singular_name, 'geodirectory') : $obj_post_type->labels->singular_name; |
| 1871 | 1911 | |
| 1872 | - if ($echo) |
|
| 1873 | - echo $label; |
|
| 1874 | - else |
|
| 1875 | - return $label; |
|
| 1876 | -} |
|
| 1912 | + if ($echo) { |
|
| 1913 | + echo $label; |
|
| 1914 | + } else { |
|
| 1915 | + return $label; |
|
| 1916 | + } |
|
| 1917 | + } |
|
| 1877 | 1918 | |
| 1878 | 1919 | /** |
| 1879 | 1920 | * Print or Get post type plural label. |
@@ -1889,18 +1930,20 @@ discard block |
||
| 1889 | 1930 | function get_post_type_plural_label($post_type, $echo = false, $translate = false) {
|
| 1890 | 1931 | $all_postypes = geodir_get_posttypes(); |
| 1891 | 1932 | |
| 1892 | - if (!in_array($post_type, $all_postypes)) |
|
| 1893 | - return false; |
|
| 1933 | + if (!in_array($post_type, $all_postypes)) { |
|
| 1934 | + return false; |
|
| 1935 | + } |
|
| 1894 | 1936 | |
| 1895 | 1937 | $obj_post_type = get_post_type_object($post_type); |
| 1896 | 1938 | |
| 1897 | 1939 | $label = $translate ? __($obj_post_type->labels->name, 'geodirectory') : $obj_post_type->labels->name; |
| 1898 | 1940 | |
| 1899 | - if ($echo) |
|
| 1900 | - echo $label; |
|
| 1901 | - else |
|
| 1902 | - return $label; |
|
| 1903 | -} |
|
| 1941 | + if ($echo) { |
|
| 1942 | + echo $label; |
|
| 1943 | + } else { |
|
| 1944 | + return $label; |
|
| 1945 | + } |
|
| 1946 | + } |
|
| 1904 | 1947 | |
| 1905 | 1948 | /** |
| 1906 | 1949 | * Checks whether a term exists or not. |
@@ -1923,19 +1966,22 @@ discard block |
||
| 1923 | 1966 | $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 "; |
| 1924 | 1967 | |
| 1925 | 1968 | if (is_int($term)) {
|
| 1926 | - if (0 == $term) |
|
| 1927 | - return 0; |
|
| 1969 | + if (0 == $term) { |
|
| 1970 | + return 0; |
|
| 1971 | + } |
|
| 1928 | 1972 | $where = 't.term_id = %d'; |
| 1929 | - if (!empty($taxonomy)) |
|
| 1930 | - return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); |
|
| 1931 | - else |
|
| 1932 | - return $wpdb->get_var($wpdb->prepare($select . $where, $term)); |
|
| 1973 | + if (!empty($taxonomy)) { |
|
| 1974 | + return $wpdb->get_row($wpdb->prepare($tax_select . $where . " AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A); |
|
| 1975 | + } else { |
|
| 1976 | + return $wpdb->get_var($wpdb->prepare($select . $where, $term)); |
|
| 1977 | + } |
|
| 1933 | 1978 | } |
| 1934 | 1979 | |
| 1935 | 1980 | $term = trim(wp_unslash($term)); |
| 1936 | 1981 | |
| 1937 | - if ('' === $slug = sanitize_title($term))
|
|
| 1938 | - return 0; |
|
| 1982 | + if ('' === $slug = sanitize_title($term)) { |
|
| 1983 | + return 0; |
|
| 1984 | + } |
|
| 1939 | 1985 | |
| 1940 | 1986 | $where = 't.slug = %s'; |
| 1941 | 1987 | |
@@ -1952,14 +1998,16 @@ discard block |
||
| 1952 | 1998 | $where_fields[] = $taxonomy; |
| 1953 | 1999 | |
| 1954 | 2000 | |
| 1955 | - 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))
|
|
| 1956 | - return $result; |
|
| 2001 | + 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)) { |
|
| 2002 | + return $result; |
|
| 2003 | + } |
|
| 1957 | 2004 | |
| 1958 | 2005 | return false; |
| 1959 | 2006 | } |
| 1960 | 2007 | |
| 1961 | - if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields)))
|
|
| 1962 | - return $result; |
|
| 2008 | + if ($result = $wpdb->get_var($wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $where_fields))) { |
|
| 2009 | + return $result; |
|
| 2010 | + } |
|
| 1963 | 2011 | |
| 1964 | 2012 | return false; |
| 1965 | 2013 | } |