1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
<?php
namespace hji\AgentRoster\utils;
class ContactForm
{
function __constructor(){}
function form($admin_email = false)
{
$send_to = $admin_email;
$full_name = __('Full Name:', 'agent_roster');
$email = __('Email:', 'agent_roster');
$phone = __('Phone:', 'agent_roster');
$message = __('Message:', 'agent_roster');
$submit = __('Send Inquiry', 'agent_roster');
$is_entry_valid = true;
if (isset($_REQUEST['contact-agent']) &&
(@empty($_REQUEST['email']) || @empty($_REQUEST['full_name'])))
{
$is_entry_valid = false;
}
if (empty($_REQUEST['input_field_731']) &&
isset($_REQUEST['contact-agent']) &&
(@!empty($_REQUEST['email']) ||
@!empty($_REQUEST['full_name'])))
{
if (!$send_to)
{
$send_to = get_option('admin_email');
}
$headers = 'From: ' . __('Agent Roster Page', 'agent_roster') . ' <' . $send_to . '>' . "\r\n";
$content = $full_name . ' ' . esc_attr($_REQUEST['full_name']) . "\r\n";
$content .= $email . ' ' . esc_attr($_REQUEST['email']) . "\r\n";
$content .= $phone . ' ' . esc_attr($_REQUEST['phone']) . "\r\n";
$content .= $message . ' ' . esc_attr($_REQUEST['message']) . "\r\n";
$content .= __('Referring URL:', 'agent_roster') . ' http://' . $_SERVER['HTTP_HOST'] . $_SERVER["REQUEST_URI"] . "\r\n";
$subject = 'Web Inquiry via: ' . get_site_url();
if (wp_mail($send_to, $subject, $content, $headers))
{
$notice = '<p class="message">' . __('Thank you for your inquiry! We will get back to you shortly.', 'agent_roster') . '</p>';
}
}
require_once(\hji\membership\Membership::$dir . '/common/utils/Views.php');
$view = new \hji\common\utils\Views(AGRO_VIEWS);
$vars = array(
'is_entry_valid' => $is_entry_valid,
'full_name' => $full_name,
'email' => $email,
'phone' => $phone,
'message' => $message,
'submit' => $submit
);
return $view->render('contact-form', $vars);
}
}