Plugin Directory

Changeset 766174


Ignore:
Timestamp:
09/03/2013 09:21:08 AM (13 years ago)
Author:
parswp
Message:

updated 2

Location:
hide-login/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • hide-login/trunk/hide-login.php

    r662765 r766174  
    22/*
    33Plugin Name: Hide Login
    4 Plugin URI: http://www.websoftdownload.com/
    54Description: This plugin allows you to create custom URLs for user's login, logout and admin's login page.
    65Author: mohammad hossein aghanabi
    7 Version: 3.0
    8 Author URI: http://www.websoftdownload.com
     6Version: 3.1
     7Author URI: http://developr.ir
    98*/
    109/*
     
    1211*/
    1312/* CHANGELOG
     1303-09-2013
     14    * Changed some default options at activation to avoid 500 Servre internal error
     15    * Restrictions on using default slugs like `wp-admin` for admin slug that made confliction
     16    * Optimized code readablity and stability
     17    * Solved fatal error caused by `check_admin_referer()`
     18    * Tested over wordpress 3.6
    141903-02-2013 - v3.0
    1520    * Completely rewrote.
    1621    * All rewrite rules will apply with wordpress buil-in functions
    17     * Remove plugin rewrite rules automatically on deactivation
     22    * Remove plugin rewrite rules automatically on deactivation to wordpres default rules
    1823    * Works with all permalink structures
    1924    * Droped some useless options and codes and improved functionality
     
    3742    * Removed wp-login.php refresh redirect in favor of using rewrite rules for prevention of direct access to the file.
    3843*/
    39 if( $_POST['action'] == 'hide_login_update' )
    40     UpdateSettings();
    41 function hide_options()
    42 {
    43     add_option("hide_login_slug","login");
    44     add_option("hide_logout_slug", "?logout=me");
    45     add_option("hide_admin_slug","wp-admin");
    46     add_option("hide_register_slug","register");
    47     add_option("hide_forgot_slug","forgot");
    48     add_option("hide_login_redirect", get_option('siteurl')."/".get_option("hide_admin_slug"));
    49     add_option("hide_mode", 0);
    50     add_option("hide_wp_admin", 0);
    51     add_option("htaccess_rules", "");
    52     hide_login();
    53 }
    54 register_activation_hook( __FILE__ , 'hide_options' );
    55 add_action('init', '_setup');
    56 function _setup() {
    57     if(get_option("hide_mode") == 1 && (strpos(strtolower($_SERVER['REQUEST_URI']),'wp-login.php') !== false) && $_SERVER['REQUEST_METHOD'] != "POST")
    58     {
    59         wp_redirect(get_option('siteurl'),302);
    60         exit;
    61     }
    62     else if(get_option("hide_logout_slug") !="" && (strpos(strtolower($_SERVER['REQUEST_URI']),get_option("hide_logout_slug")) !== false))
    63     {
    64         wp_logout();
    65         wp_redirect(get_option('siteurl'));
    66         exit;
    67     }
    68     else if(get_option("hide_wp_admin") == 1 && (strpos(strtolower($_SERVER['REQUEST_URI']),'wp-admin') !== false) && !is_user_logged_in())
    69     {
    70         wp_redirect(get_option('siteurl'));
    71         exit;
    72     }
    73 }
    74 add_action('admin_menu','AddPanel');
    75 function AddPanel()
    76 {
    77     add_menu_page('Hide Login', 'Hide Login', 'manage_options', 'HideSettings', 'HideSettings');
    78 }
    79 function UpdateSettings()
    80 {
    81     check_admin_referer('Hide-login-update-options');
    82     $redirect = $_POST['hide_login_redirect'];
    83     $custom = $_POST['login_custom'];
    84     unset($_POST['hide_login_redirect'],$_POST['login_custom']);
    85     $_POST = str_replace(array("/","\\"," "),array("","",""),$_POST);
    86     $_POST['hide_login_redirect'] = $redirect;
    87     $_POST['login_custom'] = $custom;
    88     if($_POST['hide_login_redirect'] == "Custom")
    89     {
    90         update_option("hide_login_redirect", $_POST['login_custom']);
    91     }
    92     else
    93     {
    94         update_option("hide_login_redirect", $_POST['hide_login_redirect']);
    95     }
    96     update_option("hide_login_slug", $_POST['hide_login_slug']);
    97    
    98     update_option("hide_logout_slug", $_POST['hide_logout_slug']);
    99     update_option("hide_admin_slug", $_POST['hide_admin_slug']);
    100     // update_option("hide_login_custom", $_POST['hide_login_custom']);
    101     update_option("hide_register_slug", $_POST['hide_register_slug']);
    102     update_option("hide_forgot_slug", $_POST['hide_forgot_slug']);
    103     // update_option("hide_custom_rules", $_POST['hide_custom_rules']);
     44    /**
     45     * [hide_options adds plugin default options at activation]
     46     * @return [void]
     47     */
     48    function hide_options()
     49    {
     50        add_option("hide_login_slug","login");
     51        add_option("hide_logout_slug", "?logout=me");
     52        add_option("hide_admin_slug","admin");
     53        add_option("hide_register_slug","register");
     54        add_option("hide_forgot_slug","forgot");
     55        add_option("hide_login_redirect", get_option('siteurl')."/".get_option("hide_admin_slug"));
     56        add_option("hide_mode", 0);
     57        add_option("hide_wp_admin", 0);
     58        add_option("htaccess_rules", "");
     59    }
     60    register_activation_hook( __FILE__ , 'hide_options' );
     61    add_action('init', '_setup');
     62    /**
     63     * [_setup handle access to URLs]
     64     * @return [void]
     65     */
     66    function _setup() {
     67        if(get_option("hide_mode") == 1 && (strpos(strtolower($_SERVER['REQUEST_URI']),'wp-login.php') !== false) && $_SERVER['REQUEST_METHOD'] != "POST")
     68        {
     69            wp_redirect(get_option('siteurl'),302);
     70            exit;
     71        }
     72        else if(get_option("hide_logout_slug") != "" && (strpos(strtolower($_SERVER['REQUEST_URI']),get_option("hide_logout_slug")) !== false))
     73        {
     74            wp_logout();
     75            wp_redirect(get_option('siteurl'));
     76            exit;
     77        }
     78        else if(get_option("hide_wp_admin") == 1 && (strpos(strtolower($_SERVER['REQUEST_URI']),'wp-admin') !== false) && !is_user_logged_in())
     79        {
     80            wp_redirect(get_option('siteurl'));
     81            exit;
     82        }
     83    }
     84    add_action('admin_menu','AddPanel');
     85    /**
     86     * [AddPanel add hide login menu]
     87     */
     88    function AddPanel()
     89    {
     90        add_menu_page('Hide Login', 'Hide Login', 'manage_options', 'HideSettings', 'HideSettings');
     91    }
     92    add_action("admin_init", "UpdateSettings");
     93    /**
     94     * [UpdateSettings update all settings after submitting form]
     95     */
     96    function UpdateSettings()
     97    {
     98        if( $_POST['action'] == 'hide_login_update' )
     99        {
     100            $redirect = $_POST['hide_login_redirect'];
     101            $custom = $_POST['login_custom'];
     102            unset($_POST['hide_login_redirect'],$_POST['login_custom']);
     103            $_POST = str_replace(array("/","\\"," "),array("","",""),$_POST);
     104            $_POST['hide_login_redirect'] = $redirect;
     105            $_POST['login_custom'] = $custom;
     106            $_POST['type'] = "success";
     107            $_POST['notice'] = __('Settings Updated','hidelogin');
     108            if($_POST['hide_login_redirect'] == "Custom")
     109            {
     110                update_option("hide_login_redirect", $_POST['login_custom']);
     111            }
     112            else
     113            {
     114                update_option("hide_login_redirect", $_POST['hide_login_redirect']);
     115            }
     116            update_option("hide_login_slug", $_POST['hide_login_slug']);
     117           
     118            update_option("hide_logout_slug", $_POST['hide_logout_slug']);
     119            if($_POST['hide_admin_slug'] == "wp-admin")
     120            {
     121                $_POST['notice'] = __('You can\'t use wp-admin as admin slug. but you can put the field empty','hidelogin');
     122                $_POST['type'] = "error";
     123            }
     124            else
     125            {
     126                update_option("hide_admin_slug", $_POST['hide_admin_slug']);
     127            }
     128            update_option("hide_register_slug", $_POST['hide_register_slug']);
     129            update_option("hide_forgot_slug", $_POST['hide_forgot_slug']);
     130            if(get_option("hide_login_slug") != "")
     131            {
     132                update_option("hide_mode", $_POST['hide_mode']);
     133            }
     134            else
     135            {
     136                update_option("hide_mode", 0);
     137            }
     138            if(get_option("hide_admin_slug") != "")
     139            {
     140                update_option("hide_wp_admin", $_POST['hide_wp_admin']);
     141            }
     142            else
     143            {
     144                update_option("hide_wp_admin", 0);
     145            }
     146            hide_login();
     147        }
     148    }
     149    if(get_option("hide_login_redirect") != "")
     150    {
     151        add_action('login_form', 'redirect_after_login');
     152        function redirect_after_login() {
     153            global $redirect_to;
     154            if (!isset($_GET['redirect_to'])) {
     155                $redirect_to = get_option('hide_login_redirect');
     156            }
     157        }
     158    }
     159    if(get_option("hide_logout_slug") != "")
     160    {
     161        add_filter('logout_url', 'new_logout_url', 10, 2);
     162        function new_logout_url($logout_url, $redirect)
     163        {
     164            return "/".get_option("hide_logout_slug");
     165        }
     166    }
    104167    if(get_option("hide_login_slug") != "")
    105         update_option("hide_mode", $_POST['hide_mode']);
    106     else
    107         update_option("hide_mode", 0);
    108     if(get_option("hide_admin_slug") != "")
    109         update_option("hide_wp_admin", $_POST['hide_wp_admin']);
    110     else
    111         update_option("hide_wp_admin", 0);
    112     add_action('admin_init', 'hide_login');
    113         $_POST['notice'] = __('Settings Updated','hidelogin');
    114 }
    115 if(get_option("hide_login_redirect") != "")
    116 {
    117     add_action('login_form', 'redirect_after_login');
    118     function redirect_after_login() {
    119         global $redirect_to;
    120         if (!isset($_GET['redirect_to'])) {
    121             $redirect_to = get_option('hide_login_redirect');
    122         }
    123     }
    124 }
    125 if(get_option("hide_logout_slug") != "")
    126 {
    127     add_filter('logout_url', 'new_logout_url', 10, 2);
    128     function new_logout_url($logout_url, $redirect)
    129     {
    130         return "/".get_option("hide_logout_slug");
    131     }
    132 }
    133 if(get_option("hide_login_slug") != "")
    134 {
    135     add_filter( 'login_url', 'new_login_url', 10, 2 );
    136     function new_login_url( $login_url, $redirect ) {
    137             return "/".get_option("hide_login_slug");
    138     }
    139 }
    140 if(get_option("hide_register_slug") != "")
    141 {
    142     add_filter('register','new_signup_url');
    143     function new_signup_url($url){
    144         return str_replace(site_url('wp-login.php?action=register', 'login'),site_url(get_option("hide_register_slug"), 'login'),$url);
    145     }
    146 }
    147 if(get_option("hide_forgot_slug") != "")
    148 {
    149     add_filter('lostpassword_url','new_forgetpass_url');
    150     function new_forgetpass_url($url){
    151        return str_replace('?action=lostpassword','',str_replace(network_site_url('wp-login.php', 'login'),site_url(get_option("hide_forgot_slug"), 'login'),$url));
    152     }
    153 }
    154 function hide_login()
    155 {
    156     global $wp_rewrite;
    157     $other_rules = array();
    158     if(get_option("hide_admin_slug") != "")
    159     {
    160         add_rewrite_rule( get_option("hide_admin_slug").'/(.*?)$', 'wp-admin/$1?%{QUERY_STRING}', 'top' );
    161         $other_rules[get_option("hide_admin_slug").'$'] = 'WITH_SLASH';
    162     }
    163     if(get_option("hide_login_slug") != "")
    164         add_rewrite_rule( get_option("hide_login_slug").'/?$', 'wp-login.php', 'top' );
     168    {
     169        add_filter( 'login_url', 'new_login_url', 10, 2 );
     170        function new_login_url( $login_url, $redirect ) {
     171                return "/".get_option("hide_login_slug");
     172        }
     173    }
    165174    if(get_option("hide_register_slug") != "")
    166         add_rewrite_rule( get_option("hide_register_slug").'/?$', 'wp-login.php?action=register', 'top' );
     175    {
     176        add_filter('register','new_signup_url');
     177        function new_signup_url($url){
     178            return str_replace(site_url('wp-login.php?action=register', 'login'),site_url(get_option("hide_register_slug"), 'login'),$url);
     179        }
     180    }
    167181    if(get_option("hide_forgot_slug") != "")
    168         add_rewrite_rule( get_option("hide_forgot_slug").'/?$', 'wp-login.php?action=lostpassword', 'top' );
    169    
    170     $wp_rewrite->non_wp_rules = $other_rules + $wp_rewrite->non_wp_rules;
    171     function ht_rules($rules)
    172     {
    173         $rules = str_replace("/WITH_SLASH [QSA,L]", "%{REQUEST_URI}/ [R=301,L]", $rules);
    174         update_option("htaccess_rules", $rules);
    175         return $rules;
    176        
    177     }
    178     add_filter('mod_rewrite_rules', 'ht_rules');
    179     $wp_rewrite->flush_rules(true);
    180 }
    181 function hideSettings(){
    182     if( $_POST['notice'] )
    183         echo '<div id="message" class="updated fade"><p><strong>' . $_POST['notice'] . '</strong></p></div>';
    184         ?>
    185             <div class="wrap" style="font-family: tahoma !important;">
    186                 <h2><?php _e('Hide Login Settings', 'hidelogin')?></h2>
    187                 <form method="post" action="">
    188                 <?php if( function_exists( 'wp_nonce_field' )) wp_nonce_field( 'Hide-login-update-options'); ?>
    189                     <table class="form-table">
    190                         <tbody>
    191                             <tr valign="top">
    192                                  <th scope="row"><label for="login_slug"><?php _e('Login Slug', 'hidelogin');?></label></th>
    193                                 <td><input name="hide_login_slug" id="login_slug" value="<?php echo get_option('hide_login_slug');?>" type="text"><br />
    194                                 <strong style="color:#777;font-size:12px;">Login URL:</strong> <span style="font-size:0.9em;color:#999999;"><?php echo trailingslashit( get_option('siteurl') ); ?><span style="background-color: #fffbcc;"><?php echo get_option('hide_login_slug');?></span></span></td>
    195                             </tr>
    196                             <tr valign="top">
    197                                 <th scope="row"><label for="login_redirect"><?php _e('Login Redirect', 'hidelogin');?></label></th>
    198                                 <td><select name="hide_login_redirect" id="login_redirect">
    199                                         <?php $cus = true; ?>
    200                                         <option value="<?php echo get_option('siteurl')."/".get_option("hide_admin_slug");?>" <?php if(get_option('hide_login_redirect') == get_option('siteurl')."/".get_option("hide_admin_slug")){$cus = false;  echo 'selected="selected"';} ?>">WordPress Admin</option>
    201                                         <option value="<?php echo get_option('siteurl');?>" <?php if(get_option('hide_login_redirect') == get_option('siteurl')){$cus = false; echo 'selected="selected"';} ?>">WordPress Address</option>
    202                                         <option value="Custom" <?php if($cus){echo 'selected="selected"';} ?>">Custom URL (Enter Below)</option>
    203                                     </select><br />
    204                                 <input type="text" name="login_custom" size="40" value="<?php if($cus){ echo get_option('hide_login_redirect'); }?>" /><br />
    205                                 <strong style="color:#777;font-size:12px;">Redirect URL:</strong> <span style="font-size:0.9em;color:#999999;"><?php if( get_option('hide_login_redirect') != 'Custom' ) { echo get_option('hide_login_redirect'); } else { echo get_option('hide_login_custom'); } ?></span></td>
    206                             </tr>
    207                             <tr valign="top">
    208                                 <th scope="row"><label for="logout_slug"><?php _e('Logout Slug', 'hidelogin');?></label></th>
    209                                 <td><input type="text" name="hide_logout_slug" id="logout_slug" value="<?php echo get_option('hide_logout_slug');?>" /><br />
    210                                 <strong style="color:#777;font-size:12px;">Logout URL:</strong> <span style="font-size:0.9em;color:#999999;"><?php echo trailingslashit( get_option('siteurl') ); ?><span style="background-color: #fffbcc;"><?php echo get_option('hide_logout_slug');?></span></span></td>
    211                             </tr>
    212                          <?php if( get_option('users_can_register') ){ ?>
    213                             <tr valign="top">
    214                                 <th scope="row"><label for="register_slug"><?php _e('Register Slug', 'hidelogin');?></label></th>
    215                                 <td><input type="text" name="hide_register_slug" id="register_slug" value="<?php echo get_option('hide_register_slug');?>" /><br />
    216                                 <strong style="color:#777;font-size:12px;">Register URL:</strong> <span style="font-size:0.9em;color:#999999;"><?php echo trailingslashit( get_option('siteurl') ); ?><span style="background-color: #fffbcc;"><?php echo get_option('hide_register_slug');?></span></span></td>
    217                             </tr>
    218                           <?php } ?>
    219                           <tr valign="top">
    220                                  <th scope="row"><label for="admin_slug"><?php _e('Admin Slug', 'hidelogin');?></label></th>
    221                                 <td><input name="hide_admin_slug" id="admin_slug" value="<?php echo get_option('hide_admin_slug');?>" type="text"><br />
    222                                 <strong style="color:#777;font-size:12px;">Admin URL:</strong> <span style="font-size:0.9em;color:#999999;"><?php echo trailingslashit( get_option('siteurl') ); ?><span style="background-color: #fffbcc;"><?php echo get_option('hide_admin_slug');?></span></span></td>
    223                             </tr>
    224                             <tr valign="top">
    225                                  <th scope="row"><label for="forgot_slug"><?php _e('Forgot Password Slug', 'hidelogin');?></label></th>
    226                                 <td><input name="hide_forgot_slug" id="forgot_slug" value="<?php echo get_option('hide_forgot_slug');?>" type="text"><br />
    227                                 <strong style="color:#777;font-size:12px;">Forgot Password URL:</strong> <span style="font-size:0.9em;color:#999999;"><?php echo trailingslashit( get_option('siteurl') ); ?><span style="background-color: #fffbcc;"><?php echo get_option('hide_forgot_slug');?></span></span></td>
    228                             </tr>
    229                             <tr valign="top">
    230                                 <th scope="row"><?php _e('hide Mode', 'hidelogin'); ?></th>
    231                                 <td><label><input type="radio" name="hide_mode" value="1" <?php if(get_option('hide_mode') ) echo 'checked="checked" ';?> /> Enable</label><br />
    232                                     <label><input type="radio" name="hide_mode" value="0" <?php if(!get_option('hide_mode') ) echo 'checked="checked" ';?>/> Disable</label><br />
    233                                     <small><?php _e('Prevent users from being able to access wp-login.php directly ( enable this when you use custom login slug )','hidelogin');?></small></td>
    234                             </tr>
    235                             <tr valign="top">
    236                                 <th scope="row"><?php _e('hide wp-admin', 'hidelogin'); ?></th>
    237                                 <td><label><input type="radio" name="hide_wp_admin" value="1" <?php if(get_option('hide_wp_admin') ) echo 'checked="checked" ';?> /> Enable</label><br />
    238                                     <label><input type="radio" name="hide_wp_admin" value="0" <?php if(!get_option('hide_wp_admin') ) echo 'checked="checked" ';?>/> Disable</label><br />
    239                                     <small><?php _e('Prevent users from being able to access wp-admin directly ( enable this when you use custom admin slug )','hidelogin');?></small></td>
    240                             </tr>
    241                             <tr valign="top">
    242                             <th scope="row"><?php _e('.htaccess Output', 'hidelogin');?></th>
    243                             <td style="color: navy;"><pre><?php echo ((get_option('htaccess_rules') != "")?get_option('htaccess_rules'):"<span style=\"color: red !important;\">No Output.</span>");?></pre></td>
    244                             </tr>
    245                             <tr valign="top">
    246                             <th scope="row"><?php _e('Did the Tricks ?', 'hidelogin');?></th>
    247                             <td>
    248                                     <input name="Submit" style="font-family: tahoma !important; font-weight: bold;" value="<?php _e('Save Changes','hidelogin');?>" type="submit" />
    249                                     <input name="action" value="hide_login_update" type="hidden" />
    250                             </td>
    251                             </tr>
    252                         </tbody>
    253                     </table>
    254                 </form>
    255              
    256             </div>
    257 <?php
    258 }
    259 function _deactivate()
    260 {
    261     remove_action( 'generate_rewrite_rules', 'hide_login' );
    262     $GLOBALS['wp_rewrite']->flush_rules(true);
    263 }
    264 register_deactivation_hook( __FILE__ , '_deactivate' );
     182    {
     183        add_filter('lostpassword_url','new_forgetpass_url');
     184        function new_forgetpass_url($url){
     185           return str_replace('?action=lostpassword','',str_replace(network_site_url('wp-login.php', 'login'),site_url(get_option("hide_forgot_slug"), 'login'),$url));
     186        }
     187    }
     188    /**
     189     * [hide_login write rewrite rules in .htaccess file]
     190     */
     191    function hide_login()
     192    {
     193        global $wp_rewrite;
     194        $other_rules = array();
     195        if(get_option("hide_admin_slug") != "")
     196        {
     197            add_rewrite_rule( get_option("hide_admin_slug").'/(.*?)$', 'wp-admin/$1?%{QUERY_STRING}', 'top' );
     198            $other_rules[get_option("hide_admin_slug").'$'] = 'WITH_SLASH';
     199        }
     200        if(get_option("hide_login_slug") != "")
     201        {
     202            add_rewrite_rule( get_option("hide_login_slug").'/?$', 'wp-login.php', 'top' );
     203        }
     204        if(get_option("hide_register_slug") != "")
     205        {
     206            add_rewrite_rule( get_option("hide_register_slug").'/?$', 'wp-login.php?action=register', 'top' );
     207        }
     208        if(get_option("hide_forgot_slug") != "")
     209        {
     210            add_rewrite_rule( get_option("hide_forgot_slug").'/?$', 'wp-login.php?action=lostpassword', 'top' );
     211        }
     212        $wp_rewrite->non_wp_rules = $other_rules + $wp_rewrite->non_wp_rules;
     213        function ht_rules($rules)
     214        {
     215            $rules = str_replace("/WITH_SLASH [QSA,L]", "%{REQUEST_URI}/ [R=301,L]", $rules);
     216            update_option("htaccess_rules", $rules);
     217            return $rules;
     218           
     219        }
     220        add_filter('mod_rewrite_rules', 'ht_rules');
     221        $wp_rewrite->flush_rules(true);
     222    }
     223    /**
     224     * [dis_msg description]
     225     * @param  [type] $msg  [shown message]
     226     * @param  string $type [if "success"ful or an "error"]
     227     * @return [string]       [html and message]
     228     */
     229    function dis_msg($msg, $type = "success")
     230    {
     231        if($type == "success")
     232        {
     233            $display = '<div id="message" class="updated fade"><p><strong>' . $msg . '</strong></p></div>';
     234        }
     235        else if($type == "error")
     236        {
     237            $display = '<div id="message" class="error fade"><p><strong>' . $msg . '</strong></p></div>';
     238        }
     239        return $display;
     240    }
     241    /**
     242     * [hideSettings form on the settings page]
     243     */
     244    function hideSettings()
     245    {
     246        echo dis_msg($_POST['notice'], $_POST['type']);
     247            ?>
     248                <div class="wrap" style="font-family: tahoma !important;">
     249                    <h2><?php _e('Hide Login Settings', 'hidelogin')?></h2>
     250                    <form method="post" action="">
     251                        <table class="form-table">
     252                            <tbody>
     253                                <tr valign="top">
     254                                     <th scope="row"><label for="login_slug"><?php _e('Login Slug', 'hidelogin');?></label></th>
     255                                    <td><input name="hide_login_slug" id="login_slug" value="<?php echo get_option('hide_login_slug');?>" type="text"><br />
     256                                    <strong style="color:#777;font-size:12px;">Login URL:</strong> <span style="font-size:0.9em;color:#999999;"><?php echo trailingslashit( get_option('siteurl') ); ?><span style="background-color: #fffbcc;"><?php echo get_option('hide_login_slug');?></span></span></td>
     257                                </tr>
     258                                <tr valign="top">
     259                                    <th scope="row"><label for="login_redirect"><?php _e('Login Redirect', 'hidelogin');?></label></th>
     260                                    <td><select name="hide_login_redirect" id="login_redirect">
     261                                            <?php $cus = true; ?>
     262                                            <option value="<?php echo get_option('siteurl')."/".get_option("hide_admin_slug");?>" <?php if(get_option('hide_login_redirect') == get_option('siteurl')."/".get_option("hide_admin_slug")){$cus = false;  echo 'selected="selected"';} ?>>WordPress Admin</option>
     263                                            <option value="<?php echo get_option('siteurl');?>" <?php if(get_option('hide_login_redirect') == get_option('siteurl')){$cus = false; echo 'selected="selected"';} ?>>WordPress Address</option>
     264                                            <option value="Custom" <?php if($cus){echo 'selected="selected"';} ?>>Custom URL (Enter Below)</option>
     265                                        </select><br />
     266                                    <input type="text" name="login_custom" size="40" value="<?php if($cus){ echo get_option('hide_login_redirect'); }?>" /><br />
     267                                    <strong style="color:#777;font-size:12px;">Redirect URL:</strong> <span style="font-size:0.9em;color:#999999;"><?php if( get_option('hide_login_redirect') != 'Custom' ) { echo get_option('hide_login_redirect'); } else { echo get_option('hide_login_custom'); } ?></span></td>
     268                                </tr>
     269                                <tr valign="top">
     270                                    <th scope="row"><label for="logout_slug"><?php _e('Logout Slug', 'hidelogin');?></label></th>
     271                                    <td><input type="text" name="hide_logout_slug" id="logout_slug" value="<?php echo get_option('hide_logout_slug');?>" /><br />
     272                                    <strong style="color:#777;font-size:12px;">Logout URL:</strong> <span style="font-size:0.9em;color:#999999;"><?php echo trailingslashit( get_option('siteurl') ); ?><span style="background-color: #fffbcc;"><?php echo get_option('hide_logout_slug');?></span></span></td>
     273                                </tr>
     274                             <?php if( get_option('users_can_register') ){ ?>
     275                                <tr valign="top">
     276                                    <th scope="row"><label for="register_slug"><?php _e('Register Slug', 'hidelogin');?></label></th>
     277                                    <td><input type="text" name="hide_register_slug" id="register_slug" value="<?php echo get_option('hide_register_slug');?>" /><br />
     278                                    <strong style="color:#777;font-size:12px;">Register URL:</strong> <span style="font-size:0.9em;color:#999999;"><?php echo trailingslashit( get_option('siteurl') ); ?><span style="background-color: #fffbcc;"><?php echo get_option('hide_register_slug');?></span></span></td>
     279                                </tr>
     280                              <?php } ?>
     281                              <tr valign="top">
     282                                     <th scope="row"><label for="admin_slug"><?php _e('Admin Slug', 'hidelogin');?></label></th>
     283                                    <td><input name="hide_admin_slug" id="admin_slug" value="<?php echo get_option('hide_admin_slug');?>" type="text"><br />
     284                                    <strong style="color:#777;font-size:12px;">Admin URL:</strong> <span style="font-size:0.9em;color:#999999;"><?php echo trailingslashit( get_option('siteurl') ); ?><span style="background-color: #fffbcc;"><?php echo get_option('hide_admin_slug');?></span></span></td>
     285                                </tr>
     286                                <tr valign="top">
     287                                     <th scope="row"><label for="forgot_slug"><?php _e('Forgot Password Slug', 'hidelogin');?></label></th>
     288                                    <td><input name="hide_forgot_slug" id="forgot_slug" value="<?php echo get_option('hide_forgot_slug');?>" type="text"><br />
     289                                    <strong style="color:#777;font-size:12px;">Forgot Password URL:</strong> <span style="font-size:0.9em;color:#999999;"><?php echo trailingslashit( get_option('siteurl') ); ?><span style="background-color: #fffbcc;"><?php echo get_option('hide_forgot_slug');?></span></span></td>
     290                                </tr>
     291                                <tr valign="top">
     292                                    <th scope="row"><?php _e('hide Mode', 'hidelogin'); ?></th>
     293                                    <td><label><input type="radio" name="hide_mode" value="1" <?php if(get_option('hide_mode') ) echo 'checked="checked" ';?> /> Enable</label><br />
     294                                        <label><input type="radio" name="hide_mode" value="0" <?php if(!get_option('hide_mode') ) echo 'checked="checked" ';?>/> Disable</label><br />
     295                                        <small><?php _e('Prevent users from being able to access wp-login.php directly ( enable this when you use custom login slug )','hidelogin');?></small></td>
     296                                </tr>
     297                                <tr valign="top">
     298                                    <th scope="row"><?php _e('hide wp-admin', 'hidelogin'); ?></th>
     299                                    <td><label><input type="radio" name="hide_wp_admin" value="1" <?php if(get_option('hide_wp_admin') ) echo 'checked="checked" ';?> /> Enable</label><br />
     300                                        <label><input type="radio" name="hide_wp_admin" value="0" <?php if(!get_option('hide_wp_admin') ) echo 'checked="checked" ';?>/> Disable</label><br />
     301                                        <small><?php _e('Prevent users from being able to access wp-admin directly ( enable this when you use custom admin slug )','hidelogin');?></small></td>
     302                                </tr>
     303                                <tr valign="top">
     304                                <th scope="row"><?php _e('.htaccess Output', 'hidelogin');?></th>
     305                                <td style="color: navy;"><pre><?php echo ((get_option('htaccess_rules') != "")?get_option('htaccess_rules'):"<span style=\"color: red !important;\">No Output.</span>");?></pre></td>
     306                                </tr>
     307                                <tr valign="top">
     308                                <th scope="row"><?php _e('Did the Tricks ?', 'hidelogin');?></th>
     309                                <td>
     310                                        <input name="Submit" style="font-family: tahoma !important; font-weight: bold;" value="<?php _e('Save Changes','hidelogin');?>" type="submit" />
     311                                        <input name="action" value="hide_login_update" type="hidden" />
     312                                </td>
     313                                </tr>
     314                            </tbody>
     315                        </table>
     316                    </form>
     317                 
     318                </div>
     319    <?php
     320    }
     321    /**
     322     * [_deactivate remove all changes and leave wordpres rules as default on deactivation]
     323     */
     324    function _deactivate()
     325    {
     326        remove_action( 'generate_rewrite_rules', 'hide_login' );
     327        $GLOBALS['wp_rewrite']->flush_rules(true);
     328    }
     329    register_deactivation_hook( __FILE__ , '_deactivate' );
    265330?>
  • hide-login/trunk/readme.txt

    r662767 r766174  
    44Requires at least: 2.3
    55Tested up to: 3.5.1
    6 Stable tag: 3.0
     6Stable tag: 3.1
    77
    88Have a Secure Login Page! Allows you to create custom URLs for user's login, logout and admin's login page.
     
    2020
    21211. Upload the `hide-login` directory to the `/wp-content/plugins/` directory
    22 
    23222. Add these two lines in wp-config.php file after `/* That's all, stop editing! Happy blogging. */`
    2423`define('WP_ADMIN_DIR', 'YOUR_ADMIN_SLUG');`
    2524`define('ADMIN_COOKIE_PATH', SITECOOKIEPATH . WP_ADMIN_DIR);`
    26 Where `YOUR_ADMIN_SLUG` is the slug you will use in plugin settings page for Admin.
    27 
     25Where `YOUR_ADMIN_SLUG` is the slug you use in plugin setting page for Admin.
    28263. Activate the plugin through the 'Plugins' menu in WordPress
    29 
    30274. Set the options in the Settings Panel
    3128
    3229== Changelog ==
     30= 3.1 =
     31    * Changed some default options at activation to avoid 500 Servre internal error
     32    * Restrictions on using default slugs like `wp-admin` for admin slug that made confliction
     33    * Optimized code readablity and stability
     34    * Solved fatal error caused by `check_admin_referer()`
     35    * Tested over wordpress 3.6
    3336= 3.0 =
    3437    * Completely rewrote.
    3538    * All rewrite rules will apply with wordpress buil-in functions
    36     * Remove plugin rewrite rules automatically on deactivation
     39    * Remove plugin rewrite rules automatically on deactivation to wordpres default rules
    3740    * Works with all permalink structures
    3841    * Droped some useless options and codes and improved functionality
    39     * Now Setting page menue is at root
     42    * Now Setting page menu is at root
    4043    * Tested Over the latest Wordpress version(3.5.1)
    4144= 2.1 =
Note: See TracChangeset for help on using the changeset viewer.