Login With Ajax - Version 1.3

Version Description

  • Fixed widget template $before_widget... variables being used with shorttag and template tag functions
  • Added JSON encoding compatability for PHP4
  • Fixed bad link for non root hosted sites in template
  • Added forgot password widget
  • Added redirect capability based on user roles
  • Fixed template locating to handle child themes
  • Added Shortcode

=

Download this release

Release Info

Developer netweblogic
Plugin Icon 128x128 Login With Ajax
Version 1.3
Comparing to
See all releases

Code changes from version 1.2 to 1.3

login-with-ajax-admin.php CHANGED
@@ -31,7 +31,16 @@ class LWA{
31
  //Build the array of options here
32
  if(!$errors){
33
  foreach ($_POST as $postKey => $postValue){
34
- if( substr($postKey, 0, 4) == 'lwa_' ){
 
 
 
 
 
 
 
 
 
35
  //For now, no validation, since this is in admin area.
36
  if($postValue != ''){
37
  $lwa_data[substr($postKey, 4)] = $postValue;
@@ -59,7 +68,7 @@ class LWA{
59
  <tbody id="lwa-body">
60
  <tr valign="top">
61
  <td scope="row">
62
- <label>Custom Login Redirect</label>
63
  </td>
64
  <td>
65
  <input type="text" name="lwa_login_redirect" value='<?= $lwa_data['login_redirect'] ?>' />
@@ -69,7 +78,7 @@ class LWA{
69
  </tr>
70
  <tr valign="top">
71
  <td scope="row">
72
- <label>Custom Logout Redirect</label>
73
  </td>
74
  <td>
75
  <input type="text" name="lwa_logout_redirect" value='<?= $lwa_data['logout_redirect'] ?>' />
@@ -87,6 +96,59 @@ class LWA{
87
  <i>Checking this will show a link to their wp-admin profile in the sidebar widget when the user is logged in.</i>
88
  </td>
89
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  </tbody>
91
  <tfoot>
92
  <tr valign="top">
31
  //Build the array of options here
32
  if(!$errors){
33
  foreach ($_POST as $postKey => $postValue){
34
+ if( $postValue != '' && preg_match('/lwa_role_log(in|out)_/', $postKey) ){
35
+ //Custom role-based redirects
36
+ if( preg_match('/lwa_role_login/', $postKey) ){
37
+ //Login
38
+ $lwa_data['role_login'][str_replace('lwa_role_login_', '', $postKey)] = $postValue;
39
+ }else{
40
+ //Logout
41
+ $lwa_data['role_logout'][str_replace('lwa_role_logout_', '', $postKey)] = $postValue;
42
+ }
43
+ }elseif( substr($postKey, 0, 4) == 'lwa_' ){
44
  //For now, no validation, since this is in admin area.
45
  if($postValue != ''){
46
  $lwa_data[substr($postKey, 4)] = $postValue;
68
  <tbody id="lwa-body">
69
  <tr valign="top">
70
  <td scope="row">
71
+ <label>Global Login Redirect</label>
72
  </td>
73
  <td>
74
  <input type="text" name="lwa_login_redirect" value='<?= $lwa_data['login_redirect'] ?>' />
78
  </tr>
79
  <tr valign="top">
80
  <td scope="row">
81
+ <label>Global Logout Redirect</label>
82
  </td>
83
  <td>
84
  <input type="text" name="lwa_logout_redirect" value='<?= $lwa_data['logout_redirect'] ?>' />
96
  <i>Checking this will show a link to their wp-admin profile in the sidebar widget when the user is logged in.</i>
97
  </td>
98
  </tr>
99
+ <?
100
+ //Sort out the role_login/logout arrays, in case they're empty
101
+ if(!is_array($lwa_data['role_login'])){
102
+ $lwa_data['role_login'] = array();
103
+ }
104
+ if(!is_array($lwa_data['role_logout'])){
105
+ $lwa_data['role_logout'] = array();
106
+ }
107
+ ?>
108
+ <tr valign="top">
109
+ <td scope="row">
110
+ <label>Role-Based Custom Login Redirects</label>
111
+ </td>
112
+ <td>
113
+ <i>If you would like a specific user role to be redirected to a custom URL upon login, place it here (blank value will default to the global redirect)</i>
114
+ <table>
115
+ <?php
116
+ //Taken from /wp-admin/includes/template.php Line 2715
117
+ $editable_roles = get_editable_roles();
118
+ foreach( $editable_roles as $role => $details ) {
119
+ ?>
120
+ <tr>
121
+ <td><?php echo translate_user_role($details['name']) ?></td>
122
+ <td><input type='text' name='lwa_role_login_<?php echo esc_attr($role) ?>' value="<?php echo $lwa_data['role_login'][$role] ?>" /></td>
123
+ </tr>
124
+ <?php
125
+ }
126
+ ?>
127
+ </table>
128
+ </td>
129
+ </tr>
130
+ <tr valign="top">
131
+ <td scope="row">
132
+ <label>Role-Based Custom Logout Redirects</label>
133
+ </td>
134
+ <td>
135
+ <i>If you would like a specific user role to be redirected to a custom URL upon logout, place it here (blank value will default to the global redirect)</i>
136
+ <table>
137
+ <?php
138
+ //Taken from /wp-admin/includes/template.php Line 2715
139
+ $editable_roles = get_editable_roles();
140
+ foreach( $editable_roles as $role => $details ) {
141
+ ?>
142
+ <tr>
143
+ <td><?php echo translate_user_role($details['name']) ?></td>
144
+ <td><input type='text' name='lwa_role_logout_<?php echo esc_attr($role) ?>' value="<?php echo $lwa_data['role_logout'][$role] ?>" /></td>
145
+ </tr>
146
+ <?php
147
+ }
148
+ ?>
149
+ </table>
150
+ </td>
151
+ </tr>
152
  </tbody>
153
  <tfoot>
154
  <tr valign="top">
login-with-ajax.js CHANGED
@@ -1,48 +1 @@
1
- jQuery(document).ready( function($) {
2
- //Oh well... I guess we have to use jQuery ... if you are a javascript developer, consider MooTools if you have a choice, it's great!
3
- //I'm biased, but form functionality already comes prepacked with MooTools :)
4
- $('#LoginWithAjax_Form').submit(function(event){
5
- //Stop event, add loading pic...
6
- event.preventDefault();
7
- $('<div id="LoginWithAjax_Loading"></div>').prependTo('#login-with-ajax');
8
- //Sort out url
9
- url = $('#LoginWithAjax_Form').attr('action');
10
- url += (url.match(/\?/) != null) ? '&callback=?' : '?callback=?' ;
11
- url += "&log="+$("#lwa_user_login").attr('value');
12
- url += "&pwd="+$("#lwa_user_pass").attr('value');
13
- url += "&login-with-ajax=login";
14
- $.getJSON( url , function(data, status){
15
- $('#LoginWithAjax_Loading').remove();
16
- if( data.result === true || data.result === false ){
17
- if(data.result == '1'){
18
- //Login Successful
19
- if( $('#LoginWithAjax_Status').length > 0 ){
20
- $('#LoginWithAjax_Status').attr('class','confirm').html("Login Successful, redirecting...");
21
- }else{
22
- $('<span id="LoginWithAjax_Status" class="confirm">Login Successful, redirecting...</span>').prependTo('#login-with-ajax');
23
- }
24
- if(data.redirect == null){
25
- window.location.reload();
26
- }else{
27
- window.location = data.redirect;
28
- }
29
- }else{
30
- //Login Failed
31
- //If there already is an error element, replace text contents, otherwise create a new one and insert it
32
- if( $('#LoginWithAjax_Status').length > 0 ){
33
- $('#LoginWithAjax_Status').attr('class','invalid').html(data.error);
34
- }else{
35
- $('<span id="LoginWithAjax_Status" class="invalid">'+data.error+'</span>').prependTo('#login-with-ajax');
36
- }
37
- }
38
- }else{
39
- //If there already is an error element, replace text contents, otherwise create a new one and insert it
40
- if( $('#LoginWithAjax_Status').length > 0 ){
41
- $('#LoginWithAjax_Status').attr('class','invalid').html('An error has occured. Please try again.'+status);
42
- }else{
43
- $('<span id="LoginWithAjax_Status" class="invalid">An error has occured. Please try again.</span>').prependTo('#login-with-ajax');
44
- }
45
- }
46
- });
47
- });
48
- });
1
+ jQuery(document).ready(function(a){a("#LoginWithAjax_Form").submit(function(b){b.preventDefault();if(a("#LoginWithAjax").length>0){a('<div class="LoginWithAjax_Loading" id="LoginWithAjax_Loading"></div>').prependTo("#LoginWithAjax")}else{a('<div class="LoginWithAjax_Loading" id="LoginWithAjax_Loading"></div>').prependTo("#login-with-ajax")}url=a("#LoginWithAjax_Form").attr("action");url+=(url.match(/\?/)!=null)?"&callback=?":"?callback=?";url+="&log="+a("#lwa_user_login").attr("value");url+="&pwd="+a("#lwa_user_pass").attr("value");url+="&login-with-ajax=login";a.getJSON(url,function(d,c){a("#LoginWithAjax_Loading").remove();if(d.result===true||d.result===false){if(d.result=="1"){if(a("#LoginWithAjax_Status").length>0){a("#LoginWithAjax_Status").attr("class","confirm").html("Login Successful, redirecting...")}else{a('<span id="LoginWithAjax_Status" class="confirm">Login Successful, redirecting...</span>').prependTo("#login-with-ajax")}if(d.redirect==null){window.location.reload()}else{window.location=d.redirect}}else{if(a("#LoginWithAjax_Status").length>0){a("#LoginWithAjax_Status").attr("class","invalid").html(d.error)}else{a('<span id="LoginWithAjax_Status" class="invalid">'+d.error+"</span>").prependTo("#login-with-ajax")}a("#LoginWithAjax_Status").click(function(e){e.preventDefault();a("#LoginWithAjax_Remember").show("slow")})}}else{if(a("#LoginWithAjax_Status").length>0){a("#LoginWithAjax_Status").attr("class","invalid").html("An error has occured. Please try again."+c)}else{a('<span id="LoginWithAjax_Status" class="invalid">An error has occured. Please try again.</span>').prependTo("#login-with-ajax")}}})});a("#LoginWithAjax_Remember").submit(function(b){b.preventDefault();a('<div id="LoginWithAjax_Loading"></div>').prependTo("#LoginWithAjax");url=a("#LoginWithAjax_Remember").attr("action");url+=(url.match(/\?/)!=null)?"&callback=?":"?callback=?";url+="&user_login="+a("#lwa_user_remember").attr("value");url+="&login-with-ajax=remember";a.getJSON(url,function(d,c){a("#LoginWithAjax_Loading").remove();if(d.result===true||d.result===false){if(d.result=="1"){if(a("#LoginWithAjax_Status").length>0){a("#LoginWithAjax_Status").attr("class","confirm").html("We have sent you an email")}else{a('<span id="LoginWithAjax_Status" class="confirm">We have sent you an email</span>').prependTo("#login-with-ajax")}}else{if(a("#LoginWithAjax_Status").length>0){a("#LoginWithAjax_Status").attr("class","invalid").html(d.error)}else{a('<span id="LoginWithAjax_Status" class="invalid">'+d.error+"</span>").prependTo("#login-with-ajax")}}}else{if(a("#LoginWithAjax_Status").length>0){a("#LoginWithAjax_Status").attr("class","invalid").html("An error has occured. Please try again."+c)}else{a('<span id="LoginWithAjax_Status" class="invalid">An error has occured. Please try again.</span>').prependTo("#login-with-ajax")}}})});a("#LoginWithAjax_Remember").hide();a("#LoginWithAjax_Links_Remember").click(function(b){b.preventDefault();a("#LoginWithAjax_Remember").show("slow")});a("#LoginWithAjax_Links_Remember_Cancel").click(function(b){b.preventDefault();a("#LoginWithAjax_Remember").hide("slow")})});
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
login-with-ajax.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Login With Ajax
4
  Plugin URI: http://netweblogic.com/wordpress/plugins/login-with-ajax/
5
  Description: Ajax driven login widget. Customisable from within your template folder, and advanced settings from the admin area.
6
  Author: NetWebLogic
7
- Version: 1.2
8
  Author URI: http://netweblogic.com/
9
  Tags: Login, Ajax, Redirect, BuddyPress, MU, WPMU, sidebar, admin, widget
10
 
@@ -28,14 +28,24 @@ include_once('login-with-ajax-admin.php');
28
 
29
  class LoginWithAjax {
30
 
 
 
 
 
 
31
  // Class initialization
32
  function LoginWithAjax() {
 
 
33
  //Make decision on what to display
34
  if ( function_exists('register_sidebar_widget') && !isset($_GET["login-with-ajax"]) ){
35
  //Enqueue scripts
36
  wp_enqueue_script( "login-with-ajax", path_join(WP_PLUGIN_URL, basename( dirname( __FILE__ ) )."/login-with-ajax.js"), array( 'jquery' ) );
37
  //Enqueue stylesheets
38
- if( file_exists(get_template_directory().'/plugins/login-with-ajax/widget.css') ){
 
 
 
39
  wp_enqueue_style( "login-with-ajax-css", get_template_directory_uri().'/plugins/login-with-ajax/widget.css' );
40
  }else{
41
  wp_enqueue_style( "login-with-ajax-css", path_join(WP_PLUGIN_URL, basename( dirname( __FILE__ ) )."/widget/widget.css") );
@@ -45,31 +55,35 @@ class LoginWithAjax {
45
  //Add logout/in redirection
46
  add_action('wp_logout', array(&$this, 'logoutRedirect'));
47
  add_action('wp_login', array(&$this, 'loginRedirect'));
48
-
 
49
  }elseif ( isset($_GET["login-with-ajax"]) ) {
50
  $this->ajax();
51
  }
52
  }
53
 
 
 
 
 
54
  // Decides what action to take from the ajax request
55
  function ajax(){
56
  switch ( $_GET["login-with-ajax"] ) {
57
  case 'login':
58
  //A login has been requested
59
- $this->ajaxLogin();
 
 
 
 
 
 
 
60
  break;
61
  default:
62
- echo json_encode(array('result'=>0, 'error'=>'Unknown command requested'));
63
- exit();
64
  break;
65
  }
66
- }
67
-
68
- //Calls normal login and JSON encodes it
69
- function ajaxLogin(){
70
- $_POST['log'] = $_GET['log'];
71
- $_POST['pwd'] = $_GET['pwd'];
72
- $return = json_encode($this->login());
73
  if( isset($_GET['callback']) ){
74
  $return = $_GET['callback']."($return)";
75
  }
@@ -81,19 +95,22 @@ class LoginWithAjax {
81
  function login(){
82
  $return = array(); //What we send back
83
  $loginResult = wp_signon();
84
-
85
  if ( get_class($loginResult) == 'WP_User' ) {
86
  //User login successful
87
- /* @var $result WP_User */
88
- if(get_option('login-with-ajax_login-refresh') == 1){
89
- //Refresh page - todo
90
- }else{
91
- //Return true value
92
- $return['result'] = true;
 
 
 
93
  }
94
  } elseif ( get_class($loginResult) == 'WP_Error' ) {
95
  //User login failed
96
- /* @var $result WP_Error */
97
  $return['result'] = false;
98
  $return['error'] = $loginResult->get_error_message();
99
  } else {
@@ -101,57 +118,175 @@ class LoginWithAjax {
101
  $return['result'] = false;
102
  $return['error'] = 'An undefined error has ocurred';
103
  }
104
- $data = get_option('lwa_data');
105
- if($data['login_redirect'] != ''){
106
- $return['redirect'] = $data['login_redirect'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  }
108
  //Return the result array with errors etc.
109
  return $return;
110
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
 
112
  // Generate the login template
113
  function widget($args = array()) {
 
 
114
  extract($args);
 
115
  if(is_user_logged_in()){
116
- if( file_exists(TEMPLATEPATH.'/plugins/login-with-ajax/widget_in.php') ){
117
- include(TEMPLATEPATH.'/plugins/login-with-ajax/widget_in.php');
 
 
118
  }else{
119
  include('widget/widget_in.php');
120
  }
121
  }else{
122
- if( file_exists(TEMPLATEPATH.'/plugins/login-with-ajax/widget_out.php') ){
123
- include(TEMPLATEPATH.'/plugins/login-with-ajax/widget_out.php');
 
 
124
  }else{
125
  include('widget/widget_out.php');
126
  }
127
  }
128
  }
129
 
130
- function logoutRedirect(){
131
- $data = get_option('lwa_data');
132
- if($data['logout_redirect'] != ''){
133
- wp_redirect($data['logout_redirect']);
134
- exit();
135
- }
136
  }
137
 
138
- function loginRedirect(){
139
- $data = get_option('lwa_data');
140
- if($data['login_redirect'] != ''){
141
- wp_redirect($data['login_redirect']);
142
- exit();
 
 
 
 
 
143
  }
144
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  }
146
 
 
147
  function LoginWithAjaxInit(){
148
  global $LoginWithAjax;
149
  $LoginWithAjax = new LoginWithAjax();
150
  }
151
 
152
- function login_with_ajax(){
153
- global $LoginWithAjax;
154
- $LoginWithAjax->widget();
 
 
 
155
  }
156
 
157
  // Start this plugin once all other plugins are fully loaded
4
  Plugin URI: http://netweblogic.com/wordpress/plugins/login-with-ajax/
5
  Description: Ajax driven login widget. Customisable from within your template folder, and advanced settings from the admin area.
6
  Author: NetWebLogic
7
+ Version: 1.3
8
  Author URI: http://netweblogic.com/
9
  Tags: Login, Ajax, Redirect, BuddyPress, MU, WPMU, sidebar, admin, widget
10
 
28
 
29
  class LoginWithAjax {
30
 
31
+ /**
32
+ * If logged in upon instantiation, it is a user object.
33
+ * @var WP_User
34
+ */
35
+ var $current_user;
36
  // Class initialization
37
  function LoginWithAjax() {
38
+ //Remember the current user, in case there is a logout
39
+ $this->current_user = wp_get_current_user();
40
  //Make decision on what to display
41
  if ( function_exists('register_sidebar_widget') && !isset($_GET["login-with-ajax"]) ){
42
  //Enqueue scripts
43
  wp_enqueue_script( "login-with-ajax", path_join(WP_PLUGIN_URL, basename( dirname( __FILE__ ) )."/login-with-ajax.js"), array( 'jquery' ) );
44
  //Enqueue stylesheets
45
+ locate_template(array("plugins/login-with-ajax/widget_outs.php"), false);
46
+ if( file_exists(get_stylesheet_directory().'/plugins/login-with-ajax/widget.css') ){
47
+ wp_enqueue_style( "login-with-ajax-css", get_stylesheet_directory_uri().'/plugins/login-with-ajax/widget.css' );
48
+ }else if( file_exists(get_template_directory().'/plugins/login-with-ajax/widget.css') ){
49
  wp_enqueue_style( "login-with-ajax-css", get_template_directory_uri().'/plugins/login-with-ajax/widget.css' );
50
  }else{
51
  wp_enqueue_style( "login-with-ajax-css", path_join(WP_PLUGIN_URL, basename( dirname( __FILE__ ) )."/widget/widget.css") );
55
  //Add logout/in redirection
56
  add_action('wp_logout', array(&$this, 'logoutRedirect'));
57
  add_action('wp_login', array(&$this, 'loginRedirect'));
58
+ add_shortcode('login-with-ajax', array(&$this, 'shortcode'));
59
+ add_shortcode('lwa', array(&$this, 'shortcode'));
60
  }elseif ( isset($_GET["login-with-ajax"]) ) {
61
  $this->ajax();
62
  }
63
  }
64
 
65
+ /*
66
+ * LOGIN OPERATIONS
67
+ */
68
+
69
  // Decides what action to take from the ajax request
70
  function ajax(){
71
  switch ( $_GET["login-with-ajax"] ) {
72
  case 'login':
73
  //A login has been requested
74
+ $_POST['log'] = $_GET['log'];
75
+ $_POST['pwd'] = $_GET['pwd'];
76
+ $return = $this->json_encode($this->login());
77
+ break;
78
+ case 'remember':
79
+ //Remember the password
80
+ $_POST['user_login'] = $_GET['user_login'];
81
+ $return = $this->json_encode($this->remember());
82
  break;
83
  default:
84
+ $return = $this->json_encode(array('result'=>0, 'error'=>'Unknown command requested'));
 
85
  break;
86
  }
 
 
 
 
 
 
 
87
  if( isset($_GET['callback']) ){
88
  $return = $_GET['callback']."($return)";
89
  }
95
  function login(){
96
  $return = array(); //What we send back
97
  $loginResult = wp_signon();
98
+ $user_role = 'null';
99
  if ( get_class($loginResult) == 'WP_User' ) {
100
  //User login successful
101
+ /* @var $loginResult WP_User */
102
+ $return['result'] = true;
103
+ //Do a redirect if necessary
104
+ $data = get_option('lwa_data');
105
+ $user_role = array_shift($loginResult->roles); //Checking for role-based redirects
106
+ if( isset($data["role_login"][$user_role]) ){
107
+ $return['redirect'] = $data["role_login"][$user_role];
108
+ }else if($data['login_redirect'] != ''){
109
+ $return['redirect'] = $data['login_redirect'];
110
  }
111
  } elseif ( get_class($loginResult) == 'WP_Error' ) {
112
  //User login failed
113
+ /* @var $loginResult WP_Error */
114
  $return['result'] = false;
115
  $return['error'] = $loginResult->get_error_message();
116
  } else {
118
  $return['result'] = false;
119
  $return['error'] = 'An undefined error has ocurred';
120
  }
121
+ //Return the result array with errors etc.
122
+ return $return;
123
+ }
124
+
125
+ // Reads ajax login creds via POSt, calls the login script and interprets the result
126
+ function remember(){
127
+ $return = array(); //What we send back
128
+ $result = retrieve_password();
129
+
130
+ if ( $result === true ) {
131
+ //Password correctly remembered
132
+ $return['result'] = true;
133
+ } elseif ( get_class($result) == 'WP_Error' ) {
134
+ //Something went wrong
135
+ /* @var $result WP_Error */
136
+ $return['result'] = false;
137
+ $return['error'] = $result->get_error_message();
138
+ } else {
139
+ //Undefined Error
140
+ $return['result'] = false;
141
+ $return['error'] = 'An undefined error has ocurred';
142
  }
143
  //Return the result array with errors etc.
144
  return $return;
145
  }
146
+
147
+ function logoutRedirect(){
148
+ $data = get_option('lwa_data');
149
+ if( get_class($this->current_user) == "WP_User" ){
150
+ //Do a redirect if necessary
151
+ $data = get_option('lwa_data');
152
+ $user_role = array_shift($this->current_user->roles); //Checking for role-based redirects
153
+ if( isset($data["role_logout"][$user_role]) ){
154
+ wp_redirect( $data["role_logout"][$user_role] );
155
+ exit();
156
+ }
157
+ }
158
+ if($data['logout_redirect'] != ''){
159
+ wp_redirect($data['logout_redirect']);
160
+ exit();
161
+ }
162
+ }
163
+
164
+ function loginRedirect(){
165
+ $data = get_option('lwa_data');
166
+ $user = wp_get_current_user();
167
+ if( get_class($user) == "WP_User" ){
168
+ //Do a redirect if necessary
169
+ $data = get_option('lwa_data');
170
+ $user_role = array_shift($user->roles); //Checking for role-based redirects
171
+ if( isset($data["role_login"][$user_role]) ){
172
+ wp_redirect( $data["role_login"][$user_role] );
173
+ exit();
174
+ }
175
+ }
176
+ if($data['login_redirect'] != ''){
177
+ wp_redirect($data['login_redirect']);
178
+ exit();
179
+ }
180
+ }
181
+
182
+ /*
183
+ * WIDGET OPERATIONS
184
+ */
185
 
186
  // Generate the login template
187
  function widget($args = array()) {
188
+ $defaultAtts = array( "is_widget" => true );
189
+ $atts = shortcode_atts($defaultAtts, $atts);
190
  extract($args);
191
+ $is_widget = ( $is_widget !== false && $is_widget !== "false" && $is_widget !== '0' && $widget !== 0 );
192
  if(is_user_logged_in()){
193
+ if( file_exists(get_stylesheet_directory().'/plugins/login-with-ajax/widget_in.php') ){
194
+ include(get_stylesheet_directory().'/plugins/login-with-ajax/widget_in.php');
195
+ }else if( file_exists(get_template_directory().'/plugins/login-with-ajax/widget_in.php') ){
196
+ include(get_template_directory().'/plugins/login-with-ajax/widget_in.php');
197
  }else{
198
  include('widget/widget_in.php');
199
  }
200
  }else{
201
+ if( file_exists(get_stylesheet_directory().'/plugins/login-with-ajax/widget_out.php') ){
202
+ include(get_stylesheet_directory().'/plugins/login-with-ajax/widget_out.php');
203
+ }else if( file_exists(get_template_directory().'/plugins/login-with-ajax/widget_out.php') ){
204
+ include(get_template_directory().'/plugins/login-with-ajax/widget_out.php');
205
  }else{
206
  include('widget/widget_out.php');
207
  }
208
  }
209
  }
210
 
211
+ function shortcode($atts){
212
+ $defaultAtts = array( "is_widget" => false );
213
+ $atts = shortcode_atts($defaultAtts, $atts);
214
+ $this->widget($atts);
 
 
215
  }
216
 
217
+ /*
218
+ * Auxillary Functions
219
+ */
220
+
221
+ //PHP4 Safe JSON encoding
222
+ function json_encode($array){
223
+ if( !function_exists("json_encode") ){
224
+ return json_encode($array);
225
+ }else{
226
+ return $this->array_to_json($array);
227
  }
228
  }
229
+ //PHP4 Compatible json encoder function
230
+ function array_to_json($array){
231
+ //PHP4 Comapatability - This encodes the array into JSON. Thanks go to Andy - http://www.php.net/manual/en/function.json-encode.php#89908
232
+ if( !is_array( $array ) ){
233
+ return false;
234
+ }
235
+ $associative = count( array_diff( array_keys($array), array_keys( array_keys( $array )) ));
236
+ if( $associative ){
237
+ $construct = array();
238
+ foreach( $array as $key => $value ){
239
+ // We first copy each key/value pair into a staging array,
240
+ // formatting each key and value properly as we go.
241
+ // Format the key:
242
+ if( is_numeric($key) ){
243
+ $key = "key_$key";
244
+ }
245
+ $key = "'".addslashes($key)."'";
246
+ // Format the value:
247
+ if( is_array( $value )){
248
+ $value = array_to_json( $value );
249
+ }else if( is_bool($value) ) {
250
+ $value = ($value) ? "true" : "false";
251
+ }else if( !is_numeric( $value ) || is_string( $value ) ){
252
+ $value = "'".addslashes($value)."'";
253
+ }
254
+ // Add to staging array:
255
+ $construct[] = "$key: $value";
256
+ }
257
+ // Then we collapse the staging array into the JSON form:
258
+ $result = "{ " . implode( ", ", $construct ) . " }";
259
+ } else { // If the array is a vector (not associative):
260
+ $construct = array();
261
+ foreach( $array as $value ){
262
+ // Format the value:
263
+ if( is_array( $value )){
264
+ $value = array_to_json( $value );
265
+ } else if( !is_numeric( $value ) || is_string( $value ) ){
266
+ $value = "'".addslashes($value)."'";
267
+ }
268
+ // Add to staging array:
269
+ $construct[] = $value;
270
+ }
271
+ // Then we collapse the staging array into the JSON form:
272
+ $result = "[ " . implode( ", ", $construct ) . " ]";
273
+ }
274
+ return $result;
275
+ }
276
  }
277
 
278
+ //Instantiate the plugin
279
  function LoginWithAjaxInit(){
280
  global $LoginWithAjax;
281
  $LoginWithAjax = new LoginWithAjax();
282
  }
283
 
284
+ //Template Tag
285
+ function login_with_ajax($atts){
286
+ global $LoginWithAjax;
287
+ $pairs = array( 'is_widget' => false );
288
+ $atts = shortcode_parse_atts($atts);
289
+ $LoginWithAjax->widget(shortcode_atts($pairs, $atts));
290
  }
291
 
292
  // Start this plugin once all other plugins are fully loaded
login-with-ajax.source.js ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready( function($) {
2
+ //Oh well... I guess we have to use jQuery ... if you are a javascript developer, consider MooTools if you have a choice, it's great!
3
+ //I'm biased, but form functionality already comes prepacked with MooTools :)
4
+ $('#LoginWithAjax_Form').submit(function(event){
5
+ //Stop event, add loading pic...
6
+ event.preventDefault();
7
+ if( $('#LoginWithAjax').length > 0 ){
8
+ $('<div class="LoginWithAjax_Loading" id="LoginWithAjax_Loading"></div>').prependTo('#LoginWithAjax');
9
+ }else{
10
+ $('<div class="LoginWithAjax_Loading" id="LoginWithAjax_Loading"></div>').prependTo('#login-with-ajax');
11
+ }
12
+ //Sort out url
13
+ url = $('#LoginWithAjax_Form').attr('action');
14
+ url += (url.match(/\?/) != null) ? '&callback=?' : '?callback=?' ;
15
+ url += "&log="+$("#lwa_user_login").attr('value');
16
+ url += "&pwd="+$("#lwa_user_pass").attr('value');
17
+ url += "&login-with-ajax=login";
18
+ $.getJSON( url , function(data, status){
19
+ $('#LoginWithAjax_Loading').remove();
20
+ if( data.result === true || data.result === false ){
21
+ if(data.result == '1'){
22
+ //Login Successful
23
+ if( $('#LoginWithAjax_Status').length > 0 ){
24
+ $('#LoginWithAjax_Status').attr('class','confirm').html("Login Successful, redirecting...");
25
+ }else{
26
+ $('<span id="LoginWithAjax_Status" class="confirm">Login Successful, redirecting...</span>').prependTo('#login-with-ajax');
27
+ }
28
+ if(data.redirect == null){
29
+ window.location.reload();
30
+ }else{
31
+ window.location = data.redirect;
32
+ }
33
+ }else{
34
+ //Login Failed
35
+ //If there already is an error element, replace text contents, otherwise create a new one and insert it
36
+ if( $('#LoginWithAjax_Status').length > 0 ){
37
+ $('#LoginWithAjax_Status').attr('class','invalid').html(data.error);
38
+ }else{
39
+ $('<span id="LoginWithAjax_Status" class="invalid">'+data.error+'</span>').prependTo('#login-with-ajax');
40
+ }
41
+ //We assume a link in the status message is for a forgotten password
42
+ $('#LoginWithAjax_Status').click(function(event){
43
+ event.preventDefault();
44
+ $('#LoginWithAjax_Remember').show('slow');
45
+ });
46
+ }
47
+ }else{
48
+ //If there already is an error element, replace text contents, otherwise create a new one and insert it
49
+ if( $('#LoginWithAjax_Status').length > 0 ){
50
+ $('#LoginWithAjax_Status').attr('class','invalid').html('An error has occured. Please try again.'+status);
51
+ }else{
52
+ $('<span id="LoginWithAjax_Status" class="invalid">An error has occured. Please try again.</span>').prependTo('#login-with-ajax');
53
+ }
54
+ }
55
+ });
56
+ });
57
+
58
+ $('#LoginWithAjax_Remember').submit(function(event){
59
+ //Stop event, add loading pic...
60
+ event.preventDefault();
61
+ $('<div id="LoginWithAjax_Loading"></div>').prependTo('#LoginWithAjax');
62
+ //Sort out url
63
+ url = $('#LoginWithAjax_Remember').attr('action');
64
+ url += (url.match(/\?/) != null) ? '&callback=?' : '?callback=?' ;
65
+ url += "&user_login="+$("#lwa_user_remember").attr('value');
66
+ url += "&login-with-ajax=remember";
67
+ $.getJSON( url , function(data, status){
68
+ $('#LoginWithAjax_Loading').remove();
69
+ if( data.result === true || data.result === false ){
70
+ if(data.result == '1'){
71
+ //Successful
72
+ if( $('#LoginWithAjax_Status').length > 0 ){
73
+ $('#LoginWithAjax_Status').attr('class','confirm').html("We have sent you an email");
74
+ }else{
75
+ $('<span id="LoginWithAjax_Status" class="confirm">We have sent you an email</span>').prependTo('#login-with-ajax');
76
+ }
77
+ }else{
78
+ //Failed
79
+ //If there already is an error element, replace text contents, otherwise create a new one and insert it
80
+ if( $('#LoginWithAjax_Status').length > 0 ){
81
+ $('#LoginWithAjax_Status').attr('class','invalid').html(data.error);
82
+ }else{
83
+ $('<span id="LoginWithAjax_Status" class="invalid">'+data.error+'</span>').prependTo('#login-with-ajax');
84
+ }
85
+ }
86
+ }else{
87
+ //If there already is an error element, replace text contents, otherwise create a new one and insert it
88
+ if( $('#LoginWithAjax_Status').length > 0 ){
89
+ $('#LoginWithAjax_Status').attr('class','invalid').html('An error has occured. Please try again.'+status);
90
+ }else{
91
+ $('<span id="LoginWithAjax_Status" class="invalid">An error has occured. Please try again.</span>').prependTo('#login-with-ajax');
92
+ }
93
+ }
94
+ });
95
+ });
96
+ $('#LoginWithAjax_Remember').hide();
97
+ $('#LoginWithAjax_Links_Remember').click(function(event){
98
+ event.preventDefault();
99
+ $('#LoginWithAjax_Remember').show('slow');
100
+ });
101
+ $('#LoginWithAjax_Links_Remember_Cancel').click(function(event){
102
+ event.preventDefault();
103
+ $('#LoginWithAjax_Remember').hide('slow');
104
+ });
105
+ });
readme.txt CHANGED
@@ -3,8 +3,8 @@
3
  Contributors: netweblogic
4
  Tags: Login, Ajax, Redirect, BuddyPress, MU, WPMU, sidebar, admin, widget
5
  Requires at least: 2.7
6
- Tested up to: 2.8.2
7
- Stable tag: 1.2
8
 
9
  Add smooth ajax during login, avoid screen refreshes and choose where users get redirected to upon login/logout. Supports SSL, MU, and BuddyPress.
10
 
@@ -12,15 +12,24 @@ Add smooth ajax during login, avoid screen refreshes and choose where users get
12
 
13
  For sites that need user logins and would like to avoid the normal wordpress login, this plugin adds the capability of placing a login widget in the sidebar with smooth AJAX login effects.
14
 
15
- Compatible with Wordpress, Wordpress MU and BuddyPress. Will work with forced SSL logins.
16
 
17
- This plugin allows full customization of your widget html by allowing you to create template files within your theme folder.
 
 
 
 
 
 
 
18
 
19
- Another useful feature (which can be used without the widget) is login and logout redirects, so you control where the user is taken upon login and logout.
20
 
21
- If you have any problems with the plugins, please leave a comment on the plugin page or at least give feedback before giving a low rating. It's rude to just give low ratings and nothing else.
22
 
23
- If you find this plugin useful and would like to donate something, all we ask is you please add a link on your site to the plugin page on our blog or digg our plugin page [http://netweblogic.com/wordpress/plugins/login-with-ajax/](http://netweblogic.com/wordpress/plugins/login-with-ajax/) thanks!
 
 
24
 
25
  == Changelog ==
26
 
@@ -35,6 +44,16 @@ If you find this plugin useful and would like to donate something, all we ask is
35
  * Fixed redirection issue.
36
  * Added link to wp-admin profile page when logged in to default widget template.
37
 
 
 
 
 
 
 
 
 
 
 
38
  == Installation ==
39
 
40
  1. Upload this plugin to the `/wp-content/plugins/` directory and unzip it, or simply upload the zip file within your wordpress installation.
@@ -49,13 +68,19 @@ If you find this plugin useful and would like to donate something, all we ask is
49
 
50
  == Notes ==
51
 
 
 
 
 
52
  When creating customized themes for your widget, there are a few points to consider:
53
 
54
  * Start by copying the files in the /yourpluginpath/login-with-ajax/widget/ folder to /yourthemepath/plugins/login-with-ajax/
 
55
  * If you want to customize the login-with-ajax.js javascript, you can also copy that into the same folder above.
56
- * Unless you change the javascript, make sure you wrap your widget with an element with id="login-with-ajax". If you use the $before_widget ... variables, this should be done automatically.
57
  * To force SSL, see [http://codex.wordpress.org/Administration_Over_SSL]("this page"). The plugin will automatically detect the wordpress settings.
58
 
 
59
  == Screenshots ==
60
 
61
  1. Add a login widget to your sidebars. Widget html is fully customizable and upgrade safe since they go in your theme files.
@@ -70,4 +95,5 @@ When creating customized themes for your widget, there are a few points to consi
70
 
71
  == Frequently Asked Questions ==
72
 
73
- None yet!
 
3
  Contributors: netweblogic
4
  Tags: Login, Ajax, Redirect, BuddyPress, MU, WPMU, sidebar, admin, widget
5
  Requires at least: 2.7
6
+ Tested up to: 2.8.4
7
+ Stable tag: 1.3
8
 
9
  Add smooth ajax during login, avoid screen refreshes and choose where users get redirected to upon login/logout. Supports SSL, MU, and BuddyPress.
10
 
12
 
13
  For sites that need user logins and would like to avoid the normal wordpress login, this plugin adds the capability of placing a login widget in the sidebar with smooth AJAX login effects.
14
 
15
+ Some of the features:
16
 
17
+ * Login without refreshing your screen!
18
+ * Password retrieval now available within the widget.
19
+ * Compatible with Wordpress, Wordpress MU and BuddyPress.
20
+ * Will work with forced SSL logins.
21
+ * Customizable, upgrade-safe widgets.
22
+ * Redirect users to custom URLs on Login and Logout
23
+ * Redirect users with different roles to custom URLs
24
+ * shortcode and template tags available
25
 
26
+ If you have any problems with the plugins, please leave a comment on the plugin page (not on the WP forums please) or at least give feedback before giving a low rating. It's considered rude to just give low ratings and nothing reason for doing so.
27
 
28
+ If you find this plugin useful please show some love by adding a link on your site to the plugin page on our blog or digg our plugin page [http://netweblogic.com/wordpress/plugins/login-with-ajax/](http://netweblogic.com/wordpress/plugins/login-with-ajax/) thanks!
29
 
30
+ = Important information if upgrading and you have a customized widget =
31
+
32
+ If you customized the widget, two small changes were made to the default template which you should copy over if you'd like the remember password feature to work. The change requires that you add the ID attribute "LoginWithAjax_Links_Remember" to the remember password link. Also, you need to copy the new element and contents of the <form> below the first one with the ID "LoginWithAjax_Remember" and ensure you don't have another element with that ID in your template. Sorry, first and last time that will happen :)
33
 
34
  == Changelog ==
35
 
44
  * Fixed redirection issue.
45
  * Added link to wp-admin profile page when logged in to default widget template.
46
 
47
+ = 1.3 =
48
+ * Fixed widget template $before_widget... variables being used with shorttag and template tag functions
49
+ * Added JSON encoding compatability for PHP4
50
+ * Fixed bad link for non root hosted sites in template
51
+ * Added forgot password widget
52
+ * Added redirect capability based on user roles
53
+ * Fixed template locating to handle child themes
54
+ * Added Shortcode
55
+
56
+
57
  == Installation ==
58
 
59
  1. Upload this plugin to the `/wp-content/plugins/` directory and unzip it, or simply upload the zip file within your wordpress installation.
68
 
69
  == Notes ==
70
 
71
+ You can use the shortcode [login-with-ajax] or [lwa] and template tag login_with_ajax() :
72
+
73
+ * The only option you can add there is "is_widget=true|false". By default it's set to false, if true it uses the $before_widget/$after_widget variables.
74
+
75
  When creating customized themes for your widget, there are a few points to consider:
76
 
77
  * Start by copying the files in the /yourpluginpath/login-with-ajax/widget/ folder to /yourthemepath/plugins/login-with-ajax/
78
+ * If you have a child theme, you can place the customizations in the child or parent folder (you should probably want to put it in the child folder).
79
  * If you want to customize the login-with-ajax.js javascript, you can also copy that into the same folder above.
80
+ * Unless you change the javascript, make sure you wrap your widget with an element with id="login-with-ajax" or "LoginWithAjax". If you use the $before_widget ... variables, this should be done automatically depending on your theme. I recommend you just wrap a div with id="LoginWithAjax" for fuller compatability across themes.
81
  * To force SSL, see [http://codex.wordpress.org/Administration_Over_SSL]("this page"). The plugin will automatically detect the wordpress settings.
82
 
83
+
84
  == Screenshots ==
85
 
86
  1. Add a login widget to your sidebars. Widget html is fully customizable and upgrade safe since they go in your theme files.
95
 
96
  == Frequently Asked Questions ==
97
 
98
+ How do I use SSL with this plugin?
99
+ To force SSL, see [http://codex.wordpress.org/Administration_Over_SSL]("this page"). The plugin will automatically detect the wordpress settings.
screenshot-6.jpg ADDED
Binary file
widget/widget.css CHANGED
@@ -1,8 +1,8 @@
1
- #login-with-ajax { margin-bottom:10px; position:relative; font-size:1em; }
2
- #login-with-ajax td { padding-top:7px; vertical-align:top; }
3
 
4
  /*Logged out CSS*/
5
- #login-with-ajax .password_label, #login-with-ajax .username_label { padding-right:10px; vertical-align:middle; }
6
  #LoginWithAjax_Password input, #LoginWithAjax_Username input { width:97%; }
7
 
8
  #LoginWithAjax_Loading { position:absolute; width:100%; height:100%; background:#FFFFFF url(loading.gif) 50% 50% no-repeat; left:0px; top:0px; opacity:0.8; filter:alpha(opacity=80)}
@@ -12,4 +12,9 @@
12
  #LoginWithAjax_Status.confirm { color:#009900; }
13
 
14
  /*Logged In CSS*/
15
- #LoginWithAjax_Avatar { width:60px; }
 
 
 
 
 
1
+ #LoginWithAjax { margin-bottom:10px; position:relative; font-size:1em; }
2
+ #LoginWithAjax td { padding-top:7px; vertical-align:top; }
3
 
4
  /*Logged out CSS*/
5
+ #LoginWithAjax .password_label, #LoginWithAjax .username_label { padding-right:10px; vertical-align:middle; }
6
  #LoginWithAjax_Password input, #LoginWithAjax_Username input { width:97%; }
7
 
8
  #LoginWithAjax_Loading { position:absolute; width:100%; height:100%; background:#FFFFFF url(loading.gif) 50% 50% no-repeat; left:0px; top:0px; opacity:0.8; filter:alpha(opacity=80)}
12
  #LoginWithAjax_Status.confirm { color:#009900; }
13
 
14
  /*Logged In CSS*/
15
+ #LoginWithAjax_Avatar { width:60px; }
16
+
17
+ /*Forgotten password*/
18
+ #LoginWithAjax_Remember { margin-top:5px; display:none; }
19
+ #LoginWithAjax_Remember p { padding: 0px 0px 3px 0px }
20
+ #LoginWithAjax_Remember .forgot-pass-email input { width:97%; padding:2px; color:#666; }
widget/widget_in.php CHANGED
@@ -7,8 +7,11 @@
7
  ?>
8
  <?php
9
  global $current_user;
10
- echo $before_widget . $before_title . __( 'Hi '. ucwords($current_user->display_name) ) . $after_title;
 
 
11
  ?>
 
12
  <?php
13
  global $current_user;
14
  global $wpmu_version;
@@ -54,7 +57,7 @@
54
  }
55
  }
56
  ?>
57
- | <a href="/wp-admin/">blog admin</a>
58
  <?php
59
  }
60
  ?>
@@ -84,6 +87,9 @@
84
  ?>
85
  </div>
86
  <?php endif; ?>
 
87
  <?php
88
- echo $after_widget;
 
 
89
  ?>
7
  ?>
8
  <?php
9
  global $current_user;
10
+ if( $is_widget ){
11
+ echo $before_widget . $before_title . __( 'Hi ' ) . ucwords($current_user->display_name) . $after_title;
12
+ }
13
  ?>
14
+ <div id="LoginWithAjax">
15
  <?php
16
  global $current_user;
17
  global $wpmu_version;
57
  }
58
  }
59
  ?>
60
+ | <a href="<?php bloginfo('siteurl') ?>/wp_admin/">blog admin</a>
61
  <?php
62
  }
63
  ?>
87
  ?>
88
  </div>
89
  <?php endif; ?>
90
+ </div>
91
  <?php
92
+ if( $is_widget ){
93
+ echo $after_widget;
94
+ }
95
  ?>
widget/widget_out.php CHANGED
@@ -6,64 +6,92 @@
6
  */
7
  ?>
8
  <?php
9
- echo $before_widget . $before_title . __('Log In') . $after_title;
 
 
10
  ?>
11
- <span id="LoginWithAjax_Status"></span>
12
- <form name="LoginWithAjax_Form" id="LoginWithAjax_Form" action="<?php echo site_url('wp-login.php', 'login_post') ?>" method="post">
13
- <table width='100%' cellspacing="0" cellpadding="0">
14
- <tr id="LoginWithAjax_Username">
15
- <td class="username_label">
16
- <label><?php _e( 'Username' ) ?></label>
17
- </td>
18
- <td class="username_input">
19
- <input type="text" name="log" id="lwa_user_login" class="input" value="<?php echo attribute_escape(stripslashes($user_login)); ?>" />
20
- </td>
21
- </tr>
22
- <tr id="LoginWithAjax_Password">
23
- <td class="password_label">
24
- <label><?php _e( 'Password' ) ?></label>
25
- </td>
26
- <td class="password_input">
27
- <input type="password" name="pwd" id="lwa_user_pass" class="input" value="" />
28
- </td>
29
- </tr>
30
- <tr id="LoginWithAjax_Submit">
31
- <td id="LoginWithAjax_SubmitButton">
32
- <input type="submit" name="wp-submit" id="lwa_wp-submit" value="<?php _e('Log In'); ?>" tabindex="100" />
33
- <input type="hidden" name="redirect_to" value="http://<?php echo $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] ?>" />
34
- <input type="hidden" name="testcookie" value="1" />
35
- <input type="hidden" name="login-with-ajax" value="login" />
36
- </td>
37
- <td id="LoginWithAjax_Remember">
38
- <input name="rememberme" type="checkbox" id="lwa_rememberme" value="forever" /> <label><?php _e( 'Remember Me' ) ?></label>
39
- <br />
40
- <a href="<?php echo site_url('wp-login.php?action=lostpassword', 'login') ?>" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a>
41
- <?php
42
- //Signup Links
43
- if ( get_option('users_can_register')/*&& get_option('login-with-ajax_register')=='1'*/ ) {
44
- echo "<br />";
45
- // MU FIX
46
- global $wpmu_version;
47
- if (empty($wpmu_version)) {
48
- ?>
49
- <a href="<?php echo site_url('wp-login.php?action=register', 'login') ?>"><?php _e('Register') ?></a>
50
- <?php
51
- } else {
52
- ?>
53
- <a href="<?php echo site_url('wp-signup.php', 'login') ?>"><?php _e('Register') ?></a>
54
- <?php
55
- }
56
- } elseif ( true/*&& get_option('login-with-ajax_register')=='1'*/ && function_exists('bp_signup_page') ){
57
- echo "<br />";
58
- ?>
59
- <a href="<?php echo bp_signup_page() ?>" title="<?php _e( 'Sign Up' ) ?>" rel="nofollow" /><?php _e( 'Sign Up' ) ?></a>
60
- <?php
61
- }
62
- ?>
63
- </td>
64
- </tr>
65
- </table>
66
- </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  <?php
68
- echo $after_widget;
 
 
69
  ?>
6
  */
7
  ?>
8
  <?php
9
+ if( $is_widget ){
10
+ echo $before_widget . $before_title . __('Log In') . $after_title;
11
+ }
12
  ?>
13
+ <div id="LoginWithAjax">
14
+ <span id="LoginWithAjax_Status"></span>
15
+ <form name="LoginWithAjax_Form" id="LoginWithAjax_Form" action="<?php echo site_url('wp-login.php', 'login_post') ?>" method="post">
16
+ <table width='100%' cellspacing="0" cellpadding="0">
17
+ <tr id="LoginWithAjax_Username">
18
+ <td class="username_label">
19
+ <label><?php _e( 'Username' ) ?></label>
20
+ </td>
21
+ <td class="username_input">
22
+ <input type="text" name="log" id="lwa_user_login" class="input" value="<?php echo attribute_escape(stripslashes($user_login)); ?>" />
23
+ </td>
24
+ </tr>
25
+ <tr id="LoginWithAjax_Password">
26
+ <td class="password_label">
27
+ <label><?php _e( 'Password' ) ?></label>
28
+ </td>
29
+ <td class="password_input">
30
+ <input type="password" name="pwd" id="lwa_user_pass" class="input" value="" />
31
+ </td>
32
+ </tr>
33
+ <tr id="LoginWithAjax_Submit">
34
+ <td id="LoginWithAjax_SubmitButton">
35
+ <input type="submit" name="wp-submit" id="lwa_wp-submit" value="<?php _e('Log In'); ?>" tabindex="100" />
36
+ <input type="hidden" name="redirect_to" value="http://<?php echo $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] ?>" />
37
+ <input type="hidden" name="testcookie" value="1" />
38
+ <input type="hidden" name="login-with-ajax" value="login" />
39
+ </td>
40
+ <td id="LoginWithAjax_Links">
41
+ <input name="rememberme" type="checkbox" id="lwa_rememberme" value="forever" /> <label><?php _e( 'Remember Me' ) ?></label>
42
+ <br />
43
+ <a id="LoginWithAjax_Links_Remember" href="<?php echo site_url('wp-login.php?action=lostpassword', 'login') ?>" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a>
44
+ <?php
45
+ //Signup Links
46
+ if ( get_option('users_can_register')/*&& get_option('login-with-ajax_register')=='1'*/ ) {
47
+ echo "<br />";
48
+ // MU FIX
49
+ global $wpmu_version;
50
+ if (empty($wpmu_version)) {
51
+ ?>
52
+ <a href="<?php echo site_url('wp-login.php?action=register', 'login') ?>"><?php _e('Register') ?></a>
53
+ <?php
54
+ } else {
55
+ ?>
56
+ <a href="<?php echo site_url('wp-signup.php', 'login') ?>"><?php _e('Register') ?></a>
57
+ <?php
58
+ }
59
+ } elseif ( true/*&& get_option('login-with-ajax_register')=='1'*/ && function_exists('bp_signup_page') ){
60
+ echo "<br />";
61
+ ?>
62
+ <a href="<?php echo bp_signup_page() ?>" title="<?php _e( 'Sign Up' ) ?>" rel="nofollow" /><?php _e( 'Sign Up' ) ?></a>
63
+ <?php
64
+ }
65
+ ?>
66
+ </td>
67
+ </tr>
68
+ </table>
69
+ </form>
70
+ <form name="LoginWithAjax_Remember" id="LoginWithAjax_Remember" action="<?php echo site_url('wp-login.php?action=lostpassword', 'login_post') ?>" method="post">
71
+ <table width='100%' cellspacing="0" cellpadding="0">
72
+ <tr>
73
+ <td>
74
+ <strong><?php echo __("Forgotten Password") ?></strong>
75
+ </td>
76
+ </tr>
77
+ <tr>
78
+ <td class="forgot-pass-email">
79
+ <?php $msg = __("Enter username or email"); ?>
80
+ <input type="text" name="user_login" id="lwa_user_remember" value="<?php echo $msg ?>" onfocus="if(this.value == '<?php echo $msg ?>'){this.value = '';}" onblur="if(this.value == ''){this.value = '<?php echo $msg ?>'}" />
81
+ </td>
82
+ </tr>
83
+ <tr>
84
+ <td>
85
+ <input type="submit" value="<?php echo __("Get New Password") ?>" />
86
+ <a href="#" id="LoginWithAjax_Links_Remember_Cancel">Cancel</a>
87
+ <input type="hidden" name="login-with-ajax" value="remember" />
88
+ </td>
89
+ </tr>
90
+ </table>
91
+ </form>
92
+ </div>
93
  <?php
94
+ if( $is_widget ){
95
+ echo $after_widget;
96
+ }
97
  ?>