/**
 * 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 
}
/**
 * Outputs the add listing form HTML content.
 *
 * Other things are needed to output a working add listing form, you should use the add listing shortcode if needed.
 *
 * @since 1.0.0
 * @package GeoDirectory
 * @global object $current_user Current user object.
 * @global object $post The current post object.
 * @global object $post_images Image objects of current post if available.
 */
function geodir_action_add_listing_form()
{
    global $cat_display, $post_cat, $current_user;
    $page_id = get_the_ID();
    $post = '';
    $title = '';
    $desc = '';
    $kw_tags = '';
    $required_msg = '';
    $submit_button = '';
    if (isset($_REQUEST['ajax_action'])) {
        $ajax_action = $_REQUEST['ajax_action'];
    } else {
        $ajax_action = 'add';
    }
    $thumb_img_arr = array();
    $curImages = '';
    if (isset($_REQUEST['backandedit'])) {
        global $post;
        $post = (object) unserialize($_SESSION['listing']);
        $listing_type = $post->listing_type;
        $title = $post->post_title;
        $desc = $post->post_desc;
        /*if(is_array($post->post_category) && !empty($post->post_category))
        			$post_cat = $post->post_category;
        		else*/
        $post_cat = $post->post_category;
        $kw_tags = $post->post_tags;
        $curImages = isset($post->post_images) ? $post->post_images : '';
    } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
        global $post, $post_images;
        /*query_posts(array('p'=>$_REQUEST['pid']));
        		if ( have_posts() ) while ( have_posts() ) the_post(); global $post,$post_images;*/
        $post = geodir_get_post_info($_REQUEST['pid']);
        $thumb_img_arr = geodir_get_images($post->ID);
        if ($thumb_img_arr) {
            foreach ($thumb_img_arr as $post_img) {
                $curImages .= $post_img->src . ',';
            }
        }
        $listing_type = $post->post_type;
        $title = $post->post_title;
        $desc = $post->post_content;
        //$post_cat = $post->categories;
        $kw_tags = $post->post_tags;
        $kw_tags = implode(",", wp_get_object_terms($post->ID, $listing_type . '_tags', array('fields' => 'names')));
    } else {
        $listing_type = $_REQUEST['listing_type'];
    }
    if ($current_user->ID != '0') {
        $user_login = true;
    }
    ?>
    <form name="propertyform" id="propertyform" action="<?php 
    echo get_page_link(geodir_preview_page_id());
    ?>
"
          method="post" enctype="multipart/form-data">
        <input type="hidden" name="preview" value="<?php 
    echo $listing_type;
    ?>
"/>
        <input type="hidden" name="listing_type" value="<?php 
    echo $listing_type;
    ?>
"/>
        <?php 
    if ($page_id) {
        ?>
<input type="hidden" name="add_listing_page_id"
                                       value="<?php 
        echo $page_id;
        ?>
" /><?php 
    }
    ?>
        <?php 
    if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
        ?>
            <input type="hidden" name="pid" value="<?php 
        echo $_REQUEST['pid'];
        ?>
"/>
        <?php 
    }
    ?>
        <?php 
    if (isset($_REQUEST['backandedit'])) {
        ?>
            <input type="hidden" name="backandedit" value="<?php 
        echo $_REQUEST['backandedit'];
        ?>
"/>
        <?php 
    }
    ?>
        <?php 
    /**
     * Called at the very top of the add listing page form for frontend.
     *
     * This is called just before the "Enter Listing Details" text.
     *
     * @since 1.0.0
     */
    do_action('geodir_before_detail_fields');
    ?>

        <h5><?php 
    echo LISTING_DETAILS_TEXT;
    ?>
</h5>

        <?php 
    /**
     * Called at the top of the add listing page form for frontend.
     *
     * This is called after the "Enter Listing Details" text.
     *
     * @since 1.0.0
     */
    do_action('geodir_before_main_form_fields');
    ?>

        <div id="geodir_post_title_row" class="required_field geodir_form_row clearfix">
            <label><?php 
    echo PLACE_TITLE_TEXT;
    ?>
