Adding a review.

After the booking period has passed(the user that rent the property stay in that property) a “Post review ” button will appear on the properties listed in “My Reservation” page. The html code for this button is located in book-listing-user-unit.php

if(strtotime($booking_to_date) < time() ){
if ( get_post_meta($booking_id,'review_by_'.$userID,true) != 'has' ){
print '<span class="tag-post-review post_review" data-listing-review="'.$booking_id.'">'.esc_html__( 'Post Review','wpestate').'</span>';
print '<span class="tag-published">'.esc_html__( 'You already reviewed this property!','wpestate').'</span>';
print '<span class="tag-published">'.esc_html__( 'You can post the review after the trip!','wpestate').'</span>';

The actual posting of the review is made via Ajax with the javascript event located in js/dashboard-control.js  in function create_review_action().  Once we read the info inserted by the user (stars & comment) we send that data to php function wpestate_post_review located in in ajax_functions_booking.php at line 1540 .  In there we get the data sent by javascript as POST variables and insert the review.

The review is actually a comment for the property custom post type, while the stars are saved as comment meta.

$comment_id = wp_insert_comment($data);
add_comment_meta( $comment_id, 'review_stars',$stars );

The reviews that are displayed on owner page are located in file owner_details_header.php . We get the review data via function wpestate_review_composer() located in help_functions.php at line 93

$comments_data      =   wpestate_review_composer($agent_id);


The reviews that are displayed on property page(both template styles)  are located in file listing_reviews.php