/
page-login.php
246 lines (185 loc) · 7.74 KB
/
page-login.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
<?php
$action = !empty( $_GET['action'] ) && ($_GET['action'] == 'register' || $_GET['action'] == 'forgot' || $_GET['action'] == 'resetpass') ? $_GET['action'] : 'login';
$success = !empty( $_GET['success'] );
$failed = !empty( $_GET['failed'] ) ? $_GET['failed'] : false;
?>
<?php get_header(); ?>
<main id="main" class="site-main wrapper" role="main">
<div class="main-column">
<?php while ( have_posts() ) : the_post(); ?>
<?php if ( !$success && $action != 'resetpass' ): ?>
<ul class="tabs cf" id="login-tabs">
<li class="<?php if ($action == 'login') echo 'active-tab'; ?>"><a href="#tab-login">Login</a></li>
<li class="<?php if ($action == 'register') echo 'active-tab'; ?>"><a href="#tab-register">Register</a></li>
<li class="<?php if ($action == 'forgot') echo 'active-tab'; ?>"><a href="#tab-forgot">Forgot?</a></li>
</ul>
<?php endif; ?>
<article id="page-<?php the_ID(); ?>" class="meta-box hentry">
<div id="page-login" class="post-content page-login cf">
<?php if ( $action == 'register' && $success ): ?>
<header class="entry-header">
<h1>Success!</h1>
</header>
<div class="message-box message-success">
<span class="icon-thumbs-up"></span>
Check your email for the password and then return to log in.
</div>
<?php elseif ( $action == 'forgot' && $success ): ?>
<header class="entry-header">
<h1>Password recovery</h1>
</header>
<div class="message-box message-info">
<span class="icon-bell"></span>
Check your email for the instructions to get a new password.
</div>
<?php elseif ( $action == 'resetpass' && $success ): ?>
<header class="entry-header">
<h1>Password reset</h1>
</header>
<div class="message-box message-success">
<span class="icon-thumbs-up"></span>
Your password has been updated. <a href="/login/">Proceed to login</a>.
</div>
<?php else: ?>
<div id="tab-login" class="tab-content" style="<?php if ( $action != 'login' ) echo 'display:none' ?>">
<?php if ( $action == 'login' && $failed ): ?>
<div class="message-box message-error">
<span class="icon-attention"></span>
<?php if ( $failed ): ?>
Invalid username or password. Please try again.
<?php endif; ?>
</div>
<?php endif; ?>
<header class="entry-header">
<h1 class="entry-title">Login</h1>
</header>
<div class="entry-content">
<p>Don't have an account? <a href="/login/?action=register">Sign up now</a>!</p>
</div>
<?php wp_login_form(); ?>
</div>
<div id="tab-register" class="tab-content" style="<?php if ( $action != 'register' ) echo 'display:none' ?>">
<?php if ( $action == 'register' && $failed ): ?>
<div class="message-box message-error">
<span class="icon-attention"></span>
<?php if ( $failed == 'invalid_character' ): ?>
Username can only contain alphanumerical characters, "_" and "-". Please choose another username.
<?php elseif ( $failed == 'username_exists' ): ?>
Username already in use.
<?php elseif ( $failed == 'email_exists' ): ?>
E-mail already in use. Maybe you are already registered?
<?php elseif ( $failed == 'empty' ): ?>
All fields are required.
<?php else: ?>
An error occurred while registering the new user. Please try again.
<?php endif; ?>
</div>
<?php endif; ?>
<header class="entry-header">
<h1 class="entry-title">Register</h1>
</header>
<div class="entry-content">
<p>Sign up for the cool stuff!</p>
</div>
<form name="registerform" id="registerform" action="<?php echo site_url('wp-login.php?action=register', 'login_post') ?>" method="post">
<p>
<label for="user_login">Username</label>
<input type="text" name="user_login" id="user_login" class="input" value="">
</p>
<p>
<label for="user_email">E-mail</label>
<input type="text" name="user_email" id="user_email" class="input" value="">
</p>
<p style="display:none">
<label for="confirm_email">Please leave this field empty</label>
<input type="text" name="confirm_email" id="confirm_email" class="input" value="">
</p>
<p id="reg_passmail">A password will be e-mailed to you.</p>
<input type="hidden" name="redirect_to" value="/login/?action=register&success=1" />
<p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="Register" /></p>
</form>
</div>
<div id="tab-forgot" class="tab-content" style="<?php if ( $action != 'forgot' ) echo 'display:none' ?>">
<?php if ( $action == 'forgot' && $failed ): ?>
<div class="message-box message-error">
<span class="icon-attention"></span>
<?php if ( $failed == 'wrongkey' ): ?>
The reset key is wrong or expired. Please check that you used the right reset link or request a new one.
<?php else: ?>
Sorry, we couldn't find any user with that username or email.
<?php endif; ?>
</div>
<?php endif; ?>
<header class="entry-header">
<h1 class="entry-title">Password recovery</h1>
</header>
<div class="entry-content">
<p>Please enter your username or email address. You will receive a link to create a new password.</p>
</div>
<form name="lostpasswordform" id="lostpasswordform" action="<?php echo site_url('wp-login.php?action=lostpassword', 'login_post') ?>" method="post">
<p>
<label for="user_login">Username or E-mail:</label>
<input type="text" name="user_login" id="user_login" class="input" value="">
</p>
<input type="hidden" name="redirect_to" value="/login/?action=forgot&success=1">
<p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="Get New Password" /></p>
</form>
</div>
<?php if ( $action == 'resetpass' ): ?>
<div id="tab-resetpass" class="tab-content">
<?php if ( $failed ): ?>
<div class="message-box message-error">
<span class="icon-attention"></span>
The passwords don't match. Please try again.
</div>
<?php endif; ?>
<header class="entry-header">
<h1 class="entry-title">Reset password</h1>
</header>
<div class="entry-content">
<p>Create a new password for your account.</p>
</div>
<form name="resetpasswordform" id="resetpasswordform" action="<?php echo site_url('wp-login.php?action=resetpass', 'login_post') ?>" method="post">
<p class="form-password">
<label for="pass1">New Password</label>
<input class="text-input" name="pass1" type="password" id="pass1">
</p>
<p class="form-password">
<label for="pass2">Confirm Password</label>
<input class="text-input" name="pass2" type="password" id="pass2">
</p>
<input type="hidden" name="redirect_to" value="/login/?action=resetpass&success=1">
<?php
$rp_key = '';
$rp_cookie = 'wp-resetpass-' . COOKIEHASH;
if ( isset( $_COOKIE[ $rp_cookie ] ) && 0 < strpos( $_COOKIE[ $rp_cookie ], ':' ) ) {
list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ $rp_cookie ] ), 2 );
}
?>
<input type="hidden" name="rp_key" value="<?php echo esc_attr( $rp_key ); ?>">
<p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="Get New Password" /></p>
</form>
</div>
<?php endif; ?>
<?php endif; ?>
</div>
</article>
<?php endwhile; ?>
</div><!-- .main-column -->
<?php get_sidebar(); ?>
</main><!-- #main -->
<script>
// tabs
$('#login-tabs a').click(function (e) {
e.preventDefault();
$this = $(this);
// add class to tab
$('#login-tabs li').removeClass('active-tab');
$this.parent().addClass('active-tab');
// show the right tab
$('#page-login .tab-content').hide();
$('#page-login ' + $this.attr('href')).show();
return false;
});
</script>
<?php get_footer(); ?>