contactbyemail

/contactbyemail
­
settings->get( 'recaptcha_public' ) && Avada()->settings->get( 'recaptcha_private' ) && ! function_exists( 'recaptcha_get_html' ) ) { if ( ! class_exists( 'ReCaptcha' ) ) { require_once( 'framework/recaptchalib.php' ); } // Instantiate ReCaptcha object $re_captcha = new ReCaptcha( Avada()->settings->get( 'recaptcha_private' ) ); } //If the form is submitted if(isset($_POST['submit'])) { //Check to make sure that the name field is not empty if(trim($_POST['contact_name']) == '' || trim($_POST['contact_name']) == 'Name (required)') { $hasError = true; } else { $name = trim($_POST['contact_name']); } //Subject field is not required if(function_exists('stripslashes')) { $subject = stripslashes(trim($_POST['url'])); } else { $subject = trim($_POST['url']); } //Check to make sure sure that a valid email address is submitted $pattern = '/^(?!(?:(?:\\x22?\\x5C[\\x00-\\x7E]\\x22?)|(?:\\x22?[^\\x5C\\x22]\\x22?)){255,})(?!(?:(?:\\x22?\\x5C[\\x00-\\x7E]\\x22?)|(?:\\x22?[^\\x5C\\x22]\\x22?)){65,}@)(?:(?:[\\x21\\x23-\\x27\\x2A\\x2B\\x2D\\x2F-\\x39\\x3D\\x3F\\x5E-\\x7E]+)|(?:\\x22(?:[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x21\\x23-\\x5B\\x5D-\\x7F]|(?:\\x5C[\\x00-\\x7F]))*\\x22))(?:\\.(?:(?:[\\x21\\x23-\\x27\\x2A\\x2B\\x2D\\x2F-\\x39\\x3D\\x3F\\x5E-\\x7E]+)|(?:\\x22(?:[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x21\\x23-\\x5B\\x5D-\\x7F]|(?:\\x5C[\\x00-\\x7F]))*\\x22)))*@(?:(?:(?!.*[^.]{64,})(?:(?:(?:xn--)?[a-z0-9]+(?:-+[a-z0-9]+)*\\.){1,126}){1,}(?:(?:[a-z][a-z0-9]*)|(?:(?:xn--)[a-z0-9]+))(?:-+[a-z0-9]+)*)|(?:\\[(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){7})|(?:(?!(?:.*[a-f0-9][:\\]]){7,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?)))|(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){5}:)|(?:(?!(?:.*[a-f0-9]:){5,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3}:)?)))?(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))(?:\\.(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))){3}))\\]))$/iD'; if(trim($_POST['email']) == '' || trim($_POST['email']) == 'Email (required)') { $hasError = true; } else if ( preg_match($pattern, $_POST['email']) === 0 ) { $hasError = true; } else { $email = trim($_POST['email']); } //Check to make sure comments were entered if(trim($_POST['msg']) == '' || trim($_POST['msg']) == 'Message') { $hasError = true; } else { if(function_exists('stripslashes')) { $comments = stripslashes(trim($_POST['msg'])); } else { $comments = trim($_POST['msg']); } } // Check if recaptcha is used if ( $re_captcha ) { $re_captcha_response = null; // Was there a reCAPTCHA response? if ( $_POST["g-recaptcha-response"] ) { $re_captcha_response = $re_captcha->verifyResponse( $_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"] ); } // Check the reCaptcha response if ( $re_captcha_response == null || ! $re_captcha_response->success ) { $hasError = true; } } //If there is no error, send the email if(!isset($hasError)) { $name = wp_filter_kses( $name ); $email = wp_filter_kses( $email ); $subject = wp_filter_kses( $subject ); $comments = wp_filter_kses( $comments ); if(function_exists('stripslashes')) { $subject = stripslashes($subject); $comments = stripslashes($comments); } $emailTo = Avada()->settings->get( 'email_address' ); //Put your own email address here $body = __('Name:', 'Avada')." $name \n\n"; $body .= __('Email:', 'Avada')." $email \n\n"; $body .= __('Subject:', 'Avada')." $subject \n\n"; $body .= __('Comments:', 'Avada')."\n $comments"; $headers = 'Reply-To: ' . $name . ' <' . $email . '>' . "\r\n"; $mail = wp_mail($emailTo, $subject, $body, $headers); $emailSent = true; if($emailSent == true) { $_POST['contact_name'] = ''; $_POST['email'] = ''; $_POST['url'] = ''; $_POST['msg'] = ''; } } } ?>
layout->add_style( 'content_style' ); ?>>
>
settings->get( 'email_address' ) ) { // Email address not set ?>

' . $name . ' ' . __( 'for using our contact form! Your email was successfully sent!', 'Avada' ) . '[/alert]' ); ?>
settings->get( 'recaptcha_public' ) && Avada()->settings->get( 'recaptcha_private' ) ): ?>