Ejemplo n.º 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 
}
Ejemplo n.º 2
0
/**
 * Details page tab custom fields.
 *
 * @since 1.0.0
 * @package GeoDirectory
 * @global object $post The current post object.
 * @param array $tabs_arr Tabs array {@see geodir_detail_page_tab_headings_change()}.
 * @return array Modified tabs array.
 */
function geodir_detail_page_custom_field_tab($tabs_arr)
{
    global $post;
    $post_type = geodir_get_current_posttype();
    $all_postypes = geodir_get_posttypes();
    if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes) && (geodir_is_page('detail') || geodir_is_page('preview'))) {
        $package_info = array();
        $package_info = geodir_post_package_info($package_info, $post);
        $post_package_id = $package_info->pid;
        $fields_location = 'detail';
        $custom_fields = geodir_post_custom_fields($post_package_id, 'default', $post_type, $fields_location);
        if (!empty($custom_fields)) {
            $parse_custom_fields = array();
            foreach ($custom_fields as $field) {
                $field = stripslashes_deep($field);
                // strip slashes
                $type = $field;
                $field_name = $field['htmlvar_name'];
                if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) {
                    $post->{$field_name} = $_REQUEST[$field_name];
                }
                if (isset($field['show_as_tab']) && $field['show_as_tab'] == 1 && (isset($post->{$field_name}) && $post->{$field_name} != '' || $field['type'] == 'fieldset') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file'))) {
                    if ($type['type'] == 'datepicker' && ($post->{$type}['htmlvar_name'] == '' || $post->{$type}['htmlvar_name'] == '0000-00-00')) {
                        continue;
                    }
                    $parse_custom_fields[] = $field;
                }
            }
            $custom_fields = $parse_custom_fields;
        }
        if (!empty($custom_fields)) {
            $field_set_start = 0;
            $fieldset_count = 0;
            $fieldset = '';
            $total_fields = count($custom_fields);
            $count_field = 0;
            $fieldset_arr = array();
            $i = 0;
            $geodir_post_info = isset($post->ID) && !empty($post->ID) ? geodir_get_post_info($post->ID) : NULL;
            foreach ($custom_fields as $field) {
                $count_field++;
                $field_name = $field['htmlvar_name'];
                if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) {
                    $post->{$field_name} = $_REQUEST[$field_name];
                }
                if (isset($field['show_as_tab']) && $field['show_as_tab'] == 1 && (isset($post->{$field_name}) && $post->{$field_name} != '' || $field['type'] == 'fieldset') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file'))) {
                    $label = $field['site_title'] != '' ? $field['site_title'] : $field['admin_title'];
                    $site_title = trim($field['site_title']);
                    $type = $field;
                    $html = '';
                    $html_var = $field_name;
                    $field_icon = '';
                    $variables_array = array();
                    if ($type['type'] == 'datepicker' && ($post->{$type}['htmlvar_name'] == '' || $post->{$type}['htmlvar_name'] == '0000-00-00')) {
                        continue;
                    }
                    if ($type['type'] != 'fieldset') {
                        $i++;
                        $variables_array['post_id'] = $post->ID;
                        $variables_array['label'] = __($type['site_title'], 'geodirectory');
                        $variables_array['value'] = '';
                        $variables_array['value'] = $post->{$type}['htmlvar_name'];
                    }
                    if (strpos($type['field_icon'], 'http') !== false) {
                        $field_icon = ' background: url(' . $type['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;';
                    } elseif (strpos($type['field_icon'], 'fa fa-') !== false) {
                        $field_icon = '<i class="' . $type['field_icon'] . '"></i>';
                    }
                    switch ($type['type']) {
                        case 'fieldset':
                            $i = 0;
                            $fieldset_count++;
                            $field_set_start = 1;
                            $fieldset_arr[$fieldset_count]['htmlvar_name'] = 'gd_tab_' . $fieldset_count;
                            $fieldset_arr[$fieldset_count]['label'] = $label;
                            break;
                        case 'url':
                            if (strpos($field_icon, 'http') !== false) {
                                $field_icon_af = '';
                            } elseif ($field_icon == '') {
                                if ($type['name'] == 'geodir_facebook') {
                                    $field_icon_af = '<i class="fa fa-facebook-square"></i>';
                                } elseif ($type['name'] == 'geodir_twitter') {
                                    $field_icon_af = '<i class="fa fa-twitter-square"></i>';
                                } else {
                                    $field_icon_af = '<i class="fa fa-link"></i>';
                                }
                            } else {
                                $field_icon_af = $field_icon;
                                $field_icon = '';
                            }
                            if (!strstr($post->{$type}['htmlvar_name'], 'http')) {
                                $website = 'http://' . $post->{$type}['htmlvar_name'];
                            } else {
                                $website = $post->{$type}['htmlvar_name'];
                            }
                            $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd';
                            // all search engines that use the nofollow value exclude links that use it from their ranking calculation
                            $rel = strpos($website, get_site_url()) !== false ? '' : 'rel="nofollow"';
                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '"><span class="geodir-i-website" style="' . $field_icon . '">' . $field_icon_af . ' <a href="' . $website . '" target="_blank" ' . $rel . ' ><strong>' . apply_filters('geodir_custom_field_website_name', stripslashes(__($type['site_title'], 'geodirectory')), $website, $post->ID) . '</strong></a></span></div>';
                            break;
                        case 'phone':
                            if (strpos($field_icon, 'http') !== false) {
                                $field_icon_af = '';
                            } elseif ($field_icon == '') {
                                $field_icon_af = '<i class="fa fa-phone"></i>';
                            } else {
                                $field_icon_af = $field_icon;
                                $field_icon = '';
                            }
                            $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd';
                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-contact" style="' . $field_icon . '">' . $field_icon_af;
                            if ($field_set_start == 1 && $site_title != '') {
                                $html .= ' ' . __($site_title, 'geodirectory') . ': ';
                            }
                            $html .= ' </span>' . stripslashes($post->{$type}['htmlvar_name']) . '</div>';
                            break;
                        case 'time':
                            $value = '';
                            if ($post->{$type}['htmlvar_name'] != '') {
                                //$value = date('h:i',strtotime($post->$type['htmlvar_name']));
                                $value = date(get_option('time_format'), strtotime($post->{$type}['htmlvar_name']));
                            }
                            if (strpos($field_icon, 'http') !== false) {
                                $field_icon_af = '';
                            } elseif ($field_icon == '') {
                                $field_icon_af = '<i class="fa fa-clock-o"></i>';
                            } else {
                                $field_icon_af = $field_icon;
                                $field_icon = '';
                            }
                            $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd';
                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-time" style="' . $field_icon . '">' . $field_icon_af;
                            if ($field_set_start == 1 && $site_title != '') {
                                $html .= ' ' . __($site_title, 'geodirectory') . ': ';
                            }
                            $html .= ' </span>' . stripslashes($value) . '</div>';
                            break;
                        case 'datepicker':
                            $date_format = geodir_default_date_format();
                            if ($type['extra_fields'] != '') {
                                $date_format = unserialize($type['extra_fields']);
                                $date_format = $date_format['date_format'];
                            }
                            $search = array('dd', 'd', 'DD', 'mm', 'm', 'MM', 'yy');
                            //jQuery UI datepicker format
                            $replace = array('d', 'j', 'l', 'm', 'n', 'F', 'Y');
                            //PHP date format
                            $date_format = str_replace($search, $replace, $date_format);
                            $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $post->{$type}['htmlvar_name']) : $post->{$type}['htmlvar_name'];
                            // PHP doesn't work well with dd/mm/yyyy format
                            $value = '';
                            if ($post->{$type}['htmlvar_name'] != '') {
                                $value = date($date_format, strtotime($post_htmlvar_value));
                            }
                            if (strpos($field_icon, 'http') !== false) {
                                $field_icon_af = '';
                            } elseif ($field_icon == '') {
                                $field_icon_af = '<i class="fa fa-calendar"></i>';
                            } else {
                                $field_icon_af = $field_icon;
                                $field_icon = '';
                            }
                            $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd';
                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-datepicker" style="' . $field_icon . '">' . $field_icon_af;
                            if ($field_set_start == 1 && $site_title != '') {
                                $html .= ' ' . __($site_title, 'geodirectory') . ': ';
                            }
                            $html .= ' </span>' . $value . '</div>';
                            break;
                        case 'text':
                            if (strpos($field_icon, 'http') !== false) {
                                $field_icon_af = '';
                            } elseif ($field_icon == '') {
                                $field_icon_af = '';
                            } else {
                                $field_icon_af = $field_icon;
                                $field_icon = '';
                            }
                            $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd';
                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af;
                            if ($field_set_start == 1 && $site_title != '') {
                                $html .= ' ' . __($site_title, 'geodirectory') . ': ';
                            }
                            $html .= ' </span>' . stripslashes($post->{$type}['htmlvar_name']) . '</div>';
                            break;
                        case 'radio':
                            if ($post->{$type}['htmlvar_name'] != '') {
                                if ($post->{$type}['htmlvar_name'] == 'f' || $post->{$type}['htmlvar_name'] == '0') {
                                    $html_val = __('No', 'geodirectory');
                                } else {
                                    if ($post->{$type}['htmlvar_name'] == 't' || $post->{$type}['htmlvar_name'] == '1') {
                                        $html_val = __('Yes', 'geodirectory');
                                    }
                                }
                                if (strpos($field_icon, 'http') !== false) {
                                    $field_icon_af = '';
                                } else {
                                    if ($field_icon == '') {
                                        $field_icon_af = '';
                                    } else {
                                        $field_icon_af = $field_icon;
                                        $field_icon = '';
                                    }
                                }
                                $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd';
                                $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-radio" style="' . $field_icon . '">' . $field_icon_af;
                                if ($field_set_start == 1 && $site_title != '') {
                                    $html .= ' ' . __($site_title, 'geodirectory') . ': ';
                                }
                                $html .= ' </span>' . $html_val . '</div>';
                            }
                            break;
                        case 'checkbox':
                            $html_var = $type['htmlvar_name'];
                            $html_val = $type['htmlvar_name'];
                            if ((int) $post->{$html_var} == 1) {
                                if ($post->{$type}['htmlvar_name'] == '1') {
                                    $html_val = __('Yes', 'geodirectory');
                                } else {
                                    $html_val = __('No', 'geodirectory');
                                }
                                if (strpos($field_icon, 'http') !== false) {
                                    $field_icon_af = '';
                                } else {
                                    if ($field_icon == '') {
                                        $field_icon_af = '';
                                    } else {
                                        $field_icon_af = $field_icon;
                                        $field_icon = '';
                                    }
                                }
                                $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd';
                                $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-checkbox" style="' . $field_icon . '">' . $field_icon_af;
                                if ($field_set_start == 1 && $site_title != '') {
                                    $html .= ' ' . __($site_title, 'geodirectory') . ': ';
                                }
                                $html .= ' </span>' . $html_val . '</div>';
                            }
                            break;
                        case 'select':
                            if (strpos($field_icon, 'http') !== false) {
                                $field_icon_af = '';
                            } elseif ($field_icon == '') {
                                $field_icon_af = '';
                            } else {
                                $field_icon_af = $field_icon;
                                $field_icon = '';
                            }
                            $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd';
                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af;
                            if ($field_set_start == 1 && $site_title != '') {
                                $html .= ' ' . __($site_title, 'geodirectory') . ': ';
                            }
                            $html .= ' </span>' . stripslashes($post->{$type}['htmlvar_name']) . '</div>';
                            break;
                        case 'multiselect':
                            if (is_array($post->{$type}['htmlvar_name'])) {
                                $post->{$type}['htmlvar_name'] = implode(', ', $post->{$type}['htmlvar_name']);
                            }
                            if (strpos($field_icon, 'http') !== false) {
                                $field_icon_af = '';
                            } elseif ($field_icon == '') {
                                $field_icon_af = '';
                            } else {
                                $field_icon_af = $field_icon;
                                $field_icon = '';
                            }
                            $option_values = explode(',', $post->{$type}['htmlvar_name']);
                            if ($type['option_values']) {
                                if (strstr($type['option_values'], "/")) {
                                    $option_values = array();
                                    $field_values = explode(',', $type['option_values']);
                                    foreach ($field_values as $data) {
                                        $val = explode('/', $data);
                                        if (isset($val[1]) && in_array($val[1], explode(',', $post->{$type}['htmlvar_name']))) {
                                            $option_values[] = $val[0];
                                        }
                                    }
                                }
                            }
                            $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd';
                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af;
                            if ($field_set_start == 1 && $site_title != '') {
                                $html .= ' ' . __($site_title, 'geodirectory') . ': ';
                            }
                            $html .= ' </span>';
                            if (count($option_values) > 1) {
                                $html .= '<ul>';
                                foreach ($option_values as $val) {
                                    $html .= '<li>' . stripslashes($val) . '</li>';
                                }
                                $html .= '</ul>';
                            } else {
                                $html .= stripslashes(trim($post->{$type}['htmlvar_name'], ','));
                            }
                            $html .= '</div>';
                            break;
                        case 'email':
                            if (strpos($field_icon, 'http') !== false) {
                                $field_icon_af = '';
                            } elseif ($field_icon == '') {
                                $field_icon_af = '<i class="fa fa-envelope"></i>';
                            } else {
                                $field_icon_af = $field_icon;
                                $field_icon = '';
                            }
                            $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd';
                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-email" style="' . $field_icon . '">' . $field_icon_af;
                            if ($field_set_start == 1 && $site_title != '') {
                                $html .= ' ' . __($site_title, 'geodirectory') . ': ';
                            }
                            $html .= ' </span>' . stripslashes($post->{$type}['htmlvar_name']) . '</div>';
                            break;
                        case 'textarea':
                            if (strpos($field_icon, 'http') !== false) {
                                $field_icon_af = '';
                            } elseif ($field_icon == '') {
                                $field_icon_af = '';
                            } else {
                                $field_icon_af = $field_icon;
                                $field_icon = '';
                            }
                            $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd';
                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af;
                            if ($field_set_start == 1 && $site_title != '') {
                                $html .= ' ' . __($site_title, 'geodirectory') . ': ';
                            }
                            $html .= '</span>' . wpautop(stripslashes($post->{$type}['htmlvar_name'])) . '</div>';
                            break;
                        case 'html':
                            if (strpos($field_icon, 'http') !== false) {
                                $field_icon_af = '';
                            } elseif ($field_icon == '') {
                                $field_icon_af = '';
                            } else {
                                $field_icon_af = $field_icon;
                                $field_icon = '';
                            }
                            $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd';
                            $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af;
                            if ($field_set_start == 1 && $site_title != '') {
                                $html .= ' ' . __($site_title, 'geodirectory') . ': ';
                            }
                            $html .= ' </span>' . wpautop(stripslashes($post->{$type}['htmlvar_name'])) . '</div>';
                            break;
                        case 'file':
                            $html_var = $type['htmlvar_name'];
                            if (!empty($post->{$type}['htmlvar_name'])) {
                                $files = explode(",", $post->{$type}['htmlvar_name']);
                                if (!empty($files)) {
                                    $extra_fields = !empty($type['extra_fields']) ? maybe_unserialize($type['extra_fields']) : NULL;
                                    $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types']) ? $extra_fields['gd_file_types'] : '';
                                    $file_paths = '';
                                    foreach ($files as $file) {
                                        if (!empty($file)) {
                                            $filetype = wp_check_filetype($file);
                                            $image_name_arr = explode('/', $file);
                                            $curr_img_dir = $image_name_arr[count($image_name_arr) - 2];
                                            $filename = end($image_name_arr);
                                            $img_name_arr = explode('.', $filename);
                                            $arr_file_type = wp_check_filetype($filename);
                                            if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) {
                                                continue;
                                            }
                                            $uploaded_file_type = $arr_file_type['type'];
                                            $uploaded_file_ext = $arr_file_type['ext'];
                                            if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) {
                                                continue;
                                                // Invalid file type.
                                            }
                                            //$allowed_file_types = array('application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain');
                                            $image_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/x-icon');
                                            // If the uploaded file is image
                                            if (in_array($uploaded_file_type, $image_file_types)) {
                                                $file_paths .= '<div class="geodir-custom-post-gallery" class="clearfix">';
                                                $file_paths .= '<a href="' . $file . '">';
                                                $file_paths .= geodir_show_image(array('src' => $file), 'thumbnail', false, false);
                                                $file_paths .= '</a>';
                                                $file_paths .= '</div>';
                                            } else {
                                                $ext_path = '_' . $html_var . '_';
                                                $filename = explode($ext_path, $filename);
                                                $file_paths .= '<a href="' . $file . '" target="_blank">' . $filename[count($filename) - 1] . '</a>';
                                            }
                                        }
                                    }
                                    if (strpos($field_icon, 'http') !== false) {
                                        $field_icon_af = '';
                                    } else {
                                        if ($field_icon == '') {
                                            $field_icon_af = '';
                                        } else {
                                            $field_icon_af = $field_icon;
                                            $field_icon = '';
                                        }
                                    }
                                    $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd';
                                    $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . ' geodir-custom-file-box" style="clear:both;"><span class="geodir-i-file" style="display:inline-block;vertical-align:top;padding-right:14px;' . $field_icon . '">' . $field_icon_af;
                                    if ($field_set_start == 1 && $site_title != '') {
                                        $html .= ' ' . __($site_title, 'geodirectory') . ': ';
                                    }
                                    $html .= ' </span>' . $file_paths . '</div>';
                                }
                            }
                            break;
                    }
                    if ($field_set_start == 1) {
                        $add_html = false;
                        if ($type['type'] == 'fieldset' && $fieldset_count > 1) {
                            if ($fieldset != '') {
                                $add_html = true;
                                $label = $fieldset_arr[$fieldset_count - 1]['label'];
                                $htmlvar_name = $fieldset_arr[$fieldset_count - 1]['htmlvar_name'];
                            }
                            $fieldset_html = $fieldset;
                            $fieldset = '';
                        } else {
                            $fieldset .= $html;
                            if ($total_fields == $count_field && $fieldset != '') {
                                $add_html = true;
                                $label = $fieldset_arr[$fieldset_count]['label'];
                                $htmlvar_name = $fieldset_arr[$fieldset_count]['htmlvar_name'];
                                $fieldset_html = $fieldset;
                            }
                        }
                        if ($add_html) {
                            $tabs_arr[$htmlvar_name] = array('heading_text' => __($label, 'geodirectory'), 'is_active_tab' => false, 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $htmlvar_name), 'tab_content' => '<div class="geodir-company_info field-group">' . $fieldset_html . '</html>');
                        }
                    } else {
                        if ($html != '') {
                            $tabs_arr[$field['htmlvar_name']] = array('heading_text' => __($label, 'geodirectory'), 'is_active_tab' => false, 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $field['htmlvar_name']), 'tab_content' => $html);
                        }
                    }
                }
            }
        }
    }
    return $tabs_arr;
}
/**
 * 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();
}
/**
 * This is used to put country , region , city and neighbour dropdown on add/edit listing page.
 *
 * @since 1.0.0
 * @package GeoDirectory_Location_Manager
 *
 * @global object $wpdb WordPress Database object.
 * @global string $plugin_prefix Geodirectory plugin table prefix.
 *
 * @param array $val The array of setting for the custom field.
 */
