Changeset 721036
- Timestamp:
- 05/31/2013 09:32:10 PM (13 years ago)
- Location:
- s8-custom-login-and-registration
- Files:
-
- 1 added
- 2 deleted
- 3 edited
- 15 copied
-
tags/0.8.5 (added)
-
tags/0.8.5/admin (copied) (copied from s8-custom-login-and-registration/trunk/admin)
-
tags/0.8.5/admin/settings.php (copied) (copied from s8-custom-login-and-registration/trunk/admin/settings.php)
-
tags/0.8.5/css (copied) (copied from s8-custom-login-and-registration/trunk/css)
-
tags/0.8.5/css/jquery-ui-1.9.0.custom.min.css (copied) (copied from s8-custom-login-and-registration/trunk/css/jquery-ui-1.9.0.custom.min.css)
-
tags/0.8.5/css/s8-login-admin.css (copied) (copied from s8-custom-login-and-registration/trunk/css/s8-login-admin.css)
-
tags/0.8.5/css/s8-login-basic-styles.css (copied) (copied from s8-custom-login-and-registration/trunk/css/s8-login-basic-styles.css)
-
tags/0.8.5/images (copied) (copied from s8-custom-login-and-registration/trunk/images)
-
tags/0.8.5/inc (copied) (copied from s8-custom-login-and-registration/trunk/inc)
-
tags/0.8.5/inc/forms.php (copied) (copied from s8-custom-login-and-registration/trunk/inc/forms.php) (1 diff)
-
tags/0.8.5/inc/functions.php (copied) (copied from s8-custom-login-and-registration/trunk/inc/functions.php)
-
tags/0.8.5/inc/login.php (deleted)
-
tags/0.8.5/inc/register.php (deleted)
-
tags/0.8.5/inc/s8-login-widget.php (copied) (copied from s8-custom-login-and-registration/trunk/inc/s8-login-widget.php)
-
tags/0.8.5/js (copied) (copied from s8-custom-login-and-registration/trunk/js)
-
tags/0.8.5/js/s8-login-admin.js (copied) (copied from s8-custom-login-and-registration/trunk/js/s8-login-admin.js)
-
tags/0.8.5/readme.txt (copied) (copied from s8-custom-login-and-registration/trunk/readme.txt) (3 diffs)
-
tags/0.8.5/s8-login-registration.php (copied) (copied from s8-custom-login-and-registration/trunk/s8-login-registration.php) (13 diffs)
-
trunk/inc/forms.php (modified) (1 diff)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/s8-login-registration.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
s8-custom-login-and-registration/tags/0.8.5/inc/forms.php
r712965 r721036 4 4 */ 5 5 6 if (!function_exists('s8_clr_get_form')):6 if ( ! function_exists( 's8_clr_get_form' ) ): 7 7 /** 8 8 * Echos out the requested form 9 9 * @since 0.8.1 10 10 */ 11 function s8_clr_get_form( $form = 'login', $args = array(), $errors = false) {11 function s8_clr_get_form( $form = 'login', $args = array(), $errors = false ) { 12 12 global $s8_login_errors; 13 if($errors === false) 13 $args = array_merge( array( 14 // Work on ANY form 15 'split_lines' => false, // This splits the labels and form fields onto separate lines 16 'single_line' => false, // This, when true, displays the entire form without any line breaks 17 'use_html5_placeholders' => false, // When true, labels become HTML5 placeholder text instead 18 'submit_text' => false, // This changes the submit button text, false uses the forms default value 19 20 // Works only on login form 21 'hide_remember' => false, // Login form specific, hides the "Remember me" checkbox 22 ), $args ); 23 if ( $errors === false ) { 14 24 $errors = $s8_login_errors; 15 switch($form) { 16 case 'register': // Register user 17 $redirect_url = ($_GET['redirect'] != '')?$_GET['redirect']:home_url(); 18 ?><form method="post" action="<?php echo s8_get_register_url($redirect_url); ?>" name="register" class="s8_form register_form"> 19 <?php 20 if(is_wp_error($errors)) { 21 echo '<p class="error">'.$errors->get_error_message().'</p>'; 22 } 23 elseif($errors !== false && !empty($errors) && !is_array($errors)) 25 } 26 // Pick the right form 27 switch ( $form ) { 28 case 'register': 29 /***** REGISTRATION FORM *****/ 30 $redirect_url = ( $_GET['redirect'] != '' ) ? $_GET['redirect'] : home_url(); 31 // Output our form 32 ?><form method="post" action="<?php echo s8_get_register_url( $redirect_url ); ?>" name="register" class="s8_form register_form"><?php 33 // Output any errors we find 34 if ( is_wp_error( $errors ) ) { 35 echo '<p class="error">' . $errors->get_error_message() . '</p>'; 36 } elseif ( $errors !== false && ! empty( $errors ) && ! is_array( $errors ) ) { 24 37 echo '<p class="notice">'.$errors.'</p>'; 25 ?> 26 <p> 27 <input type="hidden" name="s8-register-nonce" value="<?php echo wp_create_nonce('s8-register-new-user') ?>" /> 28 <label for="username"><?php _e('Username'); ?></label> 29 <?php if($args['split_lines']) echo '<br/>'; ?> 30 <input type="text" name="username" id="username" value="<?php echo $_POST['username']; ?>" required="required" /><br/> 31 <label for="email"><?php _e('Email Address'); ?></label> 32 <?php if($args['split_lines']) echo '<br/>'; ?> 33 <input type="email" name="email" id="email" value="<?php echo $_POST['email']; ?>" required="required" /><br/> 34 A password will be e-mailed to you.<br/> 35 <input type="hidden" name="redirect" value="<?php echo $redirect_url?$redirect_url:''; ?>" /> 36 <input type="submit" name="s8-register" value="Register" /> 37 <?php if($args['login']) 38 echo '<br/>'.s8_get_login_link(false); 39 if($args['forgot']) 40 echo '<br/>'.s8_get_forgot_password_link(s8_get_current_url()); ?> 38 } ?> 39 <p> 40 <?php wp_nonce_field( plugin_dir_path( S8_LOGIN_FILE ), 's8-clr-register-nonce' ); 41 //<input type="hidden" name="s8-register-nonce" value="<?php echo wp_create_nonce('s8-register-new-user') ? >" /> 42 43 // USERNAME FIELD AND LABEL 44 if ( ! $args['use_html5_placeholders'] ) { // Don't display if we are using html5 placeholders 45 ?><label for="username"><?php _e( 'Username' ); ?></label><?php 46 } 47 if ( $args['split_lines'] && ! $args['single_line'] ) echo '<br/>'; ?> 48 <input type="text" name="username" id="username" value="<?php echo $_POST['username']; ?>" required="required" <?php if ( $args['use_html5_placeholders'] ) echo 'placeholder="' . __( 'Username' ) . '"'; ?> /><?php 49 if ( ! $args['single_line'] ) echo '<br/>'; 50 51 // EMAIL ADDRESS FIELD AND LABEL 52 if ( ! $args['use_html5_placeholders'] ) { // Don't display if we are using html5 placeholders 53 ?><label for="email"><?php _e( 'Email Address' ); ?></label><?php 54 } 55 if ( $args['split_lines'] && ! $args['single_line'] ) echo '<br/>'; ?> 56 <input type="email" name="email" id="email" value="<?php echo $_POST['email']; ?>" required="required" <?php if ( $args['use_html5_placeholders'] ) echo 'placeholder="' . __( 'Email Address' ) . '"'; ?> /><?php 57 if ( ! $args['single_line'] ) echo '<br/>'; 58 59 // PASSWORD NOTICE 60 if ( $args['split_lines'] && ! $args['single_line'] ) echo '<br/>'; 61 _e( 'A password will be e-mailed to you.' ); 62 if ( ! $args['single_line'] ) echo '<br/>'; 63 64 // SUBMIT BUTTON AND LINKS ?> 65 <input type="hidden" name="redirect" value="<?php echo $redirect_url; ?>" /> 66 <input type="submit" name="s8-register" value="<?php echo ( $args['submit_text'] ) ? $args['submit_text'] : __( 'Register' ); ?>" /> 67 <?php 68 if ( $args['login'] ) { 69 echo ( $args['single_line'] ? '' : '<br/>' ) . s8_get_login_link( false ); 70 } 71 if ( $args['forgot'] ) { 72 echo ( $args['single_line'] ? '' : '<br/>' ) . s8_get_forgot_password_link( s8_get_current_url() ); 73 } ?> 41 74 </p> 42 75 </form><?php 43 76 break; 44 case 'reset': // Password reset 45 ?><form name="pass-reset" action="<?php echo home_url('/'.s8_login_registration::ep_login.'/?action=reset&key='.$_GET['key'].'&login='.$_GET['login']); ?>" method="post" class="s8_form reset_form"> 46 <?php 47 if(is_wp_error($errors)) { 48 echo '<p class="error">'.$errors->get_error_message().'</p>'; 49 } 50 elseif($errors !== false && !empty($errors) && !is_array($errors)) 51 echo '<p class="notice">'.$errors.'</p>'; 52 ?> 53 <p> 54 <input type="hidden" name="s8-login-nonce" value="<?php echo wp_create_nonce('s8_wp_custom_login-nonce-reset'); ?>" /> 55 <label for="new-pass"><?php _e('New Password'); ?></label> 56 <?php if($args['split_lines']) echo '<br/>'; ?> 57 <input type="password" name="new-pass" id="new-pass" /><br/> 58 <label for="new-pass-confirm"><?php _e('Confirm New Password'); ?></label> 59 <?php if($args['split_lines']) echo '<br/>'; ?> 60 <input type="password" name="new-pass-confirm" id="new-pass-confirm" /><br/> 61 <input type="submit" name="s8-login-reset" value="Change Password" /> 77 78 case 'reset': 79 /***** PASSWORD RESET FORM *****/ 80 // Output our form 81 ?><form name="pass-reset" action="<?php echo home_url( '/' . s8_login_registration::ep_login . '/?action=reset&key=' . $_GET['key'] . '&login=' . $_GET['login'] ); ?>" method="post" class="s8_form reset_form"><?php 82 // Output any errors we found 83 if ( is_wp_error( $errors ) ) { 84 echo '<p class="error">' . $errors->get_error_message() . '</p>'; 85 } elseif ( $errors !== false && ! empty( $errors ) && ! is_array( $errors ) ) { 86 echo '<p class="notice">' . $errors . '</p>'; 87 } ?> 88 <p> 89 <?php wp_nonce_field( plugin_dir_path( S8_LOGIN_FILE ), 's8-clr-reset-nonce' ); 90 // <input type="hidden" name="s8-login-nonce" value="<?php echo wp_create_nonce('s8_wp_custom_login-nonce-reset'); ? >" /> 91 92 // NEW PASSWORD FIELD AND LABEL 93 if ( ! $args['use_html5_placeholders'] ) { // Don't display if we are using html5 placeholders 94 ?><label for="new-pass"><?php _e( 'New Password' ); ?></label><?php 95 } 96 if ( $args['split_lines'] && ! $args['single_line'] ) echo '<br/>'; ?> 97 <input type="password" name="new-pass" id="new-pass" <?php if ( $args['use_html5_placeholders'] ) echo 'placeholder="' . __( 'New Password' ) . '"'; ?> /><?php 98 if ( ! $args['single_line'] ) echo '<br/>'; 99 100 // CONFIRM NEW PASSWORD FIELD AND LABEL 101 if ( ! $args['use_html5_placeholders'] ) { // Don't display if we are using html5 placeholders 102 ?><label for="new-pass-confirm"><?php _e( 'Confirm New Password' ); ?></label><?php 103 } 104 if ( $args['split_lines'] && ! $args['single_line'] ) echo '<br/>'; ?> 105 <input type="password" name="new-pass-confirm" id="new-pass-confirm" <?php if ( $args['use_html5_placeholders'] ) echo 'placeholder="' . __( 'Confirm New Password' ) . '"'; ?> /><?php 106 if ( ! $args['single_line'] ) echo '<br/>'; 107 108 // SUBMIT BUTTON ?> 109 <input type="submit" name="s8-login-reset" value="<?php echo ( $args['submit_text'] ) ? $args['submit_text'] : __( 'Change Password' ); ?>" /> 62 110 </p> 63 111 </form><?php 64 112 break; 65 case 'forgot': // Forgot password 66 ?><form name="forgot" action="<?php echo s8_get_forgot_password_url(); ?>" method="post" class="s8_form forgot_form"> 67 <?php 68 if(is_wp_error($errors)) { 69 echo '<p class="error">'.$errors->get_error_message().'</p>'; 70 } 71 elseif($errors !== false && !empty($errors) && !is_array($errors)) 72 echo '<p class="notice">'.$errors.'</p>'; 73 ?> 74 <p> 75 <input type="hidden" name="s8-login-nonce" value="<?php echo wp_create_nonce('s8_wp_custom_login-nonce-forgot'); ?>" /> 76 <label for="user_login"><?php _e('Username or Email'); ?></label> 77 <?php if($args['split_lines']) echo '<br/>'; ?> 78 <input type="text" name="user_login" id="user_login" value="<?php echo $_POST['user_login']; ?>" /><br/> 113 114 case 'forgot': 115 /***** FORGOT PASSWORD FORM *****/ 116 // Output our form 117 ?><form name="forgot" action="<?php echo s8_get_forgot_password_url(); ?>" method="post" class="s8_form forgot_form"><?php 118 // Output any errors we found 119 if ( is_wp_error( $errors ) ) { 120 echo '<p class="error">' . $errors->get_error_message() . '</p>'; 121 } elseif ( $errors !== false && ! empty( $errors ) && ! is_array( $errors ) ) { 122 echo '<p class="notice">' . $errors . '</p>'; 123 } ?> 124 <p> 125 <?php wp_nonce_field( plugin_dir_path( S8_LOGIN_FILE ), 's8-clr-forgot-nonce' ); 126 //<input type="hidden" name="s8-login-nonce" value="<?php echo wp_create_nonce('s8_wp_custom_login-nonce-forgot'); ? >" /> 127 // USERNAME OR EMAIL FIELD AND LABEL 128 if ( ! $args['use_html5_placeholders'] ) { // Don't display if we are using html5 placeholders 129 ?><label for="user_login"><?php _e( 'Username or Email Address' ); ?></label><?php 130 } 131 if ( $args['split_lines'] && ! $args['single_line'] ) echo '<br/>'; ?> 132 <input type="text" name="user_login" id="user_login" value="<?php echo $_POST['user_login']; ?>" <?php if ( $args['use_html5_placeholders'] ) echo 'placeholder="' . __( 'Username or Email Address' ) . '"'; ?> /><?php 133 if ( ! $args['single_line'] ) echo '<br/>'; 134 135 // SUBMIT BUTTON AND LINKS ?> 79 136 <input type="submit" name="s8-login-forgot" value="Get New Password" /> 80 <?php if($args['login']) 81 echo '<br/>'.s8_get_login_link(); 82 if($args['register'] && get_option('users_can_register')) 83 echo '<br/>'.s8_get_register_link(s8_get_current_url()); ?> 137 <?php 138 if ( $args['login'] ) { 139 echo ( $args['single_line'] ? '' : '<br/>' ) . s8_get_login_link(); 140 } 141 if ( $args['register'] && get_option( 'users_can_register' ) ) { 142 echo ( $args['single_line'] ? '' : '<br/>' ) . s8_get_register_link( s8_get_current_url() ); 143 } ?> 84 144 </p> 85 145 </form><?php 86 146 break; 87 default: // Login form 88 $redirect_url = ($_GET['redirect'] != '')?$_GET['redirect']:s8_get_current_url(); 147 148 default: 149 /***** LOGIN FORM *****/ 89 150 global $wp_query; 90 if(isset($wp_query->query_vars[s8_login_registration::ep_login]) && s8_get_current_url() == $redirect_url) 151 // Get our redirect url 152 $redirect_url = ( $_GET['redirect'] != '' ) ? $_GET['redirect'] : s8_get_current_url(); 153 if ( isset( $wp_query->query_vars[s8_login_registration::ep_login] ) && s8_get_current_url() == $redirect_url ) { 91 154 $redirect_url = home_url(); 92 ?><form action="<?php echo s8_get_login_url($redirect_url); ?>" name="login" method="post" class="s8_form login_form"> 93 <?php 94 if(is_wp_error($errors)) { 95 echo '<p class="error">'.$errors->get_error_message().'</p>'; 96 } 97 elseif($errors !== false && !empty($errors) && !is_array($errors)) 98 echo '<p class="notice">'.$errors.'</p>'; 99 ?> 100 <p> 101 <input type="hidden" name="s8-login-nonce" value="<?php echo wp_create_nonce('s8_CLR-login-nonce'); ?>" /> 155 } 156 // Output our form 157 ?><form action="<?php echo s8_get_login_url( $redirect_url ); ?>" name="login" method="post" class="s8_form login_form"><?php 158 // Output any errors we found 159 if ( is_wp_error( $errors ) ) { 160 echo '<p class="error">' . $errors->get_error_message() . '</p>'; 161 } elseif ( $errors !== false && ! empty( $errors ) && ! is_array( $errors ) ) { 162 echo '<p class="notice">' . $errors . '</p>'; 163 } ?> 164 <p> 165 <?php wp_nonce_field( plugin_dir_path( S8_LOGIN_FILE ), 's8-clr-login-nonce' ); 166 // <input type="hidden" name="s8-login-nonce" value="<?php echo wp_create_nonce( 's8_CLR-login-nonce' ); ? >" /> 167 // USERNAME FIELD AND LABEL 168 if ( ! $args['use_html5_placeholders'] ) { // Don't display if we are using html5 placeholders 169 ?><label for="username"><?php _e( 'Username' ); ?></label><?php 170 } 171 if ( $args['split_lines'] && ! $args['single_line'] ) echo '<br/>'; ?> 172 <input type="text" name="username" id="username" <?php if ( $args['use_html5_placeholders'] ) echo 'placeholder="' . __( 'Username' ) . '"'; ?> /><?php 173 if ( ! $args['single_line'] ) echo '<br/>'; 174 175 // PASSWORD FIELD AND LABEL 176 if ( ! $args['use_html5_placeholders'] ) { // Don't display if we are using html5 placeholders 177 ?><label for="pwd"><?php _e('Password'); ?></label><?php 178 } 179 if ( $args['split_lines'] && ! $args['single_line'] ) echo '<br/>'; ?> 180 <input type="password" name="pwd" id="pwd" <?php if ( $args['use_html5_placeholders'] ) echo 'placeholder="' . __( 'Password' ) . '"'; ?> /><?php 181 if ( ! $args['single_line'] ) echo '<br/>'; 182 183 //do_action('login_form'); // TODO: Look at integrating this and how it all works 184 185 // REMEMBER ME CHECKBOX 186 if ( ! $args['hide_remember'] ) { ?> 187 <input type="checkbox" id="remember-me" name="remember" value="forever" /> <label for="remember-me"><? _e( 'Remember me' ); ?></label><?php 188 if ( ! $args['single_line'] ) echo '<br/>'; 189 } 190 191 // SUBMIT BUTTON AND LINKS ?> 102 192 <input type="hidden" name="redirect" value="<?php echo $redirect_url; ?>" /> 103 <label for="username"><?php _e('Username'); ?></label> 104 <?php if($args['split_lines']) echo '<br/>'; ?> 105 <input type="text" name="username" id="username" /><br/> 106 <label for="pwd"><?php _e('Password'); ?></label> 107 <?php if($args['split_lines']) echo '<br/>'; ?> 108 <input type="password" name="pwd" id="pwd" /><br/> 109 <?php //do_action('login_form'); ?> 110 <input type="checkbox" id="remember-me" name="remember" value="forever" /> 111 <label for="remember-me"><? _e('Remember me'); ?></label><br /> 112 <input type="submit" name="s8-login" value="<?php _e('Login'); ?>" class="login-button" /> 113 <?php if($args['forgot']) 114 echo '<br/>'.s8_get_forgot_password_link(); 115 if($args['register'] && get_option('users_can_register')) 116 echo '<br/>'.s8_get_register_link(s8_get_current_url()); ?> 193 <input type="submit" name="s8-login" value="<?php echo ( $args['submit_text'] ) ? $args['submit_text'] : __( 'Login' ); ?>" class="login-button" /> 194 <?php 195 if ( $args['forgot'] ) { 196 echo ( $args['single_line'] ? '' : '<br/>' ) . s8_get_forgot_password_link(); 197 } 198 if ( $args['register'] && get_option( 'users_can_register' ) ) { 199 echo ( $args['single_line'] ? '' : '<br/>' ) . s8_get_register_link( s8_get_current_url() ); 200 } ?> 117 201 </p> 118 202 </form> -
s8-custom-login-and-registration/tags/0.8.5/readme.txt
r713234 r721036 1 1 === Sideways8 Custom Login and Registration === 2 2 Contributors: sideways8, technical_mastermind, areimann 3 Tags: custom login, login, registration, form, login widget, widget3 Tags: s8, sideways8, sideways 8, custom login, login, registration, form, login widget, widget, theme login, style login, theme, style log in, theme log in, log in, custom log in, brand, brand login, brand log in 4 4 Requires at least: 3.3 5 5 Tested up to: 3.5.1 6 Stable tag: 0.8. 46 Stable tag: 0.8.5 7 7 License: GPLv3 8 8 License URI: http://www.gnu.org/licenses/gpl-3.0.html 9 9 10 Quick and easy relocation of the login and registration forms to another page that matches your site.10 Hides the WP login page, allows you to "embed" login in a page, and allows customization on how the login page looks. 11 11 12 12 == Description == 13 13 The way your site is presented to your users is important. That is why we made the "Custom Login and Registration" plugin. It is designed so that both you and your users never see the built-in WP login, registration, and password reset forms. It is still compatible with all of WordPress' built-in functionality and logout links will still function as they should. A login form widget is included to make it easy for your non-logged in visitors to find the login form. You are even able to add content to the login, registration, forgot password and password reset pages through the settings page. 14 14 15 If you want to add a form to a page on your site, you can use the new shortcodes: `[s8-login-form]`, `[s8-registration-form]`, and `[s8-forgot-form]`. 15 If you want to add a form to a page on your site, you can use the following shortcodes: `[s8-login-form]`, `[s8-registration-form]`, and `[s8-forgot-form]`. 16 17 Note: This plugin requires that you use pretty permalinks 16 18 17 19 = Support/Help = … … 54 56 55 57 == Upgrade Notice == 58 = 0.8.5 = 59 Several major and minor bug fixes with some code improvements 56 60 = 0.8.4 = 57 61 Bug fix related to the password reset functionality. … … 66 70 67 71 == Changelog == 72 = 0.8.5 = 73 * Updated a function related to the login process to more effectively use WordPress' built-in methods 74 * Updated the login redirect priority to fire LATER so other plugins have the opportunity to do their own redirects 75 * Several other minor improvements and bug fixes 76 * Fixed a bug related to WordPress' default password protection of pages/posts 68 77 = 0.8.4 = 69 78 * Fixed a bug related to resetting a password -
s8-custom-login-and-registration/tags/0.8.5/s8-login-registration.php
r712965 r721036 4 4 * Plugin URI: http://sideways8.com/plugins/s8-custom-login-and-registration/ 5 5 * Description: The way your site is presented to your users is important. That is why we made the "Custom Login and Registration" plugin. It is designed so that both you and your users never see the built-in WP login, registration, and password reset forms. It is still compatible with all of WordPress' built-in functionality and logout links will still function as they should. It also comes with a login form widget to make it easy for your non-logged in visitors to find the login form. 6 * Tags: custom login, login, registration, form, login widget, widget7 * Version: 0.8. 46 * Tags: s8, sideways8, sideways 8, custom login, login, registration, form, login widget, widget, theme login, style login, theme, style log in, theme log in, log in, custom log in, brand, brand login, brand log in 7 * Version: 0.8.5 8 8 * Author: Sideways8 Interactive 9 9 * Author URI: http://sideways8.com/ … … 13 13 14 14 //define('S8_LOGIN_EP', 'login'); 15 define( 'S8_LOGIN_FILE', __FILE__);16 17 include_once( plugin_dir_path(S8_LOGIN_FILE).'inc/forms.php');18 include_once( plugin_dir_path(S8_LOGIN_FILE).'inc/functions.php');19 include_once( plugin_dir_path(S8_LOGIN_FILE).'inc/s8-login-widget.php');15 define( 'S8_LOGIN_FILE', __FILE__ ); 16 17 include_once( plugin_dir_path( S8_LOGIN_FILE ) . 'inc/forms.php' ); 18 include_once( plugin_dir_path( S8_LOGIN_FILE ) . 'inc/functions.php' ); 19 include_once( plugin_dir_path( S8_LOGIN_FILE ) . 'inc/s8-login-widget.php' ); 20 20 21 21 /** … … 26 26 class s8_login_registration { 27 27 const ep_login = 'login'; 28 private $version = '0.8. 4',28 private $version = '0.8.5', 29 29 $title = '404 Not Found', 30 30 $content = 'Sorry, what you are looking for could not be found!'; … … 36 36 function __construct() { 37 37 // Update if needed 38 if ($this->version != get_option('s8-login-registration-version')) $this->update();38 if ( $this->version != get_option( 's8-login-registration-version' ) ) $this->update(); 39 39 // Add our activation/deactivation hooks 40 register_activation_hook( S8_LOGIN_FILE, array($this, 'activation'));41 register_deactivation_hook( S8_LOGIN_FILE, array($this, 'deactivation'));40 register_activation_hook( S8_LOGIN_FILE, array( $this, 'activation' ) ); 41 register_deactivation_hook( S8_LOGIN_FILE, array( $this, 'deactivation' ) ); 42 42 // Add our endpoints 43 add_action( 'init', array($this, 'endpoints'));43 add_action( 'init', array( $this, 'endpoints' ) ); 44 44 // Add our posts and load the appropriate template 45 add_action( 'the_posts', array($this, 'the_posts'));46 add_action( 'template_include', array($this, 'template_include'));45 add_action( 'the_posts', array( $this, 'the_posts' ) ); 46 add_action( 'template_include', array( $this, 'template_include' ) ); 47 47 // Filter out the wrong urls in the reset password emails 48 add_filter( 'retrieve_password_message', array($this, 'filter_email_urls'), 10, 2);48 add_filter( 'retrieve_password_message', array( $this, 'filter_email_urls' ), 10, 2 ); 49 49 // Keep people from seeing the WP Login page 50 add_action( 'login_init', array($this, 'no_wp_login'));50 add_action( 'login_init', array( $this, 'no_wp_login' ) ); 51 51 // Work with the WordPress functions 52 add_filter( 'logout_url', array($this, 'logout_url'), 10, 2);53 add_filter( 'login_url', array($this, 'login_url'), 10, 2);54 add_filter( 'lostpassword_url', array($this, 'forgotpassword_url'), 10, 2);52 add_filter( 'logout_url', array( $this, 'logout_url' ), 10, 2 ); 53 add_filter( 'login_url', array( $this, 'login_url' ), 10, 2 ); 54 add_filter( 'lostpassword_url', array( $this, 'forgotpassword_url' ), 10, 2 ); 55 55 // Add our shortcodes 56 add_shortcode( 's8-login-form', array($this, 'login_shortcode'));57 add_shortcode( 's8-registration-form', array($this, 'registration_shortcode'));58 add_shortcode( 's8-forgot-form', array($this, 'forgot_shortcode'));59 add_shortcode( 's8-reset-form', array($this, 'reset_shortcode')); // This is intended for internal use ONLY56 add_shortcode( 's8-login-form', array( $this, 'login_shortcode' ) ); 57 add_shortcode( 's8-registration-form', array( $this, 'registration_shortcode' ) ); 58 add_shortcode( 's8-forgot-form', array( $this, 'forgot_shortcode' ) ); 59 add_shortcode( 's8-reset-form', array( $this, 'reset_shortcode' ) ); // This is intended for internal use ONLY 60 60 //add_filter('register', array($this, 'register_url')); 61 61 // Add our admin stuff 62 add_action('admin_menu', array($this, 'admin_menu')); 62 add_action( 'admin_menu', array( $this, 'admin_menu' ) ); 63 add_action( 'wp_login', array( $this, 'login_redirect' ), 99, 2 ); 63 64 } 64 65 … … 91 92 switch($_GET['action']) { 92 93 case 'register': 93 if (!get_option('users_can_register')) {94 wp_redirect( s8_get_login_url(home_url()));94 if ( ! get_option( 'users_can_register' ) ) { 95 wp_redirect( s8_get_login_url( home_url() ) ); 95 96 exit; 96 97 } 97 if ($_POST['s8-register']) {98 if ( isset( $_POST['s8-register'] ) ) { 98 99 $s8_login_errors = $this->register_user(); 99 100 } … … 103 104 break; 104 105 case 'reset': 105 define( 'S8_LOGIN_INIT', true);106 if ($_POST['s8-login-reset'] == 'Change Password') {106 define( 'S8_LOGIN_INIT', true ); 107 if ( isset( $_POST['s8-login-reset'] ) ) { 107 108 $s8_login_errors = $this->user_password_reset(); 108 109 } 109 $this->title = __( 'Reset Password');110 $this->title = __( 'Reset Password' ); 110 111 $this->content = '[s8-reset-form action="reset" s8_internal="true"]'; 111 112 //$this->display_template('login'); 112 113 break; 113 114 case 'forgot': 114 define( 'S8_LOGIN_INIT', true);115 if ($_POST['s8-login-forgot'] == 'Get New Password') {115 define( 'S8_LOGIN_INIT', true ); 116 if ( isset( $_POST['s8-login-forgot'] ) ) { 116 117 $s8_login_errors = $this->user_password_reset_request(); 117 118 } 118 $this->title = __( 'Forgot Password');119 $this->title = __( 'Forgot Password' ); 119 120 $this->content = '[s8-forgot-form s8_internal="true"]'; 120 121 //$this->display_template('login'); … … 122 123 default: 123 124 // Check if we are processing (and process if needed) 124 if ($_POST['s8-login'] == 'Login') {125 if ( isset( $_POST['s8-login'] ) ) { 125 126 $s8_login_errors = $this->login_user(); 126 127 } … … 150 151 151 152 /** 152 * 153 */ 154 function template_include($template) { 153 * Changes the template used for the form pages 154 * @param string $template 155 * @return string 156 * @since 0.8.3 157 */ 158 function template_include( $template ) { 155 159 global $wp_query; 156 if(!isset($wp_query->query_vars[self::ep_login])) return $template; 157 $order = array('s8-login.php', 'page.php', 'index.php'); 158 if($temp = get_option('s8_custom_login_form_template')) 159 $order = array($temp, 's8-login.php', 'page.php', 'index.php'); 160 $child_theme = get_stylesheet_directory(); 161 $parent_theme = get_template_directory(); 162 if($child_theme == $parent_theme) { 163 // Same theme! 164 foreach($order as $temp_file) { 165 if(file_exists($parent_theme.'/'.$temp_file)) 166 return $parent_theme.'/'.$temp_file; 167 } 168 } 169 else { 170 // Check child then parent 171 foreach($order as $temp_file) { 172 if(file_exists($child_theme.'/'.$temp_file)) 173 return $child_theme.'/'.$temp_file; 174 elseif(file_exists($parent_theme.'/'.$temp_file)) 175 return $parent_theme.'/'.$temp_file; 176 } 160 if ( isset( $wp_query->query_vars[self::ep_login] ) ) { 161 $order = array( 's8-login.php', 'page.php', 'index.php' ); 162 if ( $temp = get_option( 's8_custom_login_form_template' ) ) 163 $order = array( $temp, 's8-login.php', 'page.php', 'index.php' ); 164 $template = locate_template( $order ); 177 165 } 178 166 // If we fail to find an appropriate file, return what WP was going to use anyways. … … 186 174 */ 187 175 function register_user() { 188 if(!wp_verify_nonce($_POST['s8-register-nonce'], 's8-register-new-user')) die('An attempt to bypass security checks was detected! Please go back to the register form and try again.'); 176 if ( ! wp_verify_nonce( $_POST['s8-clr-register-nonce'], plugin_dir_path( S8_LOGIN_FILE ) ) ) 177 die('An attempt to bypass security checks was detected! Please go back to the register form and try again.'); 189 178 // Verify our data 190 179 if(empty($_POST['username']) || empty($_POST['email'])) … … 225 214 */ 226 215 function user_password_reset() { 227 if(!wp_verify_nonce($_POST['s8-login-nonce'], 's8_wp_custom_login-nonce-reset')) die('An attempt to bypass security checks was detected! Please go back to the password reset and try again.'); 216 if ( ! wp_verify_nonce( $_POST['s8-clr-reset-nonce'], plugin_dir_path( S8_LOGIN_FILE ) ) ) 217 die('An attempt to bypass security checks was detected! Please go back to the password reset and try again.'); 228 218 // We are updating our password! 229 219 ob_start(); … … 251 241 */ 252 242 function user_password_reset_request() { 253 if(!wp_verify_nonce($_POST['s8-login-nonce'], 's8_wp_custom_login-nonce-forgot')) die('An attempt to bypass security checks was detected! Please go back to the forgot password form and try again.'); 243 if ( ! wp_verify_nonce( $_POST['s8-clr-forgot-nonce'], plugin_dir_path( S8_LOGIN_FILE ) ) ) 244 die('An attempt to bypass security checks was detected! Please go back to the forgot password form, refresh the page, and try again.'); 254 245 // We are requesting a password reset! 255 246 ob_start(); … … 268 259 */ 269 260 function login_user() { 270 if(!wp_verify_nonce($_POST['s8-login-nonce'], 's8_CLR-login-nonce')) die('An attempt to bypass security checks was detected! Please go back to the login form and try again.'); 271 // We are logging in! 272 $username = sanitize_user($_POST['username']); 273 $user = wp_authenticate($username, $_POST['pwd']); 274 if(is_wp_error($user)) 275 return $user; 276 elseif($user && is_object($user) && $user->data->user_login == $username) { 277 if($_POST['remember'] == 'forever') $remember = true; 278 else $remember = false; 279 wp_set_current_user($user->ID, $username); 280 wp_set_auth_cookie($user->ID, $remember); 281 do_action('wp_login', $username); 282 // Check for custom redirect 283 global $current_user; 284 $redirects = get_option('s8_login_redirects'); 285 $role = $current_user->roles; 286 if(is_array($role)) $role = $role[0]; 287 // Do our redirect! 288 if(isset($redirects[$role])) $url = $redirects[$role]; 289 elseif($_POST['redirect'] != '') $url = $_POST['redirect']; 290 else $url = home_url('/'); 291 wp_redirect($url, 302); 292 exit; 293 } 294 else { 295 return new WP_Error('unexpected', 'An unexpected error occurred!'); 296 } 261 if ( ! wp_verify_nonce( $_POST['s8-clr-login-nonce'], plugin_dir_path( S8_LOGIN_FILE ) ) ) 262 die( 'An attempt to bypass security checks was detected! Please go back to the login form, refresh the page, and try again.' ); 263 $credentials = array( 264 'user_login' => sanitize_user( $_POST['username'] ), 265 'user_password' => $_POST['pwd'], 266 'remember' => ( empty( $_POST['remember'] ) ? false : true ) 267 ); 268 $user = wp_signon( $credentials ); 269 return $user; 270 } 271 272 /** 273 * This handles the redirection of our users after login, this was split off from our login_user function 274 * @param $user_login 275 * @param $user 276 * @since 0.8.5 277 */ 278 function login_redirect( $user_login, $user ) { 279 // Check for custom redirect 280 $redirects = get_option('s8_login_redirects'); 281 $role = $user->roles; 282 // Grab the first user role 283 if ( is_array( $role ) ) 284 $role = $role[0]; 285 // Setup our redirect URL 286 if ( isset( $redirects[$role] ) ) { 287 $url = $redirects[$role]; 288 } elseif ( $_POST['redirect'] != '' ) { 289 $url = $_POST['redirect']; 290 } else { 291 $url = home_url('/'); 292 } 293 // Redirect and exit to avoid errors 294 wp_redirect( $url, 302 ); 295 exit; 297 296 } 298 297 … … 302 301 */ 303 302 function no_wp_login() { 304 if(defined('S8_LOGIN_INIT') && S8_LOGIN_INIT === true) return; 305 $check = get_option('s8_allow_wp_register'); 306 if($check && $_REQUEST['action'] == 'register') return; 307 if($_GET['no-redirect'] == 'true') { 308 wp_enqueue_script('s8-login-failsafe', plugins_url('/js/s8-login-failsafe.js', S8_LOGIN_FILE), array('jquery')); 303 // This does something important... 304 if ( defined( 'S8_LOGIN_INIT' ) && S8_LOGIN_INIT === true ) 309 305 return; 310 } 311 if($_GET['redirect_to'] != '') $url = $_GET['redirect_to']; 312 else $url = false; 313 if($_GET['action'] == 'logout') 314 wp_redirect(s8_get_logout_url($url)); 315 elseif($_GET['action'] == 'register') 316 wp_redirect(s8_get_register_url($url)); 317 else 318 wp_redirect(s8_get_login_url($url)); 306 // See if we are trying to register and want to use the WP registration form 307 $check = get_option( 's8_allow_wp_register' ); 308 if ( $check && $_REQUEST['action'] == 'register' ) 309 return; 310 // Check if this is validation for a password protected post/page 311 if ( $_GET['action'] == 'postpass' ) 312 return; 313 // See if we are in no-redirect mode 314 if ( $_GET['no-redirect'] == 'true' ) { 315 wp_enqueue_script( 's8-login-failsafe', plugins_url( '/js/s8-login-failsafe.js', S8_LOGIN_FILE ), array( 'jquery' ) ); 316 return; 317 } 318 // Let's check for a redirect value 319 if ( $_GET['redirect_to'] != '' ) { 320 $url = $_GET['redirect_to']; 321 } else { 322 $url = false; 323 } 324 // Redirect away from the WP login page 325 if ( $_GET['action'] == 'logout' ) { 326 wp_redirect( s8_get_logout_url( $url ) ); 327 } elseif ( $_GET['action'] == 'register' ) { 328 wp_redirect( s8_get_register_url( $url ) ); 329 } else { 330 wp_redirect( s8_get_login_url( $url ) ); 331 } 319 332 exit; 320 333 } -
s8-custom-login-and-registration/trunk/inc/forms.php
r712965 r721036 4 4 */ 5 5 6 if (!function_exists('s8_clr_get_form')):6 if ( ! function_exists( 's8_clr_get_form' ) ): 7 7 /** 8 8 * Echos out the requested form 9 9 * @since 0.8.1 10 10 */ 11 function s8_clr_get_form( $form = 'login', $args = array(), $errors = false) {11 function s8_clr_get_form( $form = 'login', $args = array(), $errors = false ) { 12 12 global $s8_login_errors; 13 if($errors === false) 13 $args = array_merge( array( 14 // Work on ANY form 15 'split_lines' => false, // This splits the labels and form fields onto separate lines 16 'single_line' => false, // This, when true, displays the entire form without any line breaks 17 'use_html5_placeholders' => false, // When true, labels become HTML5 placeholder text instead 18 'submit_text' => false, // This changes the submit button text, false uses the forms default value 19 20 // Works only on login form 21 'hide_remember' => false, // Login form specific, hides the "Remember me" checkbox 22 ), $args ); 23 if ( $errors === false ) { 14 24 $errors = $s8_login_errors; 15 switch($form) { 16 case 'register': // Register user 17 $redirect_url = ($_GET['redirect'] != '')?$_GET['redirect']:home_url(); 18 ?><form method="post" action="<?php echo s8_get_register_url($redirect_url); ?>" name="register" class="s8_form register_form"> 19 <?php 20 if(is_wp_error($errors)) { 21 echo '<p class="error">'.$errors->get_error_message().'</p>'; 22 } 23 elseif($errors !== false && !empty($errors) && !is_array($errors)) 25 } 26 // Pick the right form 27 switch ( $form ) { 28 case 'register': 29 /***** REGISTRATION FORM *****/ 30 $redirect_url = ( $_GET['redirect'] != '' ) ? $_GET['redirect'] : home_url(); 31 // Output our form 32 ?><form method="post" action="<?php echo s8_get_register_url( $redirect_url ); ?>" name="register" class="s8_form register_form"><?php 33 // Output any errors we find 34 if ( is_wp_error( $errors ) ) { 35 echo '<p class="error">' . $errors->get_error_message() . '</p>'; 36 } elseif ( $errors !== false && ! empty( $errors ) && ! is_array( $errors ) ) { 24 37 echo '<p class="notice">'.$errors.'</p>'; 25 ?> 26 <p> 27 <input type="hidden" name="s8-register-nonce" value="<?php echo wp_create_nonce('s8-register-new-user') ?>" /> 28 <label for="username"><?php _e('Username'); ?></label> 29 <?php if($args['split_lines']) echo '<br/>'; ?> 30 <input type="text" name="username" id="username" value="<?php echo $_POST['username']; ?>" required="required" /><br/> 31 <label for="email"><?php _e('Email Address'); ?></label> 32 <?php if($args['split_lines']) echo '<br/>'; ?> 33 <input type="email" name="email" id="email" value="<?php echo $_POST['email']; ?>" required="required" /><br/> 34 A password will be e-mailed to you.<br/> 35 <input type="hidden" name="redirect" value="<?php echo $redirect_url?$redirect_url:''; ?>" /> 36 <input type="submit" name="s8-register" value="Register" /> 37 <?php if($args['login']) 38 echo '<br/>'.s8_get_login_link(false); 39 if($args['forgot']) 40 echo '<br/>'.s8_get_forgot_password_link(s8_get_current_url()); ?> 38 } ?> 39 <p> 40 <?php wp_nonce_field( plugin_dir_path( S8_LOGIN_FILE ), 's8-clr-register-nonce' ); 41 //<input type="hidden" name="s8-register-nonce" value="<?php echo wp_create_nonce('s8-register-new-user') ? >" /> 42 43 // USERNAME FIELD AND LABEL 44 if ( ! $args['use_html5_placeholders'] ) { // Don't display if we are using html5 placeholders 45 ?><label for="username"><?php _e( 'Username' ); ?></label><?php 46 } 47 if ( $args['split_lines'] && ! $args['single_line'] ) echo '<br/>'; ?> 48 <input type="text" name="username" id="username" value="<?php echo $_POST['username']; ?>" required="required" <?php if ( $args['use_html5_placeholders'] ) echo 'placeholder="' . __( 'Username' ) . '"'; ?> /><?php 49 if ( ! $args['single_line'] ) echo '<br/>'; 50 51 // EMAIL ADDRESS FIELD AND LABEL 52 if ( ! $args['use_html5_placeholders'] ) { // Don't display if we are using html5 placeholders 53 ?><label for="email"><?php _e( 'Email Address' ); ?></label><?php 54 } 55 if ( $args['split_lines'] && ! $args['single_line'] ) echo '<br/>'; ?> 56 <input type="email" name="email" id="email" value="<?php echo $_POST['email']; ?>" required="required" <?php if ( $args['use_html5_placeholders'] ) echo 'placeholder="' . __( 'Email Address' ) . '"'; ?> /><?php 57 if ( ! $args['single_line'] ) echo '<br/>'; 58 59 // PASSWORD NOTICE 60 if ( $args['split_lines'] && ! $args['single_line'] ) echo '<br/>'; 61 _e( 'A password will be e-mailed to you.' ); 62 if ( ! $args['single_line'] ) echo '<br/>'; 63 64 // SUBMIT BUTTON AND LINKS ?> 65 <input type="hidden" name="redirect" value="<?php echo $redirect_url; ?>" /> 66 <input type="submit" name="s8-register" value="<?php echo ( $args['submit_text'] ) ? $args['submit_text'] : __( 'Register' ); ?>" /> 67 <?php 68 if ( $args['login'] ) { 69 echo ( $args['single_line'] ? '' : '<br/>' ) . s8_get_login_link( false ); 70 } 71 if ( $args['forgot'] ) { 72 echo ( $args['single_line'] ? '' : '<br/>' ) . s8_get_forgot_password_link( s8_get_current_url() ); 73 } ?> 41 74 </p> 42 75 </form><?php 43 76 break; 44 case 'reset': // Password reset 45 ?><form name="pass-reset" action="<?php echo home_url('/'.s8_login_registration::ep_login.'/?action=reset&key='.$_GET['key'].'&login='.$_GET['login']); ?>" method="post" class="s8_form reset_form"> 46 <?php 47 if(is_wp_error($errors)) { 48 echo '<p class="error">'.$errors->get_error_message().'</p>'; 49 } 50 elseif($errors !== false && !empty($errors) && !is_array($errors)) 51 echo '<p class="notice">'.$errors.'</p>'; 52 ?> 53 <p> 54 <input type="hidden" name="s8-login-nonce" value="<?php echo wp_create_nonce('s8_wp_custom_login-nonce-reset'); ?>" /> 55 <label for="new-pass"><?php _e('New Password'); ?></label> 56 <?php if($args['split_lines']) echo '<br/>'; ?> 57 <input type="password" name="new-pass" id="new-pass" /><br/> 58 <label for="new-pass-confirm"><?php _e('Confirm New Password'); ?></label> 59 <?php if($args['split_lines']) echo '<br/>'; ?> 60 <input type="password" name="new-pass-confirm" id="new-pass-confirm" /><br/> 61 <input type="submit" name="s8-login-reset" value="Change Password" /> 77 78 case 'reset': 79 /***** PASSWORD RESET FORM *****/ 80 // Output our form 81 ?><form name="pass-reset" action="<?php echo home_url( '/' . s8_login_registration::ep_login . '/?action=reset&key=' . $_GET['key'] . '&login=' . $_GET['login'] ); ?>" method="post" class="s8_form reset_form"><?php 82 // Output any errors we found 83 if ( is_wp_error( $errors ) ) { 84 echo '<p class="error">' . $errors->get_error_message() . '</p>'; 85 } elseif ( $errors !== false && ! empty( $errors ) && ! is_array( $errors ) ) { 86 echo '<p class="notice">' . $errors . '</p>'; 87 } ?> 88 <p> 89 <?php wp_nonce_field( plugin_dir_path( S8_LOGIN_FILE ), 's8-clr-reset-nonce' ); 90 // <input type="hidden" name="s8-login-nonce" value="<?php echo wp_create_nonce('s8_wp_custom_login-nonce-reset'); ? >" /> 91 92 // NEW PASSWORD FIELD AND LABEL 93 if ( ! $args['use_html5_placeholders'] ) { // Don't display if we are using html5 placeholders 94 ?><label for="new-pass"><?php _e( 'New Password' ); ?></label><?php 95 } 96 if ( $args['split_lines'] && ! $args['single_line'] ) echo '<br/>'; ?> 97 <input type="password" name="new-pass" id="new-pass" <?php if ( $args['use_html5_placeholders'] ) echo 'placeholder="' . __( 'New Password' ) . '"'; ?> /><?php 98 if ( ! $args['single_line'] ) echo '<br/>'; 99 100 // CONFIRM NEW PASSWORD FIELD AND LABEL 101 if ( ! $args['use_html5_placeholders'] ) { // Don't display if we are using html5 placeholders 102 ?><label for="new-pass-confirm"><?php _e( 'Confirm New Password' ); ?></label><?php 103 } 104 if ( $args['split_lines'] && ! $args['single_line'] ) echo '<br/>'; ?> 105 <input type="password" name="new-pass-confirm" id="new-pass-confirm" <?php if ( $args['use_html5_placeholders'] ) echo 'placeholder="' . __( 'Confirm New Password' ) . '"'; ?> /><?php 106 if ( ! $args['single_line'] ) echo '<br/>'; 107 108 // SUBMIT BUTTON ?> 109 <input type="submit" name="s8-login-reset" value="<?php echo ( $args['submit_text'] ) ? $args['submit_text'] : __( 'Change Password' ); ?>" /> 62 110 </p> 63 111 </form><?php 64 112 break; 65 case 'forgot': // Forgot password 66 ?><form name="forgot" action="<?php echo s8_get_forgot_password_url(); ?>" method="post" class="s8_form forgot_form"> 67 <?php 68 if(is_wp_error($errors)) { 69 echo '<p class="error">'.$errors->get_error_message().'</p>'; 70 } 71 elseif($errors !== false && !empty($errors) && !is_array($errors)) 72 echo '<p class="notice">'.$errors.'</p>'; 73 ?> 74 <p> 75 <input type="hidden" name="s8-login-nonce" value="<?php echo wp_create_nonce('s8_wp_custom_login-nonce-forgot'); ?>" /> 76 <label for="user_login"><?php _e('Username or Email'); ?></label> 77 <?php if($args['split_lines']) echo '<br/>'; ?> 78 <input type="text" name="user_login" id="user_login" value="<?php echo $_POST['user_login']; ?>" /><br/> 113 114 case 'forgot': 115 /***** FORGOT PASSWORD FORM *****/ 116 // Output our form 117 ?><form name="forgot" action="<?php echo s8_get_forgot_password_url(); ?>" method="post" class="s8_form forgot_form"><?php 118 // Output any errors we found 119 if ( is_wp_error( $errors ) ) { 120 echo '<p class="error">' . $errors->get_error_message() . '</p>'; 121 } elseif ( $errors !== false && ! empty( $errors ) && ! is_array( $errors ) ) { 122 echo '<p class="notice">' . $errors . '</p>'; 123 } ?> 124 <p> 125 <?php wp_nonce_field( plugin_dir_path( S8_LOGIN_FILE ), 's8-clr-forgot-nonce' ); 126 //<input type="hidden" name="s8-login-nonce" value="<?php echo wp_create_nonce('s8_wp_custom_login-nonce-forgot'); ? >" /> 127 // USERNAME OR EMAIL FIELD AND LABEL 128 if ( ! $args['use_html5_placeholders'] ) { // Don't display if we are using html5 placeholders 129 ?><label for="user_login"><?php _e( 'Username or Email Address' ); ?></label><?php 130 } 131 if ( $args['split_lines'] && ! $args['single_line'] ) echo '<br/>'; ?> 132 <input type="text" name="user_login" id="user_login" value="<?php echo $_POST['user_login']; ?>" <?php if ( $args['use_html5_placeholders'] ) echo 'placeholder="' . __( 'Username or Email Address' ) . '"'; ?> /><?php 133 if ( ! $args['single_line'] ) echo '<br/>'; 134 135 // SUBMIT BUTTON AND LINKS ?> 79 136 <input type="submit" name="s8-login-forgot" value="Get New Password" /> 80 <?php if($args['login']) 81 echo '<br/>'.s8_get_login_link(); 82 if($args['register'] && get_option('users_can_register')) 83 echo '<br/>'.s8_get_register_link(s8_get_current_url()); ?> 137 <?php 138 if ( $args['login'] ) { 139 echo ( $args['single_line'] ? '' : '<br/>' ) . s8_get_login_link(); 140 } 141 if ( $args['register'] && get_option( 'users_can_register' ) ) { 142 echo ( $args['single_line'] ? '' : '<br/>' ) . s8_get_register_link( s8_get_current_url() ); 143 } ?> 84 144 </p> 85 145 </form><?php 86 146 break; 87 default: // Login form 88 $redirect_url = ($_GET['redirect'] != '')?$_GET['redirect']:s8_get_current_url(); 147 148 default: 149 /***** LOGIN FORM *****/ 89 150 global $wp_query; 90 if(isset($wp_query->query_vars[s8_login_registration::ep_login]) && s8_get_current_url() == $redirect_url) 151 // Get our redirect url 152 $redirect_url = ( $_GET['redirect'] != '' ) ? $_GET['redirect'] : s8_get_current_url(); 153 if ( isset( $wp_query->query_vars[s8_login_registration::ep_login] ) && s8_get_current_url() == $redirect_url ) { 91 154 $redirect_url = home_url(); 92 ?><form action="<?php echo s8_get_login_url($redirect_url); ?>" name="login" method="post" class="s8_form login_form"> 93 <?php 94 if(is_wp_error($errors)) { 95 echo '<p class="error">'.$errors->get_error_message().'</p>'; 96 } 97 elseif($errors !== false && !empty($errors) && !is_array($errors)) 98 echo '<p class="notice">'.$errors.'</p>'; 99 ?> 100 <p> 101 <input type="hidden" name="s8-login-nonce" value="<?php echo wp_create_nonce('s8_CLR-login-nonce'); ?>" /> 155 } 156 // Output our form 157 ?><form action="<?php echo s8_get_login_url( $redirect_url ); ?>" name="login" method="post" class="s8_form login_form"><?php 158 // Output any errors we found 159 if ( is_wp_error( $errors ) ) { 160 echo '<p class="error">' . $errors->get_error_message() . '</p>'; 161 } elseif ( $errors !== false && ! empty( $errors ) && ! is_array( $errors ) ) { 162 echo '<p class="notice">' . $errors . '</p>'; 163 } ?> 164 <p> 165 <?php wp_nonce_field( plugin_dir_path( S8_LOGIN_FILE ), 's8-clr-login-nonce' ); 166 // <input type="hidden" name="s8-login-nonce" value="<?php echo wp_create_nonce( 's8_CLR-login-nonce' ); ? >" /> 167 // USERNAME FIELD AND LABEL 168 if ( ! $args['use_html5_placeholders'] ) { // Don't display if we are using html5 placeholders 169 ?><label for="username"><?php _e( 'Username' ); ?></label><?php 170 } 171 if ( $args['split_lines'] && ! $args['single_line'] ) echo '<br/>'; ?> 172 <input type="text" name="username" id="username" <?php if ( $args['use_html5_placeholders'] ) echo 'placeholder="' . __( 'Username' ) . '"'; ?> /><?php 173 if ( ! $args['single_line'] ) echo '<br/>'; 174 175 // PASSWORD FIELD AND LABEL 176 if ( ! $args['use_html5_placeholders'] ) { // Don't display if we are using html5 placeholders 177 ?><label for="pwd"><?php _e('Password'); ?></label><?php 178 } 179 if ( $args['split_lines'] && ! $args['single_line'] ) echo '<br/>'; ?> 180 <input type="password" name="pwd" id="pwd" <?php if ( $args['use_html5_placeholders'] ) echo 'placeholder="' . __( 'Password' ) . '"'; ?> /><?php 181 if ( ! $args['single_line'] ) echo '<br/>'; 182 183 //do_action('login_form'); // TODO: Look at integrating this and how it all works 184 185 // REMEMBER ME CHECKBOX 186 if ( ! $args['hide_remember'] ) { ?> 187 <input type="checkbox" id="remember-me" name="remember" value="forever" /> <label for="remember-me"><? _e( 'Remember me' ); ?></label><?php 188 if ( ! $args['single_line'] ) echo '<br/>'; 189 } 190 191 // SUBMIT BUTTON AND LINKS ?> 102 192 <input type="hidden" name="redirect" value="<?php echo $redirect_url; ?>" /> 103 <label for="username"><?php _e('Username'); ?></label> 104 <?php if($args['split_lines']) echo '<br/>'; ?> 105 <input type="text" name="username" id="username" /><br/> 106 <label for="pwd"><?php _e('Password'); ?></label> 107 <?php if($args['split_lines']) echo '<br/>'; ?> 108 <input type="password" name="pwd" id="pwd" /><br/> 109 <?php //do_action('login_form'); ?> 110 <input type="checkbox" id="remember-me" name="remember" value="forever" /> 111 <label for="remember-me"><? _e('Remember me'); ?></label><br /> 112 <input type="submit" name="s8-login" value="<?php _e('Login'); ?>" class="login-button" /> 113 <?php if($args['forgot']) 114 echo '<br/>'.s8_get_forgot_password_link(); 115 if($args['register'] && get_option('users_can_register')) 116 echo '<br/>'.s8_get_register_link(s8_get_current_url()); ?> 193 <input type="submit" name="s8-login" value="<?php echo ( $args['submit_text'] ) ? $args['submit_text'] : __( 'Login' ); ?>" class="login-button" /> 194 <?php 195 if ( $args['forgot'] ) { 196 echo ( $args['single_line'] ? '' : '<br/>' ) . s8_get_forgot_password_link(); 197 } 198 if ( $args['register'] && get_option( 'users_can_register' ) ) { 199 echo ( $args['single_line'] ? '' : '<br/>' ) . s8_get_register_link( s8_get_current_url() ); 200 } ?> 117 201 </p> 118 202 </form> -
s8-custom-login-and-registration/trunk/readme.txt
r713234 r721036 1 1 === Sideways8 Custom Login and Registration === 2 2 Contributors: sideways8, technical_mastermind, areimann 3 Tags: custom login, login, registration, form, login widget, widget3 Tags: s8, sideways8, sideways 8, custom login, login, registration, form, login widget, widget, theme login, style login, theme, style log in, theme log in, log in, custom log in, brand, brand login, brand log in 4 4 Requires at least: 3.3 5 5 Tested up to: 3.5.1 6 Stable tag: 0.8. 46 Stable tag: 0.8.5 7 7 License: GPLv3 8 8 License URI: http://www.gnu.org/licenses/gpl-3.0.html 9 9 10 Quick and easy relocation of the login and registration forms to another page that matches your site.10 Hides the WP login page, allows you to "embed" login in a page, and allows customization on how the login page looks. 11 11 12 12 == Description == 13 13 The way your site is presented to your users is important. That is why we made the "Custom Login and Registration" plugin. It is designed so that both you and your users never see the built-in WP login, registration, and password reset forms. It is still compatible with all of WordPress' built-in functionality and logout links will still function as they should. A login form widget is included to make it easy for your non-logged in visitors to find the login form. You are even able to add content to the login, registration, forgot password and password reset pages through the settings page. 14 14 15 If you want to add a form to a page on your site, you can use the new shortcodes: `[s8-login-form]`, `[s8-registration-form]`, and `[s8-forgot-form]`. 15 If you want to add a form to a page on your site, you can use the following shortcodes: `[s8-login-form]`, `[s8-registration-form]`, and `[s8-forgot-form]`. 16 17 Note: This plugin requires that you use pretty permalinks 16 18 17 19 = Support/Help = … … 54 56 55 57 == Upgrade Notice == 58 = 0.8.5 = 59 Several major and minor bug fixes with some code improvements 56 60 = 0.8.4 = 57 61 Bug fix related to the password reset functionality. … … 66 70 67 71 == Changelog == 72 = 0.8.5 = 73 * Updated a function related to the login process to more effectively use WordPress' built-in methods 74 * Updated the login redirect priority to fire LATER so other plugins have the opportunity to do their own redirects 75 * Several other minor improvements and bug fixes 76 * Fixed a bug related to WordPress' default password protection of pages/posts 68 77 = 0.8.4 = 69 78 * Fixed a bug related to resetting a password -
s8-custom-login-and-registration/trunk/s8-login-registration.php
r712965 r721036 4 4 * Plugin URI: http://sideways8.com/plugins/s8-custom-login-and-registration/ 5 5 * Description: The way your site is presented to your users is important. That is why we made the "Custom Login and Registration" plugin. It is designed so that both you and your users never see the built-in WP login, registration, and password reset forms. It is still compatible with all of WordPress' built-in functionality and logout links will still function as they should. It also comes with a login form widget to make it easy for your non-logged in visitors to find the login form. 6 * Tags: custom login, login, registration, form, login widget, widget7 * Version: 0.8. 46 * Tags: s8, sideways8, sideways 8, custom login, login, registration, form, login widget, widget, theme login, style login, theme, style log in, theme log in, log in, custom log in, brand, brand login, brand log in 7 * Version: 0.8.5 8 8 * Author: Sideways8 Interactive 9 9 * Author URI: http://sideways8.com/ … … 13 13 14 14 //define('S8_LOGIN_EP', 'login'); 15 define( 'S8_LOGIN_FILE', __FILE__);16 17 include_once( plugin_dir_path(S8_LOGIN_FILE).'inc/forms.php');18 include_once( plugin_dir_path(S8_LOGIN_FILE).'inc/functions.php');19 include_once( plugin_dir_path(S8_LOGIN_FILE).'inc/s8-login-widget.php');15 define( 'S8_LOGIN_FILE', __FILE__ ); 16 17 include_once( plugin_dir_path( S8_LOGIN_FILE ) . 'inc/forms.php' ); 18 include_once( plugin_dir_path( S8_LOGIN_FILE ) . 'inc/functions.php' ); 19 include_once( plugin_dir_path( S8_LOGIN_FILE ) . 'inc/s8-login-widget.php' ); 20 20 21 21 /** … … 26 26 class s8_login_registration { 27 27 const ep_login = 'login'; 28 private $version = '0.8. 4',28 private $version = '0.8.5', 29 29 $title = '404 Not Found', 30 30 $content = 'Sorry, what you are looking for could not be found!'; … … 36 36 function __construct() { 37 37 // Update if needed 38 if ($this->version != get_option('s8-login-registration-version')) $this->update();38 if ( $this->version != get_option( 's8-login-registration-version' ) ) $this->update(); 39 39 // Add our activation/deactivation hooks 40 register_activation_hook( S8_LOGIN_FILE, array($this, 'activation'));41 register_deactivation_hook( S8_LOGIN_FILE, array($this, 'deactivation'));40 register_activation_hook( S8_LOGIN_FILE, array( $this, 'activation' ) ); 41 register_deactivation_hook( S8_LOGIN_FILE, array( $this, 'deactivation' ) ); 42 42 // Add our endpoints 43 add_action( 'init', array($this, 'endpoints'));43 add_action( 'init', array( $this, 'endpoints' ) ); 44 44 // Add our posts and load the appropriate template 45 add_action( 'the_posts', array($this, 'the_posts'));46 add_action( 'template_include', array($this, 'template_include'));45 add_action( 'the_posts', array( $this, 'the_posts' ) ); 46 add_action( 'template_include', array( $this, 'template_include' ) ); 47 47 // Filter out the wrong urls in the reset password emails 48 add_filter( 'retrieve_password_message', array($this, 'filter_email_urls'), 10, 2);48 add_filter( 'retrieve_password_message', array( $this, 'filter_email_urls' ), 10, 2 ); 49 49 // Keep people from seeing the WP Login page 50 add_action( 'login_init', array($this, 'no_wp_login'));50 add_action( 'login_init', array( $this, 'no_wp_login' ) ); 51 51 // Work with the WordPress functions 52 add_filter( 'logout_url', array($this, 'logout_url'), 10, 2);53 add_filter( 'login_url', array($this, 'login_url'), 10, 2);54 add_filter( 'lostpassword_url', array($this, 'forgotpassword_url'), 10, 2);52 add_filter( 'logout_url', array( $this, 'logout_url' ), 10, 2 ); 53 add_filter( 'login_url', array( $this, 'login_url' ), 10, 2 ); 54 add_filter( 'lostpassword_url', array( $this, 'forgotpassword_url' ), 10, 2 ); 55 55 // Add our shortcodes 56 add_shortcode( 's8-login-form', array($this, 'login_shortcode'));57 add_shortcode( 's8-registration-form', array($this, 'registration_shortcode'));58 add_shortcode( 's8-forgot-form', array($this, 'forgot_shortcode'));59 add_shortcode( 's8-reset-form', array($this, 'reset_shortcode')); // This is intended for internal use ONLY56 add_shortcode( 's8-login-form', array( $this, 'login_shortcode' ) ); 57 add_shortcode( 's8-registration-form', array( $this, 'registration_shortcode' ) ); 58 add_shortcode( 's8-forgot-form', array( $this, 'forgot_shortcode' ) ); 59 add_shortcode( 's8-reset-form', array( $this, 'reset_shortcode' ) ); // This is intended for internal use ONLY 60 60 //add_filter('register', array($this, 'register_url')); 61 61 // Add our admin stuff 62 add_action('admin_menu', array($this, 'admin_menu')); 62 add_action( 'admin_menu', array( $this, 'admin_menu' ) ); 63 add_action( 'wp_login', array( $this, 'login_redirect' ), 99, 2 ); 63 64 } 64 65 … … 91 92 switch($_GET['action']) { 92 93 case 'register': 93 if (!get_option('users_can_register')) {94 wp_redirect( s8_get_login_url(home_url()));94 if ( ! get_option( 'users_can_register' ) ) { 95 wp_redirect( s8_get_login_url( home_url() ) ); 95 96 exit; 96 97 } 97 if ($_POST['s8-register']) {98 if ( isset( $_POST['s8-register'] ) ) { 98 99 $s8_login_errors = $this->register_user(); 99 100 } … … 103 104 break; 104 105 case 'reset': 105 define( 'S8_LOGIN_INIT', true);106 if ($_POST['s8-login-reset'] == 'Change Password') {106 define( 'S8_LOGIN_INIT', true ); 107 if ( isset( $_POST['s8-login-reset'] ) ) { 107 108 $s8_login_errors = $this->user_password_reset(); 108 109 } 109 $this->title = __( 'Reset Password');110 $this->title = __( 'Reset Password' ); 110 111 $this->content = '[s8-reset-form action="reset" s8_internal="true"]'; 111 112 //$this->display_template('login'); 112 113 break; 113 114 case 'forgot': 114 define( 'S8_LOGIN_INIT', true);115 if ($_POST['s8-login-forgot'] == 'Get New Password') {115 define( 'S8_LOGIN_INIT', true ); 116 if ( isset( $_POST['s8-login-forgot'] ) ) { 116 117 $s8_login_errors = $this->user_password_reset_request(); 117 118 } 118 $this->title = __( 'Forgot Password');119 $this->title = __( 'Forgot Password' ); 119 120 $this->content = '[s8-forgot-form s8_internal="true"]'; 120 121 //$this->display_template('login'); … … 122 123 default: 123 124 // Check if we are processing (and process if needed) 124 if ($_POST['s8-login'] == 'Login') {125 if ( isset( $_POST['s8-login'] ) ) { 125 126 $s8_login_errors = $this->login_user(); 126 127 } … … 150 151 151 152 /** 152 * 153 */ 154 function template_include($template) { 153 * Changes the template used for the form pages 154 * @param string $template 155 * @return string 156 * @since 0.8.3 157 */ 158 function template_include( $template ) { 155 159 global $wp_query; 156 if(!isset($wp_query->query_vars[self::ep_login])) return $template; 157 $order = array('s8-login.php', 'page.php', 'index.php'); 158 if($temp = get_option('s8_custom_login_form_template')) 159 $order = array($temp, 's8-login.php', 'page.php', 'index.php'); 160 $child_theme = get_stylesheet_directory(); 161 $parent_theme = get_template_directory(); 162 if($child_theme == $parent_theme) { 163 // Same theme! 164 foreach($order as $temp_file) { 165 if(file_exists($parent_theme.'/'.$temp_file)) 166 return $parent_theme.'/'.$temp_file; 167 } 168 } 169 else { 170 // Check child then parent 171 foreach($order as $temp_file) { 172 if(file_exists($child_theme.'/'.$temp_file)) 173 return $child_theme.'/'.$temp_file; 174 elseif(file_exists($parent_theme.'/'.$temp_file)) 175 return $parent_theme.'/'.$temp_file; 176 } 160 if ( isset( $wp_query->query_vars[self::ep_login] ) ) { 161 $order = array( 's8-login.php', 'page.php', 'index.php' ); 162 if ( $temp = get_option( 's8_custom_login_form_template' ) ) 163 $order = array( $temp, 's8-login.php', 'page.php', 'index.php' ); 164 $template = locate_template( $order ); 177 165 } 178 166 // If we fail to find an appropriate file, return what WP was going to use anyways. … … 186 174 */ 187 175 function register_user() { 188 if(!wp_verify_nonce($_POST['s8-register-nonce'], 's8-register-new-user')) die('An attempt to bypass security checks was detected! Please go back to the register form and try again.'); 176 if ( ! wp_verify_nonce( $_POST['s8-clr-register-nonce'], plugin_dir_path( S8_LOGIN_FILE ) ) ) 177 die('An attempt to bypass security checks was detected! Please go back to the register form and try again.'); 189 178 // Verify our data 190 179 if(empty($_POST['username']) || empty($_POST['email'])) … … 225 214 */ 226 215 function user_password_reset() { 227 if(!wp_verify_nonce($_POST['s8-login-nonce'], 's8_wp_custom_login-nonce-reset')) die('An attempt to bypass security checks was detected! Please go back to the password reset and try again.'); 216 if ( ! wp_verify_nonce( $_POST['s8-clr-reset-nonce'], plugin_dir_path( S8_LOGIN_FILE ) ) ) 217 die('An attempt to bypass security checks was detected! Please go back to the password reset and try again.'); 228 218 // We are updating our password! 229 219 ob_start(); … … 251 241 */ 252 242 function user_password_reset_request() { 253 if(!wp_verify_nonce($_POST['s8-login-nonce'], 's8_wp_custom_login-nonce-forgot')) die('An attempt to bypass security checks was detected! Please go back to the forgot password form and try again.'); 243 if ( ! wp_verify_nonce( $_POST['s8-clr-forgot-nonce'], plugin_dir_path( S8_LOGIN_FILE ) ) ) 244 die('An attempt to bypass security checks was detected! Please go back to the forgot password form, refresh the page, and try again.'); 254 245 // We are requesting a password reset! 255 246 ob_start(); … … 268 259 */ 269 260 function login_user() { 270 if(!wp_verify_nonce($_POST['s8-login-nonce'], 's8_CLR-login-nonce')) die('An attempt to bypass security checks was detected! Please go back to the login form and try again.'); 271 // We are logging in! 272 $username = sanitize_user($_POST['username']); 273 $user = wp_authenticate($username, $_POST['pwd']); 274 if(is_wp_error($user)) 275 return $user; 276 elseif($user && is_object($user) && $user->data->user_login == $username) { 277 if($_POST['remember'] == 'forever') $remember = true; 278 else $remember = false; 279 wp_set_current_user($user->ID, $username); 280 wp_set_auth_cookie($user->ID, $remember); 281 do_action('wp_login', $username); 282 // Check for custom redirect 283 global $current_user; 284 $redirects = get_option('s8_login_redirects'); 285 $role = $current_user->roles; 286 if(is_array($role)) $role = $role[0]; 287 // Do our redirect! 288 if(isset($redirects[$role])) $url = $redirects[$role]; 289 elseif($_POST['redirect'] != '') $url = $_POST['redirect']; 290 else $url = home_url('/'); 291 wp_redirect($url, 302); 292 exit; 293 } 294 else { 295 return new WP_Error('unexpected', 'An unexpected error occurred!'); 296 } 261 if ( ! wp_verify_nonce( $_POST['s8-clr-login-nonce'], plugin_dir_path( S8_LOGIN_FILE ) ) ) 262 die( 'An attempt to bypass security checks was detected! Please go back to the login form, refresh the page, and try again.' ); 263 $credentials = array( 264 'user_login' => sanitize_user( $_POST['username'] ), 265 'user_password' => $_POST['pwd'], 266 'remember' => ( empty( $_POST['remember'] ) ? false : true ) 267 ); 268 $user = wp_signon( $credentials ); 269 return $user; 270 } 271 272 /** 273 * This handles the redirection of our users after login, this was split off from our login_user function 274 * @param $user_login 275 * @param $user 276 * @since 0.8.5 277 */ 278 function login_redirect( $user_login, $user ) { 279 // Check for custom redirect 280 $redirects = get_option('s8_login_redirects'); 281 $role = $user->roles; 282 // Grab the first user role 283 if ( is_array( $role ) ) 284 $role = $role[0]; 285 // Setup our redirect URL 286 if ( isset( $redirects[$role] ) ) { 287 $url = $redirects[$role]; 288 } elseif ( $_POST['redirect'] != '' ) { 289 $url = $_POST['redirect']; 290 } else { 291 $url = home_url('/'); 292 } 293 // Redirect and exit to avoid errors 294 wp_redirect( $url, 302 ); 295 exit; 297 296 } 298 297 … … 302 301 */ 303 302 function no_wp_login() { 304 if(defined('S8_LOGIN_INIT') && S8_LOGIN_INIT === true) return; 305 $check = get_option('s8_allow_wp_register'); 306 if($check && $_REQUEST['action'] == 'register') return; 307 if($_GET['no-redirect'] == 'true') { 308 wp_enqueue_script('s8-login-failsafe', plugins_url('/js/s8-login-failsafe.js', S8_LOGIN_FILE), array('jquery')); 303 // This does something important... 304 if ( defined( 'S8_LOGIN_INIT' ) && S8_LOGIN_INIT === true ) 309 305 return; 310 } 311 if($_GET['redirect_to'] != '') $url = $_GET['redirect_to']; 312 else $url = false; 313 if($_GET['action'] == 'logout') 314 wp_redirect(s8_get_logout_url($url)); 315 elseif($_GET['action'] == 'register') 316 wp_redirect(s8_get_register_url($url)); 317 else 318 wp_redirect(s8_get_login_url($url)); 306 // See if we are trying to register and want to use the WP registration form 307 $check = get_option( 's8_allow_wp_register' ); 308 if ( $check && $_REQUEST['action'] == 'register' ) 309 return; 310 // Check if this is validation for a password protected post/page 311 if ( $_GET['action'] == 'postpass' ) 312 return; 313 // See if we are in no-redirect mode 314 if ( $_GET['no-redirect'] == 'true' ) { 315 wp_enqueue_script( 's8-login-failsafe', plugins_url( '/js/s8-login-failsafe.js', S8_LOGIN_FILE ), array( 'jquery' ) ); 316 return; 317 } 318 // Let's check for a redirect value 319 if ( $_GET['redirect_to'] != '' ) { 320 $url = $_GET['redirect_to']; 321 } else { 322 $url = false; 323 } 324 // Redirect away from the WP login page 325 if ( $_GET['action'] == 'logout' ) { 326 wp_redirect( s8_get_logout_url( $url ) ); 327 } elseif ( $_GET['action'] == 'register' ) { 328 wp_redirect( s8_get_register_url( $url ) ); 329 } else { 330 wp_redirect( s8_get_login_url( $url ) ); 331 } 319 332 exit; 320 333 }
Note: See TracChangeset
for help on using the changeset viewer.