function wpestate_populate_columns($column) { if ('estate_status' == $column) { $estate_status = get_post_status(get_the_ID()); if ($estate_status == 'publish') { echo esc_html__('published', 'wpestate'); } else { echo $estate_status; } $pay_status = get_post_meta(get_the_ID(), 'pay_status', true); if ($pay_status != '') { echo " | " . $pay_status; } } if ('estate_autor' == $column) { $user_id = wpsestate_get_author(get_the_ID()); $estate_autor = get_the_author_meta('display_name'); echo '<a href="' . get_edit_user_link($user_id) . '" >' . $estate_autor . '</a>'; } if ('estate_action' == $column) { $estate_action = get_the_term_list(get_the_ID(), 'property_action_category', '', ', ', ''); echo $estate_action; } elseif ('estate_category' == $column) { $estate_category = get_the_term_list(get_the_ID(), 'property_category', '', ', ', ''); echo $estate_category; } if ('estate_price' == $column) { $currency = esc_html(get_option('wp_estate_currency_symbol', '')); $where_currency = esc_html(get_option('wp_estate_where_currency_symbol', '')); wpestate_show_price(get_the_ID(), $currency, $where_currency, 0); } }
function wpestate_mess_front_end() { // check_ajax_referer( 'mess_ajax_nonce_front', 'security-register' ); global $current_user; get_currentuserinfo(); $allowed_html = array(); $userID = $current_user->ID; $user_login = $current_user->user_login; $subject = esc_html__('Message from ', 'wpestate') . $user_login; $message_user = wp_kses($_POST['message'], $allowed_html); $property_id = intval($_POST['agent_property_id']); $agent_id = intval($_POST['agent_id']); if ($agent_id === 0) { $owner_id = wpsestate_get_author($property_id); } else { $owner_id = get_post_meta($agent_id, 'user_agent_id', true); } $owner = get_userdata($owner_id); $owner_email = $owner->user_email; $owner_login = $owner->ID; $subject = esc_html__('Message from ', 'wpestate') . $user_login; wpestate_send_booking_email('inbox', $owner_email); $booking_guest_no = intval($_POST['booking_guest_no']); $booking_from_date = wp_kses($_POST['booking_from_date'], $allowed_html); $booking_to_date = wp_kses($_POST['booking_to_date'], $allowed_html); $message_user = esc_html__('Selected dates: ', 'wpestate') . $booking_from_date . esc_html__(' to ', 'wpestate') . $booking_to_date . ", " . esc_html__(' guests:', 'wpestate') . $booking_guest_no . "||" . $message_user; // add into inbox wpestate_add_to_inbox($userID, $userID, $owner_login, $subject, $message_user, 1); esc_html_e('Your message was sent! You will be notified by email when a reply is received.', 'wpestate'); die; }
function wpestate_user_booked_from_agent($userid, $agent_id) { $all_my_post = array(); $args = array('post_type' => 'wpestate_booking', 'post_status' => 'publish', 'posts_per_page' => -1, 'author' => $userid, 'meta_query' => array(array('key' => 'booking_status', 'value' => 'confirmed', 'compare' => '='))); $prop_selection = new WP_Query($args); if ($prop_selection->have_posts()) { while ($prop_selection->have_posts()) { $prop_selection->the_post(); $prop_id = intval(get_post_meta(get_the_ID(), 'booking_id', true)); // print 'check for '.$prop_id.'</br>'; if (wpsestate_get_author($prop_id) === $agent_id) { return true; } } // end of the loop. return false; } else { return false; } }
<?php } ?> </div> <div class="row admin-list-wrapper booking_list"> <?php wp_reset_query(); $paged = get_query_var('paged') ? get_query_var('paged') : 1; $args = array('post_type' => 'wpestate_booking', 'post_status' => 'publish', 'paged' => $paged, 'posts_per_page' => 30, 'order' => 'DESC', 'author' => $userID); $book_selection = new WP_Query($args); if ($book_selection->have_posts()) { while ($book_selection->have_posts()) { $book_selection->the_post(); $booking_id = get_post_meta($post->ID, 'booking_id', true); $listing_owner = wpsestate_get_author($booking_id); if ($userID != $listing_owner) { get_template_part('templates/book-listing-user-unit'); } } } else { print '<h4 class="no_favorites">' . esc_html__('You don\'t have any reservations made!', 'wpestate') . '</h4>'; } wp_reset_query(); ?> </div> </div> </div> <?php wp_reset_query();
function wpestate_listing_set_to_expire($post_id) { $prop = array('ID' => $post_id, 'post_type' => 'estate_property', 'post_status' => 'expired'); wp_update_post($prop); $user_id = wpsestate_get_author($post_id); $user = get_user_by('id', $user_id); $user_email = $user->user_email; $headers = 'From: No Reply <noreply@' . $_SERVER['HTTP_HOST'] . '>' . "\r\n"; $message = esc_html__('A free listing has expired,', 'wpestate') . "\r\n\r\n"; $message .= sprintf(esc_html__("Hello, One of your free listings on %s has \"expired\". The listing is %s. Thank you!", 'wpestate'), get_option('blogname'), esc_url(get_permalink($post_id))) . "\r\n\r\n"; wp_mail($user_email, sprintf(esc_html__('[%s] Free Listing expired', 'wpestate'), get_option('blogname')), $message, $headers); }
$thumb_prop = '<img src="' . $thumb_prop_default . '" class="b-lazy img-responsive wp-post-image lazy-hidden" alt="no thumb" />'; } $featured = intval(get_post_meta($post->ID, 'prop_featured', true)); $property_rooms = get_post_meta($post->ID, 'property_bedrooms', true); if ($property_rooms != '') { $property_rooms = intval($property_rooms); } $property_bathrooms = get_post_meta($post->ID, 'property_bathrooms', true); if ($property_bathrooms != '') { $property_bathrooms = floatval($property_bathrooms); } $property_size = get_post_meta($post->ID, 'property_size', true); if ($property_size) { $property_size = number_format(intval($property_size)); } $agent_id = wpsestate_get_author($post->ID); $agent_id = get_user_meta($agent_id, 'user_agent_id', true); $thumb_id_agent = get_post_thumbnail_id($agent_id); $preview_agent = wp_get_attachment_image_src($thumb_id_agent, 'wpestate_user_thumb'); $preview_agent_img = $preview_agent[0]; if ($preview_agent_img == '') { $preview_agent_img = get_template_directory_uri() . '/img/default_user_small.png'; } $agent_link = esc_url(get_permalink($agent_id)); $measure_sys = esc_html(get_option('wp_estate_measure_sys', '')); $price = intval(get_post_meta($post->ID, 'property_price', true)); $property_city = get_the_term_list($post->ID, 'property_city', '', ', ', ''); $property_area = get_the_term_list($post->ID, 'property_area', '', ', ', ''); $property_action = get_the_term_list($post->ID, 'property_action_category', '', ', ', ''); $property_categ = get_the_term_list($post->ID, 'property_category', '', ', ', ''); ?>
<?php global $prop_id; global $agent_email; $owner_id = wpsestate_get_author($prop_id); //$agent_id = intval( get_post_meta($post->ID, 'property_agent', true) ); $agent_id = get_user_meta($owner_id, 'user_agent_id', true); $prop_id = $post->ID; $author_email = get_the_author_meta('user_email'); $preview_img = ''; $content = ''; if ($agent_id != 0) { $args = array('post_type' => 'estate_agent', 'p' => $agent_id); $agent_selection = new WP_Query($args); $thumb_id = ''; $agent_skype = ''; $agent_phone = ''; $agent_mobile = ''; $agent_email = ''; $agent_pitch = ''; $link = ''; $name = 'No agent'; if ($agent_selection->have_posts()) { while ($agent_selection->have_posts()) { $agent_selection->the_post(); $thumb_id = get_post_thumbnail_id($post->ID); $preview = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail'); $preview_img = $preview[0]; $agent_skype = esc_html(get_post_meta($post->ID, 'agent_skype', true)); $agent_phone = esc_html(get_post_meta($post->ID, 'agent_phone', true)); $agent_mobile = esc_html(get_post_meta($post->ID, 'agent_mobile', true));
$booking_id = intval($_POST['booking_id']); $depozit = intval($_POST['depozit']); $charge = Stripe_Charge::create(array('customer' => $customer->id, 'amount' => $depozit, 'currency' => $submission_curency_status)); // confirm booking update_post_meta($booking_id, 'booking_status', 'confirmed'); $curent_listng_id = get_post_meta($booking_id, 'booking_id', true); $reservation_array = wpestate_get_booking_dates($curent_listng_id); update_post_meta($curent_listng_id, 'booking_dates', $reservation_array); // set invoice to paid update_post_meta($invoice_id, 'invoice_status', 'confirmed'); update_post_meta($invoice_id, 'depozit_paid', $depozit / 100); ///////////////////////////////////////////////////////////////////////////// // send confirmation emails ///////////////////////////////////////////////////////////////////////////// wpestate_send_booking_email("bookingconfirmeduser", $user_email); $receiver_id = wpsestate_get_author($invoice_id); $receiver_email = get_the_author_meta('user_email', $receiver_id); $receiver_name = get_the_author_meta('user_login', $receiver_id); wpestate_send_booking_email("bookingconfirmed", $receiver_email); // add messages to inbox $subject = esc_html__('Booking Confirmation', 'wpestate'); $description = esc_html__('A booking was confirmed', 'wpestate'); wpestate_add_to_inbox($userID, $userID, $receiver_id, $subject, $description, 1); ////redirect catre bookng list $redirect = wpestate_my_reservations_link(); wp_redirect($redirect); exit; } catch (Exception $e) { $error = '<div class="alert alert-danger"> <strong>Error!</strong> ' . $e->getMessage() . ' </div>';
function wpestate_ajax_add_booking() { // check_ajax_referer( 'booking_ajax_nonce','security'); global $current_user; get_currentuserinfo(); $allowded_html = array(); $userID = $current_user->ID; $from = $current_user->user_login; $comment = ''; $status = 'pending'; if (isset($_POST['comment'])) { $comment = wp_kses($_POST['comment'], $allowded_html); } $booking_guest_no = 0; if (isset($_POST['booking_guest_no'])) { $booking_guest_no = intval($_POST['booking_guest_no']); } if (isset($_POST['confirmed'])) { if (intval($_POST['confirmed']) == 1) { $status = 'confirmed'; } } $property_id = intval($_POST['listing_edit']); $owner_id = wpsestate_get_author($property_id); $fromdate = wp_kses($_POST['fromdate'], $allowded_html); $to_date = wp_kses($_POST['todate'], $allowded_html); $event_name = esc_html__('Booking Request', 'wpestate'); $post = array('post_title' => $event_name, 'post_content' => $comment, 'post_status' => 'publish', 'post_type' => 'wpestate_booking', 'post_author' => $userID); $post_id = wp_insert_post($post); $post = array('ID' => $post_id, 'post_title' => $event_name . ' ' . $post_id); wp_update_post($post); update_post_meta($post_id, 'booking_status', $status); update_post_meta($post_id, 'booking_id', $property_id); update_post_meta($post_id, 'owner_id', $owner_id); update_post_meta($post_id, 'booking_from_date', $fromdate); update_post_meta($post_id, 'booking_to_date', $to_date); update_post_meta($post_id, 'booking_invoice_no', 0); update_post_meta($post_id, 'booking_pay_ammount', 0); update_post_meta($post_id, 'booking_guests', $booking_guest_no); // build the reservation array $reservation_array = wpestate_get_booking_dates($property_id); update_post_meta($property_id, 'booking_dates', $reservation_array); if ($owner_id == $userID) { $subject = esc_html__('You reserved a period', 'wpestate'); $description = esc_html__('You have reserverd a period on your own listing', 'wpestate'); $from = $current_user->user_login; $to = $owner_id; $receiver = get_userdata($owner_id); $receiver_email = $receiver->user_email; wpestate_add_to_inbox($userID, $from, $to, $subject, $description); wpestate_send_booking_email('mynewbook', $receiver_email); } else { $subject = esc_html__('New Booking Request from ', 'wpestate'); $description = esc_html__('You have received a new booking request', 'wpestate'); $from = $current_user->ID; $to = $owner_id; $receiver = get_userdata($owner_id); $receiver_email = $receiver->user_email; wpestate_add_to_inbox($userID, $userID, $to, $subject, $description, 1); wpestate_send_booking_email('newbook', $receiver_email); } die; }