@@ -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_clauses', 'geodir_posts_having', 99999, 2 ); |
@@ -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') ";
|
@@ -1217,7 +1228,7 @@ discard block |
||
| 1217 | 1228 | |
| 1218 | 1229 | if(isset($query->query->gd_is_geodir_page) && $query->query->gd_is_geodir_page) {
|
| 1219 | 1230 | $is_main_query = true; |
| 1220 | - }elseif(isset($query->query['gd_is_geodir_page']) && $query->query['gd_is_geodir_page']) {
|
|
| 1231 | + } elseif(isset($query->query['gd_is_geodir_page']) && $query->query['gd_is_geodir_page']) {
|
|
| 1221 | 1232 | $is_main_query = true; |
| 1222 | 1233 | } |
| 1223 | 1234 | |