Function Reference: geodir_action_add_listing_form

Summary

Outputs the add listing form HTML content.

Description

Other things are needed to output a working add listing form, you should use the add listing shortcode if needed.

Global Values

$current_user
(object) (required) Current user object.

Default: None
$post
(object) (required) The current post object.

Default: None
$post_images
(object) (required) Image objects of current post if available.

Default: None
$gd_session
(object) (required) GeoDirectory Session object.

Default: None

Package

GeoDirectory

Change Log

Since: 1.0.0

Actions

‘geodir_before_detail_fields’ [Line: 2239]

‘geodir_before_main_form_fields’ [Line: 2250]

‘geodir_before_description_field’ [Line: 2317]

‘geodir_after_description_field’ [Line: 2358]

‘geodir_before_listing_tags_field’ [Line: 2397]

‘geodir_after_listing_tags_field’ [Line: 2415]

‘geodir_after_main_form_fields’ [Line: 2535]

Filters

‘geodir_add_listing_title_label’ [Line: 2262]

‘geodir_description_field_show_editor’ [Line: 2279]

‘geodir_description_field_desc_limit’ [Line: 2289]

‘geodir_description_field_desc’ [Line: 2297]

‘geodir_description_field_desc_limit_msg’ [Line: 2308]

‘geodir_add_listing_description_label’ [Line: 2334]

‘geodir_listing_tags_field_tags_count’ [Line: 2370]

‘geodir_listing_tags_field_tags’ [Line: 2380]

‘geodir_listing_tags_field_tags_msg’ [Line: 2388]

‘geodir_image_uploader_on_add_listing’ [Line: 2479]

Source File

geodir_action_add_listing_form() is located in geodirectory_template_actions.php [Line: 2164]

Source Code

function geodir_action_add_listing_form()
{
    global $cat_display, $post_cat, $current_user, $gd_session;
    $page_id = get_the_ID();
    $post = '';
    $title = '';
    $desc = '';
    $kw_tags = '';
    $required_msg = '';
    $submit_button = '';

    $ajax_action = isset($_REQUEST['ajax_action']) ? $_REQUEST['ajax_action'] : 'add';

    $thumb_img_arr = array();
    $curImages = '';

    if (isset($_REQUEST['backandedit'])) {
        global $post;
        $post = (object)$gd_session->get('listing');
        $listing_type = $post->listing_type;
        $title = $post->post_title;
        $desc = $post->post_desc;
        $post_cat = isset($post->post_category) ? $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;

        $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;
        $kw_tags = $post->post_tags;
        $kw_tags = implode(",", wp_get_object_terms($post->ID, $listing_type . '_tags', array('fields' => 'names')));
    } else {
        $listing_type = sanitize_text_field($_REQUEST['listing_type']);
    }

    if ($current_user->ID != '0') {
        $user_login = true;
    }

    $post_type_info = geodir_get_posttype_info($listing_type);

    $cpt_singular_name = (isset($post_type_info['labels']['singular_name']) && $post_type_info['labels']['singular_name']) ? __($post_type_info['labels']['singular_name'], 'geodirectory') : __('Listing','geodirectory');
    
    $package_info = array();
    $package_info = geodir_post_package_info($package_info, $post);
    ?>
    
0) { /** * Called on the add listing page form for frontend just before the description field. * * @since 1.0.0 */ do_action('geodir_before_description_field'); $desc_class = ' required_field'; } else { $desc_class = ' hidden'; } ?>
false, 'textarea_rows' => 10); ?>
0) { /** * Called on the add listing page form for frontend just after the description field. * * @since 1.0.0 */ do_action('geodir_after_description_field'); } $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); $tags_class = ''; if ($kw_tags_count === '' || (int)$kw_tags_count > 0) { /** * 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'); } else { $tags_class = ' hidden'; } ?>
0) { /** * 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'); } $package_info = array(); $package_info = geodir_post_package_info($package_info, $post); geodir_get_custom_fields_html($package_info->pid, 'all', $listing_type); // 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)$gd_session->get('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((int)$_REQUEST['pid']); $listing_type = $post->post_type; $thumb_img_arr = geodir_get_images($_REQUEST['pid']); } else { $listing_type = sanitize_text_field($_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; // this will be initial value of the above form field. Image urls. else $svalue = ''; $image_limit = isset($package_info->image_limit) ? $package_info->image_limit : '0'; $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) { ?>
(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')'; } ?> 1) { echo '
(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')'; } ?> (' . __('You can upload unlimited images with this package', 'geodirectory') . ')'; } ?>


/>