Changeset 681396
- Timestamp:
- 03/13/2013 06:33:46 PM (13 years ago)
- Location:
- gatekeeper/trunk
- Files:
-
- 1 added
- 3 edited
-
gk-jquery.js (added)
-
gkfunc.php (modified) (6 diffs)
-
readme.txt (modified) (2 diffs)
-
style.css (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
gatekeeper/trunk/gkfunc.php
r408778 r681396 4 4 Plugin URI: http://wordpress.org/extend/plugins/gatekeeper 5 5 Description: 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 BETA6 Version: 1.0 7 7 Author: Jamie Wilson 8 8 Author URI: http://jamiewilson.net 9 9 License: GPL2 10 10 11 Copyright © 2011 Jamie Wilson (email: wpdev@jamiewilson.net)11 Copyright © 2011-2013 Jamie Wilson (email: wpdev@jamiewilson.net) 12 12 13 13 This program is free software; you can redistribute it and/or modify … … 31 31 32 32 // REGISTER ACTIONS 33 add_action('admin_head', 'admin_register_head');34 33 add_action('init', 'gatekeeper_watch_the_gate', 1); 35 34 add_action('admin_notices', 'gatekeeper_admin_status'); 35 add_action('admin_head', 'gatekeeper_css_register'); 36 add_action('admin_head', 'gatekeeper_js_register'); 37 36 38 37 39 // SETUP ADMIN MENU … … 84 86 85 87 // 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"; 88 function 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 94 function gatekeeper_js_register() { 95 wp_register_script("gatekeeper-js", plugins_url("gk-jquery.js", __FILE__) ); 96 wp_enqueue_script("gatekeeper-js"); 90 97 } 91 98 … … 100 107 101 108 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>"; 116 110 } 117 111 } … … 134 128 <?php if ($_GET['settings-updated']) { 135 129 echo "<div style='color: red;'>Settings saved.</div>"; } ?> 136 <?php /*<p>137 [ GATEKEEPER DEVELOPMENT VERSION - NOT FOR DISTRIBUTION ]138 </p>*/ ?>139 130 140 131 <div id="gk-main"> … … 180 171 181 172 <?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> 224 213 225 214 <?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> 262 249 263 250 <p class="submit"> -
gatekeeper/trunk/readme.txt
r408522 r681396 4 4 Tags: gatekeeper, offline, maintenance, whitelist, blacklist, access, ip, coming soon 5 5 Requires at least: 3.0 6 Tested up to: 3. 36 Tested up to: 3.5.1 7 7 Stable tag: trunk 8 8 … … 57 57 == Changelog == 58 58 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 59 65 = 0.8 = 60 66 * Initial release (beta version). -
gatekeeper/trunk/style.css
r408779 r681396 2 2 GATEKEEPER STYLESHEET 3 3 Author: Jamie Wilson 4 Copyright © 2011 Jamie Wilson (wpdev@jamiewilson.net)4 Copyright © 2011-2013 Jamie Wilson (wpdev@jamiewilson.net) 5 5 */ 6 6 7 7 .gk-rounded { 8 8 -moz-border-radius: 5px; 9 -khtml-border-radius: 5px;10 9 -webkit-border-radius: 5px; 10 border-radius: 5px; 11 11 } 12 12 13 .gk- option-table .gk-section-title {13 .gk-section-title { 14 14 background-color: #dfdfdf; 15 15 font: bold 16px sans-serif; … … 17 17 padding: 5px; 18 18 -moz-border-radius: 5px; 19 -khtml-border-radius: 5px;20 19 -webkit-border-radius: 5px; 20 border-radius: 5px;x; 21 21 } 22 22 23 23 .gk-option-table textarea { 24 24 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; 25 50 } 26 51 … … 39 64 margin-bottom: 10px; 40 65 -moz-border-radius: 5px; 41 -khtml-border-radius: 5px;42 66 -webkit-border-radius: 5px; 67 border-radius: 5px; 43 68 } 44 69 … … 50 75 -moz-border-topleft-radius: 5px; 51 76 -moz-border-topright-radius: 5px; 52 -khtml-border-topleft-radius: 5px;53 -khtml-border-topright-radius: 5px;54 77 -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; 56 80 } 57 81 … … 69 93 text-transform: uppercase; 70 94 width: 100%; 95 96 -moz-border-radius: 5px; 97 -webkit-border-radius: 5px; 98 border-radius: 5px; 71 99 }
Note: See TracChangeset
for help on using the changeset viewer.