Kodlarda nasıl bir düzenleme yaparsam sitenin iletişim formundan atılan maillerin kendi mailime gelmesini sağlayabilirim?
Nereye kendi mailimi yazmam gerekiyor? [I]<?php // Template Name: Contact Page[/I]
[I]// get header.php
get_header();[/I]
[I]// get theme customizer data
$cPage_general = get_option( 'royal_cPage_general' );
$cPage_map = get_option( 'royal_cPage_map' );[/I]
[I]// contact form validations
function isEmail( $email ) {
$reg_exp = '/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/';
return ( preg_match( $reg_exp, $email ) );
}[/I]
[I]// define error variables
$error_name = false;
$error_email = false;
$error_message = false;
$error_captcha = false;
$error_class = 'rf-error';[/I]
[I]// default variables
$name = esc_html__( '*Name', 'hyperx' );
$email = esc_html__( '*Email', 'hyperx' );
$subject = esc_html__( 'Subject', 'hyperx' );
$message = esc_html__( '*Message', 'hyperx' );
$reciever_email = '';
$sent_report = '';[/I]
[I]// generate captcha
$rf_captcha_1 = rand(0, 10);
$rf_captcha_2 = rand(0, 10);
$rf_captcha_sum = $rf_captcha_1 + $rf_captcha_2;[/I]
[I]// get the reciever email
if ( trim($cPage_general['reciever_email']) === '' ) {
$reciever_email = get_option('admin_email');
} else {
$reciever_email = $cPage_general['reciever_email'];
}[/I]
[I]if ( isset($_POST['cont-submit']) ) {[/I]
[I] // Get the name
if ( trim($_POST['cont-name']) === '' || trim($_POST['cont-name']) == $name || strlen( trim($_POST['cont-name']) ) < 2 ) {
$error_name = $error_class;
} else {
$name = esc_attr( trim($_POST['cont-name']) );
}[/I]
[I] // Get the email
if ( trim($_POST['cont-email']) === '' || ! isEmail( trim($_POST['cont-email']) ) ) {
$error_email = $error_class;
} else {
$email = esc_attr( trim($_POST['cont-email']) );
}[/I]
[I] // Get the subject
if ( trim($_POST['cont-subject']) == 'subject' ) {
$subject = '';
} else {
$subject = esc_attr( trim($_POST['cont-subject']) );
}[/I]
[I] // Get the message
if ( trim($_POST['cont-message']) === '' || trim($_POST['cont-message']) == $message ) {
$error_message = $error_class;
} else {
$message = stripslashes( trim($_POST['cont-message']) );
}[/I]
[I] if ( $cPage_general['enable_captcha'] === true && ( trim($_POST['cont-captcha']) === '' || trim($_POST['cont-captcha']) !== $_POST['cont-captcha-sum'] ) ) {
$error_captcha = $error_class;
}[/I]
[I] // chek for errors and get email contnet
if ( $error_name !== $error_class && $error_email !== $error_class && $error_message !== $error_class && $error_captcha !== $error_class ) {[/I]
[I] // email content
$body = esc_html__( 'Name: ', 'hyperx' ) . $name ."\n\n";
$body .= esc_html__( 'Email: ', 'hyperx' ) . $email ."\n\n";
$body .= esc_html__( 'Subject: ', 'hyperx' ) . $subject ."\n\n";
$body .= esc_html__( 'Message: ', 'hyperx' ) ."\n\n";
$body .= $message;[/I]
[I] // email headers
$headers = array( 'From: '. $email );[/I]
[I] // send and check if email was sent
if ( wp_mail( $reciever_email, $subject, $body, $headers ) ) {
$email_sent = true;
} else {
$email_sent = false;
}[/I]
[I] } // endif[/I]
[I]} // endif[/I]
[I]// if email was sent successfly echo success!
if ( isset($email_sent) && $email_sent ) {
$sent_report = '<span class="mail-success-txt">'. esc_html__( 'The message was successfully sent!', 'hyperx' ) .'</span>';
} elseif ( isset($email_sent) && ! $email_sent ) {
$sent_report = '<span class="mail-error-txt">'. esc_html__( 'An error has occurred!', 'hyperx' ) .'</span>';
}[/I]
[I]// get post meta data
$form_title = get_post_meta( $post->ID, 'rf_cont_form_title', true );
$info_title = get_post_meta( $post->ID, 'rf_cont_info_title', true );
$info_field_1 = get_post_meta( $post->ID, 'rf_cont_info_field_1', true );
$info_field_2 = get_post_meta( $post->ID, 'rf_cont_info_field_2', true );
$info_field_3 = get_post_meta( $post->ID, 'rf_cont_info_field_3', true );
$info_field_4 = get_post_meta( $post->ID, 'rf_cont_info_field_4', true );
$info_field_5 = get_post_meta( $post->ID, 'rf_cont_info_field_5', true );[/I]
[I]// change title in case of error/success
$form_title = ( isset($email_sent) && $sent_report != '' ? $sent_report : '<span>'. $form_title .'</span>' );[/I]
[I]// if all info fields are empty, make contact form full width
if ( trim($info_field_1) === '' &&
trim($info_field_2) === '' &&
trim($info_field_3) === '' &&
trim($info_field_4) === '' &&
trim($info_field_5) === ''
) {
$contact_form_full = 'contact-form-full';
} else {
$contact_form_full = '';
}[/I]
[I]?>[/I]
[I]<!-- Google Map - top of the Page -->
<?php if ( $cPage_map['position'] === 'top' ) : ?>
<div id="royal-gmap" class="google-map-wrap body-section" data-location="<?php echo esc_attr($cPage_map['location']); ?>" data-title="<?php echo esc_attr($cPage_map['tooltip_label']); ?>" data-map-type="<?php echo esc_attr($cPage_map['type']); ?>" data-zoom="<?php echo esc_attr($cPage_map['zoom']); ?>" data-scroll="<?php echo esc_attr($cPage_map['mousewheel']); ?>" data-nav="<?php echo esc_attr($cPage_map['nav']); ?>" data-type-control="<?php echo esc_attr($cPage_map['type_control']); ?>">
<div class="google-map"></div>[/I]
[I] </div>[/I]
[I]<?php endif; ?>[/I]
[I]<!-- Inner Content Wrapper -->
<div class="inner-content-wrap">[/I]
[I] <!-- Contact & Contact info -->
<div class="contact-form-wrap inner-content body-section">[/I]
[I] <?php if ( $cPage_general['layout'] === 'info_form' ) : ?>
<aside class="contact-info">[/I]
[I] <?php if ( trim( $info_title ) !== '' ) : ?>
<h3 class="contact-title"><span><?php echo esc_html($info_title); ?></span></h3>
<?php endif; ?>[/I]
[I] <ul>
<?php[/I]
[I] if ( trim( $info_field_1 ) !== '' ) {
echo '<li><span>'. $info_field_1 .'</span></li>';
}
if ( trim( $info_field_2 ) !== '' ) {
echo '<li><span>'. $info_field_2 .'</span></li>';
}
if ( trim( $info_field_3 ) !== '' ) {
echo '<li><span>'. $info_field_3 .'</span></li>';
}
if ( trim( $info_field_4 ) !== '' ) {
echo '<li><span>'. $info_field_4 .'</span></li>';
}
if ( trim( $info_field_5 ) !== '' ) {
echo '<li><span>'. $info_field_5 .'</span></li>';
}[/I]
[I] ?>
</ul>[/I]
[I] </aside>[/I]
[I] <?php endif; ?>[/I]
[I] <section class="contact-form <?php echo esc_attr($contact_form_full); ?>">
<?php[/I]
[I] $html = '';[/I]
[I] if ( trim( $form_title ) !== '<span></span>' ) {
$html .= '<h3 class="contact-title">'. wp_kses_post($form_title) .'</h3>';
}
$html .= '<form action="'. esc_url(get_permalink()) .'" method="post" class="rf-form" data-disabled="'. ( isset($email_sent) ? $email_sent : '' ) .'">';[/I]
[I] // Name
$html .= '<input type="text" id="cont-name" name="cont-name" class="rf-input pers-name '. esc_attr($error_name) .'" data-placeholder="'. esc_attr__( '*Name', 'hyperx' ) .'" value="'. esc_attr($name) .'" aria-required="true">';
// Email
$html .= '<input type="text" id="cont-email" name="cont-email" class="rf-input pers-email '. esc_attr($error_email) .'" data-placeholder="'. esc_attr__( '*Email', 'hyperx' ) .'" value="'. esc_attr($email) .'" aria-required="true">';
// Subject
$html .= '<input type="text" id="cont-subject" name="cont-subject" class="rf-input" data-placeholder="'. esc_attr__( 'Subject', 'hyperx' ) .'" value="'. esc_attr($subject) .'">';
// Message
$html .= '<textarea id="cont-message" name="cont-message" class="rf-input pers-message '. esc_attr($error_message) .'" rows="8" data-placeholder="'. esc_attr__( '*Message', 'hyperx' ) .'">'. esc_attr($message) .'</textarea>';
// captcha
if ( $cPage_general['enable_captcha'] === true ) {[/I]
[I] $html .= '<p class="royal-captcha">';
$html .= esc_html__( 'Prove your humanity', 'hyperx' );
$html .= ': <span class="random-captcha"><span>'. $rf_captcha_1 .'</span> + <span>'. $rf_captcha_2 .'</span> = </span>';
$html .= '<input style="width:50px;" type="text" id="cont-captcha" name="cont-captcha" class="rf-input '. esc_attr($error_captcha) .'">';
$html .= '<input type="hidden" id="cont-captcha-sum" name="cont-captcha-sum" value="'. $rf_captcha_sum .'">';
$html .= '</p>';[/I]
[I] }[/I]
[I] // Submit
$html .= '<input type="submit" value="'. esc_attr__( 'Send Message', 'hyperx' ) .'" class="submit-btn rf-button">';
$html .= '<input type="hidden" id="cont-submit" name="cont-submit" value="true">';[/I]
[I] $html .= '</form>';[/I]
[I] echo ''. $html;[/I]
[I] ?>
</section>[/I]
[I] <?php if ( $cPage_general['layout'] === 'form_info' ) : ?>[/I]
[I] <aside class="contact-info">[/I]
[I] <?php if ( trim( $info_title ) !== '' ) : ?>
<h3 class="contact-title"><span><?php echo esc_html($info_title); ?></span></h3>
<?php endif; ?>[/I]
[I] <ul>
<?php[/I]
[I] // field 1
if ( trim( $info_field_1 ) !== '' ) {
echo '<li><span>'. wp_kses_post($info_field_1) .'</span></li>';
}[/I]
[I] // field 2
if ( trim( $info_field_2 ) !== '' ) {
echo '<li><span>'. wp_kses_post($info_field_2) .'</span></li>';
}[/I]
[I] // field 3
if ( trim( $info_field_3 ) !== '' ) {
echo '<li><span>'. wp_kses_post($info_field_3) .'</span></li>';
}[/I]
[I] // field 4
if ( trim( $info_field_4 ) !== '' ) {
echo '<li><span>'. wp_kses_post($info_field_4) .'</span></li>';
}[/I]
[I] // field 5 (textarea)
if ( trim( $info_field_5 ) !== '' ) {
echo '<li><span>'. wp_kses_post($info_field_5) .'</span></li>';
}[/I]
[I] ?>
</ul>[/I]
[I] </aside>[/I]
[I] <?php endif; ?>[/I]
[I] </div><!-- end .contact-form-wrap -->[/I]
[I]</div><!-- end .inner-content-wrap --> [/I]
[I]<!-- Google Map - bottom of the Page -->
<?php if ( $cPage_map['position'] === 'bottom' ) : ?>
<div id="royal-gmap" class="google-map-wrap body-section" data-location="<?php echo esc_attr($cPage_map['location']); ?>" data-title="<?php echo esc_attr($cPage_map['tooltip_label']); ?>" data-map-type="<?php echo esc_attr($cPage_map['type']); ?>" data-zoom="<?php echo esc_attr($cPage_map['zoom']); ?>" data-scroll="<?php echo esc_attr($cPage_map['mousewheel']); ?>" data-nav="<?php echo esc_attr($cPage_map['nav']); ?>" data-type-control="<?php echo esc_attr($cPage_map['type_control']); ?>">
<div class="google-map"></div>
</div>[/I]
[I]<?php endif; ?>[/I]
[I]<!-- get footer.php -->
<?php get_footer(); ?>[/I]
[I][/I]