underConstruction - Version 1.06

Version Description

  • Added the ability to allow certain IP addresses to see the site
  • Added the ability to have a 301 redirect instead of having the "Coming Soon" page
  • Added the ability to restrict what level of user can log into the site (Thanks Gerry for the feature request!)
Download this release

Release Info

Developer jkmassel
Plugin Icon 128x128 underConstruction
Version 1.06
Comparing to
See all releases

Code changes from version 1.05 to 1.06

ajax-loader.gif ADDED
Binary file
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: Jeremy Massel
3
Donate link: http://masseltech.com/donate/
4
Tags: construction, under construction, private, preview, security, coming soon
5
Requires at least: 2.7
6
- Tested up to: 3.1
7
- Stable tag: 1.05
8
9
Creates a 'Coming Soon' page that will show for all users who are not logged in
10
@@ -12,11 +12,6 @@ Creates a 'Coming Soon' page that will show for all users who are not logged in
12
13
Creates a 'Coming Soon' page that will show for all users who are not logged in. Useful for developing a site on a live server, without the world being able to see it
14
15
-
16
- *Shameless plug*
17
- Try my new App on the Mac App Store. It's great for testing Web Services, AJAX calls, or any time you just need a simple way to make a POST request!
18
- http://itunes.apple.com/us/app/rest-tester/id424466236?mt=12&ls=1
19
-
20
== Installation ==
21
22
1. Upload the folder to the `/wp-content/plugins/` directory
@@ -26,7 +21,7 @@ http://itunes.apple.com/us/app/rest-tester/id424466236?mt=12&ls=1
26
== Frequently Asked Questions ==
27
28
= I'm finished with it, and disabled the plugin, but the "under construction" message is still showing up! =
29
- If you've disabled the plugin, it won't show anything anymore. To be extra super-sure, try deleting the plugin files. Usually, though, the issue is that you're seeing a cached version of the page. Try force-refreshing your browser, and then try clearing your cache on the server and force refreshing again.
30
31
= I can't see the under construction page! =
32
As long as you're logged in, you won't be able to see it. That's a feature! This way, while you're logged in you can work as usual. To preview what it looks like, either a) log out, or b) try viewing it in another browser
@@ -48,6 +43,11 @@ Sorry, I get a lot of questions. But visit the homepage for this plugin and leav
48
49
== Changelog ==
50
51
= 1.05 =
52
* Fixed an issue where single quotes were being escaped on custom HTML pages. They will now be unquoted when printed to the screen
53
@@ -98,6 +98,7 @@ Sorry, I get a lot of questions. But visit the homepage for this plugin and leav
98
99
= 1.0 =
100
* First version
101
== Screenshots ==
102
1. The default page that is displayed (this can be overridden)
103
2. The editing screen with the default page selected
3
Donate link: http://masseltech.com/donate/
4
Tags: construction, under construction, private, preview, security, coming soon
5
Requires at least: 2.7
6
+ Tested up to: 3.2.1
7
+ Stable tag: 1.06
8
9
Creates a 'Coming Soon' page that will show for all users who are not logged in
10
12
13
Creates a 'Coming Soon' page that will show for all users who are not logged in. Useful for developing a site on a live server, without the world being able to see it
14
15
== Installation ==
16
17
1. Upload the folder to the `/wp-content/plugins/` directory
21
== Frequently Asked Questions ==
22
23
= I'm finished with it, and disabled the plugin, but the "under construction" message is still showing up! =
24
+ If you've disabled the plugin, it won't show anything anymore. To be extra super-sure, try deleting the plugin files. Usually, though, the issue is that you're seeing a cached version of the page. Try force-refreshing your browser, and then try clearing your cache on the server and force refreshing again. If you have a caching plugin like W3 Total Cache, make sure you clear that too!
25
26
= I can't see the under construction page! =
27
As long as you're logged in, you won't be able to see it. That's a feature! This way, while you're logged in you can work as usual. To preview what it looks like, either a) log out, or b) try viewing it in another browser
43
44
== Changelog ==
45
46
+ = 1.06 =
47
+ * Added the ability to allow certain IP addresses to see the site
48
+ * Added the ability to have a 301 redirect instead of having the "Coming Soon" page
49
+ * Added the ability to restrict what level of user can log into the site (Thanks Gerry for the feature request!)
50
+
51
= 1.05 =
52
* Fixed an issue where single quotes were being escaped on custom HTML pages. They will now be unquoted when printed to the screen
53
98
99
= 1.0 =
100
* First version
101
+
102
== Screenshots ==
103
1. The default page that is displayed (this can be overridden)
104
2. The editing screen with the default page selected
ucOptions.php CHANGED
@@ -1,16 +1,15 @@
1
- <?php
2
if (isset($_GET['turnOnUnderConstructionMode']))
3
{
4
- update_option('underConstructionActivationStatus', 1);
5
-
6
}
7
8
if (isset($_GET['turnOffUnderConstructionMode']))
9
{
10
- update_option('underConstructionActivationStatus', 0);
11
-
12
- }
13
14
15
// ======================================
16
// process display options
@@ -18,43 +17,43 @@ if (isset($_GET['turnOffUnderConstructionMode']))
18
19
if (isset($_POST['display_options']))
20
{
21
- if ($_POST['display_options'] == 0) //they want to just use the default
22
- {
23
- update_option('underConstructionDisplayOption', 0);
24
- }
25
-
26
- if ($_POST['display_options'] == 1) //they want to use the default with custom text
27
- {
28
- $values = array('pageTitle'=>'', 'headerText'=>'', 'bodyText'=>'');
29
-
30
- if (isset($_POST['pageTitle']))
31
- {
32
- $values['pageTitle'] = attribute_escape($_POST['pageTitle']);
33
- }
34
-
35
- if (isset($_POST['headerText']))
36
- {
37
- $values['headerText'] = attribute_escape($_POST['headerText']);
38
- }
39
-
40
- if (isset($_POST['bodyText']))
41
- {
42
- $values['bodyText'] = attribute_escape($_POST['bodyText']);
43
- }
44
-
45
-
46
- update_option('underConstructionCustomText', $values);
47
- update_option('underConstructionDisplayOption', 1);
48
- }
49
-
50
- if ($_POST['display_options'] == 2) //they want to use their own HTML
51
- {
52
- if (isset($_POST['ucHTML']))
53
- {
54
- update_option('underConstructionHTML', attribute_escape($_POST['ucHTML']));
55
- update_option('underConstructionDisplayOption', 2);
56
- }
57
- }
58
}
59
60
// ======================================
@@ -62,15 +61,15 @@ if (isset($_POST['display_options']))
62
// ======================================
63
if (isset($_POST['activate']))
64
{
65
- if ($_POST['activate'] == 0)
66
- {
67
- update_option('underConstructionActivationStatus', 0);
68
- }
69
-
70
- if ($_POST['activate'] == 1)
71
- {
72
- update_option('underConstructionActivationStatus', 1);
73
- }
74
}
75
76
// ======================================
@@ -78,15 +77,63 @@ if (isset($_POST['activate']))
78
// ======================================
79
if (isset($_POST['http_status']))
80
{
81
- if ($_POST['http_status'] == 200)
82
- {
83
- update_option('underConstructionHTTPStatus', 200);
84
- }
85
-
86
- if ($_POST['http_status'] == 503)
87
- {
88
- update_option('underConstructionHTTPStatus', 503);
89
- }
90
}
91
92
@@ -94,174 +141,204 @@ if (isset($_POST['http_status']))
94
95
?>
96
<noscript>
97
- <div class='updated' id='javascriptWarn'>
98
- <p>
99
- JavaScript appears to be disabled in your browser. For this plugin to work correctly, please enable JavaScript or switch to a more modern browser
100
- </p>
101
- </div>
102
</noscript>
103
<div class="wrap">
104
- <div id="icon-options-general" class="icon32">
105
- <br/>
106
- </div>
107
- <form method="post" action="<?php echo $GLOBALS['PHP_SELF'] . '?page=' . $this->mainOptionsPage; ?>">
108
- <h2>
109
- Under Construction
110
- </h2>
111
- <table>
112
- <tr>
113
- <td>
114
- <h3>
115
- Activate or Deactivate
116
- </h3>
117
- </td>
118
- </tr>
119
- <tr>
120
- <td>
121
- <fieldset>
122
- <legend class="screen-reader-text">
123
- <span>
124
- Activate or Deactivate
125
- </span>
126
- </legend>
127
- <label title="activate">
128
- <input type="radio" name="activate" value="1"<?php if ($this->pluginIsActive()) { echo ' checked="checked"'; } ?>>
129
- on
130
- </label>
131
- <br/>
132
- <label title="deactivate">
133
- <input type="radio" name="activate" value="0"<?php if (!$this->pluginIsActive()) { echo ' checked="checked"'; } ?>>
134
- off
135
- </label>
136
- </fieldset>
137
- </td>
138
- </tr>
139
- <tr>
140
- <td>
141
- <h3>
142
- HTTP Status Code
143
- </h3>
144
- <p>
145
- You can choose to send the standard HTTP status code with the under construction page, or send a 503 "Service Unavailable" status code. This will tell Google that
146
- this page isn't ready yet, and cause your site not to be listed until this plugin is disabled
147
- </p>
148
- </td>
149
- </tr>
150
- <tr>
151
- <td>
152
- <fieldset>
153
- <legend class="screen-reader-text">
154
- <span>
155
- HTTP Status Code
156
- </span>
157
- </legend>
158
- <label title="HTTP200">
159
- <input type="radio" name="http_status" value="200"<?php if ($this->httpStatusCodeIs(200)) { echo ' checked="checked"'; } ?>>
160
- HTTP
161
- 200
162
- -
163
-
164
- ok
165
- </label>
166
- <br/>
167
- <label title="HTTP503">
168
- <input type="radio" name="http_status" value="503"<?php if ($this->httpStatusCodeIs(503)) { echo ' checked="checked"'; } ?>>
169
- HTTP
170
- 503
171
- -
172
-
173
- Service Unavailable
174
- </label>
175
- </fieldset>
176
- </td>
177
- </tr>
178
- <tr>
179
- <td>
180
- <h3>
181
- Display Options
182
- </h3>
183
- </td>
184
- </tr>
185
- <tr>
186
- <td>
187
- <fieldset>
188
- <legend class="screen-reader-text">
189
- <span>
190
- Display Options
191
- </span>
192
- </legend>
193
- <label title="defaultPage">
194
- <input type="radio" name="display_options" value="0" id="displayOption0"<?php if ($this->displayStatusCodeIs(0)) { echo ' checked="checked"'; } ?>>
195
- Display the default under construction page
196
- </label>
197
- <br/>
198
- <label title="HTTP503">
199
- <input type="radio" name="display_options" value="1" id="displayOption1"<?php if ($this->displayStatusCodeIs(1)) { echo ' checked="checked"'; } ?>>
200
- Display the default under construction page
201
- ,
202
-
203
- but use custom text
204
- </label>
205
- <br/>
206
- <label title="HTTP503">
207
- <input type="radio" name="display_options" value="2" id="displayOption2"<?php if ($this->displayStatusCodeIs(2)) { echo ' checked="checked"'; } ?>>
208
- Display a custom page using your own HTML
209
- </label>
210
- </fieldset>
211
- </td>
212
- </tr>
213
- </table>
214
- <div id="customText"<?php if (!$this->displayStatusCodeIs(1)) { echo ' style="display: none;"'; } ?>>
215
- <h3>
216
- Display Custom Text
217
- </h3>
218
- <p>
219
- The text here will replace the text on the default page
220
- </p>
221
- <table>
222
- <tr valign="top">
223
- <th scope="row">
224
- <label for="pageTitle">
225
- Page Title
226
- </label>
227
- </th>
228
- <td>
229
- <input name="pageTitle" type="text" id="pageTitle" value="<?php echo $this->getCustomPageTitle(); ?>" class="regular-text" size="50">
230
- </td>
231
- </tr>
232
- <tr valign="top">
233
- <th scope="row">
234
- <label for="headerText">
235
- Header Text
236
- </label>
237
- </th>
238
- <td>
239
- <input name="headerText" type="text" id="headerText" value="<?php echo $this->getCustomHeaderText(); ?>" class="regular-text" size="50">
240
- </td>
241
- </tr>
242
- <tr valign="top">
243
- <th scope="row">
244
- <label for="bodyText">
245
- Body Text
246
- </label>
247
- </th>
248
- <td>
249
- <?php echo '<textarea rows="2" cols="44" name="bodyText" id="bodyText" class="regular-text">'.trim($this->getCustomBodyText()).'</textarea>'; ?>
250
- </td>
251
- </tr>
252
- </table>
253
- </div>
254
- <div id="customHTML"<?php if (!$this->displayStatusCodeIs(2)) { echo ' style="display: none;"'; } ?>>
255
- <h3>
256
- Under Construction Page HTML
257
- </h3>
258
- <p>
259
- Put in this area the HTML you want to show up on your front page
260
- </p>
261
- <?php echo '<textarea name="ucHTML" rows="15" cols="75">'.$this->getCustomHTML().'</textarea>'; ?>
262
- </div>
263
- <p class="submit">
264
- <input type="submit" name="Submit" class="button-primary" value="Save Changes" id="submitChangesToUnderConstructionPlugin" />
265
- </p>
266
- </form>
267
</div>
1
+ <?php
2
if (isset($_GET['turnOnUnderConstructionMode']))
3
{
4
+ update_option('underConstructionActivationStatus', 1);
5
+
6
}
7
8
if (isset($_GET['turnOffUnderConstructionMode']))
9
{
10
+ update_option('underConstructionActivationStatus', 0);
11
12
+ }
13
14
// ======================================
15
// process display options
17
18
if (isset($_POST['display_options']))
19
{
20
+ if ($_POST['display_options'] == 0) //they want to just use the default
21
+ {
22
+ update_option('underConstructionDisplayOption', 0);
23
+ }
24
+
25
+ if ($_POST['display_options'] == 1) //they want to use the default with custom text
26
+ {
27
+ $values = array('pageTitle'=>'', 'headerText'=>'', 'bodyText'=>'');
28
+
29
+ if (isset($_POST['pageTitle']))
30
+ {
31
+ $values['pageTitle'] = esc_attr($_POST['pageTitle']);
32
+ }
33
+
34
+ if (isset($_POST['headerText']))
35
+ {
36
+ $values['headerText'] = esc_attr($_POST['headerText']);
37
+ }
38
+
39
+ if (isset($_POST['bodyText']))
40
+ {
41
+ $values['bodyText'] = esc_attr($_POST['bodyText']);
42
+ }
43
+
44
+
45
+ update_option('underConstructionCustomText', $values);
46
+ update_option('underConstructionDisplayOption', 1);
47
+ }
48
+
49
+ if ($_POST['display_options'] == 2) //they want to use their own HTML
50
+ {
51
+ if (isset($_POST['ucHTML']))
52
+ {
53
+ update_option('underConstructionHTML', esc_attr($_POST['ucHTML']));
54
+ update_option('underConstructionDisplayOption', 2);
55
+ }
56
+ }
57
}
58
59
// ======================================
61
// ======================================
62
if (isset($_POST['activate']))
63
{
64
+ if ($_POST['activate'] == 0)
65
+ {
66
+ update_option('underConstructionActivationStatus', 0);
67
+ }
68
+
69
+ if ($_POST['activate'] == 1)
70
+ {
71
+ update_option('underConstructionActivationStatus', 1);
72
+ }
73
}
74
75
// ======================================
77
// ======================================
78
if (isset($_POST['http_status']))
79
{
80
+ if ($_POST['http_status'] == 200)
81
+ {
82
+ update_option('underConstructionHTTPStatus', 200);
83
+ }
84
+
85
+ if ($_POST['http_status'] == 301)
86
+ {
87
+ update_option('underConstructionHTTPStatus', 301);
88
+ update_option('underConstructionRedirectURL', $_POST['url']);
89
+ }
90
+
91
+ if ($_POST['http_status'] == 503)
92
+ {
93
+ update_option('underConstructionHTTPStatus', 503);
94
+ }
95
+ }
96
+
97
+ // ======================================
98
+ // process IP addresses
99
+ // ======================================
100
+
101
+ if(isset($_POST['ip_address'])){
102
+
103
+ $ip = $_POST['ip_address'];
104
+ $ip = long2ip(ip2long($ip));
105
+
106
+ if($ip != "0.0.0.0"){
107
+ $array = get_option('underConstructionIPWhitelist');
108
+
109
+ if(!$array){
110
+ $array = array();
111
+ }
112
+
113
+ $array[] = $ip;
114
+
115
+ $array = array_unique($array);
116
+
117
+ update_option('underConstructionIPWhitelist', $array);
118
+ }
119
+ }
120
+
121
+ if(isset($_POST['remove_selected_ip_btn'])){
122
+ if(isset($_POST['ip_whitelist'])){
123
+ $array = get_option('underConstructionIPWhitelist');
124
+
125
+ if(!$array){
126
+ $array = array();
127
+ }
128
+
129
+ unset($array[$_POST['ip_whitelist']]);
130
+ $array = array_values($array);
131
+ update_option('underConstructionIPWhitelist', $array);
132
+ }
133
+ }
134
+
135
+ if(isset($_POST['required_role'])){
136
+ update_option('underConstructionRequiredRole', $_POST['required_role']);
137
}
138
139
141
142
?>
143
<noscript>
144
+ <div class='updated' id='javascriptWarn'>
145
+ <p>JavaScript appears to be disabled in your browser. For this plugin
146
+ to work correctly, please enable JavaScript or switch to a more
147
+ modern browser</p>
148
+ </div>
149
</noscript>
150
<div class="wrap">
151
+ <div id="icon-options-general" class="icon32">
152
+ <br />
153
+ </div>
154
+ <form method="post"
155
+ action="<?php echo $GLOBALS['PHP_SELF'] . '?page=' . $this->mainOptionsPage; ?>"
156
+ id="ucoptions">
157
+ <h2>Under Construction</h2>
158
+ <table>
159
+ <tr>
160
+ <td>
161
+ <h3>Activate or Deactivate</h3>
162
+ </td>
163
+ </tr>
164
+ <tr>
165
+ <td>
166
+ <fieldset>
167
+ <legend class="screen-reader-text">
168
+ <span> Activate or Deactivate </span>
169
+ </legend>
170
+ <label title="activate"> <input type="radio" name="activate"
171
+ value="1"
172
+ <?php if ($this->pluginIsActive()) { echo ' checked="checked"'; } ?>>
173
+ on </label> <br /> <label title="deactivate"> <input type="radio"
174
+ name="activate" value="0"
175
+ <?php if (!$this->pluginIsActive()) { echo ' checked="checked"'; } ?>>
176
+ off </label>
177
+ </fieldset>
178
+ </td>
179
+ </tr>
180
+ <tr>
181
+ <td>
182
+ <h3>HTTP Status Code</h3>
183
+ <p>You can choose to send the standard HTTP status code with the
184
+ under construction page, or send a 503 "Service Unavailable"
185
+ status code. This will tell Google that this page isn't ready yet,
186
+ and cause your site not to be listed until this plugin is disabled
187
+ </p>
188
+ </td>
189
+ </tr>
190
+ <tr>
191
+ <td>
192
+ <fieldset>
193
+ <legend class="screen-reader-text">
194
+ <span> HTTP Status Code </span>
195
+ </legend>
196
+ <label title="HTTP200"> <input type="radio" name="http_status"
197
+ value="200" id="200_status"
198
+ <?php if ($this->httpStatusCodeIs(200)) { echo ' checked="checked"'; } ?>>
199
+ HTTP 200 - ok </label> <br /> <label title="HTTP301"> <input
200
+ type="radio" name="http_status" value="301" id="301_status"
201
+ <?php if ($this->httpStatusCodeIs(301)) { echo ' checked="checked"'; } ?>>
202
+ HTTP 301 - Redirect </label> <br /> <label title="HTTP503"> <input
203
+ type="radio" name="http_status" value="503" id="503_status"
204
+ <?php if ($this->httpStatusCodeIs(503)) { echo ' checked="checked"'; } ?>>
205
+ HTTP 503 - Service Unavailable </label>
206
+ </fieldset>
207
+
208
+ <div id="redirect_panel" <?php if(!$this->httpStatusCodeIs(301)):?>
209
+ class="hidden" <?php endif;?>>
210
+ <br /> <label for="url">Redirect Location: </label><input
211
+ type="text" name="url" id="url"
212
+ value="<?php echo get_option('underConstructionRedirectURL');?>" />
213
+ </div>
214
+ </td>
215
+ </tr>
216
+
217
+ <tr>
218
+ <td>
219
+ <h3>Restrict By Role</h3>
220
+ </td>
221
+ </tr>
222
+ <tr>
223
+ <td>Only users at or above this level will be able to log in: <select id="required_role" name="required_role">
224
+ <option value="0">All Users</option>
225
+ <?php
226
+ $selected = get_option('underConstructionRequiredRole');
227
+ $editable_roles = get_editable_roles();
228
+
229
+ foreach ( $editable_roles as $role => $details ) {
230
+ $name = translate_user_role($details['name'] );
231
+ if ( $selected == $role ) // preselect specified role
232
+ $p = "\n\t<option selected='selected' value='" . esc_attr($role) . "'>$name</option>";
233
+ else
234
+ $r .= "\n\t<option value='" . esc_attr($role) . "'>$name</option>";
235
+ }
236
+ echo $p . $r;
237
+ ?>
238
+ </select>
239
+ </td>
240
+
241
+
242
+ <tr>
243
+
244
+
245
+ <tr>
246
+ <td>
247
+ <h3>IP Address Whitelist</h3>
248
+ </td>
249
+ </tr>
250
+ <tr>
251
+ <td><?php
252
+ $whitelist = get_option('underConstructionIPWhitelist');
253
+
254
+ if(count($whitelist)):
255
+
256
+ ?> <select size="4" id="ip_whitelist" name="ip_whitelist"
257
+ style="width: 250px; height: 100px;">
258
+ <?php for($i = 0; $i < count($whitelist); $i++):?>
259
+ <option id="<?php echo $i; ?>" value="<?php echo $i;?>">
260
+ <?php echo $whitelist[$i];?>
261
+ </option>
262
+ <?php endfor;?>
263
+
264
+ </select><br /> <input type="submit"
265
+ value="Remove Selected IP Address" name="remove_selected_ip_btn"
266
+ id="remove_selected_ip_btn" /> <br /> <br /> <?php endif; ?> <label>IP
267
+ Address: <input type="text" name="ip_address" id="ip_address" /> </label>
268
+ <a id="add_current_address_btn" style="cursor: pointer;">Add
269
+ Current Address</a><img id="loading_current_address"
270
+ class="hidden"
271
+ src="<?php echo plugins_url( 'ajax-loader.gif' , __FILE__ ); ?>" />
272
+
273
+ <br />
274
+ </td>
275
+ </tr>
276
+
277
+ <tr>
278
+ <td>
279
+ <h3>Display Options</h3>
280
+ </td>
281
+ </tr>
282
+ <tr>
283
+ <td>
284
+ <fieldset>
285
+ <legend class="screen-reader-text">
286
+ <span> Display Options </span>
287
+ </legend>
288
+ <label title="defaultPage"> <input type="radio"
289
+ name="display_options" value="0" id="displayOption0"
290
+ <?php if ($this->displayStatusCodeIs(0)) { echo ' checked="checked"'; } ?>>
291
+ Display the default under construction page </label> <br /> <label
292
+ title="HTTP503"> <input type="radio" name="display_options"
293
+ value="1" id="displayOption1"
294
+ <?php if ($this->displayStatusCodeIs(1)) { echo ' checked="checked"'; } ?>>
295
+ Display the default under construction page , but use custom text
296
+ </label> <br /> <label title="HTTP503"> <input type="radio"
297
+ name="display_options" value="2" id="displayOption2"
298
+ <?php if ($this->displayStatusCodeIs(2)) { echo ' checked="checked"'; } ?>>
299
+ Display a custom page using your own HTML </label>
300
+ </fieldset>
301
+ </td>
302
+ </tr>
303
+ </table>
304
+ <div id="customText"
305
+ <?php if (!$this->displayStatusCodeIs(1)) { echo ' style="display: none;"'; } ?>>
306
+ <h3>Display Custom Text</h3>
307
+ <p>The text here will replace the text on the default page</p>
308
+ <table>
309
+ <tr valign="top">
310
+ <th scope="row"><label for="pageTitle"> Page Title </label>
311
+ </th>
312
+ <td><input name="pageTitle" type="text" id="pageTitle"
313
+ value="<?php echo $this->getCustomPageTitle(); ?>"
314
+ class="regular-text" size="50">
315
+ </td>
316
+ </tr>
317
+ <tr valign="top">
318
+ <th scope="row"><label for="headerText"> Header Text </label>
319
+ </th>
320
+ <td><input name="headerText" type="text" id="headerText"
321
+ value="<?php echo $this->getCustomHeaderText(); ?>"
322
+ class="regular-text" size="50">
323
+ </td>
324
+ </tr>
325
+ <tr valign="top">
326
+ <th scope="row"><label for="bodyText"> Body Text </label>
327
+ </th>
328
+ <td><?php echo '<textarea rows="2" cols="44" name="bodyText" id="bodyText" class="regular-text">'.trim($this->getCustomBodyText()).'</textarea>'; ?>
329
+ </td>
330
+ </tr>
331
+ </table>
332
+ </div>
333
+ <div id="customHTML"
334
+ <?php if (!$this->displayStatusCodeIs(2)) { echo ' style="display: none;"'; } ?>>
335
+ <h3>Under Construction Page HTML</h3>
336
+ <p>Put in this area the HTML you want to show up on your front page</p>
337
+ <?php echo '<textarea name="ucHTML" rows="15" cols="75">'.$this->getCustomHTML().'</textarea>'; ?>
338
+ </div>
339
+ <p class="submit">
340
+ <input type="submit" name="Submit" class="button-primary"
341
+ value="Save Changes" id="submitChangesToUnderConstructionPlugin" />
342
+ </p>
343
+ </form>
344
</div>
underConstruction.php CHANGED
@@ -1,9 +1,9 @@
1
- <?php
2
/*
3
Plugin Name: Under Construction
4
Plugin URI: http://www.masseltech.com/
5
Description: Makes it so your site can only be accessed by users who log in. Useful for developing a site on a live server, without the world being able to see it
6
- Version: 1.04
7
Author: Jeremy Massel
8
Author URI: http://www.masseltech.com/
9
*/
@@ -23,236 +23,271 @@
23
*/
24
25
?>
26
- <?php
27
class underConstruction
28
{
29
- var $installedFolder = "";
30
- var $mainOptionsPage = "underConstructionMainOptions";
31
-
32
- function __construct()
33
- {
34
- $this->installedFolder = basename(dirname(__FILE__));
35
- }
36
-
37
- function underConstruction()
38
- {
39
- $this->__construct();
40
- }
41
-
42
- function getMainOptionsPage()
43
- {
44
- return $this->mainOptionsPage;
45
- }
46
-
47
- function underConstructionAdminInit()
48
- {
49
- /* Register our script. */
50
- wp_register_script('underConstructionJS', WP_PLUGIN_URL.'/'.$this->installedFolder.'/underconstruction.min.js');
51
- }
52
-
53
- function uc_changeMessage()
54
- {
55
- require_once ('ucOptions.php');
56
- }
57
-
58
- function uc_adminMenu()
59
- {
60
- /* Register our plugin page */
61
- $page = add_options_page('Under Construction Settings', 'Under Construction', 8, $this->mainOptionsPage, array($this, 'uc_changeMessage'));
62
-
63
- /* Using registered $page handle to hook script load */
64
- add_action('admin_print_scripts-'.$page, array($this, 'underConstructionEnqueueScripts'));
65
-
66
- }
67
-
68
- function underConstructionEnqueueScripts()
69
- {
70
- /*
71
- * It will be called only on your plugin admin page, enqueue our script here
72
- */
73
- wp_enqueue_script('scriptaculous');
74
- wp_enqueue_script('underConstructionJS');
75
- }
76
-
77
- function uc_overrideWP()
78
- {
79
- if ($this->pluginIsActive())
80
- {
81
- if (!is_user_logged_in())
82
- {
83
- //send a 503 if the setting requires it
84
- if (get_option('underConstructionHTTPStatus') == 503)
85
- {
86
- header('HTTP/1.1 503 Service Unavailable');
87
- }
88
-
89
- if ($this->displayStatusCodeIs(0)) //they want the default!
90
- {
91
- require_once ('defaultMessage.php');
92
- displayDefaultComingSoonPage();
93
- die();
94
- }
95
-
96
- if ($this->displayStatusCodeIs(1)) //they want the default with custom text!
97
- {
98
- require_once ('defaultMessage.php');
99
- displayComingSoonPage($this->getCustomPageTitle(), $this->getCustomHeaderText(), $this->getCustomBodyText());
100
- die();
101
- }
102
-
103
- if ($this->displayStatusCodeIs(2)) //they want custom HTML!
104
- {
105
- echo html_entity_decode($this->getCustomHTML(), ENT_QUOTES);
106
- die();
107
- }
108
- }
109
- }
110
- }
111
-
112
- function getCustomHTML()
113
- {
114
- return stripslashes(get_option('underConstructionHTML'));
115
- }
116
-
117
-
118
- function uc_activate()
119
- {
120
- if (get_option('underConstructionArchive'))
121
- {
122
- //get all the options back from the archive
123
- $options = get_option('underConstructionArchive');
124
-
125
- //put them back where they belong
126
- update_option('underConstructionHTML', $options['underConstructionHTML']);
127
- update_option('underConstructionActivationStatus', $options['underConstructionActivationStatus']);
128
- update_option('underConstructionCustomText', $options['underConstructionCustomText']);
129
- update_option('underConstructionDisplayOption', $options['underConstructionDisplayOption']);
130
- update_option('underConstructionHTTPStatus', $options['underConstructionHTTPStatus']);
131
-
132
- delete_option('underConstructionArchive');
133
- }
134
- }
135
-
136
- function uc_deactivate()
137
- {
138
- //get all the options. store them in an array
139
- $options = array();
140
- $options['underConstructionHTML'] = get_option('underConstructionHTML');
141
- $options['underConstructionActivationStatus'] = get_option('underConstructionActivationStatus');
142
- $options['underConstructionCustomText'] = get_option('underConstructionCustomText');
143
- $options['underConstructionDisplayOption'] = get_option('underConstructionDisplayOption');
144
- $options['underConstructionHTTPStatus'] = get_option('underConstructionHTTPStatus');
145
-
146
- //store the options all in one record, in case we ever reactivate the plugin
147
- update_option('underConstructionArchive', $options);
148
-
149
- //delete the separate ones
150
- delete_option('underConstructionHTML');
151
- delete_option('underConstructionActivationStatus');
152
- delete_option('underConstructionCustomText');
153
- delete_option('underConstructionDisplayOption');
154
- delete_option('underConstructionHTTPStatus');
155
- }
156
-
157
- function pluginIsActive()
158
- {
159
-
160
- if (!get_option('underConstructionActivationStatus')) //if it's not set yet
161
- {
162
- return false;
163
- }
164
-
165
- if (get_option('underConstructionActivationStatus') == 1)
166
- {
167
- return true;
168
- }
169
- else
170
- {
171
- return false;
172
- }
173
- }
174
-
175
- function httpStatusCodeIs($status)
176
- {
177
- if (!get_option('underConstructionHTTPStatus')) //if it's not set yet
178
- {
179
- update_option('underConstructionHTTPStatus', 200); //set it
180
- }
181
-
182
- if (get_option('underConstructionHTTPStatus') == $status)
183
- {
184
- return true;
185
- }
186
- else
187
- {
188
- return false;
189
- }
190
-
191
- }
192
-
193
- function displayStatusCodeIs($status)
194
- {
195
- if (!get_option('underConstructionDisplayOption')) //if it's not set yet
196
- {
197
- update_option('underConstructionDisplayOption', 0); //set it
198
- }
199
-
200
- if (get_option('underConstructionDisplayOption') == $status)
201
- {
202
- return true;
203
- }
204
- else
205
- {
206
- return false;
207
- }
208
- }
209
-
210
- function getCustomPageTitle()
211
- {
212
- if (get_option('underConstructionCustomText') != false)
213
- {
214
- $fields = get_option('underConstructionCustomText');
215
- return stripslashes($fields['pageTitle']);
216
- }
217
- else
218
- {
219
- return '';
220
- }
221
- }
222
-
223
- function getCustomHeaderText()
224
- {
225
- if (get_option('underConstructionCustomText') != false)
226
- {
227
- $fields = get_option('underConstructionCustomText');
228
- return stripslashes($fields['headerText']);
229
- }
230
- else
231
- {
232
- return '';
233
- }
234
- }
235
-
236
- function getCustomBodyText()
237
- {
238
- if (get_option('underConstructionCustomText') != false)
239
- {
240
- $fields = get_option('underConstructionCustomText');
241
- return stripslashes($fields['bodyText']);
242
- }
243
- else
244
- {
245
- return '';
246
- }
247
- }
248
-
249
-
250
}
251
252
$underConstructionPlugin = new underConstruction();
253
254
add_action('template_redirect', array($underConstructionPlugin, 'uc_overrideWP'));
255
-
256
257
register_activation_hook(__FILE__, array($underConstructionPlugin, 'uc_activate'));
258
register_deactivation_hook(__FILE__, array($underConstructionPlugin, 'uc_deactivate'));
@@ -264,24 +299,34 @@ add_action('admin_menu', array($underConstructionPlugin, 'uc_adminMenu'));
264
265
function underConstructionPlugin_delete()
266
{
267
- delete_option('underConstructionArchive');
268
}
269
270
271
function underConstructionPluginLinks($links, $file)
272
{
273
- global $underConstructionPlugin;
274
- if ($file == basename(dirname(__FILE__)).'/'.basename(__FILE__) && function_exists("admin_url"))
275
- {
276
- //add settings page
277
- $manage_link = '<a href="'.admin_url('options-general.php?page='.$underConstructionPlugin->getMainOptionsPage()).'">'.__('Settings').'</a>';
278
- array_unshift($links, $manage_link);
279
-
280
-
281
- }
282
- return $links;
283
}
284
285
add_filter('plugin_action_links', 'underConstructionPluginLinks', 10, 2);
286
287
?>
1
+ <?php
2
/*
3
Plugin Name: Under Construction
4
Plugin URI: http://www.masseltech.com/
5
Description: Makes it so your site can only be accessed by users who log in. Useful for developing a site on a live server, without the world being able to see it
6
+ Version: 1.06
7
Author: Jeremy Massel
8
Author URI: http://www.masseltech.com/
9
*/
23
*/
24
25
?>
26
+ <?php
27
class underConstruction
28
{
29
+ var $installedFolder = "";
30
+ var $mainOptionsPage = "underConstructionMainOptions";
31
+
32
+ function __construct()
33
+ {
34
+ $this->installedFolder = basename(dirname(__FILE__));
35
+ }
36
+
37
+ function underConstruction()
38
+ {
39
+ $this->__construct();
40
+ }
41
+
42
+ function getMainOptionsPage()
43
+ {
44
+ return $this->mainOptionsPage;
45
+ }
46
+
47
+ function underConstructionAdminInit()
48
+ {
49
+ /* Register our script. */
50
+ wp_register_script('underConstructionJS', WP_PLUGIN_URL.'/'.$this->installedFolder.'/underconstruction.min.js');
51
+ }
52
+
53
+ function uc_changeMessage()
54
+ {
55
+ require_once ('ucOptions.php');
56
+ }
57
+
58
+ function uc_adminMenu()
59
+ {
60
+ /* Register our plugin page */
61
+ $page = add_options_page('Under Construction Settings', 'Under Construction', 8, $this->mainOptionsPage, array($this, 'uc_changeMessage'));
62
+
63
+ /* Using registered $page handle to hook script load */
64
+ add_action('admin_print_scripts-'.$page, array($this, 'underConstructionEnqueueScripts'));
65
+
66
+ }
67
+
68
+ function underConstructionEnqueueScripts()
69
+ {
70
+ /*
71
+ * It will be called only on your plugin admin page, enqueue our script here
72
+ */
73
+ wp_enqueue_script('scriptaculous');
74
+ wp_enqueue_script('underConstructionJS');
75
+ }
76
+
77
+ function uc_overrideWP()
78
+ {
79
+ if ($this->pluginIsActive())
80
+ {
81
+ if (!is_user_logged_in())
82
+ {
83
+ $array = get_option('underConstructionIPWhitelist');
84
+
85
+ if(!in_array($_SERVER['REMOTE_ADDR'], $array)){
86
+
87
+ //send a 503 if the setting requires it
88
+ if (get_option('underConstructionHTTPStatus') == 503)
89
+ {
90
+ header('HTTP/1.1 503 Service Unavailable');
91
+ }
92
+
93
+ //send a 503 if the setting requires it
94
+ if (get_option('underConstructionHTTPStatus') == 301)
95
+ {
96
+ header( "HTTP/1.1 301 Moved Permanently" );
97
+ header( "Location: " . get_option('underConstructionRedirectURL') );
98
+ }
99
+
100
+ if ($this->displayStatusCodeIs(0)) //they want the default!
101
+ {
102
+ require_once ('defaultMessage.php');
103
+ displayDefaultComingSoonPage();
104
+ die();
105
+ }
106
+
107
+ if ($this->displayStatusCodeIs(1)) //they want the default with custom text!
108
+ {
109
+ require_once ('defaultMessage.php');
110
+ displayComingSoonPage($this->getCustomPageTitle(), $this->getCustomHeaderText(), $this->getCustomBodyText());
111
+ die();
112
+ }
113
+
114
+ if ($this->displayStatusCodeIs(2)) //they want custom HTML!
115
+ {
116
+ echo html_entity_decode($this->getCustomHTML(), ENT_QUOTES);
117
+ die();
118
+ }
119
+ }
120
+ }
121
+ }
122
+ }
123
+
124
+ function uc_admin_override_WP(){
125
+
126
+ if(get_option('underConstructionRequiredRole')){
127
+ $editable_roles = get_editable_roles();
128
+
129
+ $required_role = $editable_roles[get_option('underConstructionRequiredRole')];
130
+
131
+ $new_privs = array();
132
+
133
+
134
+ foreach($required_role['capabilities'] as $key => $value){
135
+ if($value == true){
136
+ $new_privs[] = $key;
137
+ }
138
+ }
139
+
140
+ if(!current_user_can($new_privs[0])){
141
+ wp_logout();
142
+ wp_redirect(get_bloginfo('url'));
143
+ }
144
+ }
145
+ }
146
+
147
+ function getCustomHTML()
148
+ {
149
+ return stripslashes(get_option('underConstructionHTML'));
150
+ }
151
+
152
+
153
+ function uc_activate()
154
+ {
155
+ if (get_option('underConstructionArchive'))
156
+ {
157
+ //get all the options back from the archive
158
+ $options = get_option('underConstructionArchive');
159
+
160
+ //put them back where they belong
161
+ update_option('underConstructionHTML', $options['underConstructionHTML']);
162
+ update_option('underConstructionActivationStatus', $options['underConstructionActivationStatus']);
163
+ update_option('underConstructionCustomText', $options['underConstructionCustomText']);
164
+ update_option('underConstructionDisplayOption', $options['underConstructionDisplayOption']);
165
+ update_option('underConstructionHTTPStatus', $options['underConstructionHTTPStatus']);
166
+
167
+ delete_option('underConstructionArchive');
168
+ }
169
+ }
170
+
171
+ function uc_deactivate()
172
+ {
173
+ //get all the options. store them in an array
174
+ $options = array();
175
+ $options['underConstructionHTML'] = get_option('underConstructionHTML');
176
+ $options['underConstructionActivationStatus'] = get_option('underConstructionActivationStatus');
177
+ $options['underConstructionCustomText'] = get_option('underConstructionCustomText');
178
+ $options['underConstructionDisplayOption'] = get_option('underConstructionDisplayOption');
179
+ $options['underConstructionHTTPStatus'] = get_option('underConstructionHTTPStatus');
180
+
181
+ //store the options all in one record, in case we ever reactivate the plugin
182
+ update_option('underConstructionArchive', $options);
183
+
184
+ //delete the separate ones
185
+ delete_option('underConstructionHTML');
186
+ delete_option('underConstructionActivationStatus');
187
+ delete_option('underConstructionCustomText');
188
+ delete_option('underConstructionDisplayOption');
189
+ delete_option('underConstructionHTTPStatus');
190
+ }
191
+
192
+ function pluginIsActive()
193
+ {
194
+
195
+ if (!get_option('underConstructionActivationStatus')) //if it's not set yet
196
+ {
197
+ return false;
198
+ }
199
+
200
+ if (get_option('underConstructionActivationStatus') == 1)
201
+ {
202
+ return true;
203
+ }
204
+ else
205
+ {
206
+ return false;
207
+ }
208
+ }
209
+
210
+ function httpStatusCodeIs($status)
211
+ {
212
+ if (!get_option('underConstructionHTTPStatus')) //if it's not set yet
213
+ {
214
+ update_option('underConstructionHTTPStatus', 200); //set it
215
+ }
216
+
217
+ if (get_option('underConstructionHTTPStatus') == $status)
218
+ {
219
+ return true;
220
+ }
221
+ else
222
+ {
223
+ return false;
224
+ }
225
+
226
+ }
227
+
228
+ function displayStatusCodeIs($status)
229
+ {
230
+ if (!get_option('underConstructionDisplayOption')) //if it's not set yet
231
+ {
232
+ update_option('underConstructionDisplayOption', 0); //set it
233
+ }
234
+
235
+ if (get_option('underConstructionDisplayOption') == $status)
236
+ {
237
+ return true;
238
+ }
239
+ else
240
+ {
241
+ return false;
242
+ }
243
+ }
244
+
245
+ function getCustomPageTitle()
246
+ {
247
+ if (get_option('underConstructionCustomText') != false)
248
+ {
249
+ $fields = get_option('underConstructionCustomText');
250
+ return stripslashes($fields['pageTitle']);
251
+ }
252
+ else
253
+ {
254
+ return '';
255
+ }
256
+ }
257
+
258
+ function getCustomHeaderText()
259
+ {
260
+ if (get_option('underConstructionCustomText') != false)
261
+ {
262
+ $fields = get_option('underConstructionCustomText');
263
+ return stripslashes($fields['headerText']);
264
+ }
265
+ else
266
+ {
267
+ return '';
268
+ }
269
+ }
270
+
271
+ function getCustomBodyText()
272
+ {
273
+ if (get_option('underConstructionCustomText') != false)
274
+ {
275
+ $fields = get_option('underConstructionCustomText');
276
+ return stripslashes($fields['bodyText']);
277
+ }
278
+ else
279
+ {
280
+ return '';
281
+ }
282
+ }
283
+
284
+
285
}
286
287
$underConstructionPlugin = new underConstruction();
288
289
add_action('template_redirect', array($underConstructionPlugin, 'uc_overrideWP'));
290
+ add_action('admin_init', array($underConstructionPlugin, 'uc_admin_override_WP'));
291
292
register_activation_hook(__FILE__, array($underConstructionPlugin, 'uc_activate'));
293
register_deactivation_hook(__FILE__, array($underConstructionPlugin, 'uc_deactivate'));
299
300
function underConstructionPlugin_delete()
301
{
302
+ delete_option('underConstructionArchive');
303
+ }
304
+
305
+ function uc_get_ip_address(){
306
+ echo $_SERVER['REMOTE_ADDR'];
307
+ die();
308
}
309
310
311
function underConstructionPluginLinks($links, $file)
312
{
313
+ global $underConstructionPlugin;
314
+ if ($file == basename(dirname(__FILE__)).'/'.basename(__FILE__) && function_exists("admin_url"))
315
+ {
316
+ //add settings page
317
+ $manage_link = '<a href="'.admin_url('options-general.php?page='.$underConstructionPlugin->getMainOptionsPage()).'">'.__('Settings').'</a>';
318
+ array_unshift($links, $manage_link);
319
+
320
+
321
+ }
322
+ return $links;
323
}
324
325
add_filter('plugin_action_links', 'underConstructionPluginLinks', 10, 2);
326
327
+
328
+ //ajax
329
+
330
+ add_action('wp_ajax_uc_get_ip_address', 'uc_get_ip_address');
331
+
332
?>
underconstruction.dev.js CHANGED
@@ -1,23 +1,47 @@
1
- document.observe("dom:loaded", function()
2
- {
3
- Event.observe('displayOption0', 'click', displayOption0Checked);
4
- Event.observe('displayOption1', 'click', displayOption1Checked);
5
- Event.observe('displayOption2', 'click', displayOption2Checked);
6
});
7
- function displayOption0Checked()
8
- {
9
- document.getElementById('customText').style.display = 'none';
10
- document.getElementById('customHTML').style.display = 'none';
11
}
12
13
- function displayOption1Checked()
14
- {
15
- document.getElementById('customText').style.display = 'block';
16
- document.getElementById('customHTML').style.display = 'none';
17
}
18
19
- function displayOption2Checked()
20
- {
21
- document.getElementById('customText').style.display = 'none';
22
- document.getElementById('customHTML').style.display = 'block';
23
}
1
+ document.observe("dom:loaded", function() {
2
+ Event.observe('displayOption0', 'click', displayOption0Checked);
3
+ Event.observe('displayOption1', 'click', displayOption1Checked);
4
+ Event.observe('displayOption2', 'click', displayOption2Checked);
5
});
6
+ function displayOption0Checked() {
7
+ document.getElementById('customText').style.display = 'none';
8
+ document.getElementById('customHTML').style.display = 'none';
9
}
10
11
+ function displayOption1Checked() {
12
+ document.getElementById('customText').style.display = 'block';
13
+ document.getElementById('customHTML').style.display = 'none';
14
}
15
16
+ function displayOption2Checked() {
17
+ document.getElementById('customText').style.display = 'none';
18
+ document.getElementById('customHTML').style.display = 'block';
19
}
20
+
21
+ jQuery(function($) {
22
+ $('#add_current_address_btn').click(function(e) {
23
+ e.preventDefault();
24
+ e.stopPropagation();
25
+
26
+ $(this).hide();
27
+ $('#loading_current_address').show();
28
+
29
+ $.get(ajaxurl, {
30
+ action : 'uc_get_ip_address'
31
+ }, function(response) {
32
+
33
+ $('#loading_current_address').hide();
34
+ $('#add_current_address_btn').show();
35
+ $('#ip_address').val(response);
36
+ });
37
+ });
38
+
39
+ $('#301_status').click(function(){
40
+ console.log("selected 301 redirect");
41
+ jQuery('#redirect_panel').show();
42
+ });
43
+
44
+ $('#200_status, #503_status').click(function(){
45
+ jQuery('#redirect_panel').hide();
46
+ });
47
+ });
underconstruction.min.js CHANGED
@@ -1 +1 @@
1
- document.observe("dom:loaded",function(){Event.observe("displayOption0","click",displayOption0Checked);Event.observe("displayOption1","click",displayOption1Checked);Event.observe("displayOption2","click",displayOption2Checked)});function displayOption0Checked(){document.getElementById("customText").style.display="none";document.getElementById("customHTML").style.display="none"}function displayOption1Checked(){document.getElementById("customText").style.display="block";document.getElementById("customHTML").style.display="none"}function displayOption2Checked(){document.getElementById("customText").style.display="none";document.getElementById("customHTML").style.display="block"};
1
+ function displayOption2Checked(){document.getElementById("customText").style.display="none";document.getElementById("customHTML").style.display="block"}function displayOption1Checked(){document.getElementById("customText").style.display="block";document.getElementById("customHTML").style.display="none"}function displayOption0Checked(){document.getElementById("customText").style.display="none";document.getElementById("customHTML").style.display="none"}document.observe("dom:loaded",function(){Event.observe("displayOption0","click",displayOption0Checked);Event.observe("displayOption1","click",displayOption1Checked);Event.observe("displayOption2","click",displayOption2Checked)});jQuery(function(a){a("#add_current_address_btn").click(function(b){b.preventDefault();b.stopPropagation();a(this).hide();a("#loading_current_address").show();a.get(ajaxurl,{action:"uc_get_ip_address"},function(b){a("#loading_current_address").hide();a("#add_current_address_btn").show();a("#ip_address").val(b)})});a("#301_status").click(function(){console.log("selected 301 redirect");jQuery("#redirect_panel").show()});a("#200_status, #503_status").click(function(){jQuery("#redirect_panel").hide()})})