@@ -46,7 +46,6 @@ discard block |
||
46 | 46 | * @since 1.0.0 |
47 | 47 | * @since 1.5.2 Added TERRAIN map type. |
48 | 48 | * |
49 | - * @param string $value Input value to validate measurement. |
|
50 | 49 | * @return string The measurement valud in valid format. |
51 | 50 | */ |
52 | 51 | function gdsc_validate_map_args($params) |
@@ -95,7 +94,7 @@ discard block |
||
95 | 94 | * @param mixed $in The variable to check |
96 | 95 | * @param bool $strict If set to false, consider everything that is not false to be true. |
97 | 96 | * |
98 | - * @return bool The boolean equivalent or null |
|
97 | + * @return null|boolean The boolean equivalent or null |
|
99 | 98 | */ |
100 | 99 | function gdsc_to_bool_val($in, $strict = false) |
101 | 100 | { |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * All shortcode related functions |
|
4 | - * |
|
5 | - * @since 1.0.0 |
|
6 | - * |
|
7 | - * @package GeoDirectory |
|
8 | - */ |
|
3 | + * All shortcode related functions |
|
4 | + * |
|
5 | + * @since 1.0.0 |
|
6 | + * |
|
7 | + * @package GeoDirectory |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | // If this file is called directly, abort. |
11 | 11 | if (!defined('WPINC')) { |
@@ -284,13 +284,13 @@ discard block |
||
284 | 284 | // @todo: Extract this |
285 | 285 | // This is wrong, it should be in JS and CSS files. |
286 | 286 | if (!(function_exists('geodir_home_map_add_script'))) { |
287 | - /** |
|
288 | - * Adds the script in the page footer for the home page google map. |
|
289 | - * |
|
290 | - * @since 1.0.0 |
|
287 | + /** |
|
288 | + * Adds the script in the page footer for the home page google map. |
|
289 | + * |
|
290 | + * @since 1.0.0 |
|
291 | 291 | * @return string Print the script in page footer. |
292 | - */ |
|
293 | - function geodir_home_map_add_script() |
|
292 | + */ |
|
293 | + function geodir_home_map_add_script() |
|
294 | 294 | { |
295 | 295 | ?> |
296 | 296 | <script type="text/javascript"> |
@@ -554,32 +554,32 @@ discard block |
||
554 | 554 | */ |
555 | 555 | function geodir_sc_gd_listings_output($args = array()) { |
556 | 556 | $title = !empty($args['title']) ? __($args['title'], 'geodirectory') : ''; |
557 | - $post_type = !empty($args['post_type']) ? $args['post_type'] : 'gd_place'; |
|
558 | - $category = !empty($args['category']) ? $args['category'] : '0'; |
|
559 | - $post_number = !empty($args['post_number']) ? $args['post_number'] : 10; |
|
560 | - $add_location_filter = !empty($args['add_location_filter']) ? true : false; |
|
561 | - $list_sort = !empty($args['list_sort']) ? $args['list_sort'] : 'latest'; |
|
562 | - $character_count = isset($args['character_count']) ? $args['character_count'] : ''; |
|
563 | - $layout = !empty($args['layout']) ? $args['layout'] : 'gridview_onehalf'; |
|
564 | - $with_pagination = !empty($args['with_pagination']) ? true : false; |
|
565 | - $event_type = !empty($args['event_type']) ? $args['event_type'] : ''; |
|
557 | + $post_type = !empty($args['post_type']) ? $args['post_type'] : 'gd_place'; |
|
558 | + $category = !empty($args['category']) ? $args['category'] : '0'; |
|
559 | + $post_number = !empty($args['post_number']) ? $args['post_number'] : 10; |
|
560 | + $add_location_filter = !empty($args['add_location_filter']) ? true : false; |
|
561 | + $list_sort = !empty($args['list_sort']) ? $args['list_sort'] : 'latest'; |
|
562 | + $character_count = isset($args['character_count']) ? $args['character_count'] : ''; |
|
563 | + $layout = !empty($args['layout']) ? $args['layout'] : 'gridview_onehalf'; |
|
564 | + $with_pagination = !empty($args['with_pagination']) ? true : false; |
|
565 | + $event_type = !empty($args['event_type']) ? $args['event_type'] : ''; |
|
566 | 566 | |
567 | - $top_pagination = $with_pagination && !empty($args['top_pagination']) ? true : false; |
|
568 | - $bottom_pagination = $with_pagination && !empty($args['bottom_pagination']) ? true : false; |
|
567 | + $top_pagination = $with_pagination && !empty($args['top_pagination']) ? true : false; |
|
568 | + $bottom_pagination = $with_pagination && !empty($args['bottom_pagination']) ? true : false; |
|
569 | 569 | |
570 | - $shortcode_atts = !empty($args['shortcode_atts']) ? $args['shortcode_atts'] : array(); |
|
570 | + $shortcode_atts = !empty($args['shortcode_atts']) ? $args['shortcode_atts'] : array(); |
|
571 | 571 | |
572 | - // ajax mode |
|
573 | - $geodir_ajax = !empty($args['geodir_ajax']) ? true : false; |
|
574 | - $pageno = $geodir_ajax && !empty($args['pageno']) ? $args['pageno'] : 1; |
|
572 | + // ajax mode |
|
573 | + $geodir_ajax = !empty($args['geodir_ajax']) ? true : false; |
|
574 | + $pageno = $geodir_ajax && !empty($args['pageno']) ? $args['pageno'] : 1; |
|
575 | 575 | |
576 | - $query_args = array( |
|
576 | + $query_args = array( |
|
577 | 577 | 'posts_per_page' => $post_number, |
578 | 578 | 'is_geodir_loop' => true, |
579 | 579 | 'gd_location' => $add_location_filter, |
580 | 580 | 'post_type' => $post_type, |
581 | 581 | 'order_by' => $list_sort, |
582 | - 'pageno' => $pageno |
|
582 | + 'pageno' => $pageno |
|
583 | 583 | ); |
584 | 584 | |
585 | 585 | if ($character_count >= 0) { |
@@ -625,32 +625,32 @@ discard block |
||
625 | 625 | global $gridview_columns_widget, $geodir_is_widget_listing; |
626 | 626 | |
627 | 627 | if ($post_type == 'gd_event' && function_exists('geodir_event_get_widget_events')) { |
628 | - global $geodir_event_widget_listview; |
|
629 | - $geodir_event_widget_listview = true; |
|
628 | + global $geodir_event_widget_listview; |
|
629 | + $geodir_event_widget_listview = true; |
|
630 | 630 | |
631 | - if ($event_type && in_array($event_type, array('past', 'today', 'upcoming'))) { |
|
632 | - $query_args['geodir_event_type'] = $event_type; |
|
633 | - } |
|
631 | + if ($event_type && in_array($event_type, array('past', 'today', 'upcoming'))) { |
|
632 | + $query_args['geodir_event_type'] = $event_type; |
|
633 | + } |
|
634 | 634 | |
635 | - $total_posts = geodir_event_get_widget_events($query_args, true); |
|
636 | - $widget_listings = $total_posts > 0 ? geodir_event_get_widget_events($query_args) : array(); |
|
635 | + $total_posts = geodir_event_get_widget_events($query_args, true); |
|
636 | + $widget_listings = $total_posts > 0 ? geodir_event_get_widget_events($query_args) : array(); |
|
637 | 637 | |
638 | - } else { |
|
639 | - $total_posts = geodir_get_widget_listings($query_args, true); |
|
640 | - $widget_listings = $total_posts > 0 ? geodir_get_widget_listings($query_args) : array(); |
|
641 | - } |
|
642 | - $current_gridview_columns_widget = $gridview_columns_widget; |
|
638 | + } else { |
|
639 | + $total_posts = geodir_get_widget_listings($query_args, true); |
|
640 | + $widget_listings = $total_posts > 0 ? geodir_get_widget_listings($query_args) : array(); |
|
641 | + } |
|
642 | + $current_gridview_columns_widget = $gridview_columns_widget; |
|
643 | 643 | |
644 | 644 | ob_start(); |
645 | - if (!empty($widget_listings) || $with_no_results) { |
|
646 | - if (!$geodir_ajax) { |
|
645 | + if (!empty($widget_listings) || $with_no_results) { |
|
646 | + if (!$geodir_ajax) { |
|
647 | 647 | /** |
648 | 648 | * Called before the shortcode [gd_listings] content is output. |
649 | 649 | * |
650 | 650 | * @since 1.0.0 |
651 | 651 | */ |
652 | 652 | do_action('geodir_before_sc_gd_listings'); |
653 | - ?> |
|
653 | + ?> |
|
654 | 654 | <div class="geodir_locations geodir_location_listing geodir-sc-gd-listings"> |
655 | 655 | <?php } ?> |
656 | 656 | <?php if ($title != '') { ?> |
@@ -668,13 +668,13 @@ discard block |
||
668 | 668 | } |
669 | 669 | |
670 | 670 | /** |
671 | - * Filter the widget listing listview template. |
|
672 | - * |
|
673 | - * @since 1.0.0 |
|
674 | - * |
|
675 | - * @param string The template file to display listing. |
|
676 | - */ |
|
677 | - $template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview')); |
|
671 | + * Filter the widget listing listview template. |
|
672 | + * |
|
673 | + * @since 1.0.0 |
|
674 | + * |
|
675 | + * @param string The template file to display listing. |
|
676 | + */ |
|
677 | + $template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview')); |
|
678 | 678 | |
679 | 679 | global $post, $map_jason, $map_canvas_arr, $gd_session; |
680 | 680 | |
@@ -682,38 +682,38 @@ discard block |
||
682 | 682 | $current_map_jason = $map_jason; |
683 | 683 | $current_map_canvas_arr = $map_canvas_arr; |
684 | 684 | $geodir_is_widget_listing = true; |
685 | - $gd_session->un_set('gd_listing_view'); |
|
685 | + $gd_session->un_set('gd_listing_view'); |
|
686 | 686 | |
687 | 687 | if ($with_pagination && $top_pagination) { |
688 | - echo geodir_sc_listings_pagination($total_posts, $post_number, $pageno); |
|
689 | - } |
|
688 | + echo geodir_sc_listings_pagination($total_posts, $post_number, $pageno); |
|
689 | + } |
|
690 | 690 | |
691 | 691 | /** |
692 | 692 | * Includes listing listview template. |
693 | 693 | * |
694 | 694 | * @since 1.0.0 |
695 | 695 | */ |
696 | - include($template); |
|
696 | + include($template); |
|
697 | 697 | |
698 | - if ($with_pagination && $bottom_pagination) { |
|
699 | - echo geodir_sc_listings_pagination($total_posts, $post_number, $pageno); |
|
700 | - } |
|
698 | + if ($with_pagination && $bottom_pagination) { |
|
699 | + echo geodir_sc_listings_pagination($total_posts, $post_number, $pageno); |
|
700 | + } |
|
701 | 701 | |
702 | 702 | $geodir_is_widget_listing = false; |
703 | 703 | |
704 | 704 | $GLOBALS['post'] = $current_post; |
705 | - if (!empty($current_post)) { |
|
706 | - setup_postdata($current_post); |
|
707 | - } |
|
705 | + if (!empty($current_post)) { |
|
706 | + setup_postdata($current_post); |
|
707 | + } |
|
708 | 708 | $map_jason = $current_map_jason; |
709 | 709 | $map_canvas_arr = $current_map_canvas_arr; |
710 | - global $gridview_columns_widget; |
|
711 | - $gridview_columns_widget = $current_gridview_columns_widget; |
|
712 | - ?> |
|
710 | + global $gridview_columns_widget; |
|
711 | + $gridview_columns_widget = $current_gridview_columns_widget; |
|
712 | + ?> |
|
713 | 713 | <p class="geodir-sclisting-loading" style="display:none;"><i class="fa fa-cog fa-spin"></i></p> |
714 | 714 | <?php |
715 | 715 | if (!$geodir_ajax) { |
716 | - ?> |
|
716 | + ?> |
|
717 | 717 | </div> |
718 | 718 | <script type="text/javascript"> |
719 | 719 | function gd_sc_gopage(obj, pid) { |
@@ -750,7 +750,7 @@ discard block |
||
750 | 750 | <?php } ?> |
751 | 751 | <?php |
752 | 752 | } |
753 | - $output = ob_get_contents(); |
|
753 | + $output = ob_get_contents(); |
|
754 | 754 | ob_end_clean(); |
755 | 755 | |
756 | 756 | return trim($output); |
@@ -790,60 +790,60 @@ discard block |
||
790 | 790 | |
791 | 791 | $half_pages_to_show = round($pages_to_show / 2); |
792 | 792 | |
793 | - $numposts = $total_posts; |
|
793 | + $numposts = $total_posts; |
|
794 | 794 | |
795 | - $max_page = ceil($numposts / $posts_per_page); |
|
795 | + $max_page = ceil($numposts / $posts_per_page); |
|
796 | 796 | |
797 | - if (empty($pageno)) { |
|
798 | - $pageno = 1; |
|
799 | - } |
|
797 | + if (empty($pageno)) { |
|
798 | + $pageno = 1; |
|
799 | + } |
|
800 | 800 | |
801 | - ob_start(); |
|
802 | - if ($max_page > 1 || $always_show) { |
|
803 | - // Extra pagination info |
|
804 | - $geodir_pagination_more_info = get_option('geodir_pagination_advance_info'); |
|
805 | - $start_no = ( $pageno - 1 ) * $posts_per_page + 1; |
|
806 | - $end_no = min($pageno * $posts_per_page, $numposts); |
|
801 | + ob_start(); |
|
802 | + if ($max_page > 1 || $always_show) { |
|
803 | + // Extra pagination info |
|
804 | + $geodir_pagination_more_info = get_option('geodir_pagination_advance_info'); |
|
805 | + $start_no = ( $pageno - 1 ) * $posts_per_page + 1; |
|
806 | + $end_no = min($pageno * $posts_per_page, $numposts); |
|
807 | 807 | |
808 | - if ($geodir_pagination_more_info != '') { |
|
809 | - $pagination_info = '<div class="gd-pagination-details">' . wp_sprintf(__('Showing listings %d-%d of %d', 'geodirectory'), $start_no, $end_no, $numposts) . '</div>'; |
|
808 | + if ($geodir_pagination_more_info != '') { |
|
809 | + $pagination_info = '<div class="gd-pagination-details">' . wp_sprintf(__('Showing listings %d-%d of %d', 'geodirectory'), $start_no, $end_no, $numposts) . '</div>'; |
|
810 | 810 | |
811 | - if ($geodir_pagination_more_info == 'before') { |
|
812 | - $before = $before . $pagination_info; |
|
813 | - } else if ($geodir_pagination_more_info == 'after') { |
|
814 | - $after = $pagination_info . $after; |
|
815 | - } |
|
816 | - } |
|
811 | + if ($geodir_pagination_more_info == 'before') { |
|
812 | + $before = $before . $pagination_info; |
|
813 | + } else if ($geodir_pagination_more_info == 'after') { |
|
814 | + $after = $pagination_info . $after; |
|
815 | + } |
|
816 | + } |
|
817 | 817 | |
818 | - echo "$before <div class='Navi geodir-ajax-pagination'>"; |
|
819 | - if ($pageno > 1) { |
|
820 | - echo '<a class="gd-page-sc-fst" href="javascript:void(0);" onclick="gd_sc_gopage(this, 1);">«</a> '; |
|
821 | - } |
|
818 | + echo "$before <div class='Navi geodir-ajax-pagination'>"; |
|
819 | + if ($pageno > 1) { |
|
820 | + echo '<a class="gd-page-sc-fst" href="javascript:void(0);" onclick="gd_sc_gopage(this, 1);">«</a> '; |
|
821 | + } |
|
822 | 822 | |
823 | - if (($pageno - 1) > 0) { |
|
824 | - echo '<a class="gd-page-sc-prev" href="javascript:void(0);" onclick="gd_sc_gopage(this, ' . (int)($pageno - 1) . ');">' . $prelabel . '</a> '; |
|
825 | - } |
|
823 | + if (($pageno - 1) > 0) { |
|
824 | + echo '<a class="gd-page-sc-prev" href="javascript:void(0);" onclick="gd_sc_gopage(this, ' . (int)($pageno - 1) . ');">' . $prelabel . '</a> '; |
|
825 | + } |
|
826 | 826 | |
827 | - for ($i = $pageno - $half_pages_to_show; $i <= $pageno + $half_pages_to_show; $i++) { |
|
828 | - if ($i >= 1 && $i <= $max_page) { |
|
829 | - if ($i == $pageno) { |
|
830 | - echo "<strong class='on' class='gd-page-sc-act'>$i</strong>"; |
|
831 | - } else { |
|
832 | - echo ' <a class="gd-page-sc-no" href="javascript:void(0);" onclick="gd_sc_gopage(this, ' . (int)$i . ');">' . $i . '</a> '; |
|
833 | - } |
|
834 | - } |
|
835 | - } |
|
827 | + for ($i = $pageno - $half_pages_to_show; $i <= $pageno + $half_pages_to_show; $i++) { |
|
828 | + if ($i >= 1 && $i <= $max_page) { |
|
829 | + if ($i == $pageno) { |
|
830 | + echo "<strong class='on' class='gd-page-sc-act'>$i</strong>"; |
|
831 | + } else { |
|
832 | + echo ' <a class="gd-page-sc-no" href="javascript:void(0);" onclick="gd_sc_gopage(this, ' . (int)$i . ');">' . $i . '</a> '; |
|
833 | + } |
|
834 | + } |
|
835 | + } |
|
836 | 836 | |
837 | - if (($pageno + 1) <= $max_page) { |
|
838 | - echo ' <a class="gd-page-sc-nxt" href="javascript:void(0);" onclick="gd_sc_gopage(this, ' . (int)($pageno + 1) . ');">' . $nxtlabel . '</a>'; |
|
839 | - } |
|
837 | + if (($pageno + 1) <= $max_page) { |
|
838 | + echo ' <a class="gd-page-sc-nxt" href="javascript:void(0);" onclick="gd_sc_gopage(this, ' . (int)($pageno + 1) . ');">' . $nxtlabel . '</a>'; |
|
839 | + } |
|
840 | 840 | |
841 | - if ($pageno < $max_page) { |
|
842 | - echo ' <a class="gd-page-sc-lst" href="javascript:void(0);" onclick="gd_sc_gopage(this, ' . (int)$max_page . ');">»</a>'; |
|
843 | - } |
|
844 | - echo "</div> $after"; |
|
845 | - } |
|
846 | - $output = ob_get_contents(); |
|
841 | + if ($pageno < $max_page) { |
|
842 | + echo ' <a class="gd-page-sc-lst" href="javascript:void(0);" onclick="gd_sc_gopage(this, ' . (int)$max_page . ');">»</a>'; |
|
843 | + } |
|
844 | + echo "</div> $after"; |
|
845 | + } |
|
846 | + $output = ob_get_contents(); |
|
847 | 847 | ob_end_clean(); |
848 | 848 | |
849 | 849 | return trim($output); |
@@ -862,16 +862,16 @@ discard block |
||
862 | 862 | $scatts = isset($_POST['scatts']) ? $_POST['scatts'] : NULL; |
863 | 863 | $pageno = isset($_POST['pageno']) ? absint($_POST['pageno']) : 1; |
864 | 864 | |
865 | - $shortcode_atts = !empty($scatts) ? (array)json_decode(stripslashes_deep($scatts)) : NULL; |
|
865 | + $shortcode_atts = !empty($scatts) ? (array)json_decode(stripslashes_deep($scatts)) : NULL; |
|
866 | 866 | |
867 | - if (!empty($shortcode_atts) && is_array($shortcode_atts)) { |
|
868 | - $shortcode_atts['pageno'] = $pageno; |
|
869 | - $shortcode_atts['geodir_ajax'] = true; |
|
867 | + if (!empty($shortcode_atts) && is_array($shortcode_atts)) { |
|
868 | + $shortcode_atts['pageno'] = $pageno; |
|
869 | + $shortcode_atts['geodir_ajax'] = true; |
|
870 | 870 | |
871 | - echo geodir_sc_gd_listings($shortcode_atts); |
|
872 | - } else { |
|
873 | - echo 0; |
|
874 | - } |
|
871 | + echo geodir_sc_gd_listings($shortcode_atts); |
|
872 | + } else { |
|
873 | + echo 0; |
|
874 | + } |
|
875 | 875 | wp_die(); |
876 | 876 | } |
877 | 877 | add_action('wp_ajax_geodir_sclistings', 'geodir_sclistings_callback'); |
@@ -559,19 +559,19 @@ discard block |
||
559 | 559 | $post_number = !empty($args['post_number']) ? $args['post_number'] : 10; |
560 | 560 | $add_location_filter = !empty($args['add_location_filter']) ? true : false; |
561 | 561 | $list_sort = !empty($args['list_sort']) ? $args['list_sort'] : 'latest'; |
562 | - $character_count = isset($args['character_count']) ? $args['character_count'] : ''; |
|
563 | - $layout = !empty($args['layout']) ? $args['layout'] : 'gridview_onehalf'; |
|
564 | - $with_pagination = !empty($args['with_pagination']) ? true : false; |
|
565 | - $event_type = !empty($args['event_type']) ? $args['event_type'] : ''; |
|
562 | + $character_count = isset($args['character_count']) ? $args['character_count'] : ''; |
|
563 | + $layout = !empty($args['layout']) ? $args['layout'] : 'gridview_onehalf'; |
|
564 | + $with_pagination = !empty($args['with_pagination']) ? true : false; |
|
565 | + $event_type = !empty($args['event_type']) ? $args['event_type'] : ''; |
|
566 | 566 | |
567 | 567 | $top_pagination = $with_pagination && !empty($args['top_pagination']) ? true : false; |
568 | - $bottom_pagination = $with_pagination && !empty($args['bottom_pagination']) ? true : false; |
|
568 | + $bottom_pagination = $with_pagination && !empty($args['bottom_pagination']) ? true : false; |
|
569 | 569 | |
570 | 570 | $shortcode_atts = !empty($args['shortcode_atts']) ? $args['shortcode_atts'] : array(); |
571 | 571 | |
572 | 572 | // ajax mode |
573 | - $geodir_ajax = !empty($args['geodir_ajax']) ? true : false; |
|
574 | - $pageno = $geodir_ajax && !empty($args['pageno']) ? $args['pageno'] : 1; |
|
573 | + $geodir_ajax = !empty($args['geodir_ajax']) ? true : false; |
|
574 | + $pageno = $geodir_ajax && !empty($args['pageno']) ? $args['pageno'] : 1; |
|
575 | 575 | |
576 | 576 | $query_args = array( |
577 | 577 | 'posts_per_page' => $post_number, |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | if(!pid > 0 || !(container && typeof container != 'undefined')) { |
723 | 723 | return false; |
724 | 724 | } |
725 | - var scatts = "<?php echo addslashes(json_encode($shortcode_atts));?>"; |
|
725 | + var scatts = "<?php echo addslashes(json_encode($shortcode_atts)); ?>"; |
|
726 | 726 | |
727 | 727 | var data = { |
728 | 728 | 'action': 'geodir_sclistings', |
@@ -802,7 +802,7 @@ discard block |
||
802 | 802 | if ($max_page > 1 || $always_show) { |
803 | 803 | // Extra pagination info |
804 | 804 | $geodir_pagination_more_info = get_option('geodir_pagination_advance_info'); |
805 | - $start_no = ( $pageno - 1 ) * $posts_per_page + 1; |
|
805 | + $start_no = ($pageno - 1) * $posts_per_page + 1; |
|
806 | 806 | $end_no = min($pageno * $posts_per_page, $numposts); |
807 | 807 | |
808 | 808 | if ($geodir_pagination_more_info != '') { |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | } |
822 | 822 | |
823 | 823 | if (($pageno - 1) > 0) { |
824 | - echo '<a class="gd-page-sc-prev" href="javascript:void(0);" onclick="gd_sc_gopage(this, ' . (int)($pageno - 1) . ');">' . $prelabel . '</a> '; |
|
824 | + echo '<a class="gd-page-sc-prev" href="javascript:void(0);" onclick="gd_sc_gopage(this, ' . (int) ($pageno - 1) . ');">' . $prelabel . '</a> '; |
|
825 | 825 | } |
826 | 826 | |
827 | 827 | for ($i = $pageno - $half_pages_to_show; $i <= $pageno + $half_pages_to_show; $i++) { |
@@ -829,17 +829,17 @@ discard block |
||
829 | 829 | if ($i == $pageno) { |
830 | 830 | echo "<strong class='on' class='gd-page-sc-act'>$i</strong>"; |
831 | 831 | } else { |
832 | - echo ' <a class="gd-page-sc-no" href="javascript:void(0);" onclick="gd_sc_gopage(this, ' . (int)$i . ');">' . $i . '</a> '; |
|
832 | + echo ' <a class="gd-page-sc-no" href="javascript:void(0);" onclick="gd_sc_gopage(this, ' . (int) $i . ');">' . $i . '</a> '; |
|
833 | 833 | } |
834 | 834 | } |
835 | 835 | } |
836 | 836 | |
837 | 837 | if (($pageno + 1) <= $max_page) { |
838 | - echo ' <a class="gd-page-sc-nxt" href="javascript:void(0);" onclick="gd_sc_gopage(this, ' . (int)($pageno + 1) . ');">' . $nxtlabel . '</a>'; |
|
838 | + echo ' <a class="gd-page-sc-nxt" href="javascript:void(0);" onclick="gd_sc_gopage(this, ' . (int) ($pageno + 1) . ');">' . $nxtlabel . '</a>'; |
|
839 | 839 | } |
840 | 840 | |
841 | 841 | if ($pageno < $max_page) { |
842 | - echo ' <a class="gd-page-sc-lst" href="javascript:void(0);" onclick="gd_sc_gopage(this, ' . (int)$max_page . ');">»</a>'; |
|
842 | + echo ' <a class="gd-page-sc-lst" href="javascript:void(0);" onclick="gd_sc_gopage(this, ' . (int) $max_page . ');">»</a>'; |
|
843 | 843 | } |
844 | 844 | echo "</div> $after"; |
845 | 845 | } |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | $scatts = isset($_POST['scatts']) ? $_POST['scatts'] : NULL; |
863 | 863 | $pageno = isset($_POST['pageno']) ? absint($_POST['pageno']) : 1; |
864 | 864 | |
865 | - $shortcode_atts = !empty($scatts) ? (array)json_decode(stripslashes_deep($scatts)) : NULL; |
|
865 | + $shortcode_atts = !empty($scatts) ? (array) json_decode(stripslashes_deep($scatts)) : NULL; |
|
866 | 866 | |
867 | 867 | if (!empty($shortcode_atts) && is_array($shortcode_atts)) { |
868 | 868 | $shortcode_atts['pageno'] = $pageno; |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * @package GeoDirectory |
14 | 14 | * @global object $current_user Current user object. |
15 | 15 | * @param bool $redirect Optional. Do you want to redirect to signup page, if user not logged in? Default: false. |
16 | - * @return bool |
|
16 | + * @return null|boolean |
|
17 | 17 | */ |
18 | 18 | function geodir_is_login($redirect = false) |
19 | 19 | { |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @since 1.0.0 |
71 | 71 | * @package GeoDirectory |
72 | - * @return string|mixed|void The email ID. |
|
72 | + * @return string The email ID. |
|
73 | 73 | */ |
74 | 74 | function geodir_get_site_email_id() |
75 | 75 | { |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Account Signup functions. |
|
4 | - * |
|
5 | - * @since 1.0.0 |
|
6 | - * @package GeoDirectory |
|
7 | - */ |
|
3 | + * Account Signup functions. |
|
4 | + * |
|
5 | + * @since 1.0.0 |
|
6 | + * @package GeoDirectory |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Check whether the user is logged in or not. |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | if ($redirect) { |
23 | 23 | ?> |
24 | 24 | <script type="text/javascript"> |
25 | - window.location.href = '<?php echo geodir_login_url();?>'; |
|
25 | + window.location.href = '<?php echo geodir_login_url(); ?>'; |
|
26 | 26 | </script> |
27 | 27 | <?php |
28 | 28 | } else |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | */ |
237 | 237 | $message = apply_filters('password_reset_message', $message, $new_pass); |
238 | 238 | //geodir_sendEmail($fromEmail,$fromEmailName,$user_email,$user_name,$title,$message,$extra='');///forgot password email |
239 | - geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $user_name, $title, $message, $extra = '', 'forgot_password', $post_id = '', $user->ID);///forgot password email |
|
239 | + geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $user_name, $title, $message, $extra = '', 'forgot_password', $post_id = '', $user->ID); ///forgot password email |
|
240 | 240 | |
241 | 241 | return true; |
242 | 242 | } |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | |
397 | 397 | /////////////customer email////////////// |
398 | 398 | //geodir_sendEmail($fromEmail,$fromEmailName,$user_email,$userName,$subject,$client_message,$extra='');///To client email |
399 | - geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $userName, '', $message, '', 'registration', '', $user_id);/// registration email |
|
399 | + geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $userName, '', $message, '', 'registration', '', $user_id); /// registration email |
|
400 | 400 | //////REGISTRATION EMAIL END//////// |
401 | 401 | } |
402 | 402 | |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | exit(); |
508 | 508 | } |
509 | 509 | |
510 | - wp_redirect(geodir_login_url(array('error'=>'invalidkey','action'=>'lostpassword'))); |
|
510 | + wp_redirect(geodir_login_url(array('error'=>'invalidkey', 'action'=>'lostpassword'))); |
|
511 | 511 | exit(); |
512 | 512 | |
513 | 513 | break; |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | if (isset($_REQUEST['pagetype']) && $_REQUEST['pagetype'] != '') { |
726 | 726 | wp_redirect($_REQUEST['pagetype'] . '&emsg=1'); |
727 | 727 | } else { |
728 | - wp_redirect(geodir_login_url(array('logemsg'=>'1','redirect_to'=>urlencode($_REQUEST['redirect_to'])))); |
|
728 | + wp_redirect(geodir_login_url(array('logemsg'=>'1', 'redirect_to'=>urlencode($_REQUEST['redirect_to'])))); |
|
729 | 729 | } |
730 | 730 | exit; |
731 | 731 | } |
@@ -25,11 +25,13 @@ discard block |
||
25 | 25 | window.location.href = '<?php echo geodir_login_url();?>'; |
26 | 26 | </script> |
27 | 27 | <?php |
28 | - } else |
|
29 | - return false; |
|
30 | - } else |
|
31 | - return true; |
|
32 | -} |
|
28 | + } else { |
|
29 | + return false; |
|
30 | + } |
|
31 | + } else { |
|
32 | + return true; |
|
33 | + } |
|
34 | + } |
|
33 | 35 | |
34 | 36 | /** |
35 | 37 | * Redirect to SSL url, if SSL is being used. |
@@ -60,7 +62,9 @@ discard block |
||
60 | 62 | * @param string $message Login message. |
61 | 63 | */ |
62 | 64 | $message = apply_filters('login_message', $message); |
63 | - if (!empty($message)) echo $message . "\n"; |
|
65 | + if (!empty($message)) { |
|
66 | + echo $message . "\n"; |
|
67 | + } |
|
64 | 68 | |
65 | 69 | } |
66 | 70 | |
@@ -141,14 +145,16 @@ discard block |
||
141 | 145 | global $wpdb; |
142 | 146 | |
143 | 147 | $errors = new WP_Error(); |
144 | - if (empty($_POST['user_login']) && empty($_POST['user_email'])) |
|
145 | - $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.', 'geodirectory')); |
|
148 | + if (empty($_POST['user_login']) && empty($_POST['user_email'])) { |
|
149 | + $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.', 'geodirectory')); |
|
150 | + } |
|
146 | 151 | |
147 | 152 | if (strpos($_POST['user_login'], '@')) { |
148 | 153 | //$user_data = get_user_by_email(trim($_POST['user_login'])); |
149 | 154 | $user_data = get_user_by('email', trim($_POST['user_login'])); |
150 | - if (empty($user_data)) |
|
151 | - $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.', 'geodirectory')); |
|
155 | + if (empty($user_data)) { |
|
156 | + $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.', 'geodirectory')); |
|
157 | + } |
|
152 | 158 | } else { |
153 | 159 | $login = trim($_POST['user_login']); |
154 | 160 | $user_data = get_user_by('email', $login); |
@@ -161,8 +167,9 @@ discard block |
||
161 | 167 | */ |
162 | 168 | do_action('lostpassword_post'); |
163 | 169 | |
164 | - if ($errors->get_error_code()) |
|
165 | - return $errors; |
|
170 | + if ($errors->get_error_code()) { |
|
171 | + return $errors; |
|
172 | + } |
|
166 | 173 | |
167 | 174 | if (!$user_data) { |
168 | 175 | $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.', 'geodirectory')); |
@@ -192,8 +199,9 @@ discard block |
||
192 | 199 | ) |
193 | 200 | ); |
194 | 201 | |
195 | - if (empty($user)) |
|
196 | - return new WP_Error('invalid_key', __('Invalid key', 'geodirectory')); |
|
202 | + if (empty($user)) { |
|
203 | + return new WP_Error('invalid_key', __('Invalid key', 'geodirectory')); |
|
204 | + } |
|
197 | 205 | |
198 | 206 | $new_pass = wp_generate_password(12, false); |
199 | 207 | |
@@ -282,13 +290,14 @@ discard block |
||
282 | 290 | } |
283 | 291 | |
284 | 292 | // Check the username |
285 | - if ($user_login == '') |
|
286 | - $errors->add('empty_username', __('ERROR: Please enter a username.', 'geodirectory')); |
|
287 | - elseif (!validate_username($user_login)) { |
|
293 | + if ($user_login == '') { |
|
294 | + $errors->add('empty_username', __('ERROR: Please enter a username.', 'geodirectory')); |
|
295 | + } elseif (!validate_username($user_login)) { |
|
288 | 296 | $errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid. Please enter a valid username.', 'geodirectory')); |
289 | 297 | $user_login = ''; |
290 | - } elseif (username_exists($user_login)) |
|
291 | - $errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered, please choose another one.', 'geodirectory')); |
|
298 | + } elseif (username_exists($user_login)) { |
|
299 | + $errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered, please choose another one.', 'geodirectory')); |
|
300 | + } |
|
292 | 301 | |
293 | 302 | // Check the e-mail address |
294 | 303 | if ($user_email == '') { |
@@ -296,8 +305,9 @@ discard block |
||
296 | 305 | } elseif (!is_email($user_email)) { |
297 | 306 | $errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn’t correct.', 'geodirectory')); |
298 | 307 | $user_email = ''; |
299 | - } elseif (email_exists($user_email)) |
|
300 | - $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.', 'geodirectory')); |
|
308 | + } elseif (email_exists($user_email)) { |
|
309 | + $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.', 'geodirectory')); |
|
310 | + } |
|
301 | 311 | |
302 | 312 | /** |
303 | 313 | * Called when registering a new user. |
@@ -317,8 +327,9 @@ discard block |
||
317 | 327 | */ |
318 | 328 | $errors = apply_filters('registration_errors', $errors); |
319 | 329 | |
320 | - if ($errors->get_error_code()) |
|
321 | - return $errors; |
|
330 | + if ($errors->get_error_code()) { |
|
331 | + return $errors; |
|
332 | + } |
|
322 | 333 | |
323 | 334 | |
324 | 335 | if (!isset($user_pass) || $user_pass == '') { |
@@ -423,28 +434,33 @@ discard block |
||
423 | 434 | |
424 | 435 | $errors = new WP_Error(); |
425 | 436 | |
426 | - if (isset($_GET['key'])) |
|
427 | - $action = 'resetpass'; |
|
437 | + if (isset($_GET['key'])) { |
|
438 | + $action = 'resetpass'; |
|
439 | + } |
|
428 | 440 | |
429 | 441 | // validate action so as to default to the login screen |
430 | - if (!in_array($action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login')) && false === has_filter('login_form_' . $action)) |
|
431 | - $action = 'login'; |
|
442 | + if (!in_array($action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login')) && false === has_filter('login_form_' . $action)) { |
|
443 | + $action = 'login'; |
|
444 | + } |
|
432 | 445 | |
433 | 446 | nocache_headers(); |
434 | 447 | |
435 | 448 | if (defined('RELOCATE')) { // Move flag is set |
436 | - if (isset($_SERVER['PATH_INFO']) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF'])) |
|
437 | - $_SERVER['PHP_SELF'] = str_replace($_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF']); |
|
449 | + if (isset($_SERVER['PATH_INFO']) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF'])) { |
|
450 | + $_SERVER['PHP_SELF'] = str_replace($_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF']); |
|
451 | + } |
|
438 | 452 | |
439 | 453 | $schema = (isset($_SERVER['HTTPS']) && geodir_strtolower($_SERVER['HTTPS']) == 'on') ? 'https://' : 'http://'; |
440 | - if (dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != home_url()) |
|
441 | - update_option('siteurl', dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'])); |
|
454 | + if (dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != home_url()) { |
|
455 | + update_option('siteurl', dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'])); |
|
456 | + } |
|
442 | 457 | } |
443 | 458 | |
444 | 459 | //Set a cookie now to see if they are supported by the browser. |
445 | 460 | //setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN); |
446 | - if (SITECOOKIEPATH != COOKIEPATH) |
|
447 | - setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN); |
|
461 | + if (SITECOOKIEPATH != COOKIEPATH) { |
|
462 | + setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN); |
|
463 | + } |
|
448 | 464 | |
449 | 465 | /** |
450 | 466 | * Allow plugins to override the default actions, and to add extra actions if they want on the register/signin page. |
@@ -465,8 +481,9 @@ discard block |
||
465 | 481 | |
466 | 482 | $redirect_to = $_SERVER['HTTP_REFERER']; |
467 | 483 | //$redirect_to = home_url().'/?ptype=login&loggedout=true'; |
468 | - if (isset($_REQUEST['redirect_to'])) |
|
469 | - $redirect_to = $_REQUEST['redirect_to']; |
|
484 | + if (isset($_REQUEST['redirect_to'])) { |
|
485 | + $redirect_to = $_REQUEST['redirect_to']; |
|
486 | + } |
|
470 | 487 | $redirect_to = home_url(); |
471 | 488 | wp_safe_redirect($redirect_to); |
472 | 489 | exit(); |
@@ -486,7 +503,9 @@ discard block |
||
486 | 503 | exit(); |
487 | 504 | } |
488 | 505 | } |
489 | - if (isset($_GET['error']) && 'invalidkey' == $_GET['error']) $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.', 'geodirectory')); |
|
506 | + if (isset($_GET['error']) && 'invalidkey' == $_GET['error']) { |
|
507 | + $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.', 'geodirectory')); |
|
508 | + } |
|
490 | 509 | /** |
491 | 510 | * Called in the geodir_user_signup() function during the lostpassword case. |
492 | 511 | * |
@@ -582,8 +601,9 @@ discard block |
||
582 | 601 | } |
583 | 602 | |
584 | 603 | |
585 | - if (!$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && (0 !== strpos($redirect_to, 'https')) && (0 === strpos($redirect_to, 'http'))) |
|
586 | - $secure_cookie = false; |
|
604 | + if (!$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && (0 !== strpos($redirect_to, 'https')) && (0 === strpos($redirect_to, 'http'))) { |
|
605 | + $secure_cookie = false; |
|
606 | + } |
|
587 | 607 | |
588 | 608 | $user = wp_signon('', $secure_cookie); |
589 | 609 | |
@@ -652,22 +672,26 @@ discard block |
||
652 | 672 | $default_author_link = apply_filters('geodir_dashboard_author_link', $default_author_link, $user_ID); |
653 | 673 | |
654 | 674 | $_REQUEST['redirect_to'] = $default_author_link; |
655 | - else: |
|
656 | - $_REQUEST['redirect_to'] = home_url(); |
|
675 | + else { |
|
676 | + : |
|
677 | + $_REQUEST['redirect_to'] = home_url(); |
|
678 | + } |
|
657 | 679 | endif; |
658 | 680 | |
659 | 681 | } |
660 | 682 | if (isset($_REQUEST['redirect_to'])) { |
661 | 683 | $redirect_to = $_REQUEST['redirect_to']; |
662 | 684 | // Redirect to https if user wants ssl |
663 | - if ($secure_cookie && false !== strpos($redirect_to, 'wp-admin')) |
|
664 | - $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to); |
|
685 | + if ($secure_cookie && false !== strpos($redirect_to, 'wp-admin')) { |
|
686 | + $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to); |
|
687 | + } |
|
665 | 688 | } else { |
666 | 689 | $redirect_to = admin_url(); |
667 | 690 | } |
668 | 691 | |
669 | - if (!$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && (0 !== strpos($redirect_to, 'https')) && (0 === strpos($redirect_to, 'http'))) |
|
670 | - $secure_cookie = false; |
|
692 | + if (!$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && (0 !== strpos($redirect_to, 'https')) && (0 === strpos($redirect_to, 'http'))) { |
|
693 | + $secure_cookie = false; |
|
694 | + } |
|
671 | 695 | $user = wp_signon('', $secure_cookie); |
672 | 696 | |
673 | 697 | |
@@ -702,11 +726,13 @@ discard block |
||
702 | 726 | $errors = $user; |
703 | 727 | |
704 | 728 | // Clear errors if loggedout is set. |
705 | - if (!empty($_GET['loggedout'])) |
|
706 | - $errors = new WP_Error(); |
|
729 | + if (!empty($_GET['loggedout'])) { |
|
730 | + $errors = new WP_Error(); |
|
731 | + } |
|
707 | 732 | // If cookies are disabled we can't log in even with a valid user+pass |
708 | - if (isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE])) |
|
709 | - $errors->add('test_cookie', __("<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress.", 'geodirectory')); |
|
733 | + if (isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE])) { |
|
734 | + $errors->add('test_cookie', __("<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress.", 'geodirectory')); |
|
735 | + } |
|
710 | 736 | |
711 | 737 | // Some parts of this script use the main login form to display a message |
712 | 738 | if (isset($_GET['loggedout']) && TRUE == $_GET['loggedout']) { |
@@ -393,7 +393,7 @@ |
||
393 | 393 | * @global object $post The current post object. |
394 | 394 | * @global object $geodirectory Not yet implemented. |
395 | 395 | * @param string $slug The template slug. |
396 | - * @param null $name The template name. |
|
396 | + * @param string $name The template name. |
|
397 | 397 | */ |
398 | 398 | function geodir_get_template_part($slug = '', $name = NULL) |
399 | 399 | { |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Template functions |
|
4 | - * |
|
5 | - * @since 1.0.0 |
|
6 | - * @package GeoDirectory |
|
7 | - */ |
|
3 | + * Template functions |
|
4 | + * |
|
5 | + * @since 1.0.0 |
|
6 | + * @package GeoDirectory |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Locates template based on the template type. |
@@ -29,21 +29,21 @@ discard block |
||
29 | 29 | case 'add-listing': |
30 | 30 | |
31 | 31 | $sc_post_type = ''; |
32 | - if (is_page() && isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) { |
|
32 | + if (is_page() && isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) { |
|
33 | 33 | $listing_page_id = $post->ID; |
34 | 34 | |
35 | - $regex_pattern = get_shortcode_regex(); |
|
36 | - preg_match('/'.$regex_pattern.'/s', $post->post_content, $regex_matches); |
|
35 | + $regex_pattern = get_shortcode_regex(); |
|
36 | + preg_match('/'.$regex_pattern.'/s', $post->post_content, $regex_matches); |
|
37 | 37 | |
38 | - if (!empty($regex_matches) && isset($regex_matches[2]) == 'gd_add_listing' && isset($regex_matches[3])) { |
|
39 | - $shortcode_atts = shortcode_parse_atts($regex_matches[3]); |
|
40 | - $sc_post_type = !empty($shortcode_atts) && isset($shortcode_atts['listing_type']) && !empty($shortcode_atts['listing_type']) ? $shortcode_atts['listing_type'] : ''; |
|
41 | - } |
|
38 | + if (!empty($regex_matches) && isset($regex_matches[2]) == 'gd_add_listing' && isset($regex_matches[3])) { |
|
39 | + $shortcode_atts = shortcode_parse_atts($regex_matches[3]); |
|
40 | + $sc_post_type = !empty($shortcode_atts) && isset($shortcode_atts['listing_type']) && !empty($shortcode_atts['listing_type']) ? $shortcode_atts['listing_type'] : ''; |
|
41 | + } |
|
42 | 42 | } else { |
43 | 43 | $listing_page_id = geodir_add_listing_page_id(); |
44 | 44 | } |
45 | 45 | |
46 | - $is_wpml = function_exists('icl_object_id') ? true : false; |
|
46 | + $is_wpml = function_exists('icl_object_id') ? true : false; |
|
47 | 47 | |
48 | 48 | if ($listing_page_id != '' && (is_page($listing_page_id) || ($is_wpml && !empty($wp->query_vars['page_id']))) && isset($_REQUEST['listing_type']) |
49 | 49 | && in_array($_REQUEST['listing_type'], geodir_get_posttypes()) |
@@ -55,14 +55,14 @@ discard block |
||
55 | 55 | if (!empty($post_types)) |
56 | 56 | $post_type = $post_types[0]; |
57 | 57 | |
58 | - if($sc_post_type != '' ) |
|
59 | - $post_type = $sc_post_type; |
|
58 | + if($sc_post_type != '' ) |
|
59 | + $post_type = $sc_post_type; |
|
60 | 60 | |
61 | 61 | if ($is_wpml && !empty($wp->query_vars['page_id'])) { |
62 | - wp_redirect(geodir_getlink(get_permalink($wp->query_vars['page_id']), array('listing_type' => $post_type))); |
|
63 | - } else { |
|
64 | - wp_redirect(trailingslashit(get_site_url()) . $pagename . '/?listing_type=' . $post_type); |
|
65 | - } |
|
62 | + wp_redirect(geodir_getlink(get_permalink($wp->query_vars['page_id']), array('listing_type' => $post_type))); |
|
63 | + } else { |
|
64 | + wp_redirect(trailingslashit(get_site_url()) . $pagename . '/?listing_type=' . $post_type); |
|
65 | + } |
|
66 | 66 | exit(); |
67 | 67 | } |
68 | 68 | return $template = locate_template(array("geodirectory/add-{$post_type}.php", "geodirectory/add-listing.php")); |
@@ -481,21 +481,21 @@ discard block |
||
481 | 481 | */ |
482 | 482 | function geodir_display_message_not_found_on_listing($template_listview = 'listing-listview', $favorite = false) { |
483 | 483 | if ($favorite) { |
484 | - $message = __('No favorite listings found which match your selection.', 'geodirectory'); |
|
485 | - } else { |
|
486 | - $message = __('No listings found which match your selection.', 'geodirectory'); |
|
487 | - } |
|
484 | + $message = __('No favorite listings found which match your selection.', 'geodirectory'); |
|
485 | + } else { |
|
486 | + $message = __('No listings found which match your selection.', 'geodirectory'); |
|
487 | + } |
|
488 | 488 | |
489 | - /** |
|
490 | - * Filter the no listing found message. |
|
491 | - * |
|
492 | - * @since 1.5.5 |
|
493 | - * @param string $template_listview Listing listview template. |
|
494 | - * @param bool $favorite Are favorite listings results? |
|
495 | - */ |
|
496 | - $message = apply_filters('geodir_message_listing_not_found', $message, $template_listview, $favorite); |
|
489 | + /** |
|
490 | + * Filter the no listing found message. |
|
491 | + * |
|
492 | + * @since 1.5.5 |
|
493 | + * @param string $template_listview Listing listview template. |
|
494 | + * @param bool $favorite Are favorite listings results? |
|
495 | + */ |
|
496 | + $message = apply_filters('geodir_message_listing_not_found', $message, $template_listview, $favorite); |
|
497 | 497 | |
498 | - echo '<li class="no-listing">' . $message . '</li>'; |
|
498 | + echo '<li class="no-listing">' . $message . '</li>'; |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | /** |
@@ -509,9 +509,9 @@ discard block |
||
509 | 509 | * @return string Breadcrumb HTML. |
510 | 510 | */ |
511 | 511 | function geodir_strip_breadcrumb_li_wrappers($breadcrumb, $separator) { |
512 | - $breadcrumb = str_replace(array('</li><li>', '</li> <li>'), '', $breadcrumb); |
|
512 | + $breadcrumb = str_replace(array('</li><li>', '</li> <li>'), '', $breadcrumb); |
|
513 | 513 | |
514 | - return $breadcrumb; |
|
514 | + return $breadcrumb; |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | /** |
@@ -522,30 +522,30 @@ discard block |
||
522 | 522 | * @return string Listing listview class. |
523 | 523 | */ |
524 | 524 | function geodir_convert_listing_view_class($columns = '') { |
525 | - $class = ''; |
|
525 | + $class = ''; |
|
526 | 526 | |
527 | - switch ((int)$columns) { |
|
528 | - case 1: |
|
529 | - $class = ''; |
|
530 | - break; |
|
531 | - case 2: |
|
532 | - $class = 'gridview_onehalf'; |
|
533 | - break; |
|
534 | - case 3: |
|
535 | - $class = 'gridview_onethird'; |
|
536 | - break; |
|
537 | - case 4: |
|
538 | - $class = 'gridview_onefourth'; |
|
539 | - break; |
|
540 | - case 5: |
|
541 | - $class = 'gridview_onefifth'; |
|
542 | - break; |
|
543 | - default: |
|
544 | - $class = ''; |
|
545 | - break; |
|
546 | - } |
|
527 | + switch ((int)$columns) { |
|
528 | + case 1: |
|
529 | + $class = ''; |
|
530 | + break; |
|
531 | + case 2: |
|
532 | + $class = 'gridview_onehalf'; |
|
533 | + break; |
|
534 | + case 3: |
|
535 | + $class = 'gridview_onethird'; |
|
536 | + break; |
|
537 | + case 4: |
|
538 | + $class = 'gridview_onefourth'; |
|
539 | + break; |
|
540 | + case 5: |
|
541 | + $class = 'gridview_onefifth'; |
|
542 | + break; |
|
543 | + default: |
|
544 | + $class = ''; |
|
545 | + break; |
|
546 | + } |
|
547 | 547 | |
548 | - return $class; |
|
548 | + return $class; |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | /** |
@@ -558,18 +558,18 @@ discard block |
||
558 | 558 | * @return bool Modified value for display the excerpt. |
559 | 559 | */ |
560 | 560 | function geodir_show_listing_post_excerpt($display, $view, $post) { |
561 | - if ($view == 'listview') { |
|
562 | - if (geodir_is_page('author')) { |
|
563 | - $word_limit = get_option('geodir_author_desc_word_limit'); |
|
564 | - } else { |
|
565 | - $word_limit = get_option('geodir_desc_word_limit'); |
|
566 | - } |
|
561 | + if ($view == 'listview') { |
|
562 | + if (geodir_is_page('author')) { |
|
563 | + $word_limit = get_option('geodir_author_desc_word_limit'); |
|
564 | + } else { |
|
565 | + $word_limit = get_option('geodir_desc_word_limit'); |
|
566 | + } |
|
567 | 567 | |
568 | - if ($word_limit !== '' && ($word_limit == 0 || $word_limit == '0')) { |
|
569 | - $display = false; |
|
570 | - } |
|
571 | - } |
|
572 | - return $display; |
|
568 | + if ($word_limit !== '' && ($word_limit == 0 || $word_limit == '0')) { |
|
569 | + $display = false; |
|
570 | + } |
|
571 | + } |
|
572 | + return $display; |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | /** |
@@ -584,24 +584,24 @@ discard block |
||
584 | 584 | * @return string Rating icons html content. |
585 | 585 | */ |
586 | 586 | function geodir_font_awesome_rating_form_html($html, $star_texts = array(), $default = '') { |
587 | - if (get_option('geodir_reviewrating_enable_font_awesome') == '1') { |
|
588 | - $html = '<select class="gd-fa-rating">'; |
|
589 | - $html .= '<option value=""></option>'; |
|
590 | - if (!empty($star_texts) && is_array($star_texts)) { |
|
591 | - foreach ($star_texts as $i => $text) { |
|
592 | - $html .= '<option ' . selected((int)($i + 1), (int)$default, false) . ' value="' . (int)($i + 1) . '">' . $text . '</option>'; |
|
593 | - } |
|
594 | - } else { |
|
595 | - $html .= '<option value="1">1</option>'; |
|
596 | - $html .= '<option value="2">2</option>'; |
|
597 | - $html .= '<option value="3">3</option>'; |
|
598 | - $html .= '<option value="4">4</option>'; |
|
599 | - $html .= '<option value="5">5</option>'; |
|
600 | - } |
|
601 | - $html .= '</select>'; |
|
602 | - } |
|
603 | - |
|
604 | - return $html; |
|
587 | + if (get_option('geodir_reviewrating_enable_font_awesome') == '1') { |
|
588 | + $html = '<select class="gd-fa-rating">'; |
|
589 | + $html .= '<option value=""></option>'; |
|
590 | + if (!empty($star_texts) && is_array($star_texts)) { |
|
591 | + foreach ($star_texts as $i => $text) { |
|
592 | + $html .= '<option ' . selected((int)($i + 1), (int)$default, false) . ' value="' . (int)($i + 1) . '">' . $text . '</option>'; |
|
593 | + } |
|
594 | + } else { |
|
595 | + $html .= '<option value="1">1</option>'; |
|
596 | + $html .= '<option value="2">2</option>'; |
|
597 | + $html .= '<option value="3">3</option>'; |
|
598 | + $html .= '<option value="4">4</option>'; |
|
599 | + $html .= '<option value="5">5</option>'; |
|
600 | + } |
|
601 | + $html .= '</select>'; |
|
602 | + } |
|
603 | + |
|
604 | + return $html; |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | /** |
@@ -616,20 +616,20 @@ discard block |
||
616 | 616 | * @return string Rating icons html content. |
617 | 617 | */ |
618 | 618 | function geodir_font_awesome_rating_stars_html($html, $rating, $star_count = 5) { |
619 | - if (get_option('geodir_reviewrating_enable_font_awesome') == '1') { |
|
620 | - $rating = min($rating, $star_count); |
|
621 | - $full_stars = floor( $rating ); |
|
622 | - $half_stars = ceil( $rating - $full_stars ); |
|
623 | - $empty_stars = $star_count - $full_stars - $half_stars; |
|
619 | + if (get_option('geodir_reviewrating_enable_font_awesome') == '1') { |
|
620 | + $rating = min($rating, $star_count); |
|
621 | + $full_stars = floor( $rating ); |
|
622 | + $half_stars = ceil( $rating - $full_stars ); |
|
623 | + $empty_stars = $star_count - $full_stars - $half_stars; |
|
624 | 624 | |
625 | - $html = '<div class="gd-star-rating gd-fa-star-rating">'; |
|
626 | - $html .= str_repeat( '<i class="fa fa-star gd-full-star"></i>', $full_stars ); |
|
627 | - $html .= str_repeat( '<i class="fa fa-star-o fa-star-half-full gd-half-star"></i>', $half_stars ); |
|
628 | - $html .= str_repeat( '<i class="fa fa-star-o gd-empty-star"></i>', $empty_stars); |
|
629 | - $html .= '</div>'; |
|
630 | - } |
|
631 | - |
|
632 | - return $html; |
|
625 | + $html = '<div class="gd-star-rating gd-fa-star-rating">'; |
|
626 | + $html .= str_repeat( '<i class="fa fa-star gd-full-star"></i>', $full_stars ); |
|
627 | + $html .= str_repeat( '<i class="fa fa-star-o fa-star-half-full gd-half-star"></i>', $half_stars ); |
|
628 | + $html .= str_repeat( '<i class="fa fa-star-o gd-empty-star"></i>', $empty_stars); |
|
629 | + $html .= '</div>'; |
|
630 | + } |
|
631 | + |
|
632 | + return $html; |
|
633 | 633 | } |
634 | 634 | |
635 | 635 | /** |
@@ -639,12 +639,12 @@ discard block |
||
639 | 639 | * @package GeoDirectory |
640 | 640 | */ |
641 | 641 | function geodir_font_awesome_rating_css() { |
642 | - // Font awesome rating style |
|
643 | - if (get_option('geodir_reviewrating_enable_font_awesome') == '1') { |
|
644 | - $full_color = get_option('geodir_reviewrating_fa_full_rating_color', '#757575'); |
|
645 | - if ($full_color != '#757575') { |
|
646 | - echo '<style type="text/css">.br-theme-fontawesome-stars .br-widget a.br-active:after,.br-theme-fontawesome-stars .br-widget a.br-selected:after, |
|
642 | + // Font awesome rating style |
|
643 | + if (get_option('geodir_reviewrating_enable_font_awesome') == '1') { |
|
644 | + $full_color = get_option('geodir_reviewrating_fa_full_rating_color', '#757575'); |
|
645 | + if ($full_color != '#757575') { |
|
646 | + echo '<style type="text/css">.br-theme-fontawesome-stars .br-widget a.br-active:after,.br-theme-fontawesome-stars .br-widget a.br-selected:after, |
|
647 | 647 | .gd-star-rating i.fa {color:' . stripslashes($full_color) . '!important;</style>'; |
648 | - } |
|
649 | - } |
|
648 | + } |
|
649 | + } |
|
650 | 650 | } |
651 | 651 | \ No newline at end of file |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $listing_page_id = $post->ID; |
34 | 34 | |
35 | 35 | $regex_pattern = get_shortcode_regex(); |
36 | - preg_match('/'.$regex_pattern.'/s', $post->post_content, $regex_matches); |
|
36 | + preg_match('/' . $regex_pattern . '/s', $post->post_content, $regex_matches); |
|
37 | 37 | |
38 | 38 | if (!empty($regex_matches) && isset($regex_matches[2]) == 'gd_add_listing' && isset($regex_matches[3])) { |
39 | 39 | $shortcode_atts = shortcode_parse_atts($regex_matches[3]); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | if (!empty($post_types)) |
56 | 56 | $post_type = $post_types[0]; |
57 | 57 | |
58 | - if($sc_post_type != '' ) |
|
58 | + if ($sc_post_type != '') |
|
59 | 59 | $post_type = $sc_post_type; |
60 | 60 | |
61 | 61 | if ($is_wpml && !empty($wp->query_vars['page_id'])) { |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | */ |
411 | 411 | do_action("geodir_get_template_part_{$slug}", $slug, $name); |
412 | 412 | $templates = array(); |
413 | - $name = (string)$name; |
|
413 | + $name = (string) $name; |
|
414 | 414 | if ('' !== $name) { |
415 | 415 | $template_name = "{$slug}-{$name}.php"; |
416 | 416 | |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | function geodir_convert_listing_view_class($columns = '') { |
525 | 525 | $class = ''; |
526 | 526 | |
527 | - switch ((int)$columns) { |
|
527 | + switch ((int) $columns) { |
|
528 | 528 | case 1: |
529 | 529 | $class = ''; |
530 | 530 | break; |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | $html .= '<option value=""></option>'; |
590 | 590 | if (!empty($star_texts) && is_array($star_texts)) { |
591 | 591 | foreach ($star_texts as $i => $text) { |
592 | - $html .= '<option ' . selected((int)($i + 1), (int)$default, false) . ' value="' . (int)($i + 1) . '">' . $text . '</option>'; |
|
592 | + $html .= '<option ' . selected((int) ($i + 1), (int) $default, false) . ' value="' . (int) ($i + 1) . '">' . $text . '</option>'; |
|
593 | 593 | } |
594 | 594 | } else { |
595 | 595 | $html .= '<option value="1">1</option>'; |
@@ -618,14 +618,14 @@ discard block |
||
618 | 618 | function geodir_font_awesome_rating_stars_html($html, $rating, $star_count = 5) { |
619 | 619 | if (get_option('geodir_reviewrating_enable_font_awesome') == '1') { |
620 | 620 | $rating = min($rating, $star_count); |
621 | - $full_stars = floor( $rating ); |
|
622 | - $half_stars = ceil( $rating - $full_stars ); |
|
621 | + $full_stars = floor($rating); |
|
622 | + $half_stars = ceil($rating - $full_stars); |
|
623 | 623 | $empty_stars = $star_count - $full_stars - $half_stars; |
624 | 624 | |
625 | 625 | $html = '<div class="gd-star-rating gd-fa-star-rating">'; |
626 | - $html .= str_repeat( '<i class="fa fa-star gd-full-star"></i>', $full_stars ); |
|
627 | - $html .= str_repeat( '<i class="fa fa-star-o fa-star-half-full gd-half-star"></i>', $half_stars ); |
|
628 | - $html .= str_repeat( '<i class="fa fa-star-o gd-empty-star"></i>', $empty_stars); |
|
626 | + $html .= str_repeat('<i class="fa fa-star gd-full-star"></i>', $full_stars); |
|
627 | + $html .= str_repeat('<i class="fa fa-star-o fa-star-half-full gd-half-star"></i>', $half_stars); |
|
628 | + $html .= str_repeat('<i class="fa fa-star-o gd-empty-star"></i>', $empty_stars); |
|
629 | 629 | $html .= '</div>'; |
630 | 630 | } |
631 | 631 |
@@ -47,16 +47,19 @@ discard block |
||
47 | 47 | |
48 | 48 | if ($listing_page_id != '' && (is_page($listing_page_id) || ($is_wpml && !empty($wp->query_vars['page_id']))) && isset($_REQUEST['listing_type']) |
49 | 49 | && in_array($_REQUEST['listing_type'], geodir_get_posttypes()) |
50 | - ) |
|
51 | - $post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
50 | + ) { |
|
51 | + $post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
52 | + } |
|
52 | 53 | if (empty($post_type) && !isset($_REQUEST['pid'])) { |
53 | 54 | $pagename = $wp->query_vars['pagename']; |
54 | 55 | $post_types = geodir_get_posttypes(); |
55 | - if (!empty($post_types)) |
|
56 | - $post_type = $post_types[0]; |
|
56 | + if (!empty($post_types)) { |
|
57 | + $post_type = $post_types[0]; |
|
58 | + } |
|
57 | 59 | |
58 | - if($sc_post_type != '' ) |
|
59 | - $post_type = $sc_post_type; |
|
60 | + if($sc_post_type != '' ) { |
|
61 | + $post_type = $sc_post_type; |
|
62 | + } |
|
60 | 63 | |
61 | 64 | if ($is_wpml && !empty($wp->query_vars['page_id'])) { |
62 | 65 | wp_redirect(geodir_getlink(get_permalink($wp->query_vars['page_id']), array('listing_type' => $post_type))); |
@@ -71,14 +74,16 @@ discard block |
||
71 | 74 | $success_page_id = geodir_success_page_id(); |
72 | 75 | if ($success_page_id != '' && is_page($success_page_id) && isset($_REQUEST['listing_type']) |
73 | 76 | && in_array($_REQUEST['listing_type'], geodir_get_posttypes()) |
74 | - ) |
|
75 | - $post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
77 | + ) { |
|
78 | + $post_type = sanitize_text_field($_REQUEST['listing_type']); |
|
79 | + } |
|
76 | 80 | return $template = locate_template(array("geodirectory/{$post_type}-success.php", "geodirectory/listing-success.php")); |
77 | 81 | break; |
78 | 82 | case 'detail': |
79 | 83 | case 'preview': |
80 | - if (in_array(get_post_type(), geodir_get_posttypes())) |
|
81 | - $post_type = get_post_type(); |
|
84 | + if (in_array(get_post_type(), geodir_get_posttypes())) { |
|
85 | + $post_type = get_post_type(); |
|
86 | + } |
|
82 | 87 | return $template = locate_template(array("geodirectory/single-{$post_type}.php", "geodirectory/listing-detail.php")); |
83 | 88 | break; |
84 | 89 | case 'listing': |
@@ -184,7 +189,9 @@ discard block |
||
184 | 189 | |
185 | 190 | $template = geodir_locate_template('signup'); |
186 | 191 | |
187 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-signup.php'; |
|
192 | + if (!$template) { |
|
193 | + $template = geodir_plugin_path() . '/geodirectory-templates/geodir-signup.php'; |
|
194 | + } |
|
188 | 195 | |
189 | 196 | /** |
190 | 197 | * Filter the signup template path. |
@@ -202,7 +209,9 @@ discard block |
||
202 | 209 | |
203 | 210 | $template = geodir_locate_template('information'); |
204 | 211 | |
205 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-information.php'; |
|
212 | + if (!$template) { |
|
213 | + $template = geodir_plugin_path() . '/geodirectory-templates/geodir-information.php'; |
|
214 | + } |
|
206 | 215 | /** |
207 | 216 | * Filter the information template path. |
208 | 217 | * |
@@ -219,7 +228,9 @@ discard block |
||
219 | 228 | if (!$is_current_user_owner) { |
220 | 229 | $template = geodir_locate_template('information'); |
221 | 230 | |
222 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-information.php'; |
|
231 | + if (!$template) { |
|
232 | + $template = geodir_plugin_path() . '/geodirectory-templates/geodir-information.php'; |
|
233 | + } |
|
223 | 234 | /** |
224 | 235 | * Filter the information template path. |
225 | 236 | * |
@@ -241,7 +252,9 @@ discard block |
||
241 | 252 | |
242 | 253 | $template = geodir_locate_template('add-listing'); |
243 | 254 | |
244 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/add-listing.php'; |
|
255 | + if (!$template) { |
|
256 | + $template = geodir_plugin_path() . '/geodirectory-templates/add-listing.php'; |
|
257 | + } |
|
245 | 258 | /** |
246 | 259 | * Filter the add listing template path. |
247 | 260 | * |
@@ -258,7 +271,9 @@ discard block |
||
258 | 271 | |
259 | 272 | $template = geodir_locate_template('preview'); |
260 | 273 | |
261 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-detail.php'; |
|
274 | + if (!$template) { |
|
275 | + $template = geodir_plugin_path() . '/geodirectory-templates/listing-detail.php'; |
|
276 | + } |
|
262 | 277 | /** |
263 | 278 | * Filter the preview template path. |
264 | 279 | * |
@@ -274,7 +289,9 @@ discard block |
||
274 | 289 | |
275 | 290 | $template = geodir_locate_template('success'); |
276 | 291 | |
277 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-success.php'; |
|
292 | + if (!$template) { |
|
293 | + $template = geodir_plugin_path() . '/geodirectory-templates/listing-success.php'; |
|
294 | + } |
|
278 | 295 | /** |
279 | 296 | * Filter the success template path. |
280 | 297 | * |
@@ -289,7 +306,9 @@ discard block |
||
289 | 306 | |
290 | 307 | $template = geodir_locate_template('detail'); |
291 | 308 | |
292 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/listing-detail.php'; |
|
309 | + if (!$template) { |
|
310 | + $template = geodir_plugin_path() . '/geodirectory-templates/listing-detail.php'; |
|
311 | + } |
|
293 | 312 | /** |
294 | 313 | * Filter the detail template path. |
295 | 314 | * |
@@ -304,7 +323,9 @@ discard block |
||
304 | 323 | |
305 | 324 | $template = geodir_locate_template('listing'); |
306 | 325 | |
307 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-listing.php'; |
|
326 | + if (!$template) { |
|
327 | + $template = geodir_plugin_path() . '/geodirectory-templates/geodir-listing.php'; |
|
328 | + } |
|
308 | 329 | /** |
309 | 330 | * Filter the listing template path. |
310 | 331 | * |
@@ -319,7 +340,9 @@ discard block |
||
319 | 340 | |
320 | 341 | $template = geodir_locate_template('search'); |
321 | 342 | |
322 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-search.php'; |
|
343 | + if (!$template) { |
|
344 | + $template = geodir_plugin_path() . '/geodirectory-templates/geodir-search.php'; |
|
345 | + } |
|
323 | 346 | /** |
324 | 347 | * Filter the search template path. |
325 | 348 | * |
@@ -334,7 +357,9 @@ discard block |
||
334 | 357 | |
335 | 358 | $template = geodir_locate_template('author'); |
336 | 359 | |
337 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-author.php'; |
|
360 | + if (!$template) { |
|
361 | + $template = geodir_plugin_path() . '/geodirectory-templates/geodir-author.php'; |
|
362 | + } |
|
338 | 363 | /** |
339 | 364 | * Filter the author template path. |
340 | 365 | * |
@@ -355,7 +380,9 @@ discard block |
||
355 | 380 | |
356 | 381 | $template = geodir_locate_template('geodir-home'); |
357 | 382 | |
358 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-home.php'; |
|
383 | + if (!$template) { |
|
384 | + $template = geodir_plugin_path() . '/geodirectory-templates/geodir-home.php'; |
|
385 | + } |
|
359 | 386 | /** |
360 | 387 | * Filter the home page template path. |
361 | 388 | * |
@@ -368,7 +395,9 @@ discard block |
||
368 | 395 | |
369 | 396 | $template = geodir_locate_template('location'); |
370 | 397 | |
371 | - if (!$template) $template = geodir_plugin_path() . '/geodirectory-templates/geodir-location.php'; |
|
398 | + if (!$template) { |
|
399 | + $template = geodir_plugin_path() . '/geodirectory-templates/geodir-location.php'; |
|
400 | + } |
|
372 | 401 | /** |
373 | 402 | * Filter the location template path. |
374 | 403 | * |
@@ -377,8 +406,9 @@ discard block |
||
377 | 406 | */ |
378 | 407 | return $template = apply_filters('geodir_template_location', $template); |
379 | 408 | |
380 | - } else |
|
381 | - return $template; |
|
409 | + } else { |
|
410 | + return $template; |
|
411 | + } |
|
382 | 412 | |
383 | 413 | } |
384 | 414 | |
@@ -432,8 +462,10 @@ discard block |
||
432 | 462 | * @since 1.0.0 |
433 | 463 | */ |
434 | 464 | include($template); |
435 | - else: |
|
436 | - locate_template(array("geodirectory/" . $template_name), true, false); |
|
465 | + else { |
|
466 | + : |
|
467 | + locate_template(array("geodirectory/" . $template_name), true, false); |
|
468 | + } |
|
437 | 469 | endif; |
438 | 470 | |
439 | 471 | } |
@@ -107,7 +107,6 @@ |
||
107 | 107 | * @link http://php.net/manual/en/arrayaccess.offsetset.php |
108 | 108 | * |
109 | 109 | * @param mixed $offset The offset to assign the value to. |
110 | - * @param mixed $value The value to set. |
|
111 | 110 | * |
112 | 111 | * @return void |
113 | 112 | */ |
@@ -1,14 +1,14 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Multidimensional ArrayAccess |
|
4 | - * |
|
5 | - * Allows ArrayAccess-like functionality with multidimensional arrays. Fully supports |
|
6 | - * both sets and unsets. |
|
7 | - * |
|
8 | - * @package WordPress |
|
9 | - * @subpackage Session |
|
10 | - * @since 3.6.0 |
|
11 | - */ |
|
3 | + * Multidimensional ArrayAccess |
|
4 | + * |
|
5 | + * Allows ArrayAccess-like functionality with multidimensional arrays. Fully supports |
|
6 | + * both sets and unsets. |
|
7 | + * |
|
8 | + * @package WordPress |
|
9 | + * @subpackage Session |
|
10 | + * @since 3.6.0 |
|
11 | + */ |
|
12 | 12 | |
13 | 13 | // Exit if accessed directly |
14 | 14 | if ( ! defined( 'ABSPATH' ) ) exit; |
@@ -20,120 +20,120 @@ discard block |
||
20 | 20 | * @since 3.6.0 |
21 | 21 | */ |
22 | 22 | class Recursive_ArrayAccess implements ArrayAccess { |
23 | - /** |
|
24 | - * Internal data collection. |
|
25 | - * |
|
26 | - * @var array |
|
27 | - */ |
|
28 | - protected $container = array(); |
|
23 | + /** |
|
24 | + * Internal data collection. |
|
25 | + * |
|
26 | + * @var array |
|
27 | + */ |
|
28 | + protected $container = array(); |
|
29 | 29 | |
30 | - /** |
|
31 | - * Flag whether or not the internal collection has been changed. |
|
32 | - * |
|
33 | - * @var bool |
|
34 | - */ |
|
35 | - protected $dirty = false; |
|
30 | + /** |
|
31 | + * Flag whether or not the internal collection has been changed. |
|
32 | + * |
|
33 | + * @var bool |
|
34 | + */ |
|
35 | + protected $dirty = false; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Default object constructor. |
|
39 | - * |
|
40 | - * @param array $data |
|
41 | - */ |
|
42 | - protected function __construct( $data = array() ) { |
|
43 | - foreach ( $data as $key => $value ) { |
|
44 | - $this[ $key ] = $value; |
|
45 | - } |
|
46 | - } |
|
37 | + /** |
|
38 | + * Default object constructor. |
|
39 | + * |
|
40 | + * @param array $data |
|
41 | + */ |
|
42 | + protected function __construct( $data = array() ) { |
|
43 | + foreach ( $data as $key => $value ) { |
|
44 | + $this[ $key ] = $value; |
|
45 | + } |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Allow deep copies of objects |
|
50 | - */ |
|
51 | - public function __clone() { |
|
52 | - foreach ( $this->container as $key => $value ) { |
|
53 | - if ( $value instanceof self ) { |
|
54 | - $this[ $key ] = clone $value; |
|
55 | - } |
|
56 | - } |
|
57 | - } |
|
48 | + /** |
|
49 | + * Allow deep copies of objects |
|
50 | + */ |
|
51 | + public function __clone() { |
|
52 | + foreach ( $this->container as $key => $value ) { |
|
53 | + if ( $value instanceof self ) { |
|
54 | + $this[ $key ] = clone $value; |
|
55 | + } |
|
56 | + } |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Output the data container as a multidimensional array. |
|
61 | - * |
|
62 | - * @return array |
|
63 | - */ |
|
64 | - public function toArray() { |
|
65 | - $data = $this->container; |
|
66 | - foreach ( $data as $key => $value ) { |
|
67 | - if ( $value instanceof self ) { |
|
68 | - $data[ $key ] = $value->toArray(); |
|
69 | - } |
|
70 | - } |
|
71 | - return $data; |
|
72 | - } |
|
59 | + /** |
|
60 | + * Output the data container as a multidimensional array. |
|
61 | + * |
|
62 | + * @return array |
|
63 | + */ |
|
64 | + public function toArray() { |
|
65 | + $data = $this->container; |
|
66 | + foreach ( $data as $key => $value ) { |
|
67 | + if ( $value instanceof self ) { |
|
68 | + $data[ $key ] = $value->toArray(); |
|
69 | + } |
|
70 | + } |
|
71 | + return $data; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * ArrayAccess Implementation |
|
76 | - **/ |
|
74 | + /** |
|
75 | + * ArrayAccess Implementation |
|
76 | + **/ |
|
77 | 77 | |
78 | - /** |
|
79 | - * Whether a offset exists |
|
80 | - * |
|
81 | - * @link http://php.net/manual/en/arrayaccess.offsetexists.php |
|
82 | - * |
|
83 | - * @param mixed $offset An offset to check for. |
|
84 | - * |
|
85 | - * @return boolean true on success or false on failure. |
|
86 | - */ |
|
87 | - public function offsetExists( $offset ) { |
|
88 | - return isset( $this->container[ $offset ]) ; |
|
89 | - } |
|
78 | + /** |
|
79 | + * Whether a offset exists |
|
80 | + * |
|
81 | + * @link http://php.net/manual/en/arrayaccess.offsetexists.php |
|
82 | + * |
|
83 | + * @param mixed $offset An offset to check for. |
|
84 | + * |
|
85 | + * @return boolean true on success or false on failure. |
|
86 | + */ |
|
87 | + public function offsetExists( $offset ) { |
|
88 | + return isset( $this->container[ $offset ]) ; |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * Offset to retrieve |
|
93 | - * |
|
94 | - * @link http://php.net/manual/en/arrayaccess.offsetget.php |
|
95 | - * |
|
96 | - * @param mixed $offset The offset to retrieve. |
|
97 | - * |
|
98 | - * @return mixed Can return all value types. |
|
99 | - */ |
|
100 | - public function offsetGet( $offset ) { |
|
101 | - return isset( $this->container[ $offset ] ) ? $this->container[ $offset ] : null; |
|
102 | - } |
|
91 | + /** |
|
92 | + * Offset to retrieve |
|
93 | + * |
|
94 | + * @link http://php.net/manual/en/arrayaccess.offsetget.php |
|
95 | + * |
|
96 | + * @param mixed $offset The offset to retrieve. |
|
97 | + * |
|
98 | + * @return mixed Can return all value types. |
|
99 | + */ |
|
100 | + public function offsetGet( $offset ) { |
|
101 | + return isset( $this->container[ $offset ] ) ? $this->container[ $offset ] : null; |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * Offset to set |
|
106 | - * |
|
107 | - * @link http://php.net/manual/en/arrayaccess.offsetset.php |
|
108 | - * |
|
109 | - * @param mixed $offset The offset to assign the value to. |
|
110 | - * @param mixed $value The value to set. |
|
111 | - * |
|
112 | - * @return void |
|
113 | - */ |
|
114 | - public function offsetSet( $offset, $data ) { |
|
115 | - if ( is_array( $data ) ) { |
|
116 | - $data = new self( $data ); |
|
117 | - } |
|
118 | - if ( $offset === null ) { // don't forget this! |
|
119 | - $this->container[] = $data; |
|
120 | - } else { |
|
121 | - $this->container[ $offset ] = $data; |
|
122 | - } |
|
104 | + /** |
|
105 | + * Offset to set |
|
106 | + * |
|
107 | + * @link http://php.net/manual/en/arrayaccess.offsetset.php |
|
108 | + * |
|
109 | + * @param mixed $offset The offset to assign the value to. |
|
110 | + * @param mixed $value The value to set. |
|
111 | + * |
|
112 | + * @return void |
|
113 | + */ |
|
114 | + public function offsetSet( $offset, $data ) { |
|
115 | + if ( is_array( $data ) ) { |
|
116 | + $data = new self( $data ); |
|
117 | + } |
|
118 | + if ( $offset === null ) { // don't forget this! |
|
119 | + $this->container[] = $data; |
|
120 | + } else { |
|
121 | + $this->container[ $offset ] = $data; |
|
122 | + } |
|
123 | 123 | |
124 | - $this->dirty = true; |
|
125 | - } |
|
124 | + $this->dirty = true; |
|
125 | + } |
|
126 | 126 | |
127 | - /** |
|
128 | - * Offset to unset |
|
129 | - * |
|
130 | - * @link http://php.net/manual/en/arrayaccess.offsetunset.php |
|
131 | - * |
|
132 | - * @param mixed $offset The offset to unset. |
|
133 | - * |
|
134 | - * @return void |
|
135 | - */ |
|
136 | - public function offsetUnset( $offset ) { |
|
137 | - unset( $this->container[ $offset ] ); |
|
138 | - } |
|
127 | + /** |
|
128 | + * Offset to unset |
|
129 | + * |
|
130 | + * @link http://php.net/manual/en/arrayaccess.offsetunset.php |
|
131 | + * |
|
132 | + * @param mixed $offset The offset to unset. |
|
133 | + * |
|
134 | + * @return void |
|
135 | + */ |
|
136 | + public function offsetUnset( $offset ) { |
|
137 | + unset( $this->container[ $offset ] ); |
|
138 | + } |
|
139 | 139 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly |
14 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
14 | +if (!defined('ABSPATH')) exit; |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * Recursive array class to allow multidimensional array access. |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @param array $data |
41 | 41 | */ |
42 | - protected function __construct( $data = array() ) { |
|
43 | - foreach ( $data as $key => $value ) { |
|
44 | - $this[ $key ] = $value; |
|
42 | + protected function __construct($data = array()) { |
|
43 | + foreach ($data as $key => $value) { |
|
44 | + $this[$key] = $value; |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | * Allow deep copies of objects |
50 | 50 | */ |
51 | 51 | public function __clone() { |
52 | - foreach ( $this->container as $key => $value ) { |
|
53 | - if ( $value instanceof self ) { |
|
54 | - $this[ $key ] = clone $value; |
|
52 | + foreach ($this->container as $key => $value) { |
|
53 | + if ($value instanceof self) { |
|
54 | + $this[$key] = clone $value; |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | } |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function toArray() { |
65 | 65 | $data = $this->container; |
66 | - foreach ( $data as $key => $value ) { |
|
67 | - if ( $value instanceof self ) { |
|
68 | - $data[ $key ] = $value->toArray(); |
|
66 | + foreach ($data as $key => $value) { |
|
67 | + if ($value instanceof self) { |
|
68 | + $data[$key] = $value->toArray(); |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | return $data; |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return boolean true on success or false on failure. |
86 | 86 | */ |
87 | - public function offsetExists( $offset ) { |
|
88 | - return isset( $this->container[ $offset ]) ; |
|
87 | + public function offsetExists($offset) { |
|
88 | + return isset($this->container[$offset]); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @return mixed Can return all value types. |
99 | 99 | */ |
100 | - public function offsetGet( $offset ) { |
|
101 | - return isset( $this->container[ $offset ] ) ? $this->container[ $offset ] : null; |
|
100 | + public function offsetGet($offset) { |
|
101 | + return isset($this->container[$offset]) ? $this->container[$offset] : null; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -111,14 +111,14 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @return void |
113 | 113 | */ |
114 | - public function offsetSet( $offset, $data ) { |
|
115 | - if ( is_array( $data ) ) { |
|
116 | - $data = new self( $data ); |
|
114 | + public function offsetSet($offset, $data) { |
|
115 | + if (is_array($data)) { |
|
116 | + $data = new self($data); |
|
117 | 117 | } |
118 | - if ( $offset === null ) { // don't forget this! |
|
118 | + if ($offset === null) { // don't forget this! |
|
119 | 119 | $this->container[] = $data; |
120 | 120 | } else { |
121 | - $this->container[ $offset ] = $data; |
|
121 | + $this->container[$offset] = $data; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | $this->dirty = true; |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * |
134 | 134 | * @return void |
135 | 135 | */ |
136 | - public function offsetUnset( $offset ) { |
|
137 | - unset( $this->container[ $offset ] ); |
|
136 | + public function offsetUnset($offset) { |
|
137 | + unset($this->container[$offset]); |
|
138 | 138 | } |
139 | 139 | } |
@@ -11,7 +11,9 @@ |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly |
14 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
14 | +if ( ! defined( 'ABSPATH' ) ) { |
|
15 | + exit; |
|
16 | +} |
|
15 | 17 | |
16 | 18 | /** |
17 | 19 | * Return the current cache expire setting. |
@@ -51,7 +51,6 @@ |
||
51 | 51 | /** |
52 | 52 | * Retrieve the current session instance. |
53 | 53 | * |
54 | - * @param bool $session_id Session ID from which to populate data. |
|
55 | 54 | * |
56 | 55 | * @return bool|WP_Session |
57 | 56 | */ |
@@ -11,7 +11,9 @@ |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly |
14 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
14 | +if ( ! defined( 'ABSPATH' ) ) { |
|
15 | + exit; |
|
16 | +} |
|
15 | 17 | |
16 | 18 | /** |
17 | 19 | * Return the current cache expire setting. |
@@ -1,14 +1,14 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * WordPress session managment. |
|
4 | - * |
|
5 | - * Standardizes WordPress session data using database-backed options for storage. |
|
6 | - * for storing user session information. |
|
7 | - * |
|
8 | - * @package WordPress |
|
9 | - * @subpackage Session |
|
10 | - * @since 3.7.0 |
|
11 | - */ |
|
3 | + * WordPress session managment. |
|
4 | + * |
|
5 | + * Standardizes WordPress session data using database-backed options for storage. |
|
6 | + * for storing user session information. |
|
7 | + * |
|
8 | + * @package WordPress |
|
9 | + * @subpackage Session |
|
10 | + * @since 3.7.0 |
|
11 | + */ |
|
12 | 12 | |
13 | 13 | // Exit if accessed directly |
14 | 14 | if ( ! defined( 'ABSPATH' ) ) exit; |
@@ -20,317 +20,317 @@ discard block |
||
20 | 20 | * @since 3.7.0 |
21 | 21 | */ |
22 | 22 | final class WP_Session extends Recursive_ArrayAccess implements Iterator, Countable { |
23 | - /** |
|
24 | - * ID of the current session. |
|
25 | - * |
|
26 | - * @var string |
|
27 | - */ |
|
28 | - public $session_id; |
|
29 | - |
|
30 | - /** |
|
31 | - * Unix timestamp when session expires. |
|
32 | - * |
|
33 | - * @var int |
|
34 | - */ |
|
35 | - protected $expires; |
|
36 | - |
|
37 | - /** |
|
38 | - * Unix timestamp indicating when the expiration time needs to be reset. |
|
39 | - * |
|
40 | - * @var int |
|
41 | - */ |
|
42 | - protected $exp_variant; |
|
43 | - |
|
44 | - /** |
|
45 | - * Singleton instance. |
|
46 | - * |
|
47 | - * @var bool|WP_Session |
|
48 | - */ |
|
49 | - private static $instance = false; |
|
50 | - |
|
51 | - /** |
|
52 | - * Retrieve the current session instance. |
|
53 | - * |
|
54 | - * @param bool $session_id Session ID from which to populate data. |
|
55 | - * |
|
56 | - * @return bool|WP_Session |
|
57 | - */ |
|
58 | - public static function get_instance() { |
|
59 | - if ( ! self::$instance ) { |
|
60 | - self::$instance = new self(); |
|
61 | - } |
|
62 | - |
|
63 | - return self::$instance; |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * Default constructor. |
|
68 | - * Will rebuild the session collection from the given session ID if it exists. Otherwise, will |
|
69 | - * create a new session with that ID. |
|
70 | - * |
|
71 | - * @param $session_id |
|
72 | - * @uses apply_filters Calls `wp_session_expiration` to determine how long until sessions expire. |
|
73 | - */ |
|
74 | - protected function __construct() { |
|
75 | - if ( isset( $_COOKIE[WP_SESSION_COOKIE] ) ) { |
|
76 | - $cookie = stripslashes( $_COOKIE[WP_SESSION_COOKIE] ); |
|
77 | - $cookie_crumbs = explode( '||', $cookie ); |
|
78 | - |
|
79 | - if( $this->is_valid_md5( $cookie_crumbs[0] ) ) { |
|
80 | - |
|
81 | - $this->session_id = $cookie_crumbs[0]; |
|
82 | - |
|
83 | - } else { |
|
84 | - |
|
85 | - $this->regenerate_id( true ); |
|
86 | - |
|
87 | - } |
|
88 | - |
|
89 | - $this->expires = $cookie_crumbs[1]; |
|
90 | - $this->exp_variant = $cookie_crumbs[2]; |
|
91 | - |
|
92 | - // Update the session expiration if we're past the variant time |
|
93 | - if ( time() > $this->exp_variant ) { |
|
94 | - $this->set_expiration(); |
|
95 | - delete_option( "_wp_session_expires_{$this->session_id}" ); |
|
96 | - add_option( "_wp_session_expires_{$this->session_id}", $this->expires, '', 'no' ); |
|
97 | - } |
|
98 | - } else { |
|
99 | - $this->session_id = $this->generate_id(); |
|
100 | - $this->set_expiration(); |
|
101 | - } |
|
102 | - |
|
103 | - $this->read_data(); |
|
104 | - |
|
105 | - $this->set_cookie(); |
|
106 | - |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * Set both the expiration time and the expiration variant. |
|
111 | - * |
|
112 | - * If the current time is below the variant, we don't update the session's expiration time. If it's |
|
113 | - * greater than the variant, then we update the expiration time in the database. This prevents |
|
114 | - * writing to the database on every page load for active sessions and only updates the expiration |
|
115 | - * time if we're nearing when the session actually expires. |
|
116 | - * |
|
117 | - * By default, the expiration time is set to 30 minutes. |
|
118 | - * By default, the expiration variant is set to 24 minutes. |
|
119 | - * |
|
120 | - * As a result, the session expiration time - at a maximum - will only be written to the database once |
|
121 | - * every 24 minutes. After 30 minutes, the session will have been expired. No cookie will be sent by |
|
122 | - * the browser, and the old session will be queued for deletion by the garbage collector. |
|
123 | - * |
|
124 | - * @uses apply_filters Calls `wp_session_expiration_variant` to get the max update window for session data. |
|
125 | - * @uses apply_filters Calls `wp_session_expiration` to get the standard expiration time for sessions. |
|
126 | - */ |
|
127 | - protected function set_expiration() { |
|
128 | - $this->exp_variant = time() + (int) apply_filters( 'wp_session_expiration_variant', 24 * 60 ); |
|
129 | - $this->expires = time() + (int) apply_filters( 'wp_session_expiration', 30 * 60 ); |
|
130 | - } |
|
131 | - |
|
132 | - /** |
|
133 | - * Set the session cookie |
|
134 | - */ |
|
135 | - protected function set_cookie() { |
|
136 | - try { |
|
23 | + /** |
|
24 | + * ID of the current session. |
|
25 | + * |
|
26 | + * @var string |
|
27 | + */ |
|
28 | + public $session_id; |
|
29 | + |
|
30 | + /** |
|
31 | + * Unix timestamp when session expires. |
|
32 | + * |
|
33 | + * @var int |
|
34 | + */ |
|
35 | + protected $expires; |
|
36 | + |
|
37 | + /** |
|
38 | + * Unix timestamp indicating when the expiration time needs to be reset. |
|
39 | + * |
|
40 | + * @var int |
|
41 | + */ |
|
42 | + protected $exp_variant; |
|
43 | + |
|
44 | + /** |
|
45 | + * Singleton instance. |
|
46 | + * |
|
47 | + * @var bool|WP_Session |
|
48 | + */ |
|
49 | + private static $instance = false; |
|
50 | + |
|
51 | + /** |
|
52 | + * Retrieve the current session instance. |
|
53 | + * |
|
54 | + * @param bool $session_id Session ID from which to populate data. |
|
55 | + * |
|
56 | + * @return bool|WP_Session |
|
57 | + */ |
|
58 | + public static function get_instance() { |
|
59 | + if ( ! self::$instance ) { |
|
60 | + self::$instance = new self(); |
|
61 | + } |
|
62 | + |
|
63 | + return self::$instance; |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * Default constructor. |
|
68 | + * Will rebuild the session collection from the given session ID if it exists. Otherwise, will |
|
69 | + * create a new session with that ID. |
|
70 | + * |
|
71 | + * @param $session_id |
|
72 | + * @uses apply_filters Calls `wp_session_expiration` to determine how long until sessions expire. |
|
73 | + */ |
|
74 | + protected function __construct() { |
|
75 | + if ( isset( $_COOKIE[WP_SESSION_COOKIE] ) ) { |
|
76 | + $cookie = stripslashes( $_COOKIE[WP_SESSION_COOKIE] ); |
|
77 | + $cookie_crumbs = explode( '||', $cookie ); |
|
78 | + |
|
79 | + if( $this->is_valid_md5( $cookie_crumbs[0] ) ) { |
|
80 | + |
|
81 | + $this->session_id = $cookie_crumbs[0]; |
|
82 | + |
|
83 | + } else { |
|
84 | + |
|
85 | + $this->regenerate_id( true ); |
|
86 | + |
|
87 | + } |
|
88 | + |
|
89 | + $this->expires = $cookie_crumbs[1]; |
|
90 | + $this->exp_variant = $cookie_crumbs[2]; |
|
91 | + |
|
92 | + // Update the session expiration if we're past the variant time |
|
93 | + if ( time() > $this->exp_variant ) { |
|
94 | + $this->set_expiration(); |
|
95 | + delete_option( "_wp_session_expires_{$this->session_id}" ); |
|
96 | + add_option( "_wp_session_expires_{$this->session_id}", $this->expires, '', 'no' ); |
|
97 | + } |
|
98 | + } else { |
|
99 | + $this->session_id = $this->generate_id(); |
|
100 | + $this->set_expiration(); |
|
101 | + } |
|
102 | + |
|
103 | + $this->read_data(); |
|
104 | + |
|
105 | + $this->set_cookie(); |
|
106 | + |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * Set both the expiration time and the expiration variant. |
|
111 | + * |
|
112 | + * If the current time is below the variant, we don't update the session's expiration time. If it's |
|
113 | + * greater than the variant, then we update the expiration time in the database. This prevents |
|
114 | + * writing to the database on every page load for active sessions and only updates the expiration |
|
115 | + * time if we're nearing when the session actually expires. |
|
116 | + * |
|
117 | + * By default, the expiration time is set to 30 minutes. |
|
118 | + * By default, the expiration variant is set to 24 minutes. |
|
119 | + * |
|
120 | + * As a result, the session expiration time - at a maximum - will only be written to the database once |
|
121 | + * every 24 minutes. After 30 minutes, the session will have been expired. No cookie will be sent by |
|
122 | + * the browser, and the old session will be queued for deletion by the garbage collector. |
|
123 | + * |
|
124 | + * @uses apply_filters Calls `wp_session_expiration_variant` to get the max update window for session data. |
|
125 | + * @uses apply_filters Calls `wp_session_expiration` to get the standard expiration time for sessions. |
|
126 | + */ |
|
127 | + protected function set_expiration() { |
|
128 | + $this->exp_variant = time() + (int) apply_filters( 'wp_session_expiration_variant', 24 * 60 ); |
|
129 | + $this->expires = time() + (int) apply_filters( 'wp_session_expiration', 30 * 60 ); |
|
130 | + } |
|
131 | + |
|
132 | + /** |
|
133 | + * Set the session cookie |
|
134 | + */ |
|
135 | + protected function set_cookie() { |
|
136 | + try { |
|
137 | 137 | setcookie( WP_SESSION_COOKIE, $this->session_id . '||' . $this->expires . '||' . $this->exp_variant , $this->expires, COOKIEPATH, COOKIE_DOMAIN ); |
138 | 138 | } catch(Exception $e) { |
139 | 139 | error_log( 'Set Cookie Error: ' . $e->getMessage() ); |
140 | 140 | } |
141 | - } |
|
142 | - |
|
143 | - /** |
|
144 | - * Generate a cryptographically strong unique ID for the session token. |
|
145 | - * |
|
146 | - * @return string |
|
147 | - */ |
|
148 | - protected function generate_id() { |
|
149 | - require_once( ABSPATH . 'wp-includes/class-phpass.php'); |
|
150 | - $hasher = new PasswordHash( 8, false ); |
|
151 | - |
|
152 | - return md5( $hasher->get_random_bytes( 32 ) ); |
|
153 | - } |
|
154 | - |
|
155 | - /** |
|
156 | - * Checks if is valid md5 string |
|
157 | - * |
|
158 | - * @param string $md5 |
|
159 | - * @return int |
|
160 | - */ |
|
161 | - protected function is_valid_md5( $md5 = '' ){ |
|
162 | - return preg_match( '/^[a-f0-9]{32}$/', $md5 ); |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * Read data from a transient for the current session. |
|
167 | - * |
|
168 | - * Automatically resets the expiration time for the session transient to some time in the future. |
|
169 | - * |
|
170 | - * @return array |
|
171 | - */ |
|
172 | - protected function read_data() { |
|
173 | - $this->container = get_option( "_wp_session_{$this->session_id}", array() ); |
|
174 | - |
|
175 | - return $this->container; |
|
176 | - } |
|
177 | - |
|
178 | - /** |
|
179 | - * Write the data from the current session to the data storage system. |
|
180 | - */ |
|
181 | - public function write_data() { |
|
182 | - $option_key = "_wp_session_{$this->session_id}"; |
|
183 | - |
|
184 | - // Only write the collection to the DB if it's changed. |
|
185 | - if ( $this->dirty ) { |
|
186 | - if ( false === get_option( $option_key ) ) { |
|
187 | - add_option( "_wp_session_{$this->session_id}", $this->container, '', 'no' ); |
|
188 | - add_option( "_wp_session_expires_{$this->session_id}", $this->expires, '', 'no' ); |
|
189 | - } else { |
|
190 | - delete_option( "_wp_session_{$this->session_id}" ); |
|
191 | - add_option( "_wp_session_{$this->session_id}", $this->container, '', 'no' ); |
|
192 | - } |
|
193 | - } |
|
194 | - } |
|
195 | - |
|
196 | - /** |
|
197 | - * Output the current container contents as a JSON-encoded string. |
|
198 | - * |
|
199 | - * @return string |
|
200 | - */ |
|
201 | - public function json_out() { |
|
202 | - return json_encode( $this->container ); |
|
203 | - } |
|
204 | - |
|
205 | - /** |
|
206 | - * Decodes a JSON string and, if the object is an array, overwrites the session container with its contents. |
|
207 | - * |
|
208 | - * @param string $data |
|
209 | - * |
|
210 | - * @return bool |
|
211 | - */ |
|
212 | - public function json_in( $data ) { |
|
213 | - $array = json_decode( $data ); |
|
214 | - |
|
215 | - if ( is_array( $array ) ) { |
|
216 | - $this->container = $array; |
|
217 | - return true; |
|
218 | - } |
|
219 | - |
|
220 | - return false; |
|
221 | - } |
|
222 | - |
|
223 | - /** |
|
224 | - * Regenerate the current session's ID. |
|
225 | - * |
|
226 | - * @param bool $delete_old Flag whether or not to delete the old session data from the server. |
|
227 | - */ |
|
228 | - public function regenerate_id( $delete_old = false ) { |
|
229 | - if ( $delete_old ) { |
|
230 | - delete_option( "_wp_session_{$this->session_id}" ); |
|
231 | - } |
|
232 | - |
|
233 | - $this->session_id = $this->generate_id(); |
|
234 | - |
|
235 | - $this->set_cookie(); |
|
236 | - } |
|
237 | - |
|
238 | - /** |
|
239 | - * Check if a session has been initialized. |
|
240 | - * |
|
241 | - * @return bool |
|
242 | - */ |
|
243 | - public function session_started() { |
|
244 | - return !!self::$instance; |
|
245 | - } |
|
246 | - |
|
247 | - /** |
|
248 | - * Return the read-only cache expiration value. |
|
249 | - * |
|
250 | - * @return int |
|
251 | - */ |
|
252 | - public function cache_expiration() { |
|
253 | - return $this->expires; |
|
254 | - } |
|
255 | - |
|
256 | - /** |
|
257 | - * Flushes all session variables. |
|
258 | - */ |
|
259 | - public function reset() { |
|
260 | - $this->container = array(); |
|
261 | - } |
|
262 | - |
|
263 | - /*****************************************************************/ |
|
264 | - /* Iterator Implementation */ |
|
265 | - /*****************************************************************/ |
|
266 | - |
|
267 | - /** |
|
268 | - * Current position of the array. |
|
269 | - * |
|
270 | - * @link http://php.net/manual/en/iterator.current.php |
|
271 | - * |
|
272 | - * @return mixed |
|
273 | - */ |
|
274 | - public function current() { |
|
275 | - return current( $this->container ); |
|
276 | - } |
|
277 | - |
|
278 | - /** |
|
279 | - * Key of the current element. |
|
280 | - * |
|
281 | - * @link http://php.net/manual/en/iterator.key.php |
|
282 | - * |
|
283 | - * @return mixed |
|
284 | - */ |
|
285 | - public function key() { |
|
286 | - return key( $this->container ); |
|
287 | - } |
|
288 | - |
|
289 | - /** |
|
290 | - * Move the internal point of the container array to the next item |
|
291 | - * |
|
292 | - * @link http://php.net/manual/en/iterator.next.php |
|
293 | - * |
|
294 | - * @return void |
|
295 | - */ |
|
296 | - public function next() { |
|
297 | - next( $this->container ); |
|
298 | - } |
|
299 | - |
|
300 | - /** |
|
301 | - * Rewind the internal point of the container array. |
|
302 | - * |
|
303 | - * @link http://php.net/manual/en/iterator.rewind.php |
|
304 | - * |
|
305 | - * @return void |
|
306 | - */ |
|
307 | - public function rewind() { |
|
308 | - reset( $this->container ); |
|
309 | - } |
|
310 | - |
|
311 | - /** |
|
312 | - * Is the current key valid? |
|
313 | - * |
|
314 | - * @link http://php.net/manual/en/iterator.rewind.php |
|
315 | - * |
|
316 | - * @return bool |
|
317 | - */ |
|
318 | - public function valid() { |
|
319 | - return $this->offsetExists( $this->key() ); |
|
320 | - } |
|
321 | - |
|
322 | - /*****************************************************************/ |
|
323 | - /* Countable Implementation */ |
|
324 | - /*****************************************************************/ |
|
325 | - |
|
326 | - /** |
|
327 | - * Get the count of elements in the container array. |
|
328 | - * |
|
329 | - * @link http://php.net/manual/en/countable.count.php |
|
330 | - * |
|
331 | - * @return int |
|
332 | - */ |
|
333 | - public function count() { |
|
334 | - return count( $this->container ); |
|
335 | - } |
|
141 | + } |
|
142 | + |
|
143 | + /** |
|
144 | + * Generate a cryptographically strong unique ID for the session token. |
|
145 | + * |
|
146 | + * @return string |
|
147 | + */ |
|
148 | + protected function generate_id() { |
|
149 | + require_once( ABSPATH . 'wp-includes/class-phpass.php'); |
|
150 | + $hasher = new PasswordHash( 8, false ); |
|
151 | + |
|
152 | + return md5( $hasher->get_random_bytes( 32 ) ); |
|
153 | + } |
|
154 | + |
|
155 | + /** |
|
156 | + * Checks if is valid md5 string |
|
157 | + * |
|
158 | + * @param string $md5 |
|
159 | + * @return int |
|
160 | + */ |
|
161 | + protected function is_valid_md5( $md5 = '' ){ |
|
162 | + return preg_match( '/^[a-f0-9]{32}$/', $md5 ); |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * Read data from a transient for the current session. |
|
167 | + * |
|
168 | + * Automatically resets the expiration time for the session transient to some time in the future. |
|
169 | + * |
|
170 | + * @return array |
|
171 | + */ |
|
172 | + protected function read_data() { |
|
173 | + $this->container = get_option( "_wp_session_{$this->session_id}", array() ); |
|
174 | + |
|
175 | + return $this->container; |
|
176 | + } |
|
177 | + |
|
178 | + /** |
|
179 | + * Write the data from the current session to the data storage system. |
|
180 | + */ |
|
181 | + public function write_data() { |
|
182 | + $option_key = "_wp_session_{$this->session_id}"; |
|
183 | + |
|
184 | + // Only write the collection to the DB if it's changed. |
|
185 | + if ( $this->dirty ) { |
|
186 | + if ( false === get_option( $option_key ) ) { |
|
187 | + add_option( "_wp_session_{$this->session_id}", $this->container, '', 'no' ); |
|
188 | + add_option( "_wp_session_expires_{$this->session_id}", $this->expires, '', 'no' ); |
|
189 | + } else { |
|
190 | + delete_option( "_wp_session_{$this->session_id}" ); |
|
191 | + add_option( "_wp_session_{$this->session_id}", $this->container, '', 'no' ); |
|
192 | + } |
|
193 | + } |
|
194 | + } |
|
195 | + |
|
196 | + /** |
|
197 | + * Output the current container contents as a JSON-encoded string. |
|
198 | + * |
|
199 | + * @return string |
|
200 | + */ |
|
201 | + public function json_out() { |
|
202 | + return json_encode( $this->container ); |
|
203 | + } |
|
204 | + |
|
205 | + /** |
|
206 | + * Decodes a JSON string and, if the object is an array, overwrites the session container with its contents. |
|
207 | + * |
|
208 | + * @param string $data |
|
209 | + * |
|
210 | + * @return bool |
|
211 | + */ |
|
212 | + public function json_in( $data ) { |
|
213 | + $array = json_decode( $data ); |
|
214 | + |
|
215 | + if ( is_array( $array ) ) { |
|
216 | + $this->container = $array; |
|
217 | + return true; |
|
218 | + } |
|
219 | + |
|
220 | + return false; |
|
221 | + } |
|
222 | + |
|
223 | + /** |
|
224 | + * Regenerate the current session's ID. |
|
225 | + * |
|
226 | + * @param bool $delete_old Flag whether or not to delete the old session data from the server. |
|
227 | + */ |
|
228 | + public function regenerate_id( $delete_old = false ) { |
|
229 | + if ( $delete_old ) { |
|
230 | + delete_option( "_wp_session_{$this->session_id}" ); |
|
231 | + } |
|
232 | + |
|
233 | + $this->session_id = $this->generate_id(); |
|
234 | + |
|
235 | + $this->set_cookie(); |
|
236 | + } |
|
237 | + |
|
238 | + /** |
|
239 | + * Check if a session has been initialized. |
|
240 | + * |
|
241 | + * @return bool |
|
242 | + */ |
|
243 | + public function session_started() { |
|
244 | + return !!self::$instance; |
|
245 | + } |
|
246 | + |
|
247 | + /** |
|
248 | + * Return the read-only cache expiration value. |
|
249 | + * |
|
250 | + * @return int |
|
251 | + */ |
|
252 | + public function cache_expiration() { |
|
253 | + return $this->expires; |
|
254 | + } |
|
255 | + |
|
256 | + /** |
|
257 | + * Flushes all session variables. |
|
258 | + */ |
|
259 | + public function reset() { |
|
260 | + $this->container = array(); |
|
261 | + } |
|
262 | + |
|
263 | + /*****************************************************************/ |
|
264 | + /* Iterator Implementation */ |
|
265 | + /*****************************************************************/ |
|
266 | + |
|
267 | + /** |
|
268 | + * Current position of the array. |
|
269 | + * |
|
270 | + * @link http://php.net/manual/en/iterator.current.php |
|
271 | + * |
|
272 | + * @return mixed |
|
273 | + */ |
|
274 | + public function current() { |
|
275 | + return current( $this->container ); |
|
276 | + } |
|
277 | + |
|
278 | + /** |
|
279 | + * Key of the current element. |
|
280 | + * |
|
281 | + * @link http://php.net/manual/en/iterator.key.php |
|
282 | + * |
|
283 | + * @return mixed |
|
284 | + */ |
|
285 | + public function key() { |
|
286 | + return key( $this->container ); |
|
287 | + } |
|
288 | + |
|
289 | + /** |
|
290 | + * Move the internal point of the container array to the next item |
|
291 | + * |
|
292 | + * @link http://php.net/manual/en/iterator.next.php |
|
293 | + * |
|
294 | + * @return void |
|
295 | + */ |
|
296 | + public function next() { |
|
297 | + next( $this->container ); |
|
298 | + } |
|
299 | + |
|
300 | + /** |
|
301 | + * Rewind the internal point of the container array. |
|
302 | + * |
|
303 | + * @link http://php.net/manual/en/iterator.rewind.php |
|
304 | + * |
|
305 | + * @return void |
|
306 | + */ |
|
307 | + public function rewind() { |
|
308 | + reset( $this->container ); |
|
309 | + } |
|
310 | + |
|
311 | + /** |
|
312 | + * Is the current key valid? |
|
313 | + * |
|
314 | + * @link http://php.net/manual/en/iterator.rewind.php |
|
315 | + * |
|
316 | + * @return bool |
|
317 | + */ |
|
318 | + public function valid() { |
|
319 | + return $this->offsetExists( $this->key() ); |
|
320 | + } |
|
321 | + |
|
322 | + /*****************************************************************/ |
|
323 | + /* Countable Implementation */ |
|
324 | + /*****************************************************************/ |
|
325 | + |
|
326 | + /** |
|
327 | + * Get the count of elements in the container array. |
|
328 | + * |
|
329 | + * @link http://php.net/manual/en/countable.count.php |
|
330 | + * |
|
331 | + * @return int |
|
332 | + */ |
|
333 | + public function count() { |
|
334 | + return count( $this->container ); |
|
335 | + } |
|
336 | 336 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly |
14 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
14 | +if (!defined('ABSPATH')) exit; |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * WordPress Session class for managing user session data. |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @return bool|WP_Session |
57 | 57 | */ |
58 | 58 | public static function get_instance() { |
59 | - if ( ! self::$instance ) { |
|
59 | + if (!self::$instance) { |
|
60 | 60 | self::$instance = new self(); |
61 | 61 | } |
62 | 62 | |
@@ -72,17 +72,17 @@ discard block |
||
72 | 72 | * @uses apply_filters Calls `wp_session_expiration` to determine how long until sessions expire. |
73 | 73 | */ |
74 | 74 | protected function __construct() { |
75 | - if ( isset( $_COOKIE[WP_SESSION_COOKIE] ) ) { |
|
76 | - $cookie = stripslashes( $_COOKIE[WP_SESSION_COOKIE] ); |
|
77 | - $cookie_crumbs = explode( '||', $cookie ); |
|
75 | + if (isset($_COOKIE[WP_SESSION_COOKIE])) { |
|
76 | + $cookie = stripslashes($_COOKIE[WP_SESSION_COOKIE]); |
|
77 | + $cookie_crumbs = explode('||', $cookie); |
|
78 | 78 | |
79 | - if( $this->is_valid_md5( $cookie_crumbs[0] ) ) { |
|
79 | + if ($this->is_valid_md5($cookie_crumbs[0])) { |
|
80 | 80 | |
81 | 81 | $this->session_id = $cookie_crumbs[0]; |
82 | 82 | |
83 | 83 | } else { |
84 | 84 | |
85 | - $this->regenerate_id( true ); |
|
85 | + $this->regenerate_id(true); |
|
86 | 86 | |
87 | 87 | } |
88 | 88 | |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | $this->exp_variant = $cookie_crumbs[2]; |
91 | 91 | |
92 | 92 | // Update the session expiration if we're past the variant time |
93 | - if ( time() > $this->exp_variant ) { |
|
93 | + if (time() > $this->exp_variant) { |
|
94 | 94 | $this->set_expiration(); |
95 | - delete_option( "_wp_session_expires_{$this->session_id}" ); |
|
96 | - add_option( "_wp_session_expires_{$this->session_id}", $this->expires, '', 'no' ); |
|
95 | + delete_option("_wp_session_expires_{$this->session_id}"); |
|
96 | + add_option("_wp_session_expires_{$this->session_id}", $this->expires, '', 'no'); |
|
97 | 97 | } |
98 | 98 | } else { |
99 | 99 | $this->session_id = $this->generate_id(); |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | * @uses apply_filters Calls `wp_session_expiration` to get the standard expiration time for sessions. |
126 | 126 | */ |
127 | 127 | protected function set_expiration() { |
128 | - $this->exp_variant = time() + (int) apply_filters( 'wp_session_expiration_variant', 24 * 60 ); |
|
129 | - $this->expires = time() + (int) apply_filters( 'wp_session_expiration', 30 * 60 ); |
|
128 | + $this->exp_variant = time() + (int) apply_filters('wp_session_expiration_variant', 24 * 60); |
|
129 | + $this->expires = time() + (int) apply_filters('wp_session_expiration', 30 * 60); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | */ |
135 | 135 | protected function set_cookie() { |
136 | 136 | try { |
137 | - setcookie( WP_SESSION_COOKIE, $this->session_id . '||' . $this->expires . '||' . $this->exp_variant , $this->expires, COOKIEPATH, COOKIE_DOMAIN ); |
|
138 | - } catch(Exception $e) { |
|
139 | - error_log( 'Set Cookie Error: ' . $e->getMessage() ); |
|
137 | + setcookie(WP_SESSION_COOKIE, $this->session_id . '||' . $this->expires . '||' . $this->exp_variant, $this->expires, COOKIEPATH, COOKIE_DOMAIN); |
|
138 | + } catch (Exception $e) { |
|
139 | + error_log('Set Cookie Error: ' . $e->getMessage()); |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
@@ -146,10 +146,10 @@ discard block |
||
146 | 146 | * @return string |
147 | 147 | */ |
148 | 148 | protected function generate_id() { |
149 | - require_once( ABSPATH . 'wp-includes/class-phpass.php'); |
|
150 | - $hasher = new PasswordHash( 8, false ); |
|
149 | + require_once(ABSPATH . 'wp-includes/class-phpass.php'); |
|
150 | + $hasher = new PasswordHash(8, false); |
|
151 | 151 | |
152 | - return md5( $hasher->get_random_bytes( 32 ) ); |
|
152 | + return md5($hasher->get_random_bytes(32)); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | * @param string $md5 |
159 | 159 | * @return int |
160 | 160 | */ |
161 | - protected function is_valid_md5( $md5 = '' ){ |
|
162 | - return preg_match( '/^[a-f0-9]{32}$/', $md5 ); |
|
161 | + protected function is_valid_md5($md5 = '') { |
|
162 | + return preg_match('/^[a-f0-9]{32}$/', $md5); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @return array |
171 | 171 | */ |
172 | 172 | protected function read_data() { |
173 | - $this->container = get_option( "_wp_session_{$this->session_id}", array() ); |
|
173 | + $this->container = get_option("_wp_session_{$this->session_id}", array()); |
|
174 | 174 | |
175 | 175 | return $this->container; |
176 | 176 | } |
@@ -182,13 +182,13 @@ discard block |
||
182 | 182 | $option_key = "_wp_session_{$this->session_id}"; |
183 | 183 | |
184 | 184 | // Only write the collection to the DB if it's changed. |
185 | - if ( $this->dirty ) { |
|
186 | - if ( false === get_option( $option_key ) ) { |
|
187 | - add_option( "_wp_session_{$this->session_id}", $this->container, '', 'no' ); |
|
188 | - add_option( "_wp_session_expires_{$this->session_id}", $this->expires, '', 'no' ); |
|
185 | + if ($this->dirty) { |
|
186 | + if (false === get_option($option_key)) { |
|
187 | + add_option("_wp_session_{$this->session_id}", $this->container, '', 'no'); |
|
188 | + add_option("_wp_session_expires_{$this->session_id}", $this->expires, '', 'no'); |
|
189 | 189 | } else { |
190 | - delete_option( "_wp_session_{$this->session_id}" ); |
|
191 | - add_option( "_wp_session_{$this->session_id}", $this->container, '', 'no' ); |
|
190 | + delete_option("_wp_session_{$this->session_id}"); |
|
191 | + add_option("_wp_session_{$this->session_id}", $this->container, '', 'no'); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * @return string |
200 | 200 | */ |
201 | 201 | public function json_out() { |
202 | - return json_encode( $this->container ); |
|
202 | + return json_encode($this->container); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
@@ -209,10 +209,10 @@ discard block |
||
209 | 209 | * |
210 | 210 | * @return bool |
211 | 211 | */ |
212 | - public function json_in( $data ) { |
|
213 | - $array = json_decode( $data ); |
|
212 | + public function json_in($data) { |
|
213 | + $array = json_decode($data); |
|
214 | 214 | |
215 | - if ( is_array( $array ) ) { |
|
215 | + if (is_array($array)) { |
|
216 | 216 | $this->container = $array; |
217 | 217 | return true; |
218 | 218 | } |
@@ -225,9 +225,9 @@ discard block |
||
225 | 225 | * |
226 | 226 | * @param bool $delete_old Flag whether or not to delete the old session data from the server. |
227 | 227 | */ |
228 | - public function regenerate_id( $delete_old = false ) { |
|
229 | - if ( $delete_old ) { |
|
230 | - delete_option( "_wp_session_{$this->session_id}" ); |
|
228 | + public function regenerate_id($delete_old = false) { |
|
229 | + if ($delete_old) { |
|
230 | + delete_option("_wp_session_{$this->session_id}"); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | $this->session_id = $this->generate_id(); |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * @return mixed |
273 | 273 | */ |
274 | 274 | public function current() { |
275 | - return current( $this->container ); |
|
275 | + return current($this->container); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * @return mixed |
284 | 284 | */ |
285 | 285 | public function key() { |
286 | - return key( $this->container ); |
|
286 | + return key($this->container); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | /** |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | * @return void |
295 | 295 | */ |
296 | 296 | public function next() { |
297 | - next( $this->container ); |
|
297 | + next($this->container); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | /** |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | * @return void |
306 | 306 | */ |
307 | 307 | public function rewind() { |
308 | - reset( $this->container ); |
|
308 | + reset($this->container); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | /** |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | * @return bool |
317 | 317 | */ |
318 | 318 | public function valid() { |
319 | - return $this->offsetExists( $this->key() ); |
|
319 | + return $this->offsetExists($this->key()); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | /*****************************************************************/ |
@@ -331,6 +331,6 @@ discard block |
||
331 | 331 | * @return int |
332 | 332 | */ |
333 | 333 | public function count() { |
334 | - return count( $this->container ); |
|
334 | + return count($this->container); |
|
335 | 335 | } |
336 | 336 | } |
@@ -2203,7 +2203,7 @@ |
||
2203 | 2203 | * @global object $wpdb WordPress Database object. |
2204 | 2204 | * @global string $plugin_prefix Geodirectory plugin table prefix. |
2205 | 2205 | * @param int $attachment_id Attachment ID. |
2206 | - * @return bool|void Returns false on failure. |
|
2206 | + * @return false|null Returns false on failure. |
|
2207 | 2207 | */ |
2208 | 2208 | function geodirectory_before_featured_image_delete($attachment_id) |
2209 | 2209 | { |
@@ -86,8 +86,9 @@ discard block |
||
86 | 86 | add_filter('query_vars', 'geodir_add_location_var'); |
87 | 87 | add_filter('query_vars', 'geodir_add_geodir_page_var'); |
88 | 88 | add_action('wp', 'geodir_add_page_id_in_query_var'); // problem fix in wordpress 3.8 |
89 | -if (get_option('permalink_structure') != '') |
|
90 | - add_filter('parse_request', 'geodir_set_location_var_in_session_in_core'); |
|
89 | +if (get_option('permalink_structure') != '') { |
|
90 | + add_filter('parse_request', 'geodir_set_location_var_in_session_in_core'); |
|
91 | +} |
|
91 | 92 | |
92 | 93 | add_filter('parse_query', 'geodir_modified_query'); |
93 | 94 | |
@@ -420,8 +421,9 @@ discard block |
||
420 | 421 | */ |
421 | 422 | do_action('geodir_after_social_sharing_buttons'); |
422 | 423 | $content_html = ob_get_clean(); |
423 | - if (trim($content_html) != '') |
|
424 | - $content_html = '<div class="geodir-company_info geodir-details-sidebar-social-sharing">' . $content_html . '</div>'; |
|
424 | + if (trim($content_html) != '') { |
|
425 | + $content_html = '<div class="geodir-company_info geodir-details-sidebar-social-sharing">' . $content_html . '</div>'; |
|
426 | + } |
|
425 | 427 | if ((int)get_option('geodir_disable_tfg_buttons_section') != 1) { |
426 | 428 | /** |
427 | 429 | * Filter the geodir_social_sharing_buttons() function content. |
@@ -467,8 +469,9 @@ discard block |
||
467 | 469 | */ |
468 | 470 | do_action('geodir_after_share_this_button'); |
469 | 471 | $content_html = ob_get_clean(); |
470 | - if (trim($content_html) != '') |
|
471 | - $content_html = '<div class="geodir-company_info geodir-details-sidebar-sharethis">' . $content_html . '</div>'; |
|
472 | + if (trim($content_html) != '') { |
|
473 | + $content_html = '<div class="geodir-company_info geodir-details-sidebar-sharethis">' . $content_html . '</div>'; |
|
474 | + } |
|
472 | 475 | if ((int)get_option('geodir_disable_sharethis_button_section') != 1) { |
473 | 476 | /** |
474 | 477 | * Filter the geodir_share_this_button() function content. |
@@ -526,8 +529,9 @@ discard block |
||
526 | 529 | */ |
527 | 530 | do_action('geodir_after_edit_post_link'); |
528 | 531 | $content_html = ob_get_clean(); |
529 | - if (trim($content_html) != '') |
|
530 | - $content_html = '<div class="geodir-company_info geodir-details-sidebar-user-links">' . $content_html . '</div>'; |
|
532 | + if (trim($content_html) != '') { |
|
533 | + $content_html = '<div class="geodir-company_info geodir-details-sidebar-user-links">' . $content_html . '</div>'; |
|
534 | + } |
|
531 | 535 | if ((int)get_option('geodir_disable_user_links_section') != 1) { |
532 | 536 | /** |
533 | 537 | * Filter the geodir_edit_post_link() function content. |
@@ -1080,8 +1084,9 @@ discard block |
||
1080 | 1084 | */ |
1081 | 1085 | do_action('geodir_after_google_analytics'); |
1082 | 1086 | $content_html = ob_get_clean(); |
1083 | - if (trim($content_html) != '') |
|
1084 | - $content_html = '<div class="geodir-company_info geodir-details-sidebar-google-analytics">' . $content_html . '</div>'; |
|
1087 | + if (trim($content_html) != '') { |
|
1088 | + $content_html = '<div class="geodir-company_info geodir-details-sidebar-google-analytics">' . $content_html . '</div>'; |
|
1089 | + } |
|
1085 | 1090 | if ((int)get_option('geodir_disable_google_analytics_section') != 1) { |
1086 | 1091 | /** |
1087 | 1092 | * Filter the geodir_edit_post_link() function content. |
@@ -1216,8 +1221,9 @@ discard block |
||
1216 | 1221 | do_action('geodir_after_detail_page_more_info'); |
1217 | 1222 | |
1218 | 1223 | $content_html = ob_get_clean(); |
1219 | - if (trim($content_html) != '') |
|
1220 | - $content_html = '<div class="geodir-company_info geodir-details-sidebar-listing-info">' . $content_html . '</div>'; |
|
1224 | + if (trim($content_html) != '') { |
|
1225 | + $content_html = '<div class="geodir-company_info geodir-details-sidebar-listing-info">' . $content_html . '</div>'; |
|
1226 | + } |
|
1221 | 1227 | if ((int)get_option('geodir_disable_listing_info_section') != 1) { |
1222 | 1228 | /** |
1223 | 1229 | * Filter the output html for function geodir_detail_page_more_info(). |
@@ -1322,8 +1328,9 @@ discard block |
||
1322 | 1328 | $arr_alert_msg = apply_filters('geodir_all_js_msg', $arr_alert_msg); |
1323 | 1329 | |
1324 | 1330 | foreach ($arr_alert_msg as $key => $value) { |
1325 | - if (!is_scalar($value)) |
|
1326 | - continue; |
|
1331 | + if (!is_scalar($value)) { |
|
1332 | + continue; |
|
1333 | + } |
|
1327 | 1334 | $arr_alert_msg[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8'); |
1328 | 1335 | } |
1329 | 1336 | |
@@ -1377,17 +1384,19 @@ discard block |
||
1377 | 1384 | global $geodir_sidebars; |
1378 | 1385 | global $sidebars_widgets; |
1379 | 1386 | |
1380 | - if (!is_array($sidebars_widgets)) |
|
1381 | - $sidebars_widgets = wp_get_sidebars_widgets(); |
|
1387 | + if (!is_array($sidebars_widgets)) { |
|
1388 | + $sidebars_widgets = wp_get_sidebars_widgets(); |
|
1389 | + } |
|
1382 | 1390 | $geodir_old_sidebars = array(); |
1383 | 1391 | |
1384 | 1392 | if (is_array($geodir_sidebars)) { |
1385 | 1393 | foreach ($geodir_sidebars as $val) { |
1386 | 1394 | if (is_array($sidebars_widgets)) { |
1387 | - if (array_key_exists($val, $sidebars_widgets)) |
|
1388 | - $geodir_old_sidebars[$val] = $sidebars_widgets[$val]; |
|
1389 | - else |
|
1390 | - $geodir_old_sidebars[$val] = array(); |
|
1395 | + if (array_key_exists($val, $sidebars_widgets)) { |
|
1396 | + $geodir_old_sidebars[$val] = $sidebars_widgets[$val]; |
|
1397 | + } else { |
|
1398 | + $geodir_old_sidebars[$val] = array(); |
|
1399 | + } |
|
1391 | 1400 | } |
1392 | 1401 | } |
1393 | 1402 | } |
@@ -1408,8 +1417,9 @@ discard block |
||
1408 | 1417 | { |
1409 | 1418 | global $sidebars_widgets; |
1410 | 1419 | |
1411 | - if (!is_array($sidebars_widgets)) |
|
1412 | - $sidebars_widgets = wp_get_sidebars_widgets(); |
|
1420 | + if (!is_array($sidebars_widgets)) { |
|
1421 | + $sidebars_widgets = wp_get_sidebars_widgets(); |
|
1422 | + } |
|
1413 | 1423 | |
1414 | 1424 | if (is_array($sidebars_widgets)) { |
1415 | 1425 | $geodir_old_sidebars = get_option('geodir_sidebars'); |
@@ -1551,20 +1561,25 @@ discard block |
||
1551 | 1561 | |
1552 | 1562 | global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields; |
1553 | 1563 | |
1554 | - if ($tab == 'post_info') |
|
1555 | - $is_display = (!empty($geodir_post_detail_fields)) ? true : false; |
|
1564 | + if ($tab == 'post_info') { |
|
1565 | + $is_display = (!empty($geodir_post_detail_fields)) ? true : false; |
|
1566 | + } |
|
1556 | 1567 | |
1557 | - if ($tab == 'post_images') |
|
1558 | - $is_display = (!empty($post_images)) ? true : false; |
|
1568 | + if ($tab == 'post_images') { |
|
1569 | + $is_display = (!empty($post_images)) ? true : false; |
|
1570 | + } |
|
1559 | 1571 | |
1560 | - if ($tab == 'post_video') |
|
1561 | - $is_display = (!empty($video)) ? true : false; |
|
1572 | + if ($tab == 'post_video') { |
|
1573 | + $is_display = (!empty($video)) ? true : false; |
|
1574 | + } |
|
1562 | 1575 | |
1563 | - if ($tab == 'special_offers') |
|
1564 | - $is_display = (!empty($special_offers)) ? true : false; |
|
1576 | + if ($tab == 'special_offers') { |
|
1577 | + $is_display = (!empty($special_offers)) ? true : false; |
|
1578 | + } |
|
1565 | 1579 | |
1566 | - if ($tab == 'reviews') |
|
1567 | - $is_display = (geodir_is_page('detail')) ? true : false; |
|
1580 | + if ($tab == 'reviews') { |
|
1581 | + $is_display = (geodir_is_page('detail')) ? true : false; |
|
1582 | + } |
|
1568 | 1583 | |
1569 | 1584 | if ($tab == 'related_listing') { |
1570 | 1585 | $message = __('No listings found which match your selection.', 'geodirectory'); |
@@ -1840,11 +1855,13 @@ discard block |
||
1840 | 1855 | $region_slug = $default_location->region_slug; |
1841 | 1856 | $city_slug = $default_location->city_slug; |
1842 | 1857 | |
1843 | - if ($country_slug == $slug || $region_slug == $slug || $city_slug == $slug) |
|
1844 | - return $slug_exists = true; |
|
1858 | + if ($country_slug == $slug || $region_slug == $slug || $city_slug == $slug) { |
|
1859 | + return $slug_exists = true; |
|
1860 | + } |
|
1845 | 1861 | |
1846 | - if ($wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s AND term_id != %d", array($slug, $term_id)))) |
|
1847 | - return $slug_exists = true; |
|
1862 | + if ($wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s AND term_id != %d", array($slug, $term_id)))) { |
|
1863 | + return $slug_exists = true; |
|
1864 | + } |
|
1848 | 1865 | |
1849 | 1866 | return $slug_exists; |
1850 | 1867 | } |
@@ -1886,40 +1903,31 @@ discard block |
||
1886 | 1903 | if(geodir_is_page('home')){ |
1887 | 1904 | $gd_page = 'home'; |
1888 | 1905 | $title = (get_option('geodir_meta_title_homepage')) ? get_option('geodir_meta_title_homepage') : $title; |
1889 | - } |
|
1890 | - elseif(geodir_is_page('detail')){ |
|
1906 | + } elseif(geodir_is_page('detail')){ |
|
1891 | 1907 | $gd_page = 'detail'; |
1892 | 1908 | $title = (get_option('geodir_meta_title_detail')) ? get_option('geodir_meta_title_detail') : $title; |
1893 | - } |
|
1894 | - elseif(geodir_is_page('pt')){ |
|
1909 | + } elseif(geodir_is_page('pt')){ |
|
1895 | 1910 | $gd_page = 'pt'; |
1896 | 1911 | $title = (get_option('geodir_meta_title_pt')) ? get_option('geodir_meta_title_pt') : $title; |
1897 | - } |
|
1898 | - elseif(geodir_is_page('listing')){ |
|
1912 | + } elseif(geodir_is_page('listing')){ |
|
1899 | 1913 | $gd_page = 'listing'; |
1900 | 1914 | $title = (get_option('geodir_meta_title_listing')) ? get_option('geodir_meta_title_listing') : $title; |
1901 | - } |
|
1902 | - elseif(geodir_is_page('location')){ |
|
1915 | + } elseif(geodir_is_page('location')){ |
|
1903 | 1916 | $gd_page = 'location'; |
1904 | 1917 | $title = (get_option('geodir_meta_title_location')) ? get_option('geodir_meta_title_location') : $title; |
1905 | - } |
|
1906 | - elseif(geodir_is_page('search')){ |
|
1918 | + } elseif(geodir_is_page('search')){ |
|
1907 | 1919 | $gd_page = 'search'; |
1908 | 1920 | $title = (get_option('geodir_meta_title_search')) ? get_option('geodir_meta_title_search') : $title; |
1909 | - } |
|
1910 | - elseif(geodir_is_page('add-listing')){ |
|
1921 | + } elseif(geodir_is_page('add-listing')){ |
|
1911 | 1922 | $gd_page = 'add-listing'; |
1912 | 1923 | $title = (get_option('geodir_meta_title_add-listing')) ? get_option('geodir_meta_title_add-listing') : $title; |
1913 | - } |
|
1914 | - elseif(geodir_is_page('author')){ |
|
1924 | + } elseif(geodir_is_page('author')){ |
|
1915 | 1925 | $gd_page = 'author'; |
1916 | 1926 | $title = (get_option('geodir_meta_title_author')) ? get_option('geodir_meta_title_author') : $title; |
1917 | - } |
|
1918 | - elseif(geodir_is_page('login')){ |
|
1927 | + } elseif(geodir_is_page('login')){ |
|
1919 | 1928 | $gd_page = 'login'; |
1920 | 1929 | $title = (get_option('geodir_meta_title_login')) ? get_option('geodir_meta_title_login') : $title; |
1921 | - } |
|
1922 | - elseif(geodir_is_page('listing-success')){ |
|
1930 | + } elseif(geodir_is_page('listing-success')){ |
|
1923 | 1931 | $gd_page = 'listing-success'; |
1924 | 1932 | $title = (get_option('geodir_meta_title_listing-success')) ? get_option('geodir_meta_title_listing-success') : $title; |
1925 | 1933 | } |
@@ -1994,11 +2002,13 @@ discard block |
||
1994 | 2002 | |
1995 | 2003 | if (!get_option('geodir_remove_url_seperator')) { |
1996 | 2004 | |
1997 | - if (get_option('geodir_listingurl_separator')) |
|
1998 | - delete_option('geodir_listingurl_separator'); |
|
2005 | + if (get_option('geodir_listingurl_separator')) { |
|
2006 | + delete_option('geodir_listingurl_separator'); |
|
2007 | + } |
|
1999 | 2008 | |
2000 | - if (get_option('geodir_detailurl_separator')) |
|
2001 | - delete_option('geodir_detailurl_separator'); |
|
2009 | + if (get_option('geodir_detailurl_separator')) { |
|
2010 | + delete_option('geodir_detailurl_separator'); |
|
2011 | + } |
|
2002 | 2012 | |
2003 | 2013 | flush_rewrite_rules(false); |
2004 | 2014 | |
@@ -2022,8 +2032,9 @@ discard block |
||
2022 | 2032 | { |
2023 | 2033 | foreach ($permalink_arr as $key => $value) { |
2024 | 2034 | |
2025 | - if ($value['id'] == 'geodir_listingurl_separator' || $value['id'] == 'geodir_detailurl_separator') |
|
2026 | - unset($permalink_arr[$key]); |
|
2035 | + if ($value['id'] == 'geodir_listingurl_separator' || $value['id'] == 'geodir_detailurl_separator') { |
|
2036 | + unset($permalink_arr[$key]); |
|
2037 | + } |
|
2027 | 2038 | |
2028 | 2039 | } |
2029 | 2040 | |
@@ -2156,16 +2167,18 @@ discard block |
||
2156 | 2167 | |
2157 | 2168 | $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_video', $post_type))); |
2158 | 2169 | |
2159 | - if (isset($tabs_arr['post_video']['heading_text']) && $field_title != '') |
|
2160 | - $tabs_arr['post_video']['heading_text'] = $field_title; |
|
2170 | + if (isset($tabs_arr['post_video']['heading_text']) && $field_title != '') { |
|
2171 | + $tabs_arr['post_video']['heading_text'] = $field_title; |
|
2172 | + } |
|
2161 | 2173 | } |
2162 | 2174 | |
2163 | 2175 | if (array_key_exists('special_offers', $tabs_arr)) { |
2164 | 2176 | |
2165 | 2177 | $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_special_offers', $post_type))); |
2166 | 2178 | |
2167 | - if (isset($tabs_arr['special_offers']['heading_text']) && $field_title != '') |
|
2168 | - $tabs_arr['special_offers']['heading_text'] = $field_title; |
|
2179 | + if (isset($tabs_arr['special_offers']['heading_text']) && $field_title != '') { |
|
2180 | + $tabs_arr['special_offers']['heading_text'] = $field_title; |
|
2181 | + } |
|
2169 | 2182 | } |
2170 | 2183 | |
2171 | 2184 | } |
@@ -2220,8 +2233,9 @@ discard block |
||
2220 | 2233 | |
2221 | 2234 | $all_postypes = geodir_get_posttypes(); |
2222 | 2235 | |
2223 | - if (!in_array($post_type, $all_postypes) || !is_admin()) |
|
2224 | - return false; |
|
2236 | + if (!in_array($post_type, $all_postypes) || !is_admin()) { |
|
2237 | + return false; |
|
2238 | + } |
|
2225 | 2239 | |
2226 | 2240 | $uploads = wp_upload_dir(); |
2227 | 2241 | |
@@ -2295,8 +2309,9 @@ discard block |
||
2295 | 2309 | $file_info = pathinfo($attach->file); |
2296 | 2310 | |
2297 | 2311 | $sub_dir = ''; |
2298 | - if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') |
|
2299 | - $sub_dir = stripslashes_deep($file_info['dirname']); |
|
2312 | + if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') { |
|
2313 | + $sub_dir = stripslashes_deep($file_info['dirname']); |
|
2314 | + } |
|
2300 | 2315 | |
2301 | 2316 | $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
2302 | 2317 | $uploads_baseurl = $uploads['baseurl']; |
@@ -2318,8 +2333,9 @@ discard block |
||
2318 | 2333 | |
2319 | 2334 | if (!empty($attachment_data)) { |
2320 | 2335 | |
2321 | - if ($attachment_data->ID) |
|
2322 | - $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID); |
|
2336 | + if ($attachment_data->ID) { |
|
2337 | + $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID); |
|
2338 | + } |
|
2323 | 2339 | |
2324 | 2340 | } else { |
2325 | 2341 | |
@@ -2605,9 +2621,10 @@ discard block |
||
2605 | 2621 | break; |
2606 | 2622 | case 'time': { |
2607 | 2623 | $value = ''; |
2608 | - if ($post->$type['htmlvar_name'] != '') |
|
2609 | - //$value = date('h:i',strtotime($post->$type['htmlvar_name'])); |
|
2610 | - $value = date(get_option('time_format'), strtotime($post->$type['htmlvar_name'])); |
|
2624 | + if ($post->$type['htmlvar_name'] != '') { |
|
2625 | + //$value = date('h:i',strtotime($post->$type['htmlvar_name'])); |
|
2626 | + $value = date(get_option('time_format'), strtotime($post->$type['htmlvar_name'])); |
|
2627 | + } |
|
2611 | 2628 | |
2612 | 2629 | if (strpos($field_icon, 'http') !== false) { |
2613 | 2630 | $field_icon_af = ''; |
@@ -2642,8 +2659,9 @@ discard block |
||
2642 | 2659 | $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $post->$type['htmlvar_name']) : $post->$type['htmlvar_name']; // PHP doesn't work well with dd/mm/yyyy format |
2643 | 2660 | |
2644 | 2661 | $value = ''; |
2645 | - if ($post->$type['htmlvar_name'] != '') |
|
2646 | - $value = date($date_format, strtotime($post_htmlvar_value)); |
|
2662 | + if ($post->$type['htmlvar_name'] != '') { |
|
2663 | + $value = date($date_format, strtotime($post_htmlvar_value)); |
|
2664 | + } |
|
2647 | 2665 | |
2648 | 2666 | if (strpos($field_icon, 'http') !== false) { |
2649 | 2667 | $field_icon_af = ''; |
@@ -1095,9 +1095,9 @@ discard block |
||
1095 | 1095 | $html .= '<div class="average-review" itemscope itemtype="http://data-vocabulary.org/Review-aggregate">'; |
1096 | 1096 | $post_avgratings = (is_float($post_avgratings) || (strpos($post_avgratings, ".", 1) == 1 && strlen($post_avgratings) > 3)) ? number_format($post_avgratings, 1, '.', '') : $post_avgratings; |
1097 | 1097 | |
1098 | - $reviews_text = $comment_count > 1 ? __("reviews", 'geodirectory') : __("review", 'geodirectory'); |
|
1098 | + $reviews_text = $comment_count > 1 ? __("reviews", 'geodirectory') : __("review", 'geodirectory'); |
|
1099 | 1099 | |
1100 | - $html .= '<span itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating"><span class="rating" itemprop="average" content="' . $post_avgratings . '">' . $post_avgratings . '</span> / <span itemprop="best" content="5">5</span> ' . __("based on", 'geodirectory') . ' </span><span class="count" itemprop="count" content="' . $comment_count . '">' . $comment_count . ' ' . $reviews_text . '</span><br />'; |
|
1100 | + $html .= '<span itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating"><span class="rating" itemprop="average" content="' . $post_avgratings . '">' . $post_avgratings . '</span> / <span itemprop="best" content="5">5</span> ' . __("based on", 'geodirectory') . ' </span><span class="count" itemprop="count" content="' . $comment_count . '">' . $comment_count . ' ' . $reviews_text . '</span><br />'; |
|
1101 | 1101 | |
1102 | 1102 | $html .= '<span class="item">'; |
1103 | 1103 | $html .= '<span class="fn" itemprop="itemreviewed">' . $post->post_title . '</span>'; |
@@ -1211,13 +1211,13 @@ discard block |
||
1211 | 1211 | $ajax_url = str_replace("http", "https", admin_url('admin-ajax.php')); |
1212 | 1212 | } |
1213 | 1213 | |
1214 | - /** |
|
1215 | - * Filter the allowed image type extensions for post images. |
|
1216 | - * |
|
1217 | - * @since 1.4.7.1 |
|
1218 | - * @param string $allowed_img_types The image type extensions array. |
|
1219 | - */ |
|
1220 | - $allowed_img_types = apply_filters('geodir_allowed_post_image_exts', array('jpg', 'jpeg', 'jpe', 'gif', 'png')); |
|
1214 | + /** |
|
1215 | + * Filter the allowed image type extensions for post images. |
|
1216 | + * |
|
1217 | + * @since 1.4.7.1 |
|
1218 | + * @param string $allowed_img_types The image type extensions array. |
|
1219 | + */ |
|
1220 | + $allowed_img_types = apply_filters('geodir_allowed_post_image_exts', array('jpg', 'jpeg', 'jpe', 'gif', 'png')); |
|
1221 | 1221 | |
1222 | 1222 | $arr_alert_msg = array( |
1223 | 1223 | 'geodir_plugin_url' => geodir_plugin_url(), |
@@ -1265,13 +1265,13 @@ discard block |
||
1265 | 1265 | 'geodir_err_file_upload_limit' => __('You have reached your upload limit of %s files.', 'geodirectory'), |
1266 | 1266 | 'geodir_err_pkg_upload_limit' => __('You may only upload %s files with this package, please try again.', 'geodirectory'), |
1267 | 1267 | 'geodir_action_remove' => __('Remove', 'geodirectory'), |
1268 | - 'geodir_txt_all_files' => __('Allowed files', 'geodirectory'), |
|
1269 | - 'geodir_err_file_type' => __('File type error. Allowed file types: %s', 'geodirectory'), |
|
1270 | - 'gd_allowed_img_types' => !empty($allowed_img_types) ? implode(',', $allowed_img_types) : '', |
|
1271 | - 'geodir_txt_form_wait' => __('Wait...', 'geodirectory'), |
|
1272 | - 'geodir_txt_form_searching' => __('Searching...', 'geodirectory'), |
|
1273 | - 'fa_rating' => (int)get_option('geodir_reviewrating_enable_font_awesome') == 1 ? 1 : '', |
|
1274 | - 'reviewrating' => defined('GEODIRREVIEWRATING_VERSION') ? 1 : '', |
|
1268 | + 'geodir_txt_all_files' => __('Allowed files', 'geodirectory'), |
|
1269 | + 'geodir_err_file_type' => __('File type error. Allowed file types: %s', 'geodirectory'), |
|
1270 | + 'gd_allowed_img_types' => !empty($allowed_img_types) ? implode(',', $allowed_img_types) : '', |
|
1271 | + 'geodir_txt_form_wait' => __('Wait...', 'geodirectory'), |
|
1272 | + 'geodir_txt_form_searching' => __('Searching...', 'geodirectory'), |
|
1273 | + 'fa_rating' => (int)get_option('geodir_reviewrating_enable_font_awesome') == 1 ? 1 : '', |
|
1274 | + 'reviewrating' => defined('GEODIRREVIEWRATING_VERSION') ? 1 : '', |
|
1275 | 1275 | ); |
1276 | 1276 | |
1277 | 1277 | /** |
@@ -1457,7 +1457,7 @@ discard block |
||
1457 | 1457 | * @global object $gd_session GeoDirectory Session object. |
1458 | 1458 | */ |
1459 | 1459 | function geodir_after_main_form_fields() { |
1460 | - global $gd_session; |
|
1460 | + global $gd_session; |
|
1461 | 1461 | |
1462 | 1462 | if (get_option('geodir_accept_term_condition')) { |
1463 | 1463 | global $post; |
@@ -1530,13 +1530,13 @@ discard block |
||
1530 | 1530 | $is_display = (geodir_is_page('detail')) ? true : false; |
1531 | 1531 | |
1532 | 1532 | if ($tab == 'related_listing') { |
1533 | - $message = __('No listings found which match your selection.', 'geodirectory'); |
|
1533 | + $message = __('No listings found which match your selection.', 'geodirectory'); |
|
1534 | 1534 | |
1535 | - /** This action is documented in geodirectory-functions/template_functions.php */ |
|
1536 | - $message = apply_filters('geodir_message_listing_not_found', $message, 'listing-listview', false); |
|
1535 | + /** This action is documented in geodirectory-functions/template_functions.php */ |
|
1536 | + $message = apply_filters('geodir_message_listing_not_found', $message, 'listing-listview', false); |
|
1537 | 1537 | |
1538 | - $is_display = ((strpos($related_listing, $message) !== false || $related_listing == '' || !geodir_is_page('detail'))) ? false : true; |
|
1539 | - } |
|
1538 | + $is_display = ((strpos($related_listing, $message) !== false || $related_listing == '' || !geodir_is_page('detail'))) ? false : true; |
|
1539 | + } |
|
1540 | 1540 | |
1541 | 1541 | |
1542 | 1542 | return $is_display; |
@@ -1583,12 +1583,12 @@ discard block |
||
1583 | 1583 | function geodir_changes_in_custom_fields_table() { |
1584 | 1584 | global $wpdb, $plugin_prefix; |
1585 | 1585 | |
1586 | - // Remove unused virtual page |
|
1587 | - $listings_page_id = (int)get_option('geodir_listing_page'); |
|
1588 | - if ($listings_page_id) { |
|
1589 | - $wpdb->query($wpdb->prepare("DELETE FROM " . $wpdb->posts . " WHERE ID=%d AND post_name = %s AND post_type=%s", array($listings_page_id, 'listings', 'page'))); |
|
1586 | + // Remove unused virtual page |
|
1587 | + $listings_page_id = (int)get_option('geodir_listing_page'); |
|
1588 | + if ($listings_page_id) { |
|
1589 | + $wpdb->query($wpdb->prepare("DELETE FROM " . $wpdb->posts . " WHERE ID=%d AND post_name = %s AND post_type=%s", array($listings_page_id, 'listings', 'page'))); |
|
1590 | 1590 | delete_option('geodir_listing_page'); |
1591 | - } |
|
1591 | + } |
|
1592 | 1592 | |
1593 | 1593 | // updated custom field table(add field to show custom field as a tab) |
1594 | 1594 | /*if (!$wpdb->get_var("SHOW COLUMNS FROM ".GEODIR_CUSTOM_FIELDS_TABLE." WHERE field = 'show_as_tab'")) { |
@@ -1756,26 +1756,26 @@ discard block |
||
1756 | 1756 | |
1757 | 1757 | } |
1758 | 1758 | |
1759 | - // Update tag in detail table. |
|
1760 | - $taxonomy_obj = get_taxonomy($taxonomy); |
|
1761 | - $post_type = !empty($taxonomy_obj) ? $taxonomy_obj->object_type[0] : NULL; |
|
1759 | + // Update tag in detail table. |
|
1760 | + $taxonomy_obj = get_taxonomy($taxonomy); |
|
1761 | + $post_type = !empty($taxonomy_obj) ? $taxonomy_obj->object_type[0] : NULL; |
|
1762 | 1762 | |
1763 | - $post_types = geodir_get_posttypes(); |
|
1764 | - if ($post_type && in_array($post_type, $post_types) && $post_type . '_tags' == $taxonomy) { |
|
1765 | - $posts_obj = $wpdb->get_results($wpdb->prepare("SELECT object_id FROM " . $wpdb->term_relationships . " WHERE term_taxonomy_id = %d", array($tt_id))); |
|
1763 | + $post_types = geodir_get_posttypes(); |
|
1764 | + if ($post_type && in_array($post_type, $post_types) && $post_type . '_tags' == $taxonomy) { |
|
1765 | + $posts_obj = $wpdb->get_results($wpdb->prepare("SELECT object_id FROM " . $wpdb->term_relationships . " WHERE term_taxonomy_id = %d", array($tt_id))); |
|
1766 | 1766 | |
1767 | - if (!empty($posts_obj)) { |
|
1768 | - foreach ($posts_obj as $post_obj) { |
|
1769 | - $post_id = $post_obj->object_id; |
|
1767 | + if (!empty($posts_obj)) { |
|
1768 | + foreach ($posts_obj as $post_obj) { |
|
1769 | + $post_id = $post_obj->object_id; |
|
1770 | 1770 | |
1771 | - $raw_tags = wp_get_object_terms($post_id, $post_type . '_tags', array('fields' => 'names')); |
|
1772 | - $post_tags = !empty($raw_tags) ? implode(',', $raw_tags) : ''; |
|
1771 | + $raw_tags = wp_get_object_terms($post_id, $post_type . '_tags', array('fields' => 'names')); |
|
1772 | + $post_tags = !empty($raw_tags) ? implode(',', $raw_tags) : ''; |
|
1773 | 1773 | |
1774 | - $listing_table = $plugin_prefix . $post_type . '_detail'; |
|
1775 | - $wpdb->query($wpdb->prepare("UPDATE " . $listing_table . " SET post_tags=%s WHERE post_id =%d", array($post_tags, $post_id))); |
|
1776 | - } |
|
1777 | - } |
|
1778 | - } |
|
1774 | + $listing_table = $plugin_prefix . $post_type . '_detail'; |
|
1775 | + $wpdb->query($wpdb->prepare("UPDATE " . $listing_table . " SET post_tags=%s WHERE post_id =%d", array($post_tags, $post_id))); |
|
1776 | + } |
|
1777 | + } |
|
1778 | + } |
|
1779 | 1779 | } |
1780 | 1780 | |
1781 | 1781 | |
@@ -1998,14 +1998,14 @@ discard block |
||
1998 | 1998 | add_filter('posts_results', 'geodir_set_status_draft_to_publish_for_own_post'); |
1999 | 1999 | } |
2000 | 2000 | /** |
2001 | - * Set status from draft to publish. |
|
2002 | - * |
|
2003 | - * @since 1.0.0 |
|
2004 | - * @package GeoDirectory |
|
2005 | - * @global object $wp WordPress object. |
|
2006 | - * @param object $post Post object. |
|
2007 | - * @return object Modified post object. |
|
2008 | - */ |
|
2001 | + * Set status from draft to publish. |
|
2002 | + * |
|
2003 | + * @since 1.0.0 |
|
2004 | + * @package GeoDirectory |
|
2005 | + * @global object $wp WordPress object. |
|
2006 | + * @param object $post Post object. |
|
2007 | + * @return object Modified post object. |
|
2008 | + */ |
|
2009 | 2009 | function geodir_set_status_draft_to_publish_for_own_post($post) |
2010 | 2010 | { |
2011 | 2011 | global $wp; |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | /* ON TEMPLATE INCLUDE */ |
137 | 137 | ///////////////////////// |
138 | 138 | |
139 | -add_filter('template_include', 'geodir_template_loader',9); |
|
139 | +add_filter('template_include', 'geodir_template_loader', 9); |
|
140 | 140 | |
141 | 141 | ///////////////////////// |
142 | 142 | /* CATEGORY / TAXONOMY / CUSTOM POST ACTIONS */ |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | //////////////////////// |
178 | 178 | |
179 | 179 | add_action('geodir_update_postrating', 'geodir_term_review_count_force_update', 100); |
180 | -add_action('transition_post_status', 'geodir_term_review_count_force_update', 100,3); |
|
180 | +add_action('transition_post_status', 'geodir_term_review_count_force_update', 100, 3); |
|
181 | 181 | add_action('created_term', 'geodir_term_review_count_force_update', 100); |
182 | 182 | add_action('edited_term', 'geodir_term_review_count_force_update', 100); |
183 | 183 | add_action('delete_term', 'geodir_term_review_count_force_update', 100); |
@@ -319,8 +319,8 @@ discard block |
||
319 | 319 | |
320 | 320 | /////// GEO DIRECOTORY CUSTOM HOOKS /// |
321 | 321 | |
322 | -add_action('geodir_before_tab_content', 'geodir_before_tab_content');// this function is in custom_functions.php and it is used to wrap detail page tab content |
|
323 | -add_action('geodir_after_tab_content', 'geodir_after_tab_content');// this function is in custom_functions.php and it is used to wrap detail page tab content |
|
322 | +add_action('geodir_before_tab_content', 'geodir_before_tab_content'); // this function is in custom_functions.php and it is used to wrap detail page tab content |
|
323 | +add_action('geodir_after_tab_content', 'geodir_after_tab_content'); // this function is in custom_functions.php and it is used to wrap detail page tab content |
|
324 | 324 | |
325 | 325 | // Detail page sidebar content |
326 | 326 | add_action('geodir_detail_page_sidebar', 'geodir_detail_page_sidebar_content_sorting', 1); |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | $content_html = ob_get_clean(); |
423 | 423 | if (trim($content_html) != '') |
424 | 424 | $content_html = '<div class="geodir-company_info geodir-details-sidebar-social-sharing">' . $content_html . '</div>'; |
425 | - if ((int)get_option('geodir_disable_tfg_buttons_section') != 1) { |
|
425 | + if ((int) get_option('geodir_disable_tfg_buttons_section') != 1) { |
|
426 | 426 | /** |
427 | 427 | * Filter the geodir_social_sharing_buttons() function content. |
428 | 428 | * |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | $content_html = ob_get_clean(); |
470 | 470 | if (trim($content_html) != '') |
471 | 471 | $content_html = '<div class="geodir-company_info geodir-details-sidebar-sharethis">' . $content_html . '</div>'; |
472 | - if ((int)get_option('geodir_disable_sharethis_button_section') != 1) { |
|
472 | + if ((int) get_option('geodir_disable_sharethis_button_section') != 1) { |
|
473 | 473 | /** |
474 | 474 | * Filter the geodir_share_this_button() function content. |
475 | 475 | * |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | $post_id = $post->ID; |
512 | 512 | if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
513 | 513 | |
514 | - $post_id = (int)$_REQUEST['pid']; |
|
514 | + $post_id = (int) $_REQUEST['pid']; |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | $postlink = get_permalink(geodir_add_listing_page_id()); |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | $content_html = ob_get_clean(); |
529 | 529 | if (trim($content_html) != '') |
530 | 530 | $content_html = '<div class="geodir-company_info geodir-details-sidebar-user-links">' . $content_html . '</div>'; |
531 | - if ((int)get_option('geodir_disable_user_links_section') != 1) { |
|
531 | + if ((int) get_option('geodir_disable_user_links_section') != 1) { |
|
532 | 532 | /** |
533 | 533 | * Filter the geodir_edit_post_link() function content. |
534 | 534 | * |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | */ |
570 | 570 | do_action('geodir_before_google_analytics'); |
571 | 571 | |
572 | - if (get_option('geodir_ga_stats') && is_user_logged_in() && (isset($package_info->google_analytics) && $package_info->google_analytics == '1') && (get_current_user_id()==$post->post_author || current_user_can( 'manage_options' )) ) { |
|
572 | + if (get_option('geodir_ga_stats') && is_user_logged_in() && (isset($package_info->google_analytics) && $package_info->google_analytics == '1') && (get_current_user_id() == $post->post_author || current_user_can('manage_options'))) { |
|
573 | 573 | $page_url = urlencode($_SERVER['REQUEST_URI']); |
574 | 574 | ?> |
575 | 575 | <script type="text/javascript"> |
@@ -593,34 +593,34 @@ discard block |
||
593 | 593 | }); |
594 | 594 | |
595 | 595 | function gdga_weekVSweek() { |
596 | - jQuery.ajax({url: "<?php echo get_bloginfo('url').'/?ptype=ga&ga_page='.$page_url; ?>&ga_type=thisweek", success: function(result){ |
|
596 | + jQuery.ajax({url: "<?php echo get_bloginfo('url') . '/?ptype=ga&ga_page=' . $page_url; ?>&ga_type=thisweek", success: function(result){ |
|
597 | 597 | ga_data1 = jQuery.parseJSON(result); |
598 | 598 | if(ga_data1.error){jQuery('#ga_stats').html(result);return;} |
599 | 599 | gd_renderWeekOverWeekChart(); |
600 | 600 | }}); |
601 | 601 | |
602 | - jQuery.ajax({url: "<?php echo get_bloginfo('url').'/?ptype=ga&ga_page='.$page_url; ?>&ga_type=lastweek", success: function(result){ |
|
602 | + jQuery.ajax({url: "<?php echo get_bloginfo('url') . '/?ptype=ga&ga_page=' . $page_url; ?>&ga_type=lastweek", success: function(result){ |
|
603 | 603 | ga_data2 = jQuery.parseJSON(result); |
604 | 604 | gd_renderWeekOverWeekChart(); |
605 | 605 | }}); |
606 | 606 | } |
607 | 607 | |
608 | 608 | function gdga_yearVSyear() { |
609 | - jQuery.ajax({url: "<?php echo get_bloginfo('url').'/?ptype=ga&ga_page='.$page_url; ?>&ga_type=thisyear", success: function(result){ |
|
609 | + jQuery.ajax({url: "<?php echo get_bloginfo('url') . '/?ptype=ga&ga_page=' . $page_url; ?>&ga_type=thisyear", success: function(result){ |
|
610 | 610 | ga_data3 = jQuery.parseJSON(result); |
611 | 611 | if(ga_data3.error){jQuery('#ga_stats').html(result);return;} |
612 | 612 | |
613 | 613 | gd_renderYearOverYearChart() |
614 | 614 | }}); |
615 | 615 | |
616 | - jQuery.ajax({url: "<?php echo get_bloginfo('url').'/?ptype=ga&ga_page='.$page_url; ?>&ga_type=lastyear", success: function(result){ |
|
616 | + jQuery.ajax({url: "<?php echo get_bloginfo('url') . '/?ptype=ga&ga_page=' . $page_url; ?>&ga_type=lastyear", success: function(result){ |
|
617 | 617 | ga_data4 = jQuery.parseJSON(result); |
618 | 618 | gd_renderYearOverYearChart() |
619 | 619 | }}); |
620 | 620 | } |
621 | 621 | |
622 | 622 | function gdga_country() { |
623 | - jQuery.ajax({url: "<?php echo get_bloginfo('url').'/?ptype=ga&ga_page='.$page_url; ?>&ga_type=country", success: function(result){ |
|
623 | + jQuery.ajax({url: "<?php echo get_bloginfo('url') . '/?ptype=ga&ga_page=' . $page_url; ?>&ga_type=country", success: function(result){ |
|
624 | 624 | ga_data5 = jQuery.parseJSON(result); |
625 | 625 | if(ga_data5.error){jQuery('#ga_stats').html(result);return;} |
626 | 626 | gd_renderTopCountriesChart(); |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | } |
629 | 629 | |
630 | 630 | function gdga_realtime() { |
631 | - jQuery.ajax({url: "<?php echo get_bloginfo('url').'/?ptype=ga&ga_page='.$page_url; ?>&ga_type=realtime", success: function(result){ |
|
631 | + jQuery.ajax({url: "<?php echo get_bloginfo('url') . '/?ptype=ga&ga_page=' . $page_url; ?>&ga_type=realtime", success: function(result){ |
|
632 | 632 | ga_data6 = jQuery.parseJSON(result); |
633 | 633 | if(ga_data6.error){jQuery('#ga_stats').html(result);return;} |
634 | 634 | gd_renderRealTime(); |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | } |
695 | 695 | |
696 | 696 | function gdga_noResults() { |
697 | - jQuery('#gdga-chart-container').html('<?php _e('No results available','geodirectory');?>'); |
|
697 | + jQuery('#gdga-chart-container').html('<?php _e('No results available', 'geodirectory'); ?>'); |
|
698 | 698 | jQuery('#gdga-legend-container').html(''); |
699 | 699 | } |
700 | 700 | |
@@ -726,18 +726,18 @@ discard block |
||
726 | 726 | var data2 = results[1].rows.map(function(row) { return +row[2]; }); |
727 | 727 | //var labelsN = results[0].rows.map(function(row) { return +row[1]; }); |
728 | 728 | |
729 | - var labels = ['<?php _e('Jan', 'geodirectory');?>', |
|
730 | - '<?php _e('Feb', 'geodirectory');?>', |
|
731 | - '<?php _e('Mar', 'geodirectory');?>', |
|
732 | - '<?php _e('Apr', 'geodirectory');?>', |
|
733 | - '<?php _e('May', 'geodirectory');?>', |
|
734 | - '<?php _e('Jun', 'geodirectory');?>', |
|
735 | - '<?php _e('Jul', 'geodirectory');?>', |
|
736 | - '<?php _e('Aug', 'geodirectory');?>', |
|
737 | - '<?php _e('Sep', 'geodirectory');?>', |
|
738 | - '<?php _e('Oct', 'geodirectory');?>', |
|
739 | - '<?php _e('Nov', 'geodirectory');?>', |
|
740 | - '<?php _e('Dec', 'geodirectory');?>']; |
|
729 | + var labels = ['<?php _e('Jan', 'geodirectory'); ?>', |
|
730 | + '<?php _e('Feb', 'geodirectory'); ?>', |
|
731 | + '<?php _e('Mar', 'geodirectory'); ?>', |
|
732 | + '<?php _e('Apr', 'geodirectory'); ?>', |
|
733 | + '<?php _e('May', 'geodirectory'); ?>', |
|
734 | + '<?php _e('Jun', 'geodirectory'); ?>', |
|
735 | + '<?php _e('Jul', 'geodirectory'); ?>', |
|
736 | + '<?php _e('Aug', 'geodirectory'); ?>', |
|
737 | + '<?php _e('Sep', 'geodirectory'); ?>', |
|
738 | + '<?php _e('Oct', 'geodirectory'); ?>', |
|
739 | + '<?php _e('Nov', 'geodirectory'); ?>', |
|
740 | + '<?php _e('Dec', 'geodirectory'); ?>']; |
|
741 | 741 | |
742 | 742 | // Ensure the data arrays are at least as long as the labels array. |
743 | 743 | // Chart.js bar charts don't (yet) accept sparse datasets. |
@@ -750,13 +750,13 @@ discard block |
||
750 | 750 | labels : labels, |
751 | 751 | datasets : [ |
752 | 752 | { |
753 | - label: '<?php _e('Last Year', 'geodirectory');?>', |
|
753 | + label: '<?php _e('Last Year', 'geodirectory'); ?>', |
|
754 | 754 | fillColor : "rgba(220,220,220,0.5)", |
755 | 755 | strokeColor : "rgba(220,220,220,1)", |
756 | 756 | data : data2 |
757 | 757 | }, |
758 | 758 | { |
759 | - label: '<?php _e('This Year', 'geodirectory');?>', |
|
759 | + label: '<?php _e('This Year', 'geodirectory'); ?>', |
|
760 | 760 | fillColor : "rgba(151,187,205,0.5)", |
761 | 761 | strokeColor : "rgba(151,187,205,1)", |
762 | 762 | data : data1 |
@@ -801,30 +801,30 @@ discard block |
||
801 | 801 | |
802 | 802 | <?php |
803 | 803 | // Here we list the shorthand days of the week so it can be used in translation. |
804 | - __("Mon",'geodirectory'); |
|
805 | - __("Tue",'geodirectory'); |
|
806 | - __("Wed",'geodirectory'); |
|
807 | - __("Thu",'geodirectory'); |
|
808 | - __("Fri",'geodirectory'); |
|
809 | - __("Sat",'geodirectory'); |
|
810 | - __("Sun",'geodirectory'); |
|
804 | + __("Mon", 'geodirectory'); |
|
805 | + __("Tue", 'geodirectory'); |
|
806 | + __("Wed", 'geodirectory'); |
|
807 | + __("Thu", 'geodirectory'); |
|
808 | + __("Fri", 'geodirectory'); |
|
809 | + __("Sat", 'geodirectory'); |
|
810 | + __("Sun", 'geodirectory'); |
|
811 | 811 | ?> |
812 | 812 | |
813 | 813 | labels = [ |
814 | - "<?php _e(date('D', strtotime("+1 day")),'geodirectory'); ?>", |
|
815 | - "<?php _e(date('D', strtotime("+2 day")),'geodirectory'); ?>", |
|
816 | - "<?php _e(date('D', strtotime("+3 day")),'geodirectory'); ?>", |
|
817 | - "<?php _e(date('D', strtotime("+4 day")),'geodirectory'); ?>", |
|
818 | - "<?php _e(date('D', strtotime("+5 day")),'geodirectory'); ?>", |
|
819 | - "<?php _e(date('D', strtotime("+6 day")),'geodirectory'); ?>", |
|
820 | - "<?php _e(date('D', strtotime("+7 day")),'geodirectory'); ?>" |
|
814 | + "<?php _e(date('D', strtotime("+1 day")), 'geodirectory'); ?>", |
|
815 | + "<?php _e(date('D', strtotime("+2 day")), 'geodirectory'); ?>", |
|
816 | + "<?php _e(date('D', strtotime("+3 day")), 'geodirectory'); ?>", |
|
817 | + "<?php _e(date('D', strtotime("+4 day")), 'geodirectory'); ?>", |
|
818 | + "<?php _e(date('D', strtotime("+5 day")), 'geodirectory'); ?>", |
|
819 | + "<?php _e(date('D', strtotime("+6 day")), 'geodirectory'); ?>", |
|
820 | + "<?php _e(date('D', strtotime("+7 day")), 'geodirectory'); ?>" |
|
821 | 821 | ]; |
822 | 822 | |
823 | 823 | var data = { |
824 | 824 | labels : labels, |
825 | 825 | datasets : [ |
826 | 826 | { |
827 | - label: '<?php _e('Last Week', 'geodirectory');?>', |
|
827 | + label: '<?php _e('Last Week', 'geodirectory'); ?>', |
|
828 | 828 | fillColor : "rgba(220,220,220,0.5)", |
829 | 829 | strokeColor : "rgba(220,220,220,1)", |
830 | 830 | pointColor : "rgba(220,220,220,1)", |
@@ -832,7 +832,7 @@ discard block |
||
832 | 832 | data : data2 |
833 | 833 | }, |
834 | 834 | { |
835 | - label: '<?php _e('This Week', 'geodirectory');?>', |
|
835 | + label: '<?php _e('This Week', 'geodirectory'); ?>', |
|
836 | 836 | fillColor : "rgba(151,187,205,0.5)", |
837 | 837 | strokeColor : "rgba(151,187,205,1)", |
838 | 838 | pointColor : "rgba(151,187,205,1)", |
@@ -1014,18 +1014,18 @@ discard block |
||
1014 | 1014 | |
1015 | 1015 | |
1016 | 1016 | <span id="ga_stats"> |
1017 | - <div id="ga-analytics-title"><?php _e("Analytics", 'geodirectory');?></div> |
|
1017 | + <div id="ga-analytics-title"><?php _e("Analytics", 'geodirectory'); ?></div> |
|
1018 | 1018 | |
1019 | 1019 | <div id="gd-active-users-container"> |
1020 | - <div class="gd-ActiveUsers"><?php _e("Active Users:", 'geodirectory');?> |
|
1020 | + <div class="gd-ActiveUsers"><?php _e("Active Users:", 'geodirectory'); ?> |
|
1021 | 1021 | <b class="gd-ActiveUsers-value">0</b> |
1022 | 1022 | </div> |
1023 | 1023 | </div> |
1024 | 1024 | |
1025 | 1025 | <select id="gdga-select-analytic" onchange="gdga_select_option();" style="display: none;"> |
1026 | - <option value="weeks"><?php _e("Last Week vs This Week", 'geodirectory');?></option> |
|
1027 | - <option value="years"><?php _e("This Year vs Last Year", 'geodirectory');?></option> |
|
1028 | - <option value="country"><?php _e("Top Countries", 'geodirectory');?></option> |
|
1026 | + <option value="weeks"><?php _e("Last Week vs This Week", 'geodirectory'); ?></option> |
|
1027 | + <option value="years"><?php _e("This Year vs Last Year", 'geodirectory'); ?></option> |
|
1028 | + <option value="country"><?php _e("Top Countries", 'geodirectory'); ?></option> |
|
1029 | 1029 | </select> |
1030 | 1030 | <img alt="loader icon" id="gdga-loader-icon" src="<?php echo geodir_plugin_url() . '/geodirectory-assets/images/ajax-loader.gif'; ?>" /> |
1031 | 1031 | <div class="Chartjs-figure" id="gdga-chart-container"></div> |
@@ -1043,7 +1043,7 @@ discard block |
||
1043 | 1043 | $content_html = ob_get_clean(); |
1044 | 1044 | if (trim($content_html) != '') |
1045 | 1045 | $content_html = '<div class="geodir-company_info geodir-details-sidebar-google-analytics">' . $content_html . '</div>'; |
1046 | - if ((int)get_option('geodir_disable_google_analytics_section') != 1) { |
|
1046 | + if ((int) get_option('geodir_disable_google_analytics_section') != 1) { |
|
1047 | 1047 | /** |
1048 | 1048 | * Filter the geodir_edit_post_link() function content. |
1049 | 1049 | * |
@@ -1139,7 +1139,7 @@ discard block |
||
1139 | 1139 | if (trim($content_html) != '') { |
1140 | 1140 | $content_html = '<div class="geodir-company_info geodir-details-sidebar-rating">' . $content_html . '</div>'; |
1141 | 1141 | } |
1142 | - if ((int)get_option('geodir_disable_rating_info_section') != 1) { |
|
1142 | + if ((int) get_option('geodir_disable_rating_info_section') != 1) { |
|
1143 | 1143 | /** |
1144 | 1144 | * Filter the geodir_detail_page_review_rating() function content. |
1145 | 1145 | * |
@@ -1179,7 +1179,7 @@ discard block |
||
1179 | 1179 | $content_html = ob_get_clean(); |
1180 | 1180 | if (trim($content_html) != '') |
1181 | 1181 | $content_html = '<div class="geodir-company_info geodir-details-sidebar-listing-info">' . $content_html . '</div>'; |
1182 | - if ((int)get_option('geodir_disable_listing_info_section') != 1) { |
|
1182 | + if ((int) get_option('geodir_disable_listing_info_section') != 1) { |
|
1183 | 1183 | /** |
1184 | 1184 | * Filter the output html for function geodir_detail_page_more_info(). |
1185 | 1185 | * |
@@ -1270,7 +1270,7 @@ discard block |
||
1270 | 1270 | 'gd_allowed_img_types' => !empty($allowed_img_types) ? implode(',', $allowed_img_types) : '', |
1271 | 1271 | 'geodir_txt_form_wait' => __('Wait...', 'geodirectory'), |
1272 | 1272 | 'geodir_txt_form_searching' => __('Searching...', 'geodirectory'), |
1273 | - 'fa_rating' => (int)get_option('geodir_reviewrating_enable_font_awesome') == 1 ? 1 : '', |
|
1273 | + 'fa_rating' => (int) get_option('geodir_reviewrating_enable_font_awesome') == 1 ? 1 : '', |
|
1274 | 1274 | 'reviewrating' => defined('GEODIRREVIEWRATING_VERSION') ? 1 : '', |
1275 | 1275 | ); |
1276 | 1276 | |
@@ -1287,7 +1287,7 @@ discard block |
||
1287 | 1287 | foreach ($arr_alert_msg as $key => $value) { |
1288 | 1288 | if (!is_scalar($value)) |
1289 | 1289 | continue; |
1290 | - $arr_alert_msg[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8'); |
|
1290 | + $arr_alert_msg[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
1291 | 1291 | } |
1292 | 1292 | |
1293 | 1293 | $script = "var geodir_all_js_msg = " . json_encode($arr_alert_msg) . ';'; |
@@ -1463,7 +1463,7 @@ discard block |
||
1463 | 1463 | global $post; |
1464 | 1464 | $term_condition = ''; |
1465 | 1465 | if (isset($_REQUEST['backandedit'])) { |
1466 | - $post = (object)$gd_session->get('listing'); |
|
1466 | + $post = (object) $gd_session->get('listing'); |
|
1467 | 1467 | $term_condition = isset($post->geodir_accept_term_condition) ? $post->geodir_accept_term_condition : ''; |
1468 | 1468 | } |
1469 | 1469 | |
@@ -1477,7 +1477,7 @@ discard block |
||
1477 | 1477 | echo 'checked="checked"'; |
1478 | 1478 | } ?> field_type="checkbox" name="geodir_accept_term_condition" id="geodir_accept_term_condition" |
1479 | 1479 | class="geodir_textfield" value="1" |
1480 | - style="display:inline-block"/><a href="<?php $terms_page = get_option('geodir_term_condition_page'); if($terms_page){ echo get_permalink($terms_page);}?>" target="_blank"><?php _e('Please accept our terms and conditions', 'geodirectory'); ?></a> |
|
1480 | + style="display:inline-block"/><a href="<?php $terms_page = get_option('geodir_term_condition_page'); if ($terms_page) { echo get_permalink($terms_page); }?>" target="_blank"><?php _e('Please accept our terms and conditions', 'geodirectory'); ?></a> |
|
1481 | 1481 | </span> |
1482 | 1482 | </div> |
1483 | 1483 | <span class="geodir_message_error"><?php if (isset($required_msg)) { |
@@ -1584,7 +1584,7 @@ discard block |
||
1584 | 1584 | global $wpdb, $plugin_prefix; |
1585 | 1585 | |
1586 | 1586 | // Remove unused virtual page |
1587 | - $listings_page_id = (int)get_option('geodir_listing_page'); |
|
1587 | + $listings_page_id = (int) get_option('geodir_listing_page'); |
|
1588 | 1588 | if ($listings_page_id) { |
1589 | 1589 | $wpdb->query($wpdb->prepare("DELETE FROM " . $wpdb->posts . " WHERE ID=%d AND post_name = %s AND post_type=%s", array($listings_page_id, 'listings', 'page'))); |
1590 | 1590 | delete_option('geodir_listing_page'); |
@@ -1846,43 +1846,43 @@ discard block |
||
1846 | 1846 | |
1847 | 1847 | |
1848 | 1848 | $gd_page = ''; |
1849 | - if(geodir_is_page('home')){ |
|
1849 | + if (geodir_is_page('home')) { |
|
1850 | 1850 | $gd_page = 'home'; |
1851 | 1851 | $title = (get_option('geodir_meta_title_homepage')) ? get_option('geodir_meta_title_homepage') : $title; |
1852 | 1852 | } |
1853 | - elseif(geodir_is_page('detail')){ |
|
1853 | + elseif (geodir_is_page('detail')) { |
|
1854 | 1854 | $gd_page = 'detail'; |
1855 | 1855 | $title = (get_option('geodir_meta_title_detail')) ? get_option('geodir_meta_title_detail') : $title; |
1856 | 1856 | } |
1857 | - elseif(geodir_is_page('pt')){ |
|
1857 | + elseif (geodir_is_page('pt')) { |
|
1858 | 1858 | $gd_page = 'pt'; |
1859 | 1859 | $title = (get_option('geodir_meta_title_pt')) ? get_option('geodir_meta_title_pt') : $title; |
1860 | 1860 | } |
1861 | - elseif(geodir_is_page('listing')){ |
|
1861 | + elseif (geodir_is_page('listing')) { |
|
1862 | 1862 | $gd_page = 'listing'; |
1863 | 1863 | $title = (get_option('geodir_meta_title_listing')) ? get_option('geodir_meta_title_listing') : $title; |
1864 | 1864 | } |
1865 | - elseif(geodir_is_page('location')){ |
|
1865 | + elseif (geodir_is_page('location')) { |
|
1866 | 1866 | $gd_page = 'location'; |
1867 | 1867 | $title = (get_option('geodir_meta_title_location')) ? get_option('geodir_meta_title_location') : $title; |
1868 | 1868 | } |
1869 | - elseif(geodir_is_page('search')){ |
|
1869 | + elseif (geodir_is_page('search')) { |
|
1870 | 1870 | $gd_page = 'search'; |
1871 | 1871 | $title = (get_option('geodir_meta_title_search')) ? get_option('geodir_meta_title_search') : $title; |
1872 | 1872 | } |
1873 | - elseif(geodir_is_page('add-listing')){ |
|
1873 | + elseif (geodir_is_page('add-listing')) { |
|
1874 | 1874 | $gd_page = 'add-listing'; |
1875 | 1875 | $title = (get_option('geodir_meta_title_add-listing')) ? get_option('geodir_meta_title_add-listing') : $title; |
1876 | 1876 | } |
1877 | - elseif(geodir_is_page('author')){ |
|
1877 | + elseif (geodir_is_page('author')) { |
|
1878 | 1878 | $gd_page = 'author'; |
1879 | 1879 | $title = (get_option('geodir_meta_title_author')) ? get_option('geodir_meta_title_author') : $title; |
1880 | 1880 | } |
1881 | - elseif(geodir_is_page('login')){ |
|
1881 | + elseif (geodir_is_page('login')) { |
|
1882 | 1882 | $gd_page = 'login'; |
1883 | 1883 | $title = (get_option('geodir_meta_title_login')) ? get_option('geodir_meta_title_login') : $title; |
1884 | 1884 | } |
1885 | - elseif(geodir_is_page('listing-success')){ |
|
1885 | + elseif (geodir_is_page('listing-success')) { |
|
1886 | 1886 | $gd_page = 'listing-success'; |
1887 | 1887 | $title = (get_option('geodir_meta_title_listing-success')) ? get_option('geodir_meta_title_listing-success') : $title; |
1888 | 1888 | } |
@@ -2146,7 +2146,7 @@ discard block |
||
2146 | 2146 | */ |
2147 | 2147 | function geodir_remove_template_redirect_actions() |
2148 | 2148 | { |
2149 | - if (geodir_is_page('login')){ |
|
2149 | + if (geodir_is_page('login')) { |
|
2150 | 2150 | remove_all_actions('template_redirect'); |
2151 | 2151 | remove_action('init', 'avia_modify_front', 10); |
2152 | 2152 | } |
@@ -2593,8 +2593,8 @@ discard block |
||
2593 | 2593 | $date_format = $date_format['date_format']; |
2594 | 2594 | } |
2595 | 2595 | |
2596 | - $search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format |
|
2597 | - $replace = array('d','j','l','m','n','F','Y');//PHP date format |
|
2596 | + $search = array('dd', 'd', 'DD', 'mm', 'm', 'MM', 'yy'); //jQuery UI datepicker format |
|
2597 | + $replace = array('d', 'j', 'l', 'm', 'n', 'F', 'Y'); //PHP date format |
|
2598 | 2598 | |
2599 | 2599 | $date_format = str_replace($search, $replace, $date_format); |
2600 | 2600 | |
@@ -2689,7 +2689,7 @@ discard block |
||
2689 | 2689 | $html_var = $type['htmlvar_name']; |
2690 | 2690 | $html_val = $type['htmlvar_name']; |
2691 | 2691 | |
2692 | - if ((int)$post->$html_var == 1) { |
|
2692 | + if ((int) $post->$html_var == 1) { |
|
2693 | 2693 | |
2694 | 2694 | if ($post->$type['htmlvar_name'] == '1') { |
2695 | 2695 | $html_val = __('Yes', 'geodirectory'); |
@@ -2865,7 +2865,7 @@ discard block |
||
2865 | 2865 | |
2866 | 2866 | if (!empty($files)) { |
2867 | 2867 | $extra_fields = !empty($type['extra_fields']) ? maybe_unserialize($type['extra_fields']) : NULL; |
2868 | - $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? $extra_fields['gd_file_types'] : ''; |
|
2868 | + $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types']) ? $extra_fields['gd_file_types'] : ''; |
|
2869 | 2869 | |
2870 | 2870 | $file_paths = ''; |
2871 | 2871 | foreach ($files as $file) { |
@@ -2893,7 +2893,7 @@ discard block |
||
2893 | 2893 | // If the uploaded file is image |
2894 | 2894 | if (in_array($uploaded_file_type, $image_file_types)) { |
2895 | 2895 | $file_paths .= '<div class="geodir-custom-post-gallery" class="clearfix">'; |
2896 | - $file_paths .= '<a href="'.$file.'">'; |
|
2896 | + $file_paths .= '<a href="' . $file . '">'; |
|
2897 | 2897 | $file_paths .= geodir_show_image(array('src' => $file), 'thumbnail', false, false); |
2898 | 2898 | $file_paths .= '</a>'; |
2899 | 2899 | $file_paths .= '</div>'; |
@@ -3243,7 +3243,7 @@ discard block |
||
3243 | 3243 | * @return array Translation texts. |
3244 | 3244 | */ |
3245 | 3245 | function geodir_load_gd_options_text_translation($translation_texts = array()) { |
3246 | - $translation_texts = !empty( $translation_texts ) && is_array( $translation_texts ) ? $translation_texts : array(); |
|
3246 | + $translation_texts = !empty($translation_texts) && is_array($translation_texts) ? $translation_texts : array(); |
|
3247 | 3247 | |
3248 | 3248 | $gd_options = array('geodir_post_submited_success_email_subject_admin', 'geodir_post_submited_success_email_content_admin', 'geodir_post_submited_success_email_subject', 'geodir_post_submited_success_email_content', 'geodir_forgot_password_subject', 'geodir_forgot_password_content', 'geodir_registration_success_email_subject', 'geodir_registration_success_email_content', 'geodir_post_published_email_subject', 'geodir_post_published_email_content', 'geodir_email_friend_subject', 'geodir_email_friend_content', 'geodir_email_enquiry_subject', 'geodir_email_enquiry_content', 'geodir_post_added_success_msg_content'); |
3249 | 3249 |
@@ -27,12 +27,12 @@ |
||
27 | 27 | if (!empty($wpdb->collate)) $collate .= " COLLATE $wpdb->collate"; |
28 | 28 | } |
29 | 29 | |
30 | - /** |
|
31 | - * Include any functions needed for upgrades. |
|
32 | - * |
|
33 | - * @since 1.0.0 |
|
34 | - */ |
|
35 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
30 | + /** |
|
31 | + * Include any functions needed for upgrades. |
|
32 | + * |
|
33 | + * @since 1.0.0 |
|
34 | + */ |
|
35 | + require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
36 | 36 | |
37 | 37 | |
38 | 38 | // rename tables if we need to |
@@ -23,8 +23,12 @@ |
||
23 | 23 | |
24 | 24 | $collate = ''; |
25 | 25 | if ($wpdb->has_cap('collation')) { |
26 | - if (!empty($wpdb->charset)) $collate = "DEFAULT CHARACTER SET $wpdb->charset"; |
|
27 | - if (!empty($wpdb->collate)) $collate .= " COLLATE $wpdb->collate"; |
|
26 | + if (!empty($wpdb->charset)) { |
|
27 | + $collate = "DEFAULT CHARACTER SET $wpdb->charset"; |
|
28 | + } |
|
29 | + if (!empty($wpdb->collate)) { |
|
30 | + $collate .= " COLLATE $wpdb->collate"; |
|
31 | + } |
|
28 | 32 | } |
29 | 33 | |
30 | 34 | /** |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * GeoDirectory Installation related functions. |
|
4 | - * |
|
5 | - * Plugin install script which adds default pages, taxonomies, and database tables. |
|
6 | - * |
|
7 | - * @since 1.0.0 |
|
8 | - * @package GeoDirectory |
|
9 | - */ |
|
3 | + * GeoDirectory Installation related functions. |
|
4 | + * |
|
5 | + * Plugin install script which adds default pages, taxonomies, and database tables. |
|
6 | + * |
|
7 | + * @since 1.0.0 |
|
8 | + * @package GeoDirectory |
|
9 | + */ |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Include custom database table related functions. |
@@ -7,12 +7,12 @@ |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | if (isset($_REQUEST['create_field'])) { |
10 | - /** |
|
11 | - * Includes file to create custom fields. |
|
12 | - * |
|
13 | - * @since 1.0.0 |
|
14 | - */ |
|
15 | - include_once(geodir_plugin_path() . '/geodirectory-admin/option-pages/create_field.php'); |
|
10 | + /** |
|
11 | + * Includes file to create custom fields. |
|
12 | + * |
|
13 | + * @since 1.0.0 |
|
14 | + */ |
|
15 | + include_once(geodir_plugin_path() . '/geodirectory-admin/option-pages/create_field.php'); |
|
16 | 16 | die; |
17 | 17 | } |
18 | 18 |