-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfront-page.php
More file actions
402 lines (235 loc) · 11.8 KB
/
front-page.php
File metadata and controls
402 lines (235 loc) · 11.8 KB
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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
<?php get_header();
if ( get_option( 'show_on_front' ) == 'page' ) {
include( get_page_template() );
}else {
if(isset($_POST['submitted']) && !defined('PIRATE_FORMS_VERSION') && !shortcode_exists( 'pirate_forms' ) ) :
/* recaptcha */
$zerif_contactus_sitekey = get_theme_mod('zerif_contactus_sitekey');
$zerif_contactus_secretkey = get_theme_mod('zerif_contactus_secretkey');
$zerif_contactus_recaptcha_show = get_theme_mod('zerif_contactus_recaptcha_show');
if( isset($zerif_contactus_recaptcha_show) && $zerif_contactus_recaptcha_show != 1 && !empty($zerif_contactus_sitekey) && !empty($zerif_contactus_secretkey) ) :
$captcha;
if( isset($_POST['g-recaptcha-response']) ){
$captcha=$_POST['g-recaptcha-response'];
}
if( !$captcha ){
$hasError = true;
}
$response = wp_remote_get( "https://www.google.com/recaptcha/api/siteverify?secret=".$zerif_contactus_secretkey."&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR'] );
if($response['body'].success==false) {
$hasError = true;
}
endif;
/* name */
if(trim($_POST['myname']) === ''):
$nameError = __('* Please enter your name.','zerif-lite');
$hasError = true;
else:
$name = trim($_POST['myname']);
endif;
/* email */
if(trim($_POST['myemail']) === ''):
$emailError = __('* Please enter your email address.','zerif-lite');
$hasError = true;
elseif (!preg_match("/^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$/i", trim($_POST['myemail']))) :
$emailError = __('* You entered an invalid email address.','zerif-lite');
$hasError = true;
else:
$email = trim($_POST['myemail']);
endif;
/* subject */
if(trim($_POST['mysubject']) === ''):
$subjectError = __('* Please enter a subject.','zerif-lite');
$hasError = true;
else:
$subject = trim($_POST['mysubject']);
endif;
/* message */
if(trim($_POST['mymessage']) === ''):
$messageError = __('* Please enter a message.','zerif-lite');
$hasError = true;
else:
$message = stripslashes(trim($_POST['mymessage']));
endif;
/* send the email */
if(!isset($hasError)):
$zerif_contactus_email = get_theme_mod('zerif_contactus_email');
if( empty($zerif_contactus_email) ):
$emailTo = get_theme_mod('zerif_email');
else:
$emailTo = $zerif_contactus_email;
endif;
if(isset($emailTo) && $emailTo != ""):
if( empty($subject) ):
$subject = 'From '.$name;
endif;
$body = "Name: $name \n\nEmail: $email \n\n Subject: $subject \n\n Message: $message";
/* FIXED HEADERS FOR EMAIL NOT GOING TO SPAM */
$zerif_admin_email = get_option( 'admin_email' );
$zerif_sitename = strtolower( $_SERVER['SERVER_NAME'] );
function zerif_is_localhost() {
$zerif_server_name = strtolower( $_SERVER['SERVER_NAME'] );
return in_array( $zerif_server_name, array( 'localhost', '127.0.0.1' ) );
}
if ( zerif_is_localhost() ) {
$headers = 'From: '.$name.' <'.$zerif_admin_email.'>' . "\r\n" . 'Reply-To: ' . $email;
} else {
if ( substr( $zerif_sitename, 0, 4 ) == 'www.' ) {
$zerif_sitename = substr( $zerif_sitename, 4 );
}
$headers = 'From: '.$name.' <wordpress@'.$zerif_sitename.'>' . "\r\n" . 'Reply-To: ' . $email;
}
wp_mail($emailTo, $subject, $body, $headers);
$emailSent = true;
else:
$emailSent = false;
endif;
endif;
endif;
$zerif_bigtitle_show = get_theme_mod('zerif_bigtitle_show');
if( isset($zerif_bigtitle_show) && $zerif_bigtitle_show != 1 ):
get_template_part( 'sections/big_title' );
endif;
?>
</header> <!-- / END HOME SECTION -->
<div id="content" class="site-content">
<?php
/* ABOUT US */
$zerif_aboutus_show = get_theme_mod('zerif_aboutus_show');
if( isset($zerif_aboutus_show) && $zerif_aboutus_show != 1 ):
get_template_part( 'sections/about_us' );
endif;
/* RIBBON WITH BOTTOM BUTTON */
get_template_part( 'sections/ribbon_with_bottom_button' );
/* GETTING STARTED SECTION */
$zerif_ourfocus_show = get_theme_mod('zerif_ourfocus_show');
if( isset($zerif_ourfocus_show) && $zerif_ourfocus_show != 1 ):
get_template_part( 'sections/our_focus' );
endif;
/*
/* OUR TEAM
$zerif_ourteam_show = get_theme_mod('zerif_ourteam_show');
if( isset($zerif_ourteam_show) && $zerif_ourteam_show != 1 ):
get_template_part( 'sections/our_team' );
endif;
/* TESTIMONIALS
$zerif_testimonials_show = get_theme_mod('zerif_testimonials_show');
if( isset($zerif_testimonials_show) && $zerif_testimonials_show != 1 ):
get_template_part( 'sections/testimonials' );
endif;
/* RIBBON WITH RIGHT SIDE BUTTON *
get_template_part( 'sections/ribbon_with_right_button' );
/* LATEST NEWS
$zerif_latestnews_show = get_theme_mod('zerif_latestnews_show');
if( isset($zerif_latestnews_show) && $zerif_latestnews_show != 1 ):
get_template_part( 'sections/latest_news' );
endif;
*/
/* CONTACT US */
$zerif_contactus_show = get_theme_mod('zerif_contactus_show');
if( isset($zerif_contactus_show) && $zerif_contactus_show != 1 ):
?>
<section class="contact-us" id="contact">
<div class="container">
<!-- SECTION HEADER -->
<div class="section-header">
<?php
$zerif_contactus_title = get_theme_mod('zerif_contactus_title',__('Submit Project','zerif-lite'));
if ( !empty($zerif_contactus_title) ):
echo '<h2 class="white-text">'.$zerif_contactus_title.'</h2>';
endif;
$zerif_contactus_subtitle = get_theme_mod('zerif_contactus_subtitle');
if(isset($zerif_contactus_subtitle) && $zerif_contactus_subtitle != ""):
echo '<div class="white-text section-legend">'.$zerif_contactus_subtitle.'</div>';
endif;
?>
</div>
<!-- / END SECTION HEADER -->
<?php
if ( defined('PIRATE_FORMS_VERSION') && shortcode_exists( 'pirate_forms' ) ):
echo '<div class="row">';
echo do_shortcode('[pirate_forms]');
echo '</div>';
else:
?>
<!-- CONTACT FORM-->
<div class="row">
<?php
if(isset($emailSent) && $emailSent == true) :
echo '<div class="notification success"><p>'.__('Thanks, your email was sent successfully!','zerif-lite').'</p></div>';
elseif(isset($_POST['submitted'])):
echo '<div class="notification error"><p>'.__('Sorry, an error occured.','zerif-lite').'</p></div>';
endif;
if(isset($nameError) && $nameError != '') :
echo '<div class="notification error"><p>'.esc_html($nameError).'</p></div>';
endif;
if(isset($emailError) && $emailError != '') :
echo '<div class="notification error"><p>'.esc_html($emailError).'</p></div>';
endif;
if(isset($subjectError) && $subjectError != '') :
echo '<div class="notification error"><p>'.esc_html($subjectError).'</p></div>';
endif;
if(isset($messageError) && $messageError != '') :
echo '<div class="notification error"><p>'.esc_html($messageError).'</p></div>';
endif;
if(!session('access_token')) {
//if logged in show form
print '<div style="text-align: center; background: darkgrey; padding: 10px;"><h3>You have to be logged in to submit a project!</h3> <br/><a href="?action=login" class="btn btn-primary green-btn"><i class="fa fa-github"></i> Login/Signup With Github</a></div>';
} else {
?>
<form role="form" method="POST" action="api/account/new_project" class="contact-form">
<input type="hidden" name="scrollPosition">
<input type="hidden" name="submitted" id="submitted" value="true" />
<div class="col-lg-6 col-sm-6 zerif-rtl-contact-name" data-scrollreveal="enter left after 0s over 1s">
<label for="myname" class="screen-reader-text"><?php _e( 'Your Name', 'zerif-lite' ); ?></label>
<input required="required" type="text" name="myname" id="myname" placeholder="<?php _e('Your Name','zerif-lite'); ?>" class="form-control input-box" value="<?php if(isset($_SESSION['name'])) echo esc_attr($_SESSION['name']);?>">
</div>
<div class="col-lg-6 col-sm-6 zerif-rtl-contact-email" data-scrollreveal="enter left after 0s over 1s">
<label for="myemail" class="screen-reader-text"><?php _e( 'Your Email', 'zerif-lite' ); ?></label>
<input required="required" type="email" name="myemail" id="myemail" placeholder="<?php _e('Your email','zerif-lite'); ?>" class="form-control input-box" value="<?php if(isset($_SESSION['email'])) echo is_email($_SESSION['email']) ? $_SESSION['email'] : ""; ?>">
</div>
<div class="col-lg-6 col-sm-6 zerif-rtl-contact-subject" data-scrollreveal="enter left after 0s over 1s">
<label for="myorganisation" class="screen-reader-text"><?php _e( 'myorganisation', 'zerif-lite' ); ?></label>
<input required="required" type="text" name="myorganisation" id="mysubject" placeholder="<?php _e('Name of your organisation','zerif-lite'); ?>" class="form-control input-box" value="<?php if(isset($_SESSION['company'])) echo esc_attr($_SESSION['company']);?>">
</div>
<div class="col-lg-6 col-sm-6 zerif-rtl-contact-subject" data-scrollreveal="enter left after 0s over 1s">
<label for="mygithub" class="screen-reader-text"><?php _e( 'Github Username', 'zerif-lite' ); ?></label>
<input required="required" type="text" name="mygithub" id="mygithub" placeholder="<?php _e('Github username','zerif-lite'); ?>" class="form-control input-box" value="<?php if(isset($_SESSION['login'])) echo esc_attr($_SESSION['login']);?>">
</div>
<div class="col-lg-12 col-sm-12" data-scrollreveal="enter right after 0s over 1s">
<label for="myproject" class="screen-reader-text"><?php _e( 'Title of your project', 'zerif-lite' ); ?></label>
<input required="required" type="text" name="myproject" id="myproject" placeholder="<?php _e('Title of your project','zerif-lite'); ?>" class="form-control input-box" value="<?php if(isset($_POST['myproject'])) echo esc_attr($_POST['myproject']);?>">
</div>
<div class="col-lg-12 col-sm-12" data-scrollreveal="enter right after 0s over 1s">
<label for="mymessage" class="screen-reader-text"><?php _e( 'Your Message', 'zerif-lite' ); ?></label>
<textarea name="mymessage" id="mymessage" class="form-control textarea-box" placeholder="<?php _e('Description of your project','zerif-lite'); ?>"><?php if(isset($_POST['mymessage'])) { echo esc_html($_POST['mymessage']); } ?></textarea>
</div>
<?php
$zerif_contactus_button_label = get_theme_mod('zerif_contactus_button_label',__('Submit Project','zerif-lite'));
if( !empty($zerif_contactus_button_label) ):
echo '<button class="btn btn-primary custom-button red-btn" type="submit" data-scrollreveal="enter left after 0s over 1s">'.$zerif_contactus_button_label.'</button>';
endif;
?>
<?php
$zerif_contactus_sitekey = get_theme_mod('zerif_contactus_sitekey');
$zerif_contactus_secretkey = get_theme_mod('zerif_contactus_secretkey');
$zerif_contactus_recaptcha_show = get_theme_mod('zerif_contactus_recaptcha_show');
if( isset($zerif_contactus_recaptcha_show) && $zerif_contactus_recaptcha_show != 1 && !empty($zerif_contactus_sitekey) && !empty($zerif_contactus_secretkey) ) :
echo '<div class="g-recaptcha zerif-g-recaptcha" data-sitekey="' . $zerif_contactus_sitekey . '"></div>';
endif;
?>
</form>
<?php
}
?>
</div>
<!-- / END CONTACT FORM-->
<?php
endif;
?>
</div> <!-- / END CONTAINER -->
</section> <!-- / END CONTACT US SECTION-->
<?php
endif;
}
get_footer(); ?>