function geodir_location_address_extra_listing_fields($val)
{
    $name = $val['name'];
    $site_title = $val['site_title'];
    $type = $val['type'];
    $admin_desc = $val['desc'];
    $option_values = $val['option_values'];
    $is_required = $val['is_required'];
    $is_default = $val['is_default'];
    $is_admin = $val['is_admin'];
    $required_msg = $val['required_msg'];
    $extra_fields = unserialize($val['extra_fields']);
    $prefix = $name . '_';
    $extra_fields['city_lable'] != '' ? $city_title = $extra_fields['city_lable'] : ($city_title = ucwords($prefix . ' city'));
    $extra_fields['region_lable'] != '' ? $region_title = $extra_fields['region_lable'] : ($region_title = ucwords($prefix . ' region'));
    $extra_fields['country_lable'] != '' ? $country_title = $extra_fields['country_lable'] : ($country_title = ucwords($prefix . ' country'));
    $city = '';
    $region = '';
    $country = '';
    $neighbourhood = '';
    if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && isset($_SESSION['listing'])) {
        $post = unserialize($_SESSION['listing']);
        $city = $post[$prefix . 'city'];
        $region = $post[$prefix . 'region'];
        $country = $post[$prefix . 'country'];
        $neighbourhood = isset($post[$prefix . 'neighbourhood']) ? $post[$prefix . 'neighbourhood'] : '';
    } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '' && ($post_info = geodir_get_post_info($_REQUEST['pid']))) {
        $post_info = (array) $post_info;
        $city = $post_info[$prefix . 'city'];
        $region = $post_info[$prefix . 'region'];
        $country = $post_info[$prefix . 'country'];
        if (isset($post_info[$prefix . 'neighbourhood'])) {
            $neighbourhood = $post_info[$prefix . 'neighbourhood'];
        }
    } elseif (isset($_SESSION['gd_multi_location'])) {
        if (isset($_SESSION['gd_city']) && $_SESSION['gd_city'] != '') {
            $location = geodir_get_locations('city', $_SESSION['gd_city']);
        } elseif (isset($_SESSION['gd_region']) && $_SESSION['gd_region'] != '') {
            $location = geodir_get_locations('region', $_SESSION['gd_region']);
        } elseif (isset($_SESSION['gd_country']) && $_SESSION['gd_country'] != '') {
            $location = geodir_get_locations('country', $_SESSION['gd_country']);
        }
        if (isset($location) && $location) {
            $location = end($location);
        }
        $city = isset($location->city) ? $location->city : '';
        $region = isset($location->region) ? $location->region : '';
        $country = isset($location->country) ? $location->country : '';
    }
    $location = geodir_get_default_location();
    if (empty($city)) {
        $city = isset($location->city) ? $location->city : '';
    }
    if (empty($region)) {
        $region = isset($location->region) ? $location->region : '';
    }
    if (empty($country)) {
        $country = isset($location->country) ? $location->country : '';
    }
    ?>
    <div id="geodir_add_listing_all_chosen_container_row" class="geodir_location_add_listing_all_chosen_container" >
    <?php 
    if (get_option('geodir_enable_country') == 'default') {
        global $wpdb;
        $countries_ISO2 = $wpdb->get_var($wpdb->prepare("SELECT ISO2 FROM " . GEODIR_COUNTRIES_TABLE . " WHERE Country=%s", $country));
        ?>
<input type="hidden" name="geodir_location_add_listing_country_val" value="<?php 
        echo $country;
        ?>
" />
		<input type="hidden" id="<?php 
        echo $prefix;
        ?>
country" data-country_code="<?php 
        echo $countries_ISO2;
        ?>
" name="<?php 
        echo $prefix;
        ?>
country" value="<?php 
        echo $country;
        ?>
" />
		<?php 
    } else {
        if ($extra_fields['show_country']) {
            ?>
   
			<div id="geodir_<?php 
            echo $prefix . 'country';
            ?>
_row" class="<?php 
            if ($is_required) {
                echo 'required_field';
            }
            ?>
 geodir_form_row  geodir_location_add_listing_country_chosen_container clearfix">
				<label>

					<?php 
            _e($country_title, GEODIRLOCATION_TEXTDOMAIN);
            ?>
					<?php 
            if ($is_required) {
                echo '<span>*</span>';
            }
            ?>
				</label>
				 <div class="geodir_location_add_listing_country_chosen_div" style="width:57%; float:left;">
							 <input type="hidden" name="geodir_location_add_listing_country_val" value="<?php 
            echo $country;
            ?>
" />
							 
				<select id="<?php 
            echo $prefix;
            ?>
country" class="geodir_location_add_listing_chosen" data-location_type="country" name="<?php 
            echo $prefix;
            ?>
country"  data-placeholder="<?php 
            _e('Choose a country.', GEODIRLOCATION_TEXTDOMAIN);
            ?>
" data-addsearchtermonnorecord="1" data-ajaxchosen="0" data-autoredirect="0" data-showeverywhere="0" >
				<?php 
            if (get_option('geodir_enable_country') == 'multi') {
                geodir_get_country_dl($country, $prefix);
            } else {
                if (get_option('geodir_enable_country') == 'selected') {
                    geodir_get_limited_country_dl($country, $prefix);
                }
            }
            ?>
				</select>
		
				</div>
							<span class="geodir_message_note"><?php 
            _e('Click on above field and type to filter list', GEODIRLOCATION_TEXTDOMAIN);
            ?>
</span>
				<?php 
            if ($is_required) {
                ?>
					<span class="geodir_message_error"><?php 
                echo $required_msg;
                ?>
</span> 
			<?php 
            }
            ?>
			</div>
		<?php 
        }
    }
    // end of show country if
    if (get_option('geodir_enable_region') == 'default') {
        ?>
<input type="hidden" name="geodir_location_add_listing_region_val" value="<?php 
        echo $region;
        ?>
" />
			<input type="hidden" id="<?php 
        echo $prefix;
        ?>
region" name="<?php 
        echo $prefix;
        ?>
region" value="<?php 
        echo $region;
        ?>
" />
		<?php 
    } else {
        if ($extra_fields['show_region']) {
            ?>
   
		<div id="geodir_<?php 
            echo $prefix . 'region';
            ?>
_row" class="<?php 
            if ($is_required) {
                echo 'required_field';
            }
            ?>
 geodir_form_row  geodir_location_add_listing_region_chosen_container clearfix">
			<label>
				<?php 
            _e($region_title, GEODIRLOCATION_TEXTDOMAIN);
            ?>
				<?php 
            if ($is_required) {
                echo '<span>*</span>';
            }
            ?>
			</label>
			<div class="geodir_location_add_listing_region_chosen_div" style="width:57%; float:left;">
					<input type="hidden" name="geodir_location_add_listing_region_val" value="<?php 
            echo $region;
            ?>
" />
				<select id="<?php 
            echo $prefix;
            ?>
region" class="geodir_location_add_listing_chosen"  data-location_type="region" name="<?php 
            echo $prefix;
            ?>
region" data-placeholder="<?php 
            _e('Please wait..&hellip;', GEODIRLOCATION_TEXTDOMAIN);
            ?>
" <?php 
            if (get_option('geodir_enable_region') == 'selected') {
                ?>
				data-ajaxchosen="0" <?php 
            } else {
                ?>
 data-ajaxchosen="1" <?php 
            }
            ?>
 data-addsearchtermonnorecord="1" data-autoredirect="0"  >
		<?php 
            $selected = '';
            $args = array('what' => 'region', 'country_val' => $country, 'region_val' => '', 'echo' => false, 'format' => array('type' => 'array'));
            if (get_option('location_dropdown_all')) {
                $args['no_of_records'] = '10000';
            }
            // set limit to 10 thouseand as this is most browsers limit
            $location_array = geodir_get_location_array($args);
            // get country val in case of country search to get selected option
            ?>
							<option  value='' ><?php 
            _e('Select State', GEODIRLOCATION_TEXTDOMAIN);
            ?>
</option>	
				<?php 
            if (!empty($location_array)) {
                foreach ($location_array as $locations) {
                    $selected = '';
                    if (strtolower($region) == strtolower($locations->region)) {
                        $selected = " selected='selected' ";
                    }
                    ?>
						<option <?php 
                    echo $selected;
                    ?>
 value="<?php 
                    echo $locations->region;
                    ?>
" ><?php 
                    echo ucwords($locations->region);
                    ?>
</option>
				<?php 
                }
            }
            ?>
				
			</select>
	
			</div>
						<span class="geodir_message_note"><?php 
            _e('Click on above field and type to filter list or add a new region', GEODIRLOCATION_TEXTDOMAIN);
            ?>
</span>
			<?php 
            if ($is_required) {
                ?>
				<span class="geodir_message_error"><?php 
                echo $required_msg;
                ?>
</span> 
			<?php 
            }
            ?>
		</div>
		<?php 
        }
    }
    //end of show region
    if (get_option('geodir_enable_city') == 'default') {
        ?>
<input type="hidden" name="geodir_location_add_listing_city_val" value="<?php 
        echo $city;
        ?>
" />
		 <input type="hidden" id="<?php 
        echo $prefix;
        ?>
city" name="<?php 
        echo $prefix;
        ?>
city" value="<?php 
        echo $city;
        ?>
" />
		 <?php 
    } else {
        if ($extra_fields['show_city']) {
            ?>
   
		<div id="geodir_<?php 
            echo $prefix . 'city';
            ?>
_row" class="<?php 
            if ($is_required) {
                echo 'required_field';
            }
            ?>
 geodir_form_row  geodir_location_add_listing_city_chosen_container clearfix">
			<label> 
				<?php 
            _e($city_title, GEODIRLOCATION_TEXTDOMAIN);
            ?>
				<?php 
            if ($is_required) {
                echo '<span>*</span>';
            }
            ?>
			</label>
			
			<div  class="geodir_location_add_listing_city_chosen_div" style="width:57%; float:left;">
				 <input type="hidden" name="geodir_location_add_listing_city_val" value="<?php 
            echo $city;
            ?>
" />
				<select id="<?php 
            echo $prefix;
            ?>
city" class="geodir_location_add_listing_chosen" data-location_type="city" name="<?php 
            echo $prefix;
            ?>
city" data-placeholder="<?php 
            _e('Please wait..&hellip;', GEODIRLOCATION_TEXTDOMAIN);
            ?>
" <?php 
            if (get_option('geodir_enable_city') == 'selected') {
                ?>
				data-ajaxchosen="0" <?php 
            } else {
                ?>
 data-ajaxchosen="1" <?php 
            }
            ?>
  data-addsearchtermonnorecord="1" data-autoredirect="0"  >
		<?php 
            $selected = '';
            $args = array('what' => 'city', 'country_val' => $country, 'region_val' => $region, 'echo' => false, 'format' => array('type' => 'array'));
            if (get_option('location_dropdown_all')) {
                $args['no_of_records'] = '10000';
            }
            // set limit to 10 thouseand as this is most browsers limit
            $location_array = geodir_get_location_array($args);
            // get country val in case of country search to get selected option
            ?>
				<option  value='' ><?php 
            _e('Select City', GEODIRLOCATION_TEXTDOMAIN);
            ?>
</option>	
				<?php 
            if (!empty($location_array)) {
                foreach ($location_array as $locations) {
                    $selected = '';
                    if (strtolower($city) == strtolower($locations->city)) {
                        $selected = " selected='selected' ";
                    }
                    ?>
						<option <?php 
                    echo $selected;
                    ?>
 value="<?php 
                    echo $locations->city;
                    ?>
" ><?php 
                    echo ucwords($locations->city);
                    ?>
</option>
				<?php 
                }
            }
            ?>
				
			</select>
			</div>
					<span class="geodir_message_note"><?php 
            _e('Click on above field and type to filter list or add a new city', GEODIRLOCATION_TEXTDOMAIN);
            ?>
</span>
			<?php 
            if ($is_required) {
                ?>
				<span  class="geodir_message_error"><?php 
                echo $required_msg;
                ?>
</span> 
			<?php 
            }
            ?>
		</div>
		<?php 
        }
    }
    // end of show city if
    if (get_option('location_neighbourhoods') && $is_admin == '1') {
        global $plugin_prefix;
        $neighbourhood_options = geodir_get_neighbourhoods_dl(esc_attr(stripslashes($city)), $neighbourhood, false);
        $neighbourhood_display = '';
        if (trim($neighbourhood_options) == '') {
            $neighbourhood_display = 'style="display:none;"';
        }
        ?>
	<div id="geodir_<?php 
        echo $prefix . 'neighbourhood';
        ?>
_row" class="geodir_form_row  geodir_location_add_listing_neighbourhood_chosen_container clearfix" <?php 
        echo $neighbourhood_display;
        ?>
   >
		<label><?php 
        _e('Neighbourhood', GEODIRLOCATION_TEXTDOMAIN);
        ?>
</label>
        
		<div  class="geodir_location_add_listing_neighbourhood_chosen_div" style="width:57%; float:left;">
			<select name="<?php 
        echo $prefix . 'neighbourhood';
        ?>
" class="chosen_select" option-ajaxChosen="false" >
			 <?php 
        echo $neighbourhood_options;
        ?>
			</select>
		</div>
        <span class="geodir_message_note"><?php 
        _e('Click on above field and type to filter list', GEODIRLOCATION_TEXTDOMAIN);
        ?>
</span>
	</div>
	<?php 
    }
    ?>
    </div  ><!-- end of geodir_location_add_listing_all_chosen_container -->
    <?php 
}
Ejemplo n.º 5
0
function geodir_save_listing_package_fields($post_id = '', $request_info)
{
    global $wpdb;
    $package_id = isset($request_info['package_id']) ? $request_info['package_id'] : '';
    if (!$post_id || !$package_id) {
        return;
    }
    $package_info = (array) geodir_get_package_info($package_id);
    $post_info = geodir_get_post_info($post_id);
    $post_type = $post_info->post_type;
    $post_category = $post_type . 'category';
    //print_r($package_info);
    //print_r($post_info);
    // check for excluded cats
    if ($package_info['cat']) {
        // only run if there are excluded cats
        $cur_cats = array_unique(array_filter(explode(",", $post_info->{$post_category})));
        $ex_cats = array_filter(explode(",", $package_info['cat']));
        foreach ($cur_cats as $key => $value) {
            if (in_array($value, $ex_cats)) {
                unset($cur_cats[$key]);
            }
        }
        //print_r($cur_cats);
        $cur_cats = array_map('intval', $cur_cats);
        // this was being treated as a string so we convert to int.
        $cur_cats_str = !empty($cur_cats) ? implode(',', $cur_cats) : '';
        $term_taxonomy_ids = wp_set_object_terms($post_id, $cur_cats, $post_category);
        geodir_save_post_meta($post_id, $post_category, $cur_cats_str);
        // check if defualt cat is excluded and if so chane it
        $default_cat = $post_info->default_category;
        if ($default_cat && in_array($default_cat, $ex_cats)) {
            geodir_save_post_meta($post_id, 'default_category', $cur_cats[0]);
        }
    }
    // check if featured only if not in admin
    if (!is_admin()) {
        if ($package_info['is_featured'] != $post_info->is_featured) {
            geodir_save_post_meta($post_id, 'is_featured', $package_info['is_featured']);
        }
    }
    // check image limit
    if ($package_info['image_limit'] != '') {
        $image_limit = $package_info['image_limit'];
        $post_images = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE `post_id`=%d order by menu_order asc", array($post_id)));
        //print_r($post_images);
        $count_post_images = count($post_images);
        if ($count_post_images > $image_limit) {
            if ($image_limit >= '1') {
                foreach ($post_images as $key => $perimage) {
                    // move featured image to the end of the arr so it's not removed
                    if ($post_info->featured_image == $perimage->file) {
                        unset($post_images[$key]);
                        $post_images[] = $perimage;
                    }
                }
            }
            $post_images_arr = array_slice($post_images, 0, $count_post_images - $image_limit);
            $upload_dir = wp_upload_dir();
            $upload_basedir = $upload_dir['basedir'];
            foreach ($post_images_arr as $perimage) {
                if (file_exists($upload_basedir . $perimage->file)) {
                    unlink($upload_basedir . $perimage->file);
                }
                $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE ID=%d", array($perimage->ID)));
                if ($post_info->featured_image == $perimage->file) {
                    geodir_save_post_meta($post_id, 'featured_image', '');
                }
            }
        }
    }
    // check if there is a category limit
    if ($package_info['cat_limit'] != '') {
        $cur_cats = array_unique(array_filter(explode(",", $post_info->{$post_category})));
        $cat_limit = (int) $package_info['cat_limit'];
        if (count($cur_cats) > $cat_limit) {
            $default_category = (int) $post_info->default_category > 0 ? (int) $post_info->default_category : $cur_cats[0];
            $count = 0;
            $new_cur_cats = array();
            foreach ($cur_cats as $cat_id) {
                $new_cur_cats[] = (int) $cat_id;
                $count++;
                if ($count >= $cat_limit) {
                    break;
                }
            }
            if ($default_category && !in_array($default_category, $new_cur_cats)) {
                $new_cur_cats[$cat_limit - 1] = $default_category;
            }
            $cur_cats_str = !empty($new_cur_cats) ? implode(',', $new_cur_cats) : '';
            $term_taxonomy_ids = wp_set_object_terms($post_id, $new_cur_cats, $post_category);
            geodir_save_post_meta($post_id, $post_category, $cur_cats_str);
            $post_cat_str = '';
            if (!empty($new_cur_cats)) {
                $post_cat_str = '#' . implode(",y:#", $new_cur_cats) . ',y:';
                $post_cat_str = str_replace('#' . $default_category . ',y', '#' . $default_category . ',y,d', $post_cat_str);
                $post_cat_str = ltrim($post_cat_str, '#');
                $post_cat_str = array($post_category => $post_cat_str);
            }
            geodir_set_postcat_structure($post_id, $post_category, $default_category, $post_cat_str);
        }
    }
    // check custom fields
    $custom_fields = geodir_post_custom_fields('', 'all', $post_type);
    //print_r($custom_fields);
    if (!empty($custom_fields)) {
        foreach ($custom_fields as $key => $val) {
            $id = $val['id'];
            $label = $val['label'];
            $is_default = $val['is_default'];
            $is_admin = $val['is_admin'];
            $field_type = $val['field_type'];
            $packages = array();
            $packages = array_unique(array_filter(explode(",", $val['packages'])));
            if (!($field_type == 'address' && $is_admin == '1') && !($field_type == 'taxonomy' && $is_admin == '1') && $val['for_admin_use'] != '1') {
                if (in_array($package_id, $packages)) {
                    // if active for this package then dont change
                } else {
                    // if not active in this package then blank
                    geodir_save_post_meta($post_id, $val['name'], '');
                }
            }
        }
    }
}
Ejemplo n.º 6
0
function geodir_change_invoice_status()
{
    global $wpdb;
    if (current_user_can('manage_options')) {
        if ($_REQUEST['postid'] != '' && $_REQUEST['postid'] != '' && isset($_REQUEST['_wpnonce'])) {
            if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'invoice_status_update_nonce')) {
                return;
            }
            $id = $_REQUEST['invoiceid'];
            $invoice_info = geodir_get_invoice($id);
            $invoice_package_id = '';
            if (!empty($invoice_info) && isset($invoice_info->package_id)) {
                $invoice_package_id = $invoice_info->package_id;
                $invoice_alive_days = $invoice_info->alive_days;
                $invoice_status = $invoice_info->status;
            }
            $my_post = array();
            $my_post['ID'] = $_REQUEST['postid'];
            $status = $_REQUEST['inv_status'];
            if ($status == 'paid') {
                $my_post['post_status'] = 'publish';
                $post_id = $_REQUEST['postid'];
                $post_info = get_post($post_id);
                $geodir_post_info = geodir_get_post_info($post_id);
                if (!empty($geodir_post_info) && !empty($post_info) && isset($post_info->post_status)) {
                    $post_package_id = $geodir_post_info->package_id;
                    $post_expire_date = $geodir_post_info->expire_date;
                    if (!empty($invoice_package_id) && $invoice_alive_days > 0 && $invoice_package_id == $post_package_id && strtolower($post_expire_date) != 'never' && strtotime($post_expire_date) >= strtotime(date('Y-m-d')) && $post_info->post_status == 'publish') {
                        $expire_date = date('Y-m-d', strtotime($post_expire_date . "+" . $invoice_alive_days . " days"));
                        geodir_save_post_meta($post_id, 'alive_days', $geodir_post_info->alive_days + $invoice_alive_days);
                        geodir_save_post_meta($post_id, 'expire_date', $expire_date);
                    } else {
                        if ($post_info->post_status != 'publish') {
                            $my_post['post_date'] = current_time('mysql');
                            $my_post['post_date_gmt'] = current_time('mysql', 1);
                        }
                        $alive_days = (int) $geodir_post_info->alive_days;
                        if (strtolower($post_expire_date) != 'never' && strtotime($post_expire_date) < strtotime(date('Y-m-d'))) {
                            $alive_days = $invoice_alive_days;
                        }
                        $expire_date = $alive_days > 0 ? date('Y-m-d', strtotime(date('Y-m-d') . "+" . $alive_days . " days")) : 'Never';
                        geodir_save_post_meta($post_id, 'alive_days', $alive_days);
                        geodir_save_post_meta($post_id, 'expire_date', $expire_date);
                    }
                }
            } else {
                $my_post['post_status'] = 'draft';
            }
            // Update the post into the database
            wp_update_post($my_post);
            // Update invoice status
            geodir_update_invoice_status($id, $status);
            $msg = urlencode(GD_INVOICE_MSG);
            wp_redirect(admin_url() . "admin.php?page=geodirectory&tab=paymentmanager_fields&subtab=geodir_invoice_list&success_msg=" . $msg);
            exit;
        }
    } else {
        wp_redirect(home_url() . '/?geodir_signup=true');
        exit;
    }
}
Ejemplo n.º 7
0
/**
 * Displays custom fields html.
 *
 * @since 1.0.0
 * @since 1.5.2 Added TERRAIN map type.
 * @package GeoDirectory
 * @global object $wpdb WordPress Database object.
 * @global object $post The current post object.
 * @global array $geodir_addon_list List of active GeoDirectory extensions.
 * @param int|string $package_id The package ID.
 * @param string $default Optional. When set to "default" it will display only default fields.
 * @param string $post_type Optional. The wordpress post type.
 */
