function user_enquiry_for_classified() { $zoo_property = Zoo_Property::getInstance(); $locale = $zoo_property->getLocale(); if ($_SERVER["REQUEST_METHOD"] == "POST") { $request_name = $_POST['request_name']; $request_email = $_POST['request_email']; $request_number = $_POST['request_number']; $request_message = $_POST['request_message']; $classified_id = $_POST['classified_id']; $emailTo = array($_POST['request_to'], get_option('admin_email')); if ($request_email == '' || $request_message == '' || $emailTo == '') { $json['type'] = 'error'; $json['message'] = __('Please fill the required fields.', $locale); echo json_encode($json); exit; } if (!preg_match("/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,4})\$/", $request_email)) { $json['type'] = 'error'; $json['message'] = __('Please enter a valid email.', $locale); echo json_encode($json); die; } if (!isset($_POST['term_condtions_check'])) { $json['type'] = 'error'; $json['message'] = __('Please select Term & Conditions.', $locale); echo json_encode($json); exit; } define('WP_USE_THEMES', false); $subject = ''; $subjectEmail = sprintf(__('[%s] Listing Enquiry', $locale), get_bloginfo()); $message = ' <table width="100%" border="1"> <tr> <td width="100"><strong>' . __('Classified ID', $locale) . ':</strong></td> <td>' . $classified_id . '</td> </tr> <tr> <td width="100"><strong>' . __('Name', $locale) . ':</strong></td> <td>' . $request_name . '</td> </tr> <tr> <td width="100"><strong>' . __('Email', $locale) . ':</strong></td> <td>' . $request_email . '</td> </tr> <tr> <td width="100"><strong>' . __('Phone Number', $locale) . ':</strong></td> <td>' . $request_number . '</td> </tr> <tr> <td><strong>' . __('Message', $locale) . ':</strong></td> <td>' . $request_message . '</td> </tr> <tr> <td><strong>' . __('IP Address', $locale) . ':</strong></td> <td>' . $_SERVER['REMOTE_ADDR'] . '</td> </tr> </table>'; $from_email = $request_email; $headers = "From: " . $request_name . "\r\n"; $headers .= "Reply-To: " . $from_email . "\r\n"; $headers .= "Content-type: text/html; charset=utf-8" . "\r\n"; $headers .= "MIME-Version: 1.0" . "\r\n"; $attachments = ''; if (wp_mail($emailTo, $subjectEmail, $message, $headers, $attachments)) { $json = array(); $json['type'] = 'success'; $json['message'] = __('Your message has been Sent.', $locale); } else { $json['type'] = 'error'; $json['message'] = __('An error occur, please try again later.', $locale); } echo json_encode($json); exit; } exit; }
/** * Returns an instance of this class. An implementation of the singleton design patterns. * * @return Zoo_Property A reference to an instance of this class. */ public static function getInstance() { if (!isset(self::$_instance)) { self::$_instance = new Zoo_Property(); } return self::$_instance; }