Version Description
Download this release
Release Info
Developer | jolley_small |
Plugin | Sidebar Login |
Version | 2.2 |
Comparing to | |
See all releases |
Code changes from version 2.1.7 to 2.2
- readme.txt +1 -1
- sidebar-login.php +94 -76
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://blue-anvil.com/archives/wordpress-sidebar-login-2-optimised-
|
|
4 |
Tags: login, sidebar, widget, sidebar login, meta, form, register
|
5 |
Requires at least: 2.5
|
6 |
Tested up to: 2.7
|
7 |
-
Stable tag: 2.
|
8 |
|
9 |
Adds a sidebar widget to let users login.
|
10 |
|
4 |
Tags: login, sidebar, widget, sidebar login, meta, form, register
|
5 |
Requires at least: 2.5
|
6 |
Tested up to: 2.7
|
7 |
+
Stable tag: 2.2
|
8 |
|
9 |
Adds a sidebar widget to let users login.
|
10 |
|
sidebar-login.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Sidebar Login
|
4 |
Plugin URI: http://wordpress.org/extend/plugins/sidebar-login/
|
5 |
Description: Adds a sidebar widget to let users login
|
6 |
-
Version: 2.
|
7 |
Author: Mike Jolley
|
8 |
Author URI: http://blue-anvil.com
|
9 |
*/
|
@@ -14,17 +14,18 @@ function wp_sidebarlogin_menu() {
|
|
14 |
add_management_page(__('Sidebar Login','sblogin'), __('Sidebar Login','sblogin'), 6,'Sidebar Login', 'wp_sidebarlogin_admin');
|
15 |
}
|
16 |
|
|
|
17 |
function wp_sidebarlogin_magic() {
|
18 |
function stripit($in) {
|
19 |
if (!is_array($in)) $out = stripslashes($in); else $out = $in;
|
20 |
return $out;
|
21 |
}
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
}
|
26 |
return;
|
27 |
}
|
|
|
28 |
|
29 |
if (!function_exists(is_ssl)) :
|
30 |
function is_ssl() {
|
@@ -58,30 +59,30 @@ function wp_sidebarlogin_admin(){
|
|
58 |
<form action="?page=Sidebar Login" method="post">
|
59 |
<table class="niceblue form-table">
|
60 |
<tr>
|
61 |
-
<th scope="col"><?php _e('Login redirect URL',"
|
62 |
<td><input type="text" name="sidebarlogin_login_redirect" value="<?php echo $sidebarlogin_login_redirect; ?>" /> <span class="setting-description"><?php _e('Url to redirect the user to after login. Leave blank to use their current page.','sblogin'); ?></span></td>
|
63 |
</tr>
|
64 |
<tr>
|
65 |
-
<th scope="col"><?php _e('Logout redirect URL',"
|
66 |
<td><input type="text" name="sidebarlogin_logout_redirect" value="<?php echo $sidebarlogin_logout_redirect; ?>" /> <span class="setting-description"><?php _e('Url to redirect the user to after logout. Leave blank to use their current page.','sblogin'); ?></span></td>
|
67 |
</tr>
|
68 |
<tr>
|
69 |
-
<th scope="col"><?php _e('Show Register Link',"
|
70 |
<td><select name="sidebarlogin_register_link">
|
71 |
<option <?php if ($sidebarlogin_register_link=='yes') echo 'selected="selected"'; ?> value="yes"><?php _e('Yes','sblogin'); ?></option>
|
72 |
<option <?php if ($sidebarlogin_register_link=='no') echo 'selected="selected"'; ?> value="no"><?php _e('No','sblogin'); ?></option>
|
73 |
</select> <span class="setting-description"><?php _e('User registrations must also be turned on for this to work (\'Anyone can register\' checkbox in settings).','sblogin'); ?></span></td>
|
74 |
</tr>
|
75 |
<tr>
|
76 |
-
<th scope="col"><?php _e('Show Lost Password Link',"
|
77 |
<td><select name="sidebarlogin_forgotton_link">
|
78 |
<option <?php if ($sidebarlogin_forgotton_link=='yes') echo 'selected="selected"'; ?> value="yes"><?php _e('Yes','sblogin'); ?></option>
|
79 |
<option <?php if ($sidebarlogin_forgotton_link=='no') echo 'selected="selected"'; ?> value="no"><?php _e('No','sblogin'); ?></option>
|
80 |
</select></td>
|
81 |
</tr>
|
82 |
<tr>
|
83 |
-
<th scope="col"><?php _e('Logged in links',"
|
84 |
-
<td><textarea name="sidebarlogin_logged_in_links" rows="3" cols="80" /><?php echo $sidebarlogin_logged_in_links; ?></textarea><br/><span class="setting-description"><?php _e('One link per line
|
85 |
</tr>
|
86 |
</table>
|
87 |
<p class="submit"><input type="submit" value="<?php _e('Save Changes',"sblogin"); ?>" /></p>
|
@@ -90,36 +91,72 @@ function wp_sidebarlogin_admin(){
|
|
90 |
<?php
|
91 |
}
|
92 |
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
widget_wp_sidebarlogin($args);
|
99 |
}
|
|
|
100 |
function widget_wp_sidebarlogin($args) {
|
101 |
-
|
102 |
-
extract($args);
|
103 |
-
|
104 |
global $user_ID, $current_user;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
get_currentuserinfo();
|
106 |
|
107 |
if ($user_ID != '') {
|
108 |
// User is logged in
|
109 |
-
echo $before_widget . $before_title .
|
110 |
echo '<ul class="pagenav">';
|
111 |
|
|
|
|
|
|
|
112 |
$links = get_option('sidebarlogin_logged_in_links');
|
113 |
$links = explode("\n", $links);
|
114 |
if (sizeof($links)>0)
|
115 |
foreach ($links as $l) {
|
116 |
-
|
|
|
|
|
117 |
}
|
118 |
-
|
119 |
-
|
|
|
|
|
|
|
|
|
120 |
} else {
|
121 |
// User is NOT logged in!!!
|
122 |
-
echo $before_widget . $before_title .
|
123 |
// Show any errors
|
124 |
global $myerrors;
|
125 |
$wp_error = new WP_Error();
|
@@ -146,53 +183,61 @@ function widget_wp_sidebarlogin($args) {
|
|
146 |
// login form
|
147 |
echo '<form action="'.wp_sidebarlogin_current_url().'" method="post">';
|
148 |
?>
|
149 |
-
<p><label for="user_login"><?php
|
150 |
-
<p><label for="user_pass"><?php
|
151 |
-
<p><label for="rememberme"><input name="rememberme" class="checkbox" id="rememberme" value="forever" type="checkbox" /> <?php
|
152 |
-
<p class="submit"><input type="submit" name="wp-submit" id="wp-submit" value="<?php
|
153 |
<input type="hidden" name="sidebarlogin_posted" value="1" />
|
154 |
<input type="hidden" name="testcookie" value="1" /></p>
|
155 |
</form>
|
156 |
<?php
|
157 |
// Output other links
|
158 |
-
|
159 |
if (get_option('users_can_register') && get_option('sidebarlogin_register_link')=='yes') {
|
160 |
// MU FIX
|
161 |
global $wpmu_version;
|
162 |
if (empty($wpmu_version)) {
|
|
|
|
|
163 |
?>
|
164 |
-
<li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=register"><?php
|
165 |
<?php
|
166 |
} else {
|
|
|
|
|
167 |
?>
|
168 |
-
<li><a href="<?php bloginfo('wpurl'); ?>/wp-signup.php"><?php
|
169 |
<?php
|
170 |
}
|
171 |
}
|
172 |
-
if (get_option('sidebarlogin_forgotton_link')=='yes') :
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
|
|
|
|
177 |
}
|
178 |
// echo widget closing tag
|
179 |
echo $after_widget;
|
180 |
}
|
|
|
181 |
function widget_wp_sidebarlogin_init() {
|
182 |
if ( !function_exists('register_sidebar_widget') ) return;
|
183 |
// Register widget for use
|
184 |
register_sidebar_widget(array('Sidebar Login', 'widgets'), 'widget_wp_sidebarlogin');
|
185 |
}
|
|
|
186 |
function widget_wp_sidebarlogin_check() {
|
187 |
|
188 |
// Add options - they may not exist
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
|
195 |
-
if ($_POST['sidebarlogin_posted']
|
196 |
// Includes
|
197 |
global $myerrors;
|
198 |
$myerrors = new WP_Error();
|
@@ -200,22 +245,8 @@ function widget_wp_sidebarlogin_check() {
|
|
200 |
setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN);
|
201 |
if ( SITECOOKIEPATH != COOKIEPATH )
|
202 |
setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN);
|
203 |
-
// Logout
|
204 |
-
if ($_GET['logout']==true) {
|
205 |
-
nocache_headers();
|
206 |
-
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
207 |
-
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
208 |
-
header("Cache-Control: no-store, no-cache, must-revalidate");
|
209 |
-
header("Cache-Control: post-check=0, pre-check=0", false);
|
210 |
-
header("Pragma: no-cache");
|
211 |
-
wp_logout();
|
212 |
-
$redir = get_option('sidebarlogin_logout_redirect');
|
213 |
-
if (!empty($redir)) wp_redirect($redir);
|
214 |
-
else wp_redirect(wp_sidebarlogin_current_url('nologout'));
|
215 |
-
exit;
|
216 |
-
}
|
217 |
// Are we doing a sidebar login action?
|
218 |
-
if ($_POST['sidebarlogin_posted']) {
|
219 |
|
220 |
if ( is_ssl() && force_ssl_login() && !force_ssl_admin() && ( 0 !== strpos($redirect_to, 'https') ) && ( 0 === strpos($redirect_to, 'http') ) )
|
221 |
$secure_cookie = false;
|
@@ -231,22 +262,17 @@ function widget_wp_sidebarlogin_check() {
|
|
231 |
|
232 |
// If cookies are disabled we can't log in even with a valid user+pass
|
233 |
if ( isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE]) )
|
234 |
-
$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."));
|
235 |
|
236 |
if ( empty($_POST['log']) && empty($_POST['pwd']) ) {
|
237 |
-
$errors->add('empty_username', __('<strong>ERROR</strong>: Please enter a username.'));
|
238 |
-
$errors->add('empty_password', __('<strong>ERROR</strong>: Please enter your password.'));
|
239 |
}
|
240 |
|
241 |
$myerrors = $errors;
|
242 |
|
243 |
} else {
|
244 |
nocache_headers();
|
245 |
-
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
246 |
-
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
247 |
-
header("Cache-Control: no-store, no-cache, must-revalidate");
|
248 |
-
header("Cache-Control: post-check=0, pre-check=0", false);
|
249 |
-
header("Pragma: no-cache");
|
250 |
$redir = get_option('sidebarlogin_login_redirect');
|
251 |
if (!empty($redir)) wp_redirect($redir);
|
252 |
else wp_redirect(wp_sidebarlogin_current_url('nologout'));
|
@@ -255,6 +281,7 @@ function widget_wp_sidebarlogin_check() {
|
|
255 |
}
|
256 |
}
|
257 |
}
|
|
|
258 |
if ( !function_exists('wp_sidebarlogin_current_url') ) :
|
259 |
function wp_sidebarlogin_current_url($url = '') {
|
260 |
$pageURL = ($_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://';
|
@@ -265,25 +292,16 @@ function wp_sidebarlogin_current_url($url = '') {
|
|
265 |
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
|
266 |
}
|
267 |
|
268 |
-
if ($url
|
269 |
-
if (strstr($pageURL,'?')) {
|
270 |
-
$pageURL .='&logout=true&action=logout';
|
271 |
-
} else {
|
272 |
-
$pageURL .='?logout=true&action=logout';
|
273 |
-
}
|
274 |
-
} elseif ($url != "nologout") {
|
275 |
$pageURL .='#login';
|
276 |
}
|
277 |
-
if ($url == "nologout" && strstr($pageURL,'logout')==true) {
|
278 |
-
$pageURL = str_replace('?logout=true&action=logout','',$pageURL);
|
279 |
-
$pageURL = str_replace('&logout=true&action=logout','',$pageURL);
|
280 |
-
}
|
281 |
//————–added by mick
|
282 |
if (!strstr(get_bloginfo('url'),'www.')) $pageURL = str_replace('www.','', $pageURL );
|
283 |
//——————–
|
284 |
return $pageURL;
|
285 |
}
|
286 |
endif;
|
|
|
287 |
// Run code and init
|
288 |
add_action('init', 'widget_wp_sidebarlogin_check',0);
|
289 |
add_action('widgets_init', 'widget_wp_sidebarlogin_init');
|
3 |
Plugin Name: Sidebar Login
|
4 |
Plugin URI: http://wordpress.org/extend/plugins/sidebar-login/
|
5 |
Description: Adds a sidebar widget to let users login
|
6 |
+
Version: 2.2
|
7 |
Author: Mike Jolley
|
8 |
Author URI: http://blue-anvil.com
|
9 |
*/
|
14 |
add_management_page(__('Sidebar Login','sblogin'), __('Sidebar Login','sblogin'), 6,'Sidebar Login', 'wp_sidebarlogin_admin');
|
15 |
}
|
16 |
|
17 |
+
if (!function_exists('wp_sidebarlogin_magic')) {
|
18 |
function wp_sidebarlogin_magic() {
|
19 |
function stripit($in) {
|
20 |
if (!is_array($in)) $out = stripslashes($in); else $out = $in;
|
21 |
return $out;
|
22 |
}
|
23 |
+
$_GET = array_map('stripit', $_GET);
|
24 |
+
$_POST = array_map('stripit', $_POST);
|
25 |
+
$_REQUEST = array_map('stripit', $_REQUEST);
|
|
|
26 |
return;
|
27 |
}
|
28 |
+
}
|
29 |
|
30 |
if (!function_exists(is_ssl)) :
|
31 |
function is_ssl() {
|
59 |
<form action="?page=Sidebar Login" method="post">
|
60 |
<table class="niceblue form-table">
|
61 |
<tr>
|
62 |
+
<th scope="col"><?php _e('Login redirect URL',"sblogin"); ?>:</th>
|
63 |
<td><input type="text" name="sidebarlogin_login_redirect" value="<?php echo $sidebarlogin_login_redirect; ?>" /> <span class="setting-description"><?php _e('Url to redirect the user to after login. Leave blank to use their current page.','sblogin'); ?></span></td>
|
64 |
</tr>
|
65 |
<tr>
|
66 |
+
<th scope="col"><?php _e('Logout redirect URL',"sblogin"); ?>:</th>
|
67 |
<td><input type="text" name="sidebarlogin_logout_redirect" value="<?php echo $sidebarlogin_logout_redirect; ?>" /> <span class="setting-description"><?php _e('Url to redirect the user to after logout. Leave blank to use their current page.','sblogin'); ?></span></td>
|
68 |
</tr>
|
69 |
<tr>
|
70 |
+
<th scope="col"><?php _e('Show Register Link',"sblogin"); ?>:</th>
|
71 |
<td><select name="sidebarlogin_register_link">
|
72 |
<option <?php if ($sidebarlogin_register_link=='yes') echo 'selected="selected"'; ?> value="yes"><?php _e('Yes','sblogin'); ?></option>
|
73 |
<option <?php if ($sidebarlogin_register_link=='no') echo 'selected="selected"'; ?> value="no"><?php _e('No','sblogin'); ?></option>
|
74 |
</select> <span class="setting-description"><?php _e('User registrations must also be turned on for this to work (\'Anyone can register\' checkbox in settings).','sblogin'); ?></span></td>
|
75 |
</tr>
|
76 |
<tr>
|
77 |
+
<th scope="col"><?php _e('Show Lost Password Link',"sblogin"); ?>:</th>
|
78 |
<td><select name="sidebarlogin_forgotton_link">
|
79 |
<option <?php if ($sidebarlogin_forgotton_link=='yes') echo 'selected="selected"'; ?> value="yes"><?php _e('Yes','sblogin'); ?></option>
|
80 |
<option <?php if ($sidebarlogin_forgotton_link=='no') echo 'selected="selected"'; ?> value="no"><?php _e('No','sblogin'); ?></option>
|
81 |
</select></td>
|
82 |
</tr>
|
83 |
<tr>
|
84 |
+
<th scope="col"><?php _e('Logged in links',"sblogin"); ?>:</th>
|
85 |
+
<td><textarea name="sidebarlogin_logged_in_links" rows="3" cols="80" /><?php echo $sidebarlogin_logged_in_links; ?></textarea><br/><span class="setting-description"><?php _e('One link per line. Note: Logout link will always show regardless. Tip: Add <code>|true</code> after a link to only show it to admin users. Default: <br/><a href="http://localhost:8888/wordpress27/wp-admin/">Dashboard</a><br/><a href="http://localhost:8888/wordpress27/wp-admin/profile.php">Profile</a>','sblogin'); ?></span></td>
|
86 |
</tr>
|
87 |
</table>
|
88 |
<p class="submit"><input type="submit" value="<?php _e('Save Changes',"sblogin"); ?>" /></p>
|
91 |
<?php
|
92 |
}
|
93 |
|
94 |
+
/*
|
95 |
+
example of short call with text
|
96 |
+
|
97 |
+
sidebarlogin('before_title=<h5>&after_title='</h5>');
|
98 |
+
|
99 |
+
suggested by dev.xiligroup.com
|
100 |
+
*/
|
101 |
+
|
102 |
+
function sidebarlogin($myargs = '') {
|
103 |
+
if (is_array($myargs)) $args = &$myargs;
|
104 |
+
else parse_str($myargs, $args);
|
105 |
+
|
106 |
+
$defaults = array('before_widget'=>'','after_widget'=>'',
|
107 |
+
'before_title'=>'<h2>','after_title'=>'</h2>'
|
108 |
+
);
|
109 |
+
$args = array_merge($defaults, $args);
|
110 |
+
|
111 |
widget_wp_sidebarlogin($args);
|
112 |
}
|
113 |
+
|
114 |
function widget_wp_sidebarlogin($args) {
|
|
|
|
|
|
|
115 |
global $user_ID, $current_user;
|
116 |
+
|
117 |
+
/* To add more extend i.e when terms came from themes - suggested by dev.xiligroup.com */
|
118 |
+
$defaults = array('thelogin'=>__('Login','sblogin'),
|
119 |
+
'thewelcome'=>__("Welcome",'sblogin'),
|
120 |
+
'theusername'=>__('Username:','sblogin'),
|
121 |
+
'thepassword'=>__('Password:','sblogin'),
|
122 |
+
'theremember'=>__('Remember me','sblogin'),
|
123 |
+
'theregister'=>__('Register','sblogin'),
|
124 |
+
'thepasslostandfound'=>__('Password Lost and Found','sblogin'),
|
125 |
+
'thelostpass'=> __('Lost your password?','sblogin'),
|
126 |
+
'thelogout'=> __('Logout','sblogin'),
|
127 |
+
'thelogin'=> __('Login','sblogin')
|
128 |
+
);
|
129 |
+
|
130 |
+
$args = array_merge($defaults, $args);
|
131 |
+
extract($args);
|
132 |
+
|
133 |
get_currentuserinfo();
|
134 |
|
135 |
if ($user_ID != '') {
|
136 |
// User is logged in
|
137 |
+
echo $before_widget . $before_title .$thewelcome.' '.$current_user->display_name . $after_title;
|
138 |
echo '<ul class="pagenav">';
|
139 |
|
140 |
+
$user_info = get_userdata($user_ID);
|
141 |
+
$level = $user_info->user_level;
|
142 |
+
|
143 |
$links = get_option('sidebarlogin_logged_in_links');
|
144 |
$links = explode("\n", $links);
|
145 |
if (sizeof($links)>0)
|
146 |
foreach ($links as $l) {
|
147 |
+
$link = explode('|',$l);
|
148 |
+
if (strtolower(trim($link[1]))=='true' && $level!=10) continue;
|
149 |
+
echo '<li class="page_item">'.$link[0].'</li>';
|
150 |
}
|
151 |
+
|
152 |
+
$redir = get_option('sidebarlogin_logout_redirect');
|
153 |
+
if (empty($redir)) $redir = wp_sidebarlogin_current_url('nologout');
|
154 |
+
|
155 |
+
echo '<li class="page_item"><a href="'.wp_logout_url($redirect).'&redirect_to='.$redir.'">'.$thelogout.'</a></li></ul>';
|
156 |
+
|
157 |
} else {
|
158 |
// User is NOT logged in!!!
|
159 |
+
echo $before_widget . $before_title . $thelogin . $after_title;
|
160 |
// Show any errors
|
161 |
global $myerrors;
|
162 |
$wp_error = new WP_Error();
|
183 |
// login form
|
184 |
echo '<form action="'.wp_sidebarlogin_current_url().'" method="post">';
|
185 |
?>
|
186 |
+
<p><label for="user_login"><?php echo $theusername; ?><br/><input name="log" value="<?php echo attribute_escape(stripslashes($_POST['log'])); ?>" class="mid" id="user_login" type="text" /></label></p>
|
187 |
+
<p><label for="user_pass"><?php echo $thepassword; ?><br/><input name="pwd" class="mid" id="user_pass" type="password" /></label></p>
|
188 |
+
<p><label for="rememberme"><input name="rememberme" class="checkbox" id="rememberme" value="forever" type="checkbox" /> <?php echo $theremember; ?></label></p>
|
189 |
+
<p class="submit"><input type="submit" name="wp-submit" id="wp-submit" value="<?php echo $thelogin; ?> »" />
|
190 |
<input type="hidden" name="sidebarlogin_posted" value="1" />
|
191 |
<input type="hidden" name="testcookie" value="1" /></p>
|
192 |
</form>
|
193 |
<?php
|
194 |
// Output other links
|
195 |
+
$isul = false; /* ms for w3c - suggested by dev.xiligroup.com */
|
196 |
if (get_option('users_can_register') && get_option('sidebarlogin_register_link')=='yes') {
|
197 |
// MU FIX
|
198 |
global $wpmu_version;
|
199 |
if (empty($wpmu_version)) {
|
200 |
+
echo '<ul class="sidebarlogin_otherlinks">';
|
201 |
+
$isul= true;
|
202 |
?>
|
203 |
+
<li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=register" rel="nofollow"><?php echo $theregister; ?></a></li>
|
204 |
<?php
|
205 |
} else {
|
206 |
+
echo '<ul class="sidebarlogin_otherlinks">';
|
207 |
+
$isul= true;
|
208 |
?>
|
209 |
+
<li><a href="<?php bloginfo('wpurl'); ?>/wp-signup.php" rel="nofollow"><?php echo $theregister; ?></a></li>
|
210 |
<?php
|
211 |
}
|
212 |
}
|
213 |
+
if (get_option('sidebarlogin_forgotton_link')=='yes') :
|
214 |
+
if ($isul== false) echo '<ul class="sidebarlogin_otherlinks">';
|
215 |
+
?>
|
216 |
+
<li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=lostpassword" title="<?php echo $thepasslostfound; ?>" rel="nofollow"><?php echo $thelostpass; ?></a></li>
|
217 |
+
<?php
|
218 |
+
endif;
|
219 |
+
if ($isul) echo '</ul>';
|
220 |
}
|
221 |
// echo widget closing tag
|
222 |
echo $after_widget;
|
223 |
}
|
224 |
+
|
225 |
function widget_wp_sidebarlogin_init() {
|
226 |
if ( !function_exists('register_sidebar_widget') ) return;
|
227 |
// Register widget for use
|
228 |
register_sidebar_widget(array('Sidebar Login', 'widgets'), 'widget_wp_sidebarlogin');
|
229 |
}
|
230 |
+
|
231 |
function widget_wp_sidebarlogin_check() {
|
232 |
|
233 |
// Add options - they may not exist
|
234 |
+
add_option('sidebarlogin_login_redirect','','no');
|
235 |
+
add_option('sidebarlogin_logout_redirect','','no');
|
236 |
+
add_option('sidebarlogin_register_link','yes','no');
|
237 |
+
add_option('sidebarlogin_forgotton_link','yes','no');
|
238 |
+
add_option('sidebarlogin_logged_in_links', "<a href=\"".get_bloginfo('wpurl')."/wp-admin/\">".__('Dashboard')."</a>\n<a href=\"".get_bloginfo('wpurl')."/wp-admin/profile.php\">".__('Profile')."</a>",'no');
|
239 |
|
240 |
+
if ($_POST['sidebarlogin_posted']) {
|
241 |
// Includes
|
242 |
global $myerrors;
|
243 |
$myerrors = new WP_Error();
|
245 |
setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN);
|
246 |
if ( SITECOOKIEPATH != COOKIEPATH )
|
247 |
setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
// Are we doing a sidebar login action?
|
249 |
+
if ($_POST['sidebarlogin_posted']) {
|
250 |
|
251 |
if ( is_ssl() && force_ssl_login() && !force_ssl_admin() && ( 0 !== strpos($redirect_to, 'https') ) && ( 0 === strpos($redirect_to, 'http') ) )
|
252 |
$secure_cookie = false;
|
262 |
|
263 |
// If cookies are disabled we can't log in even with a valid user+pass
|
264 |
if ( isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE]) )
|
265 |
+
$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.", 'sblogin'));
|
266 |
|
267 |
if ( empty($_POST['log']) && empty($_POST['pwd']) ) {
|
268 |
+
$errors->add('empty_username', __('<strong>ERROR</strong>: Please enter a username.', 'sblogin'));
|
269 |
+
$errors->add('empty_password', __('<strong>ERROR</strong>: Please enter your password.', 'sblogin'));
|
270 |
}
|
271 |
|
272 |
$myerrors = $errors;
|
273 |
|
274 |
} else {
|
275 |
nocache_headers();
|
|
|
|
|
|
|
|
|
|
|
276 |
$redir = get_option('sidebarlogin_login_redirect');
|
277 |
if (!empty($redir)) wp_redirect($redir);
|
278 |
else wp_redirect(wp_sidebarlogin_current_url('nologout'));
|
281 |
}
|
282 |
}
|
283 |
}
|
284 |
+
|
285 |
if ( !function_exists('wp_sidebarlogin_current_url') ) :
|
286 |
function wp_sidebarlogin_current_url($url = '') {
|
287 |
$pageURL = ($_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://';
|
292 |
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
|
293 |
}
|
294 |
|
295 |
+
if ($url != "nologout") {
|
|
|
|
|
|
|
|
|
|
|
|
|
296 |
$pageURL .='#login';
|
297 |
}
|
|
|
|
|
|
|
|
|
298 |
//————–added by mick
|
299 |
if (!strstr(get_bloginfo('url'),'www.')) $pageURL = str_replace('www.','', $pageURL );
|
300 |
//——————–
|
301 |
return $pageURL;
|
302 |
}
|
303 |
endif;
|
304 |
+
|
305 |
// Run code and init
|
306 |
add_action('init', 'widget_wp_sidebarlogin_check',0);
|
307 |
add_action('widgets_init', 'widget_wp_sidebarlogin_init');
|