/** * Sets a key and value in $wp object if the current page is a geodir page. * * @since 1.0.0 * @package GeoDirectory * @param object $wp WordPress object. */ function geodir_set_is_geodir_page($wp) { if (!is_admin()) { //$wp->query_vars['gd_is_geodir_page'] = false; //print_r() if (empty($wp->query_vars) || !array_diff(array_keys($wp->query_vars), array('preview', 'page', 'paged', 'cpage'))) { if (get_option('geodir_set_as_home')) { $wp->query_vars['gd_is_geodir_page'] = true; } } if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['page_id'])) { if ($wp->query_vars['page_id'] == geodir_add_listing_page_id() || $wp->query_vars['page_id'] == geodir_preview_page_id() || $wp->query_vars['page_id'] == geodir_success_page_id() || $wp->query_vars['page_id'] == geodir_location_page_id()) { $wp->query_vars['gd_is_geodir_page'] = true; } } if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['pagename'])) { $page = get_page_by_path($wp->query_vars['pagename']); if (!empty($page) && ($page->ID == geodir_add_listing_page_id() || $page->ID == geodir_preview_page_id() || $page->ID == geodir_success_page_id() || $page->ID == geodir_location_page_id())) { $wp->query_vars['gd_is_geodir_page'] = true; } } if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') { $requested_post_type = $wp->query_vars['post_type']; // check if this post type is geodirectory post types $post_type_array = geodir_get_posttypes(); if (in_array($requested_post_type, $post_type_array)) { $wp->query_vars['gd_is_geodir_page'] = true; } } if (!isset($wp->query_vars['gd_is_geodir_page'])) { $geodir_taxonomis = geodir_get_taxonomies('', true); foreach ($geodir_taxonomis as $taxonomy) { if (array_key_exists($taxonomy, $wp->query_vars)) { $wp->query_vars['gd_is_geodir_page'] = true; break; } } } if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['author_name']) && isset($_REQUEST['geodir_dashbord'])) { $wp->query_vars['gd_is_geodir_page'] = true; } if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($_REQUEST['geodir_search'])) { $wp->query_vars['gd_is_geodir_page'] = true; } //echo $wp->query_vars['gd_is_geodir_page'] ; /*echo "<pre>" ; print_r($wp) ; echo "</pre>" ; // exit(); */ } // end of is admin }
/** * 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 & 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(); }