-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfront-page.php
More file actions
135 lines (124 loc) · 4.09 KB
/
front-page.php
File metadata and controls
135 lines (124 loc) · 4.09 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
<?php
/**
* The main template file.
*
* This is the most generic template file in a WordPress theme
* and one of the two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* E.g., it puts together the home page when no home.php file exists.
*
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package sg-916
*/
$emailSent = false;
$errorName = false;
$errorEmail = false;
$errorMsg = false;
$errorRobot = false;
$botici = filter_input(INPUT_POST, "botici",FILTER_SANITIZE_STRING);
$email = trim(filter_input(INPUT_POST, "email", FILTER_SANITIZE_EMAIL));
$name = trim(filter_input(INPUT_POST, "sender-name", FILTER_SANITIZE_STRING));
$msg = trim(filter_input(INPUT_POST, "msg", FILTER_SANITIZE_STRING));
$sent = trim(filter_input(INPUT_GET, "sent", FILTER_SANITIZE_NUMBER_INT));
if (!$botici && ($sent == 1)) {
$first = false;
if ($email && $name && $msg) {
$subject = 'From '.$name;
$body = "Name: $name \n\nEmail: $email \n\nMessage $msg";
$headers = 'From: '.$name.' <sarah@sarahgebauer.com>' . "\r\n" . 'Reply-To: ' . $email;
wp_mail('sarah@sarahgebauer.com', $subject, $body, $headers);
$emailSent = true;
} else {
if (!$msg) {
$errorMsg = true;
}
if (!$name) {
$errorName = true;
}
if (!$email) {
$errorEmail = true;
}
}
}
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<div class="hero">
Hi! I am Sarah and I am a Front-End Developer.<br />
My specialties are:
<ul>
<li>Wordpress</li>
<li>HTML & CSS</li>
<li>JavaScript & jQuery</li>
</ul>
</div>
<div class="front-flex-parent">
<div class="front-flex-child front-blogpost">
<?php query_posts('posts_per_page=1'); ?>
<?php while (have_posts()) : the_post(); ?>
<h2 class="section-title"><a href="<?php the_permalink(); ?>"><?php the_title();?></a></h2>
<?php
if (has_post_thumbnail()) { ?>
<a href="<?php the_permalink(); ?>"><?php
the_post_thumbnail(array(440, 264)); ?>
</a> <?php
}
the_excerpt();
?>
<?php endwhile; ?>
</div>
<div class="front-flex-child front-portfolio">
<?php query_posts('post_type=piece&posts_per_page=1'); ?>
<?php while (have_posts()) : the_post(); ?>
<h2 class="section-title">Latest project:</h2>
<div class="right-align">
<?php
if (has_post_thumbnail()) { ?>
<a href="<?php the_permalink(); ?>"><?php
the_post_thumbnail(array(440, 264)); ?>
</a> <?php
}
?>
<br />
<a href="<?php the_permalink(); ?>">Read more about it</a>
</div>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
</div>
<div class="front-flex-child front-contact">
<h2 class="section-title">Contact me</h2>
<p>
My e-mail is sarah@sarahgebauer.com or use the form below.
</p>
<?php if ($emailSent) : ?>
Your e-mail has been sent!
<?php endif; ?>
<form action="<?php echo bloginfo('url'); ?>?sent=1" method="post">
<?php if ($errorMsg && !$first) :?>
<div>Your message is empty</div>
<?php endif; ?>
<label for="msg">Your message:</label><br />
<textarea id="msg" name="msg"></textarea>
<?php if ($errorName && !$first) :?>
<div>Your name is empty</div>
<?php endif; ?>
<label for="sender-name">Your name:</label><br />
<input type="text" id="sender-name" name="sender-name" /><br />
<?php if ($errorEmail && !$first) :?>
<div>Your email is empty</div>
<?php endif; ?>
<label for="email">Your e-mail:</label><br />
<input type="email" id="email" name="email" /><br />
<label for="botici">Only robots write here:</label><br />
<input type="text" id="botici" name="botici" /><br />
<input type="submit" value="Send" />
</form>
</div>
<div class="front-flex-child front-explore">
</div>
</div>
</main><!-- #main -->
</div><!-- #primary -->
<?php
get_footer();