Plugin Directory

Changeset 681396


Ignore:
Timestamp:
03/13/2013 06:33:46 PM (13 years ago)
Author:
jamiewilson
Message:

Upgrade to v1.0

Location:
gatekeeper/trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • gatekeeper/trunk/gkfunc.php

    r408778 r681396  
    44Plugin URI: http://wordpress.org/extend/plugins/gatekeeper
    55Description: Gatekeeper allows administrators to take a WordPress site offline quickly and easily while leaving it fully accessible to administrators and other authorized users. Site visitors will be shown or redirected to a specified offline page. An optional blacklist can be used for permanent bans.
    6 Version: 0.8.1 BETA
     6Version: 1.0
    77Author: Jamie Wilson
    88Author URI: http://jamiewilson.net
    99License: GPL2
    1010 
    11     Copyright © 2011 Jamie Wilson (email: wpdev@jamiewilson.net)
     11    Copyright © 2011-2013 Jamie Wilson (email: wpdev@jamiewilson.net)
    1212
    1313    This program is free software; you can redistribute it and/or modify
     
    3131
    3232// REGISTER ACTIONS
    33 add_action('admin_head', 'admin_register_head');
    3433add_action('init', 'gatekeeper_watch_the_gate', 1);
    3534add_action('admin_notices', 'gatekeeper_admin_status');
     35add_action('admin_head', 'gatekeeper_css_register');
     36add_action('admin_head', 'gatekeeper_js_register');
     37
    3638
    3739// SETUP ADMIN MENU
     
    8486
    8587// REGISTER EXTERNAL CSS
    86 function admin_register_head() {
    87     $siteurl = get_option('siteurl');
    88     $url = $siteurl . '/wp-content/plugins/' . basename(dirname(__FILE__)) . '/style.css';
    89     echo "<link rel='stylesheet' type='text/css' href='$url' />\n";
     88function gatekeeper_css_register() {
     89    wp_register_style("gatekeeper-css", plugins_url("style.css", __FILE__), false, false);
     90    wp_enqueue_style("gatekeeper-css");
     91}
     92
     93// REGISTER EXTERNAL JAVASCRIPT
     94function gatekeeper_js_register() {
     95    wp_register_script("gatekeeper-js", plugins_url("gk-jquery.js", __FILE__) );
     96    wp_enqueue_script("gatekeeper-js");
    9097}
    9198
     
    100107
    101108    if (get_option('gatekeeper_active') == 'true') {
    102         echo "<div style='float: right;
    103                                 margin: 0 10px;
    104                                 padding: 3px 5px;
    105                                 background-color: red;
    106                                 color: white;
    107                                 font-weight: bold;
    108                                 text-shadow: rgba(0, 0, 0, 0.3) 0 -1px 0;
    109                                 -moz-border-radius-bottomleft: 5px;
    110                                 -moz-border-radius-bottomright: 5px;
    111                                 -webkit-border-radius-bottomleft: 5px;
    112                                 -webkit-border-radius-bottomright: 5px;
    113                                 border-bottom-left-radius: 5px;
    114                                 border-bottom-right-radius: 5px;
    115                                 '><a href='" . get_admin_url() . "tools.php?page=gatekeeper' style='color: white; text-decoration: none;' title='Gatekeeper is active'>Offline</a></div>";
     109        echo "<div id='gk-active-notifier'><a href='" . get_admin_url() . "tools.php?page=gatekeeper' title='Gatekeeper is active'>Offline</a></div>";
    116110    }
    117111}
     
    134128        <?php if ($_GET['settings-updated']) {
    135129            echo "<div style='color: red;'>Settings saved.</div>"; } ?>
    136         <?php /*<p>
    137             [ GATEKEEPER DEVELOPMENT VERSION - NOT FOR DISTRIBUTION ]
    138         </p>*/ ?>
    139130       
    140131        <div id="gk-main">
     
    180171           
    181172            <?php /* WHITELIST TABLE */ ?>
    182             <table class="form-table gk-option-table" style="margin-top: 20px;">
    183                 <thead>
    184                     <tr valign="top">
    185                         <th colspan="2" class="gk-section-title">Whitelist</th>
    186                     </tr>
    187                 </thead>
    188                
    189                 <tr valign="top">
    190                     <td colspan="2">Allow the following to access the site when it is offline for everyone else.</td>               
    191                 </tr>
    192                
    193                 <?php /* WHITELIST ADMINS */ ?>
    194                 <tr valign="top">
    195                     <th scope="row"><label for="gatekeeper_allowadmins" title="Don't apply offline status to logged-in administrators.">Whitelist Logged-in Admins:</label></th>
    196                     <td><input name="gatekeeper_allowadmins" type="checkbox" value="true" <?php if (get_option('gatekeeper_allowadmins') == "true") { echo "CHECKED"; } ?> /></td> 
    197                 </tr>
    198                
    199                 <?php /* AUTO-PROTECT ADMIN IP */ ?>
    200                 <tr valign="top">
    201                     <th scope="row"><label for="gatekeeper_autoprotect_adminip" title="Automatically whitelist your current IP address to prevent accidentally lock-out.">Auto-Protect Admin IP:</label></th>   
    202                     <td>
    203                         <input name="gatekeeper_autoprotect_adminip" type="checkbox" value="true" <?php if (get_option('gatekeeper_autoprotect_adminip') == "true") { echo "CHECKED"; } ?>                 
    204                     </td>           
    205                 </tr>
    206                
    207                 <?php /* ADMIN IP */ ?>
    208                 <tr valign="top">
    209                     <th scope="row"><label for="gatekeeper_adminip" title="Your current IP (will be auto-whitelisted when you save).">Administrator IP:</label></th>
    210                     <td>
    211                         <input name="gatekeeper_adminipDISPLAY" type="text" disabled="disabled" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>" />
    212                         <input type="hidden" name="gatekeeper_adminip" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>" />
    213                     </td>           
    214                 </tr>
    215                
    216                 <?php /* WHITELIST */ ?>
    217                 <tr valign="top">
    218                     <th scope="row"><label for="gatekeeper_whitelist" title="Whitelist: one per line. Examples: 192.168.10.103, 192.168.10.*, 192.168.10.[0-9]">Whitelist:</label></th>
    219                     <td>
    220                         <textarea name="gatekeeper_whitelist"><?php echo get_option('gatekeeper_whitelist'); ?></textarea>                 
    221                     </td>               
    222                 </tr>                           
    223             </table>
     173            <div id="gk-whitelist">
     174                <div id="gk-whitelist-title" class="gk-section-title">Whitelist</div>
     175                <table id="gk-whitelist-table" class="form-table gk-option-table" style="margin-top: 20px;">
     176                   
     177                    <tr valign="top">
     178                        <td colspan="2">Allow the following to access the site when it is offline for everyone else.</td>               
     179                    </tr>
     180                   
     181                    <?php /* WHITELIST ADMINS */ ?>
     182                    <tr valign="top">
     183                        <th scope="row"><label for="gatekeeper_allowadmins" title="Don't apply offline status to logged-in administrators.">Whitelist Logged-in Admins:</label></th>
     184                        <td><input name="gatekeeper_allowadmins" type="checkbox" value="true" <?php if (get_option('gatekeeper_allowadmins') == "true") { echo "CHECKED"; } ?> /></td> 
     185                    </tr>
     186                   
     187                    <?php /* AUTO-PROTECT ADMIN IP */ ?>
     188                    <tr valign="top">
     189                        <th scope="row"><label for="gatekeeper_autoprotect_adminip" title="Automatically whitelist your current IP address to prevent accidentally lock-out.">Auto-Protect Admin IP:</label></th>   
     190                        <td>
     191                            <input name="gatekeeper_autoprotect_adminip" type="checkbox" value="true" <?php if (get_option('gatekeeper_autoprotect_adminip') == "true") { echo "CHECKED"; } ?>                 
     192                        </td>           
     193                    </tr>
     194                   
     195                    <?php /* ADMIN IP */ ?>
     196                    <tr valign="top">
     197                        <th scope="row"><label for="gatekeeper_adminip" title="Your current IP (will be auto-whitelisted when you save).">Administrator IP:</label></th>
     198                        <td>
     199                            <input name="gatekeeper_adminipDISPLAY" type="text" disabled="disabled" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>" />
     200                            <input type="hidden" name="gatekeeper_adminip" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>" />
     201                        </td>           
     202                    </tr>
     203                   
     204                    <?php /* WHITELIST */ ?>
     205                    <tr valign="top">
     206                        <th scope="row"><label for="gatekeeper_whitelist" title="Whitelist: one per line. Examples: 192.168.10.103, 192.168.10.*, 192.168.10.[0-9]">Whitelist:</label></th>
     207                        <td>
     208                            <textarea name="gatekeeper_whitelist"><?php echo get_option('gatekeeper_whitelist'); ?></textarea>                 
     209                        </td>               
     210                    </tr>                           
     211                </table>
     212            </div>
    224213           
    225214            <?php /* BLACKLIST TABLE */ ?>
    226             <table class="form-table gk-option-table" style="margin-top: 20px;">
    227                 <thead>
    228                     <tr valign="top">
    229                         <th colspan="2" class="gk-section-title">Blacklist</th>             
    230                     </tr>
    231                 </thead>
    232                
    233                 <tr valign="top">
    234                     <td colspan="2">Prevent blacklisted IPs from accessing the site at any time, including login and registration pages.</td>               
    235                 </tr>
    236                
    237                 <?php /* BLACKLIST BEHAVIOR */ ?>
    238                 <tr valign="top">
    239                     <th scope="row"><label for="gatekeeper_blacklist_behavior" title="Redirect to an offline page or display an offline page without redirecting the page.">Offline Behavior:</label></th>
    240                     <td>
    241                         <input type="radio" name="gatekeeper_blacklist_behavior" value="redirect" <?php if (get_option('gatekeeper_blacklist_behavior') != 'replace') { echo "checked"; } ?> />Redirect (301 Moved Permanently) <br />
    242                         <input type="radio" name="gatekeeper_blacklist_behavior" value="replace" <?php if (get_option('gatekeeper_blacklist_behavior') == 'replace') { echo "checked"; } ?> />Replace page                 
    243                     </td>               
    244                 </tr>
    245                
    246                 <?php /* BLACKLIST PAGE */ ?>
    247                 <tr valign="top">
    248                     <th scope="row"><label for="gatekeeper_blacklist_redirect_page" title="Display this page to blacklisted IPs. This cannot be a WordPress-managed page.">Blacklist page:</label></th>
    249                     <td>
    250                         <input name="gatekeeper_blacklist_redirect_page" type="text" style="width: 400px;" value="<?php echo get_option('gatekeeper_blacklist_redirect_page'); ?>" />                   
    251                     </td>               
    252                 </tr>
    253                
    254                 <?php /* BLACKLIST */ ?>
    255                 <tr valign="top">
    256                     <th scope="row"><label for="gatekeeper_blacklist" title="Blacklist: one per line. Examples: 192.168.10.103, 192.168.10.*, 192.168.10.[0-9]">Blacklist:</label></th>
    257                     <td>
    258                         <textarea name="gatekeeper_blacklist"><?php echo get_option('gatekeeper_blacklist'); ?></textarea>                 
    259                     </td>               
    260                 </tr>               
    261             </table>
     215            <div id="gk-blacklist">
     216                <div id="gk-blacklist-title" class="gk-section-title">Blacklist</div>
     217                <table id="gk-blacklist-table" class="form-table gk-option-table" style="margin-top: 20px;">
     218                   
     219                    <tr valign="top">
     220                        <td colspan="2">Prevent blacklisted IPs from accessing the site at any time, including login and registration pages.</td>               
     221                    </tr>
     222                   
     223                    <?php /* BLACKLIST BEHAVIOR */ ?>
     224                    <tr valign="top">
     225                        <th scope="row"><label for="gatekeeper_blacklist_behavior" title="Redirect to an offline page or display an offline page without redirecting the page.">Offline Behavior:</label></th>
     226                        <td>
     227                            <input type="radio" name="gatekeeper_blacklist_behavior" value="redirect" <?php if (get_option('gatekeeper_blacklist_behavior') != 'replace') { echo "checked"; } ?> />Redirect (301 Moved Permanently) <br />
     228                            <input type="radio" name="gatekeeper_blacklist_behavior" value="replace" <?php if (get_option('gatekeeper_blacklist_behavior') == 'replace') { echo "checked"; } ?> />Replace page                 
     229                        </td>               
     230                    </tr>
     231                   
     232                    <?php /* BLACKLIST PAGE */ ?>
     233                    <tr valign="top">
     234                        <th scope="row"><label for="gatekeeper_blacklist_redirect_page" title="Display this page to blacklisted IPs. This cannot be a WordPress-managed page.">Blacklist page:</label></th>
     235                        <td>
     236                            <input name="gatekeeper_blacklist_redirect_page" type="text" style="width: 400px;" value="<?php echo get_option('gatekeeper_blacklist_redirect_page'); ?>" />                   
     237                        </td>               
     238                    </tr>
     239                   
     240                    <?php /* BLACKLIST */ ?>
     241                    <tr valign="top">
     242                        <th scope="row"><label for="gatekeeper_blacklist" title="Blacklist: one per line. Examples: 192.168.10.103, 192.168.10.*, 192.168.10.[0-9]">Blacklist:</label></th>
     243                        <td>
     244                            <textarea name="gatekeeper_blacklist"><?php echo get_option('gatekeeper_blacklist'); ?></textarea>                 
     245                        </td>               
     246                    </tr>               
     247                </table>
     248            </div>
    262249               
    263250            <p class="submit">
  • gatekeeper/trunk/readme.txt

    r408522 r681396  
    44Tags: gatekeeper, offline, maintenance, whitelist, blacklist, access, ip, coming soon
    55Requires at least: 3.0
    6 Tested up to: 3.3
     6Tested up to: 3.5.1
    77Stable tag: trunk
    88
     
    5757== Changelog ==
    5858
     59= 1.0 =
     60* Updated code to avoid conflicts with other plugins and themes that were resulting in "Fatal error: Cannot redeclare admin_register_head()" errors.
     61* Consolidated plugin styles (CSS) into one stylesheet, instead of having some inline styles scattered throughout the code.
     62* Whitelist/Blacklist options are now collapsible (and collapsed by default).
     63* Minor miscellaneous visual improvements.
     64
    5965= 0.8 =
    6066* Initial release (beta version).
  • gatekeeper/trunk/style.css

    r408779 r681396  
    22    GATEKEEPER STYLESHEET
    33    Author: Jamie Wilson
    4     Copyright © 2011 Jamie Wilson (wpdev@jamiewilson.net)
     4    Copyright © 2011-2013 Jamie Wilson (wpdev@jamiewilson.net)
    55*/
    66
    77.gk-rounded {
    88    -moz-border-radius: 5px;
    9     -khtml-border-radius: 5px;
    109    -webkit-border-radius: 5px;
     10    border-radius: 5px;
    1111}
    1212
    13 .gk-option-table .gk-section-title {
     13.gk-section-title {
    1414    background-color: #dfdfdf;
    1515    font: bold 16px sans-serif;
     
    1717    padding: 5px;
    1818    -moz-border-radius: 5px;
    19     -khtml-border-radius: 5px;
    2019    -webkit-border-radius: 5px;
     20    border-radius: 5px;x;
    2121    }
    2222
    2323.gk-option-table textarea {
    2424    width: 400px;
     25    }
     26   
     27#gk-active-notifier {
     28    background-color: red;
     29    border: 1px solid rgb(119,119,119);
     30    color: white;
     31    float: right;
     32    font-size: 12px;
     33    line-height: 22px;
     34    font-weight: bold;
     35    height: 22px;
     36    margin: 0 2px;
     37    padding: 0px 6px;
     38    text-shadow: rgba(0, 0, 0, 0.3) 1px 0.8;
     39   
     40    -moz-border-radius-bottomleft: 5px;
     41    -moz-border-radius-bottomright: 5px;
     42    -webkit-border-radius-bottomleft: 5px;
     43    -webkit-border-radius-bottomright: 5px;
     44    border-bottom-left-radius: 5px;
     45    border-bottom-right-radius: 5px;
     46}
     47    #gk-active-notifier a {
     48        color: white;
     49        text-decoration: none;
    2550    }
    2651
     
    3964    margin-bottom: 10px;
    4065    -moz-border-radius: 5px;
    41     -khtml-border-radius: 5px;
    4266    -webkit-border-radius: 5px;
     67    border-radius: 5px;
    4368    }
    4469   
     
    5075    -moz-border-topleft-radius: 5px;
    5176    -moz-border-topright-radius: 5px;
    52     -khtml-border-topleft-radius: 5px;
    53     -khtml-border-topright-radius: 5px;
    5477    -webkit-border-top-left-radius: 5px;
    55     -webkit-border-top-rightradius: 5px;   
     78    -webkit-border-top-rightradius: 5px;
     79    border-radius: 5px 5px 0 0;
    5680    }
    5781   
     
    6993    text-transform: uppercase;
    7094    width: 100%;
     95   
     96    -moz-border-radius: 5px;
     97    -webkit-border-radius: 5px;
     98    border-radius: 5px;
    7199    }
Note: See TracChangeset for help on using the changeset viewer.