';
echo '
';
echo '' . __('Your Name', 'antirobot-contact-form') . ' ';
echo ' ';
echo '
';
echo '';
echo '' . __('Your E-Mail', 'antirobot-contact-form') . ' ';
echo ' ';
echo '
';
echo '';
echo '' . __('Your Message', 'antirobot-contact-form') . ' ';
echo '';
echo '
';
echo '';
echo '
';
echo '';
echo '
';
echo '';
}
/*
Validate contact form input and ReCaptcha solution and mail contents to admin mail
@since 0.0.1
@changed 1.1.0
*/
function arcf_validation()
{
if (isset($_POST['arcf-submitted'])) {
$name = sanitize_text_field($_POST["arcf-name"]);
$email = sanitize_email($_POST["arcf-email"]);
$message = esc_textarea($_POST["arcf-message"]);
$to = esc_attr(get_option('arcf_mailto'));
$subject = esc_attr(get_option('arcf_subject'));
$privatekey = esc_attr(get_option('arcf_privatekey'));
$headers = "From: $name <$email>" . "\r\n";
$headers .= "Reply-To: <$email>";
$captcha;
if (isset($_POST['g-recaptcha-response'])) {
$captcha = $_POST['g-recaptcha-response'];
}
if (!$captcha) {
echo '' . __('Solve the reCAPTCHA', 'antirobot-contact-form') . ' ';
exit;
}
$response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=" . $privatekey . "&response=" . $captcha . "&remoteip=" . $_SERVER['REMOTE_ADDR']);
if ($response . $success == false) {
echo '' . __('Solve the reCAPTCHA', 'antirobot-contact-form') . ' ';
}
else {
if (wp_mail($to, $subject, $message, $headers)) {
echo '';
echo '
' . __('Form successfully sent.', 'antirobot-contact-form') . '
';
echo '
';
}
else {
echo '' . __('An unexpected error occurred. If this problem persists, please contact the webmaster. Error: wp-mail does not work', 'antirobot-contact-form') . '
';
}
}
}
}
/*
Register recaptcha_2_contact_form shortcode to use in pages or posts
@since 0.0.1
*/
function arcf_shortcode()
{
ob_start();
arcf_add_recaptcha();
arcf_validation();
arcf_frontend();
return ob_get_clean();
}
add_shortcode('antirobot_contact_form', 'arcf_shortcode');
/*
Register backend option page
@since 0.0.2
@changed 0.1.0
*/
add_action('admin_menu', 'arcf_setup_menu');
add_action('admin_init', 'arcf_register_settings');
function arcf_register_settings()
{
register_setting('arcf-option-group', 'arcf_publickey');
register_setting('arcf-option-group', 'arcf_privatekey');
register_setting('arcf-option-group', 'arcf_mailto');
register_setting('arcf-option-group', 'arcf_subject');
}
function arcf_setup_menu()
{
add_options_page('AntiRobot Contact Form', 'AntiRobot Contact Form', 'manage_options', 'antirobot-contact-form', 'arcf_init');
}
/*
Display backend settings page
@since 0.0.2
@changed 1.1.0
*/
function arcf_init()
{
?>
[antirobot_contact_form] on pages or posts to display the contact form.', 'antirobot-contact-form'); ?>
leave a review and spread the word. If you want to support my coffee addiction, you can tip me on paypal .
', 'antirobot-contact-form'); ?>