<span>*</span> </label>
            <input type="text" field_type="text" name="post_title" id="post_title" class="geodir_textfield"
                   value="<?php 
    echo esc_attr(stripslashes($title));
    ?>
"/>
            <span class="geodir_message_error"><?php 
    _e($required_msg, GEODIRECTORY_TEXTDOMAIN);
    ?>
</span>
        </div>

        <?php 
    $show_editor = get_option('geodir_tiny_editor_on_add_listing');
    $desc = $show_editor ? stripslashes($desc) : esc_attr(stripslashes($desc));
    $desc_limit = '';
    /**
     * Filter the add listing description field character limit number.
     *
     * @since 1.0.0
     * @param int $desc_limit The amount of characters to limit the description to.
     */
    $desc_limit = apply_filters('geodir_description_field_desc_limit', $desc_limit);
    /**
     * Filter the add listing description field text.
     *
     * @since 1.0.0
     * @param string $desc The text for the description field.
     * @param int $desc_limit The character limit numer if any.
     */
    $desc = apply_filters('geodir_description_field_desc', $desc, $desc_limit);
    $desc_limit_msg = '';
    /**
     * Filter the add listing description limit message.
     *
     * This is the message shown if there is a limit applied to the amount of characters the description can use.
     *
     * @since 1.0.0
     * @param string $desc_limit_msg The limit message string if any.
     * @param int $desc_limit The character limit numer if any.
     */
    $desc_limit_msg = apply_filters('geodir_description_field_desc_limit_msg', $desc_limit_msg, $desc_limit);
    ?>
        <?php 
    /**
     * Called on the add listing page form for frontend just before the description field.
     *
     * @since 1.0.0
     */
    do_action('geodir_before_description_field');
    ?>
        <div id="geodir_post_desc_row" class="<?php 
    if ($desc_limit != '0') {
        echo 'required_field';
    }
    ?>
 geodir_form_row clearfix">
            <label><?php 
    echo PLACE_DESC_TEXT;
    ?>
<span><?php 
    if ($desc_limit != '0') {
        echo '*';
    }
    ?>
