/** * Front-end display content for home page map widget. * * @since 1.0.0 * @since 1.5.1 Declare function public. * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget($args, $instance) { extract($args, EXTR_SKIP); /** This action is documented in geodirectory_shortcodes.php */ $width = empty($instance['width']) ? '960' : apply_filters('widget_width', $instance['width']); /** This action is documented in geodirectory_shortcodes.php */ $height = empty($instance['heigh']) ? '425' : apply_filters('widget_heigh', $instance['heigh']); /** This action is documented in geodirectory_shortcodes.php */ $maptype = empty($instance['maptype']) ? 'ROADMAP' : apply_filters('widget_maptype', $instance['maptype']); /** This action is documented in geodirectory_shortcodes.php */ $zoom = empty($instance['zoom']) ? '13' : apply_filters('widget_zoom', $instance['zoom']); /** This action is documented in geodirectory_shortcodes.php */ $autozoom = empty($instance['autozoom']) ? '' : apply_filters('widget_autozoom', $instance['autozoom']); /** This action is documented in geodirectory_shortcodes.php */ $child_collapse = empty($instance['child_collapse']) ? '0' : apply_filters('widget_child_collapse', $instance['child_collapse']); /** This action is documented in geodirectory_shortcodes.php */ $scrollwheel = empty($instance['scrollwheel']) ? '0' : apply_filters('widget_scrollwheel', $instance['scrollwheel']); //$str = createRandomString(); $map_args = array(); $map_args['map_canvas_name'] = str_replace('-', '_', $args['widget_id']); //'home_map_canvas'.$str ; $map_args['width'] = $width; $map_args['height'] = $height; $map_args['maptype'] = $maptype; $map_args['scrollwheel'] = $scrollwheel; $map_args['zoom'] = $zoom; $map_args['autozoom'] = $autozoom; $map_args['child_collapse'] = $child_collapse; $map_args['enable_cat_filters'] = true; $map_args['enable_text_search'] = true; $map_args['enable_post_type_filters'] = true; /** This action is documented in geodirectory_shortcodes.php */ $map_args['enable_location_filters'] = apply_filters('geodir_home_map_enable_location_filters', false); $map_args['enable_jason_on_load'] = false; $map_args['enable_marker_cluster'] = false; $map_args['enable_map_resize_button'] = true; $map_args['map_class_name'] = 'geodir-map-home-page'; $is_geodir_home_map_widget = true; $map_args['is_geodir_home_map_widget'] = $is_geodir_home_map_widget; geodir_draw_map($map_args); /* home map post type slider */ if ($is_geodir_home_map_widget) { add_action('wp_footer', array($this, 'geodir_home_map_add_script'), 100); } }
/** * The main function responsible for displaying tabs in frontend detail page. * * @since 1.0.0 * @package GeoDirectory * @global object $post The current post object. * @global array $post_images List of images attached to the post. * @global string $video The video embed content. * @global string $special_offers Special offers content. * @global string $related_listing Related listing html. * @global string $geodir_post_detail_fields Detail field html. */ function geodir_show_detail_page_tabs() { global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields; $post_id = !empty($post) && isset($post->ID) ? (int) $post->ID : 0; $request_post_id = !empty($_REQUEST['p']) ? (int) $_REQUEST['p'] : 0; $is_backend_preview = is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p']) && is_super_admin() ? true : false; // skip if preview from backend if ($is_backend_preview && !$post_id > 0 && $request_post_id > 0) { $post = geodir_get_post_info($request_post_id); setup_postdata($post); } $geodir_post_detail_fields = geodir_show_listing_info('detail'); if (geodir_is_page('detail')) { $video = geodir_get_video($post->ID); $special_offers = geodir_get_special_offers($post->ID); $related_listing_array = array(); if (get_option('geodir_add_related_listing_posttypes')) { $related_listing_array = get_option('geodir_add_related_listing_posttypes'); } $related_listing = ''; if (in_array($post->post_type, $related_listing_array)) { $request = array('post_number' => get_option('geodir_related_post_count'), 'relate_to' => get_option('geodir_related_post_relate_to'), 'layout' => get_option('geodir_related_post_listing_view'), 'add_location_filter' => get_option('geodir_related_post_location_filter'), 'list_sort' => get_option('geodir_related_post_sortby'), 'character_count' => get_option('geodir_related_post_excerpt')); $related_listing = geodir_related_posts_display($request); } $post_images = geodir_get_images($post->ID, 'thumbnail'); $thumb_image = ''; if (!empty($post_images)) { foreach ($post_images as $image) { $caption = !empty($image->caption) ? $image->caption : ''; $thumb_image .= '<a href="' . $image->src . '" title="' . $caption . '">'; $thumb_image .= geodir_show_image($image, 'thumbnail', true, false); $thumb_image .= '</a>'; } } $map_args = array(); $map_args['map_canvas_name'] = 'detail_page_map_canvas'; $map_args['width'] = '600'; $map_args['height'] = '300'; if ($post->post_mapzoom) { $map_args['zoom'] = '' . $post->post_mapzoom . ''; } $map_args['autozoom'] = false; $map_args['child_collapse'] = '0'; $map_args['enable_cat_filters'] = false; $map_args['enable_text_search'] = false; $map_args['enable_post_type_filters'] = false; $map_args['enable_location_filters'] = false; $map_args['enable_jason_on_load'] = true; $map_args['enable_map_direction'] = true; $map_args['map_class_name'] = 'geodir-map-detail-page'; $map_args['maptype'] = !empty($post->post_mapview) ? $post->post_mapview : 'ROADMAP'; } elseif (geodir_is_page('preview')) { $video = isset($post->geodir_video) ? $post->geodir_video : ''; $special_offers = isset($post->geodir_special_offers) ? $post->geodir_special_offers : ''; if (isset($post->post_images)) { $post->post_images = trim($post->post_images, ","); } if (isset($post->post_images) && !empty($post->post_images)) { $post_images = explode(",", $post->post_images); } $thumb_image = ''; if (!empty($post_images)) { foreach ($post_images as $image) { if ($image != '') { $thumb_image .= '<a href="' . $image . '">'; $thumb_image .= geodir_show_image(array('src' => $image), 'thumbnail', true, false); $thumb_image .= '</a>'; } } } global $map_jason; $map_jason[] = $post->marker_json; $address_latitude = isset($post->post_latitude) ? $post->post_latitude : ''; $address_longitude = isset($post->post_longitude) ? $post->post_longitude : ''; $mapview = isset($post->post_mapview) ? $post->post_mapview : ''; $mapzoom = isset($post->post_mapzoom) ? $post->post_mapzoom : ''; if (!$mapzoom) { $mapzoom = 12; } $map_args = array(); $map_args['map_canvas_name'] = 'preview_map_canvas'; $map_args['width'] = '950'; $map_args['height'] = '300'; $map_args['child_collapse'] = '0'; $map_args['maptype'] = $mapview; $map_args['autozoom'] = false; $map_args['zoom'] = "{$mapzoom}"; $map_args['latitude'] = $address_latitude; $map_args['longitude'] = $address_longitude; $map_args['enable_cat_filters'] = false; $map_args['enable_text_search'] = false; $map_args['enable_post_type_filters'] = false; $map_args['enable_location_filters'] = false; $map_args['enable_jason_on_load'] = true; $map_args['enable_map_direction'] = true; $map_args['map_class_name'] = 'geodir-map-preview-page'; } $arr_detail_page_tabs = geodir_detail_page_tabs_list(); // get this sooner so we can get the active tab for the user $active_tab_name = ''; foreach ($arr_detail_page_tabs as $tabs) { if (isset($tabs['is_active_tab']) && $tabs['is_active_tab'] && isset($tabs['heading_text']) && $tabs['heading_text']) { $active_tab_name = __($tabs['heading_text'], 'geodirectory'); } } ?> <div class="geodir-tabs" id="gd-tabs" style="position:relative;"> <div id="geodir-tab-mobile-menu" > <i class="fa fa-bars"></i> <span class="geodir-mobile-active-tab"><?php echo $active_tab_name; ?> </span> <i class="fa fa-sort-desc"></i> </div> <dl class="geodir-tab-head"> <?php /** * Called before the details page tab list headings, inside the `dl` tag. * * @since 1.0.0 * @see 'geodir_after_tab_list' */ do_action('geodir_before_tab_list'); ?> <?php foreach ($arr_detail_page_tabs as $tab_index => $detail_page_tab) { if ($detail_page_tab['is_display']) { ?> <dt></dt> <!-- added to comply with validation --> <dd <?php if ($detail_page_tab['is_active_tab']) { ?> class="geodir-tab-active"<?php } ?> > <a data-tab="#<?php echo $tab_index; ?> " data-status="enable"><?php _e($detail_page_tab['heading_text'], 'geodirectory'); ?> </a> </dd> <?php ob_start(); ?> <li id="<?php echo $tab_index; ?> Tab" <?php if ($tab_index == 'post_profile') { //echo 'itemprop="description"'; } ?> > <div id="<?php echo $tab_index; ?> " class="hash-offset"></div> <?php /** * Called before the details tab content is output per tab. * * @since 1.0.0 * @param string $tab_index The tab name ID. */ do_action('geodir_before_tab_content', $tab_index); /** * Called before the details tab content is output per tab. * * Uses dynamic hook name: geodir_before_$tab_index_tab_content * * @since 1.0.0 * @todo do we need this if we have the hook above? 'geodir_before_tab_content' */ do_action('geodir_before_' . $tab_index . '_tab_content'); /// write a code to generate content of each tab switch ($tab_index) { case 'post_profile': /** * Called before the listing description content on the details page tab. * * @since 1.0.0 */ do_action('geodir_before_description_on_listing_detail'); if (geodir_is_page('detail')) { the_content(); } else { /** This action is documented in geodirectory_template_actions.php */ echo apply_filters('the_content', stripslashes($post->post_desc)); } /** * Called after the listing description content on the details page tab. * * @since 1.0.0 */ do_action('geodir_after_description_on_listing_detail'); break; case 'post_info': echo $geodir_post_detail_fields; break; case 'post_images': echo $thumb_image; break; case 'post_video': /** This action is documented in geodirectory_template_actions.php */ echo apply_filters('the_content', stripslashes($video)); // we apply the_content filter so oembed works also; break; case 'special_offers': echo wpautop(stripslashes($special_offers)); break; case 'post_map': geodir_draw_map($map_args); break; case 'reviews': comments_template(); break; case 'related_listing': echo $related_listing; break; default: if ((isset($post->{$tab_index}) || !isset($post->{$tab_index}) && (strpos($tab_index, 'gd_tab_') !== false || $tab_index == 'link_business')) && !empty($detail_page_tab['tab_content'])) { echo $detail_page_tab['tab_content']; } break; } /** * Called after the details tab content is output per tab. * * @since 1.0.0 */ do_action('geodir_after_tab_content', $tab_index); /** * Called after the details tab content is output per tab. * * Uses dynamic hook name: geodir_after_$tab_index_tab_content * * @since 1.0.0 * @todo do we need this if we have the hook above? 'geodir_after_tab_content' */ do_action('geodir_after_' . $tab_index . '_tab_content'); ?> </li> <?php /** * Filter the current tab content. * * @since 1.0.0 */ $arr_detail_page_tabs[$tab_index]['tab_content'] = apply_filters("geodir_modify_" . $detail_page_tab['tab_content'] . "_tab_content", ob_get_clean()); } // end of if for is_display } // end of foreach /** * Called after the details page tab list headings, inside the `dl` tag. * * @since 1.0.0 * @see 'geodir_before_tab_list' */ do_action('geodir_after_tab_list'); ?> </dl> <ul class="geodir-tabs-content entry-content" style="position:relative;"> <?php foreach ($arr_detail_page_tabs as $detail_page_tab) { if ($detail_page_tab['is_display'] && !empty($detail_page_tab['tab_content'])) { echo $detail_page_tab['tab_content']; } // end of if } // end of foreach /** * Called after all the tab content is output in `li` tags, called before the closing `ul` tag. * * @since 1.0.0 */ do_action('geodir_add_tab_content'); ?> </ul> <!--gd-tabs-content ul end--> </div> <script> if (window.location.hash && window.location.hash.indexOf('&') === -1 && jQuery(window.location.hash + 'Tab').length) { hashVal = window.location.hash; } else { hashVal = jQuery('dl.geodir-tab-head dd.geodir-tab-active').find('a').attr('data-tab'); } jQuery('dl.geodir-tab-head dd').each(function () { //Get all tabs var tabs = jQuery(this).children('dd'); var tab = ''; tab = jQuery(this).find('a').attr('data-tab'); if (hashVal != tab) { jQuery(tab + 'Tab').hide(); } }); </script> <?php }
/** * The geodirectory listing map shortcode. * * This implements the functionality of the shortcode for displaying listing map. * * @since 1.0.0 * @since 1.5.2 Added TERRAIN for $maptype attribute. * @package GeoDirectory * @global object $post The current post object. * @param array $atts { * Attributes of the shortcode. * * @type string $width Map width in pixels. Default 294. * @type string $height Map height in pixels. Default 370. * @type string $maptype Map type. Default ROADMAP. Can be ROADMAP | SATELLITE | HYBRID | TERRAIN. * @type string $zoom The zoom level of the map. Between 1-19. Default 13. * @type string $autozoom True if the map should autozoom, false if not. * @type bool $sticky True if should be sticky, false if not * @type string $showall Show all listings on map? (not just page list). Default 0. * @type string $child_collapse True if the map should collapse the categories, false if not. * @type string $scrollwheel True to allow scroll wheel to scroll map or false if not. * @type bool $marker_cluster Enable marker cluster? Default: false. * * } * @return string Map HTML. */ function geodir_sc_listing_map($atts) { ob_start(); add_action('wp_head', 'init_listing_map_script'); // Initialize the map object and marker array add_action('the_post', 'create_list_jsondata'); // Add marker in json array add_action('wp_footer', 'show_listing_widget_map'); // Show map for listings with markers $defaults = array('width' => '294', 'height' => '370', 'zoom' => '13', 'autozoom' => '', 'sticky' => '', 'showall' => '0', 'scrollwheel' => '0', 'maptype' => 'ROADMAP', 'child_collapse' => 0, 'marker_cluster' => false); $params = shortcode_atts($defaults, $atts); $params = gdsc_validate_map_args($params); $map_args = array('map_canvas_name' => 'gd_listing_map', 'width' => $params['width'], 'height' => $params['height'], 'zoom' => $params['zoom'], 'autozoom' => $params['autozoom'], 'sticky' => $params['sticky'], 'showall' => $params['showall'], 'scrollwheel' => $params['scrollwheel'], 'child_collapse' => 0, 'enable_cat_filters' => false, 'enable_text_search' => false, 'enable_post_type_filters' => false, 'enable_location_filters' => false, 'enable_jason_on_load' => true); if (is_single()) { global $post; $map_default_lat = $address_latitude = $post->post_latitude; $map_default_lng = $address_longitude = $post->post_longitude; $mapview = $post->post_mapview; $map_args['zoom'] = $post->post_mapzoom; $map_args['map_class_name'] = 'geodir-map-listing-page-single'; } else { $default_location = geodir_get_default_location(); $map_default_lat = isset($default_location->city_latitude) ? $default_location->city_latitude : ''; $map_default_lng = isset($default_location->city_longitude) ? $default_location->city_longitude : ''; $map_args['map_class_name'] = 'geodir-map-listing-page'; } if (empty($mapview)) { $mapview = 'ROADMAP'; } // Set default map options $map_args['ajax_url'] = geodir_get_ajax_url(); $map_args['latitude'] = $map_default_lat; $map_args['longitude'] = $map_default_lng; $map_args['streetViewControl'] = true; $map_args['maptype'] = $mapview; $map_args['showPreview'] = '0'; $map_args['maxZoom'] = 21; $map_args['bubble_size'] = 'small'; // Add marker cluster if (isset($params['marker_cluster']) && gdsc_to_bool_val($params['marker_cluster']) && defined('GDCLUSTER_VERSION')) { $map_args['enable_marker_cluster'] = true; } else { $map_args['enable_marker_cluster'] = false; } geodir_draw_map($map_args); $output = ob_get_contents(); ob_end_clean(); return $output; }
/** * Front-end display content for listing page map widget. * * @since 1.0.0 * @since 1.5.1 Declare function public. * * @global object $post The current post object. * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget($args, $instance) { if (geodir_is_page('listing') || geodir_is_page('author') || geodir_is_page('search') || geodir_is_page('detail')) { extract($args, EXTR_SKIP); /** This action is documented in geodirectory_shortcodes.php */ $width = empty($instance['width']) ? '294' : apply_filters('widget_width', $instance['width']); /** This action is documented in geodirectory_shortcodes.php */ $height = empty($instance['heigh']) ? '370' : apply_filters('widget_heigh', $instance['heigh']); /** This action is documented in geodirectory_shortcodes.php */ $maptype = empty($instance['maptype']) ? 'ROADMAP' : apply_filters('widget_maptype', $instance['maptype']); /** This action is documented in geodirectory_shortcodes.php */ $zoom = empty($instance['zoom']) ? '13' : apply_filters('widget_zoom', $instance['zoom']); /** This action is documented in geodirectory_shortcodes.php */ $autozoom = empty($instance['autozoom']) ? '' : apply_filters('widget_autozoom', $instance['autozoom']); /** * Filter the listing map value widget_sticky, to set if the map should be sticky or not (scroll with page). * * @since 1.0.0 * @param bool $sticky True if should be sticky, false if not */ $sticky = empty($instance['sticky']) ? '' : apply_filters('widget_sticky', $instance['sticky']); /** This action is documented in geodirectory_shortcodes.php */ $scrollwheel = empty($instance['scrollwheel']) ? '0' : apply_filters('widget_scrollwheel', $instance['scrollwheel']); $showall = empty($instance['showall']) ? '0' : apply_filters('widget_showall', $instance['showall']); /** * Filter the listing map should to be displayed or not. * * @since 1.4.6 * * @param bool $display true if map should be displayed, false if not. */ $show_map = apply_filters('geodir_show_map_listing', $display = true); if (!$show_map) { return; } $map_args = array(); $map_args['map_canvas_name'] = str_replace('-', '_', $args['widget_id']); $map_args['width'] = $width; $map_args['height'] = $height; $map_args['scrollwheel'] = $scrollwheel; $map_args['showall'] = $showall; $map_args['child_collapse'] = '0'; $map_args['sticky'] = $sticky; $map_args['enable_cat_filters'] = false; $map_args['enable_text_search'] = false; $map_args['enable_post_type_filters'] = false; $map_args['enable_location_filters'] = false; $map_args['enable_jason_on_load'] = true; if (is_single()) { global $post; $map_default_lat = $address_latitude = $post->post_latitude; $map_default_lng = $address_longitude = $post->post_longitude; $mapview = $post->post_mapview; $mapzoom = $post->post_mapzoom; $map_args['map_class_name'] = 'geodir-map-listing-page-single'; } else { $default_location = geodir_get_default_location(); $map_default_lat = isset($default_location->city_latitude) ? $default_location->city_latitude : ''; $map_default_lng = isset($default_location->city_longitude) ? $default_location->city_longitude : ''; $map_args['map_class_name'] = 'geodir-map-listing-page'; $mapview = $maptype; } if (empty($mapview)) { $mapview = 'ROADMAP'; } if (empty($mapzoom)) { $mapzoom = $zoom; } // Set default map options $map_args['ajax_url'] = geodir_get_ajax_url(); $map_args['latitude'] = $map_default_lat; $map_args['longitude'] = $map_default_lng; $map_args['zoom'] = $zoom; //$map_args['scrollwheel'] = true; $map_args['scrollwheel'] = $scrollwheel; $map_args['showall'] = $showall; $map_args['streetViewControl'] = true; $map_args['maptype'] = $mapview; $map_args['showPreview'] = '0'; $map_args['maxZoom'] = 21; $map_args['autozoom'] = $autozoom; $map_args['bubble_size'] = 'small'; echo $before_widget; geodir_draw_map($map_args); echo $after_widget; } }