<?php $is_sticky = get_post_meta(get_the_ID(), REALIA_PROPERTY_PREFIX . 'sticky', true); ?> <div class="property-box"> <div class="property-box-image <?php if (!has_post_thumbnail()) { echo "without-image"; } ?> "> <?php $agent = Realia_Query::get_property_agent(); ?> <a href="<?php the_permalink(); ?> " class="property-box-image-inner <?php if (!empty($agent)) { ?> has-agent<?php } ?> "> <?php if (has_post_thumbnail()) { ?> <?php
/** * Process enquire form * * @access public * @return void */ public static function process_enquire_form() { if (!isset($_POST['enquire_form']) || empty($_POST['post_id'])) { return; } $post = get_post($_POST['post_id']); $email = esc_html($_POST['email']); $name = esc_html($_POST['name']); $subject = __('Message from enquire form', 'realia'); $headers = sprintf("From: %s <%s>\r\n Content-type: text/html", $name, $email); $is_recaptcha = Realia_Recaptcha::is_recaptcha_enabled(); $is_recaptcha_valid = array_key_exists('g-recaptcha-response', $_POST) ? Realia_Recaptcha::is_recaptcha_valid($_POST['g-recaptcha-response']) : false; ob_start(); include Realia_Template_Loader::locate('mails/enquire'); $message = ob_get_contents(); ob_end_clean(); $emails = array(); // Author if (!empty($_POST['receive_author'])) { $emails[] = get_the_author_meta('user_email', $post->post_author); } // Admin if (!empty($_POST['receive_author'])) { $emails[] = get_bloginfo('admin_email'); } // Agent if (!empty($_POST['receive_agent'])) { $agent = Realia_Query::get_property_agent($post->ID); if (!empty($agent)) { $email = get_post_meta($agent->ID, REALIA_AGENT_PREFIX . 'email', true); if (!empty($email)) { $emails[] = $email; } } } // Default fallback if (empty($_POST['receive_admin']) && empty($_POST['receive_agent']) && empty($_POST['receive_author'])) { $emails[] = get_the_author_meta('user_email', $post->post_author); } $emails = array_unique($emails); if ($is_recaptcha && $is_recaptcha_valid) { $_SESSION['messages'][] = array('danger', __('CAPTCHA is not valid.', 'realia')); } foreach ($emails as $email) { $status = wp_mail($email, $subject, $message, $headers); } if (!empty($status) && $status == 1) { $_SESSION['messages'][] = array('success', __('Message has been successfully sent.', 'realia')); } else { $_SESSION['messages'][] = array('danger', __('Unable to send a message.', 'realia')); } }