</span> </label>
            <?php 
    if (!empty($show_editor) && in_array($listing_type, $show_editor)) {
        $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
        ?>

                <div class="editor" field_id="post_desc" field_type="editor">
                    <?php 
        wp_editor($desc, "post_desc", $editor_settings);
        ?>
                </div>
            <?php 
        if ($desc_limit != '') {
            ?>
                <script
                    type="text/javascript">jQuery('textarea#post_desc').attr('maxlength', "<?php 
            echo $desc_limit;
            ?>
");</script>
            <?php 
        }
        ?>
            <?php 
    } else {
        ?>
                <textarea field_type="textarea" name="post_desc" id="post_desc" class="geodir_textarea"
                          maxlength="<?php 
        echo $desc_limit;
        ?>
"><?php 
        echo $desc;
        ?>
</textarea>
            <?php 
    }
    ?>
            <?php 
    if ($desc_limit_msg != '') {
        ?>
                <span class="geodir_message_note"><?php 
        echo $desc_limit_msg;
        ?>
</span>
            <?php 
    }
    ?>
            <span class="geodir_message_error"><?php 
    echo _e($required_msg, GEODIRECTORY_TEXTDOMAIN);
    ?>
</span>
        </div>
        <?php 
    /**
     * Called on the add listing page form for frontend just after the description field.
     *
     * @since 1.0.0
     */
    do_action('geodir_after_description_field');
    ?>
        <?php 
    $kw_tags = esc_attr(stripslashes($kw_tags));
    $kw_tags_count = TAGKW_TEXT_COUNT;
    $kw_tags_msg = TAGKW_MSG;
    /**
     * Filter the add listing tags character limit.
     *
     * @since 1.0.0
     * @param int $kw_tags_count The character count limit if any.
     */
    $kw_tags_count = apply_filters('geodir_listing_tags_field_tags_count', $kw_tags_count);
    /**
     * Filter the add listing tags field value.
     *
     * You can use the $_REQUEST values to check if this is a go back and edit value etc.
     *
     * @since 1.0.0
     * @param string $kw_tags The tag field value, usually a comma separated list of tags.
     * @param int $kw_tags_count The character count limit if any.
     */
    $kw_tags = apply_filters('geodir_listing_tags_field_tags', $kw_tags, $kw_tags_count);
    /**
     * Filter the add listing tags field message text.
     *
     * @since 1.0.0
     * @param string $kw_tags_msg The message shown under the field.
     * @param int $kw_tags_count The character count limit if any.
     */
    $kw_tags_msg = apply_filters('geodir_listing_tags_field_tags_msg', $kw_tags_msg, $kw_tags_count);
    ?>
        <?php 
    /**
     * Called on the add listing page form for frontend just before the tags field.
     *
     * @since 1.0.0
     */
    do_action('geodir_before_listing_tags_field');
    ?>
        <div id="geodir_post_tags_row" class="geodir_form_row clearfix">
            <label><?php 
    echo TAGKW_TEXT;
    ?>
</label>
            <input name="post_tags" id="post_tags" value="<?php 
    echo $kw_tags;
    ?>
" type="text" class="geodir_textfield"
                   maxlength="<?php 
    echo $kw_tags_count;
    ?>
"/>
            <span class="geodir_message_note"><?php 
    echo $kw_tags_msg;
    ?>
</span>
        </div>
        <?php 
    /**
     * Called on the add listing page form for frontend just after the tags field.
     *
     * @since 1.0.0
     */
    do_action('geodir_after_listing_tags_field');
    ?>

        <?php 
    $package_info = array();
    $package_info = geodir_post_package_info($package_info, $post);
    geodir_get_custom_fields_html($package_info->pid, 'all', $listing_type);
    ?>


        <?php 
    // adjust values here
    $id = "post_images";
    // this will be the name of form field. Image url(s) will be submitted in $_POST using this key. So if $id == �img1� then $_POST[�img1�] will have all the image urls
    $multiple = true;
    // allow multiple files upload
    $width = geodir_media_image_large_width();
    // If you want to automatically resize all uploaded images then provide width here (in pixels)
    $height = geodir_media_image_large_height();
    // If you want to automatically resize all uploaded images then provide height here (in pixels)
    $thumb_img_arr = array();
    $totImg = 0;
    if (isset($_REQUEST['backandedit']) && empty($_REQUEST['pid'])) {
        $post = (object) unserialize($_SESSION['listing']);
        if (isset($post->post_images)) {
            $curImages = trim($post->post_images, ",");
        }
        if ($curImages != '') {
            $curImages_array = explode(',', $curImages);
            $totImg = count($curImages_array);
        }
        $listing_type = $post->listing_type;
    } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
        $post = geodir_get_post_info($_REQUEST['pid']);
        $listing_type = $post->post_type;
        $thumb_img_arr = geodir_get_images($_REQUEST['pid']);
    } else {
        $listing_type = $_REQUEST['listing_type'];
    }
    if (!empty($thumb_img_arr)) {
        foreach ($thumb_img_arr as $img) {
            //$curImages = $img->src.",";
        }
        $totImg = count((array) $thumb_img_arr);
    }
    if ($curImages != '') {
        $svalue = $curImages;
    } else {
        $svalue = '';
    }
    $image_limit = $package_info->image_limit;
    $show_image_input_box = $image_limit != '0';
    /**
     * Filter to be able to show/hide the image upload section of the add listing form.
     *
     * @since 1.0.0
     * @param bool $show_image_input_box Set true to show. Set false to not show.
     * @param string $listing_type The custom post type slug.
     */
    $show_image_input_box = apply_filters('geodir_image_uploader_on_add_listing', $show_image_input_box, $listing_type);
    if ($show_image_input_box) {
        ?>

            <h5 id="geodir_form_title_row" class="geodir-form_title"> <?php 
        echo PRO_PHOTO_TEXT;
        ?>
                <?php 
        if ($image_limit == 1) {
            echo '<br /><small>(' . __('You can upload', GEODIRECTORY_TEXTDOMAIN) . ' ' . $image_limit . ' ' . __('image with this package', GEODIRECTORY_TEXTDOMAIN) . ')</small>';
        }
        ?>
                <?php 
        if ($image_limit > 1) {
            echo '<br /><small>(' . __('You can upload', GEODIRECTORY_TEXTDOMAIN) . ' ' . $image_limit . ' ' . __('images with this package', GEODIRECTORY_TEXTDOMAIN) . ')</small>';
        }
        ?>
                <?php 
        if ($image_limit == '') {
            echo '<br /><small>(' . __('You can upload unlimited images with this package', GEODIRECTORY_TEXTDOMAIN) . ')</small>';
        }
        ?>
            </h5>

            <div class="geodir_form_row clearfix" id="<?php 
        echo $id;
        ?>
dropbox" align="center"
                 style="border:1px solid #ccc; min-height:100px; height:auto; padding:10px;">
                <input type="hidden" name="<?php 
        echo $id;
        ?>
" id="<?php 
        echo $id;
        ?>
" value="<?php 
        echo $svalue;
        ?>
"/>
                <input type="hidden" name="<?php 
        echo $id;
        ?>
image_limit" id="<?php 
        echo $id;
        ?>
image_limit"
                       value="<?php 
        echo $image_limit;
        ?>
"/>
                <input type="hidden" name="<?php 
        echo $id;
        ?>
totImg" id="<?php 
        echo $id;
        ?>
totImg"
                       value="<?php 
        echo $totImg;
        ?>
"/>

                <div
                    class="plupload-upload-uic hide-if-no-js <?php 
        if ($multiple) {
            ?>
plupload-upload-uic-multiple<?php 
        }
        ?>
"
                    id="<?php 
        echo $id;
        ?>
plupload-upload-ui">
                    <h4><?php 
        _e('Drop files to upload', GEODIRECTORY_TEXTDOMAIN);
        ?>
</h4><br/>
                    <input id="<?php 
        echo $id;
        ?>
plupload-browse-button" type="button"
                           value="<?php 
        esc_attr_e('Select Files', GEODIRECTORY_TEXTDOMAIN);
        ?>
" class="geodir_button"/>
                    <span class="ajaxnonceplu"
                          id="ajaxnonceplu<?php 
        echo wp_create_nonce($id . 'pluploadan');
        ?>
"></span>
                    <?php 
        if ($width && $height) {
            ?>
                        <span class="plupload-resize"></span>
                        <span class="plupload-width" id="plupload-width<?php 
            echo $width;
            ?>
"></span>
                        <span class="plupload-height" id="plupload-height<?php 
            echo $height;
            ?>
"></span>
                    <?php 
        }
        ?>
                    <div class="filelist"></div>
                </div>

                <div class="plupload-thumbs <?php 
        if ($multiple) {
            ?>
plupload-thumbs-multiple<?php 
        }
        ?>
 clearfix"
                     id="<?php 
        echo $id;
        ?>
plupload-thumbs" style="border-top:1px solid #ccc; padding-top:10px;">
                </div>
                <span
                    id="upload-msg"><?php 
        _e('Please drag &amp; drop the images to rearrange the order', GEODIRECTORY_TEXTDOMAIN);
        ?>
</span>
                <span id="<?php 
        echo $id;
        ?>
upload-error" style="display:none"></span>
            </div>

        <?php 
    }
    ?>

        <?php 
    /**
     * Called on the add listing page form for frontend just after the image upload field.
     *
     * @since 1.0.0
     */
    do_action('geodir_after_main_form_fields');
    ?>


        <!-- add captcha code -->

        <script>
            <!--<script>-->
            document.write('<inp' + 'ut type="hidden" id="geodir_sp' + 'amblocker_top_form" name="geodir_sp' + 'amblocker" value="64"/>')
        </script>
        <noscript>
            <div>
                <label><?php 
    _e('Type 64 into this box', GEODIRECTORY_TEXTDOMAIN);
    ?>
