This repository has been archived by the owner on May 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtemplate-contact.php
300 lines (237 loc) · 8.37 KB
/
template-contact.php
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
<?php
/**
* Template Name: Contact
* The template for displaying the contact template.
*
* @package Designer
* @link https://themebeans.com/themes/designer
*/
get_header();
// META
$content = $post->post_content;
$link1_page_selector = get_theme_mod( 'link1_page_selector' );
$link2_page_selector = get_theme_mod( 'link2_page_selector' );
$page_content_layout = get_post_meta( $post->ID, '_bean_page_content_layout', true );
$page_parallax = get_post_meta( $post->ID, '_bean_page_parallax', true );
// CONTACT CODE
if ( isset( $_POST['submitted'] ) ) {
if ( trim( $_POST['contactName'] ) === '' ) {
$hasError = true;
} else {
$name = trim( $_POST['contactName'] );
}
if ( trim( $_POST['email'] ) === '' ) {
$hasError = true;
} elseif ( ! is_email( trim( $_POST['email'] ) ) ) {
$hasError = true;
} else {
$email = trim( $_POST['email'] );
}
if ( trim( $_POST['contactSubject'] ) === '' ) {
$hasError = false;
} else {
$contactSubject = trim( $_POST['contactSubject'] );
}
if ( trim( $_POST['comments'] ) === '' ) {
$hasError = true;
} else {
if ( function_exists( 'stripslashes' ) ) {
$comments = stripslashes( trim( $_POST['comments'] ) );
} else {
$comments = trim( $_POST['comments'] );
}
}
do_action( 'bean_after_contactform_errors' );
if ( ! isset( $hasError ) ) {
$site_name = get_bloginfo( 'name' );
$contactEmail = get_theme_mod( 'admin_custom_email' );
if ( ! isset( $contactEmail ) || ( $contactEmail == '' ) ) {
$contactEmail = get_option( 'admin_email' );
}
$subject_content = '[' . $site_name . ' Contact Form]';
$subject = apply_filters( 'bean_contactform_emailsubject', $contactSubject );
$body_content = "Name: $name \n\nEmail: $email \n\nMessage: $comments";
$body = apply_filters( 'bean_contactform_emailbody', $body_content );
$headers = 'Reply-To: ' . $email;
/*
By default, this form will send from wordpress@yourdomain.com in order to work with
a number of web hosts' anti-spam measures. If you want the from field to be the
user sending the email, please uncomment the following line of code.
*/
// $headers = 'From: '.$name.' <'.$email.'>' . "\r\n" . 'Reply-To: ' . $email;
wp_mail( $contactEmail, $subject, $body, $headers );
$emailSent = true;
}
} ?>
<?php
while ( have_posts() ) :
the_post();
?>
<?php
if ( $page_parallax == 'off' ) {
$page_parallax = 'no-parallax'; }
?>
<?php
if ( has_post_thumbnail() ) {
echo '<div class="entry-media ' . $page_parallax . '">';
the_post_thumbnail( 'port-full' );
echo '</div>'; }
?>
<div id="post-<?php the_ID(); ?>" <?php post_class( $page_content_layout . ' ' . $page_parallax ); ?>>
<article class="entry-content main-content fadein
<?php
if ( ! has_post_thumbnail() ) {
echo 'no-media'; }
?>
clearfix">
<?php if ( $content ) { ?>
<?php the_content(); ?>
<?php } ?>
<div class="contactform">
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#BeanForm").validate({ errors: { contactName: '', email: { required: '', email: '' }, comments: '' } });
});
</script>
<?php if ( isset( $emailSent ) && $emailSent == true ) { ?>
<div class="contact-alert success">
<div class="center-vertical">
<?php echo apply_filters( 'bean_contactform_success_msg', esc_html__( 'Your message was sent. Thanks.', 'designer' ) ); ?>
</div>
</div><!-- END .alert alert-success -->
<?php } // END SUCCESS ALERT ?>
<?php if ( isset( $hasError ) || isset( $captchaError ) ) { ?>
<div class="contact-alert fail">
<?php echo apply_filters( 'bean_contactform_error_msg', esc_html__( 'An error occured. Try again.', 'designer' ) ); ?>
</div><!-- END .alert alert-success -->
<?php } // END FAIL ALERT ?>
<?php $required = '<span class="required">*</span>'; ?>
<form action="<?php the_permalink(); ?>" id="BeanForm" method="post">
<div class="group">
<input type="text" name="contactName" id="contactName" value="
<?php
if ( isset( $_POST['contactName'] ) ) {
echo esc_html( $_POST['contactName'] );}
?>
" class="required requiredField" required/>
<span class="bar"></span>
<label for="contactName">
<?php
_e( 'Name ', 'designer' );
echo balanceTags( $required );
?>
</label>
</div>
<?php do_action( 'bean_after_contactform_namefield' ); ?>
<div class="group">
<input type="text" name="email" id="email" value="
<?php
if ( isset( $_POST['email'] ) ) {
echo esc_html( $_POST['email'] );}
?>
" class="required requiredField email" required/>
<span class="bar"></span>
<label for="email">
<?php
_e( 'Email ', 'designer' );
echo balanceTags( $required );
?>
</label>
</div>
<div class="group">
<input type="text" name="contactSubject" id="contactSubject" value="
<?php
if ( isset( $_POST['contactSubject'] ) ) {
echo esc_html( $_POST['contactSubject'] );}
?>
" class="required requiredField" required/>
<span class="bar"></span>
<label for="contactSubject"><?php _e( 'Subject ', 'designer' ); ?></label>
</div>
<?php do_action( 'bean_after_contactform_emailfield' ); ?>
<div class="group last">
<textarea name="comments" id="commentsText" rows="20" cols="30" class="required requiredField" required>
<?php
if ( isset( $_POST['comments'] ) ) {
if ( function_exists( 'stripslashes' ) ) {
echo stripslashes( $_POST['comments'] );
} else {
echo esc_html( $_POST['comments'] ); }
}
?>
</textarea>
<span class="bar"></span>
<label for="commentsText">
<?php
_e( 'Message ', 'designer' );
echo balanceTags( $required );
?>
</label>
</div>
<?php do_action( 'bean_after_contactform_allfields' ); ?>
<div class="submit">
<input type="hidden" name="submitted" id="submitted" value="true" />
<span class="bar"></span>
<button type="submit" class="button"><?php _e( 'Send Message', 'designer' ); ?></button>
</div>
<?php do_action( 'bean_after_contactform_submit' ); ?>
</form><!-- END #BeanForm -->
</div><!-- END .contactform -->
</article>
</div>
<?php
if ( get_theme_mod( 'google_maps_code' ) ) {
include_once ABSPATH . 'wp-admin/includes/plugin.php'; if ( is_plugin_active( 'google-maps-builder/google-maps-builder.php' ) ) {
?>
<div class="g-map <?php echo esc_html( $page_content_layout ); ?> clearfix">
<?php if ( get_theme_mod( 'gmap_address' ) ) { ?>
<div class="address-wrap">
<span class="address-circle">
<span>
<?php echo balanceTags( get_theme_mod( 'gmap_address' ) ); ?>
</span>
</span>
</div>
<?php } ?>
<?php echo do_shortcode( get_theme_mod( 'google_maps_code' ) ); ?>
</div>
<?php
}
}
?>
<?php
if ( $link1_page_selector ) {
?>
<article class="project square-link first-link <?php echo esc_html( $page_content_layout ); ?>">
<div class="thumb">
<a href="<?php echo esc_url( get_page_link( $link1_page_selector ) ); ?>" rel="home"></a>
<h3><?php echo get_the_title( $link1_page_selector ); ?></h3>
<?php if ( get_theme_mod( 'page_selector_feats' ) == true and has_post_thumbnail( $link1_page_selector ) ) { ?>
<?php echo get_the_post_thumbnail( $link1_page_selector, 'grid-feat' ); ?>
<?php } else { ?>
<img src="<?php echo esc_url( get_parent_theme_file_uri( '/assets/images/placeholder.png' ) ); ?>" alt="<?php echo esc_attr( bloginfo( 'name' ) ); ?>">
<?php } ?>
<div class="overlay"></div>
</div>
</article>
<?php
}
if ( $link2_page_selector ) {
?>
<article class="project square-link second-link <?php echo esc_html( $page_content_layout ); ?>">
<div class="thumb">
<a href="<?php echo esc_url( get_page_link( $link2_page_selector ) ); ?>" rel="home"></a>
<h3><?php echo get_the_title( $link2_page_selector ); ?></h3>
<?php if ( get_theme_mod( 'page_selector_feats' ) == true and has_post_thumbnail( $link2_page_selector ) ) { ?>
<?php echo get_the_post_thumbnail( $link2_page_selector, 'grid-feat' ); ?>
<?php } else { ?>
<img src="<?php echo esc_url( get_parent_theme_file_uri( '/assets/images/placeholder.png' ) ); ?>" alt="<?php echo esc_attr( bloginfo( 'name' ) ); ?>">
<?php } ?>
<div class="overlay"></div>
</div>
</article>
<?php
}
endwhile;
wp_reset_postdata();
get_footer();