Version Description
Download this release
Release Info
Developer | jolley_small |
Plugin | Sidebar Login |
Version | 2.1.6 |
Comparing to | |
See all releases |
Code changes from version 2.1.5 to 2.1.6
- readme.txt +1 -1
- sidebar-login.php +41 -39
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.1.
|
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.1.6
|
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.1.
|
7 |
Author: Mike Jolley
|
8 |
Author URI: http://blue-anvil.com
|
9 |
*/
|
@@ -13,7 +13,6 @@ load_plugin_textdomain('sblogin','wp-content/plugins/sidebar-login/');
|
|
13 |
function wp_sidebarlogin_menu() {
|
14 |
add_management_page(__('Sidebar Login','sblogin'), __('Sidebar Login','sblogin'), 6,'Sidebar Login', 'wp_sidebarlogin_admin');
|
15 |
}
|
16 |
-
add_action('admin_menu', 'wp_sidebarlogin_menu');
|
17 |
|
18 |
function wp_sidebarlogin_magic() {
|
19 |
function stripit($in) {
|
@@ -60,44 +59,38 @@ function wp_sidebarlogin_admin(){
|
|
60 |
<table class="niceblue form-table">
|
61 |
<tr>
|
62 |
<th scope="col"><?php _e('Login redirect URL',"wp-download_monitor"); ?>:</th>
|
63 |
-
<td><input type="text" name="sidebarlogin_login_redirect" value="<?php echo $sidebarlogin_login_redirect; ?>" /> <span class="setting-description"
|
64 |
</tr>
|
65 |
<tr>
|
66 |
<th scope="col"><?php _e('Logout redirect URL',"wp-download_monitor"); ?>:</th>
|
67 |
-
<td><input type="text" name="sidebarlogin_logout_redirect" value="<?php echo $sidebarlogin_logout_redirect; ?>" /> <span class="setting-description"
|
68 |
</tr>
|
69 |
<tr>
|
70 |
<th scope="col"><?php _e('Show Register Link',"wp-download_monitor"); ?>:</th>
|
71 |
<td><select name="sidebarlogin_register_link">
|
72 |
-
<option <?php if ($sidebarlogin_register_link=='yes') echo 'selected="selected"'; ?> value="yes"
|
73 |
-
<option <?php if ($sidebarlogin_register_link=='no') echo 'selected="selected"'; ?> value="no"
|
74 |
-
</select> <span class="setting-description"
|
75 |
</tr>
|
76 |
<tr>
|
77 |
<th scope="col"><?php _e('Show Lost Password Link',"wp-download_monitor"); ?>:</th>
|
78 |
<td><select name="sidebarlogin_forgotton_link">
|
79 |
-
<option <?php if ($sidebarlogin_forgotton_link=='yes') echo 'selected="selected"'; ?> value="yes"
|
80 |
-
<option <?php if ($sidebarlogin_forgotton_link=='no') echo 'selected="selected"'; ?> value="no"
|
81 |
</select></td>
|
82 |
</tr>
|
83 |
<tr>
|
84 |
<th scope="col"><?php _e('Logged in links',"wp-download_monitor"); ?>:</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"
|
86 |
</tr>
|
87 |
</table>
|
88 |
-
<p class="submit"><input type="submit" value="<?php _e('Save Changes',"
|
89 |
</form>
|
90 |
</div>
|
91 |
<?php
|
92 |
}
|
93 |
|
94 |
function sidebarlogin() {
|
95 |
-
// Add options - they may not exist
|
96 |
-
add_option('sidebarlogin_login_redirect','','no');
|
97 |
-
add_option('sidebarlogin_logout_redirect','','no');
|
98 |
-
add_option('sidebarlogin_register_link','yes','no');
|
99 |
-
add_option('sidebarlogin_forgotton_link','yes','no');
|
100 |
-
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');
|
101 |
$args["before_widget"]="";
|
102 |
$args["after_widget"]="";
|
103 |
$args["before_title"]="<h2>";
|
@@ -107,14 +100,14 @@ function sidebarlogin() {
|
|
107 |
function widget_wp_sidebarlogin($args) {
|
108 |
|
109 |
extract($args);
|
110 |
-
|
111 |
global $current_user;
|
112 |
get_currentuserinfo();
|
113 |
|
114 |
|
115 |
if ($current_user->user_level > 0) {
|
116 |
// User is logged in
|
117 |
-
echo $before_widget . $before_title . __("Welcome
|
118 |
echo '<ul class="pagenav">';
|
119 |
|
120 |
$links = get_option('sidebarlogin_logged_in_links');
|
@@ -123,7 +116,7 @@ function widget_wp_sidebarlogin($args) {
|
|
123 |
foreach ($links as $l) {
|
124 |
echo '<li class="page_item">'.$l.'</li>';
|
125 |
}
|
126 |
-
echo '<li class="page_item"><a href="'.
|
127 |
</ul>';
|
128 |
} else {
|
129 |
// User is NOT logged in!!!
|
@@ -152,12 +145,12 @@ function widget_wp_sidebarlogin($args) {
|
|
152 |
echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n";
|
153 |
}
|
154 |
// login form
|
155 |
-
echo '<form action="'.
|
156 |
?>
|
157 |
-
<p><label for="user_login"><?php _e('Username:') ?><br/><input name="log" value="<?php echo attribute_escape(stripslashes($_POST['log'])); ?>" class="mid" id="user_login" type="text" /></label></p>
|
158 |
-
<p><label for="user_pass"><?php _e('Password:') ?><br/><input name="pwd" class="mid" id="user_pass" type="password" /></label></p>
|
159 |
<p><label for="rememberme"><input name="rememberme" class="checkbox" id="rememberme" value="forever" type="checkbox" /> <?php _e('Remember me'); ?></label></p>
|
160 |
-
<p class="submit"><input type="submit" name="wp-submit" id="wp-submit" value="<?php _e('Login'); ?> »" />
|
161 |
<input type="hidden" name="sidebarlogin_posted" value="1" />
|
162 |
<input type="hidden" name="testcookie" value="1" /></p>
|
163 |
</form>
|
@@ -169,16 +162,16 @@ function widget_wp_sidebarlogin($args) {
|
|
169 |
global $wpmu_version;
|
170 |
if (empty($wpmu_version)) {
|
171 |
?>
|
172 |
-
<li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=register"><?php _e('Register') ?></a></li>
|
173 |
<?php
|
174 |
} else {
|
175 |
?>
|
176 |
-
<li><a href="<?php bloginfo('wpurl'); ?>/wp-signup.php"><?php _e('Register') ?></a></li>
|
177 |
<?php
|
178 |
}
|
179 |
}
|
180 |
if (get_option('sidebarlogin_forgotton_link')=='yes') : ?>
|
181 |
-
<li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=lostpassword" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a></li>
|
182 |
<?php endif; ?>
|
183 |
</ul>
|
184 |
<?php
|
@@ -192,6 +185,14 @@ function widget_wp_sidebarlogin_init() {
|
|
192 |
register_sidebar_widget(array('Sidebar Login', 'widgets'), 'widget_wp_sidebarlogin');
|
193 |
}
|
194 |
function widget_wp_sidebarlogin_check() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
if ($_POST['sidebarlogin_posted'] || $_GET['logout']) {
|
196 |
// Includes
|
197 |
global $myerrors;
|
@@ -211,7 +212,7 @@ function widget_wp_sidebarlogin_check() {
|
|
211 |
wp_logout();
|
212 |
$redir = get_option('sidebarlogin_logout_redirect');
|
213 |
if (!empty($redir)) wp_redirect($redir);
|
214 |
-
else wp_redirect(
|
215 |
exit;
|
216 |
}
|
217 |
// Are we doing a sidebar login action?
|
@@ -249,27 +250,27 @@ function widget_wp_sidebarlogin_check() {
|
|
249 |
header("Pragma: no-cache");
|
250 |
$redir = get_option('sidebarlogin_login_redirect');
|
251 |
if (!empty($redir)) wp_redirect($redir);
|
252 |
-
else wp_redirect(
|
253 |
exit;
|
254 |
}
|
255 |
}
|
256 |
}
|
257 |
}
|
258 |
-
if ( !function_exists('
|
259 |
-
function
|
260 |
-
$pageURL = 'http';
|
261 |
-
|
262 |
-
$pageURL .= "://www.";
|
263 |
if ($_SERVER["SERVER_PORT"] != "80") {
|
264 |
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
|
265 |
} else {
|
266 |
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
|
267 |
}
|
|
|
268 |
if ($url == "logout" && strstr($pageURL,'logout')==false) {
|
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';
|
@@ -278,13 +279,14 @@ function current_url($url = '') {
|
|
278 |
$pageURL = str_replace('?logout=true&action=logout','',$pageURL);
|
279 |
$pageURL = str_replace('&logout=true&action=logout','',$pageURL);
|
280 |
}
|
281 |
-
|
282 |
-
if (!strstr(get_bloginfo('
|
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');
|
|
|
290 |
?>
|
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.1.6
|
7 |
Author: Mike Jolley
|
8 |
Author URI: http://blue-anvil.com
|
9 |
*/
|
13 |
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) {
|
59 |
<table class="niceblue form-table">
|
60 |
<tr>
|
61 |
<th scope="col"><?php _e('Login redirect URL',"wp-download_monitor"); ?>:</th>
|
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',"wp-download_monitor"); ?>:</th>
|
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',"wp-download_monitor"); ?>:</th>
|
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',"wp-download_monitor"); ?>:</th>
|
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',"wp-download_monitor"); ?>:</th>
|
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 (e.g. <code><a href="http://Yoursite.com/wp-admin/">Dashboard</a></code>). Logout link will always show regardless.','sblogin'); ?></span></td>
|
85 |
</tr>
|
86 |
</table>
|
87 |
+
<p class="submit"><input type="submit" value="<?php _e('Save Changes',"sblogin"); ?>" /></p>
|
88 |
</form>
|
89 |
</div>
|
90 |
<?php
|
91 |
}
|
92 |
|
93 |
function sidebarlogin() {
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
$args["before_widget"]="";
|
95 |
$args["after_widget"]="";
|
96 |
$args["before_title"]="<h2>";
|
100 |
function widget_wp_sidebarlogin($args) {
|
101 |
|
102 |
extract($args);
|
103 |
+
|
104 |
global $current_user;
|
105 |
get_currentuserinfo();
|
106 |
|
107 |
|
108 |
if ($current_user->user_level > 0) {
|
109 |
// User is logged in
|
110 |
+
echo $before_widget . $before_title . __("Welcome",'sblogin').' '.$current_user->display_name . $after_title;
|
111 |
echo '<ul class="pagenav">';
|
112 |
|
113 |
$links = get_option('sidebarlogin_logged_in_links');
|
116 |
foreach ($links as $l) {
|
117 |
echo '<li class="page_item">'.$l.'</li>';
|
118 |
}
|
119 |
+
echo '<li class="page_item"><a href="'.wp_sidebarlogin_current_url('logout').'">'.__('Logout').'</a></li>
|
120 |
</ul>';
|
121 |
} else {
|
122 |
// User is NOT logged in!!!
|
145 |
echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n";
|
146 |
}
|
147 |
// login form
|
148 |
+
echo '<form action="'.wp_sidebarlogin_current_url().'" method="post">';
|
149 |
?>
|
150 |
+
<p><label for="user_login"><?php _e('Username:','sblogin'); ?><br/><input name="log" value="<?php echo attribute_escape(stripslashes($_POST['log'])); ?>" class="mid" id="user_login" type="text" /></label></p>
|
151 |
+
<p><label for="user_pass"><?php _e('Password:','sblogin'); ?><br/><input name="pwd" class="mid" id="user_pass" type="password" /></label></p>
|
152 |
<p><label for="rememberme"><input name="rememberme" class="checkbox" id="rememberme" value="forever" type="checkbox" /> <?php _e('Remember me'); ?></label></p>
|
153 |
+
<p class="submit"><input type="submit" name="wp-submit" id="wp-submit" value="<?php _e('Login','sblogin'); ?> »" />
|
154 |
<input type="hidden" name="sidebarlogin_posted" value="1" />
|
155 |
<input type="hidden" name="testcookie" value="1" /></p>
|
156 |
</form>
|
162 |
global $wpmu_version;
|
163 |
if (empty($wpmu_version)) {
|
164 |
?>
|
165 |
+
<li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=register"><?php _e('Register','sblogin'); ?></a></li>
|
166 |
<?php
|
167 |
} else {
|
168 |
?>
|
169 |
+
<li><a href="<?php bloginfo('wpurl'); ?>/wp-signup.php"><?php _e('Register','sblogin'); ?></a></li>
|
170 |
<?php
|
171 |
}
|
172 |
}
|
173 |
if (get_option('sidebarlogin_forgotton_link')=='yes') : ?>
|
174 |
+
<li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=lostpassword" title="<?php _e('Password Lost and Found','sblogin'); ?>"><?php _e('Lost your password?','sblogin'); ?></a></li>
|
175 |
<?php endif; ?>
|
176 |
</ul>
|
177 |
<?php
|
185 |
register_sidebar_widget(array('Sidebar Login', 'widgets'), 'widget_wp_sidebarlogin');
|
186 |
}
|
187 |
function widget_wp_sidebarlogin_check() {
|
188 |
+
|
189 |
+
// Add options - they may not exist
|
190 |
+
add_option('sidebarlogin_login_redirect','','no');
|
191 |
+
add_option('sidebarlogin_logout_redirect','','no');
|
192 |
+
add_option('sidebarlogin_register_link','yes','no');
|
193 |
+
add_option('sidebarlogin_forgotton_link','yes','no');
|
194 |
+
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');
|
195 |
+
|
196 |
if ($_POST['sidebarlogin_posted'] || $_GET['logout']) {
|
197 |
// Includes
|
198 |
global $myerrors;
|
212 |
wp_logout();
|
213 |
$redir = get_option('sidebarlogin_logout_redirect');
|
214 |
if (!empty($redir)) wp_redirect($redir);
|
215 |
+
else wp_redirect(wp_sidebarlogin_current_url('nologout'));
|
216 |
exit;
|
217 |
}
|
218 |
// Are we doing a sidebar login action?
|
250 |
header("Pragma: no-cache");
|
251 |
$redir = get_option('sidebarlogin_login_redirect');
|
252 |
if (!empty($redir)) wp_redirect($redir);
|
253 |
+
else wp_redirect(wp_sidebarlogin_current_url('nologout'));
|
254 |
exit;
|
255 |
}
|
256 |
}
|
257 |
}
|
258 |
}
|
259 |
+
if ( !function_exists('wp_sidebarlogin_current_url') ) :
|
260 |
+
function wp_sidebarlogin_current_url($url = '') {
|
261 |
+
$pageURL = ($_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://';
|
262 |
+
|
|
|
263 |
if ($_SERVER["SERVER_PORT"] != "80") {
|
264 |
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
|
265 |
} else {
|
266 |
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
|
267 |
}
|
268 |
+
|
269 |
if ($url == "logout" && strstr($pageURL,'logout')==false) {
|
270 |
if (strstr($pageURL,'?')) {
|
271 |
+
$pageURL .='&logout=true&action=logout';
|
272 |
} else {
|
273 |
+
$pageURL .='?logout=true&action=logout';
|
274 |
}
|
275 |
} elseif ($url != "nologout") {
|
276 |
$pageURL .='#login';
|
279 |
$pageURL = str_replace('?logout=true&action=logout','',$pageURL);
|
280 |
$pageURL = str_replace('&logout=true&action=logout','',$pageURL);
|
281 |
}
|
282 |
+
//————–added by mick
|
283 |
+
if (!strstr(get_bloginfo('url'),'www.')) $pageURL = str_replace('www.','', $pageURL );
|
284 |
+
//——————–
|
285 |
return $pageURL;
|
286 |
}
|
287 |
endif;
|
288 |
// Run code and init
|
289 |
add_action('init', 'widget_wp_sidebarlogin_check',0);
|
290 |
add_action('widgets_init', 'widget_wp_sidebarlogin_init');
|
291 |
+
add_action('admin_menu', 'wp_sidebarlogin_menu');
|
292 |
?>
|