function geodir_get_custom_fields_html($package_id = '', $default = 'custom', $post_type = 'gd_place')
{
    global $is_default, $mapzoom;
    $show_editors = array();
    $listing_type = $post_type;
    $custom_fields = geodir_post_custom_fields($package_id, $default, $post_type);
    foreach ($custom_fields as $key => $val) {
        $val = stripslashes_deep($val);
        // strip slashes from labels
        $name = $val['name'];
        $site_title = $val['site_title'];
        $type = $val['type'];
        $admin_desc = $val['desc'];
        $option_values = $val['option_values'];
        $is_required = $val['is_required'];
        $is_default = $val['is_default'];
        $is_admin = $val['is_admin'];
        $required_msg = $val['required_msg'];
        $extra_fields = unserialize($val['extra_fields']);
        $value = '';
        /* field available to site admin only for edit */
        $for_admin_use = isset($val['for_admin_use']) && (int) $val['for_admin_use'] == 1 ? true : false;
        if ($for_admin_use && !is_super_admin()) {
            continue;
        }
        if (is_admin()) {
            global $post;
            if (isset($_REQUEST['post'])) {
                $_REQUEST['pid'] = $_REQUEST['post'];
            }
        }
        if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && isset($_SESSION['listing'])) {
            $post = unserialize($_SESSION['listing']);
            $value = isset($post[$name]) ? $post[$name] : '';
        } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
            $value = geodir_get_post_meta($_REQUEST['pid'], $name, true);
        } else {
            if ($value == '') {
                $value = $val['default'];
            }
        }
        /**
         * Called before the custom fields info is output for submitting a post.
         *
         * Used dynamic hook type geodir_before_custom_form_field_$name.
         *
         * @since 1.0.0
         * @param string $listing_type The post post type.
         * @param int $package_id The price package ID for the post.
         * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
         * @see 'geodir_after_custom_form_field_$name'
         */
        do_action('geodir_before_custom_form_field_' . $name, $listing_type, $package_id, $val);
        if ($type == 'fieldset') {
            ?>
<h5><?php 
            echo $site_title;
            ?>
            <?php 
            if ($admin_desc != '') {
                echo '<small>( ' . $admin_desc . ' )</small>';
            }
            ?>
            </h5><?php 
        } elseif ($type == 'address') {
            $prefix = $name . '_';
            $site_title != '' ? $address_title = $site_title : ($address_title = ucwords($prefix . ' address'));
            $extra_fields['zip_lable'] != '' ? $zip_title = $extra_fields['zip_lable'] : ($zip_title = ucwords($prefix . ' zip/post code '));
            $extra_fields['map_lable'] != '' ? $map_title = $extra_fields['map_lable'] : ($map_title = ucwords('set address on map'));
            $extra_fields['mapview_lable'] != '' ? $mapview_title = $extra_fields['mapview_lable'] : ($mapview_title = ucwords($prefix . ' mapview'));
            $address = '';
            $zip = '';
            $mapview = '';
            $mapzoom = '';
            $lat = '';
            $lng = '';
            if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && isset($_SESSION['listing'])) {
                $post = unserialize($_SESSION['listing']);
                $address = $post[$prefix . 'address'];
                $zip = isset($post[$prefix . 'zip']) ? $post[$prefix . 'zip'] : '';
                $lat = isset($post[$prefix . 'latitude']) ? $post[$prefix . 'latitude'] : '';
                $lng = isset($post[$prefix . 'longitude']) ? $post[$prefix . 'longitude'] : '';
                $mapview = isset($post[$prefix . 'mapview']) ? $post[$prefix . 'mapview'] : '';
                $mapzoom = isset($post[$prefix . 'mapzoom']) ? $post[$prefix . 'mapzoom'] : '';
            } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '' && ($post_info = geodir_get_post_info($_REQUEST['pid']))) {
                $post_info = (array) $post_info;
                $address = $post_info[$prefix . 'address'];
                $zip = isset($post_info[$prefix . 'zip']) ? $post_info[$prefix . 'zip'] : '';
                $lat = isset($post_info[$prefix . 'latitude']) ? $post_info[$prefix . 'latitude'] : '';
                $lng = isset($post_info[$prefix . 'longitude']) ? $post_info[$prefix . 'longitude'] : '';
                $mapview = isset($post_info[$prefix . 'mapview']) ? $post_info[$prefix . 'mapview'] : '';
                $mapzoom = isset($post_info[$prefix . 'mapzoom']) ? $post_info[$prefix . 'mapzoom'] : '';
            }
            $location = geodir_get_default_location();
            if (empty($city)) {
                $city = isset($location->city) ? $location->city : '';
            }
            if (empty($region)) {
                $region = isset($location->region) ? $location->region : '';
            }
            if (empty($country)) {
                $country = isset($location->country) ? $location->country : '';
            }
            $lat_lng_blank = false;
            if (empty($lat) && empty($lng)) {
                $lat_lng_blank = true;
            }
            if (empty($lat)) {
                $lat = isset($location->city_latitude) ? $location->city_latitude : '';
            }
            if (empty($lng)) {
                $lng = isset($location->city_longitude) ? $location->city_longitude : '';
            }
            /**
             * Filter the default latitude.
             *
             * @since 1.0.0
             *
             * @param float $lat Default latitude.
             * @param bool $is_admin For admin use only?.
             */
            $lat = apply_filters('geodir_default_latitude', $lat, $is_admin);
            /**
             * Filter the default longitude.
             *
             * @since 1.0.0
             *
             * @param float $lat Default longitude.
             * @param bool $is_admin For admin use only?.
             */
            $lng = apply_filters('geodir_default_longitude', $lng, $is_admin);
            ?>

            <div id="geodir_<?php 
            echo $prefix . 'address';
            ?>
