コード例 #1
0
/**
 * 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 
}
コード例 #2
0
/**
 * This outputs the info section of the details page.
 *
 * This outputs the info section fo the details page which includes all the post custom fields.
 * @since 1.0.0
 * @package GeoDirectory
 */
function geodir_detail_page_more_info()
{
    ob_start();
    // Start  buffering;
    /**
     * This is called before the info section html.
     *
     * @since 1.0.0
     */
    do_action('geodir_before_detail_page_more_info');
    if ($geodir_post_detail_fields = geodir_show_listing_info()) {
        echo $geodir_post_detail_fields;
    }
    /**
     * This is called after the info section html.
     *
     * @since 1.0.0
     */
    do_action('geodir_after_detail_page_more_info');
    $content_html = ob_get_clean();
    if (trim($content_html) != '') {
        $content_html = '<div class="geodir-company_info geodir-details-sidebar-listing-info">' . $content_html . '</div>';
    }
    if ((int) get_option('geodir_disable_listing_info_section') != 1) {
        /**
         * Filter the output html for function geodir_detail_page_more_info().
         *
         * @since 1.0.0
         * @param string $content_html The output html of the geodir_detail_page_more_info() function.
         */
        echo $content_html = apply_filters('geodir_detail_page_more_info_html', $content_html);
    }
}
コード例 #3
0
                }
                echo round($distance, 2) . ' ' . __($uom, 'geodirectory') . '
			<br />
			';
            }
            ?>
                                </h3>
                            <?php 
        }
        ?>
                            <?php 
        /** This action is documented in geodirectory-templates/listing-listview.php */
        do_action('geodir_before_listing_post_excerpt', $post);
        ?>
                            <?php 
        echo geodir_show_listing_info('listing');
        ?>
                            <?php 
        if (isset($character_count) && $character_count == '0') {
        } else {
            ?>
                                <div class="geodir-entry-content">
                                    <?php 
            if (isset($character_count) && ($character_count || $character_count == '0')) {
                $content_out = geodir_max_excerpt($character_count);
            } else {
                $content_out = get_the_excerpt();
            }
            if (!empty($content_out)) {
                echo "<p>" . $content_out . "</p>";
            }