</label>
                <input type="text" id="geodir_spamblocker_top_form" name="geodir_spamblocker" value="" maxlength="10"/>
            </div>
        </noscript>
        <input type="text" id="geodir_filled_by_spam_bot_top_form" name="geodir_filled_by_spam_bot" value=""/>


        <!-- end captcha code -->

        <div id="geodir-add-listing-submit" class="geodir_form_row clear_both" align="center" style="padding:2px;">
            <input type="submit" value="<?php 
    echo PRO_PREVIEW_BUTTON;
    ?>
"
                   class="geodir_button" <?php 
    echo $submit_button;
    ?>
/>
            <span class="geodir_message_note"
                  style="padding-left:0px;"> <?php 
    _e('Note: You will be able to see a preview in the next page', GEODIRECTORY_TEXTDOMAIN);
    ?>
</span>
        </div>

    </form>
    <?php 
    wp_reset_query();
}
/**
 * Retrives the posts for the current post type.
 *
 * @since 1.4.6
 * @since 1.5.1 Updated to import & export recurring events.
 * @package GeoDirectory
 *
 * @global object $wp_filesystem WordPress FileSystem object.
 *
 * @param string $post_type Post type.
 * @return array Array of posts data.
 */
function geodir_imex_get_posts($post_type)
{
    global $wp_filesystem;
    $posts = geodir_get_export_posts($post_type);
    $csv_rows = array();
    if (!empty($posts)) {
        $is_payment_plugin = is_plugin_active('geodir_payment_manager/geodir_payment_manager.php');
        $csv_row = array();
        $csv_row[] = 'post_id';
        $csv_row[] = 'post_title';
        $csv_row[] = 'post_author';
        $csv_row[] = 'post_content';
        $csv_row[] = 'post_category';
        $csv_row[] = 'post_tags';
        $csv_row[] = 'post_type';
        if ($post_type == 'gd_event') {
            $csv_row[] = 'event_date';
            $csv_row[] = 'event_enddate';
            $csv_row[] = 'starttime';
            $csv_row[] = 'endtime';
            $csv_row[] = 'is_recurring_event';
            $csv_row[] = 'event_duration_days';
            $csv_row[] = 'recurring_dates';
            $csv_row[] = 'is_whole_day_event';
            $csv_row[] = 'event_starttimes';
            $csv_row[] = 'event_endtimes';
            $csv_row[] = 'recurring_type';
            $csv_row[] = 'recurring_interval';
            $csv_row[] = 'recurring_week_days';
            $csv_row[] = 'recurring_week_nos';
            $csv_row[] = 'max_recurring_count';
            $csv_row[] = 'recurring_end_date';
        }
        $csv_row[] = 'post_status';
        $csv_row[] = 'is_featured';
        if ($is_payment_plugin) {
            $csv_row[] = 'package_id';
            $csv_row[] = 'expire_date';
        }
        $csv_row[] = 'geodir_video';
        $csv_row[] = 'post_address';
        $csv_row[] = 'post_city';
        $csv_row[] = 'post_region';
        $csv_row[] = 'post_country';
        $csv_row[] = 'post_zip';
        $csv_row[] = 'post_latitude';
        $csv_row[] = 'post_longitude';
        $csv_row[] = 'geodir_timing';
        $csv_row[] = 'geodir_contact';
        $csv_row[] = 'geodir_email';
        $csv_row[] = 'geodir_website';
        $csv_row[] = 'geodir_twitter';
        $csv_row[] = 'geodir_facebook';
        $csv_row[] = 'geodir_video';
        $csv_row[] = 'geodir_special_offers';
        // WPML
        $is_wpml = geodir_is_wpml();
        if ($is_wpml) {
            $csv_row[] = 'language';
            $csv_row[] = 'original_post_id';
        }
        // WPML
        $custom_fields = geodir_imex_get_custom_fields($post_type);
        if (!empty($custom_fields)) {
            foreach ($custom_fields as $custom_field) {
                $csv_row[] = $custom_field->htmlvar_name;
            }
        }
        // Export franchise fields
        $is_franchise_active = is_plugin_active('geodir_franchise/geodir_franchise.php') && geodir_franchise_enabled($post_type) ? true : false;
        if ($is_franchise_active) {
            $csv_row[] = 'gd_is_franchise';
            $csv_row[] = 'gd_franchise_lock';
            $csv_row[] = 'franchise';
        }
        $csv_rows[] = $csv_row;
        $images_count = 5;
        foreach ($posts as $post) {
            $post_id = $post['ID'];
            $taxonomy_category = $post_type . 'category';
            $taxonomy_tags = $post_type . '_tags';
            $post_category = '';
            $post_tags = '';
            $terms = wp_get_post_terms($post_id, array($taxonomy_category, $taxonomy_tags));
            if (!empty($terms) && !is_wp_error($terms)) {
                $post_category = array();
                $post_tags = array();
                foreach ($terms as $term) {
                    if ($term->taxonomy == $taxonomy_category) {
                        $post_category[] = $term->name;
                    }
                    if ($term->taxonomy == $taxonomy_tags) {
                        $post_tags[] = $term->name;
                    }
                }
                $post_category = !empty($post_category) ? implode(',', $post_category) : '';
                $post_tags = !empty($post_tags) ? implode(',', $post_tags) : '';
            }
            $gd_post_info = geodir_get_post_info($post_id);
            $post_info = (array) $gd_post_info;
            // Franchise data
            $franchise_id = NULL;
            $franchise_info = array();
            $locked_fields = array();
            if ($is_franchise_active && isset($post_info['franchise']) && (int) $post_info['franchise'] > 0 && geodir_franchise_check((int) $post_info['franchise'])) {
                $franchise_id = $post_info['franchise'];
                $gd_franchise_info = geodir_get_post_info($franchise_id);
                if (geodir_franchise_pkg_is_active($gd_franchise_info)) {
                    $franchise_info = (array) $gd_franchise_info;
                    $locked_fields = geodir_franchise_get_locked_fields($franchise_id, true);
                    if (!empty($locked_fields)) {
                        foreach ($locked_fields as $locked_field) {
                            if (isset($post_info[$locked_field]) && isset($franchise_info[$locked_field])) {
                                $post_info[$locked_field] = $franchise_info[$locked_field];
                            }
                            if (in_array($taxonomy_category, $locked_fields) || in_array('post_tags', $locked_fields)) {
                                $franchise_terms = wp_get_post_terms($franchise_id, array($taxonomy_category, $taxonomy_tags));
                                if (!empty($franchise_terms) && !is_wp_error($franchise_terms)) {
                                    $franchise_post_category = array();
                                    $franchise_post_tags = array();
                                    foreach ($franchise_terms as $franchise_term) {
                                        if ($franchise_term->taxonomy == $taxonomy_category) {
                                            $franchise_post_category[] = $franchise_term->name;
                                        }
                                        if ($franchise_term->taxonomy == $taxonomy_tags) {
                                            $franchise_post_tags[] = $franchise_term->name;
                                        }
                                    }
                                    if (in_array($taxonomy_category, $locked_fields)) {
                                        $post_category = !empty($franchise_post_category) ? implode(',', $franchise_post_category) : '';
                                    }
                                    if (in_array('post_tags', $locked_fields)) {
                                        $post_tags = !empty($franchise_post_tags) ? implode(',', $franchise_post_tags) : '';
                                    }
                                }
                            }
                        }
                    }
                }
            }
            $post_images = geodir_get_images($post_id);
            $current_images = array();
            if (!empty($post_images)) {
                foreach ($post_images as $post_image) {
                    $post_image = (array) $post_image;
                    $image = !empty($post_image) && isset($post_image['path']) && $wp_filesystem->is_file($post_image['path']) && $wp_filesystem->exists($post_image['path']) ? $post_image['src'] : '';
                    if ($image) {
                        $current_images[] = $image;
                    }
                }
                $images_count = max($images_count, count($current_images));
            }
            $csv_row = array();
            $csv_row[] = $post_id;
            // post_id
            $csv_row[] = $post_info['post_title'];
            // post_title
            $csv_row[] = $post_info['post_author'];
            // post_author
            $csv_row[] = $post_info['post_content'];
            // post_content
            $csv_row[] = $post_category;
            // post_category
            $csv_row[] = $post_tags;
            // post_tags
            $csv_row[] = $post_type;
            // post_type
            if ($post_type == 'gd_event') {
                $event_data = geodir_imex_get_event_data($post, $gd_post_info);
                $csv_row[] = $event_data['event_date'];
                // event_date
                $csv_row[] = $event_data['event_enddate'];
                // enddate
                $csv_row[] = $event_data['starttime'];
                // starttime
                $csv_row[] = $event_data['endtime'];
                // endtime
                $csv_row[] = $event_data['is_recurring_event'];
                // is_recurring
                $csv_row[] = $event_data['event_duration_days'];
                // duration_x
                $csv_row[] = $event_data['recurring_dates'];
                // recurring_dates
                $csv_row[] = $event_data['is_whole_day_event'];
                // all_day
                $csv_row[] = $event_data['event_starttimes'];
                // starttimes
                $csv_row[] = $event_data['event_endtimes'];
                // endtimes
                $csv_row[] = $event_data['recurring_type'];
                // repeat_type
                $csv_row[] = $event_data['recurring_interval'];
                // repeat_x
                $csv_row[] = $event_data['recurring_week_days'];
                // repeat_days
                $csv_row[] = $event_data['recurring_week_nos'];
                // repeat_weeks
                $csv_row[] = $event_data['max_recurring_count'];
                // max_repeat
                $csv_row[] = $event_data['recurring_end_date'];
                // repeat_end
            }
            $csv_row[] = $post_info['post_status'];
            // post_status
            $csv_row[] = (int) $post_info['is_featured'] == 1 ? 1 : '';
            // is_featured
            if ($is_payment_plugin) {
                $csv_row[] = (int) $post_info['package_id'];
                // package_id
                $csv_row[] = $post_info['expire_date'] != '' && strtolower($post_info['expire_date']) != 'never' ? date_i18n('Y-m-d', strtotime($post_info['expire_date'])) : 'Never';
                // expire_date
            }
            $csv_row[] = $post_info['geodir_video'];
            // geodir_video
            $csv_row[] = $post_info['post_address'];
            // post_address
            $csv_row[] = $post_info['post_city'];
            // post_city
            $csv_row[] = $post_info['post_region'];
            // post_region
            $csv_row[] = $post_info['post_country'];
            // post_country
            $csv_row[] = $post_info['post_zip'];
            // post_zip
            $csv_row[] = $post_info['post_latitude'];
            // post_latitude
            $csv_row[] = $post_info['post_longitude'];
            // post_longitude
            $csv_row[] = $post_info['geodir_timing'];
            // geodir_timing
            $csv_row[] = $post_info['geodir_contact'];
            // geodir_contact
            $csv_row[] = $post_info['geodir_email'];
            // geodir_email
            $csv_row[] = $post_info['geodir_website'];
            // geodir_website
            $csv_row[] = $post_info['geodir_twitter'];
            // geodir_twitter
            $csv_row[] = $post_info['geodir_facebook'];
            // geodir_facebook
            $csv_row[] = $post_info['geodir_video'];
            // geodir_video
            $csv_row[] = $post_info['geodir_special_offers'];
            // geodir_special_offers
            // WPML
            if ($is_wpml) {
                $csv_row[] = geodir_get_language_for_element($post_id, 'post_' . $post_type);
                $csv_row[] = get_post_meta($post_id, '_icl_lang_duplicate_of', true);
            }
            // WPML
            if (!empty($custom_fields)) {
                foreach ($custom_fields as $custom_field) {
                    $csv_row[] = isset($post_info[$custom_field->htmlvar_name]) ? $post_info[$custom_field->htmlvar_name] : '';
                }
            }
            // Franchise data
            if ($is_franchise_active) {
                $gd_is_franchise = '';
                $locaked_fields = '';
                $franchise = '';
                if (geodir_franchise_pkg_is_active($gd_post_info)) {
                    $gd_is_franchise = (int) get_post_meta($post_id, 'gd_is_franchise', true);
                    $locaked_fields = $gd_is_franchise ? get_post_meta($post_id, 'gd_franchise_lock', true) : '';
                    $locaked_fields = is_array($locaked_fields) && !empty($locaked_fields) ? implode(",", $locaked_fields) : '';
                    $franchise = !$gd_is_franchise && isset($post_info['franchise']) && (int) $post_info['franchise'] > 0 ? (int) $post_info['franchise'] : 0;
                    // franchise id
                }
                $csv_row[] = (int) $gd_is_franchise;
                // gd_is_franchise
                $csv_row[] = $locaked_fields;
                // gd_franchise_lock fields
                $csv_row[] = (int) $franchise;
                // franchise id
            }
            for ($c = 0; $c < $images_count; $c++) {
                $csv_row[] = isset($current_images[$c]) ? $current_images[$c] : '';
                // IMAGE
            }
            $csv_rows[] = $csv_row;
        }
        for ($c = 0; $c < $images_count; $c++) {
            $csv_rows[0][] = 'IMAGE';
        }
    }
    return $csv_rows;
}
示例#4
0
 /**
  * Delete Listing info from details table for the given post id.
  *
  * @since 1.0.0
  * @package GeoDirectory
  * @global object $wpdb WordPress Database object.
  * @global string $plugin_prefix Geodirectory plugin table prefix.
  * @param int $deleted_postid The post ID.
  * @param bool $force Optional. Do you want to force delete it? Default: false.
  * @return bool|void
  */
 function geodir_delete_listing_info($deleted_postid, $force = false)
 {
     global $wpdb, $plugin_prefix;
     // check for multisite deletions
     if (strpos($plugin_prefix, $wpdb->prefix) !== false) {
     } else {
         return;
     }
     $post_type = get_post_type($deleted_postid);
     $all_postypes = geodir_get_posttypes();
     if (!in_array($post_type, $all_postypes)) {
         return false;
     }
     $table = $plugin_prefix . $post_type . '_detail';
     /* Delete custom post meta*/
     $wpdb->query($wpdb->prepare("DELETE FROM " . $table . " WHERE `post_id` = %d", array($deleted_postid)));
     /* Delete post map icons*/
     $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ICON_TABLE . " WHERE `post_id` = %d", array($deleted_postid)));
     /* Delete Attachments*/
     $postcurr_images = geodir_get_images($deleted_postid);
     $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE `post_id` = %d", array($deleted_postid)));
     geodir_remove_attachments($postcurr_images);
 }