_row"
                 class="<?php 
            if ($is_required) {
                echo 'required_field';
            }
            ?>
 geodir_form_row clearfix">
                <label>
                    <?php 
            _e($address_title, 'geodirectory');
            ?>
                    <?php 
            if ($is_required) {
                echo '<span>*</span>';
            }
            ?>
                </label>
                <input type="text" field_type="<?php 
            echo $type;
            ?>
" name="<?php 
            echo $prefix . 'address';
            ?>
"
                       id="<?php 
            echo $prefix . 'address';
            ?>
" class="geodir_textfield"
                       value="<?php 
            echo esc_attr(stripslashes($address));
            ?>
"/>
                <span class="geodir_message_note"><?php 
            _e($admin_desc, 'geodirectory');
            ?>
</span>
                <?php 
            if ($is_required) {
                ?>
                    <span class="geodir_message_error"><?php 
                _e($required_msg, 'geodirectory');
                ?>
</span>
                <?php 
            }
            ?>
            </div>


            <?php 
            /**
             * Called after the address input on the add listings.
             *
             * This is used by the location manage to add further locations info etc.
             *
             * @since 1.0.0
             * @param array $val The array of setting for the custom field. {@see geodir_custom_field_save()}.
             */
            do_action('geodir_address_extra_listing_fields', $val);
            if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) {
                ?>

                <div id="geodir_<?php 
                echo $prefix . 'zip';
                ?>
_row"
                     class="<?php 
                /*if($is_required) echo 'required_field';*/
                ?>
 geodir_form_row clearfix">
                    <label>
                        <?php 
                _e($zip_title, 'geodirectory');
                ?>
                        <?php 
                /*if($is_required) echo '<span>*</span>';*/
                ?>
                    </label>
                    <input type="text" field_type="<?php 
                echo $type;
                ?>
" name="<?php 
                echo $prefix . 'zip';
                ?>
"
                           id="<?php 
                echo $prefix . 'zip';
                ?>
" class="geodir_textfield autofill"
                           value="<?php 
                echo esc_attr(stripslashes($zip));
                ?>
"/>
                    <?php 
                /*if($is_required) {?>
                		<span class="geodir_message_error"><?php echo _e($required_msg,'geodirectory');?></span>
                		<?php }*/
                ?>
                </div>
            <?php 
            }
            ?>

            <?php 
            if (isset($extra_fields['show_map']) && $extra_fields['show_map']) {
                ?>

                <div id="geodir_<?php 
                echo $prefix . 'map';
                ?>
_row" class="geodir_form_row clearfix">
                    <?php 
                /**
                 * Contains add listing page map functions.
                 *
                 * @since 1.0.0
                 */
                include geodir_plugin_path() . "/geodirectory-functions/map-functions/map_on_add_listing_page.php";
                if ($lat_lng_blank) {
                    $lat = '';
                    $lng = '';
                }
                ?>
                    <span class="geodir_message_note"><?php 
                echo GET_MAP_MSG;
                ?>
</span>
                </div>
                <?php 
                /* show lat lng */
                $style_latlng = isset($extra_fields['show_latlng']) && $extra_fields['show_latlng'] || is_admin() ? '' : 'style="display:none"';
                ?>
                <div id="geodir_<?php 
                echo $prefix . 'latitude';
                ?>
_row"
                     class="<?php 
                if ($is_required) {
                    echo 'required_field';
                }
                ?>
 geodir_form_row clearfix" <?php 
                echo $style_latlng;
                ?>
>
                    <label>
                        <?php 
                echo PLACE_ADDRESS_LAT;
                ?>
                        <?php 
                if ($is_required) {
                    echo '<span>*</span>';
                }
                ?>
                    </label>
                    <input type="text" field_type="<?php 
                echo $type;
                ?>
" name="<?php 
                echo $prefix . 'latitude';
                ?>
"
                           id="<?php 
                echo $prefix . 'latitude';
                ?>
" class="geodir_textfield"
                           value="<?php 
                echo esc_attr(stripslashes($lat));
                ?>
" size="25"/>
                    <span class="geodir_message_note"><?php 
                echo GET_LATITUDE_MSG;
                ?>
</span>
                    <?php 
                if ($is_required) {
                    ?>
                        <span class="geodir_message_error"><?php 
                    _e($required_msg, 'geodirectory');
                    ?>
</span>
                    <?php 
                }
                ?>
                </div>

                <div id="geodir_<?php 
                echo $prefix . 'longitude';
                ?>
_row"
                     class="<?php 
                if ($is_required) {
                    echo 'required_field';
                }
                ?>
 geodir_form_row clearfix" <?php 
                echo $style_latlng;
                ?>
>
                    <label>
                        <?php 
                echo PLACE_ADDRESS_LNG;
                ?>
                        <?php 
                if ($is_required) {
                    echo '<span>*</span>';
                }
                ?>
                    </label>
                    <input type="text" field_type="<?php 
                echo $type;
                ?>
" name="<?php 
                echo $prefix . 'longitude';
                ?>
"
                           id="<?php 
                echo $prefix . 'longitude';
                ?>
" class="geodir_textfield"
                           value="<?php 
                echo esc_attr(stripslashes($lng));
                ?>
" size="25"/>
                    <span class="geodir_message_note"><?php 
                echo GET_LOGNGITUDE_MSG;
                ?>
</span>
                    <?php 
                if ($is_required) {
                    ?>
                        <span class="geodir_message_error"><?php 
                    _e($required_msg, 'geodirectory');
                    ?>
</span>
                    <?php 
                }
                ?>
                </div>
            <?php 
            }
            ?>

            <?php 
            if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) {
                ?>
                <div id="geodir_<?php 
                echo $prefix . 'mapview';
                ?>
_row" class="geodir_form_row clearfix ">
                    <label><?php 
                _e($mapview_title, 'geodirectory');
                ?>
</label>


                    <span class="geodir_user_define"><input field_type="<?php 
                echo $type;
                ?>
" type="radio"
                                                            class="gd-checkbox"
                                                            name="<?php 
                echo $prefix . 'mapview';
                ?>
"
                                                            id="<?php 
                echo $prefix . 'mapview';
                ?>
" <?php 
                if ($mapview == 'ROADMAP' || $mapview == '') {
                    echo 'checked="checked"';
                }
                ?>
  value="ROADMAP" size="25"/> <?php 
                _e('Default Map', 'geodirectory');
                ?>
</span>
                    <span class="geodir_user_define"> <input field_type="<?php 
                echo $type;
                ?>
" type="radio"
                                                             class="gd-checkbox"
                                                             name="<?php 
                echo $prefix . 'mapview';
                ?>
"
                                                             id="map_view1" <?php 
                if ($mapview == 'SATELLITE') {
                    echo 'checked="checked"';
                }
                ?>
 value="SATELLITE" size="25"/> <?php 
                _e('Satellite Map', 'geodirectory');
                ?>
</span>

                    <span class="geodir_user_define"><input field_type="<?php 
                echo $type;
                ?>
" type="radio"
                                                            class="gd-checkbox"
                                                            name="<?php 
                echo $prefix . 'mapview';
                ?>
"
                                                            id="map_view2" <?php 
                if ($mapview == 'HYBRID') {
                    echo 'checked="checked"';
                }
                ?>
  value="HYBRID" size="25"/> <?php 
                _e('Hybrid Map', 'geodirectory');
                ?>
</span>
					<span class="geodir_user_define"><input field_type="<?php 
                echo $type;
                ?>
" type="radio"
                                                            class="gd-checkbox"
                                                            name="<?php 
                echo $prefix . 'mapview';
                ?>
"
                                                            id="map_view3" <?php 
                if ($mapview == 'TERRAIN') {
                    echo 'checked="checked"';
                }
                ?>
  value="TERRAIN" size="25"/> <?php 
                _e('Terrain Map', 'geodirectory');
                ?>
</span>


                </div>
            <?php 
            }
            ?>

            <?php 
            if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) {
                ?>
                <input type="hidden" value="<?php 
                if (isset($mapzoom)) {
                    echo esc_attr($mapzoom);
                }
                ?>
" name="<?php 
                echo $prefix . 'mapzoom';
                ?>
" id="<?php 
                echo $prefix . 'mapzoom';
                ?>
"/>
            <?php 
            }
            ?>
        <?php 
        } elseif ($type == 'text') {
            ?>

            <div id="<?php 
            echo $name;
            ?>
_row"
                 class="<?php 
            if ($is_required) {
                echo 'required_field';
            }
            ?>
 geodir_form_row clearfix">
                <label>
                    <?php 
            $site_title = __($site_title, 'geodirectory');
            echo trim($site_title) ? $site_title : '&nbsp;';
            ?>
                    <?php 
            if ($is_required) {
                echo '<span>*</span>';
            }
            ?>
                </label>
                <input field_type="<?php 
            echo $type;
            ?>
" name="<?php 
            echo $name;
            ?>
" id="<?php 
            echo $name;
            ?>
"
                       value="<?php 
            echo esc_attr(stripslashes($value));
            ?>
" type="text" class="geodir_textfield"/>
                <span class="geodir_message_note"><?php 
            _e($admin_desc, 'geodirectory');
            ?>
</span>
                <?php 
            if ($is_required) {
                ?>
                    <span class="geodir_message_error"><?php 
                _e($required_msg, 'geodirectory');
                ?>
</span>
                <?php 
            }
            ?>
            </div>

        <?php 
        } elseif ($type == 'email') {
            if ($value == $val['default']) {
                $value = '';
            }
            ?>

            <div id="<?php 
            echo $name;
            ?>
_row"
                 class="<?php 
            if ($is_required) {
                echo 'required_field';
            }
            ?>
 geodir_form_row clearfix">
                <label>
                    <?php 
            $site_title = __($site_title, 'geodirectory');
            echo trim($site_title) ? $site_title : '&nbsp;';
            ?>
                    <?php 
            if ($is_required) {
                echo '<span>*</span>';
            }
            ?>
                </label>
                <input field_type="<?php 
            echo $type;
            ?>
" name="<?php 
            echo $name;
            ?>
" id="<?php 
            echo $name;
            ?>
"
                       value="<?php 
            echo esc_attr(stripslashes($value));
            ?>
" type="text" class="geodir_textfield"/>
                <span class="geodir_message_note"><?php 
            _e($admin_desc, 'geodirectory');
            ?>
</span>
                <?php 
            if ($is_required) {
                ?>
                    <span class="geodir_message_error"><?php 
                _e($required_msg, 'geodirectory');
                ?>
</span>
                <?php 
            }
            ?>
            </div>

        <?php 
        } elseif ($type == 'phone') {
            if ($value == $val['default']) {
                $value = '';
            }
            ?>

            <div id="<?php 
            echo $name;
            ?>
_row"
                 class="<?php 
            if ($is_required) {
                echo 'required_field';
            }
            ?>
 geodir_form_row clearfix">
                <label>
                    <?php 
            $site_title = __($site_title, 'geodirectory');
            echo trim($site_title) ? $site_title : '&nbsp;';
            ?>
                    <?php 
            if ($is_required) {
                echo '<span>*</span>';
            }
            ?>
                </label>
                <input field_type="<?php 
            echo $type;
            ?>
" name="<?php 
            echo $name;
            ?>
" id="<?php 
            echo $name;
            ?>
"
                       value="<?php 
            echo esc_attr(stripslashes($value));
            ?>
" type="text" class="geodir_textfield"/>
                <span class="geodir_message_note"><?php 
            _e($admin_desc, 'geodirectory');
            ?>
</span>
                <?php 
            if ($is_required) {
                ?>
                    <span class="geodir_message_error"><?php 
                _e($required_msg, 'geodirectory');
                ?>
</span>
                <?php 
            }
            ?>
            </div>

        <?php 
        } elseif ($type == 'url') {
            if ($value == $val['default']) {
                $value = '';
            }
            ?>

            <div id="<?php 
            echo $name;
            ?>
_row"
                 class="<?php 
            if ($is_required) {
                echo 'required_field';
            }
            ?>
 geodir_form_row clearfix">
                <label>
                    <?php 
            $site_title = __($site_title, 'geodirectory');
            echo trim($site_title) ? $site_title : '&nbsp;';
            ?>
                    <?php 
            if ($is_required) {
                echo '<span>*</span>';
            }
            ?>
                </label>
                <input field_type="<?php 
            echo $type;
            ?>
" name="<?php 
            echo $name;
            ?>
" id="<?php 
            echo $name;
            ?>
"
                       value="<?php 
            echo esc_attr(stripslashes($value));
            ?>
" type="text" class="geodir_textfield"/>
                <span class="geodir_message_note"><?php 
            _e($admin_desc, 'geodirectory');
            ?>
</span>
                <?php 
            if ($is_required) {
                ?>
                    <span class="geodir_message_error"><?php 
                _e($required_msg, 'geodirectory');
                ?>
</span>
                <?php 
            }
            ?>
            </div>

        <?php 
        } elseif ($type == 'radio') {
            ?>
            <div id="<?php 
            echo $name;
            ?>
_row"
                 class="<?php 
            if ($is_required) {
                echo 'required_field';
            }
            ?>
 geodir_form_row clearfix">
                <label>
                    <?php 
            $site_title = __($site_title, 'geodirectory');
            echo trim($site_title) ? $site_title : '&nbsp;';
            ?>
                    <?php 
            if ($is_required) {
                echo '<span>*</span>';
            }
            ?>
                </label>

                <?php 
            if ($option_values) {
                $option_values_arr = explode(',', $option_values);
                for ($i = 0; $i < count($option_values_arr); $i++) {
                    if (strstr($option_values_arr[$i], "/")) {
                        $radio_attr = explode("/", $option_values_arr[$i]);
                        $radio_lable = ucfirst($radio_attr[0]);
                        $radio_value = $radio_attr[1];
                    } else {
                        $radio_lable = ucfirst($option_values_arr[$i]);
                        $radio_value = $option_values_arr[$i];
                    }
                    ?>

                        <input name="<?php 
                    echo $name;
                    ?>
" id="<?php 
                    echo $name;
                    ?>
" <?php 
                    if ($radio_value == $value) {
                        echo 'checked="checked"';
                    }
                    ?>
  value="<?php 
                    echo $radio_value;
                    ?>
" class="gd-checkbox" field_type="<?php 
                    echo $type;
                    ?>
"
                               type="radio"  /><?php 
                    _e($radio_lable);
                    ?>

                    <?php 
                }
            }
            ?>
                <span class="geodir_message_note"><?php 
            _e($admin_desc, 'geodirectory');
            ?>
</span>
                <?php 
            if ($is_required) {
                ?>
                    <span class="geodir_message_error"><?php 
                _e($required_msg, 'geodirectory');
                ?>
</span>
                <?php 
            }
            ?>
            </div>

        <?php 
        } elseif ($type == 'checkbox') {
            ?>

            <div id="<?php 
            echo $name;
            ?>
_row"
                 class="<?php 
            if ($is_required) {
                echo 'required_field';
            }
            ?>
 geodir_form_row clearfix">
                <label>
                    <?php 
            $site_title = __($site_title, 'geodirectory');
            echo trim($site_title) ? $site_title : '&nbsp;';
            ?>
                    <?php 
            if ($is_required) {
                echo '<span>*</span>';
            }
            ?>
                </label>
                <?php 
            if ($value != '1') {
                $value = '0';
            }
            ?>
                <input type="hidden" name="<?php 
            echo $name;
            ?>
" id="<?php 
            echo $name;
            ?>
" value="<?php 
            echo esc_attr($value);
            ?>
"/>
                <input  <?php 
            if ($value == '1') {
                echo 'checked="checked"';
            }
            ?>
  value="1" class="gd-checkbox" field_type="<?php 
            echo $type;
            ?>
" type="checkbox"
                     onchange="if(this.checked){jQuery('#<?php 
            echo $name;
            ?>
').val('1');} else{ jQuery('#<?php 
            echo $name;
            ?>
').val('0');}"/>
                <span class="geodir_message_note"><?php 
            _e($admin_desc, 'geodirectory');
            ?>
</span>
                <?php 
            if ($is_required) {
                ?>
                    <span class="geodir_message_error"><?php 
                _e($required_msg, 'geodirectory');
                ?>
</span>
                <?php 
            }
            ?>
            </div>

        <?php 
        } elseif ($type == 'textarea') {
            ?>

            <div id="<?php 
            echo $name;
            ?>
_row"
                 class="<?php 
            if ($is_required) {
                echo 'required_field';
            }
            ?>
 geodir_form_row clearfix">
                <label>
                    <?php 
            $site_title = __($site_title, 'geodirectory');
            echo trim($site_title) ? $site_title : '&nbsp;';
            ?>
                    <?php 
            if ($is_required) {
                echo '<span>*</span>';
            }
            ?>
                </label><?php 
            if (is_array($extra_fields) && in_array('1', $extra_fields)) {
                $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
                ?>

                <div class="editor" field_id="<?php 
                echo $name;
                ?>
" field_type="editor">
                    <?php 
                wp_editor(stripslashes($value), $name, $editor_settings);
                ?>
                    </div><?php 
            } else {
                ?>
<textarea field_type="<?php 
                echo $type;
                ?>
" class="geodir_textarea" name="<?php 
                echo $name;
                ?>
"
                                id="<?php 
                echo $name;
                ?>
"><?php 
                echo stripslashes($value);
                ?>
</textarea><?php 
            }
            ?>


                <span class="geodir_message_note"><?php 
            _e($admin_desc, 'geodirectory');
            ?>
</span>
                <?php 
            if ($is_required) {
                ?>
                    <span class="geodir_message_error"><?php 
                _e($required_msg, 'geodirectory');
                ?>
</span>
                <?php 
            }
            ?>
            </div>

        <?php 
        } elseif ($type == 'select') {
            ?>
            <div id="<?php 
            echo $name;
            ?>
_row"
                 class="<?php 
            if ($is_required) {
                echo 'required_field';
            }
            ?>
 geodir_form_row geodir_custom_fields clearfix">
                <label>
                    <?php 
            $site_title = __($site_title, 'geodirectory');
            echo trim($site_title) ? $site_title : '&nbsp;';
            ?>
                    <?php 
            if ($is_required) {
                echo '<span>*</span>';
            }
            ?>
                </label>
                <?php 
            $option_values_arr = geodir_string_values_to_options($option_values);
            $select_options = '';
            if (!empty($option_values_arr)) {
                foreach ($option_values_arr as $option_row) {
                    if (isset($option_row['optgroup']) && ($option_row['optgroup'] == 'start' || $option_row['optgroup'] == 'end')) {
                        $option_label = isset($option_row['label']) ? $option_row['label'] : '';
                        $select_options .= $option_row['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>';
                    } else {
                        $option_label = isset($option_row['label']) ? $option_row['label'] : '';
                        $option_value = isset($option_row['value']) ? $option_row['value'] : '';
                        $selected = $option_value == $value ? 'selected="selected"' : '';
                        $select_options .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
                    }
                }
            }
            ?>
                <select field_type="<?php 
            echo $type;
            ?>
" name="<?php 
            echo $name;
            ?>
" id="<?php 
            echo $name;
            ?>
"
                        class="geodir_textfield textfield_x chosen_select"
                        data-placeholder="<?php 
            echo __('Choose', 'geodirectory') . ' ' . $site_title . '&hellip;';
            ?>
"
                        option-ajaxchosen="false"><?php 
            echo $select_options;
            ?>
</select>
                <span class="geodir_message_note"><?php 
            _e($admin_desc, 'geodirectory');
            ?>
</span>
                <?php 
            if ($is_required) {
                ?>
                    <span class="geodir_message_error"><?php 
                _e($required_msg, 'geodirectory');
                ?>
</span>
                <?php 
            }
            ?>
            </div>

        <?php 
        } else {
            if ($type == 'multiselect') {
                $multi_display = 'select';
                if (!empty($val['extra_fields'])) {
                    $multi_display = unserialize($val['extra_fields']);
                }
                ?>
            <div id="<?php 
                echo $name;
                ?>
_row"
                 class="<?php 
                if ($is_required) {
                    echo 'required_field';
                }
                ?>
 geodir_form_row clearfix">
                <label>
                    <?php 
                $site_title = __($site_title, 'geodirectory');
                echo trim($site_title) ? $site_title : '&nbsp;';
                ?>
                    <?php 
                if ($is_required) {
                    echo '<span>*</span>';
                }
                ?>
                </label>
                <input type="hidden" name="gd_field_<?php 
                echo $name;
                ?>
" value="1"/>
                <?php 
                if ($multi_display == 'select') {
                    ?>
                <div class="geodir_multiselect_list">
                    <select field_type="<?php 
                    echo $type;
                    ?>
" name="<?php 
                    echo $name;
                    ?>
[]" id="<?php 
                    echo $name;
                    ?>
"
                            multiple="multiple" class="geodir_textfield textfield_x chosen_select"
                            data-placeholder="<?php 
                    _e('Select', 'geodirectory');
                    ?>
"
                            option-ajaxchosen="false">
                        <?php 
                } else {
                    echo '<ul class="gd_multi_choice">';
                }
                $option_values_arr = geodir_string_values_to_options($option_values);
                $select_options = '';
                if (!empty($option_values_arr)) {
                    foreach ($option_values_arr as $option_row) {
                        if (isset($option_row['optgroup']) && ($option_row['optgroup'] == 'start' || $option_row['optgroup'] == 'end')) {
                            $option_label = isset($option_row['label']) ? $option_row['label'] : '';
                            if ($multi_display == 'select') {
                                $select_options .= $option_row['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>';
                            } else {
                                $select_options .= $option_row['optgroup'] == 'start' ? '<li>' . $option_label . '</li>' : '';
                            }
                        } else {
                            $option_label = isset($option_row['label']) ? $option_row['label'] : '';
                            $option_value = isset($option_row['value']) ? $option_row['value'] : '';
                            $selected = $option_value == $value ? 'selected="selected"' : '';
                            $selected = '';
                            $checked = '';
                            if (!is_array($value) && trim($value) != '' || is_array($value) && !empty($value)) {
                                if (!is_array($value)) {
                                    $value_array = explode(',', $value);
                                } else {
                                    $value_array = $value;
                                }
                                if (is_array($value_array)) {
                                    if (in_array($option_value, $value_array)) {
                                        $selected = 'selected="selected"';
                                        $checked = 'checked="checked"';
                                    }
                                }
                            }
                            if ($multi_display == 'select') {
                                $select_options .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
                            } else {
                                $select_options .= '<li><input name="' . $name . '[]" ' . $checked . ' value="' . esc_attr($option_value) . '" class="gd-' . $multi_display . '" field_type="' . $multi_display . '" type="' . $multi_display . '" />&nbsp;' . $option_label . ' </li>';
                            }
                        }
                    }
                }
                echo $select_options;
                if ($multi_display == 'select') {
                    ?>
</select></div>
            <?php 
                } else {
                    ?>
</ul><?php 
                }
                ?>
                <span class="geodir_message_note"><?php 
                _e($admin_desc, 'geodirectory');
                ?>
</span>
                <?php 
                if ($is_required) {
                    ?>
                    <span class="geodir_message_error"><?php 
                    _e($required_msg, 'geodirectory');
                    ?>
</span>
                <?php 
                }
                ?>
            </div>
        <?php 
            } else {
                if ($type == 'html') {
                    ?>

            <div id="<?php 
                    echo $name;
                    ?>
_row"
                 class="<?php 
                    if ($is_required) {
                        echo 'required_field';
                    }
                    ?>
 geodir_form_row clearfix">
                <label>
                    <?php 
                    $site_title = __($site_title, 'geodirectory');
                    echo trim($site_title) ? $site_title : '&nbsp;';
                    ?>
                    <?php 
                    if ($is_required) {
                        echo '<span>*</span>';
                    }
                    ?>
                </label>

                <?php 
                    $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
                    ?>

                <div class="editor" field_id="<?php 
                    echo $name;
                    ?>
" field_type="editor">
                    <?php 
                    wp_editor(stripslashes($value), $name, $editor_settings);
                    ?>
                </div>

                <span class="geodir_message_note"><?php 
                    _e($admin_desc, 'geodirectory');
                    ?>
</span>
                <?php 
                    if ($is_required) {
                        ?>
                    <span class="geodir_message_error"><?php 
                        _e($required_msg, 'geodirectory');
                        ?>
</span>
                <?php 
                    }
                    ?>

            </div>
        <?php 
                } elseif ($type == 'datepicker') {
                    if ($extra_fields['date_format'] == '') {
                        $extra_fields['date_format'] = 'yy-mm-dd';
                    }
                    $search = array('dd', 'mm', 'yy');
                    $replace = array('d', 'm', 'Y');
                    $date_format = str_replace($search, $replace, $extra_fields['date_format']);
                    if ($value && !isset($_REQUEST['backandedit'])) {
                        $time = strtotime($value);
                        $value = date($date_format, $time);
                    }
                    ?>
            <script type="text/javascript">

                jQuery(function () {

                    jQuery("#<?php 
                    echo $name;
                    ?>
").datepicker({changeMonth: true, changeYear: true,});

                    jQuery("#<?php 
                    echo $name;
                    ?>
").datepicker("option", "dateFormat", '<?php 
                    echo $extra_fields['date_format'];
                    ?>
');

                    <?php 
                    if (!empty($value)) {
                        ?>
                    jQuery("#<?php 
                        echo $name;
                        ?>
").datepicker("setDate", "<?php 
                        echo $value;
                        ?>
");
                    <?php 
                    }
                    ?>

                });

            </script>
            <div id="<?php 
                    echo $name;
                    ?>
_row"
                 class="<?php 
                    if ($is_required) {
                        echo 'required_field';
                    }
                    ?>
 geodir_form_row clearfix">
                <label>

                    <?php 
                    $site_title = __($site_title, 'geodirectory');
                    echo trim($site_title) ? $site_title : '&nbsp;';
                    ?>
                    <?php 
                    if ($is_required) {
                        echo '<span>*</span>';
                    }
                    ?>
                </label>

                <input field_type="<?php 
                    echo $type;
                    ?>
" name="<?php 
                    echo $name;
                    ?>
" id="<?php 
                    echo $name;
                    ?>
"
                       value="<?php 
                    echo esc_attr($value);
                    ?>
" type="text" class="geodir_textfield"/>

                <span class="geodir_message_note"><?php 
                    _e($admin_desc, 'geodirectory');
                    ?>
</span>
                <?php 
                    if ($is_required) {
                        ?>
                    <span class="geodir_message_error"><?php 
                        _e($required_msg, 'geodirectory');
                        ?>
</span>
                <?php 
                    }
                    ?>
            </div>

        <?php 
                } elseif ($type == 'time') {
                    if ($value != '') {
                        $value = date('H:i', strtotime($value));
                    }
                    ?>
            <script type="text/javascript">
                jQuery(document).ready(function () {

                    jQuery('#<?php 
                    echo $name;
                    ?>
').timepicker({
                        showPeriod: true,
                        showLeadingZero: true,
                        showPeriod: true,
                    });
                });
            </script>
            <div id="<?php 
                    echo $name;
                    ?>
_row"
                 class="<?php 
                    if ($is_required) {
                        echo 'required_field';
                    }
                    ?>
 geodir_form_row clearfix">
                <label>

                    <?php 
                    $site_title = __($site_title, 'geodirectory');
                    echo trim($site_title) ? $site_title : '&nbsp;';
                    ?>
                    <?php 
                    if ($is_required) {
                        echo '<span>*</span>';
                    }
                    ?>
                </label>
                <input readonly="readonly" field_type="<?php 
                    echo $type;
                    ?>
" name="<?php 
                    echo $name;
                    ?>
"
                       id="<?php 
                    echo $name;
                    ?>
" value="<?php 
                    echo esc_attr($value);
                    ?>
" type="text" class="geodir_textfield"/>

                <span class="geodir_message_note"><?php 
                    _e($admin_desc, 'geodirectory');
                    ?>
</span>
                <?php 
                    if ($is_required) {
                        ?>
                    <span class="geodir_message_error"><?php 
                        _e($required_msg, 'geodirectory');
                        ?>
</span>
                <?php 
                    }
                    ?>
            </div>

        <?php 
                } elseif ($type == 'taxonomy') {
                    if ($value == $val['default']) {
                        $value = '';
                    }
                    ?>
            <div id="<?php 
                    echo $name;
                    ?>
_row"
                 class="<?php 
                    if ($is_required) {
                        echo 'required_field';
                    }
                    ?>
 geodir_form_row clearfix">
                <label>
                    <?php 
                    $site_title = __($site_title, 'geodirectory');
                    echo trim($site_title) ? $site_title : '&nbsp;';
                    ?>
                    <?php 
                    if ($is_required) {
                        echo '<span>*</span>';
                    }
                    ?>
                </label>

                <div id="<?php 
                    echo $name;
                    ?>
" class="geodir_taxonomy_field" style="float:left; width:70%;">
                    <?php 
                    global $wpdb, $post, $cat_display, $post_cat, $package_id, $exclude_cats;
                    $exclude_cats = array();
                    if ($is_admin == '1') {
                        $post_type = get_post_type();
                        $package_info = array();
                        $package_info = (array) geodir_post_package_info($package_info, $post, $post_type);
                        if (!empty($package_info)) {
                            if (isset($package_info['cat']) && $package_info['cat'] != '') {
                                $exclude_cats = explode(',', $package_info['cat']);
                            }
                        }
                    }
                    $cat_display = unserialize($val['extra_fields']);
                    if (isset($_REQUEST['backandedit']) && (is_array($post_cat[$name]) && !empty($post_cat[$name]))) {
                        $post_cat = implode(",", $post_cat[$name]);
                    } else {
                        if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
                            $post_cat = geodir_get_post_meta($_REQUEST['pid'], $name, true);
                        }
                    }
                    global $geodir_addon_list;
                    if (!empty($geodir_addon_list) && array_key_exists('geodir_payment_manager', $geodir_addon_list) && $geodir_addon_list['geodir_payment_manager'] == 'yes') {
                        $catadd_limit = $wpdb->get_var($wpdb->prepare("SELECT cat_limit FROM " . GEODIR_PRICE_TABLE . " WHERE pid = %d", array($package_id)));
                    } else {
                        $catadd_limit = 0;
                    }
                    if ($cat_display != '' && $cat_display != 'ajax_chained') {
                        $required_limit_msg = '';
                        if ($catadd_limit > 0 && $cat_display != 'select' && $cat_display != 'radio') {
                            $required_limit_msg = __('Only select', 'geodirectory') . ' ' . $catadd_limit . __(' categories for this package.', 'geodirectory');
                        } else {
                            $required_limit_msg = $required_msg;
                        }
                        echo '<input type="hidden" cat_limit="' . $catadd_limit . '" id="cat_limit" value="' . esc_attr($required_limit_msg) . '" name="cat_limit[' . $name . ']"  />';
                        if ($cat_display == 'select' || $cat_display == 'multiselect') {
                            $cat_display == '';
                            $multiple = '';
                            if ($cat_display == 'multiselect') {
                                $multiple = 'multiple="multiple"';
                            }
                            echo '<select id="' . $name . '" ' . $multiple . ' type="' . $name . '" name="post_category[' . $name . '][]" alt="' . $name . '" field_type="' . $cat_display . '" class="geodir_textfield textfield_x chosen_select" data-placeholder="' . __('Select Category', 'geodirectory') . '">';
                            if ($cat_display == 'select') {
                                echo '<option value="">' . __('Select Category', 'geodirectory') . '</option>';
                            }
                        }
                        echo geodir_custom_taxonomy_walker($name, $catadd_limit = 0);
                        if ($cat_display == 'select' || $cat_display == 'multiselect') {
                            echo '</select>';
                        }
                    } else {
                        echo geodir_custom_taxonomy_walker2($name, $catadd_limit);
                    }
                    ?>
                </div>

                <span class="geodir_message_note"><?php 
                    _e($admin_desc, 'geodirectory');
                    ?>
</span>
                <?php 
                    if ($is_required) {
                        ?>
                    <span class="geodir_message_error"><?php 
                        _e($required_msg, 'geodirectory');
                        ?>
</span>
                <?php 
                    }
                    ?>
            </div>

        <?php 
                } elseif ($type == 'file') {
                    ?>

            <?php 
                    // adjust values here
                    $file_id = $name;
                    // 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
                    if ($value != '') {
                        $file_value = trim($value, ",");
                        // this will be initial value of the above form field. Image urls.
                    } else {
                        $file_value = '';
                    }
                    if (isset($extra_fields['file_multiple']) && $extra_fields['file_multiple']) {
                        $file_multiple = true;
                    } else {
                        $file_multiple = false;
                    }
                    if (isset($extra_fields['image_limit']) && $extra_fields['image_limit']) {
                        $file_image_limit = $extra_fields['image_limit'];
                    } else {
                        $file_image_limit = 1;
                    }
                    $file_width = geodir_media_image_large_width();
                    // If you want to automatically resize all uploaded images then provide width here (in pixels)
                    $file_height = geodir_media_image_large_height();
                    // If you want to automatically resize all uploaded images then provide height here (in pixels)
                    if (!empty($file_value)) {
                        $curImages = explode(',', $file_value);
                        if (!empty($curImages)) {
                            $file_totImg = count($curImages);
                        }
                    }
                    $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types']) ? implode(",", $extra_fields['gd_file_types']) : '';
                    $display_file_types = $allowed_file_types != '' ? '.' . implode(", .", $extra_fields['gd_file_types']) : '';
                    ?>
            <?php 
                    /*?> <h5 class="geodir-form_title"> <?php echo $site_title; ?>
                    			 <?php if($file_image_limit!=0 && $file_image_limit==1 ){echo '<br /><small>('.__('You can upload').' '.$file_image_limit.' '.__('image with this package').')</small>';} ?>
                    			 <?php if($file_image_limit!=0 && $file_image_limit>1 ){echo '<br /><small>('.__('You can upload').' '.$file_image_limit.' '.__('images with this package').')</small>';} ?>
                    			 <?php if($file_image_limit==0){echo '<br /><small>('.__('You can upload unlimited images with this package').')</small>';} ?>
                    		</h5>   <?php */
                    ?>

            <div id="<?php 
                    echo $name;
                    ?>
_row"
                 class="<?php 
                    if ($is_required) {
                        echo 'required_field';
                    }
                    ?>
 geodir_form_row clearfix">

                <div id="<?php 
                    echo $file_id;
                    ?>
dropbox" align="center" style="">
                    <label
                        style="text-align:left; padding-top:10px;"><?php 
                    $site_title = __($site_title, 'geodirectory');
                    echo $site_title;
                    if ($is_required) {
                        echo '<span>*</span>';
                    }
                    ?>
</label>
                    <input class="geodir-custom-file-upload" field_type="file" type="hidden"
                           name="<?php 
                    echo $file_id;
                    ?>
" id="<?php 
                    echo $file_id;
                    ?>
"
                           value="<?php 
                    echo esc_attr($file_value);
                    ?>
"/>
                    <input type="hidden" name="<?php 
                    echo $file_id;
                    ?>
image_limit"
                           id="<?php 
                    echo $file_id;
                    ?>
image_limit" value="<?php 
                    echo $file_image_limit;
                    ?>
"/>
					<?php 
                    if ($allowed_file_types != '') {
                        ?>
					<input type="hidden" name="<?php 
                        echo $file_id;
                        ?>
_allowed_types"
                           id="<?php 
                        echo $file_id;
                        ?>
_allowed_types" value="<?php 
                        echo esc_attr($allowed_file_types);
                        ?>
" data-exts="<?php 
                        echo esc_attr($display_file_types);
                        ?>
"/>
					<?php 
                    }
                    ?>
                    <input type="hidden" name="<?php 
                    echo $file_id;
                    ?>
totImg" id="<?php 
                    echo $file_id;
                    ?>
totImg"
                           value="<?php 
                    if (isset($file_totImg)) {
                        echo esc_attr($file_totImg);
                    } else {
                        echo '0';
                    }
                    ?>
"/>

                    <div style="float:left; width:55%;">
                        <div
                            class="plupload-upload-uic hide-if-no-js <?php 
                    if ($file_multiple) {
                        ?>
plupload-upload-uic-multiple<?php 
                    }
                    ?>
"
                            id="<?php 
                    echo $file_id;
                    ?>
plupload-upload-ui" style="float:left; width:30%;">
                            <?php 
                    /*?><h4><?php _e('Drop files to upload');?></h4><br/><?php */
                    ?>
                            <input id="<?php 
                    echo $file_id;
                    ?>
plupload-browse-button" type="button"
                                   value="<?php 
                    $file_image_limit > 1 ? esc_attr_e('Select Files', 'geodirectory') : esc_attr_e('Select File', 'geodirectory');
                    ?>
"
                                   class="geodir_button" style="margin-top:10px;"/>
                            <span class="ajaxnonceplu"
                                  id="ajaxnonceplu<?php 
                    echo wp_create_nonce($file_id . 'pluploadan');
                    ?>
"></span>
                            <?php 
                    if ($file_width && $file_height) {
                        ?>
                                <span class="plupload-resize"></span>
                                <span class="plupload-width" id="plupload-width<?php 
                        echo $file_width;
                        ?>
"></span>
                                <span class="plupload-height" id="plupload-height<?php 
                        echo $file_height;
                        ?>
"></span>
                            <?php 
                    }
                    ?>
                            <div class="filelist"></div>
                        </div>
                        <div
                            class="plupload-thumbs <?php 
                    if ($file_multiple) {
                        ?>
plupload-thumbs-multiple<?php 
                    }
                    ?>
 "
                            id="<?php 
                    echo $file_id;
                    ?>
plupload-thumbs"
                            style=" clear:inherit; margin-top:0; margin-left:15px; padding-top:10px; float:left; width:50%;">
                        </div>
                        <?php 
                    /*?><span id="upload-msg" ><?php _e('Please drag &amp; drop the images to rearrange the order');?></span><?php */
                    ?>

                        <span id="<?php 
                    echo $file_id;
                    ?>
upload-error" style="display:none"></span>

                    </div>
                </div>
                <span class="geodir_message_note"><?php 
                    _e($admin_desc, 'geodirectory');
                    ?>
 <?php 
                    echo $display_file_types != '' ? __('Allowed file types:', 'geodirectory') . ' ' . $display_file_types : '';
                    ?>
</span>
                <?php 
                    if ($is_required) {
                        ?>
                    <span class="geodir_message_error"><?php 
                        _e($required_msg, 'geodirectory');
                        ?>
</span>
                <?php 
                    }
                    ?>
            </div>


        <?php 
                }
            }
        }
        /**
         * Called after the custom fields info is output for submitting a post.
         *
         * Used dynamic hook type geodir_after_custom_form_field_$name.
         *
         * @since 1.0.0
         * @param string $listing_type The post post type.
         * @param int $package_id The price package ID for the post.
         * @param array $val The settings array for the field. {@see geodir_custom_field_save()}.
         * @see 'geodir_before_custom_form_field_$name'
         */
        do_action('geodir_after_custom_form_field_' . $name, $listing_type, $package_id, $val);
    }
}
Ejemplo n.º 8
0
/**
 * 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;
}
/**
 * display rating summary on detail page sidebar.
 *
 * @since 1.0.0
 * @package GeoDirectory_Review_Rating_Manager
 *
 * @param float|int $avg_rating Average post rating.
 * @param int $post_id The post ID.
 * @return string Rating summary HTML.
 */
function geodir_reviewrating_detail_page_rating_summary($avg_rating, $post_id)
{
    $html = '';
    if (get_option('geodir_reviewrating_hide_rating_summary')) {
        return $html;
    }
    if (!empty($post_id) && $avg_rating != '') {
        $geodir_post_info = geodir_get_post_info($post_id);
        if (!empty($geodir_post_info)) {
            $post_title = $geodir_post_info->post_title;
            $post_thumbnail = '';
            $post_thumbnail_id = get_post_thumbnail_id($post_id);
            $overall_max_rating = (int) get_option('geodir_reviewrating_overall_count');
            $total_reviews = geodir_get_review_count_total($post_id);
            if ($total_reviews > 0) {
                $html .= '<div class="average-review">';
                $avg_ratings = is_float($avg_rating) || strpos($avg_rating, ".", 1) == 1 && strlen($avg_rating) > 3 ? number_format($avg_rating, 1, '.', '') : $avg_rating;
                $html .= '<span>';
                $html .= '<span class="rating">' . $avg_ratings . '</span>&nbsp;/&nbsp;<span>' . $overall_max_rating . '</span> ' . __('based on', GEODIRREVIEWRATING_TEXTDOMAIN) . '&nbsp;<span class="count">' . $total_reviews . '</span>&nbsp;';
                $html .= $total_reviews > 1 ? __('reviews', GEODIRREVIEWRATING_TEXTDOMAIN) : __('review', GEODIRREVIEWRATING_TEXTDOMAIN);
                $html .= '</span><br />';
                $html .= '<span class="item">';
                $html .= '<span class="fn">' . $post_title . '</span>';
                if ($post_thumbnail_id > 0) {
                    $attachment_image = wp_get_attachment_image_src($post_thumbnail_id, 'medium');
                    $post_thumbnail = !empty($attachment_image) && isset($attachment_image[0]) && $attachment_image[0] != '' ? $attachment_image[0] : '';
                    if ($post_thumbnail != '') {
                        $html .= '<br /><img src="' . $post_thumbnail . '" class="photo hreview-img"  alt="' . esc_attr($post_title) . '" />';
                    }
                }
                $html .= '</span>';
                $html .= '</div>';
            }
        }
    }
    $html = apply_filters('geodir_reviewrating_filter_detail_page_rating_summary', $html, $avg_rating, $post_id);
    return $html;
}
Ejemplo n.º 10
0
/**
 * Retrive markers data to use in map
 *
 * @since 1.0.0
 * @since 1.5.7 Fixed non recurring events markers.
 *
 * @global object $wpdb WordPress Database object.
 * @global string $plugin_prefix Geodirectory plugin table prefix.
 * @global array  $geodir_cat_icons Array of the category icon urls.
 * 
 * @return string
 */
function get_markers()
{
    global $wpdb, $plugin_prefix, $geodir_cat_icons;
    $search = '';
    $main_query_array;
    $srcharr = array("'", "/", "-", '"', '\\');
    $replarr = array("&prime;", "&frasl;", "&ndash;", "&ldquo;", '');
    $post_type = isset($_REQUEST['gd_posttype']) ? $_REQUEST['gd_posttype'] : 'gd_place';
    $map_cat_ids_array = array('0');
    $cat_find_array = array(" FIND_IN_SET(%d, pd." . $post_type . "category)");
    $field_default_cat = '';
    if (isset($_REQUEST['cat_id']) && $_REQUEST['cat_id'] != '') {
        $map_cat_arr = trim($_REQUEST['cat_id'], ',');
        if (!empty($map_cat_arr)) {
            $field_default_cat .= "WHEN (default_category IN (" . $map_cat_arr . ")) THEN default_category ";
            $map_cat_ids_array = explode(',', $map_cat_arr);
            $cat_find_array = array();
            foreach ($map_cat_ids_array as $cat_id) {
                $field_default_cat .= "WHEN (FIND_IN_SET({$cat_id}, `" . $post_type . "category`) > 0) THEN {$cat_id} ";
                $cat_find_array[] = " FIND_IN_SET(%d, pd." . $post_type . "category)";
                $main_query_array[] = $cat_id;
            }
        }
    }
    if (!empty($field_default_cat)) {
        $field_default_cat = '';
    }
    if (!empty($cat_find_array)) {
        $search .= "AND (" . implode(' OR ', $cat_find_array) . ")";
    }
    $main_query_array = $map_cat_ids_array;
    if (isset($_REQUEST['search']) && !empty($_REQUEST['search']) && $_REQUEST['search'] != __('Title', 'geodirectory')) {
        $search .= " AND p.post_title LIKE %s";
        $main_query_array[] = "%" . $_REQUEST['search'] . "%";
    }
    /**
     * Filter the marker query search SQL, values are replaces with %s or %d.
     *
     * @since 1.5.3
     *
     * @param string $search The SQL query for search/where.
     */
    $search = apply_filters('geodir_marker_search', $search);
    /**
     * Filter the marker query search SQL values %s and %d, this is an array of values.
     *
     * @since 1.5.3
     *
     * @param array $main_query_array The SQL query values for search/where.
     */
    $main_query_array = apply_filters('geodir_marker_main_query_array', $main_query_array);
    $gd_posttype = '';
    if (isset($_REQUEST['gd_posttype']) && $_REQUEST['gd_posttype'] != '') {
        $table = $plugin_prefix . $_REQUEST['gd_posttype'] . '_detail';
        $gd_posttype = " AND p.post_type = %s";
        $main_query_array[] = $_REQUEST['gd_posttype'];
    } else {
        $table = $plugin_prefix . 'gd_place_detail';
    }
    $join = ", " . $table . " AS pd ";
    /**
     * Filter the SQL JOIN clause for the markers data
     *
     * @since 1.0.0
     *
     * @param string $join Row of SQL JOIN clause to join table.
     */
    $join = apply_filters('geodir_home_map_listing_join', $join);
    /**
     * Filter the searched fields for the markers data
     *
     * @since 1.0.0
     *
     * @param string $search Row of searched fields to use in WHERE clause.
     */
    $search = apply_filters('geodir_home_map_listing_where', $search);
    $search = str_replace(array("'%", "%'"), array("'%%", "%%'"), $search);
    $cat_type = $post_type . 'category';
    if ($post_type == 'gd_event') {
        $event_select = ", pd.recurring_dates, pd.is_recurring";
    } else {
        $event_select = "";
    }
    $sql_select = 'SELECT pd.default_category, pd.' . $cat_type . ', pd.post_title, pd.post_id, pd.post_latitude, pd.post_longitude' . $event_select;
    /**
     * Filter the SQL SELECT clause to retrive fields data
     *
     * @since 1.0.0
     *
     * @param string $sql_select Row of SQL SELECT clause.
     */
    $select = apply_filters('geodir_home_map_listing_select', $sql_select);
    $groupby = " GROUP BY pd.post_id";
    /**
     * Filter the SQL GROUP BY clause to retrive map markers data.
     *
     * @since 1.5.7
     *
     * @param string $groupby Row of SQL GROUP BY clause.
     */
    $groupby = apply_filters('geodir_home_map_listing_groupby', $groupby);
    $catsql = $wpdb->prepare("{$select} {$field_default_cat} FROM " . $wpdb->posts . " as p" . $join . " WHERE p.ID = pd.post_id AND p.post_status = 'publish' " . $search . $gd_posttype . $groupby, $main_query_array);
    /**
     * Filter the SQL query to retrive markers data
     *
     * @since 1.0.0
     *
     * @param string $catsql Row of SQL query.
     * @param string $search Row of searched fields to use in WHERE clause.
     */
    $catsql = apply_filters('geodir_home_map_listing_query', $catsql, $search);
    $catinfo = $wpdb->get_results($catsql);
    $cat_content_info = array();
    $content_data = array();
    $post_ids = array();
    /**
     * Called before marker data is processed into JSON.
     *
     * Called before marker data is processed into JSON, this action can be used to change the format or add/remove markers.
     *
     * @since 1.5.3
     * @param object $catinfo The posts object containing all marker data.
     * @see 'geodir_after_marker_post_process'
     */
    $catinfo = apply_filters('geodir_before_marker_post_process', $catinfo);
    /**
     * Called before marker data is processed into JSON.
     *
     * Called before marker data is processed into JSON, this action can be used to change the format or add/remove markers.
     *
     * @since 1.4.9
     * @param object $catinfo The posts object containing all marker data.
     * @see 'geodir_after_marker_post_process'
     */
    do_action('geodir_before_marker_post_process_action', $catinfo);
    // Sort any posts into a ajax array
    if (!empty($catinfo)) {
        $geodir_cat_icons = geodir_get_term_icon();
        global $geodir_date_format;
        $today = strtotime(date_i18n('Y-m-d'));
        foreach ($catinfo as $catinfo_obj) {
            $post_title = $catinfo_obj->post_title;
            if ($post_type == 'gd_event' && !empty($catinfo_obj->recurring_dates)) {
                $event_dates = '';
                $recurring_data = isset($catinfo_obj->recurring_dates) ? maybe_unserialize($catinfo_obj->recurring_dates) : array();
                $post_info = geodir_get_post_info($catinfo_obj->post_id);
                if (!empty($catinfo_obj->is_recurring) && !empty($recurring_data) && !empty($recurring_data['is_recurring']) && geodir_event_recurring_pkg($post_info)) {
                    $recurring_dates = explode(',', $recurring_data['event_recurring_dates']);
                    if (!empty($recurring_dates)) {
                        $e = 0;
                        foreach ($recurring_dates as $date) {
                            if (strtotime($date) >= $today) {
                                $event_dates .= ' :: ' . date_i18n($geodir_date_format, strtotime($date));
                                $e++;
                                if ($e == 3) {
                                    // only show 3 event dates
                                    break;
                                }
                            }
                        }
                    }
                } else {
                    $start_date = !empty($recurring_data['event_start']) && $recurring_data['event_start'] != '0000-00-00 00:00:00' ? $recurring_data['event_start'] : '';
                    $end_date = !empty($recurring_data['event_end']) && $recurring_data['event_end'] != '0000-00-00 00:00:00' ? $recurring_data['event_end'] : $start_date;
                    if ($end_date != '' && strtotime($end_date) >= $today) {
                        $event_dates .= ' :: ' . date_i18n($geodir_date_format, strtotime($start_date)) . ' -> ' . date_i18n($geodir_date_format, strtotime($end_date));
                    }
                }
                if (empty($event_dates)) {
                    continue;
                }
                $post_title .= $event_dates;
            }
            $icon = !empty($geodir_cat_icons) && isset($geodir_cat_icons[$catinfo_obj->default_category]) ? $geodir_cat_icons[$catinfo_obj->default_category] : '';
            $mark_extra = isset($catinfo_obj->marker_extra) ? $catinfo_obj->marker_extra : '';
            $title = str_replace($srcharr, $replarr, $post_title);
            $content_data[] = '{"id":"' . $catinfo_obj->post_id . '","t": "' . $title . '","lt": "' . $catinfo_obj->post_latitude . '","ln": "' . $catinfo_obj->post_longitude . '","mk_id":"' . $catinfo_obj->post_id . '_' . $catinfo_obj->default_category . '","i":"' . $icon . '"' . $mark_extra . '}';
            $post_ids[] = $catinfo_obj->post_id;
        }
    }
    /**
     * Called after marker data is processed into JSON.
     *
     * Called after marker data is processed into JSON, this action can be used to change the format or add/remove markers.
     *
     * @since 1.4.9
     * @param array $content_data The array containing all markers in JSON format.
     * @param object $catinfo The posts object containing all marker data.
     * @see 'geodir_before_marker_post_process'
     */
    do_action('geodir_after_marker_post_process', $content_data, $catinfo);
    if (!empty($content_data)) {
        $cat_content_info[] = implode(',', $content_data);
    }
    $totalcount = count(array_unique($post_ids));
    if (!empty($cat_content_info)) {
        return '[{"totalcount":"' . $totalcount . '",' . substr(implode(',', $cat_content_info), 1) . ']';
    } else {
        return '[{"totalcount":"0"}]';
    }
}
/**
 * Adds google rich snippets.
 *
 * @since 1.0.0
 * @package GeoDirectory_Review_Rating_Manager
 */
function geodir_review_rating_reviews_rich_snippets()
{
    if (geodir_is_geodir_page() && geodir_is_page('detail')) {
        $post_id = get_the_ID();
        $geodir_post_info = geodir_get_post_info($post_id);
        if (!empty($geodir_post_info)) {
            $post_title = $geodir_post_info->post_title;
            $post_thumbnail = '';
            $post_thumbnail_id = get_post_thumbnail_id($post_id);
            $max_rating = get_option('geodir_reviewrating_overall_count');
            $average_rating = geodir_get_commentoverall_number($post_id);
            $total_reviews = geodir_get_review_count_total($post_id);
            if ($total_reviews > 0) {
                if ($post_thumbnail_id > 0) {
                    $attachment_image = wp_get_attachment_image_src($post_thumbnail_id, 'post-thumbnail');
                    $post_thumbnail = !empty($attachment_image) && isset($attachment_image[0]) && $attachment_image[0] != '' ? $attachment_image[0] : '';
                }
                $content = '';
                $content .= '<div style="height:0;width:0;margin:0;padding:0" itemscope itemtype="http://data-vocabulary.org/Review-aggregate">';
                $content .= '<meta itemprop="itemreviewed" content="' . esc_attr($post_title) . '" />';
                if ($post_thumbnail != '') {
                    $content .= '<meta itemprop="photo" content="' . $post_thumbnail . '" />';
                }
                $content .= '<div itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating">';
                $content .= '<meta itemprop="average" content="' . $average_rating . '" />';
                $content .= '<meta itemprop="best" content="' . $max_rating . '" />';
                $content .= '</div>';
                $content .= '<meta itemprop="count" content="' . $total_reviews . '" />';
                $content .= '</div>';
                echo $content;
            }
        }
    }
}