Sidebar Login - Version 2.2.3

Version Description

Download this release

Release Info

Developer jolley_small
Plugin Icon 128x128 Sidebar Login
Version 2.2.3
Comparing to
See all releases

Code changes from version 2.2.2 to 2.2.3

Files changed (2) hide show
  1. readme.txt +1 -1
  2. sidebar-login.php +25 -19
readme.txt CHANGED
@@ -3,7 +3,7 @@ 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
7
  Stable tag: 2.2.2
8
 
9
  Adds a sidebar widget to let users login.
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.8
7
  Stable tag: 2.2.2
8
 
9
  Adds a sidebar widget to let users login.
sidebar-login.php CHANGED
@@ -3,12 +3,21 @@
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.2
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'), 9,'Sidebar Login', 'wp_sidebarlogin_admin');
@@ -82,7 +91,8 @@ function wp_sidebarlogin_admin(){
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/>&lt;a href="'.get_bloginfo('wpurl').'/wp-admin/"&gt;Dashboard&lt;/a&gt;<br/>&lt;a href="'.get_bloginfo('wpurl').'/wp-admin/profile.php"&gt;Profile&lt;/a&gt;','sblogin'); ?></span></td>
 
86
  </tr>
87
  </table>
88
  <p class="submit"><input type="submit" value="<?php _e('Save Changes',"sblogin"); ?>" /></p>
@@ -153,8 +163,8 @@ function widget_wp_sidebarlogin($args) {
153
  echo '<li class="page_item">'.$link[0].'</li>';
154
  }
155
 
156
- $redir = get_option('sidebarlogin_logout_redirect');
157
- if (empty($redir)) $redir = wp_sidebarlogin_current_url('nologout');
158
 
159
  echo '<li class="page_item"><a href="'.wp_logout_url($redir).'">'.$thelogout.'</a></li></ul>';
160
 
@@ -164,7 +174,7 @@ function widget_wp_sidebarlogin($args) {
164
  // Show any errors
165
  global $myerrors;
166
  $wp_error = new WP_Error();
167
- if ( !empty($myerrors) ) {
168
  $wp_error = $myerrors;
169
  }
170
  if ( $wp_error->get_error_code() ) {
@@ -258,8 +268,8 @@ function widget_wp_sidebarlogin_check() {
258
 
259
  $secure_cookie = '';
260
 
261
- $redir = get_option('sidebarlogin_login_redirect');
262
- if (!empty($redir)) $redirect_to = $redir;
263
  else $redirect_to = wp_sidebarlogin_current_url('nologout');
264
 
265
  // If the user wants ssl but the session is not ssl, force a secure cookie.
@@ -286,14 +296,14 @@ function widget_wp_sidebarlogin_check() {
286
 
287
  $redirect_to = apply_filters('login_redirect', $redirect_to, isset( $redirect_to ) ? $redirect_to : '', $user);
288
 
289
- if ( !is_wp_error($user) ) {
290
  if ( isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE]) )
291
  $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."));
292
  else {
293
  wp_safe_redirect($redirect_to);
294
  exit();
295
  }
296
- } else {
297
  $myerrors = $user;
298
  if ( empty($_POST['log']) && empty($_POST['pwd']) ) {
299
  $myerrors->add('empty_username', __('<strong>ERROR</strong>: Please enter a username & password.', 'sblogin'));
@@ -305,25 +315,22 @@ function widget_wp_sidebarlogin_check() {
305
  if ( !function_exists('wp_sidebarlogin_current_url') ) :
306
  function wp_sidebarlogin_current_url($url = '') {
307
 
308
- global $wpdb;
309
  $pageURL = "";
310
  if (is_home() || is_front_page())
311
  {
312
- $pageURL = get_bloginfo('wpurl');
313
  }
314
  elseif (is_single() || is_page())
315
  {
316
- global $post;
317
  $pageURL = get_permalink($post->ID);
318
  }
319
  elseif (is_category())
320
  {
321
- global $cat;
322
  $pageURL = get_category_link($cat);
323
  }
324
  elseif (is_tag())
325
  {
326
- global $tag;
327
  $tag_id = $wpdb->get_var("SELECT ".$wpdb->terms.".term_id FROM $wpdb->term_taxonomy
328
  LEFT JOIN $wpdb->terms
329
  ON (".$wpdb->term_taxonomy.".term_id = ".$wpdb->terms.".term_id)
@@ -333,13 +340,10 @@ function wp_sidebarlogin_current_url($url = '') {
333
  }
334
  elseif (is_author())
335
  {
336
- global $author;
337
  $pageURL = get_author_posts_url($author);
338
  }
339
  elseif (is_date())
340
  {
341
-
342
- global $year, $monthnum, $day;
343
 
344
  if ($day)
345
  {
@@ -361,7 +365,9 @@ function wp_sidebarlogin_current_url($url = '') {
361
  if ("/" != substr($pageURL, -1)) $pageURL = $pageURL . "/";
362
  $pageURL .= '?s='.$_REQUEST['s'].'';
363
  }
364
- else {
 
 
365
  $pageURL = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://';
366
 
367
  if ($_SERVER["SERVER_PORT"] != "80") {
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.3
7
  Author: Mike Jolley
8
  Author URI: http://blue-anvil.com
9
  */
10
 
11
+ // Pre 2.6 compatibility (BY Stephen Rider)
12
+ if ( ! defined( 'WP_CONTENT_URL' ) ) {
13
+ if ( defined( 'WP_SITEURL' ) ) define( 'WP_CONTENT_URL', WP_SITEURL . '/wp-content' );
14
+ else define( 'WP_CONTENT_URL', get_option( 'url' ) . '/wp-content' );
15
+ }
16
+ if ( ! defined( 'WP_CONTENT_DIR' ) ) define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
17
+ if ( ! defined( 'WP_PLUGIN_URL' ) ) define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' );
18
+ if ( ! defined( 'WP_PLUGIN_DIR' ) ) define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );
19
+
20
+ load_plugin_textdomain('sblogin', WP_PLUGIN_URL.'/sidebar-login/', 'sidebar-login/');
21
 
22
  function wp_sidebarlogin_menu() {
23
  add_management_page(__('Sidebar Login','sblogin'), __('Sidebar Login','sblogin'), 9,'Sidebar Login', 'wp_sidebarlogin_admin');
91
  </tr>
92
  <tr>
93
  <th scope="col"><?php _e('Logged in links',"sblogin"); ?>:</th>
94
+ <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/>&lt;a href="','sblogin');
95
+ echo get_bloginfo('wpurl').'/wp-admin/"&gt;Dashboard&lt;/a&gt;<br/>&lt;a href="'.get_bloginfo('wpurl').'/wp-admin/profile.php"&gt;Profile&lt;/a&gt;'; ?></span></td>
96
  </tr>
97
  </table>
98
  <p class="submit"><input type="submit" value="<?php _e('Save Changes',"sblogin"); ?>" /></p>
163
  echo '<li class="page_item">'.$link[0].'</li>';
164
  }
165
 
166
+ $redir = trim(stripslashes(get_option('sidebarlogin_logout_redirect')));
167
+ if (!$redir || empty($redir)) $redir = wp_sidebarlogin_current_url('nologout');
168
 
169
  echo '<li class="page_item"><a href="'.wp_logout_url($redir).'">'.$thelogout.'</a></li></ul>';
170
 
174
  // Show any errors
175
  global $myerrors;
176
  $wp_error = new WP_Error();
177
+ if ( !empty($myerrors) && is_wp_error($myerrors) ) {
178
  $wp_error = $myerrors;
179
  }
180
  if ( $wp_error->get_error_code() ) {
268
 
269
  $secure_cookie = '';
270
 
271
+ $redir = trim(stripslashes(get_option('sidebarlogin_login_redirect')));
272
+ if ($redir && !empty($redir)) $redirect_to = $redir;
273
  else $redirect_to = wp_sidebarlogin_current_url('nologout');
274
 
275
  // If the user wants ssl but the session is not ssl, force a secure cookie.
296
 
297
  $redirect_to = apply_filters('login_redirect', $redirect_to, isset( $redirect_to ) ? $redirect_to : '', $user);
298
 
299
+ if ( $user && !is_wp_error($user) ) {
300
  if ( isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE]) )
301
  $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."));
302
  else {
303
  wp_safe_redirect($redirect_to);
304
  exit();
305
  }
306
+ } elseif ($user) {
307
  $myerrors = $user;
308
  if ( empty($_POST['log']) && empty($_POST['pwd']) ) {
309
  $myerrors->add('empty_username', __('<strong>ERROR</strong>: Please enter a username & password.', 'sblogin'));
315
  if ( !function_exists('wp_sidebarlogin_current_url') ) :
316
  function wp_sidebarlogin_current_url($url = '') {
317
 
318
+ global $wpdb, $post, $cat, $tag, $author, $year, $monthnum, $day;
319
  $pageURL = "";
320
  if (is_home() || is_front_page())
321
  {
322
+ $pageURL = get_bloginfo('url');
323
  }
324
  elseif (is_single() || is_page())
325
  {
 
326
  $pageURL = get_permalink($post->ID);
327
  }
328
  elseif (is_category())
329
  {
 
330
  $pageURL = get_category_link($cat);
331
  }
332
  elseif (is_tag())
333
  {
 
334
  $tag_id = $wpdb->get_var("SELECT ".$wpdb->terms.".term_id FROM $wpdb->term_taxonomy
335
  LEFT JOIN $wpdb->terms
336
  ON (".$wpdb->term_taxonomy.".term_id = ".$wpdb->terms.".term_id)
340
  }
341
  elseif (is_author())
342
  {
 
343
  $pageURL = get_author_posts_url($author);
344
  }
345
  elseif (is_date())
346
  {
 
 
347
 
348
  if ($day)
349
  {
365
  if ("/" != substr($pageURL, -1)) $pageURL = $pageURL . "/";
366
  $pageURL .= '?s='.$_REQUEST['s'].'';
367
  }
368
+
369
+ if (!$pageURL || $pageURL=="" || !is_string($pageURL)) {
370
+ $pageURL = "";
371
  $pageURL = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://';
372
 
373
  if ($_SERVER["SERVER_PORT"] != "80") {