The submit page property is actually composed on 7 submit templates, each named after the data submitted. We have Description, Price, Images, Details, Location, Amenities and Calendar.

For each of these pages the submission is made via an ajax mechanism, meaning that when you hit the save button the data inserted is read by a JavaScript and forwarded to a php function what will do the save without page reloading(except on Description – when user is logged in).

For example on the Description page, which is actually the first page of the submission process:

The html form is located in templates/submit_templates/property_description_first.php.

Please note that if the user is logged in we will use the classic submit via $_POST, if not we will use an ajax submission


<?php if ( is_user_logged_in() ) { ?>
<form id="new_post" name="new_post" method="post" action="" enctype="multipart/form-data" class="add-estate">
<?php }else{ ?>
<div id="new_post" class="add-estate">
<?php } ?>

You have the “Continue” button which in the beginning is deactivated. When you introduce all the required information the button will become active. This check and activate behavior happens only on the “Description” part.

The checks that enable the “Continue” buttons are in ajaxcalls_add.js around line 288 in the function submit_change() {

Note: The same files and scripts are used for the front end submit page, when the user is not logged in. The only difference is that if the user is not logged in we will open a modal window where we ask to login or register.

We get back on the saving process…

As we said , once the “Continue” button is enabled you can click it and trigger the save action. The Javascript action is in ajaxcalls.js around line 6


$('#form_submit_1').click(function () {
if( !$(this).hasClass('externalsubmit') ){
return;
}
var ajaxurl,title,prop_category,prop_action_category,property_city,property_area_front,property_country,property_description,guest_no,new_estate;
title = jQuery('#title').val();

 

In there we read the info submited by the user and send that data to the php function wpestate_ajax_front_end_submit(). – the function is located in ajax_functions_edit.php at line 5


if( !function_exists('wpestate_ajax_front_end_submit') ):
function wpestate_ajax_front_end_submit(){
$allowed_html = array();
if( !isset($_POST['title']) || $_POST['title']=='') {
exit('1');
}

 

In these functions, we do some data validation and if everything checks up we inserted the new custom post(the new property)

$post = array(
'post_title' => $submit_title,
'post_status' => $new_status,
'post_type' => 'estate_property' ,
'post_author' => $new_user_id ,
'post_content' => $property_description
);
$post_id = wp_insert_post($post );

 

After we insert the post we assign it to various taxonomies (read categories) like category, city, area etc.


if( isset($prop_category->name) ){
wp_set_object_terms($post_id,$prop_category->name,'property_category');
}

 

After that, we print the new post _id and return to javascript function.

The rest of the submission/ editing the process is all ajax based

Price

the html form is located in templates/submit_templates/property_price.php

JavaScript code is in ajaxcalls_add.js at line 758 and the php function is wpestate_ajax_update_listing_price() in ajax_functions_edit() at line 715


$('#edit_prop_price').click(function () {

 

Images

the html form is located in templates/submit_templates/property_images.php

JavaScript code is in ajaxcalls_add.js at line 719 and the php function is wpestate_ajax_update_listing_images() in ajax_functions_edit() at line 615


$('#edit_prop_image').click(function () {...

 

Details

the html form is located in templates/submit_templates/property_details.php

JavaScript code is in ajaxcalls_add.js at line 672 and the php function is wpestate_ajax_update_listing_details() in ajax_functions_edit() at line 550


$('#edit_prop_details').click(function () {

 

Location

the html form is located in templates/submit_templates/property_location.php

JavaScript code is in ajaxcalls_add.js at line 588 and the php function is wpestate_ajax_update_listing_location() in ajax_functions_edit() at line 455


$('#edit_prop_locations').click(function () {

 

Amenities

the html form is located in templates/submit_templates/property_amenities.php

JavaScript code is in ajaxcalls_add.js at line 550 and the php function is wpestate_ajax_update_listing_ammenities() in ajax_functions_edit() at line 400


$('#edit_prop_ammenities').click(function () {

 

Calendar

the html form is located in templates/submit_templates/property_calendar.php

JavaScript code is in ajaxcalls_add.js at line 635 and the php function is wpestate_ajax_update_ical_feed() in ajax_functions_edit() at line 506

$('#edit_calendar').click(function () {

 

Allow HTML in the description editor in front end submission

For security reasons, the theme cannot allow for html to be added in front end submit. This is a mandatory requirement imposed by Envato market.

However, to make it easier for clients, we added the code needed for HTML to exist. It’s commented by default, but all you have to do is comment on the active code and remove the comment from the code that allows HTML, as detailed in this screenshot.

wprentals/libs/ajax_functions_edit.php

ORIGINAL CODE

MODIFIED CODE TO ALLOW HTML