function tgm_soliloquy_dynamic_add_images($data, $images)
{
    global $post;
    // Uncomment to see what data is actually being passed.
    // echo '<pre>' . var_export( $data, true ) . '</pre>';
    // echo '<pre>' . var_export( $images, true ) . '</pre>';
    // You will want to add your images to the $data['slider'] key. Totally untested, but should get you going.
    //$post_thumbnail_id = get_post_thumbnail_id( $post->ID );
    //echo $post_thumbnail_id;
    $thumb_id = get_post_thumbnail_id();
    $thumb_url_array = wp_get_attachment_image_src($thumb_id, 'thumbnail-size', true);
    $thumb_url = $thumb_url_array[0];
    //echo $thumb_url . '<br />';
    $post_images = geodir_get_images($data['id'], 'thumbnail');
    //var_dump($post_images);
    foreach ((array) $post_images as $image) {
        //echo '<p>$post_images</p><pre>' . var_export($post_images, true) . '</pre>';
        if ($thumb_url != $image->src) {
            $data['slider'][$image->file] = array('status' => 'active', 'src' => $image->src, 'title' => $image->title, 'alt' => $image->title, 'caption' => '', 'link' => '', 'type' => 'image');
        }
    }
    //var_dump($image);
    // Return the data.
    //echo '<p>$data</p><pre>' . var_export($data, true) . '</pre>';
    return $data;
}