Version Description
- Added the option to require new registrations to confirm e-mail address
- Added the option to redirect users upon log out according to their role
- Allow 'theme-my-login.css' to be loaded from current theme directory
- Cleaned up and rewrote most code
- Drop support for WP versions below 2.8
Download this release
Release Info
Developer | jfarthing84 |
Plugin | Theme My Login |
Version | 4.4 |
Comparing to | |
See all releases |
Code changes from version 4.3.4 to 4.4
- admin/admin-email.php +27 -13
- admin/admin-general.php +16 -26
- admin/admin-links.php +8 -2
- admin/admin-redirection.php +15 -8
- admin/admin-template.php +0 -75
- admin/admin.php +26 -52
- classes/class.widget-old.php +0 -76
- classes/class.wp-login.php +0 -652
- includes/functions.php +306 -0
- classes/class.widget-new.php → includes/widget.php +3 -1
- js/jquery/jquery.js +0 -20
- js/jquery/ui.core.js +0 -10
- js/jquery/ui.tabs.js +0 -13
- readme.txt +9 -2
- theme-my-login.php +776 -553
admin/admin-email.php
CHANGED
@@ -1,13 +1,14 @@
|
|
1 |
<ul class="tabs-nav">
|
2 |
-
<li><a href="#fragment-
|
3 |
-
<li><a href="#fragment-
|
4 |
-
<li><a href="#fragment-
|
5 |
-
<li><a href="#fragment-
|
6 |
-
<li><a href="#fragment-
|
7 |
-
<li><a href="#fragment-
|
|
|
8 |
</ul>
|
9 |
|
10 |
-
<div id="fragment-
|
11 |
<table class="form-table">
|
12 |
<tr valign="top">
|
13 |
<td>
|
@@ -33,7 +34,7 @@
|
|
33 |
</table>
|
34 |
</div>
|
35 |
|
36 |
-
<div id="fragment-
|
37 |
<table class="form-table">
|
38 |
<tr>
|
39 |
<td>
|
@@ -44,14 +45,13 @@
|
|
44 |
<textarea name="registration_message" id="registration_message" class="large-text"><?php echo htmlspecialchars($ThemeMyLogin->options['registration_email']['message']); ?></textarea><br />
|
45 |
<p>
|
46 |
<label for "registration_admin_disable"><input name="registration_admin_disable" type="checkbox" id="registration_admin_disable" value="1" <?php if ( $ThemeMyLogin->options['registration_email']['admin_disable'] ) { echo 'checked="checked"'; } ?> /> Disable Admin Notification</label>
|
47 |
-
<label for "registration_user_disable"><input name="registration_user_disable" type="checkbox" id="registration_user_disable" value="1" <?php if ( $ThemeMyLogin->options['registration_email']['user_disable'] ) { echo 'checked="checked"'; } ?> /> Disable User Notification</label>
|
48 |
</p>
|
49 |
</td>
|
50 |
</tr>
|
51 |
</table>
|
52 |
</div>
|
53 |
|
54 |
-
<div id="fragment-
|
55 |
<table class="form-table">
|
56 |
<tr>
|
57 |
<td>
|
@@ -65,7 +65,7 @@
|
|
65 |
</table>
|
66 |
</div>
|
67 |
|
68 |
-
<div id="fragment-
|
69 |
<table class="form-table">
|
70 |
<tr>
|
71 |
<td>
|
@@ -82,7 +82,21 @@
|
|
82 |
</table>
|
83 |
</div>
|
84 |
|
85 |
-
<div id="fragment-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
<table class="form-table">
|
87 |
<tr>
|
88 |
<td>
|
@@ -96,7 +110,7 @@
|
|
96 |
</table>
|
97 |
</div>
|
98 |
|
99 |
-
<div id="fragment-
|
100 |
<table class="form-table">
|
101 |
<tr>
|
102 |
<td>
|
1 |
<ul class="tabs-nav">
|
2 |
+
<li><a href="#fragment-4-1">General</a></li>
|
3 |
+
<li><a href="#fragment-4-2">New Registration</a></li>
|
4 |
+
<li><a href="#fragment-4-3">Password Retrieval</a></li>
|
5 |
+
<li><a href="#fragment-4-4">Password Reset</a></li>
|
6 |
+
<li><a href="#fragment-4-5">E-mail Confirmation</a></li>
|
7 |
+
<li><a href="#fragment-4-6">User Approval</a></li>
|
8 |
+
<li><a href="#fragment-4-7">User Denial</a></li>
|
9 |
</ul>
|
10 |
|
11 |
+
<div id="fragment-4-1" class="tabs-div">
|
12 |
<table class="form-table">
|
13 |
<tr valign="top">
|
14 |
<td>
|
34 |
</table>
|
35 |
</div>
|
36 |
|
37 |
+
<div id="fragment-4-2" class="tabs-div">
|
38 |
<table class="form-table">
|
39 |
<tr>
|
40 |
<td>
|
45 |
<textarea name="registration_message" id="registration_message" class="large-text"><?php echo htmlspecialchars($ThemeMyLogin->options['registration_email']['message']); ?></textarea><br />
|
46 |
<p>
|
47 |
<label for "registration_admin_disable"><input name="registration_admin_disable" type="checkbox" id="registration_admin_disable" value="1" <?php if ( $ThemeMyLogin->options['registration_email']['admin_disable'] ) { echo 'checked="checked"'; } ?> /> Disable Admin Notification</label>
|
|
|
48 |
</p>
|
49 |
</td>
|
50 |
</tr>
|
51 |
</table>
|
52 |
</div>
|
53 |
|
54 |
+
<div id="fragment-4-3" class="tabs-div">
|
55 |
<table class="form-table">
|
56 |
<tr>
|
57 |
<td>
|
65 |
</table>
|
66 |
</div>
|
67 |
|
68 |
+
<div id="fragment-4-4" class="tabs-div">
|
69 |
<table class="form-table">
|
70 |
<tr>
|
71 |
<td>
|
82 |
</table>
|
83 |
</div>
|
84 |
|
85 |
+
<div id="fragment-4-5" class="tabs-div">
|
86 |
+
<table class="form-table">
|
87 |
+
<tr>
|
88 |
+
<td>
|
89 |
+
<p><em>Avilable Variables: %blogname%, %siteurl%, %confirmurl%, %user_login%, %user_email%, %user_pass%, %user_ip%</em></p>
|
90 |
+
Subject<br />
|
91 |
+
<input name="confirmation_subject" type="text" id="confirmation_subject" value="<?php echo htmlspecialchars($ThemeMyLogin->options['confirmation_email']['subject']); ?>" class="full-text" /><br />
|
92 |
+
Message<br />
|
93 |
+
<textarea name="confirmation_message" id="confirmation_message" class="large-text"><?php echo htmlspecialchars($ThemeMyLogin->options['confirmation_email']['message']); ?></textarea><br />
|
94 |
+
</td>
|
95 |
+
</tr>
|
96 |
+
</table>
|
97 |
+
</div>
|
98 |
+
|
99 |
+
<div id="fragment-4-6" class="tabs-div">
|
100 |
<table class="form-table">
|
101 |
<tr>
|
102 |
<td>
|
110 |
</table>
|
111 |
</div>
|
112 |
|
113 |
+
<div id="fragment-4-7" class="tabs-div">
|
114 |
<table class="form-table">
|
115 |
<tr>
|
116 |
<td>
|
admin/admin-general.php
CHANGED
@@ -1,40 +1,30 @@
|
|
1 |
<table class="form-table">
|
2 |
<tr valign="top">
|
3 |
-
<th scope="row"><?php _e('
|
4 |
<td>
|
5 |
-
<input name="
|
6 |
-
<label for="
|
|
|
|
|
7 |
</td>
|
8 |
</tr>
|
9 |
<tr valign="top">
|
10 |
-
<th scope="row"><?php _e('
|
11 |
<td>
|
12 |
-
<input name="
|
13 |
-
<label for="
|
|
|
|
|
|
|
|
|
14 |
</td>
|
15 |
</tr>
|
16 |
<tr valign="top">
|
17 |
-
<th scope="row"><?php _e('
|
18 |
<td>
|
19 |
-
<input name="
|
20 |
-
<label for="
|
21 |
-
|
22 |
-
</tr>
|
23 |
-
<tr valign="top">
|
24 |
-
<th scope="row"><?php _e('Registration', 'theme-my-login'); ?></th>
|
25 |
-
<td>
|
26 |
-
<input name="custom_pass" type="checkbox" id="custom_pass" value="1" <?php if ( $ThemeMyLogin->options['custom_pass'] ) { echo 'checked="checked"'; } ?> />
|
27 |
-
<label for="custom_pass"><?php _e('Allow Users To Set Their Own Password', 'theme-my-login'); ?></label>
|
28 |
-
<br />
|
29 |
-
<input name="moderate_users" type="checkbox" id="moderate_users" value="1" <?php if ( $ThemeMyLogin->options['moderate_users'] ) { echo 'checked="checked"'; } ?> />
|
30 |
-
<label for="moderate_users"><?php _e('New Users Must Approved', 'theme-my-login'); ?></label>
|
31 |
-
</td>
|
32 |
-
</tr>
|
33 |
-
<tr valign="top">
|
34 |
-
<th scope="row"><label for="page_id"><?php _e('Page ID', 'theme-my-login'); ?></label></th>
|
35 |
-
<td>
|
36 |
-
<input name="page_id" type="text" id="page_id" value="<?php echo $ThemeMyLogin->options['page_id']; ?>" size="1" />
|
37 |
-
<span class="description"><strong>DO NOT</strong> change this unless you are <strong>ABSOLUTELY POSITIVE</strong> you know what you are doing!</span>
|
38 |
</td>
|
39 |
</tr>
|
40 |
</table>
|
1 |
<table class="form-table">
|
2 |
<tr valign="top">
|
3 |
+
<th scope="row"><?php _e('Passwords', 'theme-my-login'); ?></th>
|
4 |
<td>
|
5 |
+
<input name="custom_pass" type="radio" id="custom_pass_off" value="0" <?php if ( 0 == $ThemeMyLogin->options['custom_pass'] ) { echo 'checked="checked"'; } ?> />
|
6 |
+
<label for="custom_pass_off"><?php _e('Auto-Generated', 'theme-my-login'); ?></label><br />
|
7 |
+
<input name="custom_pass" type="radio" id="custom_pass_on" value="1" <?php if ( 1 == $ThemeMyLogin->options['custom_pass'] ) { echo 'checked="checked"'; } ?> />
|
8 |
+
<label for="custom_pass_on"><?php _e('Custom', 'theme-my-login'); ?></label><br />
|
9 |
</td>
|
10 |
</tr>
|
11 |
<tr valign="top">
|
12 |
+
<th scope="row"><?php _e('User Moderation', 'theme-my-login'); ?></th>
|
13 |
<td>
|
14 |
+
<input name="moderation" type="radio" id="moderation_none" value="none" <?php if ( 'none' == $ThemeMyLogin->options['moderation'] ) { echo 'checked="checked"'; } ?> />
|
15 |
+
<label for="moderation_none"><?php _e('None', 'theme-my-login'); ?></label><br />
|
16 |
+
<input name="moderation" type="radio" id="moderation_email" value="email" <?php if ( 'email' == $ThemeMyLogin->options['moderation'] ) { echo 'checked="checked"'; } ?> />
|
17 |
+
<label for="moderation_email"><?php _e('E-mail Confirmation', 'theme-my-login'); ?></label><br />
|
18 |
+
<input name="moderation" type="radio" id="moderation_admin" value="admin" <?php if ( 'admin' == $ThemeMyLogin->options['moderation'] ) { echo 'checked="checked"'; } ?> />
|
19 |
+
<label for="moderation_admin"><?php _e('Admin Approval', 'theme-my-login'); ?></label>
|
20 |
</td>
|
21 |
</tr>
|
22 |
<tr valign="top">
|
23 |
+
<th scope="row"><?php _e('Stylesheet', 'theme-my-login'); ?></th>
|
24 |
<td>
|
25 |
+
<input name="use_css" type="checkbox" id="use_css" value="1" <?php if ( $ThemeMyLogin->options['use_css'] ) { echo 'checked="checked"'; } ?> />
|
26 |
+
<label for="use_css"><?php _e('Use theme-my-login.css', 'theme-my-login'); ?></label>
|
27 |
+
<p class="description"><?php _e('In order to keep changes between upgrades, you can store your customized "theme-my-login.css" in your current theme directory.', 'theme-my-login'); ?></p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
</td>
|
29 |
</tr>
|
30 |
</table>
|
admin/admin-links.php
CHANGED
@@ -2,7 +2,9 @@
|
|
2 |
<?php
|
3 |
$i = 1;
|
4 |
foreach ($user_roles as $role => $value) {
|
5 |
-
|
|
|
|
|
6 |
$i++;
|
7 |
}
|
8 |
?>
|
@@ -11,8 +13,12 @@
|
|
11 |
<?php
|
12 |
$i1 = 1;
|
13 |
foreach ($user_roles as $role => $value) {
|
|
|
|
|
14 |
?>
|
15 |
-
<div id="fragment-
|
|
|
|
|
16 |
|
17 |
<table id="links-<?php echo $role; ?>" class="form-table link-table">
|
18 |
<?php $i2 = 0; ?>
|
2 |
<?php
|
3 |
$i = 1;
|
4 |
foreach ($user_roles as $role => $value) {
|
5 |
+
if ( 'pending' == $role )
|
6 |
+
continue;
|
7 |
+
echo '<li><a href="#fragment-2-' . $i . '">' . ucwords($role) . '</a></li>' . "\n";
|
8 |
$i++;
|
9 |
}
|
10 |
?>
|
13 |
<?php
|
14 |
$i1 = 1;
|
15 |
foreach ($user_roles as $role => $value) {
|
16 |
+
if ( 'pending' == $role )
|
17 |
+
continue;
|
18 |
?>
|
19 |
+
<div id="fragment-2-<?php echo $i1; ?>" class="tabs-div">
|
20 |
+
|
21 |
+
<p class="description"><?php _e('These links will show up in the widget when a user is logged in, according to their role.', 'theme-my-login'); ?></p>
|
22 |
|
23 |
<table id="links-<?php echo $role; ?>" class="form-table link-table">
|
24 |
<?php $i2 = 0; ?>
|
admin/admin-redirection.php
CHANGED
@@ -1,22 +1,25 @@
|
|
1 |
<ul class="tabs-nav">
|
2 |
-
<li><a href="#fragment-
|
3 |
<?php
|
4 |
$i = 2;
|
5 |
foreach ($user_roles as $role => $value) {
|
6 |
-
|
|
|
|
|
7 |
$i++;
|
8 |
}
|
9 |
?>
|
10 |
</ul>
|
11 |
|
12 |
-
<div id="fragment-
|
13 |
<table class="form-table">
|
14 |
<tr valign="top">
|
15 |
<th scope="row"><?php _e('Redirection', 'theme-my-login'); ?></th>
|
16 |
<td>
|
17 |
-
<input name="override_redirect" type="
|
18 |
-
<label for="
|
19 |
-
<
|
|
|
20 |
</td>
|
21 |
</tr>
|
22 |
</table>
|
@@ -25,14 +28,18 @@
|
|
25 |
<?php
|
26 |
$i1 = 2;
|
27 |
foreach ($user_roles as $role => $value) {
|
|
|
|
|
28 |
?>
|
29 |
-
<div id="fragment-
|
30 |
|
31 |
<table id="redirection-<?php echo $role; ?>" class="form-table redirection-table">
|
32 |
<tr id="redirect-row-<?php echo $i2; ?>">
|
33 |
<td>
|
34 |
Log In URL<br />
|
35 |
-
<input name="redirects[<?php echo $role; ?>][login_url]" type="text" id="redirects[<?php echo $role; ?>][login_url]" value="<?php echo $redirects[$role]['login_url']; ?>" class="extended-text redirect-url" />
|
|
|
|
|
36 |
</td>
|
37 |
</tr>
|
38 |
</table>
|
1 |
<ul class="tabs-nav">
|
2 |
+
<li><a href="#fragment-3-1">General</a></li>
|
3 |
<?php
|
4 |
$i = 2;
|
5 |
foreach ($user_roles as $role => $value) {
|
6 |
+
if ( 'pending' == $role )
|
7 |
+
continue;
|
8 |
+
echo '<li><a href="#fragment-3-' . $i . '">' . ucwords($role) . '</a></li>' . "\n";
|
9 |
$i++;
|
10 |
}
|
11 |
?>
|
12 |
</ul>
|
13 |
|
14 |
+
<div id="fragment-3-1" class="tabs-div">
|
15 |
<table class="form-table">
|
16 |
<tr valign="top">
|
17 |
<th scope="row"><?php _e('Redirection', 'theme-my-login'); ?></th>
|
18 |
<td>
|
19 |
+
<input name="override_redirect" type="radio" id="override_redirect_on" value="1" <?php if ( 1 == $ThemeMyLogin->options['override_redirect'] ) { echo 'checked="checked"'; } ?> />
|
20 |
+
<label for="override_redirect_on"><?php _e('Allow Override', 'theme-my-login'); ?></label><br />
|
21 |
+
<input name="override_redirect" type="radio" id="override_redirect_off" value="0" <?php if ( 0 == $ThemeMyLogin->options['override_redirect'] ) { echo 'checked="checked"'; } ?> />
|
22 |
+
<label for="override_redirect_off"><?php _e('Always Redirect', 'theme-my-login'); ?></label><br />
|
23 |
</td>
|
24 |
</tr>
|
25 |
</table>
|
28 |
<?php
|
29 |
$i1 = 2;
|
30 |
foreach ($user_roles as $role => $value) {
|
31 |
+
if ( 'pending' == $role )
|
32 |
+
continue;
|
33 |
?>
|
34 |
+
<div id="fragment-3-<?php echo $i1; ?>" class="tabs-div">
|
35 |
|
36 |
<table id="redirection-<?php echo $role; ?>" class="form-table redirection-table">
|
37 |
<tr id="redirect-row-<?php echo $i2; ?>">
|
38 |
<td>
|
39 |
Log In URL<br />
|
40 |
+
<input name="redirects[<?php echo $role; ?>][login_url]" type="text" id="redirects[<?php echo $role; ?>][login_url]" value="<?php echo $redirects[$role]['login_url']; ?>" class="extended-text redirect-url" /><br />
|
41 |
+
Log Out URL<br />
|
42 |
+
<input name="redirects[<?php echo $role; ?>][logout_url]" type="text" id="redirects[<?php echo $role; ?>][logout_url]" value="<?php echo $redirects[$role]['logout_url']; ?>" class="extended-text redirect-url" /><br />
|
43 |
</td>
|
44 |
</tr>
|
45 |
</table>
|
admin/admin-template.php
DELETED
@@ -1,75 +0,0 @@
|
|
1 |
-
<ul class="tabs-nav">
|
2 |
-
<li><a href="#fragment-2-1">General</a></li>
|
3 |
-
<li><a href="#fragment-2-2">Titles</a></li>
|
4 |
-
<li><a href="#fragment-2-3">Messages</a></li>
|
5 |
-
</ul>
|
6 |
-
|
7 |
-
<div id="fragment-2-1" class="tabs-div">
|
8 |
-
<table class="form-table">
|
9 |
-
<tr valign="top">
|
10 |
-
<th scope="row"><?php _e('Stylesheet', 'theme-my-login'); ?></th>
|
11 |
-
<td>
|
12 |
-
<input name="use_css" type="checkbox" id="use_css" value="1" <?php if ( $ThemeMyLogin->options['use_css'] ) { echo 'checked="checked"'; } ?> />
|
13 |
-
<label for="use_css"><?php _e('Use theme-my-login.css', 'theme-my-login'); ?></label>
|
14 |
-
</td>
|
15 |
-
</tr>
|
16 |
-
</table>
|
17 |
-
</div>
|
18 |
-
|
19 |
-
<div id="fragment-2-2" class="tabs-div">
|
20 |
-
<table class="form-table">
|
21 |
-
<tr valign="top">
|
22 |
-
<th scope="row"><label for="welcome_title"><?php _e('Welcome', 'theme-my-login'); ?></label></th>
|
23 |
-
<td>
|
24 |
-
<input name="welcome_title" type="text" id="welcome_title" value="<?php echo htmlspecialchars($ThemeMyLogin->options['welcome_title']); ?>" class="regular-text" />
|
25 |
-
</td>
|
26 |
-
</tr>
|
27 |
-
<tr valign="top">
|
28 |
-
<th scope="row"><label for="login_title"><?php _e('Log In', 'theme-my-login'); ?></label></th>
|
29 |
-
<td>
|
30 |
-
<input name="login_title" type="text" id="login_title" value="<?php echo htmlspecialchars($ThemeMyLogin->options['login_title']); ?>" class="regular-text" />
|
31 |
-
</td>
|
32 |
-
</tr>
|
33 |
-
<tr valign="top">
|
34 |
-
<th scope="row"><label for="register_title"><?php _e('Register', 'theme-my-login'); ?></label></th>
|
35 |
-
<td>
|
36 |
-
<input name="register_title" type="text" id="register_title" value="<?php echo htmlspecialchars($ThemeMyLogin->options['register_title']); ?>" class="regular-text" />
|
37 |
-
</td>
|
38 |
-
</tr>
|
39 |
-
<tr valign="top">
|
40 |
-
<th scope="row"><label for="lost_pass_title"><?php _e('Lost Password', 'theme-my-login'); ?></label></th>
|
41 |
-
<td>
|
42 |
-
<input name="lost_pass_title" type="text" id="lost_pass_title" value="<?php echo htmlspecialchars($ThemeMyLogin->options['lost_pass_title']); ?>" class="regular-text" />
|
43 |
-
</td>
|
44 |
-
</tr>
|
45 |
-
<tr valign="top">
|
46 |
-
<th scope="row"><label for="logout_title"><?php _e('Log Out', 'theme-my-login'); ?></label></th>
|
47 |
-
<td>
|
48 |
-
<input name="logout_title" type="text" id="logout_title" value="<?php echo htmlspecialchars($ThemeMyLogin->options['logout_title']); ?>" class="regular-text" />
|
49 |
-
</td>
|
50 |
-
</tr>
|
51 |
-
</table>
|
52 |
-
</div>
|
53 |
-
|
54 |
-
<div id="fragment-2-3" class="tabs-div">
|
55 |
-
<table class="form-table">
|
56 |
-
<tr valign="top">
|
57 |
-
<th scope="row"><label for="register_message"><?php _e('Register', 'theme-my-login'); ?></label></th>
|
58 |
-
<td>
|
59 |
-
<input name="register_message" type="text" id="register_message" value="<?php echo htmlspecialchars($ThemeMyLogin->options['register_message']); ?>" class="extended-text" />
|
60 |
-
</td>
|
61 |
-
</tr>
|
62 |
-
<tr valign="top">
|
63 |
-
<th scope="row"><label for="success_message"><?php _e('Registration Complete', 'theme-my-login'); ?></label></th>
|
64 |
-
<td>
|
65 |
-
<input name="success_message" type="text" id="success_message" value="<?php echo htmlspecialchars($ThemeMyLogin->options['success_message']); ?>" class="extended-text" />
|
66 |
-
</td>
|
67 |
-
</tr>
|
68 |
-
<tr valign="top">
|
69 |
-
<th scope="row"><label for="lost_pass_message"><?php _e('Lost Password', 'theme-my-login'); ?></label></th>
|
70 |
-
<td>
|
71 |
-
<input name="lost_pass_message" type="text" id="lost_pass_message" value="<?php echo htmlspecialchars($ThemeMyLogin->options['lost_pass_message']); ?>" class="extended-text" />
|
72 |
-
</td>
|
73 |
-
</tr>
|
74 |
-
</table>
|
75 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/admin.php
CHANGED
@@ -1,39 +1,25 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
global $ThemeMyLogin, $wp_roles
|
4 |
$user_roles = $wp_roles->get_names();
|
5 |
|
6 |
if ( $_POST ) {
|
7 |
|
8 |
check_admin_referer('theme-my-login-settings');
|
9 |
|
10 |
-
$ThemeMyLogin->options['
|
11 |
-
$ThemeMyLogin->options['
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
add_role('pending', 'Pending', array());
|
16 |
-
add_role('denied', 'Denied', array());
|
17 |
} else {
|
18 |
-
$
|
19 |
-
|
20 |
-
remove_role('denied');
|
21 |
}
|
22 |
$ThemeMyLogin->options['use_css'] = isset($_POST['use_css']) ? 1 : 0;
|
23 |
-
$ThemeMyLogin->options['page_id'] = (int) $_POST['page_id'];
|
24 |
$ThemeMyLogin->options['email_from_name'] = stripslashes($_POST['email_from_name']);
|
25 |
$ThemeMyLogin->options['email_from'] = stripslashes($_POST['email_from']);
|
26 |
$ThemeMyLogin->options['email_content_type'] = stripslashes($_POST['email_content_type']);
|
27 |
-
|
28 |
-
$ThemeMyLogin->options['welcome_title'] = stripslashes($_POST['welcome_title']);
|
29 |
-
$ThemeMyLogin->options['login_title'] = stripslashes($_POST['login_title']);
|
30 |
-
$ThemeMyLogin->options['register_title'] = stripslashes($_POST['register_title']);
|
31 |
-
$ThemeMyLogin->options['lost_pass_title'] = stripslashes($_POST['lost_pass_title']);
|
32 |
-
$ThemeMyLogin->options['logout_title'] = stripslashes($_POST['logout_title']);
|
33 |
-
|
34 |
-
$ThemeMyLogin->options['register_message'] = stripslashes($_POST['register_message']);
|
35 |
-
$ThemeMyLogin->options['success_message'] = stripslashes($_POST['success_message']);
|
36 |
-
$ThemeMyLogin->options['lost_pass_message'] = stripslashes($_POST['lost_pass_message']);
|
37 |
|
38 |
foreach ( $_POST['links'] as $role => $tmp ) {
|
39 |
foreach ( $tmp as $key => $data ) {
|
@@ -42,12 +28,17 @@ if ( $_POST ) {
|
|
42 |
}
|
43 |
$ThemeMyLogin->options['links'] = $links;
|
44 |
|
45 |
-
$ThemeMyLogin->options['override_redirect'] =
|
46 |
foreach ( $_POST['redirects'] as $role => $data ) {
|
47 |
-
$redirects[$role] = array('login_url' => $data['login_url']);
|
48 |
}
|
49 |
$ThemeMyLogin->options['redirects'] = $redirects;
|
50 |
|
|
|
|
|
|
|
|
|
|
|
51 |
$ThemeMyLogin->options['retrieve_pass_email'] = array(
|
52 |
'subject' => stripslashes($_POST['retrieve_pass_subject']),
|
53 |
'message' => stripslashes($_POST['retrieve_pass_message'])
|
@@ -57,11 +48,9 @@ if ( $_POST ) {
|
|
57 |
'message' => stripslashes($_POST['reset_pass_message']),
|
58 |
'admin_disable' => isset($_POST['reset_pass_admin_disable']) ? 1 : 0
|
59 |
);
|
60 |
-
$ThemeMyLogin->options['
|
61 |
-
'subject' => stripslashes($_POST['
|
62 |
-
'message' => stripslashes($_POST['
|
63 |
-
'admin_disable' => isset($_POST['registration_admin_disable']) ? 1 : 0,
|
64 |
-
'user_disable' => isset($_POST['registration_user_disable']) ? 1 : 0
|
65 |
);
|
66 |
$ThemeMyLogin->options['user_approval_email'] = array(
|
67 |
'subject' => stripslashes($_POST['user_approval_subject']),
|
@@ -72,15 +61,9 @@ if ( $_POST ) {
|
|
72 |
'message' => stripslashes($_POST['user_denial_message'])
|
73 |
);
|
74 |
|
75 |
-
$ThemeMyLogin->
|
76 |
-
|
77 |
-
|
78 |
-
$info_message = __('To complete uninstall, deactivate this plugin. If you do not wish to uninstall, please uncheck the "Complete Uninstall" checkbox.', 'theme-my-login');
|
79 |
-
} elseif ( isset($_POST['defaults']) ) {
|
80 |
-
$ThemeMyLogin->options = '';
|
81 |
-
$ThemeMyLogin->InitOptions(true);
|
82 |
-
$info_message = __('All settings restored to default state.', 'theme-my-login');
|
83 |
-
} else $info_message =__('Settings saved.', 'theme-my-login');
|
84 |
}
|
85 |
|
86 |
$links = $ThemeMyLogin->options['links'];
|
@@ -116,10 +99,9 @@ $redirects = $ThemeMyLogin->options['redirects'];
|
|
116 |
|
117 |
<ul class="tabs-nav">
|
118 |
<li><a href="#fragment-1">General</a></li>
|
119 |
-
<li><a href="#fragment-2">
|
120 |
-
<li><a href="#fragment-3">
|
121 |
-
<li><a href="#fragment-4">
|
122 |
-
<li><a href="#fragment-5">E-mail</a></li>
|
123 |
</ul>
|
124 |
|
125 |
<div id="fragment-1" class="tabs-div">
|
@@ -127,28 +109,20 @@ $redirects = $ThemeMyLogin->options['redirects'];
|
|
127 |
</div>
|
128 |
|
129 |
<div id="fragment-2" class="tabs-div">
|
130 |
-
<?php include WP_PLUGIN_DIR . '/theme-my-login/admin/admin-template.php'; ?>
|
131 |
-
</div>
|
132 |
-
|
133 |
-
<div id="fragment-3" class="tabs-div">
|
134 |
<?php include WP_PLUGIN_DIR . '/theme-my-login/admin/admin-links.php'; ?>
|
135 |
</div>
|
136 |
|
137 |
-
<div id="fragment-
|
138 |
<?php include WP_PLUGIN_DIR . '/theme-my-login/admin/admin-redirection.php'; ?>
|
139 |
</div>
|
140 |
|
141 |
-
<div id="fragment-
|
142 |
<?php include WP_PLUGIN_DIR . '/theme-my-login/admin/admin-email.php'; ?>
|
143 |
</div>
|
144 |
|
145 |
</div>
|
146 |
|
147 |
-
<?php if ( version_compare($wp_version, '2.7', '>=') ) : ?>
|
148 |
<p><input type="submit" name="Submit" class="button-primary" value="<?php _e('Save Changes'); ?>" /></p>
|
149 |
-
<?php else : ?>
|
150 |
-
<p><input type="submit" name="Submit" class="button" value="<?php _e('Save Changes'); ?>" /></p>
|
151 |
-
<?php endif; ?>
|
152 |
</form>
|
153 |
|
154 |
</div>
|
1 |
<?php
|
2 |
|
3 |
+
global $ThemeMyLogin, $wp_roles;
|
4 |
$user_roles = $wp_roles->get_names();
|
5 |
|
6 |
if ( $_POST ) {
|
7 |
|
8 |
check_admin_referer('theme-my-login-settings');
|
9 |
|
10 |
+
$ThemeMyLogin->options['custom_pass'] = ( $_POST['custom_pass'] ) ? 1 : 0;
|
11 |
+
$ThemeMyLogin->options['moderation'] = ( in_array($_POST['moderation'], array('none', 'email', 'admin')) ) ? $_POST['moderation'] : 'none';
|
12 |
+
if ( in_array($_POST['moderation'], array('email', 'admin')) ) {
|
13 |
+
if ( !$wp_roles->is_role('pending') )
|
14 |
+
add_role('pending', 'Pending', array());
|
|
|
|
|
15 |
} else {
|
16 |
+
if ( $wp_roles->is_role('pending') )
|
17 |
+
remove_role('pending');
|
|
|
18 |
}
|
19 |
$ThemeMyLogin->options['use_css'] = isset($_POST['use_css']) ? 1 : 0;
|
|
|
20 |
$ThemeMyLogin->options['email_from_name'] = stripslashes($_POST['email_from_name']);
|
21 |
$ThemeMyLogin->options['email_from'] = stripslashes($_POST['email_from']);
|
22 |
$ThemeMyLogin->options['email_content_type'] = stripslashes($_POST['email_content_type']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
foreach ( $_POST['links'] as $role => $tmp ) {
|
25 |
foreach ( $tmp as $key => $data ) {
|
28 |
}
|
29 |
$ThemeMyLogin->options['links'] = $links;
|
30 |
|
31 |
+
$ThemeMyLogin->options['override_redirect'] = ( $_POST['override_redirect'] ) ? 1 : 0;
|
32 |
foreach ( $_POST['redirects'] as $role => $data ) {
|
33 |
+
$redirects[$role] = array('login_url' => $data['login_url'], 'logout_url' => $data['logout_url']);
|
34 |
}
|
35 |
$ThemeMyLogin->options['redirects'] = $redirects;
|
36 |
|
37 |
+
$ThemeMyLogin->options['registration_email'] = array(
|
38 |
+
'subject' => stripslashes($_POST['registration_subject']),
|
39 |
+
'message' => stripslashes($_POST['registration_message']),
|
40 |
+
'admin_disable' => isset($_POST['registration_admin_disable']) ? 1 : 0
|
41 |
+
);
|
42 |
$ThemeMyLogin->options['retrieve_pass_email'] = array(
|
43 |
'subject' => stripslashes($_POST['retrieve_pass_subject']),
|
44 |
'message' => stripslashes($_POST['retrieve_pass_message'])
|
48 |
'message' => stripslashes($_POST['reset_pass_message']),
|
49 |
'admin_disable' => isset($_POST['reset_pass_admin_disable']) ? 1 : 0
|
50 |
);
|
51 |
+
$ThemeMyLogin->options['confirmation_email'] = array(
|
52 |
+
'subject' => stripslashes($_POST['confirmation_subject']),
|
53 |
+
'message' => stripslashes($_POST['confirmation_message'])
|
|
|
|
|
54 |
);
|
55 |
$ThemeMyLogin->options['user_approval_email'] = array(
|
56 |
'subject' => stripslashes($_POST['user_approval_subject']),
|
61 |
'message' => stripslashes($_POST['user_denial_message'])
|
62 |
);
|
63 |
|
64 |
+
$ThemeMyLogin->saveOptions();
|
65 |
+
|
66 |
+
$info_message =__('Settings saved.', 'theme-my-login');
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
}
|
68 |
|
69 |
$links = $ThemeMyLogin->options['links'];
|
99 |
|
100 |
<ul class="tabs-nav">
|
101 |
<li><a href="#fragment-1">General</a></li>
|
102 |
+
<li><a href="#fragment-2">Links</a></li>
|
103 |
+
<li><a href="#fragment-3">Redirection</a></li>
|
104 |
+
<li><a href="#fragment-4">E-mail</a></li>
|
|
|
105 |
</ul>
|
106 |
|
107 |
<div id="fragment-1" class="tabs-div">
|
109 |
</div>
|
110 |
|
111 |
<div id="fragment-2" class="tabs-div">
|
|
|
|
|
|
|
|
|
112 |
<?php include WP_PLUGIN_DIR . '/theme-my-login/admin/admin-links.php'; ?>
|
113 |
</div>
|
114 |
|
115 |
+
<div id="fragment-3" class="tabs-div">
|
116 |
<?php include WP_PLUGIN_DIR . '/theme-my-login/admin/admin-redirection.php'; ?>
|
117 |
</div>
|
118 |
|
119 |
+
<div id="fragment-4" class="tabs-div">
|
120 |
<?php include WP_PLUGIN_DIR . '/theme-my-login/admin/admin-email.php'; ?>
|
121 |
</div>
|
122 |
|
123 |
</div>
|
124 |
|
|
|
125 |
<p><input type="submit" name="Submit" class="button-primary" value="<?php _e('Save Changes'); ?>" /></p>
|
|
|
|
|
|
|
126 |
</form>
|
127 |
|
128 |
</div>
|
classes/class.widget-old.php
DELETED
@@ -1,76 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( !function_exists('ThemeMyLoginWidget') ) :
|
4 |
-
class ThemeMyLoginWidget {
|
5 |
-
|
6 |
-
function ThemeMyLoginWidget() {
|
7 |
-
add_action('plugins_loaded', array(&$this, 'PluginsLoaded'));
|
8 |
-
}
|
9 |
-
|
10 |
-
function PluginsLoaded() {
|
11 |
-
wp_register_sidebar_widget('theme-my-login', 'Theme My Login', array(&$this, 'Widget'), array('description' => 'A login form for your blog'));
|
12 |
-
wp_register_widget_control('theme-my-login', 'Theme My Login', array(&$this, 'WidgetControl'));
|
13 |
-
}
|
14 |
-
|
15 |
-
function Widget($args) {
|
16 |
-
global $ThemeMyLogin;
|
17 |
-
echo $ThemeMyLogin->ThemeMyLoginShortcode($args);
|
18 |
-
}
|
19 |
-
|
20 |
-
function WidgetControl() {
|
21 |
-
global $ThemeMyLogin;
|
22 |
-
|
23 |
-
if ( $_POST['tml_submit'] ) {
|
24 |
-
|
25 |
-
$widget['default_action'] = $_POST['tml_default_action'];
|
26 |
-
$ThemeMyLogin->options['logged_in_widget'] = (empty($_POST['tml_show_logged'])) ? false : true;
|
27 |
-
$ThemeMyLogin->options['show_title'] = (empty($_POST['tml_show_title'])) ? false : true;
|
28 |
-
$ThemeMyLogin->options['show_log_link'] = (empty($_POST['tml_show_log_link'])) ? false: true;
|
29 |
-
$ThemeMyLogin->options['show_reg_link'] = (empty($_POST['tml_show_reg_link'])) ? false: true;
|
30 |
-
$ThemeMyLogin->options['show_pass_link'] = (empty($_POST['tml_show_pass_link'])) ? false: true;
|
31 |
-
$ThemeMyLogin->options['show_gravatar'] = (empty($_POST['tml_show_gravatar'])) ? false : true;
|
32 |
-
$ThemeMyLogin->options['gravatar_size'] = absint($_POST['tml_gravatar_size']);
|
33 |
-
$ThemeMyLogin->options['register_widget'] = (empty($_POST['tml_register_widget'])) ? false : true;
|
34 |
-
$ThemeMyLogin->options['lost_pass_widget'] = (empty($_POST['tml_lost_pass_widget'])) ? false : true;
|
35 |
-
$ThemeMyLogin->SaveOptions();
|
36 |
-
|
37 |
-
}
|
38 |
-
|
39 |
-
$ThemeMyLogin->options = $ThemeMyLogin->GetOption('widget');
|
40 |
-
|
41 |
-
$actions = array('login' => 'Login', 'register' => 'Register', 'lostpassword' => 'Lost Password');
|
42 |
-
echo '<p>Default Action<br /><select name="tml_default_action" id="tml_default_action">';
|
43 |
-
foreach ($actions as $action => $title) {
|
44 |
-
$is_selected = ($ThemeMyLogin->options['default_action'] == $action) ? ' selected="selected"' : '';
|
45 |
-
echo '<option value="' . $action . '"' . $is_selected . '>' . $title . '</option>';
|
46 |
-
}
|
47 |
-
echo '</select></p>' . "\n";
|
48 |
-
$is_checked = (empty($ThemeMyLogin->options['show_logged'])) ? '' : 'checked="checked" ';
|
49 |
-
echo '<p><input name="tml_show_logged" type="checkbox" id="tml_show_logged" value="1" ' . $is_checked . '/> <label for="tml_show_logged">' . __('Show When Logged In', 'theme-my-login') . '</label></p>' . "\n";
|
50 |
-
$is_checked = (empty($ThemeMyLogin->options['show_title'])) ? '' : 'checked="checked" ';
|
51 |
-
echo '<p><input name="tml_show_title" type="checkbox" id="tml_show_title" value="1" ' . $is_checked . '/> <label for="tml_show_title">' . __('Show Title', 'theme-my-login') . '</label></p>' . "\n";
|
52 |
-
$is_checked = (empty($ThemeMyLogin->options['show_login_link'])) ? '' : 'checked="checked" ';
|
53 |
-
echo '<p><input name="tml_show_login_link" type="checkbox" id="tml_show_login_link" value="1" ' . $is_checked . '/> <label for="tml_show_log_link">' . __('Show Login Link', 'theme-my-login') . '</label></p>' . "\n";
|
54 |
-
$is_checked = (empty($ThemeMyLogin->options['show_reg_link'])) ? '' : 'checked="checked" ';
|
55 |
-
echo '<p><input name="tml_show_reg_link" type="checkbox" id="tml_show_reg_link" value="1" ' . $is_checked . '/> <label for="tml_show_reg_link">' . __('Show Registration Link', 'theme-my-login') . '</label></p>' . "\n";
|
56 |
-
$is_checked = (empty($ThemeMyLogin->options['show_pass_link'])) ? '' : 'checked="checked" ';
|
57 |
-
echo '<p><input name="tml_show_pass_link" type="checkbox" id="tml_show_pass_link" value="1" ' . $is_checked . '/> <label for="tml_show_pass_link">' . __('Show Lost Password Link', 'theme-my-login') . '</label></p>' . "\n";
|
58 |
-
$is_checked = (empty($ThemeMyLogin->options['show_gravatar'])) ? '' : 'checked="checked" ';
|
59 |
-
echo '<p><input name="tml_show_gravatar" type="checkbox" id="tml_show_gravatar" value="1" ' . $is_checked . '/> <label for="tml_show_gravatar">' . __('Show Gravatar', 'theme-my-login') . '</label></p>' . "\n";
|
60 |
-
echo '<p>' . __('Gravatar Size', 'theme-my-login') . ': <input name="tml_gravatar_size" type="text" id="tml_gravatar_size" value="' . $ThemeMyLogin->options['gravatar_size'] . '" size="3" /> <label for="tml_gravatar_size"></label></p>' . "\n";
|
61 |
-
$is_checked = (empty($ThemeMyLogin->options['register_widget'])) ? '' : 'checked="checked" ';
|
62 |
-
echo '<p><input name="tml_register_widget" type="checkbox" id="tml_register_widget" value="1" ' . $is_checked . '/> <label for="tml_register_widget">' . __('Allow Registration', 'theme-my-login') . '</label></p>' . "\n";
|
63 |
-
$is_checked = (empty($ThemeMyLogin->options['lost_pass_widget'])) ? '' : 'checked="checked" ';
|
64 |
-
echo '<p><input name="tml_lost_pass_widget" type="checkbox" id="tml_lost_pass_widget" value="1" ' . $is_checked . '/> <label for="tml_lost_pass_widget">' . __('Allow Password Recovery', 'theme-my-login') . '</label></p>' . "\n";
|
65 |
-
echo '<p><input type="hidden" id="tml_submit" name="tml_submit" value="1" /></p>' . "\n";
|
66 |
-
|
67 |
-
}
|
68 |
-
|
69 |
-
}
|
70 |
-
endif;
|
71 |
-
|
72 |
-
if (class_exists('ThemeMyLoginWidget')) {
|
73 |
-
$ThemeMyLoginWidget = new ThemeMyLoginWidget();
|
74 |
-
}
|
75 |
-
|
76 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/class.wp-login.php
DELETED
@@ -1,652 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( !class_exists('WPLogin') ) {
|
4 |
-
class WPLogin {
|
5 |
-
|
6 |
-
var $textdomain;
|
7 |
-
|
8 |
-
var $action;
|
9 |
-
var $errors;
|
10 |
-
var $redirect_to;
|
11 |
-
var $secure_cookie;
|
12 |
-
|
13 |
-
var $instance;
|
14 |
-
|
15 |
-
var $options;
|
16 |
-
|
17 |
-
function WPLogin($textdomain = '', $options = '') {
|
18 |
-
$this->__construct($textdomain, $options);
|
19 |
-
}
|
20 |
-
|
21 |
-
function __construct($textdomain = '', $options = '') {
|
22 |
-
|
23 |
-
$this->textdomain = $textdomain;
|
24 |
-
|
25 |
-
$this->LoadOptions($options);
|
26 |
-
|
27 |
-
$this->ForceSSL();
|
28 |
-
|
29 |
-
$this->action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
|
30 |
-
$this->instance = isset($_REQUEST['instance']) ? $_REQUEST['instance'] : '';
|
31 |
-
$this->errors = new WP_Error();
|
32 |
-
|
33 |
-
if ( isset($_GET['key']) )
|
34 |
-
$this->action = 'resetpass';
|
35 |
-
|
36 |
-
nocache_headers();
|
37 |
-
|
38 |
-
header('Content-Type: '.get_bloginfo('html_type').'; charset='.get_bloginfo('charset'));
|
39 |
-
|
40 |
-
$this->HandleRelocate();
|
41 |
-
|
42 |
-
$this->SetTestCookie();
|
43 |
-
|
44 |
-
if ( !empty( $_REQUEST['redirect_to'] ) ) {
|
45 |
-
$this->redirect_to = $_REQUEST['redirect_to'];
|
46 |
-
// Redirect to https if user wants ssl
|
47 |
-
if ( $this->secure_cookie && false !== strpos($this->redirect_to, 'wp-admin') )
|
48 |
-
$this->redirect_to = preg_replace('|^http://|', 'https://', $this->redirect_to);
|
49 |
-
} else {
|
50 |
-
$this->redirect_to = admin_url();
|
51 |
-
}
|
52 |
-
|
53 |
-
$this->redirect_to = apply_filters('login_redirect', $this->redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', '');
|
54 |
-
|
55 |
-
// allow plugins to override the default actions, and to add extra actions if they want
|
56 |
-
do_action('login_form_' . $this->action);
|
57 |
-
|
58 |
-
switch ($this->action) {
|
59 |
-
|
60 |
-
case 'logout' :
|
61 |
-
$this->LogoutAction();
|
62 |
-
break;
|
63 |
-
|
64 |
-
case 'lostpassword' :
|
65 |
-
case 'retrievepassword' :
|
66 |
-
$this->RetrievePasswordAction();
|
67 |
-
break;
|
68 |
-
|
69 |
-
case 'resetpass' :
|
70 |
-
case 'rp' :
|
71 |
-
$this->ResetPassAction();
|
72 |
-
break;
|
73 |
-
|
74 |
-
case 'register' :
|
75 |
-
$this->RegisterAction();
|
76 |
-
break;
|
77 |
-
|
78 |
-
case 'login' :
|
79 |
-
default:
|
80 |
-
$this->LoginAction();
|
81 |
-
break;
|
82 |
-
}
|
83 |
-
|
84 |
-
}
|
85 |
-
|
86 |
-
function Display($instance, $args = '') {
|
87 |
-
global $user_ID, $current_user, $wp_version;
|
88 |
-
|
89 |
-
$this->LoadOptions($args);
|
90 |
-
|
91 |
-
$action = (isset($this->options['default_action'])) ? $this->options['default_action'] : 'login';
|
92 |
-
if ( $instance == $this->instance || (empty($this->instance) && 'tml-main' == $instance) )
|
93 |
-
$action = $this->action;
|
94 |
-
|
95 |
-
ob_start();
|
96 |
-
echo $this->options['before_widget'];
|
97 |
-
if ( is_user_logged_in() ) {
|
98 |
-
if ( $this->options['logged_in_widget'] ) {
|
99 |
-
$user = new WP_User($user_ID);
|
100 |
-
$user_role = array_shift($user->roles);
|
101 |
-
$replace_this = array('/%user_login%/', '/%display_name%/');
|
102 |
-
$replace_with = array($user->user_login, $user->display_name);
|
103 |
-
$welcome = preg_replace($replace_this, $replace_with, $this->options['welcome_title']);
|
104 |
-
if ( $this->options['show_title'] )
|
105 |
-
echo $this->options['before_title'] . $welcome . $this->options['after_title'] . "\n";
|
106 |
-
if ($this->options['show_gravatar'])
|
107 |
-
echo '<div class="login-avatar">' . get_avatar( $user_ID, $size = $this->options['gravatar_size'] ) . '</div>' . "\n";
|
108 |
-
do_action('login_avatar', $current_user);
|
109 |
-
echo '<ul class="login-links">' . "\n";
|
110 |
-
foreach ($this->options['links'][$user_role] as $key => $data) {
|
111 |
-
echo '<li><a href="' . $data['url'] . '">' . $data['title'] . '</a></li>' . "\n";
|
112 |
-
}
|
113 |
-
do_action('login_links', $current_user);
|
114 |
-
$redirect = $this->GuessURL();
|
115 |
-
if ( version_compare($wp_version, '2.7', '>=') )
|
116 |
-
echo '<li><a href="' . wp_logout_url($redirect) . '">' . __('Log Out') . '</a></li>' . "\n";
|
117 |
-
else
|
118 |
-
echo '<li><a href="' . site_url('wp-login.php?action=logout&redirect_to='.$redirect, 'login') . '">' . __('Log Out') . '</a></li>' . "\n";
|
119 |
-
echo '</ul>' . "\n";
|
120 |
-
}
|
121 |
-
} else {
|
122 |
-
if ( $this->options['show_title'] )
|
123 |
-
echo $this->options['before_title'] . $this->GetTitle($instance) . $this->options['after_title'] . "\n";
|
124 |
-
if ( $instance == $this->instance || !empty($action) ) {
|
125 |
-
switch ($action) {
|
126 |
-
case 'lostpassword' :
|
127 |
-
case 'retrievepassword' :
|
128 |
-
echo $this->RetrievePasswordForm($instance);
|
129 |
-
break;
|
130 |
-
case 'register' :
|
131 |
-
echo $this->RegisterForm($instance);
|
132 |
-
break;
|
133 |
-
case 'login' :
|
134 |
-
default :
|
135 |
-
echo $this->LoginForm($instance);
|
136 |
-
break;
|
137 |
-
}
|
138 |
-
} else {
|
139 |
-
echo $this->LoginForm($instance);
|
140 |
-
}
|
141 |
-
}
|
142 |
-
echo $this->options['after_widget'] . "\n";
|
143 |
-
$contents = ob_get_contents();
|
144 |
-
ob_end_clean();
|
145 |
-
return $contents;
|
146 |
-
}
|
147 |
-
|
148 |
-
function LoadOptions($options = array()) {
|
149 |
-
$this->options = wp_parse_args($options);
|
150 |
-
}
|
151 |
-
|
152 |
-
function GetTitle($instance) {
|
153 |
-
$action = (isset($this->options['default_action'])) ? $this->options['default_action'] : 'login';
|
154 |
-
if ( $instance == $this->instance || (empty($this->instance) && 'tml-main' == $instance) )
|
155 |
-
$action = $this->action;
|
156 |
-
|
157 |
-
switch ($action) {
|
158 |
-
case 'register':
|
159 |
-
return $this->options['register_title'];
|
160 |
-
break;
|
161 |
-
case 'lostpassword':
|
162 |
-
case 'retrievepassword':
|
163 |
-
return $this->options['lost_pass_title'];
|
164 |
-
break;
|
165 |
-
case 'login':
|
166 |
-
default:
|
167 |
-
return $this->options['login_title'];
|
168 |
-
break;
|
169 |
-
}
|
170 |
-
}
|
171 |
-
|
172 |
-
function PageHeader($instance, $message = '') {
|
173 |
-
global $error;
|
174 |
-
|
175 |
-
echo '<div class="login" id="' . $instance . '">';
|
176 |
-
|
177 |
-
if ( !empty( $message ) ) echo '<p class="message">' . apply_filters('login_message', $message) . "</p>\n";
|
178 |
-
|
179 |
-
// Incase a plugin uses $error rather than the $errors object
|
180 |
-
if ( !empty( $error ) ) {
|
181 |
-
$this->errors->add('error', $error);
|
182 |
-
unset($error);
|
183 |
-
}
|
184 |
-
|
185 |
-
if ( $instance == $this->instance || (empty($this->instance) && 'tml-main' == $instance) ) {
|
186 |
-
if ( $this->errors->get_error_code() ) {
|
187 |
-
$errors = '';
|
188 |
-
$messages = '';
|
189 |
-
foreach ( $this->errors->get_error_codes() as $code ) {
|
190 |
-
$severity = $this->errors->get_error_data($code);
|
191 |
-
foreach ( $this->errors->get_error_messages($code) as $error ) {
|
192 |
-
if ( 'message' == $severity )
|
193 |
-
$messages .= ' ' . $error . "<br />\n";
|
194 |
-
else
|
195 |
-
$errors .= ' ' . $error . "<br />\n";
|
196 |
-
}
|
197 |
-
}
|
198 |
-
if ( !empty($errors) )
|
199 |
-
echo '<p class="error">' . apply_filters('login_errors', $errors) . "</p>\n";
|
200 |
-
if ( !empty($messages) )
|
201 |
-
echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n";
|
202 |
-
}
|
203 |
-
}
|
204 |
-
}
|
205 |
-
|
206 |
-
function PageFooter($instance) {
|
207 |
-
$action = (isset($this->options['default_action'])) ? $this->options['default_action'] : 'login';
|
208 |
-
if ( $instance == $this->instance || (empty($this->instance) && 'tml-main' == $instance) )
|
209 |
-
$action = $this->action;
|
210 |
-
|
211 |
-
echo '<ul class="links">' . "\n";
|
212 |
-
if ( $this->options['show_log_link'] && in_array($action, array('register', 'lostpassword')) || $action == 'login' && isset($_GET['checkemail']) && 'registered' != $_GET['checkemail'] ) {
|
213 |
-
$url = $this->GuessURL(array('instance' => $instance, 'action' => 'login'));
|
214 |
-
echo '<li><a href="' . $url . '">' . $this->options['login_title'] . '</a></li>' . "\n";
|
215 |
-
}
|
216 |
-
if ( $this->options['show_reg_link'] && get_option('users_can_register') ) {
|
217 |
-
if ( 'register' != $action ) {
|
218 |
-
$url = ($this->options['register_widget']) ? $this->GuessURL(array('instance' => $instance, 'action' => 'register')) : site_url('wp-login.php?action=register', 'login');
|
219 |
-
$url = apply_filters('login_footer_registration_link', $url);
|
220 |
-
echo '<li><a href="' . $url . '">' . $this->options['register_title'] . '</a></li>' . "\n";
|
221 |
-
}
|
222 |
-
}
|
223 |
-
if ( $this->options['show_pass_link'] ) {
|
224 |
-
if ( 'lostpassword' != $action ) {
|
225 |
-
$url = ($this->options['lost_pass_widget']) ? $this->GuessURL(array('instance' => $instance, 'action' => 'lostpassword')) : site_url('wp-login.php?action=lostpassword', 'login');
|
226 |
-
$url = apply_filters('login_footer_forgotpassword_link', $url);
|
227 |
-
echo '<li><a href="' . $url . '">' . $this->options['lost_pass_title'] . '</a></li>' . "\n";
|
228 |
-
}
|
229 |
-
}
|
230 |
-
echo '</ul>' . "\n";
|
231 |
-
echo '</div>' . "\n";
|
232 |
-
}
|
233 |
-
|
234 |
-
function LoginForm($instance) {
|
235 |
-
|
236 |
-
// Clear errors if loggedout is set.
|
237 |
-
if ( !empty($_GET['loggedout']) )
|
238 |
-
$this->errors = new WP_Error();
|
239 |
-
|
240 |
-
// If cookies are disabled we can't log in even with a valid user+pass
|
241 |
-
if ( isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE]) )
|
242 |
-
$this->errors->add('test_cookie', __("<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress."));
|
243 |
-
|
244 |
-
// Some parts of this script use the main login form to display a message
|
245 |
-
if ( isset($_GET['loggedout']) && TRUE == $_GET['loggedout'] ) $this->errors->add('loggedout', __('You are now logged out.'), 'message');
|
246 |
-
elseif ( isset($_GET['registration']) && 'disabled' == $_GET['registration'] ) $this->errors->add('registerdisabled', __('User registration is currently not allowed.'));
|
247 |
-
elseif ( isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail'] ) $this->errors->add('confirm', __('Check your e-mail for the confirmation link.'), 'message');
|
248 |
-
elseif ( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] ) $this->errors->add('newpass', __('Check your e-mail for your new password.'), 'message');
|
249 |
-
elseif ( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] ) $this->errors->add('registered', $this->options['success_message'], 'message');
|
250 |
-
|
251 |
-
$this->PageHeader($instance);
|
252 |
-
|
253 |
-
if ( isset($_POST['log']) )
|
254 |
-
$user_login = ( 'incorrect_password' == $this->errors->get_error_code() || 'empty_password' == $this->errors->get_error_code() ) ? attribute_escape(stripslashes($_POST['log'])) : '';
|
255 |
-
|
256 |
-
$user_login = ( $this->instance == $instance && isset($user_login) ) ? $user_login : '';
|
257 |
-
|
258 |
-
if ( !isset($_GET['checkemail']) || (isset($_GET['checkemail']) && $instance != $this->instance) || (!in_array( $_GET['checkemail'], array('confirm', 'newpass') ) && $instance == $this->instance) || (in_array( $_GET['checkemail'], array('confirm', 'newpass') ) && $instance != $this->instance) ) {
|
259 |
-
?>
|
260 |
-
<form name="loginform-<?php echo $instance; ?>" id="loginform-<?php echo $instance; ?>" action="<?php echo $this->GuessURL(array('instance' => $instance, 'action' => 'login')); ?>" method="post">
|
261 |
-
<p>
|
262 |
-
<label for="log-<?php echo $instance; ?>"><?php _e('Username') ?></label>
|
263 |
-
<input type="text" name="log-<?php echo $instance; ?>" id="log-<?php echo $instance; ?>" class="input" value="<?php echo isset($user_login) ? $user_login : ''; ?>" size="20" />
|
264 |
-
</p>
|
265 |
-
<p>
|
266 |
-
<label for="pwd-<?php echo $instance; ?>"><?php _e('Password') ?></label>
|
267 |
-
<input type="password" name="pwd-<?php echo $instance; ?>" id="pwd-<?php echo $instance; ?>" class="input" value="" size="20" />
|
268 |
-
</p>
|
269 |
-
<?php do_action('login_form', $instance); ?>
|
270 |
-
<p class="forgetmenot"><input name="rememberme-<?php echo $instance; ?>" type="checkbox" id="rememberme-<?php echo $instance; ?>" value="forever" /> <label for="rememberme-<?php echo $instance; ?>"><?php _e('Remember Me'); ?></label></p>
|
271 |
-
<p class="submit">
|
272 |
-
<input type="submit" name="login-submit-<?php echo $instance; ?>" id="login-submit-<?php echo $instance; ?>" value="<?php _e('Log In'); ?>" />
|
273 |
-
<input type="hidden" name="redirect_to" value="<?php echo attribute_escape($this->redirect_to); ?>" />
|
274 |
-
<input type="hidden" name="testcookie" value="1" />
|
275 |
-
</p>
|
276 |
-
</form>
|
277 |
-
<?php
|
278 |
-
}
|
279 |
-
if ($instance == $this->instance) { ?>
|
280 |
-
<script type="text/javascript">
|
281 |
-
<?php if ( $user_login ) { ?>
|
282 |
-
setTimeout( function(){ try{
|
283 |
-
d = document.getElementById('user_pass-<?php echo $this->instance; ?>');
|
284 |
-
d.value = '';
|
285 |
-
d.focus();
|
286 |
-
} catch(e){}
|
287 |
-
}, 200);
|
288 |
-
<?php } else { ?>
|
289 |
-
try{document.getElementById('user_login-<?php echo $this->instance; ?>').focus();}catch(e){}
|
290 |
-
<?php } ?>
|
291 |
-
</script>
|
292 |
-
<?php }
|
293 |
-
$this->PageFooter($instance);
|
294 |
-
}
|
295 |
-
|
296 |
-
function RegisterForm($instance) {
|
297 |
-
$user_login = isset($_POST['user_login-'.$instance]) ? $_POST['user_login-'.$instance] : '';
|
298 |
-
$user_email = isset($_POST['user_email-'.$instance]) ? $_POST['user_email-'.$instance] : '';
|
299 |
-
$this->PageHeader($instance);
|
300 |
-
?>
|
301 |
-
<form name="registerform-<?php echo $instance; ?>" id="registerform-<?php echo $instance; ?>" action="<?php echo $this->GuessURL(array('instance' => $instance, 'action' => 'register')); ?>" method="post">
|
302 |
-
<p>
|
303 |
-
<label for="user_login-<?php echo $instance; ?>"><?php _e('Username') ?></label>
|
304 |
-
<input type="text" name="user_login-<?php echo $instance; ?>" id="user_login-<?php echo $instance; ?>" class="input" value="<?php echo attribute_escape(stripslashes($user_login)); ?>" size="20" />
|
305 |
-
</p>
|
306 |
-
<p>
|
307 |
-
<label for="user_email-<?php echo $instance; ?>"><?php _e('E-mail') ?></label>
|
308 |
-
<input type="text" name="user_email-<?php echo $instance; ?>" id="user_email-<?php echo $instance; ?>" class="input" value="<?php echo attribute_escape(stripslashes($user_email)); ?>" size="20" />
|
309 |
-
</p>
|
310 |
-
<?php do_action('register_form', $instance); ?>
|
311 |
-
<p id="reg_passmail-<?php echo $instance; ?>"><?php echo $this->options['register_message']; ?></p>
|
312 |
-
<p class="submit">
|
313 |
-
<input type="submit" name="register-submit-<?php echo $instance; ?>" id="register-submit-<?php echo $instance; ?>" value="<?php _e('Register'); ?>" />
|
314 |
-
</p>
|
315 |
-
</form>
|
316 |
-
<?php
|
317 |
-
if ($instance == $this->instance) { ?>
|
318 |
-
<script type="text/javascript">
|
319 |
-
try{document.getElementById('user_login-<?php echo $this->instance; ?>').focus();}catch(e){}
|
320 |
-
</script>
|
321 |
-
<?php }
|
322 |
-
$this->PageFooter($instance);
|
323 |
-
}
|
324 |
-
|
325 |
-
function RetrievePasswordForm($instance) {
|
326 |
-
do_action('lost_password', $instance);
|
327 |
-
$this->PageHeader($instance, $this->options['lost_pass_message']);
|
328 |
-
$user_login = isset($_POST['user_login-'.$this->instance]) ? stripslashes($_POST['user_login-'.$this->instance]) : '';
|
329 |
-
?>
|
330 |
-
<form name="lostpasswordform-<?php echo $instance; ?>" id="lostpasswordform-<?php echo $instance; ?>" action="<?php echo $this->GuessURL(array('instance' => $instance, 'action' => 'lostpassword')); ?>" method="post">
|
331 |
-
<p>
|
332 |
-
<label for="user_login-<?php echo $instance; ?>"><?php _e('Username or E-mail:') ?></label>
|
333 |
-
<input type="text" name="user_login-<?php echo $instance; ?>" id="user_login-<?php echo $instance; ?>" class="input" value="<?php echo attribute_escape($user_login); ?>" size="20" />
|
334 |
-
</p>
|
335 |
-
<?php do_action('lostpassword_form', $instance); ?>
|
336 |
-
<p class="submit">
|
337 |
-
<input type="submit" name="lostpassword-submit-<?php echo $instance; ?>" id="lostpassword-submit-<?php echo $instance; ?>" value="<?php _e('Get New Password'); ?>" />
|
338 |
-
</p>
|
339 |
-
</form>
|
340 |
-
<?php
|
341 |
-
if ($instance == $this->instance) { ?>
|
342 |
-
<script type="text/javascript">
|
343 |
-
try{document.getElementById('user_login-<?php echo $this->instance; ?>').focus();}catch(e){}
|
344 |
-
</script>
|
345 |
-
<?php }
|
346 |
-
$this->PageFooter($instance);
|
347 |
-
}
|
348 |
-
|
349 |
-
function LogoutAction() {
|
350 |
-
global $wp_version;
|
351 |
-
|
352 |
-
if ( version_compare($wp_version, '2.7', '>=') )
|
353 |
-
check_admin_referer('log-out');
|
354 |
-
wp_logout();
|
355 |
-
|
356 |
-
$this->redirect_to = site_url('wp-login.php?loggedout=true', 'login');
|
357 |
-
if ( isset( $_REQUEST['redirect_to'] ) )
|
358 |
-
$this->redirect_to = $_REQUEST['redirect_to'];
|
359 |
-
|
360 |
-
wp_safe_redirect($this->redirect_to);
|
361 |
-
exit();
|
362 |
-
}
|
363 |
-
|
364 |
-
function RetrievePasswordAction() {
|
365 |
-
if ( isset($_POST['lostpassword-submit-'.$this->instance]) ) {
|
366 |
-
$this->errors = $this->RetrievePassword();
|
367 |
-
if ( !is_wp_error($this->errors) ) {
|
368 |
-
$this->redirect_to = ( isset($this->instance) ) ? $this->GuessURL(array('instance' => $this->instance, 'checkemail' => 'confirm')) : site_url('wp-login.php?instance='.$this->instance.'&checkemail=confirm', 'login');
|
369 |
-
wp_redirect($this->redirect_to);
|
370 |
-
exit();
|
371 |
-
}
|
372 |
-
}
|
373 |
-
|
374 |
-
if ( isset($_GET['error']) && 'invalidkey' == $_GET['error'] )
|
375 |
-
$this->errors->add('invalidkey', __('Sorry, that key does not appear to be valid.'));
|
376 |
-
}
|
377 |
-
|
378 |
-
function ResetPassAction() {
|
379 |
-
$this->errors = $this->ResetPassword($_GET['key'], $_GET['login']);
|
380 |
-
|
381 |
-
if ( ! is_wp_error($this->errors) ) {
|
382 |
-
$this->redirect_to = ( isset($this->instance) ) ? $this->GuessURL(array('checkemail' => 'newpass')) : site_url('wp-login.php?checkemail=newpass', 'login');
|
383 |
-
wp_redirect($this->redirect_to);
|
384 |
-
exit();
|
385 |
-
}
|
386 |
-
|
387 |
-
$this->redirect_to = ( isset($this->instance) ) ? $this->GuessURL(array('action' => 'lostpassword', 'error' => 'invalidkey')) : site_url('wp-login.php?action=lostpassword&error=invalidkey', 'login');
|
388 |
-
wp_redirect($this->redirect_to);
|
389 |
-
exit();
|
390 |
-
}
|
391 |
-
|
392 |
-
function RegisterAction() {
|
393 |
-
if ( !get_option('users_can_register') ) {
|
394 |
-
$this->redirect_to = ( isset($this->instance) ) ? $this->GuessURL(array('registration' => 'disabled')) : site_url('wp-login.php?registration=disabled', 'login');
|
395 |
-
wp_redirect($this->redirect_to);
|
396 |
-
exit();
|
397 |
-
}
|
398 |
-
|
399 |
-
if ( isset($_POST['register-submit-'.$this->instance]) ) {
|
400 |
-
require_once (ABSPATH . WPINC . '/registration.php');
|
401 |
-
|
402 |
-
$user_login = $_POST['user_login-'.$this->instance];
|
403 |
-
$user_email = $_POST['user_email-'.$this->instance];
|
404 |
-
$this->errors = $this->RegisterNewUser($user_login, $user_email);
|
405 |
-
|
406 |
-
if ( !is_wp_error($this->errors) ) {
|
407 |
-
$this->redirect_to = ( isset($this->instance) ) ? $this->GuessURL(array('checkemail' => 'registered')) : site_url('wp-login.php?checkemail=registered', 'login');
|
408 |
-
wp_redirect($this->redirect_to);
|
409 |
-
exit();
|
410 |
-
}
|
411 |
-
}
|
412 |
-
}
|
413 |
-
|
414 |
-
function LoginAction() {
|
415 |
-
$this->secure_cookie = '';
|
416 |
-
|
417 |
-
// If the user wants ssl but the session is not ssl, force a secure cookie.
|
418 |
-
if ( !empty($_POST['log-'.$this->instance]) && !force_ssl_admin() ) {
|
419 |
-
$user_name = sanitize_user($_POST['log-'.$this->instance]);
|
420 |
-
if ( $user = get_userdatabylogin($user_name) ) {
|
421 |
-
if ( get_user_option('use_ssl', $user->ID) ) {
|
422 |
-
$this->secure_cookie = true;
|
423 |
-
force_ssl_admin(true);
|
424 |
-
}
|
425 |
-
}
|
426 |
-
}
|
427 |
-
|
428 |
-
if ( !$this->secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() )
|
429 |
-
$this->secure_cookie = false;
|
430 |
-
|
431 |
-
if ( isset($_POST['login-submit-'.$this->instance]) ) {
|
432 |
-
$_POST['log'] = $_POST['log-'.$this->instance];
|
433 |
-
$_POST['pwd'] = $_POST['pwd-'.$this->instance];
|
434 |
-
$_POST['rememberme'] = $_POST['rememberme-'.$this->instance];
|
435 |
-
|
436 |
-
$user = wp_signon('', $this->secure_cookie);
|
437 |
-
|
438 |
-
$this->redirect_to = apply_filters('login_redirect', $this->redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user);
|
439 |
-
|
440 |
-
if ( !is_wp_error($user) ) {
|
441 |
-
// If the user can't edit posts, send them to their profile.
|
442 |
-
if ( !$user->has_cap('edit_posts') && ( empty( $this->redirect_to ) || $this->redirect_to == 'wp-admin/' || $this->redirect_to == admin_url() ) )
|
443 |
-
$this->redirect_to = admin_url('profile.php');
|
444 |
-
wp_safe_redirect($this->redirect_to);
|
445 |
-
exit();
|
446 |
-
}
|
447 |
-
|
448 |
-
$this->errors = $user;
|
449 |
-
|
450 |
-
}
|
451 |
-
|
452 |
-
}
|
453 |
-
|
454 |
-
function ForceSSL() {
|
455 |
-
if ( force_ssl_admin() && !is_ssl() ) {
|
456 |
-
if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
|
457 |
-
wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']));
|
458 |
-
exit();
|
459 |
-
} else {
|
460 |
-
wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
|
461 |
-
exit();
|
462 |
-
}
|
463 |
-
}
|
464 |
-
}
|
465 |
-
|
466 |
-
function SetTestCookie() {
|
467 |
-
//Set a cookie now to see if they are supported by the browser.
|
468 |
-
setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN);
|
469 |
-
if ( SITECOOKIEPATH != COOKIEPATH )
|
470 |
-
setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN);
|
471 |
-
}
|
472 |
-
|
473 |
-
function HandleRelocate() {
|
474 |
-
if ( defined('RELOCATE') ) { // Move flag is set
|
475 |
-
if ( isset( $_SERVER['PATH_INFO'] ) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF']) )
|
476 |
-
$_SERVER['PHP_SELF'] = str_replace( $_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF'] );
|
477 |
-
|
478 |
-
$schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
|
479 |
-
if ( dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != get_option('siteurl') )
|
480 |
-
update_option('siteurl', dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) );
|
481 |
-
}
|
482 |
-
}
|
483 |
-
|
484 |
-
function GuessURL($args = array()) {
|
485 |
-
$keys = array('action', 'checkemail', 'error', 'loggedout', 'registered', 'redirect_to', 'updated', 'key');
|
486 |
-
$url = remove_query_arg($keys);
|
487 |
-
|
488 |
-
if (!empty($args))
|
489 |
-
$url = add_query_arg($args, $url);
|
490 |
-
|
491 |
-
return $url;
|
492 |
-
}
|
493 |
-
|
494 |
-
function RetrievePassword() {
|
495 |
-
global $wpdb;
|
496 |
-
|
497 |
-
$errors = new WP_Error();
|
498 |
-
|
499 |
-
$_POST['user_login'] = $_POST['user_login-'.$this->instance];
|
500 |
-
|
501 |
-
if ( empty( $_POST['user_login'] ) && empty( $_POST['user_email'] ) )
|
502 |
-
$errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.'));
|
503 |
-
|
504 |
-
if ( strpos($_POST['user_login'], '@') ) {
|
505 |
-
$user_data = get_user_by_email(trim($_POST['user_login']));
|
506 |
-
if ( empty($user_data) )
|
507 |
-
$errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.'));
|
508 |
-
} else {
|
509 |
-
$login = trim($_POST['user_login']);
|
510 |
-
$user_data = get_userdatabylogin($login);
|
511 |
-
}
|
512 |
-
|
513 |
-
do_action('lostpassword_post');
|
514 |
-
|
515 |
-
if ( $errors->get_error_code() )
|
516 |
-
return $errors;
|
517 |
-
|
518 |
-
if ( !$user_data ) {
|
519 |
-
$errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.'));
|
520 |
-
return $errors;
|
521 |
-
}
|
522 |
-
|
523 |
-
// redefining user_login ensures we return the right case in the email
|
524 |
-
$user_login = $user_data->user_login;
|
525 |
-
$user_email = $user_data->user_email;
|
526 |
-
|
527 |
-
do_action('retreive_password', $user_login); // Misspelled and deprecated
|
528 |
-
do_action('retrieve_password', $user_login);
|
529 |
-
|
530 |
-
$allow = apply_filters('allow_password_reset', true, $user_data->ID);
|
531 |
-
|
532 |
-
if ( ! $allow )
|
533 |
-
return new WP_Error('no_password_reset', __('Password reset is not allowed for this user'));
|
534 |
-
else if ( is_wp_error($allow) )
|
535 |
-
return $allow;
|
536 |
-
|
537 |
-
$key = $wpdb->get_var($wpdb->prepare("SELECT user_activation_key FROM $wpdb->users WHERE user_login = %s", $user_login));
|
538 |
-
if ( empty($key) ) {
|
539 |
-
// Generate something random for a key...
|
540 |
-
$key = wp_generate_password(20, false);
|
541 |
-
do_action('retrieve_password_key', $user_login, $key);
|
542 |
-
// Now insert the new md5 key into the db
|
543 |
-
$wpdb->update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $user_login));
|
544 |
-
}
|
545 |
-
$message = __('Someone has asked to reset the password for the following site and username.') . "\r\n\r\n";
|
546 |
-
$message .= get_option('siteurl') . "\r\n\r\n";
|
547 |
-
$message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
|
548 |
-
$message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.') . "\r\n\r\n";
|
549 |
-
$message .= site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . "\r\n";
|
550 |
-
|
551 |
-
$title = sprintf(__('[%s] Password Reset'), get_option('blogname'));
|
552 |
-
|
553 |
-
$title = apply_filters('retrieve_password_title', $title, $user_data);
|
554 |
-
$message = apply_filters('retrieve_password_message', $message, $key, $user_data);
|
555 |
-
|
556 |
-
tml_apply_mail_filters();
|
557 |
-
if ( $message && !wp_mail($user_email, $title, $message) )
|
558 |
-
die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');
|
559 |
-
tml_remove_mail_filters();
|
560 |
-
|
561 |
-
return true;
|
562 |
-
}
|
563 |
-
|
564 |
-
function ResetPassword($key, $login) {
|
565 |
-
global $wpdb;
|
566 |
-
|
567 |
-
$key = preg_replace('/[^a-z0-9]/i', '', $key);
|
568 |
-
|
569 |
-
if ( empty( $key ) || !is_string( $key ) )
|
570 |
-
return new WP_Error('invalid_key', __('Invalid key'));
|
571 |
-
|
572 |
-
if ( empty($login) || !is_string($login) )
|
573 |
-
return new WP_Error('invalid_key', __('Invalid key'));
|
574 |
-
|
575 |
-
$user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_login = %s", $key, $login));
|
576 |
-
if ( empty( $user ) )
|
577 |
-
return new WP_Error('invalid_key', __('Invalid key'));
|
578 |
-
|
579 |
-
// Generate something random for a password...
|
580 |
-
$new_pass = wp_generate_password();
|
581 |
-
|
582 |
-
do_action('password_reset', $user, $new_pass);
|
583 |
-
|
584 |
-
wp_set_password($new_pass, $user->ID);
|
585 |
-
update_usermeta($user->ID, 'default_password_nag', true); //Set up the Password change nag.
|
586 |
-
$message = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
|
587 |
-
$message .= sprintf(__('Password: %s'), $new_pass) . "\r\n";
|
588 |
-
$message .= site_url('wp-login.php', 'login') . "\r\n";
|
589 |
-
|
590 |
-
$title = sprintf(__('[%s] Your new password'), get_option('blogname'));
|
591 |
-
|
592 |
-
$title = apply_filters('password_reset_title', $title, $user);
|
593 |
-
$message = apply_filters('password_reset_message', $message, $new_pass, $user);
|
594 |
-
|
595 |
-
tml_apply_mail_filters();
|
596 |
-
if ( $message && !wp_mail($user->user_email, $title, $message) )
|
597 |
-
die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');
|
598 |
-
tml_remove_mail_filters();
|
599 |
-
|
600 |
-
if ( !$this->options['reset_pass_email']['admin_disable'] )
|
601 |
-
wp_password_change_notification($user);
|
602 |
-
|
603 |
-
return true;
|
604 |
-
}
|
605 |
-
|
606 |
-
function RegisterNewUser($user_login, $user_email) {
|
607 |
-
$errors = new WP_Error();
|
608 |
-
|
609 |
-
$user_login = sanitize_user( $user_login );
|
610 |
-
$user_email = apply_filters( 'user_registration_email', $user_email );
|
611 |
-
|
612 |
-
// Check the username
|
613 |
-
if ( $user_login == '' )
|
614 |
-
$errors->add('empty_username', __('<strong>ERROR</strong>: Please enter a username.'));
|
615 |
-
elseif ( !validate_username( $user_login ) ) {
|
616 |
-
$errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid. Please enter a valid username.'));
|
617 |
-
$user_login = '';
|
618 |
-
} elseif ( username_exists( $user_login ) )
|
619 |
-
$errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered, please choose another one.'));
|
620 |
-
|
621 |
-
// Check the e-mail address
|
622 |
-
if ($user_email == '') {
|
623 |
-
$errors->add('empty_email', __('<strong>ERROR</strong>: Please type your e-mail address.'));
|
624 |
-
} elseif ( !is_email( $user_email ) ) {
|
625 |
-
$errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn’t correct.'));
|
626 |
-
$user_email = '';
|
627 |
-
} elseif ( email_exists( $user_email ) )
|
628 |
-
$errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.'));
|
629 |
-
|
630 |
-
do_action('register_post', $user_login, $user_email, $errors);
|
631 |
-
|
632 |
-
$errors = apply_filters( 'registration_errors', $errors );
|
633 |
-
|
634 |
-
if ( $errors->get_error_code() )
|
635 |
-
return $errors;
|
636 |
-
|
637 |
-
$user_pass = wp_generate_password();
|
638 |
-
$user_id = wp_create_user( $user_login, $user_pass, $user_email );
|
639 |
-
if ( !$user_id ) {
|
640 |
-
$errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn’t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_option('admin_email')));
|
641 |
-
return $errors;
|
642 |
-
}
|
643 |
-
|
644 |
-
wp_new_user_notification($user_id, $user_pass);
|
645 |
-
|
646 |
-
return $user_id;
|
647 |
-
}
|
648 |
-
|
649 |
-
}
|
650 |
-
}
|
651 |
-
|
652 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/functions.php
ADDED
@@ -0,0 +1,306 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Handles sending password retrieval email to user.
|
5 |
+
*
|
6 |
+
* @uses $wpdb WordPress Database object
|
7 |
+
*
|
8 |
+
* @return bool|WP_Error True: when finish. WP_Error on error
|
9 |
+
*/
|
10 |
+
function retrieve_password() {
|
11 |
+
global $wpdb, $ThemeMyLogin;
|
12 |
+
|
13 |
+
$errors = new WP_Error();
|
14 |
+
|
15 |
+
if ( empty( $_POST['user_login'] ) && empty( $_POST['user_email'] ) )
|
16 |
+
$errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.'));
|
17 |
+
|
18 |
+
if ( strpos($_POST['user_login'], '@') ) {
|
19 |
+
$user_data = get_user_by_email(trim($_POST['user_login']));
|
20 |
+
if ( empty($user_data) )
|
21 |
+
$errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.'));
|
22 |
+
} else {
|
23 |
+
$login = trim($_POST['user_login']);
|
24 |
+
$user_data = get_userdatabylogin($login);
|
25 |
+
}
|
26 |
+
|
27 |
+
do_action('lostpassword_post');
|
28 |
+
|
29 |
+
if ( $errors->get_error_code() )
|
30 |
+
return $errors;
|
31 |
+
|
32 |
+
if ( !$user_data ) {
|
33 |
+
$errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.'));
|
34 |
+
return $errors;
|
35 |
+
}
|
36 |
+
|
37 |
+
// redefining user_login ensures we return the right case in the email
|
38 |
+
$user_login = $user_data->user_login;
|
39 |
+
$user_email = $user_data->user_email;
|
40 |
+
|
41 |
+
do_action('retreive_password', $user_login); // Misspelled and deprecated
|
42 |
+
do_action('retrieve_password', $user_login);
|
43 |
+
|
44 |
+
$allow = apply_filters('allow_password_reset', true, $user_data->ID);
|
45 |
+
|
46 |
+
if ( ! $allow )
|
47 |
+
return new WP_Error('no_password_reset', __('Password reset is not allowed for this user'));
|
48 |
+
else if ( is_wp_error($allow) )
|
49 |
+
return $allow;
|
50 |
+
|
51 |
+
$key = $wpdb->get_var($wpdb->prepare("SELECT user_activation_key FROM $wpdb->users WHERE user_login = %s", $user_login));
|
52 |
+
if ( empty($key) ) {
|
53 |
+
// Generate something random for a key...
|
54 |
+
$key = wp_generate_password(20, false);
|
55 |
+
do_action('retrieve_password_key', $user_login, $key);
|
56 |
+
// Now insert the new md5 key into the db
|
57 |
+
$wpdb->update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $user_login));
|
58 |
+
}
|
59 |
+
|
60 |
+
// The blogname option is escaped with esc_html on the way into the database in sanitize_option
|
61 |
+
// we want to reverse this for the plain text arena of emails.
|
62 |
+
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
|
63 |
+
|
64 |
+
$replace_this = array('/%blogname%/', '/%siteurl%/', '/%reseturl%/', '/%user_login%/', '/%user_email%/', '/%key%/', '/%user_ip%/');
|
65 |
+
$replace_with = array($blogname, get_option('siteurl'), site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login'), $user_login, $user_email, $key, $_SERVER['REMOTE_ADDR']);
|
66 |
+
$title = $ThemeMyLogin->options['retrieve_pass_email']['subject'];
|
67 |
+
$message = $ThemeMyLogin->options['retrieve_pass_email']['message'];
|
68 |
+
|
69 |
+
if ( !empty($title) )
|
70 |
+
$title = preg_replace($replace_this, $replace_with, $title);
|
71 |
+
else
|
72 |
+
$title = sprintf(__('[%s] Password Reset', 'theme-my-login'), $blogname);
|
73 |
+
|
74 |
+
if ( !empty($message) )
|
75 |
+
$message = preg_replace($replace_this, $replace_with, $message);
|
76 |
+
else {
|
77 |
+
$message = __('Someone has asked to reset the password for the following site and username.') . "\r\n\r\n";
|
78 |
+
$message .= get_option('siteurl') . "\r\n\r\n";
|
79 |
+
$message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
|
80 |
+
$message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.') . "\r\n\r\n";
|
81 |
+
$message .= site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . "\r\n";
|
82 |
+
}
|
83 |
+
|
84 |
+
$title = apply_filters('retrieve_password_title', $title);
|
85 |
+
$message = apply_filters('retrieve_password_message', $message, $key);
|
86 |
+
|
87 |
+
if ( $message && !$ThemeMyLogin->sendEmail($user_email, $title, $message) )
|
88 |
+
die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');
|
89 |
+
|
90 |
+
return true;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Handles resetting the user's password.
|
95 |
+
*
|
96 |
+
* @uses $wpdb WordPress Database object
|
97 |
+
*
|
98 |
+
* @param string $key Hash to validate sending user's password
|
99 |
+
* @return bool|WP_Error
|
100 |
+
*/
|
101 |
+
function reset_password($key, $login) {
|
102 |
+
global $wpdb, $ThemeMyLogin;
|
103 |
+
|
104 |
+
$key = preg_replace('/[^a-z0-9]/i', '', $key);
|
105 |
+
|
106 |
+
if ( empty( $key ) || !is_string( $key ) )
|
107 |
+
return new WP_Error('invalid_key', __('Invalid key'));
|
108 |
+
|
109 |
+
if ( empty($login) || !is_string($login) )
|
110 |
+
return new WP_Error('invalid_key', __('Invalid key'));
|
111 |
+
|
112 |
+
$user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_login = %s", $key, $login));
|
113 |
+
if ( empty( $user ) )
|
114 |
+
return new WP_Error('invalid_key', __('Invalid key'));
|
115 |
+
|
116 |
+
// Generate something random for a password...
|
117 |
+
$new_pass = wp_generate_password();
|
118 |
+
|
119 |
+
do_action('password_reset', $user, $new_pass);
|
120 |
+
|
121 |
+
wp_set_password($new_pass, $user->ID);
|
122 |
+
update_usermeta($user->ID, 'default_password_nag', true); //Set up the Password change nag.
|
123 |
+
|
124 |
+
// The blogname option is escaped with esc_html on the way into the database in sanitize_option
|
125 |
+
// we want to reverse this for the plain text arena of emails.
|
126 |
+
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
|
127 |
+
|
128 |
+
$replace_this = array('/%blogname%/', '/%siteurl%/', '/%user_login%/', '/%user_email%/', '/%user_pass%/', '/%user_ip%/');
|
129 |
+
$replace_with = array($blogname, get_option('siteurl'), $user->user_login, $user->user_email, $new_pass, $_SERVER['REMOTE_ADDR']);
|
130 |
+
$title = $ThemeMyLogin->options['reset_pass_email']['subject'];
|
131 |
+
$message = $ThemeMyLogin->options['reset_pass_email']['message'];
|
132 |
+
|
133 |
+
if ( !empty($title) )
|
134 |
+
$title = preg_replace($replace_this, $replace_with, $title);
|
135 |
+
else
|
136 |
+
$title = sprintf(__('[%s] Your new password'), $blogname);
|
137 |
+
|
138 |
+
if ( !empty($message) )
|
139 |
+
$message = preg_replace($replace_this, $replace_with, $message);
|
140 |
+
else {
|
141 |
+
$message = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
|
142 |
+
$message .= sprintf(__('Password: %s'), $new_pass) . "\r\n";
|
143 |
+
$message .= site_url('wp-login.php', 'login') . "\r\n";
|
144 |
+
}
|
145 |
+
|
146 |
+
$title = apply_filters('password_reset_title', $title);
|
147 |
+
$message = apply_filters('password_reset_message', $message, $new_pass);
|
148 |
+
|
149 |
+
if ( $message && !$ThemeMyLogin->sendEmail($user->user_email, $title, $message) )
|
150 |
+
die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');
|
151 |
+
|
152 |
+
if ( !$ThemeMyLogin->options['reset_pass_email']['admin_disable'] )
|
153 |
+
wp_password_change_notification($user);
|
154 |
+
|
155 |
+
return true;
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Handles registering a new user.
|
160 |
+
*
|
161 |
+
* @param string $user_login User's username for logging in
|
162 |
+
* @param string $user_email User's email address to send password and add
|
163 |
+
* @return int|WP_Error Either user's ID or error on failure.
|
164 |
+
*/
|
165 |
+
function register_new_user($user_login, $user_email) {
|
166 |
+
$errors = new WP_Error();
|
167 |
+
|
168 |
+
$user_login = sanitize_user( $user_login );
|
169 |
+
$user_email = apply_filters( 'user_registration_email', $user_email );
|
170 |
+
|
171 |
+
// Check the username
|
172 |
+
if ( $user_login == '' )
|
173 |
+
$errors->add('empty_username', __('<strong>ERROR</strong>: Please enter a username.'));
|
174 |
+
elseif ( !validate_username( $user_login ) ) {
|
175 |
+
$errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid. Please enter a valid username.'));
|
176 |
+
$user_login = '';
|
177 |
+
} elseif ( username_exists( $user_login ) )
|
178 |
+
$errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered, please choose another one.'));
|
179 |
+
|
180 |
+
// Check the e-mail address
|
181 |
+
if ($user_email == '') {
|
182 |
+
$errors->add('empty_email', __('<strong>ERROR</strong>: Please type your e-mail address.'));
|
183 |
+
} elseif ( !is_email( $user_email ) ) {
|
184 |
+
$errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn’t correct.'));
|
185 |
+
$user_email = '';
|
186 |
+
} elseif ( email_exists( $user_email ) )
|
187 |
+
$errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.'));
|
188 |
+
|
189 |
+
do_action('register_post', $user_login, $user_email, $errors);
|
190 |
+
|
191 |
+
$errors = apply_filters( 'registration_errors', $errors, $user_login, $user_email );
|
192 |
+
|
193 |
+
if ( $errors->get_error_code() )
|
194 |
+
return $errors;
|
195 |
+
|
196 |
+
$user_pass = wp_generate_password();
|
197 |
+
$user_id = wp_create_user( $user_login, $user_pass, $user_email );
|
198 |
+
if ( !$user_id ) {
|
199 |
+
$errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn’t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_option('admin_email')));
|
200 |
+
return $errors;
|
201 |
+
}
|
202 |
+
|
203 |
+
wp_new_user_notification($user_id, $user_pass);
|
204 |
+
|
205 |
+
return $user_id;
|
206 |
+
}
|
207 |
+
|
208 |
+
/**
|
209 |
+
* Handles activating a new user by user email confirmation.
|
210 |
+
*
|
211 |
+
* @param string $key Hash to validate sending confirmation email
|
212 |
+
* @param string $login User's username for logging in
|
213 |
+
* @param bool $newpass Whether or not to assign a new password
|
214 |
+
* @return bool|WP_Error
|
215 |
+
*/
|
216 |
+
function activate_new_user($key, $login, $newpass = false) {
|
217 |
+
global $wpdb;
|
218 |
+
|
219 |
+
$key = preg_replace('/[^a-z0-9]/i', '', $key);
|
220 |
+
|
221 |
+
if ( empty($key) || !is_string($key) )
|
222 |
+
return new WP_Error('invalid_key', __('Invalid key'));
|
223 |
+
|
224 |
+
if ( empty($login) || !is_string($login) )
|
225 |
+
return new WP_Error('invalid_key', __('Invalid key'));
|
226 |
+
|
227 |
+
$user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_login = %s", $key, $login));
|
228 |
+
if ( empty( $user ) )
|
229 |
+
return new WP_Error('invalid_key', __('Invalid key'));
|
230 |
+
|
231 |
+
$wpdb->update($wpdb->users, array('user_activation_key' => ''), array('user_login' => $login) );
|
232 |
+
|
233 |
+
$user_object = new WP_User($user->ID);
|
234 |
+
$user_object->set_role(get_option('default_role'));
|
235 |
+
unset($user_object);
|
236 |
+
|
237 |
+
$pass = __('Same as when you signed up.', 'theme-my-login');
|
238 |
+
if ( $newpass ) {
|
239 |
+
$pass = wp_generate_password();
|
240 |
+
wp_set_password($pass, $user->ID);
|
241 |
+
}
|
242 |
+
|
243 |
+
wp_new_user_notification($user->ID, $pass);
|
244 |
+
|
245 |
+
return true;
|
246 |
+
}
|
247 |
+
|
248 |
+
/**
|
249 |
+
* Handles activating a new user by admin approval.
|
250 |
+
*
|
251 |
+
* @param string $id User's ID
|
252 |
+
* @param bool $newpass Whether or not to assign a new password
|
253 |
+
* @return bool Returns false if not a valid user
|
254 |
+
*/
|
255 |
+
function approve_new_user($id, $newpass = false) {
|
256 |
+
global $wpdb, $ThemeMyLogin;
|
257 |
+
|
258 |
+
$id = (int) $id;
|
259 |
+
|
260 |
+
$user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE ID = %d", $id));
|
261 |
+
if ( empty( $user ) )
|
262 |
+
return false;
|
263 |
+
|
264 |
+
$wpdb->update($wpdb->users, array('user_activation_key' => ''), array('ID' => $id) );
|
265 |
+
|
266 |
+
$user_object = new WP_User($user->ID);
|
267 |
+
$user_object->set_role(get_option('default_role'));
|
268 |
+
unset($user_object);
|
269 |
+
|
270 |
+
$pass = __('Same as when you signed up.', 'theme-my-login');
|
271 |
+
if ( $newpass ) {
|
272 |
+
$pass = wp_generate_password();
|
273 |
+
wp_set_password($pass, $user->ID);
|
274 |
+
}
|
275 |
+
|
276 |
+
// The blogname option is escaped with esc_html on the way into the database in sanitize_option
|
277 |
+
// we want to reverse this for the plain text arena of emails.
|
278 |
+
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
|
279 |
+
|
280 |
+
$replace_this = array('/%blogname%/', '/%siteurl%/', '/%user_login%/', '/%user_email%/', '/%user_pass%/');
|
281 |
+
$replace_with = array($blogname, get_option('siteurl'), $user->user_login, $user->user_email, $pass);
|
282 |
+
$subject = $ThemeMyLogin->options['user_approval_email']['subject'];
|
283 |
+
$message = $ThemeMyLogin->options['user_approval_email']['message'];
|
284 |
+
|
285 |
+
if ( !empty($subject) )
|
286 |
+
$subject = preg_replace($replace_this, $replace_with, $subject);
|
287 |
+
else
|
288 |
+
$subject = sprintf(__('[%s] Registration Approved', 'theme-my-login'), $blogname);
|
289 |
+
|
290 |
+
if ( !empty($message) )
|
291 |
+
$message = preg_replace($replace_this, $replace_with, $message);
|
292 |
+
else {
|
293 |
+
$message = sprintf(__('You have been approved access to %s', 'theme-my-login'), $blogname) . "\r\n\r\n";
|
294 |
+
$message .= sprintf(__('Username: %s', 'theme-my-login'), $user->user_login) . "\r\n";
|
295 |
+
$message .= sprintf(__('Password: %s', 'theme-my-login'), $pass) . "\r\n";
|
296 |
+
$message .= "\r\n";
|
297 |
+
$message .= site_url('wp-login.php', 'login') . "\r\n";
|
298 |
+
}
|
299 |
+
$ThemeMyLogin->sendEmail($user->user_email, $subject, $message);
|
300 |
+
|
301 |
+
wp_new_user_notification($user->ID, $pass);
|
302 |
+
|
303 |
+
return true;
|
304 |
+
}
|
305 |
+
|
306 |
+
?>
|
classes/class.widget-new.php → includes/widget.php
RENAMED
@@ -10,8 +10,10 @@ class ThemeMyLoginWidget extends WP_Widget {
|
|
10 |
|
11 |
function widget($args, $instance){
|
12 |
global $ThemeMyLogin;
|
|
|
|
|
13 |
$args = array_merge($args, $instance);
|
14 |
-
echo $ThemeMyLogin->
|
15 |
}
|
16 |
|
17 |
function update($new_instance, $old_instance){
|
10 |
|
11 |
function widget($args, $instance){
|
12 |
global $ThemeMyLogin;
|
13 |
+
if ( is_user_logged_in() && !$instance['logged_in_widget'] )
|
14 |
+
return;
|
15 |
$args = array_merge($args, $instance);
|
16 |
+
echo $ThemeMyLogin->shortcode($args);
|
17 |
}
|
18 |
|
19 |
function update($new_instance, $old_instance){
|
js/jquery/jquery.js
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
* jQuery JavaScript Library v1.3.2
|
3 |
-
* http://jquery.com/
|
4 |
-
*
|
5 |
-
* Copyright (c) 2009 John Resig
|
6 |
-
* Dual licensed under the MIT and GPL licenses.
|
7 |
-
* http://docs.jquery.com/License
|
8 |
-
*
|
9 |
-
* Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009)
|
10 |
-
* Revision: 6246
|
11 |
-
*/
|
12 |
-
(function(){var l=this,g,y=l.jQuery,p=l.$,o=l.jQuery=l.$=function(E,F){return new o.fn.init(E,F)},D=/^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,f=/^.[^:#\[\.,]*$/;o.fn=o.prototype={init:function(E,H){E=E||document;if(E.nodeType){this[0]=E;this.length=1;this.context=E;return this}if(typeof E==="string"){var G=D.exec(E);if(G&&(G[1]||!H)){if(G[1]){E=o.clean([G[1]],H)}else{var I=document.getElementById(G[3]);if(I&&I.id!=G[3]){return o().find(E)}var F=o(I||[]);F.context=document;F.selector=E;return F}}else{return o(H).find(E)}}else{if(o.isFunction(E)){return o(document).ready(E)}}if(E.selector&&E.context){this.selector=E.selector;this.context=E.context}return this.setArray(o.isArray(E)?E:o.makeArray(E))},selector:"",jquery:"1.3.2",size:function(){return this.length},get:function(E){return E===g?Array.prototype.slice.call(this):this[E]},pushStack:function(F,H,E){var G=o(F);G.prevObject=this;G.context=this.context;if(H==="find"){G.selector=this.selector+(this.selector?" ":"")+E}else{if(H){G.selector=this.selector+"."+H+"("+E+")"}}return G},setArray:function(E){this.length=0;Array.prototype.push.apply(this,E);return this},each:function(F,E){return o.each(this,F,E)},index:function(E){return o.inArray(E&&E.jquery?E[0]:E,this)},attr:function(F,H,G){var E=F;if(typeof F==="string"){if(H===g){return this[0]&&o[G||"attr"](this[0],F)}else{E={};E[F]=H}}return this.each(function(I){for(F in E){o.attr(G?this.style:this,F,o.prop(this,E[F],G,I,F))}})},css:function(E,F){if((E=="width"||E=="height")&&parseFloat(F)<0){F=g}return this.attr(E,F,"curCSS")},text:function(F){if(typeof F!=="object"&&F!=null){return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(F))}var E="";o.each(F||this,function(){o.each(this.childNodes,function(){if(this.nodeType!=8){E+=this.nodeType!=1?this.nodeValue:o.fn.text([this])}})});return E},wrapAll:function(E){if(this[0]){var F=o(E,this[0].ownerDocument).clone();if(this[0].parentNode){F.insertBefore(this[0])}F.map(function(){var G=this;while(G.firstChild){G=G.firstChild}return G}).append(this)}return this},wrapInner:function(E){return this.each(function(){o(this).contents().wrapAll(E)})},wrap:function(E){return this.each(function(){o(this).wrapAll(E)})},append:function(){return this.domManip(arguments,true,function(E){if(this.nodeType==1){this.appendChild(E)}})},prepend:function(){return this.domManip(arguments,true,function(E){if(this.nodeType==1){this.insertBefore(E,this.firstChild)}})},before:function(){return this.domManip(arguments,false,function(E){this.parentNode.insertBefore(E,this)})},after:function(){return this.domManip(arguments,false,function(E){this.parentNode.insertBefore(E,this.nextSibling)})},end:function(){return this.prevObject||o([])},push:[].push,sort:[].sort,splice:[].splice,find:function(E){if(this.length===1){var F=this.pushStack([],"find",E);F.length=0;o.find(E,this[0],F);return F}else{return this.pushStack(o.unique(o.map(this,function(G){return o.find(E,G)})),"find",E)}},clone:function(G){var E=this.map(function(){if(!o.support.noCloneEvent&&!o.isXMLDoc(this)){var I=this.outerHTML;if(!I){var J=this.ownerDocument.createElement("div");J.appendChild(this.cloneNode(true));I=J.innerHTML}return o.clean([I.replace(/ jQuery\d+="(?:\d+|null)"/g,"").replace(/^\s*/,"")])[0]}else{return this.cloneNode(true)}});if(G===true){var H=this.find("*").andSelf(),F=0;E.find("*").andSelf().each(function(){if(this.nodeName!==H[F].nodeName){return}var I=o.data(H[F],"events");for(var K in I){for(var J in I[K]){o.event.add(this,K,I[K][J],I[K][J].data)}}F++})}return E},filter:function(E){return this.pushStack(o.isFunction(E)&&o.grep(this,function(G,F){return E.call(G,F)})||o.multiFilter(E,o.grep(this,function(F){return F.nodeType===1})),"filter",E)},closest:function(E){var G=o.expr.match.POS.test(E)?o(E):null,F=0;return this.map(function(){var H=this;while(H&&H.ownerDocument){if(G?G.index(H)>-1:o(H).is(E)){o.data(H,"closest",F);return H}H=H.parentNode;F++}})},not:function(E){if(typeof E==="string"){if(f.test(E)){return this.pushStack(o.multiFilter(E,this,true),"not",E)}else{E=o.multiFilter(E,this)}}var F=E.length&&E[E.length-1]!==g&&!E.nodeType;return this.filter(function(){return F?o.inArray(this,E)<0:this!=E})},add:function(E){return this.pushStack(o.unique(o.merge(this.get(),typeof E==="string"?o(E):o.makeArray(E))))},is:function(E){return !!E&&o.multiFilter(E,this).length>0},hasClass:function(E){return !!E&&this.is("."+E)},val:function(K){if(K===g){var E=this[0];if(E){if(o.nodeName(E,"option")){return(E.attributes.value||{}).specified?E.value:E.text}if(o.nodeName(E,"select")){var I=E.selectedIndex,L=[],M=E.options,H=E.type=="select-one";if(I<0){return null}for(var F=H?I:0,J=H?I+1:M.length;F<J;F++){var G=M[F];if(G.selected){K=o(G).val();if(H){return K}L.push(K)}}return L}return(E.value||"").replace(/\r/g,"")}return g}if(typeof K==="number"){K+=""}return this.each(function(){if(this.nodeType!=1){return}if(o.isArray(K)&&/radio|checkbox/.test(this.type)){this.checked=(o.inArray(this.value,K)>=0||o.inArray(this.name,K)>=0)}else{if(o.nodeName(this,"select")){var N=o.makeArray(K);o("option",this).each(function(){this.selected=(o.inArray(this.value,N)>=0||o.inArray(this.text,N)>=0)});if(!N.length){this.selectedIndex=-1}}else{this.value=K}}})},html:function(E){return E===g?(this[0]?this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g,""):null):this.empty().append(E)},replaceWith:function(E){return this.after(E).remove()},eq:function(E){return this.slice(E,+E+1)},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments),"slice",Array.prototype.slice.call(arguments).join(","))},map:function(E){return this.pushStack(o.map(this,function(G,F){return E.call(G,F,G)}))},andSelf:function(){return this.add(this.prevObject)},domManip:function(J,M,L){if(this[0]){var I=(this[0].ownerDocument||this[0]).createDocumentFragment(),F=o.clean(J,(this[0].ownerDocument||this[0]),I),H=I.firstChild;if(H){for(var G=0,E=this.length;G<E;G++){L.call(K(this[G],H),this.length>1||G>0?I.cloneNode(true):I)}}if(F){o.each(F,z)}}return this;function K(N,O){return M&&o.nodeName(N,"table")&&o.nodeName(O,"tr")?(N.getElementsByTagName("tbody")[0]||N.appendChild(N.ownerDocument.createElement("tbody"))):N}}};o.fn.init.prototype=o.fn;function z(E,F){if(F.src){o.ajax({url:F.src,async:false,dataType:"script"})}else{o.globalEval(F.text||F.textContent||F.innerHTML||"")}if(F.parentNode){F.parentNode.removeChild(F)}}function e(){return +new Date}o.extend=o.fn.extend=function(){var J=arguments[0]||{},H=1,I=arguments.length,E=false,G;if(typeof J==="boolean"){E=J;J=arguments[1]||{};H=2}if(typeof J!=="object"&&!o.isFunction(J)){J={}}if(I==H){J=this;--H}for(;H<I;H++){if((G=arguments[H])!=null){for(var F in G){var K=J[F],L=G[F];if(J===L){continue}if(E&&L&&typeof L==="object"&&!L.nodeType){J[F]=o.extend(E,K||(L.length!=null?[]:{}),L)}else{if(L!==g){J[F]=L}}}}}return J};var b=/z-?index|font-?weight|opacity|zoom|line-?height/i,q=document.defaultView||{},s=Object.prototype.toString;o.extend({noConflict:function(E){l.$=p;if(E){l.jQuery=y}return o},isFunction:function(E){return s.call(E)==="[object Function]"},isArray:function(E){return s.call(E)==="[object Array]"},isXMLDoc:function(E){return E.nodeType===9&&E.documentElement.nodeName!=="HTML"||!!E.ownerDocument&&o.isXMLDoc(E.ownerDocument)},globalEval:function(G){if(G&&/\S/.test(G)){var F=document.getElementsByTagName("head")[0]||document.documentElement,E=document.createElement("script");E.type="text/javascript";if(o.support.scriptEval){E.appendChild(document.createTextNode(G))}else{E.text=G}F.insertBefore(E,F.firstChild);F.removeChild(E)}},nodeName:function(F,E){return F.nodeName&&F.nodeName.toUpperCase()==E.toUpperCase()},each:function(G,K,F){var E,H=0,I=G.length;if(F){if(I===g){for(E in G){if(K.apply(G[E],F)===false){break}}}else{for(;H<I;){if(K.apply(G[H++],F)===false){break}}}}else{if(I===g){for(E in G){if(K.call(G[E],E,G[E])===false){break}}}else{for(var J=G[0];H<I&&K.call(J,H,J)!==false;J=G[++H]){}}}return G},prop:function(H,I,G,F,E){if(o.isFunction(I)){I=I.call(H,F)}return typeof I==="number"&&G=="curCSS"&&!b.test(E)?I+"px":I},className:{add:function(E,F){o.each((F||"").split(/\s+/),function(G,H){if(E.nodeType==1&&!o.className.has(E.className,H)){E.className+=(E.className?" ":"")+H}})},remove:function(E,F){if(E.nodeType==1){E.className=F!==g?o.grep(E.className.split(/\s+/),function(G){return !o.className.has(F,G)}).join(" "):""}},has:function(F,E){return F&&o.inArray(E,(F.className||F).toString().split(/\s+/))>-1}},swap:function(H,G,I){var E={};for(var F in G){E[F]=H.style[F];H.style[F]=G[F]}I.call(H);for(var F in G){H.style[F]=E[F]}},css:function(H,F,J,E){if(F=="width"||F=="height"){var L,G={position:"absolute",visibility:"hidden",display:"block"},K=F=="width"?["Left","Right"]:["Top","Bottom"];function I(){L=F=="width"?H.offsetWidth:H.offsetHeight;if(E==="border"){return}o.each(K,function(){if(!E){L-=parseFloat(o.curCSS(H,"padding"+this,true))||0}if(E==="margin"){L+=parseFloat(o.curCSS(H,"margin"+this,true))||0}else{L-=parseFloat(o.curCSS(H,"border"+this+"Width",true))||0}})}if(H.offsetWidth!==0){I()}else{o.swap(H,G,I)}return Math.max(0,Math.round(L))}return o.curCSS(H,F,J)},curCSS:function(I,F,G){var L,E=I.style;if(F=="opacity"&&!o.support.opacity){L=o.attr(E,"opacity");return L==""?"1":L}if(F.match(/float/i)){F=w}if(!G&&E&&E[F]){L=E[F]}else{if(q.getComputedStyle){if(F.match(/float/i)){F="float"}F=F.replace(/([A-Z])/g,"-$1").toLowerCase();var M=q.getComputedStyle(I,null);if(M){L=M.getPropertyValue(F)}if(F=="opacity"&&L==""){L="1"}}else{if(I.currentStyle){var J=F.replace(/\-(\w)/g,function(N,O){return O.toUpperCase()});L=I.currentStyle[F]||I.currentStyle[J];if(!/^\d+(px)?$/i.test(L)&&/^\d/.test(L)){var H=E.left,K=I.runtimeStyle.left;I.runtimeStyle.left=I.currentStyle.left;E.left=L||0;L=E.pixelLeft+"px";E.left=H;I.runtimeStyle.left=K}}}}return L},clean:function(F,K,I){K=K||document;if(typeof K.createElement==="undefined"){K=K.ownerDocument||K[0]&&K[0].ownerDocument||document}if(!I&&F.length===1&&typeof F[0]==="string"){var H=/^<(\w+)\s*\/?>$/.exec(F[0]);if(H){return[K.createElement(H[1])]}}var G=[],E=[],L=K.createElement("div");o.each(F,function(P,S){if(typeof S==="number"){S+=""}if(!S){return}if(typeof S==="string"){S=S.replace(/(<(\w+)[^>]*?)\/>/g,function(U,V,T){return T.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?U:V+"></"+T+">"});var O=S.replace(/^\s+/,"").substring(0,10).toLowerCase();var Q=!O.indexOf("<opt")&&[1,"<select multiple='multiple'>","</select>"]||!O.indexOf("<leg")&&[1,"<fieldset>","</fieldset>"]||O.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"<table>","</table>"]||!O.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!O.indexOf("<td")||!O.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||!O.indexOf("<col")&&[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"]||!o.support.htmlSerialize&&[1,"div<div>","</div>"]||[0,"",""];L.innerHTML=Q[1]+S+Q[2];while(Q[0]--){L=L.lastChild}if(!o.support.tbody){var R=/<tbody/i.test(S),N=!O.indexOf("<table")&&!R?L.firstChild&&L.firstChild.childNodes:Q[1]=="<table>"&&!R?L.childNodes:[];for(var M=N.length-1;M>=0;--M){if(o.nodeName(N[M],"tbody")&&!N[M].childNodes.length){N[M].parentNode.removeChild(N[M])}}}if(!o.support.leadingWhitespace&&/^\s/.test(S)){L.insertBefore(K.createTextNode(S.match(/^\s*/)[0]),L.firstChild)}S=o.makeArray(L.childNodes)}if(S.nodeType){G.push(S)}else{G=o.merge(G,S)}});if(I){for(var J=0;G[J];J++){if(o.nodeName(G[J],"script")&&(!G[J].type||G[J].type.toLowerCase()==="text/javascript")){E.push(G[J].parentNode?G[J].parentNode.removeChild(G[J]):G[J])}else{if(G[J].nodeType===1){G.splice.apply(G,[J+1,0].concat(o.makeArray(G[J].getElementsByTagName("script"))))}I.appendChild(G[J])}}return E}return G},attr:function(J,G,K){if(!J||J.nodeType==3||J.nodeType==8){return g}var H=!o.isXMLDoc(J),L=K!==g;G=H&&o.props[G]||G;if(J.tagName){var F=/href|src|style/.test(G);if(G=="selected"&&J.parentNode){J.parentNode.selectedIndex}if(G in J&&H&&!F){if(L){if(G=="type"&&o.nodeName(J,"input")&&J.parentNode){throw"type property can't be changed"}J[G]=K}if(o.nodeName(J,"form")&&J.getAttributeNode(G)){return J.getAttributeNode(G).nodeValue}if(G=="tabIndex"){var I=J.getAttributeNode("tabIndex");return I&&I.specified?I.value:J.nodeName.match(/(button|input|object|select|textarea)/i)?0:J.nodeName.match(/^(a|area)$/i)&&J.href?0:g}return J[G]}if(!o.support.style&&H&&G=="style"){return o.attr(J.style,"cssText",K)}if(L){J.setAttribute(G,""+K)}var E=!o.support.hrefNormalized&&H&&F?J.getAttribute(G,2):J.getAttribute(G);return E===null?g:E}if(!o.support.opacity&&G=="opacity"){if(L){J.zoom=1;J.filter=(J.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(K)+""=="NaN"?"":"alpha(opacity="+K*100+")")}return J.filter&&J.filter.indexOf("opacity=")>=0?(parseFloat(J.filter.match(/opacity=([^)]*)/)[1])/100)+"":""}G=G.replace(/-([a-z])/ig,function(M,N){return N.toUpperCase()});if(L){J[G]=K}return J[G]},trim:function(E){return(E||"").replace(/^\s+|\s+$/g,"")},makeArray:function(G){var E=[];if(G!=null){var F=G.length;if(F==null||typeof G==="string"||o.isFunction(G)||G.setInterval){E[0]=G}else{while(F){E[--F]=G[F]}}}return E},inArray:function(G,H){for(var E=0,F=H.length;E<F;E++){if(H[E]===G){return E}}return -1},merge:function(H,E){var F=0,G,I=H.length;if(!o.support.getAll){while((G=E[F++])!=null){if(G.nodeType!=8){H[I++]=G}}}else{while((G=E[F++])!=null){H[I++]=G}}return H},unique:function(K){var F=[],E={};try{for(var G=0,H=K.length;G<H;G++){var J=o.data(K[G]);if(!E[J]){E[J]=true;F.push(K[G])}}}catch(I){F=K}return F},grep:function(F,J,E){var G=[];for(var H=0,I=F.length;H<I;H++){if(!E!=!J(F[H],H)){G.push(F[H])}}return G},map:function(E,J){var F=[];for(var G=0,H=E.length;G<H;G++){var I=J(E[G],G);if(I!=null){F[F.length]=I}}return F.concat.apply([],F)}});var C=navigator.userAgent.toLowerCase();o.browser={version:(C.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[0,"0"])[1],safari:/webkit/.test(C),opera:/opera/.test(C),msie:/msie/.test(C)&&!/opera/.test(C),mozilla:/mozilla/.test(C)&&!/(compatible|webkit)/.test(C)};o.each({parent:function(E){return E.parentNode},parents:function(E){return o.dir(E,"parentNode")},next:function(E){return o.nth(E,2,"nextSibling")},prev:function(E){return o.nth(E,2,"previousSibling")},nextAll:function(E){return o.dir(E,"nextSibling")},prevAll:function(E){return o.dir(E,"previousSibling")},siblings:function(E){return o.sibling(E.parentNode.firstChild,E)},children:function(E){return o.sibling(E.firstChild)},contents:function(E){return o.nodeName(E,"iframe")?E.contentDocument||E.contentWindow.document:o.makeArray(E.childNodes)}},function(E,F){o.fn[E]=function(G){var H=o.map(this,F);if(G&&typeof G=="string"){H=o.multiFilter(G,H)}return this.pushStack(o.unique(H),E,G)}});o.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(E,F){o.fn[E]=function(G){var J=[],L=o(G);for(var K=0,H=L.length;K<H;K++){var I=(K>0?this.clone(true):this).get();o.fn[F].apply(o(L[K]),I);J=J.concat(I)}return this.pushStack(J,E,G)}});o.each({removeAttr:function(E){o.attr(this,E,"");if(this.nodeType==1){this.removeAttribute(E)}},addClass:function(E){o.className.add(this,E)},removeClass:function(E){o.className.remove(this,E)},toggleClass:function(F,E){if(typeof E!=="boolean"){E=!o.className.has(this,F)}o.className[E?"add":"remove"](this,F)},remove:function(E){if(!E||o.filter(E,[this]).length){o("*",this).add([this]).each(function(){o.event.remove(this);o.removeData(this)});if(this.parentNode){this.parentNode.removeChild(this)}}},empty:function(){o(this).children().remove();while(this.firstChild){this.removeChild(this.firstChild)}}},function(E,F){o.fn[E]=function(){return this.each(F,arguments)}});function j(E,F){return E[0]&&parseInt(o.curCSS(E[0],F,true),10)||0}var h="jQuery"+e(),v=0,A={};o.extend({cache:{},data:function(F,E,G){F=F==l?A:F;var H=F[h];if(!H){H=F[h]=++v}if(E&&!o.cache[H]){o.cache[H]={}}if(G!==g){o.cache[H][E]=G}return E?o.cache[H][E]:H},removeData:function(F,E){F=F==l?A:F;var H=F[h];if(E){if(o.cache[H]){delete o.cache[H][E];E="";for(E in o.cache[H]){break}if(!E){o.removeData(F)}}}else{try{delete F[h]}catch(G){if(F.removeAttribute){F.removeAttribute(h)}}delete o.cache[H]}},queue:function(F,E,H){if(F){E=(E||"fx")+"queue";var G=o.data(F,E);if(!G||o.isArray(H)){G=o.data(F,E,o.makeArray(H))}else{if(H){G.push(H)}}}return G},dequeue:function(H,G){var E=o.queue(H,G),F=E.shift();if(!G||G==="fx"){F=E[0]}if(F!==g){F.call(H)}}});o.fn.extend({data:function(E,G){var H=E.split(".");H[1]=H[1]?"."+H[1]:"";if(G===g){var F=this.triggerHandler("getData"+H[1]+"!",[H[0]]);if(F===g&&this.length){F=o.data(this[0],E)}return F===g&&H[1]?this.data(H[0]):F}else{return this.trigger("setData"+H[1]+"!",[H[0],G]).each(function(){o.data(this,E,G)})}},removeData:function(E){return this.each(function(){o.removeData(this,E)})},queue:function(E,F){if(typeof E!=="string"){F=E;E="fx"}if(F===g){return o.queue(this[0],E)}return this.each(function(){var G=o.queue(this,E,F);if(E=="fx"&&G.length==1){G[0].call(this)}})},dequeue:function(E){return this.each(function(){o.dequeue(this,E)})}});
|
13 |
-
/*
|
14 |
-
* Sizzle CSS Selector Engine - v0.9.3
|
15 |
-
* Copyright 2009, The Dojo Foundation
|
16 |
-
* Released under the MIT, BSD, and GPL Licenses.
|
17 |
-
* More information: http://sizzlejs.com/
|
18 |
-
*/
|
19 |
-
(function(){var R=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,L=0,H=Object.prototype.toString;var F=function(Y,U,ab,ac){ab=ab||[];U=U||document;if(U.nodeType!==1&&U.nodeType!==9){return[]}if(!Y||typeof Y!=="string"){return ab}var Z=[],W,af,ai,T,ad,V,X=true;R.lastIndex=0;while((W=R.exec(Y))!==null){Z.push(W[1]);if(W[2]){V=RegExp.rightContext;break}}if(Z.length>1&&M.exec(Y)){if(Z.length===2&&I.relative[Z[0]]){af=J(Z[0]+Z[1],U)}else{af=I.relative[Z[0]]?[U]:F(Z.shift(),U);while(Z.length){Y=Z.shift();if(I.relative[Y]){Y+=Z.shift()}af=J(Y,af)}}}else{var ae=ac?{expr:Z.pop(),set:E(ac)}:F.find(Z.pop(),Z.length===1&&U.parentNode?U.parentNode:U,Q(U));af=F.filter(ae.expr,ae.set);if(Z.length>0){ai=E(af)}else{X=false}while(Z.length){var ah=Z.pop(),ag=ah;if(!I.relative[ah]){ah=""}else{ag=Z.pop()}if(ag==null){ag=U}I.relative[ah](ai,ag,Q(U))}}if(!ai){ai=af}if(!ai){throw"Syntax error, unrecognized expression: "+(ah||Y)}if(H.call(ai)==="[object Array]"){if(!X){ab.push.apply(ab,ai)}else{if(U.nodeType===1){for(var aa=0;ai[aa]!=null;aa++){if(ai[aa]&&(ai[aa]===true||ai[aa].nodeType===1&&K(U,ai[aa]))){ab.push(af[aa])}}}else{for(var aa=0;ai[aa]!=null;aa++){if(ai[aa]&&ai[aa].nodeType===1){ab.push(af[aa])}}}}}else{E(ai,ab)}if(V){F(V,U,ab,ac);if(G){hasDuplicate=false;ab.sort(G);if(hasDuplicate){for(var aa=1;aa<ab.length;aa++){if(ab[aa]===ab[aa-1]){ab.splice(aa--,1)}}}}}return ab};F.matches=function(T,U){return F(T,null,null,U)};F.find=function(aa,T,ab){var Z,X;if(!aa){return[]}for(var W=0,V=I.order.length;W<V;W++){var Y=I.order[W],X;if((X=I.match[Y].exec(aa))){var U=RegExp.leftContext;if(U.substr(U.length-1)!=="\\"){X[1]=(X[1]||"").replace(/\\/g,"");Z=I.find[Y](X,T,ab);if(Z!=null){aa=aa.replace(I.match[Y],"");break}}}}if(!Z){Z=T.getElementsByTagName("*")}return{set:Z,expr:aa}};F.filter=function(ad,ac,ag,W){var V=ad,ai=[],aa=ac,Y,T,Z=ac&&ac[0]&&Q(ac[0]);while(ad&&ac.length){for(var ab in I.filter){if((Y=I.match[ab].exec(ad))!=null){var U=I.filter[ab],ah,af;T=false;if(aa==ai){ai=[]}if(I.preFilter[ab]){Y=I.preFilter[ab](Y,aa,ag,ai,W,Z);if(!Y){T=ah=true}else{if(Y===true){continue}}}if(Y){for(var X=0;(af=aa[X])!=null;X++){if(af){ah=U(af,Y,X,aa);var ae=W^!!ah;if(ag&&ah!=null){if(ae){T=true}else{aa[X]=false}}else{if(ae){ai.push(af);T=true}}}}}if(ah!==g){if(!ag){aa=ai}ad=ad.replace(I.match[ab],"");if(!T){return[]}break}}}if(ad==V){if(T==null){throw"Syntax error, unrecognized expression: "+ad}else{break}}V=ad}return aa};var I=F.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(T){return T.getAttribute("href")}},relative:{"+":function(aa,T,Z){var X=typeof T==="string",ab=X&&!/\W/.test(T),Y=X&&!ab;if(ab&&!Z){T=T.toUpperCase()}for(var W=0,V=aa.length,U;W<V;W++){if((U=aa[W])){while((U=U.previousSibling)&&U.nodeType!==1){}aa[W]=Y||U&&U.nodeName===T?U||false:U===T}}if(Y){F.filter(T,aa,true)}},">":function(Z,U,aa){var X=typeof U==="string";if(X&&!/\W/.test(U)){U=aa?U:U.toUpperCase();for(var V=0,T=Z.length;V<T;V++){var Y=Z[V];if(Y){var W=Y.parentNode;Z[V]=W.nodeName===U?W:false}}}else{for(var V=0,T=Z.length;V<T;V++){var Y=Z[V];if(Y){Z[V]=X?Y.parentNode:Y.parentNode===U}}if(X){F.filter(U,Z,true)}}},"":function(W,U,Y){var V=L++,T=S;if(!U.match(/\W/)){var X=U=Y?U:U.toUpperCase();T=P}T("parentNode",U,V,W,X,Y)},"~":function(W,U,Y){var V=L++,T=S;if(typeof U==="string"&&!U.match(/\W/)){var X=U=Y?U:U.toUpperCase();T=P}T("previousSibling",U,V,W,X,Y)}},find:{ID:function(U,V,W){if(typeof V.getElementById!=="undefined"&&!W){var T=V.getElementById(U[1]);return T?[T]:[]}},NAME:function(V,Y,Z){if(typeof Y.getElementsByName!=="undefined"){var U=[],X=Y.getElementsByName(V[1]);for(var W=0,T=X.length;W<T;W++){if(X[W].getAttribute("name")===V[1]){U.push(X[W])}}return U.length===0?null:U}},TAG:function(T,U){return U.getElementsByTagName(T[1])}},preFilter:{CLASS:function(W,U,V,T,Z,aa){W=" "+W[1].replace(/\\/g,"")+" ";if(aa){return W}for(var X=0,Y;(Y=U[X])!=null;X++){if(Y){if(Z^(Y.className&&(" "+Y.className+" ").indexOf(W)>=0)){if(!V){T.push(Y)}}else{if(V){U[X]=false}}}}return false},ID:function(T){return T[1].replace(/\\/g,"")},TAG:function(U,T){for(var V=0;T[V]===false;V++){}return T[V]&&Q(T[V])?U[1]:U[1].toUpperCase()},CHILD:function(T){if(T[1]=="nth"){var U=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(T[2]=="even"&&"2n"||T[2]=="odd"&&"2n+1"||!/\D/.test(T[2])&&"0n+"+T[2]||T[2]);T[2]=(U[1]+(U[2]||1))-0;T[3]=U[3]-0}T[0]=L++;return T},ATTR:function(X,U,V,T,Y,Z){var W=X[1].replace(/\\/g,"");if(!Z&&I.attrMap[W]){X[1]=I.attrMap[W]}if(X[2]==="~="){X[4]=" "+X[4]+" "}return X},PSEUDO:function(X,U,V,T,Y){if(X[1]==="not"){if(X[3].match(R).length>1||/^\w/.test(X[3])){X[3]=F(X[3],null,null,U)}else{var W=F.filter(X[3],U,V,true^Y);if(!V){T.push.apply(T,W)}return false}}else{if(I.match.POS.test(X[0])||I.match.CHILD.test(X[0])){return true}}return X},POS:function(T){T.unshift(true);return T}},filters:{enabled:function(T){return T.disabled===false&&T.type!=="hidden"},disabled:function(T){return T.disabled===true},checked:function(T){return T.checked===true},selected:function(T){T.parentNode.selectedIndex;return T.selected===true},parent:function(T){return !!T.firstChild},empty:function(T){return !T.firstChild},has:function(V,U,T){return !!F(T[3],V).length},header:function(T){return/h\d/i.test(T.nodeName)},text:function(T){return"text"===T.type},radio:function(T){return"radio"===T.type},checkbox:function(T){return"checkbox"===T.type},file:function(T){return"file"===T.type},password:function(T){return"password"===T.type},submit:function(T){return"submit"===T.type},image:function(T){return"image"===T.type},reset:function(T){return"reset"===T.type},button:function(T){return"button"===T.type||T.nodeName.toUpperCase()==="BUTTON"},input:function(T){return/input|select|textarea|button/i.test(T.nodeName)}},setFilters:{first:function(U,T){return T===0},last:function(V,U,T,W){return U===W.length-1},even:function(U,T){return T%2===0},odd:function(U,T){return T%2===1},lt:function(V,U,T){return U<T[3]-0},gt:function(V,U,T){return U>T[3]-0},nth:function(V,U,T){return T[3]-0==U},eq:function(V,U,T){return T[3]-0==U}},filter:{PSEUDO:function(Z,V,W,aa){var U=V[1],X=I.filters[U];if(X){return X(Z,W,V,aa)}else{if(U==="contains"){return(Z.textContent||Z.innerText||"").indexOf(V[3])>=0}else{if(U==="not"){var Y=V[3];for(var W=0,T=Y.length;W<T;W++){if(Y[W]===Z){return false}}return true}}}},CHILD:function(T,W){var Z=W[1],U=T;switch(Z){case"only":case"first":while(U=U.previousSibling){if(U.nodeType===1){return false}}if(Z=="first"){return true}U=T;case"last":while(U=U.nextSibling){if(U.nodeType===1){return false}}return true;case"nth":var V=W[2],ac=W[3];if(V==1&&ac==0){return true}var Y=W[0],ab=T.parentNode;if(ab&&(ab.sizcache!==Y||!T.nodeIndex)){var X=0;for(U=ab.firstChild;U;U=U.nextSibling){if(U.nodeType===1){U.nodeIndex=++X}}ab.sizcache=Y}var aa=T.nodeIndex-ac;if(V==0){return aa==0}else{return(aa%V==0&&aa/V>=0)}}},ID:function(U,T){return U.nodeType===1&&U.getAttribute("id")===T},TAG:function(U,T){return(T==="*"&&U.nodeType===1)||U.nodeName===T},CLASS:function(U,T){return(" "+(U.className||U.getAttribute("class"))+" ").indexOf(T)>-1},ATTR:function(Y,W){var V=W[1],T=I.attrHandle[V]?I.attrHandle[V](Y):Y[V]!=null?Y[V]:Y.getAttribute(V),Z=T+"",X=W[2],U=W[4];return T==null?X==="!=":X==="="?Z===U:X==="*="?Z.indexOf(U)>=0:X==="~="?(" "+Z+" ").indexOf(U)>=0:!U?Z&&T!==false:X==="!="?Z!=U:X==="^="?Z.indexOf(U)===0:X==="$="?Z.substr(Z.length-U.length)===U:X==="|="?Z===U||Z.substr(0,U.length+1)===U+"-":false},POS:function(X,U,V,Y){var T=U[2],W=I.setFilters[T];if(W){return W(X,V,U,Y)}}}};var M=I.match.POS;for(var O in I.match){I.match[O]=RegExp(I.match[O].source+/(?![^\[]*\])(?![^\(]*\))/.source)}var E=function(U,T){U=Array.prototype.slice.call(U);if(T){T.push.apply(T,U);return T}return U};try{Array.prototype.slice.call(document.documentElement.childNodes)}catch(N){E=function(X,W){var U=W||[];if(H.call(X)==="[object Array]"){Array.prototype.push.apply(U,X)}else{if(typeof X.length==="number"){for(var V=0,T=X.length;V<T;V++){U.push(X[V])}}else{for(var V=0;X[V];V++){U.push(X[V])}}}return U}}var G;if(document.documentElement.compareDocumentPosition){G=function(U,T){var V=U.compareDocumentPosition(T)&4?-1:U===T?0:1;if(V===0){hasDuplicate=true}return V}}else{if("sourceIndex" in document.documentElement){G=function(U,T){var V=U.sourceIndex-T.sourceIndex;if(V===0){hasDuplicate=true}return V}}else{if(document.createRange){G=function(W,U){var V=W.ownerDocument.createRange(),T=U.ownerDocument.createRange();V.selectNode(W);V.collapse(true);T.selectNode(U);T.collapse(true);var X=V.compareBoundaryPoints(Range.START_TO_END,T);if(X===0){hasDuplicate=true}return X}}}}(function(){var U=document.createElement("form"),V="script"+(new Date).getTime();U.innerHTML="<input name='"+V+"'/>";var T=document.documentElement;T.insertBefore(U,T.firstChild);if(!!document.getElementById(V)){I.find.ID=function(X,Y,Z){if(typeof Y.getElementById!=="undefined"&&!Z){var W=Y.getElementById(X[1]);return W?W.id===X[1]||typeof W.getAttributeNode!=="undefined"&&W.getAttributeNode("id").nodeValue===X[1]?[W]:g:[]}};I.filter.ID=function(Y,W){var X=typeof Y.getAttributeNode!=="undefined"&&Y.getAttributeNode("id");return Y.nodeType===1&&X&&X.nodeValue===W}}T.removeChild(U)})();(function(){var T=document.createElement("div");T.appendChild(document.createComment(""));if(T.getElementsByTagName("*").length>0){I.find.TAG=function(U,Y){var X=Y.getElementsByTagName(U[1]);if(U[1]==="*"){var W=[];for(var V=0;X[V];V++){if(X[V].nodeType===1){W.push(X[V])}}X=W}return X}}T.innerHTML="<a href='#'></a>";if(T.firstChild&&typeof T.firstChild.getAttribute!=="undefined"&&T.firstChild.getAttribute("href")!=="#"){I.attrHandle.href=function(U){return U.getAttribute("href",2)}}})();if(document.querySelectorAll){(function(){var T=F,U=document.createElement("div");U.innerHTML="<p class='TEST'></p>";if(U.querySelectorAll&&U.querySelectorAll(".TEST").length===0){return}F=function(Y,X,V,W){X=X||document;if(!W&&X.nodeType===9&&!Q(X)){try{return E(X.querySelectorAll(Y),V)}catch(Z){}}return T(Y,X,V,W)};F.find=T.find;F.filter=T.filter;F.selectors=T.selectors;F.matches=T.matches})()}if(document.getElementsByClassName&&document.documentElement.getElementsByClassName){(function(){var T=document.createElement("div");T.innerHTML="<div class='test e'></div><div class='test'></div>";if(T.getElementsByClassName("e").length===0){return}T.lastChild.className="e";if(T.getElementsByClassName("e").length===1){return}I.order.splice(1,0,"CLASS");I.find.CLASS=function(U,V,W){if(typeof V.getElementsByClassName!=="undefined"&&!W){return V.getElementsByClassName(U[1])}}})()}function P(U,Z,Y,ad,aa,ac){var ab=U=="previousSibling"&&!ac;for(var W=0,V=ad.length;W<V;W++){var T=ad[W];if(T){if(ab&&T.nodeType===1){T.sizcache=Y;T.sizset=W}T=T[U];var X=false;while(T){if(T.sizcache===Y){X=ad[T.sizset];break}if(T.nodeType===1&&!ac){T.sizcache=Y;T.sizset=W}if(T.nodeName===Z){X=T;break}T=T[U]}ad[W]=X}}}function S(U,Z,Y,ad,aa,ac){var ab=U=="previousSibling"&&!ac;for(var W=0,V=ad.length;W<V;W++){var T=ad[W];if(T){if(ab&&T.nodeType===1){T.sizcache=Y;T.sizset=W}T=T[U];var X=false;while(T){if(T.sizcache===Y){X=ad[T.sizset];break}if(T.nodeType===1){if(!ac){T.sizcache=Y;T.sizset=W}if(typeof Z!=="string"){if(T===Z){X=true;break}}else{if(F.filter(Z,[T]).length>0){X=T;break}}}T=T[U]}ad[W]=X}}}var K=document.compareDocumentPosition?function(U,T){return U.compareDocumentPosition(T)&16}:function(U,T){return U!==T&&(U.contains?U.contains(T):true)};var Q=function(T){return T.nodeType===9&&T.documentElement.nodeName!=="HTML"||!!T.ownerDocument&&Q(T.ownerDocument)};var J=function(T,aa){var W=[],X="",Y,V=aa.nodeType?[aa]:aa;while((Y=I.match.PSEUDO.exec(T))){X+=Y[0];T=T.replace(I.match.PSEUDO,"")}T=I.relative[T]?T+"*":T;for(var Z=0,U=V.length;Z<U;Z++){F(T,V[Z],W)}return F.filter(X,W)};o.find=F;o.filter=F.filter;o.expr=F.selectors;o.expr[":"]=o.expr.filters;F.selectors.filters.hidden=function(T){return T.offsetWidth===0||T.offsetHeight===0};F.selectors.filters.visible=function(T){return T.offsetWidth>0||T.offsetHeight>0};F.selectors.filters.animated=function(T){return o.grep(o.timers,function(U){return T===U.elem}).length};o.multiFilter=function(V,T,U){if(U){V=":not("+V+")"}return F.matches(V,T)};o.dir=function(V,U){var T=[],W=V[U];while(W&&W!=document){if(W.nodeType==1){T.push(W)}W=W[U]}return T};o.nth=function(X,T,V,W){T=T||1;var U=0;for(;X;X=X[V]){if(X.nodeType==1&&++U==T){break}}return X};o.sibling=function(V,U){var T=[];for(;V;V=V.nextSibling){if(V.nodeType==1&&V!=U){T.push(V)}}return T};return;l.Sizzle=F})();o.event={add:function(I,F,H,K){if(I.nodeType==3||I.nodeType==8){return}if(I.setInterval&&I!=l){I=l}if(!H.guid){H.guid=this.guid++}if(K!==g){var G=H;H=this.proxy(G);H.data=K}var E=o.data(I,"events")||o.data(I,"events",{}),J=o.data(I,"handle")||o.data(I,"handle",function(){return typeof o!=="undefined"&&!o.event.triggered?o.event.handle.apply(arguments.callee.elem,arguments):g});J.elem=I;o.each(F.split(/\s+/),function(M,N){var O=N.split(".");N=O.shift();H.type=O.slice().sort().join(".");var L=E[N];if(o.event.specialAll[N]){o.event.specialAll[N].setup.call(I,K,O)}if(!L){L=E[N]={};if(!o.event.special[N]||o.event.special[N].setup.call(I,K,O)===false){if(I.addEventListener){I.addEventListener(N,J,false)}else{if(I.attachEvent){I.attachEvent("on"+N,J)}}}}L[H.guid]=H;o.event.global[N]=true});I=null},guid:1,global:{},remove:function(K,H,J){if(K.nodeType==3||K.nodeType==8){return}var G=o.data(K,"events"),F,E;if(G){if(H===g||(typeof H==="string"&&H.charAt(0)==".")){for(var I in G){this.remove(K,I+(H||""))}}else{if(H.type){J=H.handler;H=H.type}o.each(H.split(/\s+/),function(M,O){var Q=O.split(".");O=Q.shift();var N=RegExp("(^|\\.)"+Q.slice().sort().join(".*\\.")+"(\\.|$)");if(G[O]){if(J){delete G[O][J.guid]}else{for(var P in G[O]){if(N.test(G[O][P].type)){delete G[O][P]}}}if(o.event.specialAll[O]){o.event.specialAll[O].teardown.call(K,Q)}for(F in G[O]){break}if(!F){if(!o.event.special[O]||o.event.special[O].teardown.call(K,Q)===false){if(K.removeEventListener){K.removeEventListener(O,o.data(K,"handle"),false)}else{if(K.detachEvent){K.detachEvent("on"+O,o.data(K,"handle"))}}}F=null;delete G[O]}}})}for(F in G){break}if(!F){var L=o.data(K,"handle");if(L){L.elem=null}o.removeData(K,"events");o.removeData(K,"handle")}}},trigger:function(I,K,H,E){var G=I.type||I;if(!E){I=typeof I==="object"?I[h]?I:o.extend(o.Event(G),I):o.Event(G);if(G.indexOf("!")>=0){I.type=G=G.slice(0,-1);I.exclusive=true}if(!H){I.stopPropagation();if(this.global[G]){o.each(o.cache,function(){if(this.events&&this.events[G]){o.event.trigger(I,K,this.handle.elem)}})}}if(!H||H.nodeType==3||H.nodeType==8){return g}I.result=g;I.target=H;K=o.makeArray(K);K.unshift(I)}I.currentTarget=H;var J=o.data(H,"handle");if(J){J.apply(H,K)}if((!H[G]||(o.nodeName(H,"a")&&G=="click"))&&H["on"+G]&&H["on"+G].apply(H,K)===false){I.result=false}if(!E&&H[G]&&!I.isDefaultPrevented()&&!(o.nodeName(H,"a")&&G=="click")){this.triggered=true;try{H[G]()}catch(L){}}this.triggered=false;if(!I.isPropagationStopped()){var F=H.parentNode||H.ownerDocument;if(F){o.event.trigger(I,K,F,true)}}},handle:function(K){var J,E;K=arguments[0]=o.event.fix(K||l.event);K.currentTarget=this;var L=K.type.split(".");K.type=L.shift();J=!L.length&&!K.exclusive;var I=RegExp("(^|\\.)"+L.slice().sort().join(".*\\.")+"(\\.|$)");E=(o.data(this,"events")||{})[K.type];for(var G in E){var H=E[G];if(J||I.test(H.type)){K.handler=H;K.data=H.data;var F=H.apply(this,arguments);if(F!==g){K.result=F;if(F===false){K.preventDefault();K.stopPropagation()}}if(K.isImmediatePropagationStopped()){break}}}},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(H){if(H[h]){return H}var F=H;H=o.Event(F);for(var G=this.props.length,J;G;){J=this.props[--G];H[J]=F[J]}if(!H.target){H.target=H.srcElement||document}if(H.target.nodeType==3){H.target=H.target.parentNode}if(!H.relatedTarget&&H.fromElement){H.relatedTarget=H.fromElement==H.target?H.toElement:H.fromElement}if(H.pageX==null&&H.clientX!=null){var I=document.documentElement,E=document.body;H.pageX=H.clientX+(I&&I.scrollLeft||E&&E.scrollLeft||0)-(I.clientLeft||0);H.pageY=H.clientY+(I&&I.scrollTop||E&&E.scrollTop||0)-(I.clientTop||0)}if(!H.which&&((H.charCode||H.charCode===0)?H.charCode:H.keyCode)){H.which=H.charCode||H.keyCode}if(!H.metaKey&&H.ctrlKey){H.metaKey=H.ctrlKey}if(!H.which&&H.button){H.which=(H.button&1?1:(H.button&2?3:(H.button&4?2:0)))}return H},proxy:function(F,E){E=E||function(){return F.apply(this,arguments)};E.guid=F.guid=F.guid||E.guid||this.guid++;return E},special:{ready:{setup:B,teardown:function(){}}},specialAll:{live:{setup:function(E,F){o.event.add(this,F[0],c)},teardown:function(G){if(G.length){var E=0,F=RegExp("(^|\\.)"+G[0]+"(\\.|$)");o.each((o.data(this,"events").live||{}),function(){if(F.test(this.type)){E++}});if(E<1){o.event.remove(this,G[0],c)}}}}}};o.Event=function(E){if(!this.preventDefault){return new o.Event(E)}if(E&&E.type){this.originalEvent=E;this.type=E.type}else{this.type=E}this.timeStamp=e();this[h]=true};function k(){return false}function u(){return true}o.Event.prototype={preventDefault:function(){this.isDefaultPrevented=u;var E=this.originalEvent;if(!E){return}if(E.preventDefault){E.preventDefault()}E.returnValue=false},stopPropagation:function(){this.isPropagationStopped=u;var E=this.originalEvent;if(!E){return}if(E.stopPropagation){E.stopPropagation()}E.cancelBubble=true},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=u;this.stopPropagation()},isDefaultPrevented:k,isPropagationStopped:k,isImmediatePropagationStopped:k};var a=function(F){var E=F.relatedTarget;while(E&&E!=this){try{E=E.parentNode}catch(G){E=this}}if(E!=this){F.type=F.data;o.event.handle.apply(this,arguments)}};o.each({mouseover:"mouseenter",mouseout:"mouseleave"},function(F,E){o.event.special[E]={setup:function(){o.event.add(this,F,a,E)},teardown:function(){o.event.remove(this,F,a)}}});o.fn.extend({bind:function(F,G,E){return F=="unload"?this.one(F,G,E):this.each(function(){o.event.add(this,F,E||G,E&&G)})},one:function(G,H,F){var E=o.event.proxy(F||H,function(I){o(this).unbind(I,E);return(F||H).apply(this,arguments)});return this.each(function(){o.event.add(this,G,E,F&&H)})},unbind:function(F,E){return this.each(function(){o.event.remove(this,F,E)})},trigger:function(E,F){return this.each(function(){o.event.trigger(E,F,this)})},triggerHandler:function(E,G){if(this[0]){var F=o.Event(E);F.preventDefault();F.stopPropagation();o.event.trigger(F,G,this[0]);return F.result}},toggle:function(G){var E=arguments,F=1;while(F<E.length){o.event.proxy(G,E[F++])}return this.click(o.event.proxy(G,function(H){this.lastToggle=(this.lastToggle||0)%F;H.preventDefault();return E[this.lastToggle++].apply(this,arguments)||false}))},hover:function(E,F){return this.mouseenter(E).mouseleave(F)},ready:function(E){B();if(o.isReady){E.call(document,o)}else{o.readyList.push(E)}return this},live:function(G,F){var E=o.event.proxy(F);E.guid+=this.selector+G;o(document).bind(i(G,this.selector),this.selector,E);return this},die:function(F,E){o(document).unbind(i(F,this.selector),E?{guid:E.guid+this.selector+F}:null);return this}});function c(H){var E=RegExp("(^|\\.)"+H.type+"(\\.|$)"),G=true,F=[];o.each(o.data(this,"events").live||[],function(I,J){if(E.test(J.type)){var K=o(H.target).closest(J.data)[0];if(K){F.push({elem:K,fn:J})}}});F.sort(function(J,I){return o.data(J.elem,"closest")-o.data(I.elem,"closest")});o.each(F,function(){if(this.fn.call(this.elem,H,this.fn.data)===false){return(G=false)}});return G}function i(F,E){return["live",F,E.replace(/\./g,"`").replace(/ /g,"|")].join(".")}o.extend({isReady:false,readyList:[],ready:function(){if(!o.isReady){o.isReady=true;if(o.readyList){o.each(o.readyList,function(){this.call(document,o)});o.readyList=null}o(document).triggerHandler("ready")}}});var x=false;function B(){if(x){return}x=true;if(document.addEventListener){document.addEventListener("DOMContentLoaded",function(){document.removeEventListener("DOMContentLoaded",arguments.callee,false);o.ready()},false)}else{if(document.attachEvent){document.attachEvent("onreadystatechange",function(){if(document.readyState==="complete"){document.detachEvent("onreadystatechange",arguments.callee);o.ready()}});if(document.documentElement.doScroll&&l==l.top){(function(){if(o.isReady){return}try{document.documentElement.doScroll("left")}catch(E){setTimeout(arguments.callee,0);return}o.ready()})()}}}o.event.add(l,"load",o.ready)}o.each(("blur,focus,load,resize,scroll,unload,click,dblclick,mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave,change,select,submit,keydown,keypress,keyup,error").split(","),function(F,E){o.fn[E]=function(G){return G?this.bind(E,G):this.trigger(E)}});o(l).bind("unload",function(){for(var E in o.cache){if(E!=1&&o.cache[E].handle){o.event.remove(o.cache[E].handle.elem)}}});(function(){o.support={};var F=document.documentElement,G=document.createElement("script"),K=document.createElement("div"),J="script"+(new Date).getTime();K.style.display="none";K.innerHTML=' <link/><table></table><a href="/a" style="color:red;float:left;opacity:.5;">a</a><select><option>text</option></select><object><param/></object>';var H=K.getElementsByTagName("*"),E=K.getElementsByTagName("a")[0];if(!H||!H.length||!E){return}o.support={leadingWhitespace:K.firstChild.nodeType==3,tbody:!K.getElementsByTagName("tbody").length,objectAll:!!K.getElementsByTagName("object")[0].getElementsByTagName("*").length,htmlSerialize:!!K.getElementsByTagName("link").length,style:/red/.test(E.getAttribute("style")),hrefNormalized:E.getAttribute("href")==="/a",opacity:E.style.opacity==="0.5",cssFloat:!!E.style.cssFloat,scriptEval:false,noCloneEvent:true,boxModel:null};G.type="text/javascript";try{G.appendChild(document.createTextNode("window."+J+"=1;"))}catch(I){}F.insertBefore(G,F.firstChild);if(l[J]){o.support.scriptEval=true;delete l[J]}F.removeChild(G);if(K.attachEvent&&K.fireEvent){K.attachEvent("onclick",function(){o.support.noCloneEvent=false;K.detachEvent("onclick",arguments.callee)});K.cloneNode(true).fireEvent("onclick")}o(function(){var L=document.createElement("div");L.style.width=L.style.paddingLeft="1px";document.body.appendChild(L);o.boxModel=o.support.boxModel=L.offsetWidth===2;document.body.removeChild(L).style.display="none"})})();var w=o.support.cssFloat?"cssFloat":"styleFloat";o.props={"for":"htmlFor","class":"className","float":w,cssFloat:w,styleFloat:w,readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",tabindex:"tabIndex"};o.fn.extend({_load:o.fn.load,load:function(G,J,K){if(typeof G!=="string"){return this._load(G)}var I=G.indexOf(" ");if(I>=0){var E=G.slice(I,G.length);G=G.slice(0,I)}var H="GET";if(J){if(o.isFunction(J)){K=J;J=null}else{if(typeof J==="object"){J=o.param(J);H="POST"}}}var F=this;o.ajax({url:G,type:H,dataType:"html",data:J,complete:function(M,L){if(L=="success"||L=="notmodified"){F.html(E?o("<div/>").append(M.responseText.replace(/<script(.|\s)*?\/script>/g,"")).find(E):M.responseText)}if(K){F.each(K,[M.responseText,L,M])}}});return this},serialize:function(){return o.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?o.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password|search/i.test(this.type))}).map(function(E,F){var G=o(this).val();return G==null?null:o.isArray(G)?o.map(G,function(I,H){return{name:F.name,value:I}}):{name:F.name,value:G}}).get()}});o.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(E,F){o.fn[F]=function(G){return this.bind(F,G)}});var r=e();o.extend({get:function(E,G,H,F){if(o.isFunction(G)){H=G;G=null}return o.ajax({type:"GET",url:E,data:G,success:H,dataType:F})},getScript:function(E,F){return o.get(E,null,F,"script")},getJSON:function(E,F,G){return o.get(E,F,G,"json")},post:function(E,G,H,F){if(o.isFunction(G)){H=G;G={}}return o.ajax({type:"POST",url:E,data:G,success:H,dataType:F})},ajaxSetup:function(E){o.extend(o.ajaxSettings,E)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:function(){return l.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest()},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(M){M=o.extend(true,M,o.extend(true,{},o.ajaxSettings,M));var W,F=/=\?(&|$)/g,R,V,G=M.type.toUpperCase();if(M.data&&M.processData&&typeof M.data!=="string"){M.data=o.param(M.data)}if(M.dataType=="jsonp"){if(G=="GET"){if(!M.url.match(F)){M.url+=(M.url.match(/\?/)?"&":"?")+(M.jsonp||"callback")+"=?"}}else{if(!M.data||!M.data.match(F)){M.data=(M.data?M.data+"&":"")+(M.jsonp||"callback")+"=?"}}M.dataType="json"}if(M.dataType=="json"&&(M.data&&M.data.match(F)||M.url.match(F))){W="jsonp"+r++;if(M.data){M.data=(M.data+"").replace(F,"="+W+"$1")}M.url=M.url.replace(F,"="+W+"$1");M.dataType="script";l[W]=function(X){V=X;I();L();l[W]=g;try{delete l[W]}catch(Y){}if(H){H.removeChild(T)}}}if(M.dataType=="script"&&M.cache==null){M.cache=false}if(M.cache===false&&G=="GET"){var E=e();var U=M.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+E+"$2");M.url=U+((U==M.url)?(M.url.match(/\?/)?"&":"?")+"_="+E:"")}if(M.data&&G=="GET"){M.url+=(M.url.match(/\?/)?"&":"?")+M.data;M.data=null}if(M.global&&!o.active++){o.event.trigger("ajaxStart")}var Q=/^(\w+:)?\/\/([^\/?#]+)/.exec(M.url);if(M.dataType=="script"&&G=="GET"&&Q&&(Q[1]&&Q[1]!=location.protocol||Q[2]!=location.host)){var H=document.getElementsByTagName("head")[0];var T=document.createElement("script");T.src=M.url;if(M.scriptCharset){T.charset=M.scriptCharset}if(!W){var O=false;T.onload=T.onreadystatechange=function(){if(!O&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){O=true;I();L();T.onload=T.onreadystatechange=null;H.removeChild(T)}}}H.appendChild(T);return g}var K=false;var J=M.xhr();if(M.username){J.open(G,M.url,M.async,M.username,M.password)}else{J.open(G,M.url,M.async)}try{if(M.data){J.setRequestHeader("Content-Type",M.contentType)}if(M.ifModified){J.setRequestHeader("If-Modified-Since",o.lastModified[M.url]||"Thu, 01 Jan 1970 00:00:00 GMT")}J.setRequestHeader("X-Requested-With","XMLHttpRequest");J.setRequestHeader("Accept",M.dataType&&M.accepts[M.dataType]?M.accepts[M.dataType]+", */*":M.accepts._default)}catch(S){}if(M.beforeSend&&M.beforeSend(J,M)===false){if(M.global&&!--o.active){o.event.trigger("ajaxStop")}J.abort();return false}if(M.global){o.event.trigger("ajaxSend",[J,M])}var N=function(X){if(J.readyState==0){if(P){clearInterval(P);P=null;if(M.global&&!--o.active){o.event.trigger("ajaxStop")}}}else{if(!K&&J&&(J.readyState==4||X=="timeout")){K=true;if(P){clearInterval(P);P=null}R=X=="timeout"?"timeout":!o.httpSuccess(J)?"error":M.ifModified&&o.httpNotModified(J,M.url)?"notmodified":"success";if(R=="success"){try{V=o.httpData(J,M.dataType,M)}catch(Z){R="parsererror"}}if(R=="success"){var Y;try{Y=J.getResponseHeader("Last-Modified")}catch(Z){}if(M.ifModified&&Y){o.lastModified[M.url]=Y}if(!W){I()}}else{o.handleError(M,J,R)}L();if(X){J.abort()}if(M.async){J=null}}}};if(M.async){var P=setInterval(N,13);if(M.timeout>0){setTimeout(function(){if(J&&!K){N("timeout")}},M.timeout)}}try{J.send(M.data)}catch(S){o.handleError(M,J,null,S)}if(!M.async){N()}function I(){if(M.success){M.success(V,R)}if(M.global){o.event.trigger("ajaxSuccess",[J,M])}}function L(){if(M.complete){M.complete(J,R)}if(M.global){o.event.trigger("ajaxComplete",[J,M])}if(M.global&&!--o.active){o.event.trigger("ajaxStop")}}return J},handleError:function(F,H,E,G){if(F.error){F.error(H,E,G)}if(F.global){o.event.trigger("ajaxError",[H,F,G])}},active:0,httpSuccess:function(F){try{return !F.status&&location.protocol=="file:"||(F.status>=200&&F.status<300)||F.status==304||F.status==1223}catch(E){}return false},httpNotModified:function(G,E){try{var H=G.getResponseHeader("Last-Modified");return G.status==304||H==o.lastModified[E]}catch(F){}return false},httpData:function(J,H,G){var F=J.getResponseHeader("content-type"),E=H=="xml"||!H&&F&&F.indexOf("xml")>=0,I=E?J.responseXML:J.responseText;if(E&&I.documentElement.tagName=="parsererror"){throw"parsererror"}if(G&&G.dataFilter){I=G.dataFilter(I,H)}if(typeof I==="string"){if(H=="script"){o.globalEval(I)}if(H=="json"){I=l["eval"]("("+I+")")}}return I},param:function(E){var G=[];function H(I,J){G[G.length]=encodeURIComponent(I)+"="+encodeURIComponent(J)}if(o.isArray(E)||E.jquery){o.each(E,function(){H(this.name,this.value)})}else{for(var F in E){if(o.isArray(E[F])){o.each(E[F],function(){H(F,this)})}else{H(F,o.isFunction(E[F])?E[F]():E[F])}}}return G.join("&").replace(/%20/g,"+")}});var m={},n,d=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];function t(F,E){var G={};o.each(d.concat.apply([],d.slice(0,E)),function(){G[this]=F});return G}o.fn.extend({show:function(J,L){if(J){return this.animate(t("show",3),J,L)}else{for(var H=0,F=this.length;H<F;H++){var E=o.data(this[H],"olddisplay");this[H].style.display=E||"";if(o.css(this[H],"display")==="none"){var G=this[H].tagName,K;if(m[G]){K=m[G]}else{var I=o("<"+G+" />").appendTo("body");K=I.css("display");if(K==="none"){K="block"}I.remove();m[G]=K}o.data(this[H],"olddisplay",K)}}for(var H=0,F=this.length;H<F;H++){this[H].style.display=o.data(this[H],"olddisplay")||""}return this}},hide:function(H,I){if(H){return this.animate(t("hide",3),H,I)}else{for(var G=0,F=this.length;G<F;G++){var E=o.data(this[G],"olddisplay");if(!E&&E!=="none"){o.data(this[G],"olddisplay",o.css(this[G],"display"))}}for(var G=0,F=this.length;G<F;G++){this[G].style.display="none"}return this}},_toggle:o.fn.toggle,toggle:function(G,F){var E=typeof G==="boolean";return o.isFunction(G)&&o.isFunction(F)?this._toggle.apply(this,arguments):G==null||E?this.each(function(){var H=E?G:o(this).is(":hidden");o(this)[H?"show":"hide"]()}):this.animate(t("toggle",3),G,F)},fadeTo:function(E,G,F){return this.animate({opacity:G},E,F)},animate:function(I,F,H,G){var E=o.speed(F,H,G);return this[E.queue===false?"each":"queue"](function(){var K=o.extend({},E),M,L=this.nodeType==1&&o(this).is(":hidden"),J=this;for(M in I){if(I[M]=="hide"&&L||I[M]=="show"&&!L){return K.complete.call(this)}if((M=="height"||M=="width")&&this.style){K.display=o.css(this,"display");K.overflow=this.style.overflow}}if(K.overflow!=null){this.style.overflow="hidden"}K.curAnim=o.extend({},I);o.each(I,function(O,S){var R=new o.fx(J,K,O);if(/toggle|show|hide/.test(S)){R[S=="toggle"?L?"show":"hide":S](I)}else{var Q=S.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),T=R.cur(true)||0;if(Q){var N=parseFloat(Q[2]),P=Q[3]||"px";if(P!="px"){J.style[O]=(N||1)+P;T=((N||1)/R.cur(true))*T;J.style[O]=T+P}if(Q[1]){N=((Q[1]=="-="?-1:1)*N)+T}R.custom(T,N,P)}else{R.custom(T,S,"")}}});return true})},stop:function(F,E){var G=o.timers;if(F){this.queue([])}this.each(function(){for(var H=G.length-1;H>=0;H--){if(G[H].elem==this){if(E){G[H](true)}G.splice(H,1)}}});if(!E){this.dequeue()}return this}});o.each({slideDown:t("show",1),slideUp:t("hide",1),slideToggle:t("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(E,F){o.fn[E]=function(G,H){return this.animate(F,G,H)}});o.extend({speed:function(G,H,F){var E=typeof G==="object"?G:{complete:F||!F&&H||o.isFunction(G)&&G,duration:G,easing:F&&H||H&&!o.isFunction(H)&&H};E.duration=o.fx.off?0:typeof E.duration==="number"?E.duration:o.fx.speeds[E.duration]||o.fx.speeds._default;E.old=E.complete;E.complete=function(){if(E.queue!==false){o(this).dequeue()}if(o.isFunction(E.old)){E.old.call(this)}};return E},easing:{linear:function(G,H,E,F){return E+F*G},swing:function(G,H,E,F){return((-Math.cos(G*Math.PI)/2)+0.5)*F+E}},timers:[],fx:function(F,E,G){this.options=E;this.elem=F;this.prop=G;if(!E.orig){E.orig={}}}});o.fx.prototype={update:function(){if(this.options.step){this.options.step.call(this.elem,this.now,this)}(o.fx.step[this.prop]||o.fx.step._default)(this);if((this.prop=="height"||this.prop=="width")&&this.elem.style){this.elem.style.display="block"}},cur:function(F){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null)){return this.elem[this.prop]}var E=parseFloat(o.css(this.elem,this.prop,F));return E&&E>-10000?E:parseFloat(o.curCSS(this.elem,this.prop))||0},custom:function(I,H,G){this.startTime=e();this.start=I;this.end=H;this.unit=G||this.unit||"px";this.now=this.start;this.pos=this.state=0;var E=this;function F(J){return E.step(J)}F.elem=this.elem;if(F()&&o.timers.push(F)&&!n){n=setInterval(function(){var K=o.timers;for(var J=0;J<K.length;J++){if(!K[J]()){K.splice(J--,1)}}if(!K.length){clearInterval(n);n=g}},13)}},show:function(){this.options.orig[this.prop]=o.attr(this.elem.style,this.prop);this.options.show=true;this.custom(this.prop=="width"||this.prop=="height"?1:0,this.cur());o(this.elem).show()},hide:function(){this.options.orig[this.prop]=o.attr(this.elem.style,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(H){var G=e();if(H||G>=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var E=true;for(var F in this.options.curAnim){if(this.options.curAnim[F]!==true){E=false}}if(E){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(o.css(this.elem,"display")=="none"){this.elem.style.display="block"}}if(this.options.hide){o(this.elem).hide()}if(this.options.hide||this.options.show){for(var I in this.options.curAnim){o.attr(this.elem.style,I,this.options.orig[I])}}this.options.complete.call(this.elem)}return false}else{var J=G-this.startTime;this.state=J/this.options.duration;this.pos=o.easing[this.options.easing||(o.easing.swing?"swing":"linear")](this.state,J,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update()}return true}};o.extend(o.fx,{speeds:{slow:600,fast:200,_default:400},step:{opacity:function(E){o.attr(E.elem.style,"opacity",E.now)},_default:function(E){if(E.elem.style&&E.elem.style[E.prop]!=null){E.elem.style[E.prop]=E.now+E.unit}else{E.elem[E.prop]=E.now}}}});if(document.documentElement.getBoundingClientRect){o.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return o.offset.bodyOffset(this[0])}var G=this[0].getBoundingClientRect(),J=this[0].ownerDocument,F=J.body,E=J.documentElement,L=E.clientTop||F.clientTop||0,K=E.clientLeft||F.clientLeft||0,I=G.top+(self.pageYOffset||o.boxModel&&E.scrollTop||F.scrollTop)-L,H=G.left+(self.pageXOffset||o.boxModel&&E.scrollLeft||F.scrollLeft)-K;return{top:I,left:H}}}else{o.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return o.offset.bodyOffset(this[0])}o.offset.initialized||o.offset.initialize();var J=this[0],G=J.offsetParent,F=J,O=J.ownerDocument,M,H=O.documentElement,K=O.body,L=O.defaultView,E=L.getComputedStyle(J,null),N=J.offsetTop,I=J.offsetLeft;while((J=J.parentNode)&&J!==K&&J!==H){M=L.getComputedStyle(J,null);N-=J.scrollTop,I-=J.scrollLeft;if(J===G){N+=J.offsetTop,I+=J.offsetLeft;if(o.offset.doesNotAddBorder&&!(o.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(J.tagName))){N+=parseInt(M.borderTopWidth,10)||0,I+=parseInt(M.borderLeftWidth,10)||0}F=G,G=J.offsetParent}if(o.offset.subtractsBorderForOverflowNotVisible&&M.overflow!=="visible"){N+=parseInt(M.borderTopWidth,10)||0,I+=parseInt(M.borderLeftWidth,10)||0}E=M}if(E.position==="relative"||E.position==="static"){N+=K.offsetTop,I+=K.offsetLeft}if(E.position==="fixed"){N+=Math.max(H.scrollTop,K.scrollTop),I+=Math.max(H.scrollLeft,K.scrollLeft)}return{top:N,left:I}}}o.offset={initialize:function(){if(this.initialized){return}var L=document.body,F=document.createElement("div"),H,G,N,I,M,E,J=L.style.marginTop,K='<div style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;"><div></div></div><table style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;" cellpadding="0" cellspacing="0"><tr><td></td></tr></table>';M={position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"};for(E in M){F.style[E]=M[E]}F.innerHTML=K;L.insertBefore(F,L.firstChild);H=F.firstChild,G=H.firstChild,I=H.nextSibling.firstChild.firstChild;this.doesNotAddBorder=(G.offsetTop!==5);this.doesAddBorderForTableAndCells=(I.offsetTop===5);H.style.overflow="hidden",H.style.position="relative";this.subtractsBorderForOverflowNotVisible=(G.offsetTop===-5);L.style.marginTop="1px";this.doesNotIncludeMarginInBodyOffset=(L.offsetTop===0);L.style.marginTop=J;L.removeChild(F);this.initialized=true},bodyOffset:function(E){o.offset.initialized||o.offset.initialize();var G=E.offsetTop,F=E.offsetLeft;if(o.offset.doesNotIncludeMarginInBodyOffset){G+=parseInt(o.curCSS(E,"marginTop",true),10)||0,F+=parseInt(o.curCSS(E,"marginLeft",true),10)||0}return{top:G,left:F}}};o.fn.extend({position:function(){var I=0,H=0,F;if(this[0]){var G=this.offsetParent(),J=this.offset(),E=/^body|html$/i.test(G[0].tagName)?{top:0,left:0}:G.offset();J.top-=j(this,"marginTop");J.left-=j(this,"marginLeft");E.top+=j(G,"borderTopWidth");E.left+=j(G,"borderLeftWidth");F={top:J.top-E.top,left:J.left-E.left}}return F},offsetParent:function(){var E=this[0].offsetParent||document.body;while(E&&(!/^body|html$/i.test(E.tagName)&&o.css(E,"position")=="static")){E=E.offsetParent}return o(E)}});o.each(["Left","Top"],function(F,E){var G="scroll"+E;o.fn[G]=function(H){if(!this[0]){return null}return H!==g?this.each(function(){this==l||this==document?l.scrollTo(!F?H:o(l).scrollLeft(),F?H:o(l).scrollTop()):this[G]=H}):this[0]==l||this[0]==document?self[F?"pageYOffset":"pageXOffset"]||o.boxModel&&document.documentElement[G]||document.body[G]:this[0][G]}});o.each(["Height","Width"],function(I,G){var E=I?"Left":"Top",H=I?"Right":"Bottom",F=G.toLowerCase();o.fn["inner"+G]=function(){return this[0]?o.css(this[0],F,false,"padding"):null};o.fn["outer"+G]=function(K){return this[0]?o.css(this[0],F,false,K?"margin":"border"):null};var J=G.toLowerCase();o.fn[J]=function(K){return this[0]==l?document.compatMode=="CSS1Compat"&&document.documentElement["client"+G]||document.body["client"+G]:this[0]==document?Math.max(document.documentElement["client"+G],document.body["scroll"+G],document.documentElement["scroll"+G],document.body["offset"+G],document.documentElement["offset"+G]):K===g?(this.length?o.css(this[0],J):null):this.css(J,typeof K==="string"?K:K+"px")}})})();
|
20 |
-
jQuery.noConflict();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/jquery/ui.core.js
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
* jQuery UI 1.7.1
|
3 |
-
*
|
4 |
-
* Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
|
5 |
-
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
6 |
-
* and GPL (GPL-LICENSE.txt) licenses.
|
7 |
-
*
|
8 |
-
* http://docs.jquery.com/UI
|
9 |
-
*/
|
10 |
-
jQuery.ui||(function(c){var i=c.fn.remove,d=c.browser.mozilla&&(parseFloat(c.browser.version)<1.9);c.ui={version:"1.7.1",plugin:{add:function(k,l,n){var m=c.ui[k].prototype;for(var j in n){m.plugins[j]=m.plugins[j]||[];m.plugins[j].push([l,n[j]])}},call:function(j,l,k){var n=j.plugins[l];if(!n||!j.element[0].parentNode){return}for(var m=0;m<n.length;m++){if(j.options[n[m][0]]){n[m][1].apply(j.element,k)}}}},contains:function(k,j){return document.compareDocumentPosition?k.compareDocumentPosition(j)&16:k!==j&&k.contains(j)},hasScroll:function(m,k){if(c(m).css("overflow")=="hidden"){return false}var j=(k&&k=="left")?"scrollLeft":"scrollTop",l=false;if(m[j]>0){return true}m[j]=1;l=(m[j]>0);m[j]=0;return l},isOverAxis:function(k,j,l){return(k>j)&&(k<(j+l))},isOver:function(o,k,n,m,j,l){return c.ui.isOverAxis(o,n,j)&&c.ui.isOverAxis(k,m,l)},keyCode:{BACKSPACE:8,CAPS_LOCK:20,COMMA:188,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38}};if(d){var f=c.attr,e=c.fn.removeAttr,h="http://www.w3.org/2005/07/aaa",a=/^aria-/,b=/^wairole:/;c.attr=function(k,j,l){var m=l!==undefined;return(j=="role"?(m?f.call(this,k,j,"wairole:"+l):(f.apply(this,arguments)||"").replace(b,"")):(a.test(j)?(m?k.setAttributeNS(h,j.replace(a,"aaa:"),l):f.call(this,k,j.replace(a,"aaa:"))):f.apply(this,arguments)))};c.fn.removeAttr=function(j){return(a.test(j)?this.each(function(){this.removeAttributeNS(h,j.replace(a,""))}):e.call(this,j))}}c.fn.extend({remove:function(){c("*",this).add(this).each(function(){c(this).triggerHandler("remove")});return i.apply(this,arguments)},enableSelection:function(){return this.attr("unselectable","off").css("MozUserSelect","").unbind("selectstart.ui")},disableSelection:function(){return this.attr("unselectable","on").css("MozUserSelect","none").bind("selectstart.ui",function(){return false})},scrollParent:function(){var j;if((c.browser.msie&&(/(static|relative)/).test(this.css("position")))||(/absolute/).test(this.css("position"))){j=this.parents().filter(function(){return(/(relative|absolute|fixed)/).test(c.curCSS(this,"position",1))&&(/(auto|scroll)/).test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0)}else{j=this.parents().filter(function(){return(/(auto|scroll)/).test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0)}return(/fixed/).test(this.css("position"))||!j.length?c(document):j}});c.extend(c.expr[":"],{data:function(l,k,j){return !!c.data(l,j[3])},focusable:function(k){var l=k.nodeName.toLowerCase(),j=c.attr(k,"tabindex");return(/input|select|textarea|button|object/.test(l)?!k.disabled:"a"==l||"area"==l?k.href||!isNaN(j):!isNaN(j))&&!c(k)["area"==l?"parents":"closest"](":hidden").length},tabbable:function(k){var j=c.attr(k,"tabindex");return(isNaN(j)||j>=0)&&c(k).is(":focusable")}});function g(m,n,o,l){function k(q){var p=c[m][n][q]||[];return(typeof p=="string"?p.split(/,?\s+/):p)}var j=k("getter");if(l.length==1&&typeof l[0]=="string"){j=j.concat(k("getterSetter"))}return(c.inArray(o,j)!=-1)}c.widget=function(k,j){var l=k.split(".")[0];k=k.split(".")[1];c.fn[k]=function(p){var n=(typeof p=="string"),o=Array.prototype.slice.call(arguments,1);if(n&&p.substring(0,1)=="_"){return this}if(n&&g(l,k,p,o)){var m=c.data(this[0],k);return(m?m[p].apply(m,o):undefined)}return this.each(function(){var q=c.data(this,k);(!q&&!n&&c.data(this,k,new c[l][k](this,p))._init());(q&&n&&c.isFunction(q[p])&&q[p].apply(q,o))})};c[l]=c[l]||{};c[l][k]=function(o,n){var m=this;this.namespace=l;this.widgetName=k;this.widgetEventPrefix=c[l][k].eventPrefix||k;this.widgetBaseClass=l+"-"+k;this.options=c.extend({},c.widget.defaults,c[l][k].defaults,c.metadata&&c.metadata.get(o)[k],n);this.element=c(o).bind("setData."+k,function(q,p,r){if(q.target==o){return m._setData(p,r)}}).bind("getData."+k,function(q,p){if(q.target==o){return m._getData(p)}}).bind("remove",function(){return m.destroy()})};c[l][k].prototype=c.extend({},c.widget.prototype,j);c[l][k].getterSetter="option"};c.widget.prototype={_init:function(){},destroy:function(){this.element.removeData(this.widgetName).removeClass(this.widgetBaseClass+"-disabled "+this.namespace+"-state-disabled").removeAttr("aria-disabled")},option:function(l,m){var k=l,j=this;if(typeof l=="string"){if(m===undefined){return this._getData(l)}k={};k[l]=m}c.each(k,function(n,o){j._setData(n,o)})},_getData:function(j){return this.options[j]},_setData:function(j,k){this.options[j]=k;if(j=="disabled"){this.element[k?"addClass":"removeClass"](this.widgetBaseClass+"-disabled "+this.namespace+"-state-disabled").attr("aria-disabled",k)}},enable:function(){this._setData("disabled",false)},disable:function(){this._setData("disabled",true)},_trigger:function(l,m,n){var p=this.options[l],j=(l==this.widgetEventPrefix?l:this.widgetEventPrefix+l);m=c.Event(m);m.type=j;if(m.originalEvent){for(var k=c.event.props.length,o;k;){o=c.event.props[--k];m[o]=m.originalEvent[o]}}this.element.trigger(m,n);return !(c.isFunction(p)&&p.call(this.element[0],m,n)===false||m.isDefaultPrevented())}};c.widget.defaults={disabled:false};c.ui.mouse={_mouseInit:function(){var j=this;this.element.bind("mousedown."+this.widgetName,function(k){return j._mouseDown(k)}).bind("click."+this.widgetName,function(k){if(j._preventClickEvent){j._preventClickEvent=false;k.stopImmediatePropagation();return false}});if(c.browser.msie){this._mouseUnselectable=this.element.attr("unselectable");this.element.attr("unselectable","on")}this.started=false},_mouseDestroy:function(){this.element.unbind("."+this.widgetName);(c.browser.msie&&this.element.attr("unselectable",this._mouseUnselectable))},_mouseDown:function(l){l.originalEvent=l.originalEvent||{};if(l.originalEvent.mouseHandled){return}(this._mouseStarted&&this._mouseUp(l));this._mouseDownEvent=l;var k=this,m=(l.which==1),j=(typeof this.options.cancel=="string"?c(l.target).parents().add(l.target).filter(this.options.cancel).length:false);if(!m||j||!this._mouseCapture(l)){return true}this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){k.mouseDelayMet=true},this.options.delay)}if(this._mouseDistanceMet(l)&&this._mouseDelayMet(l)){this._mouseStarted=(this._mouseStart(l)!==false);if(!this._mouseStarted){l.preventDefault();return true}}this._mouseMoveDelegate=function(n){return k._mouseMove(n)};this._mouseUpDelegate=function(n){return k._mouseUp(n)};c(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);(c.browser.safari||l.preventDefault());l.originalEvent.mouseHandled=true;return true},_mouseMove:function(j){if(c.browser.msie&&!j.button){return this._mouseUp(j)}if(this._mouseStarted){this._mouseDrag(j);return j.preventDefault()}if(this._mouseDistanceMet(j)&&this._mouseDelayMet(j)){this._mouseStarted=(this._mouseStart(this._mouseDownEvent,j)!==false);(this._mouseStarted?this._mouseDrag(j):this._mouseUp(j))}return !this._mouseStarted},_mouseUp:function(j){c(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;this._preventClickEvent=(j.target==this._mouseDownEvent.target);this._mouseStop(j)}return false},_mouseDistanceMet:function(j){return(Math.max(Math.abs(this._mouseDownEvent.pageX-j.pageX),Math.abs(this._mouseDownEvent.pageY-j.pageY))>=this.options.distance)},_mouseDelayMet:function(j){return this.mouseDelayMet},_mouseStart:function(j){},_mouseDrag:function(j){},_mouseStop:function(j){},_mouseCapture:function(j){return true}};c.ui.mouse.defaults={cancel:null,distance:1,delay:0}})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/jquery/ui.tabs.js
DELETED
@@ -1,13 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
* jQuery UI Tabs 1.7.1
|
3 |
-
*
|
4 |
-
* Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
|
5 |
-
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
6 |
-
* and GPL (GPL-LICENSE.txt) licenses.
|
7 |
-
*
|
8 |
-
* http://docs.jquery.com/UI/Tabs
|
9 |
-
*
|
10 |
-
* Depends:
|
11 |
-
* ui.core.js
|
12 |
-
*/
|
13 |
-
(function(a){a.widget("ui.tabs",{_init:function(){if(this.options.deselectable!==undefined){this.options.collapsible=this.options.deselectable}this._tabify(true)},_setData:function(b,c){if(b=="selected"){if(this.options.collapsible&&c==this.options.selected){return}this.select(c)}else{this.options[b]=c;if(b=="deselectable"){this.options.collapsible=c}this._tabify()}},_tabId:function(b){return b.title&&b.title.replace(/\s/g,"_").replace(/[^A-Za-z0-9\-_:\.]/g,"")||this.options.idPrefix+a.data(b)},_sanitizeSelector:function(b){return b.replace(/:/g,"\\:")},_cookie:function(){var b=this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+a.data(this.list[0]));return a.cookie.apply(null,[b].concat(a.makeArray(arguments)))},_ui:function(c,b){return{tab:c,panel:b,index:this.anchors.index(c)}},_cleanup:function(){this.lis.filter(".ui-state-processing").removeClass("ui-state-processing").find("span:data(label.tabs)").each(function(){var b=a(this);b.html(b.data("label.tabs")).removeData("label.tabs")})},_tabify:function(n){this.list=this.element.children("ul:first");this.lis=a("li:has(a[href])",this.list);this.anchors=this.lis.map(function(){return a("a",this)[0]});this.panels=a([]);var p=this,d=this.options;var c=/^#.+/;this.anchors.each(function(r,o){var q=a(o).attr("href");var s=q.split("#")[0],u;if(s&&(s===location.toString().split("#")[0]||(u=a("base")[0])&&s===u.href)){q=o.hash;o.href=q}if(c.test(q)){p.panels=p.panels.add(p._sanitizeSelector(q))}else{if(q!="#"){a.data(o,"href.tabs",q);a.data(o,"load.tabs",q.replace(/#.*$/,""));var w=p._tabId(o);o.href="#"+w;var v=a("#"+w);if(!v.length){v=a(d.panelTemplate).attr("id",w).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").insertAfter(p.panels[r-1]||p.list);v.data("destroy.tabs",true)}p.panels=p.panels.add(v)}else{d.disabled.push(r)}}});if(n){this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all");this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.lis.addClass("ui-state-default ui-corner-top");this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom");if(d.selected===undefined){if(location.hash){this.anchors.each(function(q,o){if(o.hash==location.hash){d.selected=q;return false}})}if(typeof d.selected!="number"&&d.cookie){d.selected=parseInt(p._cookie(),10)}if(typeof d.selected!="number"&&this.lis.filter(".ui-tabs-selected").length){d.selected=this.lis.index(this.lis.filter(".ui-tabs-selected"))}d.selected=d.selected||0}else{if(d.selected===null){d.selected=-1}}d.selected=((d.selected>=0&&this.anchors[d.selected])||d.selected<0)?d.selected:0;d.disabled=a.unique(d.disabled.concat(a.map(this.lis.filter(".ui-state-disabled"),function(q,o){return p.lis.index(q)}))).sort();if(a.inArray(d.selected,d.disabled)!=-1){d.disabled.splice(a.inArray(d.selected,d.disabled),1)}this.panels.addClass("ui-tabs-hide");this.lis.removeClass("ui-tabs-selected ui-state-active");if(d.selected>=0&&this.anchors.length){this.panels.eq(d.selected).removeClass("ui-tabs-hide");this.lis.eq(d.selected).addClass("ui-tabs-selected ui-state-active");p.element.queue("tabs",function(){p._trigger("show",null,p._ui(p.anchors[d.selected],p.panels[d.selected]))});this.load(d.selected)}a(window).bind("unload",function(){p.lis.add(p.anchors).unbind(".tabs");p.lis=p.anchors=p.panels=null})}else{d.selected=this.lis.index(this.lis.filter(".ui-tabs-selected"))}this.element[d.collapsible?"addClass":"removeClass"]("ui-tabs-collapsible");if(d.cookie){this._cookie(d.selected,d.cookie)}for(var g=0,m;(m=this.lis[g]);g++){a(m)[a.inArray(g,d.disabled)!=-1&&!a(m).hasClass("ui-tabs-selected")?"addClass":"removeClass"]("ui-state-disabled")}if(d.cache===false){this.anchors.removeData("cache.tabs")}this.lis.add(this.anchors).unbind(".tabs");if(d.event!="mouseover"){var f=function(o,i){if(i.is(":not(.ui-state-disabled)")){i.addClass("ui-state-"+o)}};var j=function(o,i){i.removeClass("ui-state-"+o)};this.lis.bind("mouseover.tabs",function(){f("hover",a(this))});this.lis.bind("mouseout.tabs",function(){j("hover",a(this))});this.anchors.bind("focus.tabs",function(){f("focus",a(this).closest("li"))});this.anchors.bind("blur.tabs",function(){j("focus",a(this).closest("li"))})}var b,h;if(d.fx){if(a.isArray(d.fx)){b=d.fx[0];h=d.fx[1]}else{b=h=d.fx}}function e(i,o){i.css({display:""});if(a.browser.msie&&o.opacity){i[0].style.removeAttribute("filter")}}var k=h?function(i,o){a(i).closest("li").removeClass("ui-state-default").addClass("ui-tabs-selected ui-state-active");o.hide().removeClass("ui-tabs-hide").animate(h,h.duration||"normal",function(){e(o,h);p._trigger("show",null,p._ui(i,o[0]))})}:function(i,o){a(i).closest("li").removeClass("ui-state-default").addClass("ui-tabs-selected ui-state-active");o.removeClass("ui-tabs-hide");p._trigger("show",null,p._ui(i,o[0]))};var l=b?function(o,i){i.animate(b,b.duration||"normal",function(){p.lis.removeClass("ui-tabs-selected ui-state-active").addClass("ui-state-default");i.addClass("ui-tabs-hide");e(i,b);p.element.dequeue("tabs")})}:function(o,i,q){p.lis.removeClass("ui-tabs-selected ui-state-active").addClass("ui-state-default");i.addClass("ui-tabs-hide");p.element.dequeue("tabs")};this.anchors.bind(d.event+".tabs",function(){var o=this,r=a(this).closest("li"),i=p.panels.filter(":not(.ui-tabs-hide)"),q=a(p._sanitizeSelector(this.hash));if((r.hasClass("ui-tabs-selected")&&!d.collapsible)||r.hasClass("ui-state-disabled")||r.hasClass("ui-state-processing")||p._trigger("select",null,p._ui(this,q[0]))===false){this.blur();return false}d.selected=p.anchors.index(this);p.abort();if(d.collapsible){if(r.hasClass("ui-tabs-selected")){d.selected=-1;if(d.cookie){p._cookie(d.selected,d.cookie)}p.element.queue("tabs",function(){l(o,i)}).dequeue("tabs");this.blur();return false}else{if(!i.length){if(d.cookie){p._cookie(d.selected,d.cookie)}p.element.queue("tabs",function(){k(o,q)});p.load(p.anchors.index(this));this.blur();return false}}}if(d.cookie){p._cookie(d.selected,d.cookie)}if(q.length){if(i.length){p.element.queue("tabs",function(){l(o,i)})}p.element.queue("tabs",function(){k(o,q)});p.load(p.anchors.index(this))}else{throw"jQuery UI Tabs: Mismatching fragment identifier."}if(a.browser.msie){this.blur()}});this.anchors.bind("click.tabs",function(){return false})},destroy:function(){var b=this.options;this.abort();this.element.unbind(".tabs").removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible").removeData("tabs");this.list.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.anchors.each(function(){var c=a.data(this,"href.tabs");if(c){this.href=c}var d=a(this).unbind(".tabs");a.each(["href","load","cache"],function(e,f){d.removeData(f+".tabs")})});this.lis.unbind(".tabs").add(this.panels).each(function(){if(a.data(this,"destroy.tabs")){a(this).remove()}else{a(this).removeClass(["ui-state-default","ui-corner-top","ui-tabs-selected","ui-state-active","ui-state-hover","ui-state-focus","ui-state-disabled","ui-tabs-panel","ui-widget-content","ui-corner-bottom","ui-tabs-hide"].join(" "))}});if(b.cookie){this._cookie(null,b.cookie)}},add:function(e,d,c){if(c===undefined){c=this.anchors.length}var b=this,g=this.options,i=a(g.tabTemplate.replace(/#\{href\}/g,e).replace(/#\{label\}/g,d)),h=!e.indexOf("#")?e.replace("#",""):this._tabId(a("a",i)[0]);i.addClass("ui-state-default ui-corner-top").data("destroy.tabs",true);var f=a("#"+h);if(!f.length){f=a(g.panelTemplate).attr("id",h).data("destroy.tabs",true)}f.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide");if(c>=this.lis.length){i.appendTo(this.list);f.appendTo(this.list[0].parentNode)}else{i.insertBefore(this.lis[c]);f.insertBefore(this.panels[c])}g.disabled=a.map(g.disabled,function(k,j){return k>=c?++k:k});this._tabify();if(this.anchors.length==1){i.addClass("ui-tabs-selected ui-state-active");f.removeClass("ui-tabs-hide");this.element.queue("tabs",function(){b._trigger("show",null,b._ui(b.anchors[0],b.panels[0]))});this.load(0)}this._trigger("add",null,this._ui(this.anchors[c],this.panels[c]))},remove:function(b){var d=this.options,e=this.lis.eq(b).remove(),c=this.panels.eq(b).remove();if(e.hasClass("ui-tabs-selected")&&this.anchors.length>1){this.select(b+(b+1<this.anchors.length?1:-1))}d.disabled=a.map(a.grep(d.disabled,function(g,f){return g!=b}),function(g,f){return g>=b?--g:g});this._tabify();this._trigger("remove",null,this._ui(e.find("a")[0],c[0]))},enable:function(b){var c=this.options;if(a.inArray(b,c.disabled)==-1){return}this.lis.eq(b).removeClass("ui-state-disabled");c.disabled=a.grep(c.disabled,function(e,d){return e!=b});this._trigger("enable",null,this._ui(this.anchors[b],this.panels[b]))},disable:function(c){var b=this,d=this.options;if(c!=d.selected){this.lis.eq(c).addClass("ui-state-disabled");d.disabled.push(c);d.disabled.sort();this._trigger("disable",null,this._ui(this.anchors[c],this.panels[c]))}},select:function(b){if(typeof b=="string"){b=this.anchors.index(this.anchors.filter("[href$="+b+"]"))}else{if(b===null){b=-1}}if(b==-1&&this.options.collapsible){b=this.options.selected}this.anchors.eq(b).trigger(this.options.event+".tabs")},load:function(e){var c=this,g=this.options,b=this.anchors.eq(e)[0],d=a.data(b,"load.tabs");this.abort();if(!d||this.element.queue("tabs").length!==0&&a.data(b,"cache.tabs")){this.element.dequeue("tabs");return}this.lis.eq(e).addClass("ui-state-processing");if(g.spinner){var f=a("span",b);f.data("label.tabs",f.html()).html(g.spinner)}this.xhr=a.ajax(a.extend({},g.ajaxOptions,{url:d,success:function(i,h){a(c._sanitizeSelector(b.hash)).html(i);c._cleanup();if(g.cache){a.data(b,"cache.tabs",true)}c._trigger("load",null,c._ui(c.anchors[e],c.panels[e]));try{g.ajaxOptions.success(i,h)}catch(j){}c.element.dequeue("tabs")}}))},abort:function(){this.element.queue([]);this.panels.stop(false,true);if(this.xhr){this.xhr.abort();delete this.xhr}this._cleanup()},url:function(c,b){this.anchors.eq(c).removeData("cache.tabs").data("load.tabs",b)},length:function(){return this.anchors.length}});a.extend(a.ui.tabs,{version:"1.7.1",getter:"length",defaults:{ajaxOptions:null,cache:false,cookie:null,collapsible:false,disabled:[],event:"click",fx:null,idPrefix:"ui-tabs-",panelTemplate:"<div></div>",spinner:"<em>Loading…</em>",tabTemplate:'<li><a href="#{href}"><span>#{label}</span></a></li>'}});a.extend(a.ui.tabs.prototype,{rotation:null,rotate:function(d,f){var b=this,g=this.options;var c=b._rotate||(b._rotate=function(h){clearTimeout(b.rotation);b.rotation=setTimeout(function(){var i=g.selected;b.select(++i<b.anchors.length?i:0)},d);if(h){h.stopPropagation()}});var e=b._unrotate||(b._unrotate=!f?function(h){if(h.clientX){b.rotate(null)}}:function(h){t=g.selected;c()});if(d){this.element.bind("tabsshow",c);this.anchors.bind(g.event+".tabs",e);c()}else{clearTimeout(b.rotation);this.element.unbind("tabsshow",c);this.anchors.unbind(g.event+".tabs",e);delete this._rotate;delete this._unrotate}}})})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: jfarthing84
|
3 |
Donate link: http://www.jfarthing.com/donate
|
4 |
Tags: widget, login, registration, theme, custom, log in, register, sidebar, gravatar, redirection, e-mail
|
5 |
-
Requires at least: 2.
|
6 |
-
Tested up to: 2.9
|
7 |
Stable tag: trunk
|
8 |
|
9 |
Themes the WordPress login pages according to your theme.
|
@@ -39,6 +39,13 @@ None yet. Please visit http://www.jfarthing.com/forum for any support!
|
|
39 |
|
40 |
== Changelog ==
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
= 4.3.4 =
|
43 |
* Added the option to force redirect upon login
|
44 |
|
2 |
Contributors: jfarthing84
|
3 |
Donate link: http://www.jfarthing.com/donate
|
4 |
Tags: widget, login, registration, theme, custom, log in, register, sidebar, gravatar, redirection, e-mail
|
5 |
+
Requires at least: 2.8
|
6 |
+
Tested up to: 2.9.1
|
7 |
Stable tag: trunk
|
8 |
|
9 |
Themes the WordPress login pages according to your theme.
|
39 |
|
40 |
== Changelog ==
|
41 |
|
42 |
+
= 4.4 =
|
43 |
+
* Added the option to require new registrations to confirm e-mail address
|
44 |
+
* Added the option to redirect users upon log out according to their role
|
45 |
+
* Allow 'theme-my-login.css' to be loaded from current theme directory
|
46 |
+
* Cleaned up and rewrote most code
|
47 |
+
* Drop support for WP versions below 2.8
|
48 |
+
|
49 |
= 4.3.4 =
|
50 |
* Added the option to force redirect upon login
|
51 |
|
theme-my-login.php
CHANGED
@@ -3,565 +3,815 @@
|
|
3 |
Plugin Name: Theme My Login
|
4 |
Plugin URI: http://www.jfarthing.com/wordpress-plugins/theme-my-login-plugin
|
5 |
Description: Themes the WordPress login, registration and forgot password pages according to your theme.
|
6 |
-
Version: 4.
|
7 |
Author: Jeff Farthing
|
8 |
Author URI: http://www.jfarthing.com
|
9 |
Text Domain: theme-my-login
|
10 |
*/
|
11 |
|
12 |
-
global $wp_version;
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
if (!class_exists('ThemeMyLogin')) {
|
17 |
class ThemeMyLogin {
|
18 |
|
19 |
-
var $
|
20 |
-
var $
|
21 |
-
var $permalink = '';
|
22 |
-
var $instances = 0;
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
33 |
|
34 |
-
|
35 |
-
add_action('registration_errors', array(&$this, 'RegistrationErrors'));
|
36 |
|
37 |
-
|
|
|
|
|
|
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
add_filter('wp_head', array(&$this, 'WPHead'));
|
42 |
-
add_filter('wp_title', array(&$this, 'WPTitle'));
|
43 |
-
add_filter('the_title', array(&$this, 'TheTitle'));
|
44 |
-
add_filter('wp_list_pages', array(&$this, 'WPListPages'));
|
45 |
-
add_filter('wp_list_pages_excludes', array(&$this, 'WPListPagesExcludes'));
|
46 |
-
add_filter('login_redirect', array(&$this, 'LoginRedirect'), 10, 3);
|
47 |
-
add_filter('site_url', array(&$this, 'SiteURL'), 10, 2);
|
48 |
-
add_filter('retrieve_password_title', array(&$this, 'RetrievePasswordTitle'), 10, 2);
|
49 |
-
add_filter('retrieve_password_message', array(&$this, 'RetrievePasswordMessage'), 10, 3);
|
50 |
-
add_filter('password_reset_title', array(&$this, 'PasswordResetTitle'), 10, 2);
|
51 |
-
add_filter('password_reset_message', array(&$this, 'PasswordResetMessage'), 10, 3);
|
52 |
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
55 |
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
-
|
|
|
60 |
|
61 |
-
|
|
|
|
|
|
|
|
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
$this->options['page_id'] = ( $login_page ) ? $login_page->ID : 0;
|
66 |
-
$this->SaveOptions();
|
67 |
-
}
|
68 |
}
|
69 |
|
70 |
-
function
|
71 |
-
|
72 |
-
|
73 |
-
$this->
|
|
|
74 |
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
85 |
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
}
|
91 |
|
92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
global $user_ID, $wp_version, $pagenow;
|
94 |
-
|
95 |
if ( 'options-general.php' == $pagenow ) {
|
96 |
-
|
97 |
$page = isset($_GET['page']) ? $_GET['page'] : '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
|
99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
|
101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
wp_deregister_script('jquery');
|
109 |
-
wp_deregister_script('jquery-ui-core');
|
110 |
-
wp_deregister_script('jquery-ui-tabs');
|
111 |
-
wp_enqueue_script('jquery', plugins_url('/theme-my-login/js/jquery/jquery.js'), false, '1.7.2');
|
112 |
-
wp_enqueue_script('jquery-ui-core', plugins_url('/theme-my-login/js/jquery/ui.core.js'), array('jquery'), '1.7.2');
|
113 |
-
wp_enqueue_script('jquery-ui-tabs', plugins_url('/theme-my-login/js/jquery/ui.tabs.js'), array('jquery', 'jquery-ui-core'), '1.7.2');
|
114 |
-
}
|
115 |
-
|
116 |
-
wp_enqueue_style('theme-my-login-admin', plugins_url('/theme-my-login/css/theme-my-login-admin.css'));
|
117 |
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
}
|
125 |
-
} elseif ( version_compare($wp_version, '2.6', '>=') ) {
|
126 |
-
wp_enqueue_style('jquery-colors-classic', plugins_url('/theme-my-login/css/wp-colors-classic/wp-colors-classic.css'));
|
127 |
}
|
|
|
|
|
128 |
break;
|
129 |
-
|
130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
|
137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
|
139 |
-
|
140 |
-
|
141 |
-
|
|
|
|
|
|
|
|
|
|
|
142 |
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
switch ( $_GET['action'] ) {
|
147 |
-
case 'approve' :
|
148 |
-
$user = new WP_User($user);
|
149 |
-
$user->set_role('subscriber');
|
150 |
-
|
151 |
-
$subject = $this->options['user_approval_email']['subject'];
|
152 |
-
$message = $this->options['user_approval_email']['message'];
|
153 |
-
|
154 |
-
if ( !$this->options['custom_pass'] ) {
|
155 |
-
$plaintext_pass = wp_generate_password();
|
156 |
-
wp_set_password($plaintext_pass, $user->ID);
|
157 |
-
}
|
158 |
-
|
159 |
-
$replace_this = array('/%blogname%/', '/%siteurl%/', '/%user_login%/', '/%user_email%/', '/%user_pass%/');
|
160 |
-
$replace_with = array(get_option('blogname'), get_option('siteurl'), $user->user_login, $user->user_email, $plaintext_pass);
|
161 |
|
162 |
-
|
163 |
-
$subject = preg_replace($replace_this, $replace_with, $subject);
|
164 |
-
else
|
165 |
-
$subject = sprintf(__('[%s] Registration Approved'), get_option('blogname'));
|
166 |
-
if ( !empty($message) )
|
167 |
-
$message = preg_replace($replace_this, $replace_with, $message);
|
168 |
-
else {
|
169 |
-
$message = sprintf(__('You have been approved to access %s '."\r\n\r\n"), get_option('blogname'));
|
170 |
-
$message .= sprintf(__('Username: %s'), $user->user_login) . "\r\n";
|
171 |
-
if ( !$this->options['custom_pass'] )
|
172 |
-
$message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n";
|
173 |
-
$message .= "\r\n";
|
174 |
-
$message .= site_url('wp-login.php', 'login') . "\r\n";
|
175 |
-
}
|
176 |
-
tml_apply_mail_filters();
|
177 |
-
@wp_mail($user->user_email, $subject, $message);
|
178 |
-
tml_remove_mail_filters();
|
179 |
-
|
180 |
-
add_action('admin_notices', array(&$this, 'ApprovalNotice'));
|
181 |
-
break;
|
182 |
-
|
183 |
-
case 'deny' :
|
184 |
-
$user = new WP_User($user);
|
185 |
-
$user->set_role('denied');
|
186 |
-
|
187 |
-
$subject = $this->options['user_denial_email']['subject'];
|
188 |
-
$message = $this->options['user_denial_email']['message'];
|
189 |
-
$replace_this = array('/%blogname%/', '/%siteurl%/', '/%user_login%/', '/%user_email%/');
|
190 |
-
$replace_with = array(get_option('blogname'), get_option('siteurl'), $user->user_login, $user->user_email);
|
191 |
-
|
192 |
-
if ( !empty($subject) )
|
193 |
-
$subject = preg_replace($replace_this, $replace_with, $subject);
|
194 |
-
else
|
195 |
-
$subject = sprintf(__('[%s] Registration Denied'), get_option('blogname'));
|
196 |
-
if ( !empty($message) )
|
197 |
-
$message = preg_replace($replace_this, $replace_with, $message);
|
198 |
-
else
|
199 |
-
$message = sprintf(__('You have been denied access to %s'), get_option('blogname'));
|
200 |
|
201 |
-
|
202 |
-
@wp_mail($user->user_email, $subject, $message);
|
203 |
-
tml_remove_mail_filters();
|
204 |
-
|
205 |
-
add_action('admin_notices', array(&$this, 'DenialNotice'));
|
206 |
-
break;
|
207 |
|
208 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
}
|
210 |
}
|
211 |
}
|
212 |
|
213 |
-
function
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
function ApprovalNotice() {
|
218 |
-
echo '<div id="message" class="updated fade"><p>' . __('User approved.') . '</p></div>';
|
219 |
-
}
|
220 |
-
|
221 |
-
function DenialNotice() {
|
222 |
-
echo '<div id="message" class="updated fade"><p>' . __('User denied.') . '</p></div>';
|
223 |
-
}
|
224 |
-
|
225 |
-
function AdminMenu() {
|
226 |
-
add_options_page(__('Theme My Login', 'theme-my-login'), __('Theme My Login', 'theme-my-login'), 8, 'theme-my-login/admin/admin.php');
|
227 |
-
}
|
228 |
-
|
229 |
-
function UserRowActions($actions, $user_object) {
|
230 |
-
global $current_user;
|
231 |
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
}
|
243 |
-
$actions = array_merge($approve, $actions);
|
244 |
}
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
|
|
|
|
|
|
|
|
255 |
}
|
256 |
}
|
|
|
|
|
|
|
|
|
257 |
}
|
258 |
|
259 |
-
function
|
260 |
-
|
261 |
-
?>
|
262 |
-
<p><label for="pass1-<?php echo $instance; ?>"><?php _e('Password:');?></label>
|
263 |
-
<input autocomplete="off" name="pass1" id="pass1-<?php echo $instance; ?>" class="input" size="20" value="" type="password" /><br />
|
264 |
-
<label for="pass2-<?php echo $instance; ?>"><?php _e('Confirm Password:');?></label>
|
265 |
-
<input autocomplete="off" name="pass2" id="pass2-<?php echo $instance; ?>" class="input" size="20" value="" type="password" /></p>
|
266 |
-
<?php
|
267 |
-
}
|
268 |
-
}
|
269 |
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
$_POST['user_pw'] = $_POST['pass1'];
|
280 |
-
}
|
281 |
}
|
282 |
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
} else {
|
296 |
-
return new WP_Error('pending', '<strong>ERROR</strong>: Your registration has not yet been approved.');
|
297 |
}
|
|
|
|
|
|
|
|
|
298 |
}
|
299 |
}
|
300 |
-
return $user;
|
301 |
-
}
|
302 |
-
|
303 |
-
function AllowPasswordReset($allow, $user_id) {
|
304 |
-
$user = new WP_User($user_id);
|
305 |
-
$user_role = reset($user->roles);
|
306 |
-
if ( in_array($user_role, array('pending', 'denied')) )
|
307 |
-
$allow = false;
|
308 |
-
|
309 |
-
return $allow;
|
310 |
}
|
311 |
|
312 |
-
function
|
313 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
314 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
315 |
|
316 |
-
|
317 |
-
global $WPLogin;
|
318 |
-
|
319 |
-
if ( is_page($this->options['page_id']) ) {
|
320 |
|
321 |
-
|
322 |
-
|
323 |
-
$action = $WPLogin->action;
|
324 |
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
343 |
}
|
344 |
|
345 |
-
function
|
346 |
-
|
|
|
347 |
|
348 |
-
|
349 |
-
|
|
|
|
|
|
|
|
|
350 |
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
361 |
case 'register':
|
362 |
-
|
363 |
break;
|
364 |
case 'lostpassword':
|
365 |
case 'retrievepassword':
|
366 |
case 'resetpass':
|
367 |
case 'rp':
|
368 |
-
|
369 |
break;
|
370 |
case 'login':
|
371 |
default:
|
372 |
-
|
373 |
}
|
374 |
-
} return $title;
|
375 |
-
}
|
376 |
-
|
377 |
-
function WPListPages($pages) {
|
378 |
-
global $wp_version, $WPLogin;
|
379 |
-
|
380 |
-
if ( $this->options['show_page'] && is_user_logged_in() ) {
|
381 |
-
$redirect = $WPLogin->GuessURL();
|
382 |
-
$logout_url = ( version_compare($wp_version, '2.7', '>=') ) ? wp_logout_url($redirect) : site_url('wp-login.php?action=logout&redirect_to='.$redirect, 'login');
|
383 |
-
$pages = str_replace($this->permalink, $logout_url, $pages);
|
384 |
}
|
385 |
-
return $
|
|
|
|
|
|
|
|
|
|
|
|
|
386 |
}
|
387 |
|
388 |
-
function
|
389 |
-
if (
|
390 |
-
$
|
391 |
-
|
|
|
|
|
|
|
392 |
}
|
393 |
|
394 |
-
function
|
395 |
-
global $
|
396 |
-
|
397 |
$schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
|
398 |
$self = $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
399 |
-
|
400 |
-
if (
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
$
|
405 |
-
|
406 |
-
|
407 |
-
if ( is_object($user) && !is_wp_error($user) ) {
|
408 |
-
$user_role = reset($user->roles);
|
409 |
-
$redirects = $this->options['redirects'];
|
410 |
-
if ( '' != $redirects[$user_role]['login_url'] ) {
|
411 |
-
if ( $this->options['override_redirect'] )
|
412 |
-
return $redirects[$user_role]['login_url'];
|
413 |
}
|
414 |
}
|
415 |
-
|
416 |
-
return $redirect_to;
|
417 |
}
|
418 |
|
419 |
-
function
|
420 |
-
global $wp_rewrite;
|
421 |
-
|
422 |
$schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
|
423 |
$self = $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
424 |
|
425 |
-
|
426 |
-
|
427 |
-
$parsed_url = parse_url($url);
|
428 |
-
if ( isset($parsed_url['query']) )
|
429 |
-
$url = $wp_rewrite->using_permalinks() ? $this->permalink.'?'.$parsed_url['query'] : $this->permalink.'&'.$parsed_url['query'];
|
430 |
-
else
|
431 |
-
$url = $this->permalink;
|
432 |
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
}
|
|
|
437 |
return $url;
|
438 |
}
|
439 |
|
440 |
-
function
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
445 |
}
|
446 |
-
return $
|
447 |
}
|
448 |
|
449 |
-
function
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
454 |
}
|
455 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
456 |
}
|
457 |
|
458 |
-
function
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
|
|
|
|
|
|
|
|
463 |
}
|
464 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
465 |
}
|
466 |
|
467 |
-
function
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
}
|
475 |
|
476 |
-
function
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
482 |
|
483 |
-
|
|
|
|
|
484 |
}
|
485 |
|
486 |
-
|
487 |
-
|
488 |
-
$
|
489 |
-
$
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
}
|
495 |
|
496 |
-
function
|
497 |
-
|
498 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
499 |
}
|
500 |
|
501 |
-
function
|
502 |
-
$
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
'
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
$insert['ID'] = $page_id;
|
518 |
-
$insert['post_content'] = str_replace('[theme-my-login]', '[theme-my-login-page]', $theme_my_login->post_content);
|
519 |
-
wp_update_post($insert);
|
520 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
521 |
|
522 |
-
$
|
523 |
-
$
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
528 |
}
|
529 |
|
530 |
-
function
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
538 |
}
|
539 |
|
540 |
-
function
|
541 |
|
542 |
// General
|
543 |
-
$this->options['page_id'] = 0;
|
544 |
-
$this->options['uninstall'] = 0;
|
545 |
-
$this->options['show_page'] = 0;
|
546 |
$this->options['custom_pass'] = 0;
|
|
|
547 |
$this->options['email_from'] = '';
|
548 |
$this->options['email_from_name'] = '';
|
549 |
$this->options['email_content_type'] = 'text/plain';
|
550 |
$this->options['use_css'] = 1;
|
551 |
$this->options['override_redirect'] = 1;
|
552 |
|
553 |
-
// Titles
|
554 |
-
$this->options['welcome_title'] = __('Welcome') . ', %display_name%';
|
555 |
-
$this->options['login_title'] = __('Log In');
|
556 |
-
$this->options['register_title'] = __('Register');
|
557 |
-
$this->options['lost_pass_title'] = __('Lost Password');
|
558 |
-
$this->options['logout_title'] = __('Log Out');
|
559 |
-
|
560 |
-
// Messages
|
561 |
-
$this->options['register_message'] = __('A password will be e-mailed to you.');
|
562 |
-
$this->options['success_message'] = __('Registration complete. Please check your e-mail.');
|
563 |
-
$this->options['lost_pass_message'] = __('Please enter your username or e-mail address. You will receive a new password via e-mail.');
|
564 |
-
|
565 |
// Widget
|
566 |
$this->options['default_action'] = 'login';
|
567 |
$this->options['show_title'] = 1;
|
@@ -581,7 +831,8 @@ if (!class_exists('ThemeMyLogin')) {
|
|
581 |
// E-mails
|
582 |
$this->options['retrieve_pass_email'] = array('subject' => '', 'message' => '');
|
583 |
$this->options['reset_pass_email'] = array('subject' => '', 'message' => '', 'admin_disable' => 0);
|
584 |
-
$this->options['registration_email'] = array('subject' => '', 'message' => '', 'admin_disable' => 0
|
|
|
585 |
$this->options['user_approval_email'] = array('subject' => '', 'message' => '');
|
586 |
$this->options['user_denial_email'] = array('subject' => '', 'message' => '');
|
587 |
|
@@ -591,177 +842,149 @@ if (!class_exists('ThemeMyLogin')) {
|
|
591 |
$wp_roles = new WP_Roles();
|
592 |
$user_roles = $wp_roles->get_names();
|
593 |
foreach ( $user_roles as $role => $title ) {
|
|
|
|
|
594 |
$this->options['links'][$role][] = array('title' => 'Dashboard', 'url' => admin_url());
|
595 |
$this->options['links'][$role][] = array('title' => 'Profile', 'url' => admin_url('profile.php'));
|
596 |
$this->options['redirects'][$role] = array('login_url' => '', 'logout_url' => '');
|
597 |
}
|
598 |
|
599 |
if ( $save )
|
600 |
-
|
601 |
-
|
602 |
}
|
603 |
|
604 |
-
function
|
605 |
|
606 |
-
$this->
|
607 |
|
608 |
$storedoptions = get_option('theme_my_login');
|
609 |
-
if ( $storedoptions && is_array(
|
610 |
foreach ( $storedoptions as $key => $value ) {
|
611 |
$this->options[$key] = $value;
|
612 |
}
|
613 |
} else update_option('theme_my_login', $this->options);
|
614 |
}
|
615 |
|
616 |
-
function
|
617 |
if ( array_key_exists($key, $this->options) ) {
|
618 |
return $this->options[$key];
|
619 |
} else return null;
|
620 |
}
|
621 |
|
622 |
-
function
|
623 |
$this->options[$key] = $value;
|
624 |
}
|
625 |
|
626 |
-
function
|
627 |
$oldvalue = get_option('theme_my_login');
|
628 |
-
if( $oldvalue == $this->options ) {
|
629 |
return true;
|
630 |
} else return update_option('theme_my_login', $this->options);
|
631 |
}
|
632 |
-
}
|
633 |
-
}
|
634 |
-
|
635 |
-
if (class_exists('ThemeMyLogin')) {
|
636 |
-
global $wp_version;
|
637 |
-
|
638 |
-
$ThemeMyLogin = new ThemeMyLogin();
|
639 |
-
|
640 |
-
if ( version_compare($wp_version, '2.8', '>=') ) {
|
641 |
-
require_once (WP_PLUGIN_DIR . '/theme-my-login/classes/class.widget-new.php');
|
642 |
-
} else {
|
643 |
-
require_once (WP_PLUGIN_DIR . '/theme-my-login/classes/class.widget-old.php');
|
644 |
-
}
|
645 |
-
|
646 |
-
if ( !function_exists('theme_my_login') ) :
|
647 |
-
function theme_my_login($args = '') {
|
648 |
-
global $ThemeMyLogin;
|
649 |
|
650 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
651 |
}
|
652 |
-
endif;
|
653 |
-
|
654 |
-
if ( !function_exists('wp_new_user_notification') ) :
|
655 |
-
function wp_new_user_notification($user_id, $plaintext_pass = '') {
|
656 |
-
global $ThemeMyLogin, $wp_version;
|
657 |
-
|
658 |
-
$user = new WP_User($user_id);
|
659 |
|
660 |
-
|
661 |
-
$
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
$
|
668 |
-
$
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
|
679 |
-
|
680 |
-
|
|
|
681 |
|
682 |
-
|
683 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
684 |
|
685 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
686 |
$subject = $ThemeMyLogin->options['registration_email']['subject'];
|
687 |
$message = $ThemeMyLogin->options['registration_email']['message'];
|
688 |
-
$replace_this = array('/%blogname%/', '/%siteurl%/', '/%user_login%/', '/%user_email%/', '/%user_pass%/', '/%user_ip%/');
|
689 |
-
$replace_with = array(get_option('blogname'), get_option('siteurl'), $user->user_login, $user->user_email, $plaintext_pass, $_SERVER['REMOTE_ADDR']);
|
690 |
|
691 |
if ( !empty($subject) )
|
692 |
$subject = preg_replace($replace_this, $replace_with, $subject);
|
693 |
else
|
694 |
-
$subject = sprintf(__('[%s] Your username and password'
|
695 |
if ( !empty($message) )
|
696 |
$message = preg_replace($replace_this, $replace_with, $message);
|
697 |
else {
|
698 |
-
$message = sprintf(__('Username: %s'), $user_login) . "\r\n";
|
699 |
-
$message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n";
|
700 |
-
$message .=
|
701 |
}
|
702 |
-
|
703 |
-
wp_mail($user_email, $subject, $message);
|
704 |
-
tml_remove_mail_filters();
|
705 |
}
|
706 |
}
|
|
|
707 |
}
|
708 |
-
endif;
|
709 |
-
|
710 |
-
if ( !function_exists('wp_generate_password') ) :
|
711 |
-
function wp_generate_password($length = 12, $special_chars = true) {
|
712 |
-
global $ThemeMyLogin;
|
713 |
-
|
714 |
-
if ( $ThemeMyLogin->options['custom_pass'] && isset($_POST['user_pw']) && '' != $_POST['user_pw'] )
|
715 |
-
return stripslashes($_POST['user_pw']);
|
716 |
-
|
717 |
-
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
718 |
-
if ( $special_chars )
|
719 |
-
$chars .= '!@#$%^&*()';
|
720 |
-
|
721 |
-
$password = '';
|
722 |
-
for ( $i = 0; $i < $length; $i++ )
|
723 |
-
$password .= substr($chars, wp_rand(0, strlen($chars) - 1), 1);
|
724 |
-
return $password;
|
725 |
-
}
|
726 |
-
endif;
|
727 |
-
|
728 |
-
if ( !function_exists('tml_wp_mail_from') ) :
|
729 |
-
function tml_wp_mail_from($from) {
|
730 |
-
global $ThemeMyLogin;
|
731 |
-
return empty($ThemeMyLogin->options['email_from']) ? $from : $ThemeMyLogin->options['email_from'];
|
732 |
-
}
|
733 |
-
endif;
|
734 |
-
|
735 |
-
if ( !function_exists('tml_wp_mail_from_name') ) :
|
736 |
-
function tml_wp_mail_from_name($from_name) {
|
737 |
-
global $ThemeMyLogin;
|
738 |
-
return empty($ThemeMyLogin->options['email_from_name']) ? $from_name : $ThemeMyLogin->options['email_from_name'];
|
739 |
-
}
|
740 |
-
endif;
|
741 |
-
|
742 |
-
if ( !function_exists('tml_wp_mail_content_type') ) :
|
743 |
-
function tml_wp_mail_content_type() {
|
744 |
-
global $ThemeMyLogin;
|
745 |
-
return $ThemeMyLogin->options['email_content_type'];
|
746 |
-
}
|
747 |
-
endif;
|
748 |
-
|
749 |
-
if ( !function_exists('tml_apply_mail_filters') ) :
|
750 |
-
function tml_apply_mail_filters() {
|
751 |
-
$filters = array('wp_mail_from', 'wp_mail_from_name', 'wp_mail_content_type');
|
752 |
-
foreach ( $filters as $filter )
|
753 |
-
add_filter($filter, 'tml_'.$filter);
|
754 |
-
}
|
755 |
-
endif;
|
756 |
-
|
757 |
-
if ( !function_exists('tml_remove_mail_filters') ) :
|
758 |
-
function tml_remove_mail_filters() {
|
759 |
-
$filters = array('wp_mail_from', 'wp_mail_from_name', 'wp_mail_content_type');
|
760 |
-
foreach ( $filters as $filter )
|
761 |
-
remove_filter($filter, 'tml_'.$filter);
|
762 |
-
}
|
763 |
-
endif;
|
764 |
-
|
765 |
}
|
766 |
|
767 |
?>
|
3 |
Plugin Name: Theme My Login
|
4 |
Plugin URI: http://www.jfarthing.com/wordpress-plugins/theme-my-login-plugin
|
5 |
Description: Themes the WordPress login, registration and forgot password pages according to your theme.
|
6 |
+
Version: 4.4
|
7 |
Author: Jeff Farthing
|
8 |
Author URI: http://www.jfarthing.com
|
9 |
Text Domain: theme-my-login
|
10 |
*/
|
11 |
|
|
|
12 |
|
13 |
+
if ( !class_exists('ThemeMyLogin') ) {
|
|
|
|
|
14 |
class ThemeMyLogin {
|
15 |
|
16 |
+
var $options;
|
17 |
+
var $instance_options;
|
|
|
|
|
18 |
|
19 |
+
var $request_instance;
|
20 |
+
var $current_instance;
|
21 |
+
|
22 |
+
var $action;
|
23 |
+
var $errors;
|
24 |
+
var $redirect_to;
|
25 |
|
26 |
+
function ThemeMyLogin() {
|
27 |
+
$this->__construct();
|
28 |
+
}
|
29 |
+
|
30 |
+
function __construct() {
|
31 |
|
32 |
+
$this->loadOptions();
|
|
|
33 |
|
34 |
+
load_plugin_textdomain('theme-my-login', '', plugin_basename(dirname(__FILE__) . '/language'));
|
35 |
+
|
36 |
+
register_activation_hook(__FILE__, array( &$this, 'install' ));
|
37 |
+
register_uninstall_hook(__FILE__, array(&$this, 'uninstall'));
|
38 |
|
39 |
+
add_action('init', array(&$this, 'init'));
|
40 |
+
add_action('template_redirect', array(&$this, 'templateRedirect'), 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
+
if ( $this->options['custom_pass'] ) {
|
43 |
+
add_action('register_form', array(&$this, 'customPassForm'));
|
44 |
+
add_action('registration_errors', array(&$this, 'customPassErrors'));
|
45 |
+
add_action('user_register', array(&$this, 'setUserPassword'));
|
46 |
+
}
|
47 |
|
48 |
+
if ( in_array($this->options['moderation'], array('email', 'admin')) ) {
|
49 |
+
add_action('user_register', array(&$this, 'userModeration'), 100);
|
50 |
+
add_action('login_form_activate', array(&$this, 'userActivation'));
|
51 |
+
add_action('authenticate', array(&$this, 'authenticate'), 100, 3);
|
52 |
+
add_action('delete_user', array(&$this, 'denyUser'));
|
53 |
+
add_filter('allow_password_reset', array(&$this, 'allowPasswordReset'), 10, 2);
|
54 |
+
add_filter('user_row_actions', array(&$this, 'userRowActions'), 10, 2);
|
55 |
+
}
|
56 |
|
57 |
+
add_action('admin_init', array(&$this, 'adminInit'));
|
58 |
+
add_action('admin_menu', array(&$this, 'adminMenu'));
|
59 |
|
60 |
+
add_filter('the_posts', array(&$this, 'createPage'));
|
61 |
+
add_filter('page_rewrite_rules', array(&$this, 'pageRewriteRules'));
|
62 |
+
add_filter('site_url', array(&$this, 'siteURL'), 10, 3);
|
63 |
+
add_filter('login_redirect', array(&$this, 'loginRedirect'), 10, 3);
|
64 |
+
add_filter('logout_redirect', array(&$this, 'logoutRedirect'), 10, 3);
|
65 |
|
66 |
+
add_shortcode('theme-my-login', array(&$this, 'shortcode'));
|
67 |
+
|
|
|
|
|
|
|
68 |
}
|
69 |
|
70 |
+
function init() {
|
71 |
+
// This happens before $wp and $wp_query are populated, but after all plugins, pluggable functions and widgets are loaded.
|
72 |
+
$this->request_instance = ( isset($_REQUEST['instance']) ) ? $_REQUEST['instance'] : 'tml-page';
|
73 |
+
$this->action = ( isset($_REQUEST['action']) ) ? $_REQUEST['action'] : '';
|
74 |
+
$this->errors = new WP_Error();
|
75 |
|
76 |
+
// validate action so as to default to the login screen
|
77 |
+
if ( !in_array($this->action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login'), true) && false === has_filter('login_form_' . $this->action) )
|
78 |
+
$this->action = 'login';
|
79 |
+
}
|
80 |
+
|
81 |
+
// Create a dummy page to handle our actions
|
82 |
+
function createPage($posts) {
|
83 |
+
|
84 |
+
if ( defined('IS_TML') && IS_TML )
|
85 |
+
return $posts;
|
86 |
+
|
87 |
+
$pagename = get_query_var('pagename');
|
88 |
|
89 |
+
$action = ( isset($_REQUEST['action']) && 'tml-page' == $this->request_instance ) ? $_REQUEST['action'] : 'login';
|
90 |
+
|
91 |
+
if ( 'login' == $pagename ) {
|
92 |
+
$posts[] = (object) array(
|
93 |
+
'post_content' => '[theme-my-login show_title="0" before_widget="" after_widget="" instance="tml-page"]',
|
94 |
+
'post_title' => $this->getTitle($action),
|
95 |
+
'post_excerpt' => '',
|
96 |
+
'post_status' => 'publish',
|
97 |
+
'comment_status' => 'closed',
|
98 |
+
'ping_status' => 'closed',
|
99 |
+
'post_name' => 'login',
|
100 |
+
'post_type' => 'page'
|
101 |
+
);
|
102 |
+
}
|
103 |
+
return $posts;
|
104 |
}
|
105 |
|
106 |
+
// Make our dummy page work with permalinks
|
107 |
+
function pageRewriteRules($rules) {
|
108 |
+
global $wp_rewrite;
|
109 |
+
$wp_rewrite->add_rewrite_tag('%pagename%', '(login)', 'pagename=');
|
110 |
+
$rules = array_merge($rules, $wp_rewrite->generate_rewrite_rules($wp_rewrite->get_page_permastruct(), EP_PAGES));
|
111 |
+
return $rules;
|
112 |
+
}
|
113 |
+
|
114 |
+
function adminInit() {
|
115 |
global $user_ID, $wp_version, $pagenow;
|
116 |
+
|
117 |
if ( 'options-general.php' == $pagenow ) {
|
|
|
118 |
$page = isset($_GET['page']) ? $_GET['page'] : '';
|
119 |
+
if ( 'theme-my-login/admin/admin.php'== $page ) {
|
120 |
+
wp_enqueue_script('theme-my-login-admin', plugins_url('/theme-my-login/js/theme-my-login-admin.js'));
|
121 |
+
wp_enqueue_script('jquery-ui-tabs');
|
122 |
+
wp_enqueue_style('theme-my-login-admin', plugins_url('/theme-my-login/css/theme-my-login-admin.css'));
|
123 |
+
|
124 |
+
$admin_color = get_usermeta($user_ID, 'admin_color');
|
125 |
+
if ( 'classic' == $admin_color )
|
126 |
+
wp_enqueue_style('jquery-colors-classic', plugins_url('/theme-my-login/css/wp-colors-classic/wp-colors-classic.css'));
|
127 |
+
else
|
128 |
+
wp_enqueue_style('jquery-colors-fresh', plugins_url('/theme-my-login/css/wp-colors-fresh/wp-colors-fresh.css'));
|
129 |
+
}
|
130 |
+
} elseif ( 'users.php' == $pagenow && 'admin' == $this->options['moderation'] ) {
|
131 |
+
if ( isset($_GET['action']) && 'approve' == $_GET['action'] ) {
|
132 |
+
check_admin_referer('approve-user');
|
133 |
+
|
134 |
+
$user = isset($_GET['user']) ? $_GET['user'] : '';
|
135 |
+
if ( !$user )
|
136 |
+
wp_die(__('You can’t edit that user.', 'theme-my-login'));
|
137 |
+
|
138 |
+
if ( !current_user_can('edit_user', $user) )
|
139 |
+
wp_die(__('You can’t edit that user.', 'theme-my-login'));
|
140 |
|
141 |
+
require_once(WP_PLUGIN_DIR . '/theme-my-login/includes/functions.php');
|
142 |
+
if ( !approve_new_user($user) )
|
143 |
+
wp_die(__('You can’t edit that user.', 'theme-my-login'));
|
144 |
+
|
145 |
+
add_action('admin_notices', create_function('', "echo '<div id=\"message\" class=\"updated fade\"><p>' . __('User approved.', 'theme-my-login') . '</p></div>';"));
|
146 |
+
}
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
function userRowActions($actions, $user_object) {
|
151 |
+
$current_user = wp_get_current_user();
|
152 |
+
$user_role = reset($user_object->roles);
|
153 |
+
if ( $current_user->ID != $user_object->ID ) {
|
154 |
+
if ( 'pending' == $user_role ) {
|
155 |
+
$approve['approve-user'] = '<a href="' . add_query_arg( 'wp_http_referer', urlencode( esc_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), wp_nonce_url("users.php?action=approve&user=$user_object->ID", 'approve-user') ) . '">Approve</a>';
|
156 |
+
$actions = array_merge($approve, $actions);
|
157 |
+
}
|
158 |
+
}
|
159 |
+
return $actions;
|
160 |
+
}
|
161 |
+
|
162 |
+
function adminMenu() {
|
163 |
+
add_options_page(__('Theme My Login', 'theme-my-login'), __('Theme My Login', 'theme-my-login'), 8, 'theme-my-login/admin/admin.php');
|
164 |
+
}
|
165 |
+
|
166 |
+
// If our virtual page is reached, redirect to the right template
|
167 |
+
function templateRedirect() {
|
168 |
+
if ( is_page('login') )
|
169 |
+
define('IS_TML', true);
|
170 |
+
|
171 |
+
if ( is_page('login') || is_active_widget(false, null, 'theme-my-login') ) {
|
172 |
+
|
173 |
+
if ( $this->options['use_css'] ) {
|
174 |
+
if ( file_exists(get_stylesheet_directory() . '/theme-my-login.css') )
|
175 |
+
$css_file = get_stylesheet_directory_uri() . '/theme-my-login.css';
|
176 |
+
elseif ( file_exists(get_template_directory() . '/theme-my-login.css') )
|
177 |
+
$css_file = get_template_directory_uri() . '/theme-my-login.css';
|
178 |
+
else
|
179 |
+
$css_file = plugins_url('/theme-my-login/css/theme-my-login.css');
|
180 |
+
|
181 |
+
wp_enqueue_style('theme-my-login', $css_file);
|
182 |
+
}
|
183 |
|
184 |
+
//Set a cookie now to see if they are supported by the browser.
|
185 |
+
setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN);
|
186 |
+
if ( SITECOOKIEPATH != COOKIEPATH )
|
187 |
+
setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN);
|
188 |
+
|
189 |
+
// allow plugins to override the default actions, and to add extra actions if they want
|
190 |
+
do_action('login_form_' . $this->action);
|
191 |
+
|
192 |
+
$http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
|
193 |
+
switch ( $this->action ) {
|
194 |
+
case 'logout' :
|
195 |
+
check_admin_referer('log-out');
|
196 |
|
197 |
+
$user = wp_get_current_user();
|
198 |
+
|
199 |
+
$redirect_to = site_url('wp-login.php?loggedout=true');
|
200 |
+
if ( isset( $_REQUEST['redirect_to'] ) )
|
201 |
+
$redirect_to = $_REQUEST['redirect_to'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
|
203 |
+
$redirect_to = apply_filters('logout_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user);
|
204 |
+
|
205 |
+
wp_logout();
|
206 |
+
|
207 |
+
wp_safe_redirect($redirect_to);
|
208 |
+
exit();
|
209 |
+
break;
|
210 |
+
case 'lostpassword' :
|
211 |
+
case 'retrievepassword' :
|
212 |
+
if ( $http_post ) {
|
213 |
+
require_once(WP_PLUGIN_DIR . '/theme-my-login/includes/functions.php');
|
214 |
+
$this->errors = retrieve_password();
|
215 |
+
if ( !is_wp_error($this->errors) ) {
|
216 |
+
$redirect_to = site_url('wp-login.php?checkemail=confirm');
|
217 |
+
if ( 'tml-page' != $this->request_instance )
|
218 |
+
$redirect_to = $this->getCurrentURL('checkemail=confirm&instance=' . $this->request_instance);
|
219 |
+
wp_redirect($redirect_to);
|
220 |
+
exit();
|
221 |
}
|
|
|
|
|
222 |
}
|
223 |
+
|
224 |
+
if ( isset($_REQUEST['error']) && 'invalidkey' == $_REQUEST['error'] ) $this->errors->add('invalidkey', __('Sorry, that key does not appear to be valid.', 'theme-my-login'));
|
225 |
break;
|
226 |
+
case 'resetpass' :
|
227 |
+
case 'rp' :
|
228 |
+
require_once(WP_PLUGIN_DIR . '/theme-my-login/includes/functions.php');
|
229 |
+
$this->errors = reset_password($_GET['key'], $_GET['login']);
|
230 |
+
|
231 |
+
if ( ! is_wp_error($this->errors) ) {
|
232 |
+
$redirect_to = site_url('wp-login.php?checkemail=newpass');
|
233 |
+
if ( 'tml-page' != $this->request_instance )
|
234 |
+
$redirect_to = $this->getCurrentURL('checkemail=newpass&instance=' . $this->request_instance);
|
235 |
+
wp_redirect($redirect_to);
|
236 |
+
exit();
|
237 |
+
}
|
238 |
|
239 |
+
$redirect_to = site_url('wp-login.php?action=lostpassword&error=invalidkey');
|
240 |
+
if ( 'tml-page' != $this->request_instance )
|
241 |
+
$redirect_to = $this->getCurrentURL('action=lostpassword&error=invalidkey&instance=' . $this->request_instance);
|
242 |
+
wp_redirect($redirect_to);
|
243 |
+
exit();
|
244 |
+
break;
|
245 |
+
case 'register' :
|
246 |
+
if ( !get_option('users_can_register') ) {
|
247 |
+
wp_redirect($this->getCurrentURL('registration=disabled'));
|
248 |
+
exit();
|
249 |
+
}
|
250 |
|
251 |
+
$user_login = '';
|
252 |
+
$user_email = '';
|
253 |
+
if ( $http_post ) {
|
254 |
+
require_once(ABSPATH . WPINC . '/registration.php');
|
255 |
+
require_once(WP_PLUGIN_DIR . '/theme-my-login/includes/functions.php');
|
256 |
+
|
257 |
+
$user_login = $_POST['user_login'];
|
258 |
+
$user_email = $_POST['user_email'];
|
259 |
+
$this->errors = register_new_user($user_login, $user_email);
|
260 |
+
if ( !is_wp_error($this->errors) ) {
|
261 |
+
if ( 'email' == $this->options['moderation'] )
|
262 |
+
$redirect_to = $this->getCurrentURL('pending=activation&instance=' . $this->request_instance);
|
263 |
+
elseif ( 'admin' == $this->options['moderation'] )
|
264 |
+
$redirect_to = $this->getCurrentURL('pending=approval&instance=' . $this->request_instance);
|
265 |
+
else
|
266 |
+
$redirect_to = $this->getCurrentURL('checkemail=registered&instance=' . $this->request_instance);
|
267 |
+
wp_redirect($redirect_to);
|
268 |
+
exit();
|
269 |
+
}
|
270 |
+
}
|
271 |
+
break;
|
272 |
+
case 'login' :
|
273 |
+
default:
|
274 |
+
$secure_cookie = '';
|
275 |
+
|
276 |
+
// If the user wants ssl but the session is not ssl, force a secure cookie.
|
277 |
+
if ( !empty($_POST['log']) && !force_ssl_admin() ) {
|
278 |
+
$user_name = sanitize_user($_POST['log']);
|
279 |
+
if ( $user = get_userdatabylogin($user_name) ) {
|
280 |
+
if ( get_user_option('use_ssl', $user->ID) ) {
|
281 |
+
$secure_cookie = true;
|
282 |
+
force_ssl_admin(true);
|
283 |
+
}
|
284 |
+
}
|
285 |
+
}
|
286 |
|
287 |
+
if ( isset( $_REQUEST['redirect_to'] ) ) {
|
288 |
+
$this->redirect_to = $_REQUEST['redirect_to'];
|
289 |
+
// Redirect to https if user wants ssl
|
290 |
+
if ( $secure_cookie && false !== strpos($this->redirect_to, 'wp-admin') )
|
291 |
+
$this->redirect_to = preg_replace('|^http://|', 'https://', $this->redirect_to);
|
292 |
+
} else {
|
293 |
+
$this->redirect_to = admin_url();
|
294 |
+
}
|
295 |
|
296 |
+
if ( !$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && ( 0 !== strpos($this->redirect_to, 'https') ) && ( 0 === strpos($this->redirect_to, 'http') ) )
|
297 |
+
$secure_cookie = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
298 |
|
299 |
+
$user = wp_signon('', $secure_cookie);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
300 |
|
301 |
+
$this->redirect_to = apply_filters('login_redirect', $this->redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user);
|
|
|
|
|
|
|
|
|
|
|
302 |
|
303 |
+
if ( !is_wp_error($user) ) {
|
304 |
+
// If the user can't edit posts, send them to their profile.
|
305 |
+
if ( !$user->has_cap('edit_posts') && ( empty( $this->redirect_to ) || $this->redirect_to == 'wp-admin/' || $this->redirect_to == admin_url() ) )
|
306 |
+
$this->redirect_to = admin_url('profile.php');
|
307 |
+
wp_safe_redirect($this->redirect_to);
|
308 |
+
exit();
|
309 |
+
}
|
310 |
+
|
311 |
+
$this->errors = $user;
|
312 |
+
break;
|
313 |
}
|
314 |
}
|
315 |
}
|
316 |
|
317 |
+
function display($args = '') {
|
318 |
+
|
319 |
+
$this->instance_options = wp_parse_args($args, $this->options);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
320 |
|
321 |
+
$this->action = ( isset($this->instance_options['default_action']) ) ? $this->instance_options['default_action'] : 'login';
|
322 |
+
if ( $this->request_instance == $this->current_instance )
|
323 |
+
$this->action = $_REQUEST['action'];
|
324 |
+
|
325 |
+
ob_start();
|
326 |
+
echo $this->instance_options['before_widget'];
|
327 |
+
if ( $this->instance_options['show_title'] )
|
328 |
+
echo $this->instance_options['before_title'] . $this->getTitle($this->action) . $this->instance_options['after_title'] . "\n";
|
329 |
+
if ( is_user_logged_in() ) {
|
330 |
+
$user = wp_get_current_user();
|
331 |
+
$user_role = reset($user->roles);
|
332 |
+
if ( $this->instance_options['show_gravatar'] )
|
333 |
+
echo '<div class="tml-user-avatar">' . get_avatar( $user->ID, $this->instance_options['gravatar_size'] ) . '</div>' . "\n";
|
334 |
+
echo '<ul class="tml-user-links">' . "\n";
|
335 |
+
if ( $this->instance_options['links'][$user_role] ) {
|
336 |
+
foreach ( $this->instance_options['links'][$user_role] as $key => $data ) {
|
337 |
+
echo '<li><a href="' . $data['url'] . '">' . $data['title'] . '</a></li>' . "\n";
|
338 |
}
|
|
|
339 |
}
|
340 |
+
echo '<li><a href="' . wp_logout_url() . '">' . __('Log Out', 'theme-my-login') . '</a></li>' . "\n" . '</ul>' . "\n";
|
341 |
+
} else {
|
342 |
+
switch ( $this->action ) {
|
343 |
+
case 'lostpassword' :
|
344 |
+
case 'retrievepassword' :
|
345 |
+
$this->getLostPasswordForm();
|
346 |
+
break;
|
347 |
+
case 'register' :
|
348 |
+
$this->getRegisterForm();
|
349 |
+
break;
|
350 |
+
case 'login' :
|
351 |
+
default :
|
352 |
+
$this->getLoginForm();
|
353 |
+
break;
|
354 |
}
|
355 |
}
|
356 |
+
echo $this->instance_options['after_widget'] . "\n";
|
357 |
+
$contents = ob_get_contents();
|
358 |
+
ob_end_clean();
|
359 |
+
return $contents;
|
360 |
}
|
361 |
|
362 |
+
function getHeader($message = '') {
|
363 |
+
global $error;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
364 |
|
365 |
+
echo '<div class="login" id="' . $this->current_instance . '">';
|
366 |
+
|
367 |
+
$message = apply_filters('login_message', $message);
|
368 |
+
if ( !empty($message) ) echo '<p class="message">' . $message . "</p>\n";
|
369 |
+
|
370 |
+
// Incase a plugin uses $error rather than the $errors object
|
371 |
+
if ( !empty( $error ) ) {
|
372 |
+
$this->errors->add('error', $error);
|
373 |
+
unset($error);
|
|
|
|
|
374 |
}
|
375 |
|
376 |
+
if ( $this->request_instance == $this->current_instance ) {
|
377 |
+
if ( $this->errors->get_error_code() ) {
|
378 |
+
$errors = '';
|
379 |
+
$messages = '';
|
380 |
+
foreach ( $this->errors->get_error_codes() as $code ) {
|
381 |
+
$severity = $this->errors->get_error_data($code);
|
382 |
+
foreach ( $this->errors->get_error_messages($code) as $error ) {
|
383 |
+
if ( 'message' == $severity )
|
384 |
+
$messages .= ' ' . $error . "<br />\n";
|
385 |
+
else
|
386 |
+
$errors .= ' ' . $error . "<br />\n";
|
387 |
+
}
|
|
|
|
|
388 |
}
|
389 |
+
if ( !empty($errors) )
|
390 |
+
echo '<p class="error">' . apply_filters('login_errors', $errors) . "</p>\n";
|
391 |
+
if ( !empty($messages) )
|
392 |
+
echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n";
|
393 |
}
|
394 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
395 |
}
|
396 |
|
397 |
+
function getFooter($login_link = true, $register_link = true, $password_link = true) {
|
398 |
+
echo '<ul class="tml-links">' . "\n";
|
399 |
+
if ( $login_link ) {
|
400 |
+
$url = $this->getCurrentURL('instance=' . $this->current_instance);
|
401 |
+
echo '<li><a href="' . $url . '">' . $this->getTitle('login') . '</a></li>' . "\n";
|
402 |
+
}
|
403 |
+
if ( $register_link && get_option('users_can_register') ) {
|
404 |
+
$url = ($this->instance_options['register_widget']) ? $this->getCurrentURL('action=register&instance=' . $this->current_instance) : site_url('wp-login.php?action=register', 'login');
|
405 |
+
echo '<li><a href="' . $url . '">' . $this->getTitle('register') . '</a></li>' . "\n";
|
406 |
+
}
|
407 |
+
if ( $password_link ) {
|
408 |
+
$url = ($this->instance_options['lost_pass_widget']) ? $this->getCurrentURL('action=lostpassword&instance=' . $this->current_instance) : site_url('wp-login.php?action=lostpassword', 'login');
|
409 |
+
echo '<li><a href="' . $url . '">' . $this->getTitle('lostpassword') . '</a></li>' . "\n";
|
410 |
+
}
|
411 |
+
echo '</ul>' . "\n";
|
412 |
+
echo '</div>' . "\n";
|
413 |
}
|
414 |
+
|
415 |
+
function getLoginForm() {
|
416 |
+
|
417 |
+
$this->redirect_to = apply_filters('login_redirect', $this->redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user);
|
418 |
+
|
419 |
+
// Clear errors if loggedout is set.
|
420 |
+
if ( !empty($_GET['loggedout']) )
|
421 |
+
$this->errors = new WP_Error();
|
422 |
+
|
423 |
+
// If cookies are disabled we can't log in even with a valid user+pass
|
424 |
+
if ( isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE]) )
|
425 |
+
$this->errors->add('test_cookie', __("<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress.", 'theme-my-login'));
|
426 |
+
|
427 |
+
// Some parts of this script use the main login form to display a message
|
428 |
+
if ( $this->request_instance == $this->current_instance ) {
|
429 |
+
if ( isset($_GET['loggedout']) && TRUE == $_GET['loggedout'] )
|
430 |
+
$this->errors->add('loggedout', __('You are now logged out.', 'theme-my-login'), 'message');
|
431 |
+
elseif ( isset($_GET['registration']) && 'disabled' == $_GET['registration'] )
|
432 |
+
$this->errors->add('registerdisabled', __('User registration is currently not allowed.', 'theme-my-login'));
|
433 |
+
elseif ( isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail'] )
|
434 |
+
$this->errors->add('confirm', __('Check your e-mail for the confirmation link.', 'theme-my-login'), 'message');
|
435 |
+
elseif ( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] )
|
436 |
+
$this->errors->add('newpass', __('Check your e-mail for your new password.', 'theme-my-login'), 'message');
|
437 |
+
elseif ( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] ) {
|
438 |
+
if ( $this->options['custom_pass'] )
|
439 |
+
$this->errors->add('registered', __('Registration complete. You may now log in.', 'theme-my-login'), 'message');
|
440 |
+
else
|
441 |
+
$this->errors->add('registered', __('Registration complete. Please check your e-mail.', 'theme-my-login'), 'message');
|
442 |
+
} elseif ( isset($_GET['pending']) && 'activation' == $_GET['pending'] )
|
443 |
+
$this->errors->add('pending', __('Registration successful. You must now confirm your email address before you can log in.', 'theme-my-login'), 'message');
|
444 |
+
elseif ( isset($_GET['pending']) && 'approval' == $_GET['pending'] )
|
445 |
+
$this->errors->add('registered', __('Registration successful. You must now be approved by an administrator before you can log in. You will be notified by e-mail once your account has been reviewed.', 'theme-my-login'), 'message');
|
446 |
+
elseif ( isset($_GET['activation']) && 'complete' == $_GET['activation'] ) {
|
447 |
+
if ( $this->options['custom_pass'] )
|
448 |
+
$this->errors->add('activated', __('Your account was activated successfully! You can now log in with the username and password you provided when you signed up.', 'theme-my-login'), 'message');
|
449 |
+
else
|
450 |
+
$this->errors->add('activated', __('Your account was activated successfully! Please check your e-mail for your password.', 'theme-my-login'), 'message');
|
451 |
+
} elseif ( isset($_GET['activation']) && 'invalidkey' == $_GET['activation'] )
|
452 |
+
$this->errors->add('invalidkey', __('Sorry, that key does not appear to be valid.', 'theme-my-login'));
|
453 |
+
}
|
454 |
|
455 |
+
$this->getHeader();
|
|
|
|
|
|
|
456 |
|
457 |
+
if ( isset($_POST['log']) )
|
458 |
+
$user_login = ( 'incorrect_password' == $this->errors->get_error_code() || 'empty_password' == $this->errors->get_error_code() ) ? attribute_escape(stripslashes($_POST['log'])) : '';
|
|
|
459 |
|
460 |
+
$user_login = ( $this->request_instance == $this->current_instance && isset($user_login) ) ? $user_login : '';
|
461 |
+
|
462 |
+
if ( !isset($_GET['checkemail']) ||
|
463 |
+
( isset($_GET['checkemail']) && $this->request_instance != $this->current_instance ) ||
|
464 |
+
( !in_array( $_GET['checkemail'], array('confirm', 'newpass') ) && $this->request_instance == $this->current_instance ) ||
|
465 |
+
( in_array( $_GET['checkemail'], array('confirm', 'newpass') ) && $this->request_instance != $this->current_instance ) ) {
|
466 |
+
?>
|
467 |
+
<form name="loginform" id="loginform-<?php echo $this->current_instance; ?>" action="<?php echo $this->getCurrentURL('action=login&instance=' . $this->current_instance); ?>" method="post">
|
468 |
+
<p>
|
469 |
+
<label for="log-<?php echo $this->current_instance; ?>"><?php _e('Username', 'theme-my-login') ?></label>
|
470 |
+
<input type="text" name="log" id="log-<?php echo $this->current_instance; ?>" class="input" value="<?php echo isset($user_login) ? $user_login : ''; ?>" size="20" />
|
471 |
+
</p>
|
472 |
+
<p>
|
473 |
+
<label for="pwd-<?php echo $this->current_instance; ?>"><?php _e('Password', 'theme-my-login') ?></label>
|
474 |
+
<input type="password" name="pwd" id="pwd-<?php echo $this->current_instance; ?>" class="input" value="" size="20" />
|
475 |
+
</p>
|
476 |
+
<?php do_action('login_form', $this->current_instance); ?>
|
477 |
+
<p class="forgetmenot"><input name="rememberme" type="checkbox" id="rememberme-<?php echo $this->current_instance; ?>" value="forever" /> <label for="rememberme-<?php echo $this->current_instance; ?>"><?php _e('Remember Me', 'theme-my-login'); ?></label></p>
|
478 |
+
<p class="submit">
|
479 |
+
<input type="submit" name="wp-submit" id="wp-submit-<?php echo $this->current_instance; ?>" value="<?php _e('Log In', 'theme-my-login'); ?>" />
|
480 |
+
<input type="hidden" name="redirect_to" value="<?php echo esc_attr($this->redirect_to); ?>" />
|
481 |
+
<input type="hidden" name="testcookie" value="1" />
|
482 |
+
</p>
|
483 |
+
</form>
|
484 |
+
<?php
|
485 |
+
}
|
486 |
+
if ( $this->request_instance == $this->current_instance && isset($_GET['checkemail']) && in_array( $_GET['checkemail'], array('confirm', 'newpass') ) )
|
487 |
+
$login_link = true;
|
488 |
+
else
|
489 |
+
$login_link = false;
|
490 |
+
$this->getFooter($login_link, true, true);
|
491 |
}
|
492 |
|
493 |
+
function getRegisterForm() {
|
494 |
+
$user_login = isset($_POST['user_login']) ? $_POST['user_login'] : '';
|
495 |
+
$user_email = isset($_POST['user_email']) ? $_POST['user_email'] : '';
|
496 |
|
497 |
+
$message = ( $this->options['custom_pass'] ) ? '' : __('A password will be e-mailed to you.', 'theme-my-login');
|
498 |
+
if ( 'email' == $this->options['moderation'] )
|
499 |
+
$message = __('E-mail moderation is currently enabled. You must confirm your e-mail before you can log in.', 'theme-my-login');
|
500 |
+
elseif ( 'admin' == $this->options['moderation'] )
|
501 |
+
$message = __('User moderation is currently enabled. Your registration must be approved before you can log in.', 'theme-my-login');
|
502 |
+
$message = apply_filters('tml_register_foreword', $message);
|
503 |
|
504 |
+
$this->getHeader($message);
|
505 |
+
?>
|
506 |
+
<form name="registerform" id="registerform-<?php echo $this->current_instance; ?>" action="<?php echo $this->getCurrentURL('action=register&instance=' . $this->current_instance); ?>" method="post">
|
507 |
+
<p>
|
508 |
+
<label for="user_login-<?php echo $this->current_instance; ?>"><?php _e('Username', 'theme-my-login') ?></label>
|
509 |
+
<input type="text" name="user_login" id="user_login-<?php echo $this->current_instance; ?>" class="input" value="<?php echo attribute_escape(stripslashes($user_login)); ?>" size="20" />
|
510 |
+
</p>
|
511 |
+
<p>
|
512 |
+
<label for="user_email-<?php echo $this->current_instance; ?>"><?php _e('E-mail', 'theme-my-login') ?></label>
|
513 |
+
<input type="text" name="user_email" id="user_email-<?php echo $this->current_instance; ?>" class="input" value="<?php echo attribute_escape(stripslashes($user_email)); ?>" size="20" />
|
514 |
+
</p>
|
515 |
+
<?php do_action('register_form', $this->current_instance); ?>
|
516 |
+
<p class="submit">
|
517 |
+
<input type="submit" name="wp-submit" id="wp-submit-<?php echo $this->current_instance; ?>" value="<?php _e('Register', 'theme-my-login'); ?>" />
|
518 |
+
</p>
|
519 |
+
</form>
|
520 |
+
<?php
|
521 |
+
$this->getFooter(true, false, true);
|
522 |
+
}
|
523 |
+
|
524 |
+
function getLostPasswordForm() {
|
525 |
+
do_action('lost_password', $this->current_instance);
|
526 |
+
$this->getHeader(__('Please enter your username or e-mail address. You will receive a new password via e-mail.', 'theme-my-login'));
|
527 |
+
$user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : '';
|
528 |
+
?>
|
529 |
+
<form name="lostpasswordform" id="lostpasswordform-<?php echo $this->current_instance; ?>" action="<?php echo $this->getCurrentURL('action=lostpassword&instance=' . $this->current_instance); ?>" method="post">
|
530 |
+
<p>
|
531 |
+
<label for="user_login-<?php echo $this->current_instance; ?>"><?php _e('Username or E-mail:', 'theme-my-login') ?></label>
|
532 |
+
<input type="text" name="user_login" id="user_login-<?php echo $this->current_instance; ?>" class="input" value="<?php echo attribute_escape($user_login); ?>" size="20" />
|
533 |
+
</p>
|
534 |
+
<?php do_action('lostpassword_form', $this->current_instance); ?>
|
535 |
+
<p class="submit">
|
536 |
+
<input type="submit" name="wp-submit" id="wp-submit-<?php echo $this->current_instance; ?>" value="<?php _e('Get New Password', 'theme-my-login'); ?>" />
|
537 |
+
</p>
|
538 |
+
</form>
|
539 |
+
<?php
|
540 |
+
$this->getFooter(true, true, false);
|
541 |
+
}
|
542 |
+
|
543 |
+
// Get title depending on current action
|
544 |
+
function getTitle($action = '') {
|
545 |
+
if ( empty($action) )
|
546 |
+
$action = $this->action;
|
547 |
+
|
548 |
+
if ( is_user_logged_in() ) {
|
549 |
+
$user = wp_get_current_user();
|
550 |
+
$title = sprintf(__('Welcome, %s', 'theme-my-login'), $user->display_name);
|
551 |
+
} else {
|
552 |
+
switch ( $action ) {
|
553 |
case 'register':
|
554 |
+
$title = __('Register', 'theme-my-login');
|
555 |
break;
|
556 |
case 'lostpassword':
|
557 |
case 'retrievepassword':
|
558 |
case 'resetpass':
|
559 |
case 'rp':
|
560 |
+
$title = __('Lost Password', 'theme-my-login');
|
561 |
break;
|
562 |
case 'login':
|
563 |
default:
|
564 |
+
$title = __('Log In', 'theme-my-login');
|
565 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
566 |
}
|
567 |
+
return apply_filters('tml_title', $title);
|
568 |
+
}
|
569 |
+
|
570 |
+
function getNewInstance() {
|
571 |
+
static $instance = 0;
|
572 |
+
++$instance;
|
573 |
+
$this->current_instance = 'tml-' . $instance;
|
574 |
}
|
575 |
|
576 |
+
function shortcode($atts = '') {
|
577 |
+
if ( isset($atts['instance']) )
|
578 |
+
$this->current_instance = $atts['instance'];
|
579 |
+
else
|
580 |
+
$this->getNewInstance();
|
581 |
+
$atts = shortcode_atts($this->options, $atts);
|
582 |
+
return $this->display($atts);
|
583 |
}
|
584 |
|
585 |
+
function siteURL($url, $path, $orig_scheme) {
|
586 |
+
global $wp_rewrite;
|
587 |
+
|
588 |
$schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
|
589 |
$self = $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
590 |
+
|
591 |
+
if ( preg_match('/wp-login.php/', $url) && !isset($_REQUEST['interim-login']) ) {
|
592 |
+
$orig_url = $url;
|
593 |
+
$url = $this->getPermalink();
|
594 |
+
if ( strpos($orig_url, '?') ) {
|
595 |
+
$query = substr($orig_url, strpos($orig_url, '?') + 1);
|
596 |
+
parse_str($query, $r);
|
597 |
+
$url = add_query_arg($r, $url);
|
|
|
|
|
|
|
|
|
|
|
|
|
598 |
}
|
599 |
}
|
600 |
+
return $url;
|
|
|
601 |
}
|
602 |
|
603 |
+
function getCurrentURL($query = '') {
|
|
|
|
|
604 |
$schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
|
605 |
$self = $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
606 |
|
607 |
+
$keys = array('instance', 'action', 'checkemail', 'error', 'loggedout', 'registered', 'redirect_to', 'updated', 'key', '_wpnonce');
|
608 |
+
$url = remove_query_arg($keys, $self);
|
|
|
|
|
|
|
|
|
|
|
609 |
|
610 |
+
if ( !empty($query) ) {
|
611 |
+
$query = wp_parse_args($query);
|
612 |
+
$url = add_query_arg($query, $url);
|
613 |
}
|
614 |
+
|
615 |
return $url;
|
616 |
}
|
617 |
|
618 |
+
function getPermalink() {
|
619 |
+
global $wp_rewrite;
|
620 |
+
|
621 |
+
$pagestruct = $wp_rewrite->get_page_permastruct();
|
622 |
+
|
623 |
+
if ( '' != $pagestruct ) {
|
624 |
+
$link = str_replace('%pagename%', 'login', $pagestruct);
|
625 |
+
$link = trailingslashit(get_option('home')) . "$link";
|
626 |
+
$link = user_trailingslashit($link, 'page');
|
627 |
+
} else {
|
628 |
+
$link = trailingslashit(get_option('home')) . '?pagename=login';
|
629 |
}
|
630 |
+
return $link;
|
631 |
}
|
632 |
|
633 |
+
function loginRedirect($redirect_to, $request, $user) {
|
634 |
+
global $pagenow;
|
635 |
+
|
636 |
+
if ( 'wp-login.php' == $pagenow )
|
637 |
+
return $redirect_to;
|
638 |
+
|
639 |
+
$orig_redirect = $redirect_to;
|
640 |
+
|
641 |
+
$redirect_to = ( 'tml-page' == $this->current_instance ) ? $_SERVER['HTTP_REFERER'] : $this->getCurrentURL();
|
642 |
+
|
643 |
+
if ( is_object($user) && !is_wp_error($user) ) {
|
644 |
+
$user_role = reset($user->roles);
|
645 |
+
if ( '' != $this->options['redirects'][$user_role]['login_url'] )
|
646 |
+
$role_redirect = $this->options['redirects'][$user_role]['login_url'];
|
647 |
}
|
648 |
+
|
649 |
+
if ( !empty($request) && $this->options['override_redirect'] )
|
650 |
+
$redirect_to = $request;
|
651 |
+
elseif ( isset($role_redirect) && !$this->options['override_redirect'] )
|
652 |
+
$redirect_to = $role_redirect;
|
653 |
+
|
654 |
+
return $redirect_to;
|
655 |
}
|
656 |
|
657 |
+
function logoutRedirect($redirect_to, $request, $user) {
|
658 |
+
$orig_redirect = $redirect_to;
|
659 |
+
|
660 |
+
$redirect_to = remove_query_arg(array('instance', 'action', 'checkemail', 'error', 'loggedout', 'registered', 'redirect_to', 'updated', 'key', '_wpnonce'), $_SERVER['HTTP_REFERER']);
|
661 |
+
|
662 |
+
if ( is_object($user) && !is_wp_error($user) ) {
|
663 |
+
$user_role = reset($user->roles);
|
664 |
+
if ( '' != $this->options['redirects'][$user_role]['logout_url'] )
|
665 |
+
$role_redirect = $this->options['redirects'][$user_role]['logout_url'];
|
666 |
}
|
667 |
+
|
668 |
+
if ( !empty($request) && $this->options['override_redirect'] )
|
669 |
+
$redirect_to = $request;
|
670 |
+
elseif ( isset($role_redirect) && !$this->options['override_redirect'] )
|
671 |
+
$redirect_to = $role_redirect;
|
672 |
+
|
673 |
+
return $redirect_to;
|
674 |
}
|
675 |
|
676 |
+
function customPassForm($instance) {
|
677 |
+
?>
|
678 |
+
<p><label for="pass1-<?php echo $instance; ?>"><?php _e('Password:', 'theme-my-login');?></label>
|
679 |
+
<input autocomplete="off" name="pass1" id="pass1-<?php echo $instance; ?>" class="input" size="20" value="" type="password" /></p>
|
680 |
+
<p><label for="pass2-<?php echo $instance; ?>"><?php _e('Confirm Password:', 'theme-my-login');?></label>
|
681 |
+
<input autocomplete="off" name="pass2" id="pass2-<?php echo $instance; ?>" class="input" size="20" value="" type="password" /></p>
|
682 |
+
<?php
|
683 |
}
|
684 |
|
685 |
+
function customPassErrors($errors){
|
686 |
+
if (empty($_POST['pass1']) || $_POST['pass1'] == '' || empty($_POST['pass2']) || $_POST['pass2'] == ''){
|
687 |
+
$errors->add('empty_password', __('<strong>ERROR</strong>: Please enter a password.', 'theme-my-login'));
|
688 |
+
} elseif ($_POST['pass1'] !== $_POST['pass2']){
|
689 |
+
$errors->add('password_mismatch', __('<strong>ERROR</strong>: Your passwords do not match.', 'theme-my-login'));
|
690 |
+
} elseif (strlen($_POST['pass1'])<6){
|
691 |
+
$errors->add('password_length', __('<strong>ERROR</strong>: Your password must be at least 6 characters in length.', 'theme-my-login'));
|
692 |
+
} else {
|
693 |
+
$_POST['user_pw'] = $_POST['pass1'];
|
694 |
+
}
|
695 |
+
return $errors;
|
696 |
+
}
|
697 |
|
698 |
+
function setUserPassword($user_id) {
|
699 |
+
if ( $this->options['custom_pass'] && isset($_POST['user_pw']) && '' != $_POST['user_pw'] )
|
700 |
+
wp_set_password(stripslashes($_POST['user_pw']), $user_id);
|
701 |
}
|
702 |
|
703 |
+
function userModeration($user_id) {
|
704 |
+
$user = new WP_User($user_id);
|
705 |
+
$user->set_role('pending');
|
706 |
+
if ( 'email' == $this->options['moderation'] ) {
|
707 |
+
global $wpdb;
|
708 |
+
$key = wp_generate_password(20, false);
|
709 |
+
$wpdb->update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $user->user_login));
|
710 |
+
}
|
711 |
}
|
712 |
|
713 |
+
function userActivation() {
|
714 |
+
require_once(WP_PLUGIN_DIR . '/theme-my-login/includes/functions.php');
|
715 |
+
$newpass = ( $this->options['custom_pass'] ) ? 0 : 1;
|
716 |
+
$this->errors = activate_new_user($_GET['key'], $_GET['login'], $newpass);
|
717 |
+
|
718 |
+
if ( ! is_wp_error($this->errors) ) {
|
719 |
+
$redirect_to = site_url('wp-login.php?activation=complete');
|
720 |
+
if ( 'tml-page' != $this->request_instance )
|
721 |
+
$redirect_to = $this->getCurrentURL('activation=complete&instance=' . $this->request_instance);
|
722 |
+
wp_redirect($redirect_to);
|
723 |
+
exit();
|
724 |
+
}
|
725 |
+
|
726 |
+
$redirect_to = site_url('wp-login.php?activation=invalidkey');
|
727 |
+
if ( 'tml-page' != $this->request_instance )
|
728 |
+
$redirect_to = $this->getCurrentURL('activation=invalidkey&instance=' . $this->request_instance);
|
729 |
+
wp_redirect($redirect_to);
|
730 |
+
exit();
|
731 |
}
|
732 |
|
733 |
+
function authenticate($user, $username, $password) {
|
734 |
+
global $wpdb;
|
735 |
+
|
736 |
+
if ( is_a($user, 'WP_User') ) {
|
737 |
+
$user_role = reset($user->roles);
|
738 |
+
if ( 'pending' == $user_role ) {
|
739 |
+
if ( $this->options['redirects'][$user_role]['login_url'] ) {
|
740 |
+
wp_safe_redirect($this->options['redirects'][$user_role]['login_url']);
|
741 |
+
exit();
|
742 |
+
} else {
|
743 |
+
if ( 'email' == $this->options['moderation'] )
|
744 |
+
return new WP_Error('pending', __('<strong>ERROR</strong>: You have not yet confirmed your e-mail address.', 'theme-my-login'));
|
745 |
+
else
|
746 |
+
return new WP_Error('pending', __('<strong>ERROR</strong>: Your registration has not yet been approved.', 'theme-my-login'));
|
747 |
+
}
|
748 |
+
}
|
|
|
|
|
|
|
749 |
}
|
750 |
+
return $user;
|
751 |
+
}
|
752 |
+
|
753 |
+
function denyUser($id) {
|
754 |
+
$user = new WP_User($id);
|
755 |
+
$user_role = reset($user->roles);
|
756 |
+
if ( 'pending' != $user_role )
|
757 |
+
return;
|
758 |
+
|
759 |
+
// The blogname option is escaped with esc_html on the way into the database in sanitize_option
|
760 |
+
// we want to reverse this for the plain text arena of emails.
|
761 |
+
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
|
762 |
|
763 |
+
$replace_this = array('/%blogname%/', '/%siteurl%/', '/%user_login%/', '/%user_email%/');
|
764 |
+
$replace_with = array($blogname, get_option('siteurl'), $user->user_login, $user->user_email);
|
765 |
+
$subject = $this->options['user_denial_email']['subject'];
|
766 |
+
$message = $this->options['user_denial_email']['message'];
|
767 |
+
|
768 |
+
if ( !empty($subject) )
|
769 |
+
$subject = preg_replace($replace_this, $replace_with, $subject);
|
770 |
+
else
|
771 |
+
$subject = sprintf(__('[%s] Registration Denied', 'theme-my-login'), $blogname);
|
772 |
+
if ( !empty($message) )
|
773 |
+
$message = preg_replace($replace_this, $replace_with, $message);
|
774 |
+
else
|
775 |
+
$message = sprintf(__('You have been denied access to %s', 'theme-my-login'), $blogname);
|
776 |
+
|
777 |
+
$this->sendEmail($user->user_email, $subject, $message);
|
778 |
}
|
779 |
|
780 |
+
function allowPasswordReset($allow, $user_id) {
|
781 |
+
$user = new WP_User($user_id);
|
782 |
+
$user_role = reset($user->roles);
|
783 |
+
if ( 'pending' == $user_role )
|
784 |
+
$allow = false;
|
785 |
+
|
786 |
+
return $allow;
|
787 |
+
}
|
788 |
+
|
789 |
+
function sendEmail($to, $subject, $message) {
|
790 |
+
$headers = '';
|
791 |
+
if ( $this->options['email_from'] && $this->options['email_from_name'] )
|
792 |
+
$headers .= 'From: ' . $this->options['email_from_name'] . ' <' . $this->options['email_from'] . '>' . "\r\n";
|
793 |
+
elseif ( $this->options['email_from'] )
|
794 |
+
$headers .= 'From: ' . $this->options['email_from'] . "\r\n";
|
795 |
+
|
796 |
+
if ( 'text/html' == $this->options['email_content_type'] )
|
797 |
+
$headers .= 'Content-type: text/html; charset=' . get_option('blog_charset') . "\r\n";
|
798 |
+
else
|
799 |
+
$headers .= 'Content-type: text/plain; charset=' . get_option('blog_charset') . "\r\n";
|
800 |
+
|
801 |
+
return wp_mail($to, $subject, $message, $headers);
|
802 |
}
|
803 |
|
804 |
+
function defaultOptions($save = false) {
|
805 |
|
806 |
// General
|
|
|
|
|
|
|
807 |
$this->options['custom_pass'] = 0;
|
808 |
+
$this->options['moderation'] = 'none';
|
809 |
$this->options['email_from'] = '';
|
810 |
$this->options['email_from_name'] = '';
|
811 |
$this->options['email_content_type'] = 'text/plain';
|
812 |
$this->options['use_css'] = 1;
|
813 |
$this->options['override_redirect'] = 1;
|
814 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
815 |
// Widget
|
816 |
$this->options['default_action'] = 'login';
|
817 |
$this->options['show_title'] = 1;
|
831 |
// E-mails
|
832 |
$this->options['retrieve_pass_email'] = array('subject' => '', 'message' => '');
|
833 |
$this->options['reset_pass_email'] = array('subject' => '', 'message' => '', 'admin_disable' => 0);
|
834 |
+
$this->options['registration_email'] = array('subject' => '', 'message' => '', 'admin_disable' => 0);
|
835 |
+
$this->options['confirmation_email'] = array('subject' => '', 'message' => '');
|
836 |
$this->options['user_approval_email'] = array('subject' => '', 'message' => '');
|
837 |
$this->options['user_denial_email'] = array('subject' => '', 'message' => '');
|
838 |
|
842 |
$wp_roles = new WP_Roles();
|
843 |
$user_roles = $wp_roles->get_names();
|
844 |
foreach ( $user_roles as $role => $title ) {
|
845 |
+
if ( 'pending' == $role )
|
846 |
+
continue;
|
847 |
$this->options['links'][$role][] = array('title' => 'Dashboard', 'url' => admin_url());
|
848 |
$this->options['links'][$role][] = array('title' => 'Profile', 'url' => admin_url('profile.php'));
|
849 |
$this->options['redirects'][$role] = array('login_url' => '', 'logout_url' => '');
|
850 |
}
|
851 |
|
852 |
if ( $save )
|
853 |
+
$this->saveOptions();
|
|
|
854 |
}
|
855 |
|
856 |
+
function loadOptions() {
|
857 |
|
858 |
+
$this->defaultOptions();
|
859 |
|
860 |
$storedoptions = get_option('theme_my_login');
|
861 |
+
if ( $storedoptions && is_array($storedoptions) ) {
|
862 |
foreach ( $storedoptions as $key => $value ) {
|
863 |
$this->options[$key] = $value;
|
864 |
}
|
865 |
} else update_option('theme_my_login', $this->options);
|
866 |
}
|
867 |
|
868 |
+
function getOption($key) {
|
869 |
if ( array_key_exists($key, $this->options) ) {
|
870 |
return $this->options[$key];
|
871 |
} else return null;
|
872 |
}
|
873 |
|
874 |
+
function setOption($key, $value) {
|
875 |
$this->options[$key] = $value;
|
876 |
}
|
877 |
|
878 |
+
function saveOptions() {
|
879 |
$oldvalue = get_option('theme_my_login');
|
880 |
+
if ( $oldvalue == $this->options ) {
|
881 |
return true;
|
882 |
} else return update_option('theme_my_login', $this->options);
|
883 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
884 |
|
885 |
+
function install() {
|
886 |
+
$plugin_data = get_plugin_data(__FILE__);
|
887 |
+
$this->setOption('version', $plugin_data['Version']);
|
888 |
+
$this->saveOptions();
|
889 |
+
}
|
890 |
+
|
891 |
+
function uninstall() {
|
892 |
+
delete_option('theme_my_login');
|
893 |
+
}
|
894 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
895 |
|
896 |
+
if ( class_exists('ThemeMyLogin') ) {
|
897 |
+
$ThemeMyLogin = new ThemeMyLogin();
|
898 |
+
|
899 |
+
require_once (WP_PLUGIN_DIR . '/theme-my-login/includes/widget.php');
|
900 |
+
|
901 |
+
if ( !function_exists('theme_my_login') ) :
|
902 |
+
function theme_my_login($args = '') {
|
903 |
+
global $ThemeMyLogin;
|
904 |
+
$args = wp_parse_args($args);
|
905 |
+
echo $ThemeMyLogin->shortcode($args);
|
906 |
+
}
|
907 |
+
endif;
|
908 |
+
|
909 |
+
if ( !function_exists('wp_new_user_notification') ) :
|
910 |
+
function wp_new_user_notification($user_id, $plaintext_pass = '') {
|
911 |
+
global $ThemeMyLogin;
|
912 |
+
|
913 |
+
$user = new WP_User($user_id);
|
914 |
|
915 |
+
$user_login = stripslashes($user->user_login);
|
916 |
+
$user_email = stripslashes($user->user_email);
|
917 |
+
$user_role = reset($user->roles);
|
918 |
|
919 |
+
// The blogname option is escaped with esc_html on the way into the database in sanitize_option
|
920 |
+
// we want to reverse this for the plain text arena of emails.
|
921 |
+
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
|
922 |
+
|
923 |
+
if ( 'email' == $ThemeMyLogin->options['moderation'] && 'pending' == $user_role ) {
|
924 |
+
global $wpdb;
|
925 |
+
$key = $wpdb->get_var($wpdb->prepare("SELECT user_activation_key FROM $wpdb->users WHERE user_login = %s", $user_login));
|
926 |
+
if ( empty($key) ) {
|
927 |
+
$key = wp_generate_password(20, false);
|
928 |
+
$wpdb->update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $user_login));
|
929 |
+
}
|
930 |
+
$confirm_url = add_query_arg(array('action' => 'activate', 'key' => $key, 'login' => $user_login), $ThemeMyLogin->getPermalink());
|
931 |
+
$replace_this = array('/%blogname%/', '/%siteurl%/', '/%confirmurl%/', '/%user_login%/', '/%user_email%/', '/%user_pass%/', '/%user_ip%/');
|
932 |
+
$replace_with = array($blogname, get_option('siteurl'), $confirm_url, $user_login, $user_email, $plaintext_pass, $_SERVER['REMOTE_ADDR']);
|
933 |
+
$subject = $ThemeMyLogin->options['confirmation_email']['subject'];
|
934 |
+
$message = $ThemeMyLogin->options['confirmation_email']['message'];
|
935 |
+
|
936 |
+
if ( !empty($subject) )
|
937 |
+
$subject = preg_replace($replace_this, $replace_with, $subject);
|
938 |
+
else
|
939 |
+
$subject = sprintf(__('[%s] Activate Your Account', 'theme-my-login'), $blogname);
|
940 |
+
if ( !empty($message) )
|
941 |
+
$message = preg_replace($replace_this, $replace_with, $message);
|
942 |
+
else {
|
943 |
+
$message = sprintf(__('Thanks for registering at %s! To complete the activation of your account please click the following link: ', 'theme-my-login'), $blogname) . "\r\n\r\n";
|
944 |
+
$message .= $confirm_url;
|
945 |
+
}
|
946 |
+
$ThemeMyLogin->sendEmail($user_email, $subject, $message);
|
947 |
+
} elseif ( 'admin' == $ThemeMyLogin->options['moderation'] && 'pending' == $user_role ) {
|
948 |
+
$message = sprintf(__('New user requires approval on your blog %s:', 'theme-my-login'), $blogname) . "\r\n\r\n";
|
949 |
+
$message .= sprintf(__('Username: %s', 'theme-my-login'), $user_login) . "\r\n\r\n";
|
950 |
+
$message .= sprintf(__('E-mail: %s', 'theme-my-login'), $user_email) . "\r\n\r\n";
|
951 |
+
$message .= __('To approve or deny this user:', 'theme-my-login') . "\r\n";
|
952 |
+
$message .= admin_url('users.php');
|
953 |
+
|
954 |
+
@$ThemeMyLogin->sendEmail(get_option('admin_email'), sprintf(__('[%s] New User Awaiting Approval', 'theme-my-login'), $blogname), $message);
|
955 |
+
} else {
|
956 |
+
if ( !$ThemeMyLogin->options['registration_email']['admin_disable'] ) {
|
957 |
+
$message = sprintf(__('New user registration on your blog %s:', 'theme-my-login'), $blogname) . "\r\n\r\n";
|
958 |
+
$message .= sprintf(__('Username: %s', 'theme-my-login'), $user_login) . "\r\n\r\n";
|
959 |
+
$message .= sprintf(__('E-mail: %s', 'theme-my-login'), $user_email) . "\r\n";
|
960 |
|
961 |
+
@$ThemeMyLogin->sendEmail(get_option('admin_email'), sprintf(__('[%s] New User Registration', 'theme-my-login'), $blogname), $message);
|
962 |
+
}
|
963 |
+
|
964 |
+
if ( empty($plaintext_pass) || $ThemeMyLogin->options['custom_pass'] )
|
965 |
+
return;
|
966 |
+
|
967 |
+
$replace_this = array('/%blogname%/', '/%siteurl%/', '/%user_login%/', '/%user_email%/', '/%user_pass%/', '/%user_ip%/');
|
968 |
+
$replace_with = array($blogname, get_option('siteurl'), $user_login, $user_email, $plaintext_pass, $_SERVER['REMOTE_ADDR']);
|
969 |
$subject = $ThemeMyLogin->options['registration_email']['subject'];
|
970 |
$message = $ThemeMyLogin->options['registration_email']['message'];
|
|
|
|
|
971 |
|
972 |
if ( !empty($subject) )
|
973 |
$subject = preg_replace($replace_this, $replace_with, $subject);
|
974 |
else
|
975 |
+
$subject = sprintf(__('[%s] Your username and password', 'theme-my-login'), $blogname);
|
976 |
if ( !empty($message) )
|
977 |
$message = preg_replace($replace_this, $replace_with, $message);
|
978 |
else {
|
979 |
+
$message = sprintf(__('Username: %s', 'theme-my-login'), $user_login) . "\r\n";
|
980 |
+
$message .= sprintf(__('Password: %s', 'theme-my-login'), $plaintext_pass) . "\r\n";
|
981 |
+
$message .= wp_login_url() . "\r\n";
|
982 |
}
|
983 |
+
$ThemeMyLogin->sendEmail($user_email, $subject, $message);
|
|
|
|
|
984 |
}
|
985 |
}
|
986 |
+
endif;
|
987 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
988 |
}
|
989 |
|
990 |
?>
|