/** * Returns related listings of a listing. * * @since 1.0.0 * @package GeoDirectory * @param array $request Related posts request array. * @global object $wpdb WordPress Database object. * @global object $post The current post object. * @global string $gridview_columns The girdview style of the listings. * @return string Returns related posts html. */ function geodir_related_posts_display($request) { if (!empty($request)) { $before_title = isset($request['before_title']) && !empty($request['before_title']) ? $request['before_title'] : ''; $after_title = isset($request['after_title']) && !empty($request['after_title']) ? $request['after_title'] : ''; $title = isset($request['title']) && !empty($request['title']) ? $request['title'] : __('Related Listings', 'geodirectory'); $post_number = isset($request['post_number']) && !empty($request['post_number']) ? $request['post_number'] : '5'; $relate_to = isset($request['relate_to']) && !empty($request['relate_to']) ? $request['relate_to'] : 'category'; $layout = isset($request['layout']) && !empty($request['layout']) ? $request['layout'] : 'gridview_onehalf'; $add_location_filter = isset($request['add_location_filter']) && !empty($request['add_location_filter']) ? $request['add_location_filter'] : '0'; $listing_width = isset($request['listing_width']) && !empty($request['listing_width']) ? $request['listing_width'] : ''; $list_sort = isset($request['list_sort']) && !empty($request['list_sort']) ? $request['list_sort'] : 'latest'; $character_count = isset($request['character_count']) && !empty($request['character_count']) ? $request['character_count'] : ''; global $wpdb, $post; $origi_post = $post; $post_type = ''; $post_id = ''; $category_taxonomy = ''; $tax_field = 'id'; $category = array(); if (isset($_REQUEST['backandedit'])) { $post = (object) unserialize($_SESSION['listing']); $post_type = $post->listing_type; if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { $post_id = $_REQUEST['pid']; } } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { $post = geodir_get_post_info($_REQUEST['pid']); $post_type = $post->post_type; $post_id = $_REQUEST['pid']; } elseif (isset($post->post_type) && $post->post_type != '') { $post_type = $post->post_type; $post_id = $post->ID; } if ($relate_to == 'category') { $category_taxonomy = $post_type . $relate_to; if (isset($post->{$category_taxonomy}) && $post->{$category_taxonomy} != '') { $category = explode(',', trim($post->{$category_taxonomy}, ',')); } } elseif ($relate_to == 'tags') { $category_taxonomy = $post_type . '_' . $relate_to; if ($post->post_tags != '') { $category = explode(',', trim($post->post_tags, ',')); } $tax_field = 'name'; } /* --- return false in invalid request --- */ if (empty($category)) { return false; } $all_postypes = geodir_get_posttypes(); if (!in_array($post_type, $all_postypes)) { return false; } /* --- return false in invalid request --- */ $location_url = ''; if ($add_location_filter != '0') { $location_url = array(); $geodir_show_location_url = get_option('geodir_show_location_url'); $gd_city = get_query_var('gd_city'); if ($gd_city) { $gd_country = get_query_var('gd_country'); $gd_region = get_query_var('gd_region'); } else { $location = geodir_get_default_location(); $gd_country = isset($location->country_slug) ? $location->country_slug : ''; $gd_region = isset($location->region_slug) ? $location->region_slug : ''; $gd_city = isset($location->city_slug) ? $location->city_slug : ''; } if ($geodir_show_location_url == 'all') { $location_url[] = $gd_country; $location_url[] = $gd_region; } else { if ($geodir_show_location_url == 'country_city') { $location_url[] = $gd_country; } else { if ($geodir_show_location_url == 'region_city') { $location_url[] = $gd_region; } } } $location_url[] = $gd_city; $location_url = implode('/', $location_url); } if (!empty($category)) { global $geodir_add_location_url; $geodir_add_location_url = '0'; if ($add_location_filter != '0') { $geodir_add_location_url = '1'; } $viewall_url = get_term_link((int) $category[0], $post_type . $category_taxonomy); $geodir_add_location_url = NULL; } ob_start(); ?> <div class="geodir_locations geodir_location_listing"> <?php if (isset($request['is_widget']) && $request['is_widget'] == '1') { /** geodir_before_title filter Documented in geodirectory_widgets.php */ $before_title = isset($before_title) ? $before_title : apply_filters('geodir_before_title', '<h3 class="widget-title">'); /** geodir_after_title filter Documented in geodirectory_widgets.php */ $after_title = isset($after_title) ? $after_title : apply_filters('geodir_after_title', '</h3>'); ?> <div class="location_list_heading clearfix"> <?php echo $before_title . $title . $after_title; ?> </div> <?php } $query_args = array('posts_per_page' => $post_number, 'is_geodir_loop' => true, 'gd_location' => $add_location_filter ? true : false, 'post_type' => $post_type, 'order_by' => $list_sort, 'post__not_in' => array($post_id), 'excerpt_length' => $character_count); $tax_query = array('taxonomy' => $category_taxonomy, 'field' => $tax_field, 'terms' => $category); $query_args['tax_query'] = array($tax_query); global $gridview_columns, $post; query_posts($query_args); if (strstr($layout, 'gridview')) { $listing_view_exp = explode('_', $layout); $gridview_columns = $layout; $layout = $listing_view_exp[0]; } else { if ($layout == 'list') { $gridview_columns = ''; } } $related_posts = true; /** * Filters related listing listview template. * * @since 1.0.0 */ $template = apply_filters("geodir_template_part-related-listing-listview", geodir_locate_template('listing-listview')); /** * Includes related listing listview template. * * @since 1.0.0 */ include $template; wp_reset_query(); $post = $origi_post; ?> </div> <?php return $html = ob_get_clean(); } }
/** * Generates popular postview HTML. * * @since 1.0.0 * @since 1.5.1 View all link fixed for location filter disabled. * @package GeoDirectory * @global object $post The current post object. * @global string $gridview_columns_widget The girdview style of the listings for widget. * @global bool $geodir_is_widget_listing Is this a widget listing?. Default: false. * @param array|string $args Display arguments including before_title, after_title, before_widget, and after_widget. * @param array|string $instance The settings for the particular instance of the widget. */ function geodir_popular_postview_output($args = '', $instance = '') { //print_r($args); //print_r($instance); // prints the widget extract($args, EXTR_SKIP); echo $before_widget; /** This filter is documented in geodirectory_widgets.php */ $title = empty($instance['title']) ? ucwords($instance['category_title']) : apply_filters('widget_title', __($instance['title'], 'geodirectory')); /** * Filter the widget post type. * * @since 1.0.0 * @param string $instance['post_type'] Post type of listing. */ $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']); /** * Filter the widget's term. * * @since 1.0.0 * @param string $instance['category'] Filter by term. Can be any valid term. */ $category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']); /** * Filter the widget listings limit. * * @since 1.0.0 * @param string $instance['post_number'] Number of listings to display. */ $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']); /** * Filter widget's "layout" type. * * @since 1.0.0 * @param string $instance['layout'] Widget layout type. */ $layout = empty($instance['layout']) ? 'gridview_onehalf' : apply_filters('widget_layout', $instance['layout']); /** * Filter widget's "add_location_filter" value. * * @since 1.0.0 * @param string|bool $instance['add_location_filter'] Do you want to add location filter? Can be 1 or 0. */ $add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_add_location_filter', $instance['add_location_filter']); /** * Filter widget's listing width. * * @since 1.0.0 * @param string $instance['listing_width'] Listing width. */ $listing_width = empty($instance['listing_width']) ? '' : apply_filters('widget_listing_width', $instance['listing_width']); /** * Filter widget's "list_sort" type. * * @since 1.0.0 * @param string $instance['list_sort'] Listing sort by type. */ $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']); $use_viewing_post_type = !empty($instance['use_viewing_post_type']) ? true : false; // set post type to current viewing post type if ($use_viewing_post_type) { $current_post_type = geodir_get_current_posttype(); if ($current_post_type != '' && $current_post_type != $post_type) { $post_type = $current_post_type; $category = array(); // old post type category will not work for current changed post type } } // replace widget title dynamically $posttype_plural_label = __(get_post_type_plural_label($post_type), 'geodirectory'); $posttype_singular_label = __(get_post_type_singular_label($post_type), 'geodirectory'); $title = str_replace("%posttype_plural_label%", $posttype_plural_label, $title); $title = str_replace("%posttype_singular_label%", $posttype_singular_label, $title); if (isset($instance['character_count'])) { /** * Filter the widget's excerpt character count. * * @since 1.0.0 * @param int $instance['character_count'] Excerpt character count. */ $character_count = apply_filters('widget_list_character_count', $instance['character_count']); } else { $character_count = ''; } if (empty($title) || $title == 'All') { $title .= ' ' . __(get_post_type_plural_label($post_type), 'geodirectory'); } $location_url = array(); $city = get_query_var('gd_city'); if (!empty($city)) { if (get_option('geodir_show_location_url') == 'all') { $country = get_query_var('gd_country'); $region = get_query_var('gd_region'); if (!empty($country)) { $location_url[] = $country; } if (!empty($region)) { $location_url[] = $region; } } $location_url[] = $city; } $location_url = implode("/", $location_url); $skip_location = false; if (!$add_location_filter && !empty($_SESSION['gd_multi_location'])) { $skip_location = true; unset($_SESSION['gd_multi_location']); } if (get_option('permalink_structure')) { $viewall_url = get_post_type_archive_link($post_type); } else { $viewall_url = get_post_type_archive_link($post_type); } if (!empty($category) && $category[0] != '0') { global $geodir_add_location_url; $geodir_add_location_url = '0'; if ($add_location_filter != '0') { $geodir_add_location_url = '1'; } $viewall_url = get_term_link((int) $category[0], $post_type . 'category'); $geodir_add_location_url = NULL; } if ($skip_location) { $_SESSION['gd_multi_location'] = 1; } $query_args = array('posts_per_page' => $post_number, 'is_geodir_loop' => true, 'gd_location' => $add_location_filter ? true : false, 'post_type' => $post_type, 'order_by' => $list_sort); if ($character_count) { $query_args['excerpt_length'] = $character_count; } if (!empty($instance['show_featured_only'])) { $query_args['show_featured_only'] = 1; } if (!empty($instance['show_special_only'])) { $query_args['show_special_only'] = 1; } if (!empty($instance['with_pics_only'])) { $query_args['with_pics_only'] = 0; $query_args['featured_image_only'] = 1; } if (!empty($instance['with_videos_only'])) { $query_args['with_videos_only'] = 1; } $with_no_results = !empty($instance['without_no_results']) ? false : true; if (!empty($category) && $category[0] != '0') { $category_taxonomy = geodir_get_taxonomies($post_type); ######### WPML ######### if (function_exists('icl_object_id')) { $category = gd_lang_object_ids($category, $category_taxonomy[0]); } ######### WPML ######### $tax_query = array('taxonomy' => $category_taxonomy[0], 'field' => 'id', 'terms' => $category); $query_args['tax_query'] = array($tax_query); } global $gridview_columns_widget, $geodir_is_widget_listing; $widget_listings = geodir_get_widget_listings($query_args); if (!empty($widget_listings) || $with_no_results) { ?> <div class="geodir_locations geodir_location_listing"> <?php /** * Called before the div containing the title and view all link in popular post view widget. * * @since 1.0.0 */ do_action('geodir_before_view_all_link_in_widget'); ?> <div class="geodir_list_heading clearfix"> <?php if ($title == 'ร้านอาหาร') { echo '<img src = "/wordpress/wp-content/food.png" width="100%">'; } else { echo '<img src = "/wordpress/wp-content/u.png" width="100%">'; } ?> <?php //echo $before_title . $title . $after_title; ?> <a href="<?php echo $viewall_url; ?> " class="geodir-viewall"><?php _e('View all', 'geodirectory'); ?> </a> </div> <?php /** * Called after the div containing the title and view all link in popular post view widget. * * @since 1.0.0 */ do_action('geodir_after_view_all_link_in_widget'); ?> <?php if (strstr($layout, 'gridview')) { $listing_view_exp = explode('_', $layout); $gridview_columns_widget = $layout; $layout = $listing_view_exp[0]; } else { $gridview_columns_widget = ''; } /** * Filter the widget listing listview template path. * * @since 1.0.0 */ $template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview')); if (!isset($character_count)) { /** * Filter the widget's excerpt character count. * * @since 1.0.0 * @param int $instance['character_count'] Excerpt character count. */ $character_count = $character_count == '' ? 50 : apply_filters('widget_character_count', $character_count); } global $post, $map_jason, $map_canvas_arr; $current_post = $post; $current_map_jason = $map_jason; $current_map_canvas_arr = $map_canvas_arr; $geodir_is_widget_listing = true; /** * Includes related listing listview template. * * @since 1.0.0 */ include $template; $geodir_is_widget_listing = false; $GLOBALS['post'] = $current_post; if (!empty($current_post)) { setup_postdata($current_post); } $map_jason = $current_map_jason; $map_canvas_arr = $current_map_canvas_arr; ?> </div> <?php } echo $after_widget; }
/** * Loads template based on the current page. * * @since 1.0.0 * @package GeoDirectory * @global object $wp_query WordPress Query object. * @todo $wp_query declared twice - fix it. * @global object $post The current post object. * @global object $current_user Current user object. * @param string $template The template path. * @return bool|string The template path. */ function geodir_template_loader($template) { global $wp_query; /** * Filter the custom page list. * * @since 1.0.0 */ $geodir_custom_page_list = apply_filters('geodir_set_custom_pages', array('geodir_signup_page' => apply_filters('geodir_set_custom_signup_page', false), 'geodir_add_listing_page' => apply_filters('geodir_set_custom_add_listing_page', false), 'geodir_preview_page' => apply_filters('geodir_set_custom_preview_page', false), 'geodir_listing_success_page' => apply_filters('geodir_set_custom_listing_success_page', false), 'geodir_listing_detail_page' => apply_filters('geodir_set_custom_listing_detail_page', false), 'geodir_listing_page' => apply_filters('geodir_set_custom_listing_page', false), 'geodir_search_page' => apply_filters('geodir_set_custom_search_page', false), 'geodir_author_page' => apply_filters('geodir_set_custom_author_page', false), 'geodir_home_map_page' => apply_filters('geodir_set_custom_home_map_page', false))); if (geodir_is_page('login') || $geodir_custom_page_list['geodir_signup_page']) { $template = geodir_locate_template('signup'); if (!$template) { $template = geodir_plugin_path() . '/geodirectory-templates/geodir-signup.php'; } /** * Filter the signup template path. * * @since 1.0.0 * @param string $template The template path. */ return $template = apply_filters('geodir_template_signup', $template); } if (geodir_is_page('add-listing') || $geodir_custom_page_list['geodir_add_listing_page']) { if (!geodir_is_default_location_set()) { global $information; $information = sprintf(__('Please %sclick here%s to set a default location, this will make the plugin work properly.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>'); $template = geodir_locate_template('information'); if (!$template) { $template = geodir_plugin_path() . '/geodirectory-templates/geodir-information.php'; } /** * Filter the information template path. * * @since 1.0.0 * @param string $template The template path. */ return $template = apply_filters('geodir_template_information', $template); } // check if pid exists in the record if yes then check if this post belongs to the user who is logged in. if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { global $information; $information = __('This listing does not belong to your account, please check the listing id carefully.', 'geodirectory'); $is_current_user_owner = geodir_listing_belong_to_current_user(); if (!$is_current_user_owner) { $template = geodir_locate_template('information'); if (!$template) { $template = geodir_plugin_path() . '/geodirectory-templates/geodir-information.php'; } /** * Filter the information template path. * * @since 1.0.0 * @param string $template The template path. */ return $template = apply_filters('geodir_template_information', $template); } } //geodir_is_login(true); global $current_user; if (!$current_user->ID) { wp_redirect(geodir_login_url(array('redirect_add_listing' => urlencode(geodir_curPageURL()))), 302); exit; } $template = geodir_locate_template('add-listing'); if (!$template) { $template = geodir_plugin_path() . '/geodirectory-templates/add-listing.php'; } /** * Filter the add listing template path. * * @since 1.0.0 * @param string $template The template path. */ return $template = apply_filters('geodir_template_add_listing', $template); } if (geodir_is_page('preview') || $geodir_custom_page_list['geodir_preview_page']) { global $preview; $preview = true; $template = geodir_locate_template('preview'); if (!$template) { $template = geodir_plugin_path() . '/geodirectory-templates/listing-detail.php'; } /** * Filter the preview template path. * * @since 1.0.0 * @param string $template The template path. */ return $template = apply_filters('geodir_template_preview', $template); } if (geodir_is_page('listing-success') || $geodir_custom_page_list['geodir_listing_success_page']) { $template = geodir_locate_template('success'); if (!$template) { $template = geodir_plugin_path() . '/geodirectory-templates/listing-success.php'; } /** * Filter the success template path. * * @since 1.0.0 * @param string $template The template path. */ return $template = apply_filters('geodir_template_success', $template); } if (geodir_is_page('detail') || $geodir_custom_page_list['geodir_listing_detail_page']) { $template = geodir_locate_template('detail'); if (!$template) { $template = geodir_plugin_path() . '/geodirectory-templates/listing-detail.php'; } /** * Filter the detail template path. * * @since 1.0.0 * @param string $template The template path. */ return $template = apply_filters('geodir_template_detail', $template); } if (geodir_is_page('listing') || $geodir_custom_page_list['geodir_listing_page']) { $template = geodir_locate_template('listing'); if (!$template) { $template = geodir_plugin_path() . '/geodirectory-templates/geodir-listing.php'; } /** * Filter the listing template path. * * @since 1.0.0 * @param string $template The template path. */ return $template = apply_filters('geodir_template_listing', $template); } if (geodir_is_page('search') || $geodir_custom_page_list['geodir_search_page']) { $template = geodir_locate_template('search'); if (!$template) { $template = geodir_plugin_path() . '/geodirectory-templates/geodir-search.php'; } /** * Filter the search template path. * * @since 1.0.0 * @param string $template The template path. */ return $template = apply_filters('geodir_template_search', $template); } if (geodir_is_page('author') || $geodir_custom_page_list['geodir_author_page']) { $template = geodir_locate_template('author'); if (!$template) { $template = geodir_plugin_path() . '/geodirectory-templates/geodir-author.php'; } /** * Filter the author template path. * * @since 1.0.0 * @param string $template The template path. */ return $template = apply_filters('geodir_template_author', $template); } if (get_option('geodir_set_as_home') || geodir_is_page('home') || geodir_is_page('location')) { global $post, $wp_query; if (geodir_is_page('home') || 'page' == get_option('show_on_front') && isset($post->ID) && $post->ID == get_option('page_on_front') || is_home() && !$wp_query->is_posts_page) { $template = geodir_locate_template('geodir-home'); if (!$template) { $template = geodir_plugin_path() . '/geodirectory-templates/geodir-home.php'; } /** * Filter the home page template path. * * @since 1.0.0 * @param string $template The template path. */ return $template = apply_filters('geodir_template_homepage', $template); } elseif (geodir_is_page('location')) { $template = geodir_locate_template('location'); if (!$template) { $template = geodir_plugin_path() . '/geodirectory-templates/geodir-location.php'; } /** * Filter the location template path. * * @since 1.0.0 * @param string $template The template path. */ return $template = apply_filters('geodir_template_location', $template); } else { return $template; } } return $template; }
/** * Get the geodirectory listings. * * @since 1.4.2 * * @global string $gridview_columns_widget The girdview style of the listings for widget. * @global bool $geodir_is_widget_listing Is this a widget listing?. Default: false. * @global bool $geodir_event_widget_listview Check that current listview is event. * @global object $post The current post object. * @global array $map_jason Map data in json format. * @global array $map_canvas_arr Map canvas array. * * @param array $args Array of arguements to filter listings. * @return string Listings HTML content. */ function geodir_sc_gd_listings_output($args = array()) { $title = !empty($args['title']) ? __($args['title'], 'geodirectory') : ''; $post_type = !empty($args['post_type']) ? $args['post_type'] : 'gd_place'; $category = !empty($args['category']) ? $args['category'] : '0'; $post_number = !empty($args['post_number']) ? $args['post_number'] : 10; $add_location_filter = !empty($args['add_location_filter']) ? true : false; $list_sort = !empty($args['list_sort']) ? $args['list_sort'] : 'latest'; $character_count = isset($args['character_count']) ? $args['character_count'] : ''; $layout = !empty($args['layout']) ? $args['layout'] : 'gridview_onehalf'; $with_pagination = !empty($args['with_pagination']) ? true : false; $event_type = !empty($args['event_type']) ? $args['event_type'] : ''; $top_pagination = $with_pagination && !empty($args['top_pagination']) ? true : false; $bottom_pagination = $with_pagination && !empty($args['bottom_pagination']) ? true : false; $shortcode_atts = !empty($args['shortcode_atts']) ? $args['shortcode_atts'] : array(); // ajax mode $geodir_ajax = !empty($args['geodir_ajax']) ? true : false; $pageno = $geodir_ajax && !empty($args['pageno']) ? $args['pageno'] : 1; $query_args = array('posts_per_page' => $post_number, 'is_geodir_loop' => true, 'gd_location' => $add_location_filter, 'post_type' => $post_type, 'order_by' => $list_sort, 'pageno' => $pageno); if ($character_count >= 0) { $query_args['excerpt_length'] = $character_count; } if (!empty($args['show_featured_only'])) { $query_args['show_featured_only'] = 1; } if (!empty($args['show_special_only'])) { $query_args['show_special_only'] = 1; } if (!empty($args['with_pics_only'])) { $query_args['with_pics_only'] = 0; $query_args['featured_image_only'] = 1; } if (!empty($args['with_videos_only'])) { $query_args['with_videos_only'] = 1; } $with_no_results = !empty($args['without_no_results']) ? false : true; if (!empty($category) && isset($category[0]) && $category[0] != '0') { $category_taxonomy = geodir_get_taxonomies($post_type); ######### WPML ######### if (function_exists('icl_object_id')) { $category = gd_lang_object_ids($category, $category_taxonomy[0]); } ######### WPML ######### $tax_query = array('taxonomy' => $category_taxonomy[0], 'field' => 'id', 'terms' => $category); $query_args['tax_query'] = array($tax_query); } global $gridview_columns_widget, $geodir_is_widget_listing; if ($post_type == 'gd_event' && function_exists('geodir_event_get_widget_events')) { global $geodir_event_widget_listview; $geodir_event_widget_listview = true; if ($event_type && in_array($event_type, array('past', 'today', 'upcoming'))) { $query_args['geodir_event_type'] = $event_type; } $total_posts = geodir_event_get_widget_events($query_args, true); $widget_listings = $total_posts > 0 ? geodir_event_get_widget_events($query_args) : array(); } else { $total_posts = geodir_get_widget_listings($query_args, true); $widget_listings = $total_posts > 0 ? geodir_get_widget_listings($query_args) : array(); } $current_gridview_columns_widget = $gridview_columns_widget; ob_start(); if (!empty($widget_listings) || $with_no_results) { if (!$geodir_ajax) { /** * Called before the shortcode [gd_listings] content is output. * * @since 1.0.0 */ do_action('geodir_before_sc_gd_listings'); ?> <div class="geodir_locations geodir_location_listing geodir-sc-gd-listings"> <?php } ?> <?php if ($title != '') { ?> <div class="geodir_list_heading clearfix"> <?php echo $title; ?> </div> <?php } ?> <?php if (strstr($layout, 'gridview')) { $listing_view_exp = explode('_', $layout); $gridview_columns_widget = $layout; $layout = $listing_view_exp[0]; } else { $gridview_columns_widget = ''; } /** * Filter the widget listing listview template. * * @since 1.0.0 * * @param string The template file to display listing. */ $template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview')); global $post, $map_jason, $map_canvas_arr; $current_post = $post; $current_map_jason = $map_jason; $current_map_canvas_arr = $map_canvas_arr; $geodir_is_widget_listing = true; if (isset($_SESSION['gd_listing_view'])) { unset($_SESSION['gd_listing_view']); } if ($with_pagination && $top_pagination) { echo geodir_sc_listings_pagination($total_posts, $post_number, $pageno); } /** * Includes listing listview template. * * @since 1.0.0 */ include $template; if ($with_pagination && $bottom_pagination) { echo geodir_sc_listings_pagination($total_posts, $post_number, $pageno); } $geodir_is_widget_listing = false; $GLOBALS['post'] = $current_post; if (!empty($current_post)) { setup_postdata($current_post); } $map_jason = $current_map_jason; $map_canvas_arr = $current_map_canvas_arr; global $gridview_columns_widget; $gridview_columns_widget = $current_gridview_columns_widget; ?> <p class="geodir-sclisting-loading" style="display:none;"><i class="fa fa-cog fa-spin"></i></p> <?php if (!$geodir_ajax) { ?> </div> <script type="text/javascript"> function gd_sc_gopage(obj, pid) { var pid = parseInt(pid); var container = jQuery(obj).closest('.geodir-sc-gd-listings'); if(!pid > 0 || !(container && typeof container != 'undefined')) { return false; } var scatts = "<?php echo addslashes(json_encode($shortcode_atts)); ?> "; var data = { 'action': 'geodir_sclistings', 'geodir_sclistings_nonce': '<?php echo wp_create_nonce("geodir-sclistings-nonce"); ?> ', 'scatts': scatts, 'geodir_ajax': true, 'pageno': pid }; jQuery(document).ajaxStop(function() { jQuery(container).find('.geodir_category_list_view').css({'opacity': '1'}); jQuery(container).find('.geodir-sclisting-loading').hide(); }); jQuery(container).find('.geodir_category_list_view').css({'opacity': '0.4'}); jQuery(container).find('.geodir-sclisting-loading').show(); jQuery.post(geodir_var.geodir_ajax_url, data, function(response) { if(response && response != '0') { jQuery(container).html(response); } }); } </script> <?php } ?> <?php } $output = ob_get_contents(); ob_end_clean(); return trim($output); }
function geodir_claim_template_loader($template) { global $wp_query, $current_user, $plugin_prefix, $wpdb; if (isset($_REQUEST['geodir_ptype'])) { global $information; if ($current_user->ID) { if (get_option('geodir_claim_auto_approve') == 'yes') { if (!isset($_REQUEST['rs']) || isset($_REQUEST['rs']) && $_REQUEST['rs'] == '') { $information .= CLAIM_VARIFY_CODE_NOT_EXIST; } else { $rand_string = isset($_REQUEST['rs']) ? $_REQUEST['rs'] : ''; $approvesql = $wpdb->prepare("select * from " . GEODIR_CLAIM_TABLE . " where rand_string=%s", array($rand_string)); $approveinfo = $wpdb->get_results($approvesql); if ($approveinfo) { $pid = $approveinfo[0]->pid; $post_id = $approveinfo[0]->list_id; $author_id = $approveinfo[0]->user_id; $user_id = $current_user->ID; $status = $approveinfo[0]->status; if ($author_id == $user_id) { if ($status == 1) { $information .= CLAIM_LISTING_ALREADY_VARIFIED; } elseif ($status == 2) { $information .= CLAIM_LISTING_VERIFICATION_REJECTED; } else { $wpdb->query($wpdb->prepare("update {$wpdb->posts} set post_author=%d where ID=%d", array($author_id, $post_id))); $wpdb->query($wpdb->prepare("update " . GEODIR_CLAIM_TABLE . " set status='1' where pid=%d", array($pid))); geodir_save_post_meta($post_id, 'claimed', '1'); geodir_clientEmail($post_id, $author_id, 'claim_approved'); /* email to client */ $information .= CLAIM_LISTING_SUCCESS_VERIFIED . ' <a href="' . get_option('siteurl') . '/?p=' . $post_id . '">' . $approveinfo[0]->list_title . '</a>'; } } else { $information .= CLAIM_VARIFY_CODE_NOT_MATCH; } } else { $information .= CLAIM_VARIFY_CODE_NOT_EXIST; } } } else { $information .= CLAIM_AUTO_VARIFY_DISABLE; } } else { $site_login_url = get_option('siteurl') . '?geodir_signup=true'; $information .= sprintf(CLAIM_LOGIN_REQUIRED, '<a href="' . $site_login_url . '" >'); } $template = geodir_locate_template('information'); if (!$template) { $template = geodir_plugin_path() . '/geodirectory-templates/geodir-information.php'; } $template = apply_filters('geodir_template_information', $template); } return $template; }
/** * Display the best of widget listings using the given query args. * * @since 1.3.9 * * @global object $post The current post object. * @global array $map_jason Map data in json format. * @global array $map_canvas_arr Map canvas array. * @global string $gridview_columns_widget The girdview style of the listings for widget. * * @param array $query_args The query array. */ function geodir_bestof_places_by_term($query_args) { /** * This action called before querying widget listings. * * @since 1.0.0 */ do_action('geodir_bestof_get_widget_listings_before'); $widget_listings = geodir_get_widget_listings($query_args); /** * This action called after querying widget listings. * * @since 1.0.0 */ do_action('geodir_bestof_get_widget_listings_after'); $character_count = isset($query_args['excerpt_length']) ? $query_args['excerpt_length'] : ''; if (!isset($character_count)) { /** This filter is documented in geodirectory-widgets/geodirectory_bestof_widget.php */ $character_count = $character_count == '' ? 50 : apply_filters('bestof_widget_character_count', $character_count); } /** This filter is documented in geodirectory-functions/general_functions.php */ $template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview')); global $post, $map_jason, $map_canvas_arr, $gridview_columns_widget; $current_post = $post; $current_map_jason = $map_jason; $current_map_canvas_arr = $map_canvas_arr; $current_grid_view = $gridview_columns_widget; $gridview_columns_widget = null; $gd_listing_view_set = isset($_SESSION['gd_listing_view']) ? true : false; $gd_listing_view_old = $gd_listing_view_set ? $_SESSION['gd_listing_view'] : ''; $_SESSION['gd_listing_view'] = '1'; $geodir_is_widget_listing = true; /** * Includes the template for the listing listview. * * @since 1.3.9 */ include $template; $geodir_is_widget_listing = false; $GLOBALS['post'] = $current_post; if (!empty($current_post)) { setup_postdata($current_post); } if ($gd_listing_view_set) { // Set back previous value $_SESSION['gd_listing_view'] = $gd_listing_view_old; } else { unset($_SESSION['gd_listing_view']); } $map_jason = $current_map_jason; $map_canvas_arr = $current_map_canvas_arr; $gridview_columns_widget = $current_grid_view; }