Version Description
Download this release
Release Info
Developer | jolley_small |
Plugin | Sidebar Login |
Version | 2.2.1 |
Comparing to | |
See all releases |
Code changes from version 2.2 to 2.2.1
- readme.txt +1 -1
- sidebar-login.php +64 -40
- style.css +16 -0
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.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.1
|
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.2
|
7 |
Author: Mike Jolley
|
8 |
Author URI: http://blue-anvil.com
|
9 |
*/
|
@@ -115,7 +115,8 @@ 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(
|
|
|
119 |
'thewelcome'=>__("Welcome",'sblogin'),
|
120 |
'theusername'=>__('Username:','sblogin'),
|
121 |
'thepassword'=>__('Password:','sblogin'),
|
@@ -123,8 +124,7 @@ function widget_wp_sidebarlogin($args) {
|
|
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);
|
@@ -134,13 +134,17 @@ function widget_wp_sidebarlogin($args) {
|
|
134 |
|
135 |
if ($user_ID != '') {
|
136 |
// User is logged in
|
137 |
-
echo $before_widget . $before_title .$thewelcome.' '
|
|
|
|
|
|
|
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) {
|
@@ -236,49 +240,62 @@ function widget_wp_sidebarlogin_check() {
|
|
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 |
-
|
242 |
global $myerrors;
|
243 |
$myerrors = new WP_Error();
|
244 |
-
//Set a cookie now to see if they are supported by the browser.
|
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 |
-
|
252 |
-
$secure_cookie = false;
|
253 |
-
else
|
254 |
-
$secure_cookie = '';
|
255 |
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
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'));
|
279 |
-
exit;
|
280 |
}
|
281 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
}
|
283 |
}
|
284 |
|
@@ -302,7 +319,14 @@ function wp_sidebarlogin_current_url($url = '') {
|
|
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');
|
308 |
add_action('admin_menu', 'wp_sidebarlogin_menu');
|
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.1
|
7 |
Author: Mike Jolley
|
8 |
Author URI: http://blue-anvil.com
|
9 |
*/
|
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(
|
119 |
+
'thelogin'=>__('Login','sblogin'),
|
120 |
'thewelcome'=>__("Welcome",'sblogin'),
|
121 |
'theusername'=>__('Username:','sblogin'),
|
122 |
'thepassword'=>__('Password:','sblogin'),
|
124 |
'theregister'=>__('Register','sblogin'),
|
125 |
'thepasslostandfound'=>__('Password Lost and Found','sblogin'),
|
126 |
'thelostpass'=> __('Lost your password?','sblogin'),
|
127 |
+
'thelogout'=> __('Logout','sblogin')
|
|
|
128 |
);
|
129 |
|
130 |
$args = array_merge($defaults, $args);
|
134 |
|
135 |
if ($user_ID != '') {
|
136 |
// User is logged in
|
137 |
+
echo $before_widget . $before_title .$thewelcome.' '.ucwords($current_user->display_name). $after_title;
|
138 |
+
|
139 |
+
echo '<div class="avatar_container">'.get_avatar($user_ID, $size = '38').'</div>';
|
140 |
+
|
141 |
echo '<ul class="pagenav">';
|
142 |
|
143 |
$user_info = get_userdata($user_ID);
|
144 |
$level = $user_info->user_level;
|
145 |
|
146 |
+
$links = do_shortcode(get_option('sidebarlogin_logged_in_links'));
|
147 |
+
|
148 |
$links = explode("\n", $links);
|
149 |
if (sizeof($links)>0)
|
150 |
foreach ($links as $l) {
|
240 |
add_option('sidebarlogin_register_link','yes','no');
|
241 |
add_option('sidebarlogin_forgotton_link','yes','no');
|
242 |
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');
|
243 |
+
|
244 |
+
//Set a cookie now to see if they are supported by the browser.
|
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 |
|
249 |
if ($_POST['sidebarlogin_posted']) {
|
250 |
+
|
251 |
global $myerrors;
|
252 |
$myerrors = new WP_Error();
|
|
|
|
|
|
|
|
|
|
|
|
|
253 |
|
254 |
+
nocache_headers();
|
|
|
|
|
|
|
255 |
|
256 |
+
$secure_cookie = '';
|
257 |
+
|
258 |
+
$redir = get_option('sidebarlogin_login_redirect');
|
259 |
+
if (!empty($redir)) $redirect_to = $redir;
|
260 |
+
else $redirect_to = wp_sidebarlogin_current_url('nologout');
|
261 |
+
|
262 |
+
// If the user wants ssl but the session is not ssl, force a secure cookie.
|
263 |
+
if ( !empty($_POST['log']) && !force_ssl_admin() ) {
|
264 |
+
$user_name = sanitize_user($_POST['log']);
|
265 |
+
if ( $user = get_userdatabylogin($user_name) ) {
|
266 |
+
if ( get_user_option('use_ssl', $user->ID) ) {
|
267 |
+
$secure_cookie = true;
|
268 |
+
force_ssl_admin(true);
|
|
|
269 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
270 |
}
|
271 |
}
|
272 |
+
|
273 |
+
if ( $redirect_to ) {
|
274 |
+
// Redirect to https if user wants ssl
|
275 |
+
if ( $secure_cookie && false !== strpos($redirect_to, 'wp-admin') )
|
276 |
+
$redirect_to = preg_replace('|^http://|', 'https://', $redirect_to);
|
277 |
+
}
|
278 |
+
|
279 |
+
if ( !$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && ( 0 !== strpos($redirect_to, 'https') ) && ( 0 === strpos($redirect_to, 'http') ) )
|
280 |
+
$secure_cookie = false;
|
281 |
+
|
282 |
+
$user = wp_signon('', $secure_cookie);
|
283 |
+
|
284 |
+
$redirect_to = apply_filters('login_redirect', $redirect_to, isset( $redirect_to ) ? $redirect_to : '', $user);
|
285 |
+
|
286 |
+
if ( !is_wp_error($user) ) {
|
287 |
+
if ( isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE]) )
|
288 |
+
$myerrors->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."));
|
289 |
+
else {
|
290 |
+
wp_safe_redirect($redirect_to);
|
291 |
+
exit();
|
292 |
+
}
|
293 |
+
} else {
|
294 |
+
$myerrors = $user;
|
295 |
+
if ( empty($_POST['log']) && empty($_POST['pwd']) ) {
|
296 |
+
$myerrors->add('empty_username', __('<strong>ERROR</strong>: Please enter a username & password.', 'sblogin'));
|
297 |
+
}
|
298 |
+
}
|
299 |
}
|
300 |
}
|
301 |
|
319 |
}
|
320 |
endif;
|
321 |
|
322 |
+
function wp_sidebarlogin_css() {
|
323 |
+
$myStyleFile = WP_PLUGIN_URL . '/sidebar-login/style.css';
|
324 |
+
wp_register_style('wp_sidebarlogin_css_styles', $myStyleFile);
|
325 |
+
wp_enqueue_style( 'wp_sidebarlogin_css_styles');
|
326 |
+
}
|
327 |
+
|
328 |
// Run code and init
|
329 |
+
add_action('wp_print_styles', 'wp_sidebarlogin_css');
|
330 |
add_action('init', 'widget_wp_sidebarlogin_check',0);
|
331 |
add_action('widgets_init', 'widget_wp_sidebarlogin_init');
|
332 |
add_action('admin_menu', 'wp_sidebarlogin_menu');
|
style.css
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Basic styling for login widget
|
2 |
+
// This styling aligns the gravtar left, the links right.
|
3 |
+
.widget_wp_sidebarlogin {
|
4 |
+
overflow: hidden;
|
5 |
+
}
|
6 |
+
.widget_wp_sidebarlogin .avatar_container {
|
7 |
+
float:left;
|
8 |
+
}
|
9 |
+
.widget_wp_sidebarlogin .avatar_container img {
|
10 |
+
padding: 3px;
|
11 |
+
border: 1px solid #ddd;
|
12 |
+
-moz-border-radius: 4px;
|
13 |
+
-webkit-border-radius: 4px;
|
14 |
+
margin-right: 8px;
|
15 |
+
margin-top: 5px;
|
16 |
+
}
|