Plugin Directory

Changeset 633652


Ignore:
Timestamp:
12/03/2012 09:25:54 PM (13 years ago)
Author:
sideways8
Message:

Update to version 0.8.3

Location:
s8-custom-login-and-registration
Files:
33 added
2 deleted
6 edited
13 copied

Legend:

Unmodified
Added
Removed
  • s8-custom-login-and-registration/tags/0.8.3/admin/settings.php

    r609859 r633652  
    1717    else
    1818        delete_option('s8_custom_login_form_template');
     19    if($_POST['use_wp_register'] == 'yes')
     20        update_option('s8_allow_wp_register', true);
     21    else
     22        update_option('s8_allow_wp_register', false);
     23    if(!empty($_POST['add_url'])) {
     24        $redirects = get_option('s8_login_redirects');
     25        $redirects[strip_tags(trim($_POST['add_role']))] = addslashes(strip_tags(trim($_POST['add_url'])));
     26        update_option('s8_login_redirects', $redirects);
     27    }
     28    if($_POST['delete_login_redirect'] && is_array($_POST['delete_login_redirect'])) {
     29        $redirects = get_option('s8_login_redirects');
     30        foreach($_POST['delete_login_redirect'] as $redirect) {
     31            unset($redirects[$redirect]);
     32        }
     33        update_option('s8_login_redirects', $redirects);
     34    }
    1935}
    2036$page_templates = array('s8-login.php', 'post.php', 'page.php', 'index.php');
    2137$child_theme = get_stylesheet_directory();
    2238$parent_theme = get_template_directory();
     39$redirects = get_option('s8_login_redirects');
    2340if($child_theme == $parent_theme) {
    2441    // Same theme!
     
    3754$form_text = get_option('s8_custom_login_form_text');
    3855$template = get_option('s8_custom_login_form_template');
     56$allow_wp_register = get_option('s8_allow_wp_register');
    3957if(!$form_text || !is_array($form_text))
    4058    $form_text = array();
     59
     60$checked = ' checked="checked"';
    4161?><div class="wrap s8-login-settings">
    4262    <div id="icon-options-general" class="icon32"></div><h2>Sideways8 Custom Login and Registration Settings</h2>
    4363    <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
    44         <p>
    45             <label for="page-template"><? _e('Template for form pages'); ?></label>
    46             <select name="page-template" id="page-template">
    47                 <option value="0">-- Use default --</option>
    48                 <?php foreach($page_templates as $temp_file) {
    49                     ?><option value="<?php echo $temp_file; ?>"<?php echo($temp_file == $template)?' selected="selected"':''; ?>><?php echo $temp_file; ?></option><?php
    50                 } ?>
    51                 <?php page_template_dropdown($template); ?>
    52             </select><br/>
    53         </p>
    54         <p>
    55             You can customize the content of the login, registration, forgot password, and reset password pages by using the following boxes.<br/>
    56             You can include any of the following tags to customize the content of the page:<br/>
    57             %FORM% = Shows the appropriate form. If not included, form appears below the content.<br/>
    58             %REGISTER_URL% = URL of the register page NOTE: Users must be allowed to register for this to work!<br/>
    59             %REGISTER_LINK% = Link to the register page NOTE: Users must be allowed to register for this to work!<br/>
    60             %LOGIN_URL% = URL of the login page<br/>
    61             %LOGIN_LINK% = Link to the login page<br/>
    62             %FORGOT_PASSWORD_URL% = URL of the forgot password page<br/>
    63             %FORGOT_PASSWORD_LINK% = Link to the forgot password page
    64         </p>
    65         <h3>Login page text</h3>
    66         <p>
    67             Shown when a user is logging in.
    68         </p>
    69         <?php wp_editor(stripslashes($form_text['login']), 's8-login', array('textarea_name' => 's8_custom_login_form_text[login]')); ?>
    70         <p>
    71             <input type="submit" class="button-primary" name="s8-login-settings-save" value="Save Settings" />
    72         </p>
     64        <div id="tabs">
     65            <ul>
     66                <li><a href="#tabs-1"><?php _e('General Options'); ?></a></li>
     67                <li><a href="#tabs-2"><?php _e('Login Page Options'); ?></a></li>
     68                <li><a href="#tabs-3"><?php _e('Register Page Options'); ?></a></li>
     69                <li><a href="#tabs-4"><?php _e('Forgot Password Page Options'); ?></a></li>
     70                <li><a href="#tabs-5"><?php _e('Reset Password Page Options'); ?></a></li>
     71                <li><a href="#tabs-6"><?php _e('User Redirect Options'); ?></a></li>
     72            </ul>
     73            <div class="tabs-spacer"></div>
     74            <div id="tabs-1">
     75                <p>
     76                    <label for="page-template"><? _e('Page layout template for form pages:'); ?></label><br/>
     77                    <select name="page-template" id="page-template">
     78                        <option value="0">-- Use default --</option>
     79                        <?php foreach($page_templates as $temp_file) {
     80                        ?><option value="<?php echo $temp_file; ?>"<?php echo($temp_file == $template)?' selected="selected"':''; ?>><?php echo $temp_file; ?></option><?php
     81                    } ?>
     82                        <?php page_template_dropdown($template); ?>
     83                    </select><br/>
     84                </p>
     85                <p>
     86                    <input type="checkbox" name="use_wp_register" id="use_wp_register" value="yes"<?php echo ($allow_wp_register)?$checked:''; ?> /> <label for="use_wp_register">Use the WordPress registration form and link</label>
     87                </p>
     88                <p>
     89                    <input type="submit" class="button-primary" name="s8-login-settings-save" value="Save Settings" />
     90                </p>
     91            </div>
     92            <div id="tabs-6">
     93                <h3><?php _e('On login redirects'); ?></h3>
     94                <p>
     95                    These redirects will be FORCED meaning they will always take effect on each login (based on user role).
     96                </p>
     97                <table>
     98                    <thead>
     99                        <tr><th>Delete?</th><th>Role</th><th>URL</th></tr>
     100                    </thead>
     101                    <tbody>
     102                        <?php
     103                        if($redirects && is_array($redirects) && count($redirects) > 0) {
     104                            global $wp_roles;
     105                            foreach($redirects as $role_name=>$url) {
     106                                if(isset($wp_roles->roles[$role_name]['name'])) $name = $wp_roles->roles[$role_name]['name'];
     107                                else $name = ucwords($role_name);
     108                                echo '<tr><td><input type="checkbox" name="delete_login_redirect[]" value="'.$role_name.'" /></td><td>'.$name.'</td><td>'.$url.'</td></tr>';
     109                            }
     110                        }
     111                        else
     112                            echo '<tr><td>No redirects yet!</td></tr>';
     113                        ?>
     114                    </tbody>
     115                </table>
     116                <p>
     117                    <label for="add_role"><b>Add new redirect</b> (Note: selecting a role that already has a redirect will OVERWRITE the existing redirect)</label><br/>
     118                    <select name="add_role" for="add_role">
     119                        <?php wp_dropdown_roles(); ?>
     120                    </select><br/>
     121                    <label for="add_url">URL:</label> <input type="text" name="add_url" id="add_url" />
     122                </p>
    73123
    74         <h3>Registration page text</h3>
    75         <p>
    76             Shown when a user is registering for the site.
    77         </p>
    78         <?php wp_editor(stripslashes($form_text['register']), 's8-register', array('textarea_name' => 's8_custom_login_form_text[register]')); ?>
    79         <p>
    80             <input type="submit" class="button-primary" name="s8-login-settings-save" value="Save Settings" />
    81         </p>
    82 
    83         <h3>Forgot password page text</h3>
    84         <p>
    85             Shown when a user is requesting a password reset (the form sends them an email).
    86         </p>
    87         <?php wp_editor(stripslashes($form_text['forgot']), 's8-forgot', array('textarea_name' => 's8_custom_login_form_text[forgot]')); ?>
    88         <p>
    89             <input type="submit" class="button-primary" name="s8-login-settings-save" value="Save Settings" />
    90         </p>
    91 
    92         <h3>Reset password page text</h3>
    93         <p>
    94             Shown when the user is resetting their password.
    95         </p>
    96         <?php wp_editor(stripslashes($form_text['reset']), 's8-reset', array('textarea_name' => 's8_custom_login_form_text[reset]')); ?>
    97         <p>
    98             <input type="submit" class="button-primary" name="s8-login-settings-save" value="Save Settings" />
    99         </p>
     124                <?php /*<h3><?php _e('On logout redirects'); ?></h3> */ ?>
     125                <p>
     126                    <input type="submit" class="button-primary" name="s8-login-settings-save" value="Save Settings" />
     127                </p>
     128            </div>
     129            <div id="tabs-2">
     130                <h3>Login page text</h3>
     131                <p>
     132                    Shown when a user is logging in.
     133                </p>
     134                <?php wp_editor(stripslashes($form_text['login']), 's8-login', array('textarea_name' => 's8_custom_login_form_text[login]')); ?>
     135                <p>
     136                    <input type="submit" class="button-primary" name="s8-login-settings-save" value="Save Settings" />
     137                </p>
     138                <p>
     139                    You can include any of the following tags to customize the content of the page:<br/>
     140                    %FORM% = Shows the appropriate form. If not included, form appears below the content.<br/>
     141                    %REGISTER_URL% = URL of the register page NOTE: Users must be allowed to register for this to work!<br/>
     142                    %REGISTER_LINK% = Link to the register page NOTE: Users must be allowed to register for this to work!<br/>
     143                    %LOGIN_URL% = URL of the login page<br/>
     144                    %LOGIN_LINK% = Link to the login page<br/>
     145                    %FORGOT_PASSWORD_URL% = URL of the forgot password page<br/>
     146                    %FORGOT_PASSWORD_LINK% = Link to the forgot password page
     147                </p>
     148            </div>
     149            <div id="tabs-3">
     150                <h3>Registration page text</h3>
     151                <p>
     152                    Shown when a user is registering for the site.
     153                </p>
     154                <?php wp_editor(stripslashes($form_text['register']), 's8-register', array('textarea_name' => 's8_custom_login_form_text[register]')); ?>
     155                <p>
     156                    <input type="submit" class="button-primary" name="s8-login-settings-save" value="Save Settings" />
     157                </p>
     158                <p>
     159                    You can include any of the following tags to customize the content of the page:<br/>
     160                    %FORM% = Shows the appropriate form. If not included, form appears below the content.<br/>
     161                    %REGISTER_URL% = URL of the register page NOTE: Users must be allowed to register for this to work!<br/>
     162                    %REGISTER_LINK% = Link to the register page NOTE: Users must be allowed to register for this to work!<br/>
     163                    %LOGIN_URL% = URL of the login page<br/>
     164                    %LOGIN_LINK% = Link to the login page<br/>
     165                    %FORGOT_PASSWORD_URL% = URL of the forgot password page<br/>
     166                    %FORGOT_PASSWORD_LINK% = Link to the forgot password page
     167                </p>
     168            </div>
     169            <div id="tabs-4">
     170                <h3>Forgot password page text</h3>
     171                <p>
     172                    Shown when a user is requesting a password reset (the form sends them an email).
     173                </p>
     174                <?php wp_editor(stripslashes($form_text['forgot']), 's8-forgot', array('textarea_name' => 's8_custom_login_form_text[forgot]')); ?>
     175                <p>
     176                    <input type="submit" class="button-primary" name="s8-login-settings-save" value="Save Settings" />
     177                </p>
     178                <p>
     179                    You can include any of the following tags to customize the content of the page:<br/>
     180                    %FORM% = Shows the appropriate form. If not included, form appears below the content.<br/>
     181                    %REGISTER_URL% = URL of the register page NOTE: Users must be allowed to register for this to work!<br/>
     182                    %REGISTER_LINK% = Link to the register page NOTE: Users must be allowed to register for this to work!<br/>
     183                    %LOGIN_URL% = URL of the login page<br/>
     184                    %LOGIN_LINK% = Link to the login page<br/>
     185                    %FORGOT_PASSWORD_URL% = URL of the forgot password page<br/>
     186                    %FORGOT_PASSWORD_LINK% = Link to the forgot password page
     187                </p>
     188            </div>
     189            <div id="tabs-5">
     190                <h3>Reset password page text</h3>
     191                <p>
     192                    Shown when the user is resetting their password.
     193                </p>
     194                <?php wp_editor(stripslashes($form_text['reset']), 's8-reset', array('textarea_name' => 's8_custom_login_form_text[reset]')); ?>
     195                <p>
     196                    <input type="submit" class="button-primary" name="s8-login-settings-save" value="Save Settings" />
     197                </p>
     198                <p>
     199                    You can include any of the following tags to customize the content of the page:<br/>
     200                    %FORM% = Shows the appropriate form. If not included, form appears below the content.<br/>
     201                    %REGISTER_URL% = URL of the register page NOTE: Users must be allowed to register for this to work!<br/>
     202                    %REGISTER_LINK% = Link to the register page NOTE: Users must be allowed to register for this to work!<br/>
     203                    %LOGIN_URL% = URL of the login page<br/>
     204                    %LOGIN_LINK% = Link to the login page<br/>
     205                    %FORGOT_PASSWORD_URL% = URL of the forgot password page<br/>
     206                    %FORGOT_PASSWORD_LINK% = Link to the forgot password page
     207                </p>
     208            </div>
     209        </div>
    100210    </form>
    101211</div>
  • s8-custom-login-and-registration/tags/0.8.3/inc/forms.php

    r609859 r633652  
    1616            case 'register': // Register user
    1717                $redirect_url = ($_GET['redirect'] != '')?$_GET['redirect']:home_url();
    18                 ?><form method="post" action="<?php echo s8_get_register_url($redirect_url); ?>" name="register">
     18                ?><form method="post" action="<?php echo s8_get_register_url($redirect_url); ?>" name="register" class="s8_form register_form">
    1919                    <?php
    2020                    if(is_wp_error($errors)) {
     
    4343                break;
    4444            case 'reset': // Password reset
    45                 ?><form name="pass-reset" action="<?php echo home_url('/'.s8_login_registration::ep_login.'/?action=rp&key='.$_GET['key']); ?>" method="post">
     45                ?><form name="pass-reset" action="<?php echo home_url('/'.s8_login_registration::ep_login.'/?action=rp&key='.$_GET['key']); ?>" method="post" class="s8_form reset_form">
    4646                    <?php
    4747                    if(is_wp_error($errors)) {
     
    6464                break;
    6565            case 'forgot': // Forgot password
    66                 ?><form name="forgot" action="<?php echo s8_get_forgot_password_url(); ?>" method="post">
     66                ?><form name="forgot" action="<?php echo s8_get_forgot_password_url(); ?>" method="post" class="s8_form forgot_form">
    6767                    <?php
    6868                    if(is_wp_error($errors)) {
     
    9090                if(isset($wp_query->query_vars[s8_login_registration::ep_login]) && s8_get_current_url() == $redirect_url)
    9191                    $redirect_url = home_url();
    92                 ?><form action="<?php echo s8_get_login_url($redirect_url); ?>" name="login" method="post">
     92                ?><form action="<?php echo s8_get_login_url($redirect_url); ?>" name="login" method="post" class="s8_form login_form">
    9393                    <?php
    9494                    if(is_wp_error($errors)) {
  • s8-custom-login-and-registration/tags/0.8.3/inc/functions.php

    r612857 r633652  
    4343        if($redirect_url === false) $formatted_redirect_url = '&redirect='.urlencode(home_url('/'));
    4444        if($redirect_url === true) $formatted_redirect_url = '';
     45        $check = get_option('s8_allow_wp_register');
     46        if($check) return site_url('/wp-login.php?action=register');
    4547        return home_url('/'.s8_login_registration::ep_login.
    4648            '/?action=register'.($formatted_redirect_url?$formatted_redirect_url:''));
  • s8-custom-login-and-registration/tags/0.8.3/readme.txt

    r612857 r633652  
    33Tags: custom login, login, registration, form, login widget, widget
    44Requires at least: 3.3
    5 Tested up to: 3.4.2
    6 Stable tag: 0.8.2
     5Tested up to: 3.5
     6Stable tag: 0.8.3
    77License: GPLv3
    88License URI: http://www.gnu.org/licenses/gpl-3.0.html
    99
    10 Easily change the way the WP login is seen by your users.  This allows you to "hide" the wp-login url.
     10Hides the WP login page, allows you to "embed" login in a page, and allows customization on how the login page looks.
    1111
    1212== Description ==
    1313The 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
     15If 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]`.
    1416
    1517= Support/Help =
     
    2527Despite our best attempts, it is possible that a WordPress update or another plugin may cause an issue with our plugin and you will be unable to login. To get around this use the following URL: http://yourDomainName.com/wp-login.php?no-redirect=true
    2628NOTE: Replace yourDomainName.com with your domain name. If your WordPress install is in a subdirectory (e.g. yourDomainName.com/folder/wp-login.php) then adjust the URL as needed.
     29
     30= How do I use the shortcode and what is it? =
     31A shortcode is an easy and accessible way for any site owner to add custom functionality to their site. In this case it allows you to put our login, registration, and forgot password forms on ANY page of your site.
     32
     33To use it simply place one of the following shortcodes where you want the form to appear:
     34Login: `[s8-login-form]`
     35Registration: `[s8-registration-form]`
     36Forgot password: `[s8-forgot-form]`
     37
     38You can also add the option 'hide_links' to your shortcode to hide the links to the other forms.
     39`[s8-login-form hide_links="forgot,register"]`
     40The above will, for example, hide the links to the forgot password and registration forms. You can also use 'login' as an option.
    2741
    2842= How can I change the CSS on the login/register/forgot/reset password pages? =
     
    4054
    4155== Upgrade Notice ==
     56= 0.8.3 =
     57Added shortcodes and the ability to redirect users when they login based on role.
    4258= 0.8.2 =
    4359Added widget options for when the user is logged in.
     
    4864
    4965== Changelog ==
     66= 0.8.3 =
     67* Added shortcodes for use anywhere on the site.
     68* Added new CSS classes to the forms for easy styling (form tag is the wrapper for content inserted using the shortcode)
     69* Cleaned up the admin settings page
     70* Added option to use WordPress registration form
     71* Fixed a bug when going to our registration form
     72* Added basic login redirect support to redirect users to specific URLs on login
    5073= 0.8.2 =
    5174* Can now specify if a logout link should show in the widget
  • s8-custom-login-and-registration/tags/0.8.3/s8-login-registration.php

    r612857 r633652  
    55 * 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.
    66 * Tags: custom login, login, registration, form, login widget, widget
    7  * Version: 0.8.2
     7 * Version: 0.8.3
    88 * Author: Sideways8 Interactive
    99 * Author URI: http://sideways8.com/
     
    2626class s8_login_registration {
    2727    const ep_login = 'login';
    28     private $version = '0.8.1',
     28    private $version = '0.8.3',
    2929            $title = '404 Not Found',
    3030            $content = 'Sorry, what you are looking for could not be found!';
     
    5353        add_filter('login_url', array($this, 'login_url'), 10, 2);
    5454        add_filter('lostpassword_url', array($this, 'forgotpassword_url'), 10, 2);
    55         // Add our (as of v0.8.1) internal shortcode
    56         add_shortcode('login-form', array($this, 'form_shortcode'));
     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 ONLY
    5760        //add_filter('register', array($this, 'register_url'));
    5861        // Add our admin stuff
     
    9497                    }
    9598                    $this->title = __('Register');
    96                     $this->content = '[login-form action="register" page="true"]';
     99                    $this->content = '[s8-registration-form s8_internal="true"]';
    97100                        //$this->display_template('register');
    98101                    break;
     
    103106                    }
    104107                    $this->title = __('Reset Password');
    105                     $this->content = '[login-form action="reset" page="true"]';
     108                    $this->content = '[s8-reset-form action="reset" s8_internal="true"]';
    106109                        //$this->display_template('login');
    107110                    break;
     
    112115                    }
    113116                    $this->title = __('Forgot Password');
    114                     $this->content = '[login-form action="forgot" page="true"]';
     117                    $this->content = '[s8-forgot-form s8_internal="true"]';
    115118                        //$this->display_template('login');
    116119                    break;
     
    122125                    // Do our stuff
    123126                    $this->title = __('Login');
    124                     $this->content = '[login-form page="true"]';
     127                    $this->content = '[s8-login-form s8_internal="true"]';
    125128                        //$this->display_template('login');
    126129            }
     
    273276                wp_set_auth_cookie($user->ID, $remember);
    274277                do_action('wp_login', $username);
    275                 if($_POST['redirect'] != '') $url = $_POST['redirect'];
     278                // Check for custom redirect
     279                global $current_user;
     280                $redirects = get_option('s8_login_redirects');
     281                $role = $current_user->roles;
     282                if(is_array($role)) $role = $role[0];
     283                // Do our redirect!
     284                if(isset($redirects[$role])) $url = $redirects[$role];
     285                elseif($_POST['redirect'] != '') $url = $_POST['redirect'];
    276286                else $url = home_url('/');
    277287                wp_redirect($url, 302);
     
    288298    function no_wp_login() {
    289299        if(defined('S8_LOGIN_INIT') && S8_LOGIN_INIT === true) return;
     300        $check = get_option('s8_allow_wp_register');
     301        if($check && $_REQUEST['action'] == 'register') return;
    290302        if($_GET['no-redirect'] == 'true') {
    291303            wp_enqueue_script('s8-login-failsafe', plugins_url('/js/s8-login-failsafe.js', S8_LOGIN_FILE), array('jquery'));
     
    296308        if($_GET['action'] == 'logout')
    297309            wp_redirect(s8_get_logout_url($url));
     310        elseif($_GET['action'] == 'register')
     311            wp_redirect(s8_get_register_url($url));
    298312        else
    299313            wp_redirect(s8_get_login_url($url));
     
    346360
    347361    /**
    348      * Logic for shortcode to show the various forms
     362     * Logic for shortcode to show the login form
    349363     * @since 0.8.1
    350364     * @param $atts
    351      */
    352     function form_shortcode($atts) {
    353         $page = $action = '';
    354         extract(shortcode_atts(array('page' => 'false', 'action' => 'login'), $atts));
    355         if($page == 'true') {
     365     * @return bool|string Should only ever return a string when on a page not generated by us/widget
     366     */
     367    function login_shortcode($atts) {
     368        $s8_internal = $hide_links = '';
     369        extract(shortcode_atts(array('s8_internal' => 'false', 'hide_links' => ''), $atts));
     370        $action = 'login';
     371        if($s8_internal == 'true') {
     372            $args = array('forgot' => false, 'register' => false, 'login' => false);
     373            $form_text = get_option('s8_custom_login_form_text');
     374            if(!is_array($form_text)) $form_text = array();
     375            if($form_text[$action]) {
     376                if(strpos($form_text[$action], '%FORM%') !== false) {
     377                    $output = explode('%FORM%', $this->prepare_content($form_text[$action]), 2);
     378                    echo ($output[0])?$output[0]:'';
     379                    s8_clr_get_form($action, $args);
     380                    echo ($output[1])?$output[1]:'';
     381                }
     382                else {
     383                    echo $this->prepare_content($form_text[$action]);
     384                    s8_clr_get_form($action, $args);
     385                }
     386                return '';
     387            }
     388        }
     389        $tmp = array();
     390        if(!empty($hide_links)) {
     391            // Hide our links!
     392            $hide = explode(',', $hide_links);
     393            foreach($hide as $link) {
     394                $link = strtolower(trim($link));
     395                if($link == 'login') $tmp['login'] = false;
     396                elseif($link == 'register') $tmp['register'] = false;
     397                elseif($link == 'forgot') $tmp['forgot'] = false;
     398            }
     399        }
     400        $args = array_merge(array('forgot' => true, 'register' => true, 'login' => true), $tmp);
     401        ob_start();
     402        s8_clr_get_form($action, $args);
     403        return ob_get_clean();
     404    }
     405
     406    /**
     407     * Logic for shortcode to show the register form
     408     * @since 0.8.3
     409     * @param $atts
     410     * @return bool|string Should only ever return a string when on a page not generated by us/widget
     411     */
     412    function registration_shortcode($atts) {
     413        $s8_internal = $hide_links = '';
     414        extract(shortcode_atts(array('s8_internal' => 'false', 'hide_links' => ''), $atts));
     415        $action = 'register';
     416        if($s8_internal == 'true') {
    356417            $args = array('forgot' => false, 'register' => false, 'login' => false);
    357418            $form_text = get_option('s8_custom_login_form_text');
     
    368429                    s8_clr_get_form($action, $args);
    369430                }
    370                 return;
    371             }
    372         }
    373         $args = array('forgot' => true, 'register' => true, 'login' => true);
     431                return true;
     432            }
     433        }
     434        $tmp = array();
     435        if(!empty($hide_links)) {
     436            // Hide our links!
     437            $hide = explode(',', $hide_links);
     438            foreach($hide as $link) {
     439                $link = strtolower(trim($link));
     440                if($link == 'login') $tmp['login'] = false;
     441                elseif($link == 'register') $tmp['register'] = false;
     442                elseif($link == 'forgot') $tmp['forgot'] = false;
     443            }
     444        }
     445        $args = array_merge(array('forgot' => true, 'register' => true, 'login' => true), $tmp);
     446        ob_start();
    374447        s8_clr_get_form($action, $args);
     448        return ob_get_clean();
     449    }
     450
     451    /**
     452     * Logic for shortcode to show the forgot form
     453     * @since 0.8.3
     454     * @param $atts
     455     * @return bool|string Should only ever return a string when on a page not generated by us/widget
     456     */
     457    function forgot_shortcode($atts) {
     458        $s8_internal = $hide_links = '';
     459        extract(shortcode_atts(array('s8_internal' => 'false', 'hide_links' => ''), $atts));
     460        $action = 'forgot';
     461        if($s8_internal == 'true') {
     462            $args = array('forgot' => false, 'register' => false, 'login' => false);
     463            $form_text = get_option('s8_custom_login_form_text');
     464            if(!is_array($form_text)) $form_text = array();
     465            if($form_text[$action]) {
     466                if(strpos($form_text[$action], '%FORM%') !== false) {
     467                    $output = explode('%FORM%', $this->prepare_content($form_text[$action]), 2);
     468                    echo $output[0];
     469                    s8_clr_get_form($action, $args);
     470                    echo $output[1];
     471                }
     472                else {
     473                    echo $this->prepare_content($form_text[$action]);
     474                    s8_clr_get_form($action, $args);
     475                }
     476                return true;
     477            }
     478        }
     479        $tmp = array();
     480        if(!empty($hide_links)) {
     481            // Hide our links!
     482            $hide = explode(',', $hide_links);
     483            foreach($hide as $link) {
     484                $link = strtolower(trim($link));
     485                if($link == 'login') $tmp['login'] = false;
     486                elseif($link == 'register') $tmp['register'] = false;
     487                elseif($link == 'forgot') $tmp['forgot'] = false;
     488            }
     489        }
     490        $args = array_merge(array('forgot' => true, 'register' => true, 'login' => true), $tmp);
     491        ob_start();
     492        s8_clr_get_form($action, $args);
     493        return ob_get_clean();
     494    }
     495
     496    /**
     497     * Logic for shortcode to show the forgot form
     498     * @since 0.8.3
     499     * @param $atts
     500     * @return bool|string Should only ever return a string when on a page not generated by us/widget
     501     */
     502    function reset_shortcode($atts) {
     503        $s8_internal = $hide_links = '';
     504        extract(shortcode_atts(array('s8_internal' => 'false', 'hide_links' => ''), $atts));
     505        $action = 'reset';
     506        if($s8_internal == 'true') {
     507            $args = array('forgot' => false, 'register' => false, 'login' => false);
     508            $form_text = get_option('s8_custom_login_form_text');
     509            if(!is_array($form_text)) $form_text = array();
     510            if($form_text[$action]) {
     511                if(strpos($form_text[$action], '%FORM%') !== false) {
     512                    $output = explode('%FORM%', $this->prepare_content($form_text[$action]), 2);
     513                    echo $output[0];
     514                    s8_clr_get_form($action, $args);
     515                    echo $output[1];
     516                }
     517                else {
     518                    echo $this->prepare_content($form_text[$action]);
     519                    s8_clr_get_form($action, $args);
     520                }
     521                return true;
     522            }
     523        }
     524        return false;
    375525    }
    376526
     
    392542            $tmp['REGISTER_LINK'] = s8_get_register_link(true);
    393543        }
    394         foreach($tmp as $tag=>$value) {
    395             $content = str_replace('%'.$tag.'%', $value, $content);
    396         }
    397544        $content = stripslashes($content);
    398545        $content = force_balance_tags($content);
    399546        $content = apply_filters('the_content', $content);
    400547        $content = str_replace(']]>', ']]&gt;', $content);
     548        foreach($tmp as $tag=>$value) {
     549            $content = str_replace('%'.$tag.'%', $value, $content);
     550        }
    401551        return $content;
    402552    }
     
    426576    function forgotpassword_url($url, $redirect) {
    427577        $url = s8_get_forgot_password_url();
    428         return $url;
    429     }
    430 
    431     /**
    432      * Filter the default register URL to our register URL
    433      * @since 0.8.0
    434      */
    435     function register_url($url) {
    436         $url = s8_get_register_url();
    437578        return $url;
    438579    }
     
    464605        if(is_admin())
    465606            wp_enqueue_style('s8-login-styles', plugins_url('/css/s8-login-admin.css', S8_LOGIN_FILE));
     607            wp_enqueue_style('s8-login-tabs.jquery', plugins_url('/css/jquery-ui-1.9.0.custom.min.css', S8_LOGIN_FILE));
     608            wp_enqueue_script('s8-login-admin', plugins_url('/js/s8-login-admin.js', S8_LOGIN_FILE), array('jquery', 'jquery-ui-tabs'));
    466609    }
    467610
  • s8-custom-login-and-registration/trunk/admin/settings.php

    r609859 r633652  
    1717    else
    1818        delete_option('s8_custom_login_form_template');
     19    if($_POST['use_wp_register'] == 'yes')
     20        update_option('s8_allow_wp_register', true);
     21    else
     22        update_option('s8_allow_wp_register', false);
     23    if(!empty($_POST['add_url'])) {
     24        $redirects = get_option('s8_login_redirects');
     25        $redirects[strip_tags(trim($_POST['add_role']))] = addslashes(strip_tags(trim($_POST['add_url'])));
     26        update_option('s8_login_redirects', $redirects);
     27    }
     28    if($_POST['delete_login_redirect'] && is_array($_POST['delete_login_redirect'])) {
     29        $redirects = get_option('s8_login_redirects');
     30        foreach($_POST['delete_login_redirect'] as $redirect) {
     31            unset($redirects[$redirect]);
     32        }
     33        update_option('s8_login_redirects', $redirects);
     34    }
    1935}
    2036$page_templates = array('s8-login.php', 'post.php', 'page.php', 'index.php');
    2137$child_theme = get_stylesheet_directory();
    2238$parent_theme = get_template_directory();
     39$redirects = get_option('s8_login_redirects');
    2340if($child_theme == $parent_theme) {
    2441    // Same theme!
     
    3754$form_text = get_option('s8_custom_login_form_text');
    3855$template = get_option('s8_custom_login_form_template');
     56$allow_wp_register = get_option('s8_allow_wp_register');
    3957if(!$form_text || !is_array($form_text))
    4058    $form_text = array();
     59
     60$checked = ' checked="checked"';
    4161?><div class="wrap s8-login-settings">
    4262    <div id="icon-options-general" class="icon32"></div><h2>Sideways8 Custom Login and Registration Settings</h2>
    4363    <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
    44         <p>
    45             <label for="page-template"><? _e('Template for form pages'); ?></label>
    46             <select name="page-template" id="page-template">
    47                 <option value="0">-- Use default --</option>
    48                 <?php foreach($page_templates as $temp_file) {
    49                     ?><option value="<?php echo $temp_file; ?>"<?php echo($temp_file == $template)?' selected="selected"':''; ?>><?php echo $temp_file; ?></option><?php
    50                 } ?>
    51                 <?php page_template_dropdown($template); ?>
    52             </select><br/>
    53         </p>
    54         <p>
    55             You can customize the content of the login, registration, forgot password, and reset password pages by using the following boxes.<br/>
    56             You can include any of the following tags to customize the content of the page:<br/>
    57             %FORM% = Shows the appropriate form. If not included, form appears below the content.<br/>
    58             %REGISTER_URL% = URL of the register page NOTE: Users must be allowed to register for this to work!<br/>
    59             %REGISTER_LINK% = Link to the register page NOTE: Users must be allowed to register for this to work!<br/>
    60             %LOGIN_URL% = URL of the login page<br/>
    61             %LOGIN_LINK% = Link to the login page<br/>
    62             %FORGOT_PASSWORD_URL% = URL of the forgot password page<br/>
    63             %FORGOT_PASSWORD_LINK% = Link to the forgot password page
    64         </p>
    65         <h3>Login page text</h3>
    66         <p>
    67             Shown when a user is logging in.
    68         </p>
    69         <?php wp_editor(stripslashes($form_text['login']), 's8-login', array('textarea_name' => 's8_custom_login_form_text[login]')); ?>
    70         <p>
    71             <input type="submit" class="button-primary" name="s8-login-settings-save" value="Save Settings" />
    72         </p>
     64        <div id="tabs">
     65            <ul>
     66                <li><a href="#tabs-1"><?php _e('General Options'); ?></a></li>
     67                <li><a href="#tabs-2"><?php _e('Login Page Options'); ?></a></li>
     68                <li><a href="#tabs-3"><?php _e('Register Page Options'); ?></a></li>
     69                <li><a href="#tabs-4"><?php _e('Forgot Password Page Options'); ?></a></li>
     70                <li><a href="#tabs-5"><?php _e('Reset Password Page Options'); ?></a></li>
     71                <li><a href="#tabs-6"><?php _e('User Redirect Options'); ?></a></li>
     72            </ul>
     73            <div class="tabs-spacer"></div>
     74            <div id="tabs-1">
     75                <p>
     76                    <label for="page-template"><? _e('Page layout template for form pages:'); ?></label><br/>
     77                    <select name="page-template" id="page-template">
     78                        <option value="0">-- Use default --</option>
     79                        <?php foreach($page_templates as $temp_file) {
     80                        ?><option value="<?php echo $temp_file; ?>"<?php echo($temp_file == $template)?' selected="selected"':''; ?>><?php echo $temp_file; ?></option><?php
     81                    } ?>
     82                        <?php page_template_dropdown($template); ?>
     83                    </select><br/>
     84                </p>
     85                <p>
     86                    <input type="checkbox" name="use_wp_register" id="use_wp_register" value="yes"<?php echo ($allow_wp_register)?$checked:''; ?> /> <label for="use_wp_register">Use the WordPress registration form and link</label>
     87                </p>
     88                <p>
     89                    <input type="submit" class="button-primary" name="s8-login-settings-save" value="Save Settings" />
     90                </p>
     91            </div>
     92            <div id="tabs-6">
     93                <h3><?php _e('On login redirects'); ?></h3>
     94                <p>
     95                    These redirects will be FORCED meaning they will always take effect on each login (based on user role).
     96                </p>
     97                <table>
     98                    <thead>
     99                        <tr><th>Delete?</th><th>Role</th><th>URL</th></tr>
     100                    </thead>
     101                    <tbody>
     102                        <?php
     103                        if($redirects && is_array($redirects) && count($redirects) > 0) {
     104                            global $wp_roles;
     105                            foreach($redirects as $role_name=>$url) {
     106                                if(isset($wp_roles->roles[$role_name]['name'])) $name = $wp_roles->roles[$role_name]['name'];
     107                                else $name = ucwords($role_name);
     108                                echo '<tr><td><input type="checkbox" name="delete_login_redirect[]" value="'.$role_name.'" /></td><td>'.$name.'</td><td>'.$url.'</td></tr>';
     109                            }
     110                        }
     111                        else
     112                            echo '<tr><td>No redirects yet!</td></tr>';
     113                        ?>
     114                    </tbody>
     115                </table>
     116                <p>
     117                    <label for="add_role"><b>Add new redirect</b> (Note: selecting a role that already has a redirect will OVERWRITE the existing redirect)</label><br/>
     118                    <select name="add_role" for="add_role">
     119                        <?php wp_dropdown_roles(); ?>
     120                    </select><br/>
     121                    <label for="add_url">URL:</label> <input type="text" name="add_url" id="add_url" />
     122                </p>
    73123
    74         <h3>Registration page text</h3>
    75         <p>
    76             Shown when a user is registering for the site.
    77         </p>
    78         <?php wp_editor(stripslashes($form_text['register']), 's8-register', array('textarea_name' => 's8_custom_login_form_text[register]')); ?>
    79         <p>
    80             <input type="submit" class="button-primary" name="s8-login-settings-save" value="Save Settings" />
    81         </p>
    82 
    83         <h3>Forgot password page text</h3>
    84         <p>
    85             Shown when a user is requesting a password reset (the form sends them an email).
    86         </p>
    87         <?php wp_editor(stripslashes($form_text['forgot']), 's8-forgot', array('textarea_name' => 's8_custom_login_form_text[forgot]')); ?>
    88         <p>
    89             <input type="submit" class="button-primary" name="s8-login-settings-save" value="Save Settings" />
    90         </p>
    91 
    92         <h3>Reset password page text</h3>
    93         <p>
    94             Shown when the user is resetting their password.
    95         </p>
    96         <?php wp_editor(stripslashes($form_text['reset']), 's8-reset', array('textarea_name' => 's8_custom_login_form_text[reset]')); ?>
    97         <p>
    98             <input type="submit" class="button-primary" name="s8-login-settings-save" value="Save Settings" />
    99         </p>
     124                <?php /*<h3><?php _e('On logout redirects'); ?></h3> */ ?>
     125                <p>
     126                    <input type="submit" class="button-primary" name="s8-login-settings-save" value="Save Settings" />
     127                </p>
     128            </div>
     129            <div id="tabs-2">
     130                <h3>Login page text</h3>
     131                <p>
     132                    Shown when a user is logging in.
     133                </p>
     134                <?php wp_editor(stripslashes($form_text['login']), 's8-login', array('textarea_name' => 's8_custom_login_form_text[login]')); ?>
     135                <p>
     136                    <input type="submit" class="button-primary" name="s8-login-settings-save" value="Save Settings" />
     137                </p>
     138                <p>
     139                    You can include any of the following tags to customize the content of the page:<br/>
     140                    %FORM% = Shows the appropriate form. If not included, form appears below the content.<br/>
     141                    %REGISTER_URL% = URL of the register page NOTE: Users must be allowed to register for this to work!<br/>
     142                    %REGISTER_LINK% = Link to the register page NOTE: Users must be allowed to register for this to work!<br/>
     143                    %LOGIN_URL% = URL of the login page<br/>
     144                    %LOGIN_LINK% = Link to the login page<br/>
     145                    %FORGOT_PASSWORD_URL% = URL of the forgot password page<br/>
     146                    %FORGOT_PASSWORD_LINK% = Link to the forgot password page
     147                </p>
     148            </div>
     149            <div id="tabs-3">
     150                <h3>Registration page text</h3>
     151                <p>
     152                    Shown when a user is registering for the site.
     153                </p>
     154                <?php wp_editor(stripslashes($form_text['register']), 's8-register', array('textarea_name' => 's8_custom_login_form_text[register]')); ?>
     155                <p>
     156                    <input type="submit" class="button-primary" name="s8-login-settings-save" value="Save Settings" />
     157                </p>
     158                <p>
     159                    You can include any of the following tags to customize the content of the page:<br/>
     160                    %FORM% = Shows the appropriate form. If not included, form appears below the content.<br/>
     161                    %REGISTER_URL% = URL of the register page NOTE: Users must be allowed to register for this to work!<br/>
     162                    %REGISTER_LINK% = Link to the register page NOTE: Users must be allowed to register for this to work!<br/>
     163                    %LOGIN_URL% = URL of the login page<br/>
     164                    %LOGIN_LINK% = Link to the login page<br/>
     165                    %FORGOT_PASSWORD_URL% = URL of the forgot password page<br/>
     166                    %FORGOT_PASSWORD_LINK% = Link to the forgot password page
     167                </p>
     168            </div>
     169            <div id="tabs-4">
     170                <h3>Forgot password page text</h3>
     171                <p>
     172                    Shown when a user is requesting a password reset (the form sends them an email).
     173                </p>
     174                <?php wp_editor(stripslashes($form_text['forgot']), 's8-forgot', array('textarea_name' => 's8_custom_login_form_text[forgot]')); ?>
     175                <p>
     176                    <input type="submit" class="button-primary" name="s8-login-settings-save" value="Save Settings" />
     177                </p>
     178                <p>
     179                    You can include any of the following tags to customize the content of the page:<br/>
     180                    %FORM% = Shows the appropriate form. If not included, form appears below the content.<br/>
     181                    %REGISTER_URL% = URL of the register page NOTE: Users must be allowed to register for this to work!<br/>
     182                    %REGISTER_LINK% = Link to the register page NOTE: Users must be allowed to register for this to work!<br/>
     183                    %LOGIN_URL% = URL of the login page<br/>
     184                    %LOGIN_LINK% = Link to the login page<br/>
     185                    %FORGOT_PASSWORD_URL% = URL of the forgot password page<br/>
     186                    %FORGOT_PASSWORD_LINK% = Link to the forgot password page
     187                </p>
     188            </div>
     189            <div id="tabs-5">
     190                <h3>Reset password page text</h3>
     191                <p>
     192                    Shown when the user is resetting their password.
     193                </p>
     194                <?php wp_editor(stripslashes($form_text['reset']), 's8-reset', array('textarea_name' => 's8_custom_login_form_text[reset]')); ?>
     195                <p>
     196                    <input type="submit" class="button-primary" name="s8-login-settings-save" value="Save Settings" />
     197                </p>
     198                <p>
     199                    You can include any of the following tags to customize the content of the page:<br/>
     200                    %FORM% = Shows the appropriate form. If not included, form appears below the content.<br/>
     201                    %REGISTER_URL% = URL of the register page NOTE: Users must be allowed to register for this to work!<br/>
     202                    %REGISTER_LINK% = Link to the register page NOTE: Users must be allowed to register for this to work!<br/>
     203                    %LOGIN_URL% = URL of the login page<br/>
     204                    %LOGIN_LINK% = Link to the login page<br/>
     205                    %FORGOT_PASSWORD_URL% = URL of the forgot password page<br/>
     206                    %FORGOT_PASSWORD_LINK% = Link to the forgot password page
     207                </p>
     208            </div>
     209        </div>
    100210    </form>
    101211</div>
  • s8-custom-login-and-registration/trunk/inc/forms.php

    r609859 r633652  
    1616            case 'register': // Register user
    1717                $redirect_url = ($_GET['redirect'] != '')?$_GET['redirect']:home_url();
    18                 ?><form method="post" action="<?php echo s8_get_register_url($redirect_url); ?>" name="register">
     18                ?><form method="post" action="<?php echo s8_get_register_url($redirect_url); ?>" name="register" class="s8_form register_form">
    1919                    <?php
    2020                    if(is_wp_error($errors)) {
     
    4343                break;
    4444            case 'reset': // Password reset
    45                 ?><form name="pass-reset" action="<?php echo home_url('/'.s8_login_registration::ep_login.'/?action=rp&key='.$_GET['key']); ?>" method="post">
     45                ?><form name="pass-reset" action="<?php echo home_url('/'.s8_login_registration::ep_login.'/?action=rp&key='.$_GET['key']); ?>" method="post" class="s8_form reset_form">
    4646                    <?php
    4747                    if(is_wp_error($errors)) {
     
    6464                break;
    6565            case 'forgot': // Forgot password
    66                 ?><form name="forgot" action="<?php echo s8_get_forgot_password_url(); ?>" method="post">
     66                ?><form name="forgot" action="<?php echo s8_get_forgot_password_url(); ?>" method="post" class="s8_form forgot_form">
    6767                    <?php
    6868                    if(is_wp_error($errors)) {
     
    9090                if(isset($wp_query->query_vars[s8_login_registration::ep_login]) && s8_get_current_url() == $redirect_url)
    9191                    $redirect_url = home_url();
    92                 ?><form action="<?php echo s8_get_login_url($redirect_url); ?>" name="login" method="post">
     92                ?><form action="<?php echo s8_get_login_url($redirect_url); ?>" name="login" method="post" class="s8_form login_form">
    9393                    <?php
    9494                    if(is_wp_error($errors)) {
  • s8-custom-login-and-registration/trunk/inc/functions.php

    r612857 r633652  
    4343        if($redirect_url === false) $formatted_redirect_url = '&redirect='.urlencode(home_url('/'));
    4444        if($redirect_url === true) $formatted_redirect_url = '';
     45        $check = get_option('s8_allow_wp_register');
     46        if($check) return site_url('/wp-login.php?action=register');
    4547        return home_url('/'.s8_login_registration::ep_login.
    4648            '/?action=register'.($formatted_redirect_url?$formatted_redirect_url:''));
  • s8-custom-login-and-registration/trunk/readme.txt

    r612857 r633652  
    33Tags: custom login, login, registration, form, login widget, widget
    44Requires at least: 3.3
    5 Tested up to: 3.4.2
    6 Stable tag: 0.8.2
     5Tested up to: 3.5
     6Stable tag: 0.8.3
    77License: GPLv3
    88License URI: http://www.gnu.org/licenses/gpl-3.0.html
    99
    10 Easily change the way the WP login is seen by your users.  This allows you to "hide" the wp-login url.
     10Hides the WP login page, allows you to "embed" login in a page, and allows customization on how the login page looks.
    1111
    1212== Description ==
    1313The 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
     15If 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]`.
    1416
    1517= Support/Help =
     
    2527Despite our best attempts, it is possible that a WordPress update or another plugin may cause an issue with our plugin and you will be unable to login. To get around this use the following URL: http://yourDomainName.com/wp-login.php?no-redirect=true
    2628NOTE: Replace yourDomainName.com with your domain name. If your WordPress install is in a subdirectory (e.g. yourDomainName.com/folder/wp-login.php) then adjust the URL as needed.
     29
     30= How do I use the shortcode and what is it? =
     31A shortcode is an easy and accessible way for any site owner to add custom functionality to their site. In this case it allows you to put our login, registration, and forgot password forms on ANY page of your site.
     32
     33To use it simply place one of the following shortcodes where you want the form to appear:
     34Login: `[s8-login-form]`
     35Registration: `[s8-registration-form]`
     36Forgot password: `[s8-forgot-form]`
     37
     38You can also add the option 'hide_links' to your shortcode to hide the links to the other forms.
     39`[s8-login-form hide_links="forgot,register"]`
     40The above will, for example, hide the links to the forgot password and registration forms. You can also use 'login' as an option.
    2741
    2842= How can I change the CSS on the login/register/forgot/reset password pages? =
     
    4054
    4155== Upgrade Notice ==
     56= 0.8.3 =
     57Added shortcodes and the ability to redirect users when they login based on role.
    4258= 0.8.2 =
    4359Added widget options for when the user is logged in.
     
    4864
    4965== Changelog ==
     66= 0.8.3 =
     67* Added shortcodes for use anywhere on the site.
     68* Added new CSS classes to the forms for easy styling (form tag is the wrapper for content inserted using the shortcode)
     69* Cleaned up the admin settings page
     70* Added option to use WordPress registration form
     71* Fixed a bug when going to our registration form
     72* Added basic login redirect support to redirect users to specific URLs on login
    5073= 0.8.2 =
    5174* Can now specify if a logout link should show in the widget
  • s8-custom-login-and-registration/trunk/s8-login-registration.php

    r612857 r633652  
    55 * 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.
    66 * Tags: custom login, login, registration, form, login widget, widget
    7  * Version: 0.8.2
     7 * Version: 0.8.3
    88 * Author: Sideways8 Interactive
    99 * Author URI: http://sideways8.com/
     
    2626class s8_login_registration {
    2727    const ep_login = 'login';
    28     private $version = '0.8.1',
     28    private $version = '0.8.3',
    2929            $title = '404 Not Found',
    3030            $content = 'Sorry, what you are looking for could not be found!';
     
    5353        add_filter('login_url', array($this, 'login_url'), 10, 2);
    5454        add_filter('lostpassword_url', array($this, 'forgotpassword_url'), 10, 2);
    55         // Add our (as of v0.8.1) internal shortcode
    56         add_shortcode('login-form', array($this, 'form_shortcode'));
     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 ONLY
    5760        //add_filter('register', array($this, 'register_url'));
    5861        // Add our admin stuff
     
    9497                    }
    9598                    $this->title = __('Register');
    96                     $this->content = '[login-form action="register" page="true"]';
     99                    $this->content = '[s8-registration-form s8_internal="true"]';
    97100                        //$this->display_template('register');
    98101                    break;
     
    103106                    }
    104107                    $this->title = __('Reset Password');
    105                     $this->content = '[login-form action="reset" page="true"]';
     108                    $this->content = '[s8-reset-form action="reset" s8_internal="true"]';
    106109                        //$this->display_template('login');
    107110                    break;
     
    112115                    }
    113116                    $this->title = __('Forgot Password');
    114                     $this->content = '[login-form action="forgot" page="true"]';
     117                    $this->content = '[s8-forgot-form s8_internal="true"]';
    115118                        //$this->display_template('login');
    116119                    break;
     
    122125                    // Do our stuff
    123126                    $this->title = __('Login');
    124                     $this->content = '[login-form page="true"]';
     127                    $this->content = '[s8-login-form s8_internal="true"]';
    125128                        //$this->display_template('login');
    126129            }
     
    273276                wp_set_auth_cookie($user->ID, $remember);
    274277                do_action('wp_login', $username);
    275                 if($_POST['redirect'] != '') $url = $_POST['redirect'];
     278                // Check for custom redirect
     279                global $current_user;
     280                $redirects = get_option('s8_login_redirects');
     281                $role = $current_user->roles;
     282                if(is_array($role)) $role = $role[0];
     283                // Do our redirect!
     284                if(isset($redirects[$role])) $url = $redirects[$role];
     285                elseif($_POST['redirect'] != '') $url = $_POST['redirect'];
    276286                else $url = home_url('/');
    277287                wp_redirect($url, 302);
     
    288298    function no_wp_login() {
    289299        if(defined('S8_LOGIN_INIT') && S8_LOGIN_INIT === true) return;
     300        $check = get_option('s8_allow_wp_register');
     301        if($check && $_REQUEST['action'] == 'register') return;
    290302        if($_GET['no-redirect'] == 'true') {
    291303            wp_enqueue_script('s8-login-failsafe', plugins_url('/js/s8-login-failsafe.js', S8_LOGIN_FILE), array('jquery'));
     
    296308        if($_GET['action'] == 'logout')
    297309            wp_redirect(s8_get_logout_url($url));
     310        elseif($_GET['action'] == 'register')
     311            wp_redirect(s8_get_register_url($url));
    298312        else
    299313            wp_redirect(s8_get_login_url($url));
     
    346360
    347361    /**
    348      * Logic for shortcode to show the various forms
     362     * Logic for shortcode to show the login form
    349363     * @since 0.8.1
    350364     * @param $atts
    351      */
    352     function form_shortcode($atts) {
    353         $page = $action = '';
    354         extract(shortcode_atts(array('page' => 'false', 'action' => 'login'), $atts));
    355         if($page == 'true') {
     365     * @return bool|string Should only ever return a string when on a page not generated by us/widget
     366     */
     367    function login_shortcode($atts) {
     368        $s8_internal = $hide_links = '';
     369        extract(shortcode_atts(array('s8_internal' => 'false', 'hide_links' => ''), $atts));
     370        $action = 'login';
     371        if($s8_internal == 'true') {
     372            $args = array('forgot' => false, 'register' => false, 'login' => false);
     373            $form_text = get_option('s8_custom_login_form_text');
     374            if(!is_array($form_text)) $form_text = array();
     375            if($form_text[$action]) {
     376                if(strpos($form_text[$action], '%FORM%') !== false) {
     377                    $output = explode('%FORM%', $this->prepare_content($form_text[$action]), 2);
     378                    echo ($output[0])?$output[0]:'';
     379                    s8_clr_get_form($action, $args);
     380                    echo ($output[1])?$output[1]:'';
     381                }
     382                else {
     383                    echo $this->prepare_content($form_text[$action]);
     384                    s8_clr_get_form($action, $args);
     385                }
     386                return '';
     387            }
     388        }
     389        $tmp = array();
     390        if(!empty($hide_links)) {
     391            // Hide our links!
     392            $hide = explode(',', $hide_links);
     393            foreach($hide as $link) {
     394                $link = strtolower(trim($link));
     395                if($link == 'login') $tmp['login'] = false;
     396                elseif($link == 'register') $tmp['register'] = false;
     397                elseif($link == 'forgot') $tmp['forgot'] = false;
     398            }
     399        }
     400        $args = array_merge(array('forgot' => true, 'register' => true, 'login' => true), $tmp);
     401        ob_start();
     402        s8_clr_get_form($action, $args);
     403        return ob_get_clean();
     404    }
     405
     406    /**
     407     * Logic for shortcode to show the register form
     408     * @since 0.8.3
     409     * @param $atts
     410     * @return bool|string Should only ever return a string when on a page not generated by us/widget
     411     */
     412    function registration_shortcode($atts) {
     413        $s8_internal = $hide_links = '';
     414        extract(shortcode_atts(array('s8_internal' => 'false', 'hide_links' => ''), $atts));
     415        $action = 'register';
     416        if($s8_internal == 'true') {
    356417            $args = array('forgot' => false, 'register' => false, 'login' => false);
    357418            $form_text = get_option('s8_custom_login_form_text');
     
    368429                    s8_clr_get_form($action, $args);
    369430                }
    370                 return;
    371             }
    372         }
    373         $args = array('forgot' => true, 'register' => true, 'login' => true);
     431                return true;
     432            }
     433        }
     434        $tmp = array();
     435        if(!empty($hide_links)) {
     436            // Hide our links!
     437            $hide = explode(',', $hide_links);
     438            foreach($hide as $link) {
     439                $link = strtolower(trim($link));
     440                if($link == 'login') $tmp['login'] = false;
     441                elseif($link == 'register') $tmp['register'] = false;
     442                elseif($link == 'forgot') $tmp['forgot'] = false;
     443            }
     444        }
     445        $args = array_merge(array('forgot' => true, 'register' => true, 'login' => true), $tmp);
     446        ob_start();
    374447        s8_clr_get_form($action, $args);
     448        return ob_get_clean();
     449    }
     450
     451    /**
     452     * Logic for shortcode to show the forgot form
     453     * @since 0.8.3
     454     * @param $atts
     455     * @return bool|string Should only ever return a string when on a page not generated by us/widget
     456     */
     457    function forgot_shortcode($atts) {
     458        $s8_internal = $hide_links = '';
     459        extract(shortcode_atts(array('s8_internal' => 'false', 'hide_links' => ''), $atts));
     460        $action = 'forgot';
     461        if($s8_internal == 'true') {
     462            $args = array('forgot' => false, 'register' => false, 'login' => false);
     463            $form_text = get_option('s8_custom_login_form_text');
     464            if(!is_array($form_text)) $form_text = array();
     465            if($form_text[$action]) {
     466                if(strpos($form_text[$action], '%FORM%') !== false) {
     467                    $output = explode('%FORM%', $this->prepare_content($form_text[$action]), 2);
     468                    echo $output[0];
     469                    s8_clr_get_form($action, $args);
     470                    echo $output[1];
     471                }
     472                else {
     473                    echo $this->prepare_content($form_text[$action]);
     474                    s8_clr_get_form($action, $args);
     475                }
     476                return true;
     477            }
     478        }
     479        $tmp = array();
     480        if(!empty($hide_links)) {
     481            // Hide our links!
     482            $hide = explode(',', $hide_links);
     483            foreach($hide as $link) {
     484                $link = strtolower(trim($link));
     485                if($link == 'login') $tmp['login'] = false;
     486                elseif($link == 'register') $tmp['register'] = false;
     487                elseif($link == 'forgot') $tmp['forgot'] = false;
     488            }
     489        }
     490        $args = array_merge(array('forgot' => true, 'register' => true, 'login' => true), $tmp);
     491        ob_start();
     492        s8_clr_get_form($action, $args);
     493        return ob_get_clean();
     494    }
     495
     496    /**
     497     * Logic for shortcode to show the forgot form
     498     * @since 0.8.3
     499     * @param $atts
     500     * @return bool|string Should only ever return a string when on a page not generated by us/widget
     501     */
     502    function reset_shortcode($atts) {
     503        $s8_internal = $hide_links = '';
     504        extract(shortcode_atts(array('s8_internal' => 'false', 'hide_links' => ''), $atts));
     505        $action = 'reset';
     506        if($s8_internal == 'true') {
     507            $args = array('forgot' => false, 'register' => false, 'login' => false);
     508            $form_text = get_option('s8_custom_login_form_text');
     509            if(!is_array($form_text)) $form_text = array();
     510            if($form_text[$action]) {
     511                if(strpos($form_text[$action], '%FORM%') !== false) {
     512                    $output = explode('%FORM%', $this->prepare_content($form_text[$action]), 2);
     513                    echo $output[0];
     514                    s8_clr_get_form($action, $args);
     515                    echo $output[1];
     516                }
     517                else {
     518                    echo $this->prepare_content($form_text[$action]);
     519                    s8_clr_get_form($action, $args);
     520                }
     521                return true;
     522            }
     523        }
     524        return false;
    375525    }
    376526
     
    392542            $tmp['REGISTER_LINK'] = s8_get_register_link(true);
    393543        }
    394         foreach($tmp as $tag=>$value) {
    395             $content = str_replace('%'.$tag.'%', $value, $content);
    396         }
    397544        $content = stripslashes($content);
    398545        $content = force_balance_tags($content);
    399546        $content = apply_filters('the_content', $content);
    400547        $content = str_replace(']]>', ']]&gt;', $content);
     548        foreach($tmp as $tag=>$value) {
     549            $content = str_replace('%'.$tag.'%', $value, $content);
     550        }
    401551        return $content;
    402552    }
     
    426576    function forgotpassword_url($url, $redirect) {
    427577        $url = s8_get_forgot_password_url();
    428         return $url;
    429     }
    430 
    431     /**
    432      * Filter the default register URL to our register URL
    433      * @since 0.8.0
    434      */
    435     function register_url($url) {
    436         $url = s8_get_register_url();
    437578        return $url;
    438579    }
     
    464605        if(is_admin())
    465606            wp_enqueue_style('s8-login-styles', plugins_url('/css/s8-login-admin.css', S8_LOGIN_FILE));
     607            wp_enqueue_style('s8-login-tabs.jquery', plugins_url('/css/jquery-ui-1.9.0.custom.min.css', S8_LOGIN_FILE));
     608            wp_enqueue_script('s8-login-admin', plugins_url('/js/s8-login-admin.js', S8_LOGIN_FILE), array('jquery', 'jquery-ui-tabs'));
    466609    }
    467610
Note: See TracChangeset for help on using the changeset viewer.