Version Description
Download this release
Release Info
Developer | jolley_small |
Plugin | Sidebar Login |
Version | 2.1.5 |
Comparing to | |
See all releases |
Code changes from version 2.1.2 to 2.1.5
- readme.txt +6 -2
- sidebar-login.php +141 -28
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: jolley_small
|
|
3 |
Donate link: http://blue-anvil.com/archives/wordpress-sidebar-login-2-optimised-for-wordpress-26
|
4 |
Tags: login, sidebar, widget, sidebar login, meta, form, register
|
5 |
Requires at least: 2.5
|
6 |
-
Tested up to: 2.
|
7 |
-
Stable tag: 2.1.
|
8 |
|
9 |
Adds a sidebar widget to let users login.
|
10 |
|
@@ -22,6 +22,10 @@ It lets users login, and then redirects them back to the page they logged in fro
|
|
22 |
2. Activate the plugin
|
23 |
3. For a sidebar widget: Goto the design > widgets tab - Drag the widget into a sidebar and save!
|
24 |
4. To use the template tag: Add <?php sidebarlogin(); ?> to your template.
|
|
|
|
|
|
|
|
|
25 |
|
26 |
== Screenshots ==
|
27 |
|
3 |
Donate link: http://blue-anvil.com/archives/wordpress-sidebar-login-2-optimised-for-wordpress-26
|
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.5
|
8 |
|
9 |
Adds a sidebar widget to let users login.
|
10 |
|
22 |
2. Activate the plugin
|
23 |
3. For a sidebar widget: Goto the design > widgets tab - Drag the widget into a sidebar and save!
|
24 |
4. To use the template tag: Add <?php sidebarlogin(); ?> to your template.
|
25 |
+
|
26 |
+
= Configuration =
|
27 |
+
|
28 |
+
You will find a config page in tools/settings > Sidebar Login. Here you can set links and redirects up.
|
29 |
|
30 |
== Screenshots ==
|
31 |
|
sidebar-login.php
CHANGED
@@ -3,31 +3,127 @@
|
|
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 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
function sidebarlogin() {
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
$args["before_widget"]="";
|
12 |
$args["after_widget"]="";
|
13 |
$args["before_title"]="<h2>";
|
14 |
$args["after_title"]="</h2>";
|
15 |
-
|
16 |
}
|
17 |
-
function
|
18 |
|
19 |
extract($args);
|
20 |
|
21 |
-
global $
|
|
|
22 |
|
23 |
-
|
|
|
24 |
// User is logged in
|
25 |
-
$
|
26 |
-
echo
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
31 |
</ul>';
|
32 |
} else {
|
33 |
// User is NOT logged in!!!
|
@@ -56,7 +152,7 @@ function widget_sidebarlogin($args) {
|
|
56 |
echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n";
|
57 |
}
|
58 |
// login form
|
59 |
-
echo '<form action="'.current_url().'" method="post"
|
60 |
?>
|
61 |
<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>
|
62 |
<p><label for="user_pass"><?php _e('Password:') ?><br/><input name="pwd" class="mid" id="user_pass" type="password" /></label></p>
|
@@ -68,7 +164,7 @@ function widget_sidebarlogin($args) {
|
|
68 |
<?php
|
69 |
// Output other links
|
70 |
echo '<ul class="sidebarlogin_otherlinks">';
|
71 |
-
if (get_option('users_can_register')) {
|
72 |
// MU FIX
|
73 |
global $wpmu_version;
|
74 |
if (empty($wpmu_version)) {
|
@@ -81,23 +177,23 @@ function widget_sidebarlogin($args) {
|
|
81 |
<?php
|
82 |
}
|
83 |
}
|
84 |
-
?>
|
85 |
<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>
|
|
|
86 |
</ul>
|
87 |
<?php
|
88 |
}
|
89 |
// echo widget closing tag
|
90 |
echo $after_widget;
|
91 |
}
|
92 |
-
function
|
93 |
if ( !function_exists('register_sidebar_widget') ) return;
|
94 |
// Register widget for use
|
95 |
-
register_sidebar_widget(array('Sidebar Login', 'widgets'), '
|
96 |
}
|
97 |
-
function
|
98 |
if ($_POST['sidebarlogin_posted'] || $_GET['logout']) {
|
99 |
// Includes
|
100 |
-
//include_once('wp-settings.php');
|
101 |
global $myerrors;
|
102 |
$myerrors = new WP_Error();
|
103 |
//Set a cookie now to see if they are supported by the browser.
|
@@ -107,9 +203,16 @@ function widget_sidebarlogin_check() {
|
|
107 |
// Logout
|
108 |
if ($_GET['logout']==true) {
|
109 |
nocache_headers();
|
|
|
|
|
|
|
|
|
|
|
110 |
wp_logout();
|
111 |
-
|
112 |
-
|
|
|
|
|
113 |
}
|
114 |
// Are we doing a sidebar login action?
|
115 |
if ($_POST['sidebarlogin_posted']) {
|
@@ -138,7 +241,15 @@ function widget_sidebarlogin_check() {
|
|
138 |
$myerrors = $errors;
|
139 |
|
140 |
} else {
|
141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
exit;
|
143 |
}
|
144 |
}
|
@@ -148,7 +259,7 @@ if ( !function_exists('current_url') ) :
|
|
148 |
function current_url($url = '') {
|
149 |
$pageURL = 'http';
|
150 |
if ($_SERVER["HTTPS"] == "on") $pageURL .= "s";
|
151 |
-
$pageURL .= "://";
|
152 |
if ($_SERVER["SERVER_PORT"] != "80") {
|
153 |
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
|
154 |
} else {
|
@@ -156,14 +267,16 @@ function current_url($url = '') {
|
|
156 |
}
|
157 |
if ($url == "logout" && strstr($pageURL,'logout')==false) {
|
158 |
if (strstr($pageURL,'?')) {
|
159 |
-
$pageURL .='&logout=true';
|
160 |
} else {
|
161 |
-
$pageURL .='?logout=true';
|
162 |
}
|
|
|
|
|
163 |
}
|
164 |
if ($url == "nologout" && strstr($pageURL,'logout')==true) {
|
165 |
-
$pageURL = str_replace('?logout=true','',$pageURL);
|
166 |
-
$pageURL = str_replace('&logout=true','',$pageURL);
|
167 |
}
|
168 |
//�����added by mick
|
169 |
if (!strstr(get_bloginfo('wpurl'),'www.')) $pageURL = str_replace('www.','', $pageURL );
|
@@ -172,6 +285,6 @@ function current_url($url = '') {
|
|
172 |
}
|
173 |
endif;
|
174 |
// Run code and init
|
175 |
-
add_action('init', '
|
176 |
-
add_action('widgets_init', '
|
177 |
?>
|
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.5
|
7 |
Author: Mike Jolley
|
8 |
Author URI: http://blue-anvil.com
|
9 |
*/
|
10 |
+
|
11 |
+
load_plugin_textdomain('sblogin','wp-content/plugins/sidebar-login/');
|
12 |
+
|
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) {
|
20 |
+
if (!is_array($in)) $out = stripslashes($in); else $out = $in;
|
21 |
+
return $out;
|
22 |
+
}
|
23 |
+
if (get_magic_quotes_gpc()){
|
24 |
+
$_GET = array_map('stripit', $_GET);
|
25 |
+
$_POST = array_map('stripit', $_POST);
|
26 |
+
}
|
27 |
+
return;
|
28 |
+
}
|
29 |
+
|
30 |
+
if (!function_exists(is_ssl)) :
|
31 |
+
function is_ssl() {
|
32 |
+
return ( isset($_SERVER['HTTPS']) && 'on' == strtolower($_SERVER['HTTPS']) ) ? true : false;
|
33 |
+
}
|
34 |
+
endif;
|
35 |
+
|
36 |
+
function wp_sidebarlogin_admin(){
|
37 |
+
// Update options
|
38 |
+
if ($_POST) {
|
39 |
+
wp_sidebarlogin_magic();
|
40 |
+
update_option('sidebarlogin_login_redirect', $_POST['sidebarlogin_login_redirect']);
|
41 |
+
update_option('sidebarlogin_logout_redirect', $_POST['sidebarlogin_logout_redirect']);
|
42 |
+
update_option('sidebarlogin_register_link', $_POST['sidebarlogin_register_link']);
|
43 |
+
update_option('sidebarlogin_forgotton_link', $_POST['sidebarlogin_forgotton_link']);
|
44 |
+
update_option('sidebarlogin_logged_in_links', $_POST['sidebarlogin_logged_in_links']);
|
45 |
+
echo '<div id="message"class="updated fade">';
|
46 |
+
_e('<p>Changes saved</p>',"sblogin");
|
47 |
+
echo '</div>';
|
48 |
+
}
|
49 |
+
// Get options
|
50 |
+
$sidebarlogin_login_redirect = get_option('sidebarlogin_login_redirect');
|
51 |
+
$sidebarlogin_logout_redirect = get_option('sidebarlogin_logout_redirect');
|
52 |
+
$sidebarlogin_register_link = get_option('sidebarlogin_register_link');
|
53 |
+
$sidebarlogin_forgotton_link = get_option('sidebarlogin_forgotton_link');
|
54 |
+
$sidebarlogin_logged_in_links = get_option('sidebarlogin_logged_in_links');
|
55 |
+
?>
|
56 |
+
<div class="wrap alternate">
|
57 |
+
<h2><?php _e('Sidebar Login',"sblogin"); ?></h2>
|
58 |
+
<br class="a_break" style="clear: both;"/>
|
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',"wp-download_monitor"); ?>:</th>
|
63 |
+
<td><input type="text" name="sidebarlogin_login_redirect" value="<?php echo $sidebarlogin_login_redirect; ?>" /> <span class="setting-description">Url to redirect the user to after login. Leave blank to use their current page.</span></td>
|
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">Url to redirect the user to after logout. Leave blank to use their current page.</span></td>
|
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">Yes</option>
|
73 |
+
<option <?php if ($sidebarlogin_register_link=='no') echo 'selected="selected"'; ?> value="no">No</option>
|
74 |
+
</select> <span class="setting-description">User registrations must also be turned on for this to work ('Anyone can register' checkbox in settings).</span></td>
|
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">Yes</option>
|
80 |
+
<option <?php if ($sidebarlogin_forgotton_link=='no') echo 'selected="selected"'; ?> value="no">No</option>
|
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">One link per line (e.g. <code><a href="http://Yoursite.com/wp-admin/">Dashboard</a></code>). Logout link will always show regardless.</span></td>
|
86 |
+
</tr>
|
87 |
+
</table>
|
88 |
+
<p class="submit"><input type="submit" value="<?php _e('Save Changes',"wp-download_monitor"); ?>" /></p>
|
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>";
|
104 |
$args["after_title"]="</h2>";
|
105 |
+
widget_wp_sidebarlogin($args);
|
106 |
}
|
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 "). $current_user->display_name . $after_title;
|
118 |
+
echo '<ul class="pagenav">';
|
119 |
+
|
120 |
+
$links = get_option('sidebarlogin_logged_in_links');
|
121 |
+
$links = explode("\n", $links);
|
122 |
+
if (sizeof($links)>0)
|
123 |
+
foreach ($links as $l) {
|
124 |
+
echo '<li class="page_item">'.$l.'</li>';
|
125 |
+
}
|
126 |
+
echo '<li class="page_item"><a href="'.current_url('logout').'">'.__('Logout').'</a></li>
|
127 |
</ul>';
|
128 |
} else {
|
129 |
// User is NOT logged in!!!
|
152 |
echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n";
|
153 |
}
|
154 |
// login form
|
155 |
+
echo '<form action="'.current_url().'" method="post">';
|
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>
|
164 |
<?php
|
165 |
// Output other links
|
166 |
echo '<ul class="sidebarlogin_otherlinks">';
|
167 |
+
if (get_option('users_can_register') && get_option('sidebarlogin_register_link')=='yes') {
|
168 |
// MU FIX
|
169 |
global $wpmu_version;
|
170 |
if (empty($wpmu_version)) {
|
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
|
185 |
}
|
186 |
// echo widget closing tag
|
187 |
echo $after_widget;
|
188 |
}
|
189 |
+
function widget_wp_sidebarlogin_init() {
|
190 |
if ( !function_exists('register_sidebar_widget') ) return;
|
191 |
// Register widget for use
|
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;
|
198 |
$myerrors = new WP_Error();
|
199 |
//Set a cookie now to see if they are supported by the browser.
|
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(current_url('nologout'));
|
215 |
+
exit;
|
216 |
}
|
217 |
// Are we doing a sidebar login action?
|
218 |
if ($_POST['sidebarlogin_posted']) {
|
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(current_url('nologout'));
|
253 |
exit;
|
254 |
}
|
255 |
}
|
259 |
function current_url($url = '') {
|
260 |
$pageURL = 'http';
|
261 |
if ($_SERVER["HTTPS"] == "on") $pageURL .= "s";
|
262 |
+
$pageURL .= "://www.";
|
263 |
if ($_SERVER["SERVER_PORT"] != "80") {
|
264 |
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
|
265 |
} else {
|
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';
|
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('wpurl'),'www.')) $pageURL = str_replace('www.','', $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 |
?>
|