Nginx Helper - Version 1.8.13

Version Description

Fixed PHP notice for an undefined index when "Enable Logging" is not set.

Download this release

Release Info

Developer rtcamp
Plugin Icon 128x128 Nginx Helper
Version 1.8.13
Comparing to
See all releases

Code changes from version 1.8.12 to 1.8.13

admin/lib/nginx-general.php CHANGED
@@ -2,372 +2,373 @@
2
 
3
  namespace rtCamp\WP\Nginx {
4
 
5
- function nginx_general_options_page() {
6
- global $rt_wp_nginx_helper, $rt_wp_nginx_purger;
7
 
8
- $update = 0;
9
- $error_time = false;
10
- $error_log_filesize = false;
11
- $rt_wp_nginx_helper->options['enable_purge'] = (isset($_POST['enable_purge']) and ($_POST['enable_purge'] == 1) ) ? 1 : 0;
12
- $rt_wp_nginx_helper->options['enable_map'] = (isset($_POST['enable_map']) and ($_POST['enable_map'] == 1) ) ? 1 : 0;
13
- $rt_wp_nginx_helper->options['enable_log'] = (isset($_POST['enable_log']) and ($_POST['enable_log'] == 1) ) ? 1 : 0;
14
- $rt_wp_nginx_helper->options['enable_stamp'] = (isset($_POST['enable_stamp']) and ($_POST['enable_stamp'] == 1) ) ? 1 : 0;
15
 
16
- if ( isset( $_POST['is_submit'] ) && ( $_POST['is_submit'] == 1 ) ) {
17
- if ( !( !is_network_admin() && is_multisite() ) ) {
18
- if ( $rt_wp_nginx_helper->options['enable_log'] ) {
19
- if ( isset( $_POST['log_level'] ) && !empty( $_POST['log_level'] ) && $_POST['log_level'] != '' ) {
20
- $rt_wp_nginx_helper->options['log_level'] = $_POST['log_level'];
21
- } else {
22
- $rt_wp_nginx_helper->options['log_level'] = 'INFO';
23
- }
24
- if ( isset( $_POST['log_filesize'] ) && !empty( $_POST['log_filesize'] ) && $_POST['log_filesize'] != '' ) {
25
- if ( ( !is_numeric( $_POST['log_filesize'] ) ) || ( empty( $_POST['log_filesize'] ) ) ) {
26
- $error_log_filesize = __( 'Log file size must be a number', 'nginx-helper' );
27
- } else {
28
- $rt_wp_nginx_helper->options['log_filesize'] = $_POST['log_filesize'];
29
- }
30
- } else {
31
- $rt_wp_nginx_helper->options['log_filesize'] = 5;
32
- }
33
- }
34
- if ( $rt_wp_nginx_helper->options['enable_map'] ) {
35
- $rt_wp_nginx_helper->update_map();
36
- }
37
- }
38
- if ( isset( $_POST['enable_purge'] ) ) {
39
- $rt_wp_nginx_helper->options['purge_homepage_on_edit'] = ( isset($_POST['purge_homepage_on_edit'] ) and ( $_POST['purge_homepage_on_edit'] == 1 ) ) ? 1 : 0;
40
- $rt_wp_nginx_helper->options['purge_homepage_on_del'] = ( isset($_POST['purge_homepage_on_del'] ) and ( $_POST['purge_homepage_on_del'] == 1 ) ) ? 1 : 0;
41
 
42
- $rt_wp_nginx_helper->options['purge_archive_on_edit'] = ( isset($_POST['purge_archive_on_edit'] ) and ( $_POST['purge_archive_on_edit'] == 1 ) ) ? 1 : 0;
43
- $rt_wp_nginx_helper->options['purge_archive_on_del'] = ( isset($_POST['purge_archive_on_del'] ) and ( $_POST['purge_archive_on_del'] == 1 ) ) ? 1 : 0;
44
 
45
- $rt_wp_nginx_helper->options['purge_archive_on_new_comment'] = ( isset( $_POST['purge_archive_on_new_comment'] ) and ( $_POST['purge_archive_on_new_comment'] == 1 ) ) ? 1 : 0;
46
- $rt_wp_nginx_helper->options['purge_archive_on_deleted_comment'] = ( isset( $_POST['purge_archive_on_deleted_comment'] ) and ( $_POST['purge_archive_on_deleted_comment'] == 1 ) ) ? 1 : 0;
47
 
48
- $rt_wp_nginx_helper->options['purge_page_on_mod'] = ( isset( $_POST['purge_page_on_mod'] ) and ( $_POST['purge_page_on_mod'] == 1 ) ) ? 1 : 0;
49
- $rt_wp_nginx_helper->options['purge_page_on_new_comment'] = ( isset( $_POST['purge_page_on_new_comment'] ) and ( $_POST['purge_page_on_new_comment'] == 1 ) ) ? 1 : 0;
50
- $rt_wp_nginx_helper->options['purge_page_on_deleted_comment'] = ( isset( $_POST['purge_page_on_deleted_comment'] ) and ( $_POST['purge_page_on_deleted_comment'] == 1 ) ) ? 1 : 0;
51
 
52
- $rt_wp_nginx_helper->options['purge_method'] = ( isset( $_POST['purge_method'] ) ) ? $_POST['purge_method'] : 'get_request';
53
- }
54
- update_site_option( 'rt_wp_nginx_helper_options', $rt_wp_nginx_helper->options );
55
- $update = 1;
56
- }
57
- $rt_wp_nginx_helper->options = get_site_option( 'rt_wp_nginx_helper_options' );
58
 
59
- /**
60
- * Show Update Message
61
- */
62
- if ( isset( $_POST['smart_http_expire_save'] ) ) {
63
- echo '<div class="updated"><p>' . __( 'Settings saved.', 'nginx-helper' ) . '</p></div>';
64
- }
65
 
66
- /**
67
- * Check for single multiple with subdomain OR multiple with subdirectory site
68
- */
69
- $nginx_setting_link = '#';
70
- if ( is_multisite() ) {
71
- if ( SUBDOMAIN_INSTALL == false ) {
72
- $nginx_setting_link = 'https://rtcamp.com/wordpress-nginx/tutorials/multisite/subdirectories/fastcgi-cache-with-purging/';
73
- } else {
74
- $nginx_setting_link = 'https://rtcamp.com/wordpress-nginx/tutorials/multisite/subdomains/fastcgi-cache-with-purging/';
75
- }
76
- } else {
77
- $nginx_setting_link = 'https://rtcamp.com/wordpress-nginx/tutorials/single-site/fastcgi-cache-with-purging/';
78
- } ?>
79
- <div class="postbox">
80
- <h3 class="hndle">
81
- <span><?php _e( 'Purge Cache', 'nginx-helper' ); ?></span>
82
- </h3>
83
- <form id="purgeall" action="" method="post" class="clearfix">
84
- <div class="inside">
85
- <?php $purge_url = add_query_arg( array( 'nginx_helper_action' => 'purge', 'nginx_helper_urls' => 'all' ) ); ?>
86
- <?php $nonced_url = wp_nonce_url( $purge_url, 'nginx_helper-purge_all' ); ?>
87
- <table class="form-table">
88
- <tr valign="top">
89
- <th><?php _e( 'Purge All Cache', 'nginx-helper' ); ?></th>
90
- <td>
91
- <a href="<?php echo $nonced_url; ?>" class="button-primary"><?php _e( 'Purge Cache', 'nginx-helper' ); ?></a>
92
- </td>
93
- </tr>
94
- </table>
95
- </div>
96
- </form>
97
- </div> <!-- End of .postbox -->
98
- <form id="post_form" method="post" action="#" name="smart_http_expire_form" class="clearfix">
99
- <div class="postbox">
100
- <h3 class="hndle">
101
- <span><?php _e('Plugin Options', 'nginx-helper'); ?></span>
102
- </h3>
103
- <?php if ( !( !is_network_admin() && is_multisite() ) ) { ?>
104
- <div class="inside">
105
- <input type="hidden" name="is_submit" value="1" />
106
- <table class="form-table">
107
- <tr valign="top">
108
- <td>
109
- <input type="checkbox" value="1" id="enable_purge" name="enable_purge" <?php checked($rt_wp_nginx_helper->options['enable_purge'], 1); ?> />
110
- <label for="enable_purge">
111
- <?php printf( __( 'Enable Cache Purge (<a target="_blank" href="%s" title="External settings for nginx">requires external settings for nginx</a>)', 'nginx-helper' ), $nginx_setting_link ); ?>
112
- </label>
113
- </td>
114
- </tr>
115
- <?php if ( is_network_admin() ) { ?>
116
- <tr valign="top">
117
- <td>
118
- <input type="checkbox" value="1" id="enable_map" name="enable_map"<?php checked($rt_wp_nginx_helper->options['enable_map'], 1); ?> />
119
- <label for="enable_map"><?php _e('Enable Nginx Map.', 'nginx-helper'); ?></label>
120
- </td>
121
- </tr>
122
- <?php } ?>
123
- <tr valign="top">
124
- <td>
125
- <input type="checkbox" value="1" id="enable_log" name="enable_log"<?php checked($rt_wp_nginx_helper->options['enable_log'], 1); ?> />
126
- <label for="enable_log"><?php _e('Enable Logging', 'nginx-helper'); ?></label>
127
- </td>
128
- </tr>
129
- <tr valign="top">
130
- <td>
131
- <input type="checkbox" value="1" id="enable_stamp" name="enable_stamp"<?php checked($rt_wp_nginx_helper->options['enable_stamp'], 1); ?> />
132
- <label for="enable_stamp"><?php _e('Enable Nginx Timestamp in HTML', 'nginx-helper'); ?></label>
133
- </td>
134
- </tr>
135
- </table>
136
- </div> <!-- End of .inside -->
137
- </div>
138
-
139
- <div class="postbox enable_purge"<?php echo ( $rt_wp_nginx_helper->options['enable_purge'] == false ) ? ' style="display: none;"' : ''; ?>>
140
- <h3 class="hndle">
141
- <span><?php _e('Purging Options', 'nginx-helper'); ?></span>
142
- </h3>
143
- <div class="inside">
144
 
145
- <table class="form-table rtnginx-table">
146
- <tr valign="top">
147
- <th scope="row"><h4><?php _e('Purge Homepage:', 'nginx-helper'); ?></h4></th>
148
- <td>
149
- <fieldset>
150
- <legend class="screen-reader-text">
151
- <span>&nbsp;<?php _e('when a post/page/custom post is modified or added.', 'nginx-helper'); ?></span>
152
- </legend>
153
- <label for="purge_homepage_on_edit">
154
- <input type="checkbox" value="1" id="purge_homepage_on_edit" name="purge_homepage_on_edit"<?php checked($rt_wp_nginx_helper->options['purge_homepage_on_edit'], 1); ?> />
155
- &nbsp;<?php _e('when a <strong>post</strong> (or page/custom post) is <strong>modified</strong> or <strong>added</strong>.', 'nginx-helper'); ?>
156
- </label><br />
157
- </fieldset>
158
- <fieldset>
159
- <legend class="screen-reader-text">
160
- <span>&nbsp;<?php _e('when an existing post/page/custom post is modified.', 'nginx-helper'); ?></span>
161
- </legend>
162
- <label for="purge_homepage_on_del">
163
- <input type="checkbox" value="1" id="purge_homepage_on_del" name="purge_homepage_on_del"<?php checked($rt_wp_nginx_helper->options['purge_homepage_on_del'], 1); ?> />
164
- &nbsp;<?php _e('when a <strong>published post</strong> (or page/custom post) is <strong>trashed</strong>.', 'nginx-helper'); ?></label><br />
165
- </fieldset>
166
- </td>
167
- </tr>
168
- </table>
169
- <table class="form-table rtnginx-table">
170
- <tr valign="top">
171
- <th scope="row">
172
- <h4><?php _e('Purge Post/Page/Custom Post Type:', 'nginx-helper'); ?></h4>
173
- </th>
174
- <td>
175
- <fieldset>
176
- <legend class="screen-reader-text">
177
- <span>&nbsp;<?php _e('when a post/page/custom post is published.', 'nginx-helper'); ?></span>
178
- </legend>
179
- <label for="purge_page_on_mod">
180
- <input type="checkbox" value="1" id="purge_page_on_mod" name="purge_page_on_mod"<?php checked($rt_wp_nginx_helper->options['purge_page_on_mod'], 1); ?>>
181
- &nbsp;<?php _e('when a <strong>post</strong> is <strong>published</strong>.', 'nginx-helper'); ?>
182
- </label><br />
183
- </fieldset>
184
- <fieldset>
185
- <legend class="screen-reader-text">
186
- <span>&nbsp;<?php _e('when a comment is approved/published.', 'nginx-helper'); ?></span>
187
- </legend>
188
- <label for="purge_page_on_new_comment">
189
- <input type="checkbox" value="1" id="purge_page_on_new_comment" name="purge_page_on_new_comment"<?php checked($rt_wp_nginx_helper->options['purge_page_on_new_comment'], 1); ?>>
190
- &nbsp;<?php _e('when a <strong>comment</strong> is <strong>approved/published</strong>.', 'nginx-helper'); ?>
191
- </label><br />
192
- </fieldset>
193
- <fieldset>
194
- <legend class="screen-reader-text">
195
- <span>&nbsp;<?php _e('when a comment is unapproved/deleted.', 'nginx-helper'); ?></span>
196
- </legend>
197
- <label for="purge_page_on_deleted_comment">
198
- <input type="checkbox" value="1" id="purge_page_on_deleted_comment" name="purge_page_on_deleted_comment"<?php checked($rt_wp_nginx_helper->options['purge_page_on_deleted_comment'], 1); ?>>
199
- &nbsp;<?php _e('when a <strong>comment</strong> is <strong>unapproved/deleted</strong>.', 'nginx-helper'); ?>
200
- </label><br />
201
- </fieldset>
202
- </td>
203
- </tr>
204
- </table>
205
- <table class="form-table rtnginx-table">
206
- <tr valign="top">
207
- <th scope="row">
208
- <h4><?php _e('Purge Archives:', 'nginx-helper'); ?></h4>
209
- <small><?php _e('(date, category, tag, author, custom taxonomies)', 'nginx-helper'); ?></small>
210
- </th>
211
- <td>
212
- <fieldset>
213
- <legend class="screen-reader-text">
214
- <span>&nbsp;<?php _e('when an post/page/custom post is modified or added.</span>', 'nginx-helper'); ?>
215
- </legend>
216
- <label for="purge_archive_on_edit">
217
- <input type="checkbox" value="1" id="purge_archive_on_edit" name="purge_archive_on_edit"<?php checked($rt_wp_nginx_helper->options['purge_archive_on_edit'], 1); ?> />
218
- &nbsp;<?php _e('when a <strong>post</strong> (or page/custom post) is <strong>modified</strong> or <strong>added</strong>.', 'nginx-helper'); ?>
219
- </label><br />
220
- </fieldset>
221
- <fieldset>
222
- <legend class="screen-reader-text">
223
- <span>&nbsp;<?php _e('when an existing post/page/custom post is trashed.</span>', 'nginx-helper'); ?>
224
- </legend>
225
- <label for="purge_archive_on_del">
226
- <input type="checkbox" value="1" id="purge_archive_on_del" name="purge_archive_on_del"<?php checked($rt_wp_nginx_helper->options['purge_archive_on_del'], 1); ?> />
227
- &nbsp;<?php _e('when a <strong>published post</strong> (or page/custom post) is <strong>trashed</strong>.', 'nginx-helper'); ?>
228
- </label><br />
229
- </fieldset>
230
- <br />
231
- <fieldset>
232
- <legend class="screen-reader-text">
233
- <span>&nbsp;<?php _e('when a comment is approved/published.</span>', 'nginx-helper'); ?>
234
- </legend>
235
- <label for="purge_archive_on_new_comment">
236
- <input type="checkbox" value="1" id="purge_archive_on_new_comment" name="purge_archive_on_new_comment"<?php checked($rt_wp_nginx_helper->options['purge_archive_on_new_comment'], 1); ?> />
237
- &nbsp;<?php _e('when a <strong>comment</strong> is <strong>approved/published</strong>.', 'nginx-helper'); ?>
238
- </label><br />
239
- </fieldset>
240
- <fieldset>
241
- <legend class="screen-reader-text">
242
- <span>&nbsp;<?php _e('when a comment is unapproved/deleted.</span>', 'nginx-helper'); ?>
243
- </legend>
244
- <label for="purge_archive_on_deleted_comment">
245
- <input type="checkbox" value="1" id="purge_archive_on_deleted_comment" name="purge_archive_on_deleted_comment"<?php checked($rt_wp_nginx_helper->options['purge_archive_on_deleted_comment'], 1); ?> />
246
- &nbsp;<?php _e('when a <strong>comment</strong> is <strong>unapproved/deleted</strong>.', 'nginx-helper'); ?>
247
- </label><br />
248
- </fieldset>
249
 
250
- </td>
251
- </tr>
252
- </table>
253
- <table class="form-table rtnginx-table">
254
- <tr valign="top">
255
- <th scope="row">
256
- <h4><?php _e('Purge Method:', 'nginx-helper'); ?></h4>
257
- </th>
258
- <td>
259
- <fieldset>
260
- <legend class="screen-reader-text">
261
- <span>&nbsp;<?php _e('when a post/page/custom post is published.', 'nginx-helper'); ?></span>
262
- </legend>
263
- <label for="purge_method_get_request">
264
- <input type="radio" value="get_request" id="purge_method_get_request" name="purge_method"<?php checked(($rt_wp_nginx_helper->options['purge_method']) ? $rt_wp_nginx_helper->options['purge_method'] : 'get_request', 'get_request'); ?>>
265
- &nbsp;<?php _e('Using a GET request to <strong>PURGE/url</strong> (Default option)', 'nginx-helper'); ?><br />
266
- <small><?php _e('Uses the <strong><a href="https://github.com/FRiCKLE/ngx_cache_purge">ngx_cache_purge</a></strong> module. ', 'nginx-helper'); ?></small>
267
- </label><br />
268
- <label for="purge_method_unlink_files">
269
- <input type="radio" value="unlink_files" id="purge_method_unlink_files" name="purge_method"<?php checked($rt_wp_nginx_helper->options['purge_method'], 'unlink_files'); ?>>
270
- &nbsp;<?php _e('Delete local server cache files', 'nginx-helper'); ?><br />
271
- <small><?php _e('Checks for matching cache file in <strong>RT_WP_NGINX_HELPER_CACHE_PATH</strong>. Does not require any other modules. Requires that the cache be stored on the same server as WordPress. You must also be using the default nginx cache options (levels=1:2) and (fastcgi_cache_key "$scheme$request_method$host$request_uri"). ', 'nginx-helper'); ?></small>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
272
 
273
- </label><br />
274
- </fieldset>
275
- </td>
276
- </tr>
277
- </table>
278
- </div> <!-- End of .inside -->
279
- </div><?php
280
- } // End of if ( !( !is_network_admin() && is_multisite() ) )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
281
 
 
 
 
 
 
 
 
 
282
 
283
- if ( is_network_admin() ) { ?>
284
- <div class="postbox enable_map"<?php echo ( $rt_wp_nginx_helper->options['enable_map'] == false ) ? ' style="display: none;"' : ''; ?>>
285
- <h3 class="hndle">
286
- <span><?php _e('Nginx Map', 'nginx-helper'); ?></span>
287
- </h3>
288
- <div class="inside"><?php
289
- if ( !is_writable( $rt_wp_nginx_helper->functional_asset_path() . 'map.conf' ) ) { ?>
290
- <span class="error fade" style="display: block"><p><?php printf(__('Can\'t write on map file.<br /><br />Check you have write permission on <strong>%s</strong>', 'nginx-helper'), $rt_wp_nginx_helper->functional_asset_path() . 'map.conf'); ?></p></span><?php
291
- } ?>
292
 
293
- <table class="form-table rtnginx-table">
294
- <tr>
295
- <th><?php _e('Nginx Map path to include in nginx settings<br /><small>(recommended)</small>', 'nginx-helper'); ?></th>
296
- <td>
297
- <pre><?php echo $rt_wp_nginx_helper->functional_asset_path() . 'map.conf'; ?></pre>
298
- </td>
299
- </tr>
300
- <tr>
301
- <th><?php _e('Or,<br />Text to manually copy and paste in nginx settings<br /><small>(if your network is small and new sites are not added frequently)</small>', 'nginx-helper'); ?></th>
302
- <td>
303
- <pre id="map"><?php echo $rt_wp_nginx_helper->get_map() ?></pre>
304
- </td>
305
- </tr>
306
- </table>
307
- </div> <!-- End of .inside -->
308
- </div>
309
- <?php } ?>
310
 
311
- <div class="postbox enable_log"<?php echo ( $rt_wp_nginx_helper->options['enable_log'] == false ) ? ' style="display: none;"' : ''; ?>>
312
- <h3 class="hndle">
313
- <span><?php _e('Logging Options', 'nginx-helper'); ?></span>
314
- </h3>
315
- <div class="inside">
316
- <?php
317
- $path = $rt_wp_nginx_helper->functional_asset_path();
318
- if (!is_dir($path)) {
319
- mkdir($path);
320
- }
321
- if (!file_exists($path . 'nginx.log')) {
322
- $log = fopen($path . 'nginx.log', 'w');
323
- fclose($log);
324
- }
325
- if (is_writable($path . 'nginx.log')) {
326
- $rt_wp_nginx_purger->log("+++++++++");
327
- $rt_wp_nginx_purger->log("+Log Test");
328
- $rt_wp_nginx_purger->log("+++++++++");
329
- }
330
- if (!is_writable($path . 'nginx.log')) { ?>
331
- <span class="error fade" style="display : block"><p><?php printf(__('Can\'t write on log file.<br /><br />Check you have write permission on <strong>%s</strong>', 'nginx-helper'), $rt_wp_nginx_helper->functional_asset_path() . 'nginx.log'); ?></p></span><?php
332
- } ?>
333
 
334
- <table class="form-table rtnginx-table">
335
- <tbody>
336
- <tr>
337
- <th><label for="rt_wp_nginx_helper_logs_path"><?php _e('Logs path', 'nginx-helper'); ?></label></th>
338
- <td><pre><?php echo $rt_wp_nginx_helper->functional_asset_path(); ?>nginx.log</pre></td>
339
- </tr>
340
- <tr>
341
- <th><label for="rt_wp_nginx_helper_logs_link"><?php _e('View Log', 'nginx-helper'); ?></label></th>
342
- <td><a target="_blank" href="<?php echo $rt_wp_nginx_helper->functional_asset_url(); ?>nginx.log"><?php _e('Log', 'nginx-helper'); ?></a></td>
343
- </tr>
344
- <tr>
345
- <th><label for="rt_wp_nginx_helper_log_level"><?php _e('Log level', 'nginx-helper'); ?></label></th>
346
- <td>
347
- <select name="log_level">
348
- <option value="NONE"<?php selected($rt_wp_nginx_helper->options['log_level'], 'NONE'); ?>><?php _e('None', 'nginx-helper'); ?></option>
349
- <option value="INFO"<?php selected($rt_wp_nginx_helper->options['log_level'], 'INFO'); ?>><?php _e('Info', 'nginx-helper'); ?></option>
350
- <option value="WARNING"<?php selected($rt_wp_nginx_helper->options['log_level'], 'WARNING'); ?>><?php _e('Warning', 'nginx-helper'); ?></option>
351
- <option value="ERROR"<?php selected($rt_wp_nginx_helper->options['log_level'], 'ERROR'); ?>><?php _e('Error', 'nginx-helper'); ?></option>
352
- </select>
353
- </td>
354
- </tr>
355
- <tr>
356
- <th><label for="log_filesize"><?php _e('Max log file size', 'nginx-helper'); ?></label></th>
357
- <td>
358
- <input id="log_filesize" class="small-text" type="text" name="log_filesize" value="<?php echo $rt_wp_nginx_helper->options['log_filesize'] ?>" /> <?php _e( 'Mb', 'nginx-helper' );
359
- if ( $error_log_filesize ) { ?>
360
- <p class="error fade" style="display: block;"><?php echo $error_log_filesize; ?></p><?php
361
- } ?>
362
- </td>
363
- </tr>
364
- </tbody>
365
- </table>
366
- </div> <!-- End of .inside -->
367
- </div><?php
368
-
369
- submit_button( __( 'Save All Changes', 'nginx-helper' ), 'primary large', 'smart_http_expire_save', true ); ?>
370
- </form><!-- End of #post_form --><?php
371
- }
372
 
373
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  namespace rtCamp\WP\Nginx {
4
 
5
+ function nginx_general_options_page() {
6
+ global $rt_wp_nginx_helper, $rt_wp_nginx_purger;
7
 
8
+ $update = 0;
9
+ $error_time = false;
10
+ $error_log_filesize = false;
11
+ $rt_wp_nginx_helper->options['enable_purge'] = (isset( $_POST['enable_purge'] ) and ( $_POST['enable_purge'] == 1) ) ? 1 : 0;
12
+ $rt_wp_nginx_helper->options['enable_map'] = (isset( $_POST['enable_map'] ) and ( $_POST['enable_map'] == 1) ) ? 1 : 0;
13
+ $rt_wp_nginx_helper->options['enable_log'] = (isset( $_POST['enable_log'] ) and ( $_POST['enable_log'] == 1) ) ? 1 : 0;
14
+ $rt_wp_nginx_helper->options['enable_stamp'] = (isset( $_POST['enable_stamp'] ) and ( $_POST['enable_stamp'] == 1) ) ? 1 : 0;
15
 
16
+ if ( isset( $_POST['is_submit'] ) && ( $_POST['is_submit'] == 1 ) ) {
17
+ if ( !(!is_network_admin() && is_multisite() ) ) {
18
+ if ( $rt_wp_nginx_helper->options['enable_log'] ) {
19
+ if ( isset( $_POST['log_level'] ) && !empty( $_POST['log_level'] ) && $_POST['log_level'] != '' ) {
20
+ $rt_wp_nginx_helper->options['log_level'] = $_POST['log_level'];
21
+ } else {
22
+ $rt_wp_nginx_helper->options['log_level'] = 'INFO';
23
+ }
24
+ if ( isset( $_POST['log_filesize'] ) && !empty( $_POST['log_filesize'] ) && $_POST['log_filesize'] != '' ) {
25
+ if ( (!is_numeric( $_POST['log_filesize'] ) ) || ( empty( $_POST['log_filesize'] ) ) ) {
26
+ $error_log_filesize = __( 'Log file size must be a number', 'nginx-helper' );
27
+ } else {
28
+ $rt_wp_nginx_helper->options['log_filesize'] = $_POST['log_filesize'];
29
+ }
30
+ } else {
31
+ $rt_wp_nginx_helper->options['log_filesize'] = 5;
32
+ }
33
+ }
34
+ if ( $rt_wp_nginx_helper->options['enable_map'] ) {
35
+ $rt_wp_nginx_helper->update_map();
36
+ }
37
+ }
38
+ if ( isset( $_POST['enable_purge'] ) ) {
39
+ $rt_wp_nginx_helper->options['purge_homepage_on_edit'] = ( isset( $_POST['purge_homepage_on_edit'] ) and ( $_POST['purge_homepage_on_edit'] == 1 ) ) ? 1 : 0;
40
+ $rt_wp_nginx_helper->options['purge_homepage_on_del'] = ( isset( $_POST['purge_homepage_on_del'] ) and ( $_POST['purge_homepage_on_del'] == 1 ) ) ? 1 : 0;
41
 
42
+ $rt_wp_nginx_helper->options['purge_archive_on_edit'] = ( isset( $_POST['purge_archive_on_edit'] ) and ( $_POST['purge_archive_on_edit'] == 1 ) ) ? 1 : 0;
43
+ $rt_wp_nginx_helper->options['purge_archive_on_del'] = ( isset( $_POST['purge_archive_on_del'] ) and ( $_POST['purge_archive_on_del'] == 1 ) ) ? 1 : 0;
44
 
45
+ $rt_wp_nginx_helper->options['purge_archive_on_new_comment'] = ( isset( $_POST['purge_archive_on_new_comment'] ) and ( $_POST['purge_archive_on_new_comment'] == 1 ) ) ? 1 : 0;
46
+ $rt_wp_nginx_helper->options['purge_archive_on_deleted_comment'] = ( isset( $_POST['purge_archive_on_deleted_comment'] ) and ( $_POST['purge_archive_on_deleted_comment'] == 1 ) ) ? 1 : 0;
47
 
48
+ $rt_wp_nginx_helper->options['purge_page_on_mod'] = ( isset( $_POST['purge_page_on_mod'] ) and ( $_POST['purge_page_on_mod'] == 1 ) ) ? 1 : 0;
49
+ $rt_wp_nginx_helper->options['purge_page_on_new_comment'] = ( isset( $_POST['purge_page_on_new_comment'] ) and ( $_POST['purge_page_on_new_comment'] == 1 ) ) ? 1 : 0;
50
+ $rt_wp_nginx_helper->options['purge_page_on_deleted_comment'] = ( isset( $_POST['purge_page_on_deleted_comment'] ) and ( $_POST['purge_page_on_deleted_comment'] == 1 ) ) ? 1 : 0;
51
 
52
+ $rt_wp_nginx_helper->options['purge_method'] = ( isset( $_POST['purge_method'] ) ) ? $_POST['purge_method'] : 'get_request';
53
+ }
54
+ update_site_option( 'rt_wp_nginx_helper_options', $rt_wp_nginx_helper->options );
55
+ $update = 1;
56
+ }
57
+ $rt_wp_nginx_helper->options = get_site_option( 'rt_wp_nginx_helper_options' );
58
 
59
+ /**
60
+ * Show Update Message
61
+ */
62
+ if ( isset( $_POST['smart_http_expire_save'] ) ) {
63
+ echo '<div class="updated"><p>' . __( 'Settings saved.', 'nginx-helper' ) . '</p></div>';
64
+ }
65
 
66
+ /**
67
+ * Check for single multiple with subdomain OR multiple with subdirectory site
68
+ */
69
+ $nginx_setting_link = '#';
70
+ if ( is_multisite() ) {
71
+ if ( SUBDOMAIN_INSTALL == false ) {
72
+ $nginx_setting_link = 'https://rtcamp.com/wordpress-nginx/tutorials/multisite/subdirectories/fastcgi-cache-with-purging/';
73
+ } else {
74
+ $nginx_setting_link = 'https://rtcamp.com/wordpress-nginx/tutorials/multisite/subdomains/fastcgi-cache-with-purging/';
75
+ }
76
+ } else {
77
+ $nginx_setting_link = 'https://rtcamp.com/wordpress-nginx/tutorials/single-site/fastcgi-cache-with-purging/';
78
+ }
79
+ ?>
80
+ <div class="postbox">
81
+ <h3 class="hndle">
82
+ <span><?php _e( 'Purge Cache', 'nginx-helper' ); ?></span>
83
+ </h3>
84
+ <form id="purgeall" action="" method="post" class="clearfix">
85
+ <div class="inside">
86
+ <?php $purge_url = add_query_arg( array( 'nginx_helper_action' => 'purge', 'nginx_helper_urls' => 'all' ) ); ?>
87
+ <?php $nonced_url = wp_nonce_url( $purge_url, 'nginx_helper-purge_all' ); ?>
88
+ <table class="form-table">
89
+ <tr valign="top">
90
+ <th><?php _e( 'Purge All Cache', 'nginx-helper' ); ?></th>
91
+ <td>
92
+ <a href="<?php echo $nonced_url; ?>" class="button-primary"><?php _e( 'Purge Cache', 'nginx-helper' ); ?></a>
93
+ </td>
94
+ </tr>
95
+ </table>
96
+ </div>
97
+ </form>
98
+ </div> <!-- End of .postbox -->
99
+ <form id="post_form" method="post" action="#" name="smart_http_expire_form" class="clearfix">
100
+ <div class="postbox">
101
+ <h3 class="hndle">
102
+ <span><?php _e( 'Plugin Options', 'nginx-helper' ); ?></span>
103
+ </h3>
104
+ <?php if ( !(!is_network_admin() && is_multisite() ) ) { ?>
105
+ <div class="inside">
106
+ <input type="hidden" name="is_submit" value="1" />
107
+ <table class="form-table">
108
+ <tr valign="top">
109
+ <td>
110
+ <input type="checkbox" value="1" id="enable_purge" name="enable_purge" <?php checked( $rt_wp_nginx_helper->options['enable_purge'], 1 ); ?> />
111
+ <label for="enable_purge">
112
+ <?php printf( __( 'Enable Cache Purge (<a target="_blank" href="%s" title="External settings for nginx">requires external settings for nginx</a>)', 'nginx-helper' ), $nginx_setting_link ); ?>
113
+ </label>
114
+ </td>
115
+ </tr>
116
+ <?php if ( is_network_admin() ) { ?>
117
+ <tr valign="top">
118
+ <td>
119
+ <input type="checkbox" value="1" id="enable_map" name="enable_map"<?php checked( $rt_wp_nginx_helper->options['enable_map'], 1 ); ?> />
120
+ <label for="enable_map"><?php _e( 'Enable Nginx Map.', 'nginx-helper' ); ?></label>
121
+ </td>
122
+ </tr>
123
+ <?php } ?>
124
+ <tr valign="top">
125
+ <td>
126
+ <input type="checkbox" value="1" id="enable_log" name="enable_log"<?php checked( $rt_wp_nginx_helper->options['enable_log'], 1 ); ?> />
127
+ <label for="enable_log"><?php _e( 'Enable Logging', 'nginx-helper' ); ?></label>
128
+ </td>
129
+ </tr>
130
+ <tr valign="top">
131
+ <td>
132
+ <input type="checkbox" value="1" id="enable_stamp" name="enable_stamp"<?php checked( $rt_wp_nginx_helper->options['enable_stamp'], 1 ); ?> />
133
+ <label for="enable_stamp"><?php _e( 'Enable Nginx Timestamp in HTML', 'nginx-helper' ); ?></label>
134
+ </td>
135
+ </tr>
136
+ </table>
137
+ </div> <!-- End of .inside -->
138
+ </div>
 
 
 
 
 
139
 
140
+ <div class="postbox enable_purge"<?php echo ( $rt_wp_nginx_helper->options['enable_purge'] == false ) ? ' style="display: none;"' : ''; ?>>
141
+ <h3 class="hndle">
142
+ <span><?php _e( 'Purging Options', 'nginx-helper' ); ?></span>
143
+ </h3>
144
+ <div class="inside">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
 
146
+ <table class="form-table rtnginx-table">
147
+ <tr valign="top">
148
+ <th scope="row"><h4><?php _e( 'Purge Homepage:', 'nginx-helper' ); ?></h4></th>
149
+ <td>
150
+ <fieldset>
151
+ <legend class="screen-reader-text">
152
+ <span>&nbsp;<?php _e( 'when a post/page/custom post is modified or added.', 'nginx-helper' ); ?></span>
153
+ </legend>
154
+ <label for="purge_homepage_on_edit">
155
+ <input type="checkbox" value="1" id="purge_homepage_on_edit" name="purge_homepage_on_edit"<?php checked( $rt_wp_nginx_helper->options['purge_homepage_on_edit'], 1 ); ?> />
156
+ &nbsp;<?php _e( 'when a <strong>post</strong> (or page/custom post) is <strong>modified</strong> or <strong>added</strong>.', 'nginx-helper' ); ?>
157
+ </label><br />
158
+ </fieldset>
159
+ <fieldset>
160
+ <legend class="screen-reader-text">
161
+ <span>&nbsp;<?php _e( 'when an existing post/page/custom post is modified.', 'nginx-helper' ); ?></span>
162
+ </legend>
163
+ <label for="purge_homepage_on_del">
164
+ <input type="checkbox" value="1" id="purge_homepage_on_del" name="purge_homepage_on_del"<?php checked( $rt_wp_nginx_helper->options['purge_homepage_on_del'], 1 ); ?> />
165
+ &nbsp;<?php _e( 'when a <strong>published post</strong> (or page/custom post) is <strong>trashed</strong>.', 'nginx-helper' ); ?></label><br />
166
+ </fieldset>
167
+ </td>
168
+ </tr>
169
+ </table>
170
+ <table class="form-table rtnginx-table">
171
+ <tr valign="top">
172
+ <th scope="row">
173
+ <h4><?php _e( 'Purge Post/Page/Custom Post Type:', 'nginx-helper' ); ?></h4>
174
+ </th>
175
+ <td>
176
+ <fieldset>
177
+ <legend class="screen-reader-text">
178
+ <span>&nbsp;<?php _e( 'when a post/page/custom post is published.', 'nginx-helper' ); ?></span>
179
+ </legend>
180
+ <label for="purge_page_on_mod">
181
+ <input type="checkbox" value="1" id="purge_page_on_mod" name="purge_page_on_mod"<?php checked( $rt_wp_nginx_helper->options['purge_page_on_mod'], 1 ); ?>>
182
+ &nbsp;<?php _e( 'when a <strong>post</strong> is <strong>published</strong>.', 'nginx-helper' ); ?>
183
+ </label><br />
184
+ </fieldset>
185
+ <fieldset>
186
+ <legend class="screen-reader-text">
187
+ <span>&nbsp;<?php _e( 'when a comment is approved/published.', 'nginx-helper' ); ?></span>
188
+ </legend>
189
+ <label for="purge_page_on_new_comment">
190
+ <input type="checkbox" value="1" id="purge_page_on_new_comment" name="purge_page_on_new_comment"<?php checked( $rt_wp_nginx_helper->options['purge_page_on_new_comment'], 1 ); ?>>
191
+ &nbsp;<?php _e( 'when a <strong>comment</strong> is <strong>approved/published</strong>.', 'nginx-helper' ); ?>
192
+ </label><br />
193
+ </fieldset>
194
+ <fieldset>
195
+ <legend class="screen-reader-text">
196
+ <span>&nbsp;<?php _e( 'when a comment is unapproved/deleted.', 'nginx-helper' ); ?></span>
197
+ </legend>
198
+ <label for="purge_page_on_deleted_comment">
199
+ <input type="checkbox" value="1" id="purge_page_on_deleted_comment" name="purge_page_on_deleted_comment"<?php checked( $rt_wp_nginx_helper->options['purge_page_on_deleted_comment'], 1 ); ?>>
200
+ &nbsp;<?php _e( 'when a <strong>comment</strong> is <strong>unapproved/deleted</strong>.', 'nginx-helper' ); ?>
201
+ </label><br />
202
+ </fieldset>
203
+ </td>
204
+ </tr>
205
+ </table>
206
+ <table class="form-table rtnginx-table">
207
+ <tr valign="top">
208
+ <th scope="row">
209
+ <h4><?php _e( 'Purge Archives:', 'nginx-helper' ); ?></h4>
210
+ <small><?php _e( '(date, category, tag, author, custom taxonomies)', 'nginx-helper' ); ?></small>
211
+ </th>
212
+ <td>
213
+ <fieldset>
214
+ <legend class="screen-reader-text">
215
+ <span>&nbsp;<?php _e( 'when an post/page/custom post is modified or added.</span>', 'nginx-helper' ); ?>
216
+ </legend>
217
+ <label for="purge_archive_on_edit">
218
+ <input type="checkbox" value="1" id="purge_archive_on_edit" name="purge_archive_on_edit"<?php checked( $rt_wp_nginx_helper->options['purge_archive_on_edit'], 1 ); ?> />
219
+ &nbsp;<?php _e( 'when a <strong>post</strong> (or page/custom post) is <strong>modified</strong> or <strong>added</strong>.', 'nginx-helper' ); ?>
220
+ </label><br />
221
+ </fieldset>
222
+ <fieldset>
223
+ <legend class="screen-reader-text">
224
+ <span>&nbsp;<?php _e( 'when an existing post/page/custom post is trashed.</span>', 'nginx-helper' ); ?>
225
+ </legend>
226
+ <label for="purge_archive_on_del">
227
+ <input type="checkbox" value="1" id="purge_archive_on_del" name="purge_archive_on_del"<?php checked( $rt_wp_nginx_helper->options['purge_archive_on_del'], 1 ); ?> />
228
+ &nbsp;<?php _e( 'when a <strong>published post</strong> (or page/custom post) is <strong>trashed</strong>.', 'nginx-helper' ); ?>
229
+ </label><br />
230
+ </fieldset>
231
+ <br />
232
+ <fieldset>
233
+ <legend class="screen-reader-text">
234
+ <span>&nbsp;<?php _e( 'when a comment is approved/published.</span>', 'nginx-helper' ); ?>
235
+ </legend>
236
+ <label for="purge_archive_on_new_comment">
237
+ <input type="checkbox" value="1" id="purge_archive_on_new_comment" name="purge_archive_on_new_comment"<?php checked( $rt_wp_nginx_helper->options['purge_archive_on_new_comment'], 1 ); ?> />
238
+ &nbsp;<?php _e( 'when a <strong>comment</strong> is <strong>approved/published</strong>.', 'nginx-helper' ); ?>
239
+ </label><br />
240
+ </fieldset>
241
+ <fieldset>
242
+ <legend class="screen-reader-text">
243
+ <span>&nbsp;<?php _e( 'when a comment is unapproved/deleted.</span>', 'nginx-helper' ); ?>
244
+ </legend>
245
+ <label for="purge_archive_on_deleted_comment">
246
+ <input type="checkbox" value="1" id="purge_archive_on_deleted_comment" name="purge_archive_on_deleted_comment"<?php checked( $rt_wp_nginx_helper->options['purge_archive_on_deleted_comment'], 1 ); ?> />
247
+ &nbsp;<?php _e( 'when a <strong>comment</strong> is <strong>unapproved/deleted</strong>.', 'nginx-helper' ); ?>
248
+ </label><br />
249
+ </fieldset>
250
 
251
+ </td>
252
+ </tr>
253
+ </table>
254
+ <table class="form-table rtnginx-table">
255
+ <tr valign="top">
256
+ <th scope="row">
257
+ <h4><?php _e( 'Purge Method:', 'nginx-helper' ); ?></h4>
258
+ </th>
259
+ <td>
260
+ <fieldset>
261
+ <legend class="screen-reader-text">
262
+ <span>&nbsp;<?php _e( 'when a post/page/custom post is published.', 'nginx-helper' ); ?></span>
263
+ </legend>
264
+ <label for="purge_method_get_request">
265
+ <input type="radio" value="get_request" id="purge_method_get_request" name="purge_method"<?php checked( isset( $rt_wp_nginx_helper->options['purge_method'] ) ? $rt_wp_nginx_helper->options['purge_method'] : 'get_request', 'get_request' ); ?>>
266
+ &nbsp;<?php _e( 'Using a GET request to <strong>PURGE/url</strong> (Default option)', 'nginx-helper' ); ?><br />
267
+ <small><?php _e( 'Uses the <strong><a href="https://github.com/FRiCKLE/ngx_cache_purge">ngx_cache_purge</a></strong> module. ', 'nginx-helper' ); ?></small>
268
+ </label><br />
269
+ <label for="purge_method_unlink_files">
270
+ <input type="radio" value="unlink_files" id="purge_method_unlink_files" name="purge_method"<?php checked( isset( $rt_wp_nginx_helper->options['purge_method'] ) ? $rt_wp_nginx_helper->options['purge_method'] : '', 'unlink_files' ); ?>>
271
+ &nbsp;<?php _e( 'Delete local server cache files', 'nginx-helper' ); ?><br />
272
+ <small><?php _e( 'Checks for matching cache file in <strong>RT_WP_NGINX_HELPER_CACHE_PATH</strong>. Does not require any other modules. Requires that the cache be stored on the same server as WordPress. You must also be using the default nginx cache options (levels=1:2) and (fastcgi_cache_key "$scheme$request_method$host$request_uri"). ', 'nginx-helper' ); ?></small>
273
 
274
+ </label><br />
275
+ </fieldset>
276
+ </td>
277
+ </tr>
278
+ </table>
279
+ </div> <!-- End of .inside -->
280
+ </div><?php
281
+ } // End of if ( !( !is_network_admin() && is_multisite() ) )
282
 
 
 
 
 
 
 
 
 
 
283
 
284
+ if ( is_network_admin() ) {
285
+ ?>
286
+ <div class="postbox enable_map"<?php echo ( $rt_wp_nginx_helper->options['enable_map'] == false ) ? ' style="display: none;"' : ''; ?>>
287
+ <h3 class="hndle">
288
+ <span><?php _e( 'Nginx Map', 'nginx-helper' ); ?></span>
289
+ </h3>
290
+ <div class="inside"><?php if ( !is_writable( $rt_wp_nginx_helper->functional_asset_path() . 'map.conf' ) ) { ?>
291
+ <span class="error fade" style="display: block"><p><?php printf( __( 'Can\'t write on map file.<br /><br />Check you have write permission on <strong>%s</strong>', 'nginx-helper' ), $rt_wp_nginx_helper->functional_asset_path() . 'map.conf' ); ?></p></span><?php }
292
+ ?>
 
 
 
 
 
 
 
 
293
 
294
+ <table class="form-table rtnginx-table">
295
+ <tr>
296
+ <th><?php _e( 'Nginx Map path to include in nginx settings<br /><small>(recommended)</small>', 'nginx-helper' ); ?></th>
297
+ <td>
298
+ <pre><?php echo $rt_wp_nginx_helper->functional_asset_path() . 'map.conf'; ?></pre>
299
+ </td>
300
+ </tr>
301
+ <tr>
302
+ <th><?php _e( 'Or,<br />Text to manually copy and paste in nginx settings<br /><small>(if your network is small and new sites are not added frequently)</small>', 'nginx-helper' ); ?></th>
303
+ <td>
304
+ <pre id="map"><?php echo $rt_wp_nginx_helper->get_map() ?></pre>
305
+ </td>
306
+ </tr>
307
+ </table>
308
+ </div> <!-- End of .inside -->
309
+ </div>
310
+ <?php } ?>
 
 
 
 
 
311
 
312
+ <div class="postbox enable_log"<?php echo ( $rt_wp_nginx_helper->options['enable_log'] == false ) ? ' style="display: none;"' : ''; ?>>
313
+ <h3 class="hndle">
314
+ <span><?php _e( 'Logging Options', 'nginx-helper' ); ?></span>
315
+ </h3>
316
+ <div class="inside">
317
+ <?php
318
+ $path = $rt_wp_nginx_helper->functional_asset_path();
319
+ if ( !is_dir( $path ) ) {
320
+ mkdir( $path );
321
+ }
322
+ if ( !file_exists( $path . 'nginx.log' ) ) {
323
+ $log = fopen( $path . 'nginx.log', 'w' );
324
+ fclose( $log );
325
+ }
326
+ if ( is_writable( $path . 'nginx.log' ) ) {
327
+ $rt_wp_nginx_purger->log( "+++++++++" );
328
+ $rt_wp_nginx_purger->log( "+Log Test" );
329
+ $rt_wp_nginx_purger->log( "+++++++++" );
330
+ }
331
+ if ( !is_writable( $path . 'nginx.log' ) ) {
332
+ ?>
333
+ <span class="error fade" style="display : block"><p><?php printf( __( 'Can\'t write on log file.<br /><br />Check you have write permission on <strong>%s</strong>', 'nginx-helper' ), $rt_wp_nginx_helper->functional_asset_path() . 'nginx.log' ); ?></p></span><?php }
334
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
335
 
336
+ <table class="form-table rtnginx-table">
337
+ <tbody>
338
+ <tr>
339
+ <th><label for="rt_wp_nginx_helper_logs_path"><?php _e( 'Logs path', 'nginx-helper' ); ?></label></th>
340
+ <td><pre><?php echo $rt_wp_nginx_helper->functional_asset_path(); ?>nginx.log</pre></td>
341
+ </tr>
342
+ <tr>
343
+ <th><label for="rt_wp_nginx_helper_logs_link"><?php _e( 'View Log', 'nginx-helper' ); ?></label></th>
344
+ <td><a target="_blank" href="<?php echo $rt_wp_nginx_helper->functional_asset_url(); ?>nginx.log"><?php _e( 'Log', 'nginx-helper' ); ?></a></td>
345
+ </tr>
346
+ <tr>
347
+ <th><label for="rt_wp_nginx_helper_log_level"><?php _e( 'Log level', 'nginx-helper' ); ?></label></th>
348
+ <td>
349
+ <select name="log_level">
350
+ <option value="NONE"<?php selected( $rt_wp_nginx_helper->options['log_level'], 'NONE' ); ?>><?php _e( 'None', 'nginx-helper' ); ?></option>
351
+ <option value="INFO"<?php selected( $rt_wp_nginx_helper->options['log_level'], 'INFO' ); ?>><?php _e( 'Info', 'nginx-helper' ); ?></option>
352
+ <option value="WARNING"<?php selected( $rt_wp_nginx_helper->options['log_level'], 'WARNING' ); ?>><?php _e( 'Warning', 'nginx-helper' ); ?></option>
353
+ <option value="ERROR"<?php selected( $rt_wp_nginx_helper->options['log_level'], 'ERROR' ); ?>><?php _e( 'Error', 'nginx-helper' ); ?></option>
354
+ </select>
355
+ </td>
356
+ </tr>
357
+ <tr>
358
+ <th><label for="log_filesize"><?php _e( 'Max log file size', 'nginx-helper' ); ?></label></th>
359
+ <td>
360
+ <input id="log_filesize" class="small-text" type="text" name="log_filesize" value="<?php echo $rt_wp_nginx_helper->options['log_filesize'] ?>" /> <?php _e( 'Mb', 'nginx-helper' );
361
+ if ( $error_log_filesize ) {
362
+ ?>
363
+ <p class="error fade" style="display: block;"><?php echo $error_log_filesize; ?></p><?php }
364
+ ?>
365
+ </td>
366
+ </tr>
367
+ </tbody>
368
+ </table>
369
+ </div> <!-- End of .inside -->
370
+ </div><?php submit_button( __( 'Save All Changes', 'nginx-helper' ), 'primary large', 'smart_http_expire_save', true ); ?>
371
+ </form><!-- End of #post_form --><?php
372
+ }
373
+
374
+ }
nginx-helper.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Nginx Helper
4
  Plugin URI: https://rtcamp.com/nginx-helper/
5
  Description: Cleans nginx's fastcgi/proxy cache whenever a post is edited/published. Also does few more things.
6
- Version: 1.8.12
7
  Author: rtCamp
8
  Author URI: https://rtcamp.com
9
  Text Domain: nginx-helper
3
  Plugin Name: Nginx Helper
4
  Plugin URI: https://rtcamp.com/nginx-helper/
5
  Description: Cleans nginx's fastcgi/proxy cache whenever a post is edited/published. Also does few more things.
6
+ Version: 1.8.13
7
  Author: rtCamp
8
  Author URI: https://rtcamp.com
9
  Text Domain: nginx-helper
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: rtcamp, rahul286, saurabhshukla, manishsongirkar36, faishal, desai
3
  Tags: nginx, cache, purge, nginx map, nginx cache, maps, fastcgi, proxy, rewrite, permalinks
4
  Requires at least: 3.0
5
  Tested up to: 4.2
6
- Stable tag: 1.8.12
7
  License: GPLv2 or later (of-course)
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
  Donate Link: http://rtcamp.com/donate/
@@ -113,6 +113,9 @@ Please post your problem in [our free support forum](http://community.rtcamp.com
113
 
114
  == Changelog ==
115
 
 
 
 
116
  = 1.8.12 =
117
  Updated readme and changelog
118
 
3
  Tags: nginx, cache, purge, nginx map, nginx cache, maps, fastcgi, proxy, rewrite, permalinks
4
  Requires at least: 3.0
5
  Tested up to: 4.2
6
+ Stable tag: 1.8.13
7
  License: GPLv2 or later (of-course)
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
  Donate Link: http://rtcamp.com/donate/
113
 
114
  == Changelog ==
115
 
116
+ = 1.8.13 =
117
+ Fixed PHP notice for an undefined index when "Enable Logging" is not set.
118
+
119
  = 1.8.12 =
120
  Updated readme and changelog
121
 
trunk/admin/admin.php ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace rtCamp\WP\Nginx {
4
+
5
+ class Admin {
6
+
7
+ /**
8
+ * Holds the values to be used in the fields callbacks
9
+ */
10
+ private $nginx_helper_tabs;
11
+
12
+ function __construct() {
13
+ if ( is_multisite() ) {
14
+ add_action( 'network_admin_menu', array( &$this, 'add_network_menu' ) );
15
+ } else {
16
+ add_action( 'admin_menu', array( &$this, 'add_menu' ) );
17
+ }
18
+
19
+ add_action( 'admin_init', array( $this, 'nginx_admin_page_init' ) );
20
+
21
+ /**
22
+ * Define Tabs
23
+ */
24
+ $this->nginx_helper_tabs = apply_filters( 'rt_nginx_helper_tabs', array(
25
+ 'general' => array(
26
+ 'menu_title' => __( 'General', 'nginx-helper' ),
27
+ 'menu_slug' => 'general'
28
+ ),
29
+ 'support' => array(
30
+ 'menu_title' => __( 'Support', 'nginx-helper' ),
31
+ 'menu_slug' => 'support'
32
+ ) )
33
+ );
34
+ }
35
+
36
+ /**
37
+ * Add setting sub-menu for single site
38
+ */
39
+ function add_menu() {
40
+ add_submenu_page( 'options-general.php', __( 'Nginx Helper', 'nginx-helper' ), __( 'Nginx Helper', 'nginx-helper' ), 'manage_options', 'nginx', array( &$this, 'nginx_create_admin_page' ) );
41
+ }
42
+
43
+ /**
44
+ * Add setting sub-menu for multi site
45
+ */
46
+ function add_network_menu() {
47
+ add_submenu_page( 'settings.php', __( 'Nginx Helper', 'nginx-helper' ), __( 'Nginx Helper', 'nginx-helper' ), 'manage_options', 'nginx', array( &$this, 'nginx_create_admin_page' ) );
48
+ }
49
+
50
+ /**
51
+ * Create tab with links
52
+ *
53
+ * @param type $current current tab
54
+ */
55
+ function nginx_admin_page_tabs( $current = 'general' ) {
56
+ echo '<h2 class="nav-tab-wrapper">';
57
+ foreach ( $this->nginx_helper_tabs as $tab => $name ) {
58
+ $class = ( $tab == $current ) ? ' nav-tab-active' : '';
59
+ echo '<a class="nav-tab' . $class . '" href="?page=nginx&tab=' . $name['menu_slug'] . '">' . $name['menu_title'] . '</a>';
60
+ }
61
+ echo '</h2>';
62
+ }
63
+
64
+ /**
65
+ * Options page callback
66
+ */
67
+ function nginx_create_admin_page() {
68
+ global $pagenow;
69
+
70
+ /**
71
+ * Includes PHP files located in 'admin/lib/' folder
72
+ */
73
+ foreach (glob(plugin_dir_path(__FILE__) . "lib/*.php") as $lib_filename) {
74
+ require_once( $lib_filename );
75
+ } ?>
76
+
77
+ <div class="wrap rt-nginx-wrapper">
78
+ <h2 class="rt_option_title"><?php _e( 'Nginx Settings', 'nginx-helper' ); ?></h2>
79
+ <div id="poststuff">
80
+ <div id="post-body" class="metabox-holder columns-2">
81
+ <div id="post-body-content"><?php
82
+
83
+ /* Show Tabs */
84
+ if ( ( 'options-general.php' == $pagenow || 'settings.php' == $pagenow ) && isset( $_GET['tab'] ) ) {
85
+ $this->nginx_admin_page_tabs( $_GET['tab'] );
86
+ } else {
87
+ $this->nginx_admin_page_tabs( 'general' );
88
+ }
89
+
90
+ /* Fetch Page Content */
91
+ $current = isset( $_GET['tab'] ) ? $_GET['tab'] : 'general';
92
+ if ( ( 'options-general.php' == $pagenow || 'settings.php' == $pagenow ) && isset( $_GET['page'] ) ) {
93
+ switch ( $current ) {
94
+ case 'general' :
95
+ nginx_general_options_page();
96
+ break;
97
+ case 'support' :
98
+ nginx_support_options_page();
99
+ break;
100
+ }
101
+ } ?>
102
+ </div> <!-- End of #post-body-content -->
103
+ <div id="postbox-container-1" class="postbox-container"><?php
104
+ default_admin_sidebar(); ?>
105
+ </div> <!-- End of #postbox-container-1 -->
106
+ </div> <!-- End of #post-body -->
107
+ </div> <!-- End of #poststuff -->
108
+ </div> <!-- End of .wrap .rt-nginx-wrapper -->
109
+ <?php
110
+ }
111
+
112
+ function nginx_admin_page_init() {
113
+ add_action( 'admin_enqueue_scripts', array( $this, 'nginx_admin_enqueue_assets' ), 999 );
114
+ add_action( 'admin_bar_menu', array( &$this, 'nginx_toolbar_purge_item' ), 100 );
115
+ }
116
+
117
+ function nginx_toolbar_purge_item( $admin_bar ) {
118
+ if ( !current_user_can( 'manage_options' ) ) {
119
+ return;
120
+ }
121
+ $purge_url = esc_url( add_query_arg( array( 'nginx_helper_action' => 'purge', 'nginx_helper_urls' => 'all' ) ) );
122
+ $nonced_url = wp_nonce_url( $purge_url, 'nginx_helper-purge_all' );
123
+ $admin_bar->add_menu( array( 'id' => 'nginx-helper-purge-all', 'title' => __( 'Purge Cache', 'nginx-helper' ), 'href' => $nonced_url, 'meta' => array( 'title' => __( 'Purge Cache', 'nginx-helper' ), ), ) );
124
+ }
125
+
126
+ function nginx_admin_enqueue_assets($hook) {
127
+ if ( 'settings_page_nginx' != $hook ) {
128
+ return;
129
+ }
130
+
131
+ /* Load Plugin CSS */
132
+ wp_enqueue_style('rt-nginx-admin-icon', plugin_dir_url(__FILE__) . 'assets/nginx-helper-icons/css/nginx-fontello.css');
133
+ wp_enqueue_style('rt-nginx-admin-css', plugin_dir_url(__FILE__) . 'assets/style.css');
134
+
135
+ /* Load Plugin Scripts */
136
+ $admin_js = trailingslashit( site_url() ) . '?get_feeds=1';
137
+ wp_enqueue_script( 'nginx-js', plugin_dir_url( __FILE__ ) . 'assets/nginx.js', '', '', true );
138
+ wp_localize_script( 'nginx-js', 'news_url', $admin_js );
139
+ }
140
+ }
141
+ }
trunk/admin/assets/logo.png ADDED
Binary file
trunk/admin/assets/nginx-helper-icons/config.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "nginx-fontello",
3
+ "css_prefix_text": "nginx-helper-",
4
+ "css_use_suffix": false,
5
+ "hinting": true,
6
+ "units_per_em": 1000,
7
+ "ascent": 850,
8
+ "glyphs": [
9
+ {
10
+ "uid": "72b1277834cba5b7944b0a6cac7ddb0d",
11
+ "css": "rss",
12
+ "code": 59395,
13
+ "src": "fontawesome"
14
+ },
15
+ {
16
+ "uid": "627abcdb627cb1789e009c08e2678ef9",
17
+ "css": "twitter",
18
+ "code": 59394,
19
+ "src": "fontawesome"
20
+ },
21
+ {
22
+ "uid": "bc50457410acf467b8b5721240768742",
23
+ "css": "facebook",
24
+ "code": 59393,
25
+ "src": "entypo"
26
+ },
27
+ {
28
+ "uid": "b945f4ac2439565661e8e4878e35d379",
29
+ "css": "gplus",
30
+ "code": 59392,
31
+ "src": "entypo"
32
+ }
33
+ ]
34
+ }
trunk/admin/assets/nginx-helper-icons/css/nginx-fontello.css ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @font-face {
2
+ font-family: 'nginx-fontello';
3
+ src: url('../font/nginx-fontello.eot?7388141');
4
+ src: url('../font/nginx-fontello.eot?7388141#iefix') format('embedded-opentype'),
5
+ url('../font/nginx-fontello.woff?7388141') format('woff'),
6
+ url('../font/nginx-fontello.ttf?7388141') format('truetype'),
7
+ url('../font/nginx-fontello.svg?7388141#nginx-fontello') format('svg');
8
+ font-weight: normal;
9
+ font-style: normal;
10
+ }
11
+ /* Chrome hack: SVG is rendered more smooth in Windozze. 100% magic, uncomment if you need it. */
12
+ /* Note, that will break hinting! In other OS-es font will be not as sharp as it could be */
13
+ /*
14
+ @media screen and (-webkit-min-device-pixel-ratio:0) {
15
+ @font-face {
16
+ font-family: 'nginx-fontello';
17
+ src: url('../font/nginx-fontello.svg?7388141#nginx-fontello') format('svg');
18
+ }
19
+ }
20
+ */
21
+
22
+ [class^="nginx-helper-"]:before, [class*=" nginx-helper-"]:before {
23
+ font-family: "nginx-fontello";
24
+ font-style: normal;
25
+ font-weight: normal;
26
+ speak: none;
27
+
28
+ display: inline-block;
29
+ text-decoration: inherit;
30
+ width: 1em;
31
+ margin-right: .2em;
32
+ text-align: center;
33
+ /* opacity: .8; */
34
+
35
+ /* For safety - reset parent styles, that can break glyph codes*/
36
+ font-variant: normal;
37
+ text-transform: none;
38
+
39
+ /* fix buttons height, for twitter bootstrap */
40
+ line-height: 1em;
41
+
42
+ /* Animation center compensation - margins should be symmetric */
43
+ /* remove if not needed */
44
+ margin-left: .2em;
45
+
46
+ /* you can be more comfortable with increased icons size */
47
+ /* font-size: 120%; */
48
+
49
+ /* Uncomment for 3D effect */
50
+ /* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */
51
+ }
52
+
53
+ .nginx-helper-rss:before { content: '\e803'; } /* '' */
54
+ .nginx-helper-twitter:before { content: '\e802'; } /* '' */
55
+ .nginx-helper-facebook:before { content: '\e801'; } /* '' */
56
+ .nginx-helper-gplus:before { content: '\e800'; } /* '' */
trunk/admin/assets/nginx-helper-icons/font/nginx-fontello.eot ADDED
Binary file
trunk/admin/assets/nginx-helper-icons/font/nginx-fontello.svg ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
+ <svg xmlns="http://www.w3.org/2000/svg">
4
+ <metadata>Copyright (C) 2013 by original authors @ fontello.com</metadata>
5
+ <defs>
6
+ <font id="nginx-fontello" horiz-adv-x="1000" >
7
+ <font-face font-family="nginx-fontello" font-weight="400" font-stretch="normal" units-per-em="1000" ascent="850" descent="-150" />
8
+ <missing-glyph horiz-adv-x="1000" />
9
+ <glyph glyph-name="rss" unicode="&#xe803;" d="m214 100q0-45-31-76t-76-31t-76 31t-31 76t31 76t76 31t76-31t31-76z m286-69q1-15-9-26q-11-12-27-12h-75q-14 0-24 9t-11 23q-12 128-103 219t-219 103q-14 1-23 11t-9 24v75q0 16 12 26q9 10 24 10h3q89-7 170-45t145-101q63-63 101-145t45-171z m286-1q1-15-10-26q-10-11-26-11h-80q-14 0-25 10t-11 23q-6 120-56 228t-129 188t-188 129t-227 57q-14 0-24 11t-10 24v80q0 15 11 26q10 10 25 10h1q147-8 280-67t238-164q104-104 164-238t67-280z" horiz-adv-x="785.7" />
10
+ <glyph glyph-name="twitter" unicode="&#xe802;" d="m904 622q-37-54-90-93q0-8 0-23q0-73-21-145t-64-139t-103-117t-144-82t-181-30q-151 0-276 81q19-3 43-3q126 0 224 77q-59 2-105 36t-64 89q19-2 34-2q24 0 48 6q-63 13-104 62t-41 115v2q38-21 82-23q-37 25-59 64t-22 86q0 49 25 91q68-83 164-133t208-55q-5 21-5 41q0 75 53 127t127 53q79 0 132-57q61 12 114 44q-20-64-79-100q52 6 104 28z" horiz-adv-x="928.6" />
11
+ <glyph glyph-name="facebook" unicode="&#xe801;" d="m500 644l-142 0q-14 0-25-15t-11-37l0-102l178 0l0-148l-178 0l0-442l-170 0l0 442l-152 0l0 148l152 0l0 86q0 94 59 159t147 65l142 0l0-156z" horiz-adv-x="500" />
12
+ <glyph glyph-name="gplus" unicode="&#xe800;" d="m48 572q0 58 25 102t56 65t69 34t56 15t26 2l230 0l0-4q0-22-78-36q-28 0-38-6q40-20 54-56t14-96q0-102-68-158q-38-38-38-54q0-18 50-64q104-90 104-178q0-140-116-194q-68-34-150-34l-4 0l-4 2q-2-2-4-2q-24 0-54 5t-75 21t-74 57t-29 103q0 60 32 101t83 57t88 22t71 6l2 0q-16 22-24 47t-8 39l2 14l-14 0q-64 0-110 30q-74 44-74 160z m370-452q-4 52-43 84t-103 32l-16 0q-64-2-114-46q-46-42-42-94t53-80t119-24q68 4 109 40t37 88z m-60 500q-30 108-122 108q-12 0-20-2q-40-12-58-62q-16-50-2-106q14-52 47-85t71-33q12 0 18 2q42 12 63 65t3 113z m388-174l150 0l0-94l-150 0l0-150l-94 0l0 150l-150 0l0 94l150 0l0 150l94 0l0-150z" horiz-adv-x="896" />
13
+ </font>
14
+ </defs>
15
+ </svg>
trunk/admin/assets/nginx-helper-icons/font/nginx-fontello.ttf ADDED
Binary file
trunk/admin/assets/nginx-helper-icons/font/nginx-fontello.woff ADDED
Binary file
trunk/admin/assets/nginx-icon-32x32.png ADDED
Binary file
trunk/admin/assets/nginx.js ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function() {
2
+ var news_section = jQuery('#latest_news');
3
+ if (news_section.length > 0) {
4
+ jQuery.get(news_url, function(data) {
5
+ news_section.find('.inside').html(data);
6
+ });
7
+ }
8
+
9
+ /**
10
+ * Show OR Hide options on option checkbox
11
+ * @param {type} selector Selector of Checkbox and PostBox
12
+ */
13
+ function nginx_show_option( selector ) {
14
+ jQuery( '#'+selector ).on( 'change', function (){
15
+ if ( jQuery(this).is( ':checked' ) ) {
16
+ jQuery( '.'+selector ).show();
17
+ } else {
18
+ jQuery( '.'+selector ).hide();
19
+ }
20
+ } );
21
+ }
22
+ /* Function call with parameter */
23
+ nginx_show_option( 'enable_purge' );
24
+ nginx_show_option( 'enable_map' );
25
+ nginx_show_option( 'enable_log' );
26
+ });
trunk/admin/assets/rtp-social-icons-32-32.png ADDED
Binary file
trunk/admin/assets/style.css ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .clearfix { *zoom: 1; }
2
+ .clearfix:before, .clearfix:after { content: " "; display: table; }
3
+ .clearfix:after { clear: both; }
4
+ h4 { margin: 0; }
5
+ .form-table th, .form-wrap label { vertical-align: middle; }
6
+ table.rtnginx-table { border-bottom: 1px solid #EEE; }
7
+ table.rtnginx-table:last-child { border-bottom: 0; }
8
+ .rtnginx-table p.error { color: red; }
9
+ pre#map { background: #e5e5e5 none; border-radius: 10px; padding: 10px; }
10
+ .wrap h2.rt_option_title { background: url(nginx-icon-32x32.png) 0 6px no-repeat rgba(0, 0, 0, 0); padding-left: 40px; }
11
+ #poststuff h2 { padding: 0 0 0 10px; margin-top: 0; }
12
+ form#purgeall .button-primary { box-shadow: inset 0 -2px rgba(0, 0, 0, 0.14);padding: 15px 30px;font-size: 1rem;border: 0;border-radius: 5px;color: #FFF;background: #DD3D36; height: auto; }
13
+ form#purgeall .button-primary:hover, form#purgeall .button-primary:focus { background: #d52c24; }
14
+ .nh-aligncenter { display: block; text-align: center; line-height: 2; }
15
+ #latest_news .inside ul, #useful-links .inside ul { margin: 0 0 0 12px }
16
+ #latest_news .inside ul li, #useful-links .inside ul li { list-style: square; padding: 0 0 7px; }
17
+ #social .inside a { background-color: #666;color: #FFF;display: inline-block;height: 30px;font-size: 1.25rem;line-height: 30px;margin: 10px 20px 0 0;overflow: hidden;padding: 0;text-align: center;text-decoration: none;width: 30px;-webkit-border-radius: 1000px;-moz-border-radius: 1000px;border-radius: 1000px; }
18
+ #social .inside .nginx-helper-rss:hover { background-color: #FAA33D; }
19
+ #social .inside .nginx-helper-facebook:hover { background-color: #537BBD; }
20
+ #social .inside .nginx-helper-twitter:hover { background-color: #40BFF5; }
21
+ #social .inside .nginx-helper-gplus:hover { background-color: #DD4B39; }
trunk/admin/install.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author: Saurabh Shukla <saurabh.shukla@rtcamp.com>
4
+ *
5
+ * Parts of code based off http://wordpress.org/extend/plugins/nginx-manager/ by http://profiles.wordpress.org/hpatoio/ and http://profiles.wordpress.org/rukbat/
6
+ */
7
+ namespace rtCamp\WP\Nginx {
8
+ if ( preg_match( '#' . basename( __FILE__ ) . '#', $_SERVER[ 'PHP_SELF' ] ) ) {
9
+ die( 'You are not allowed to call this page directly.' );
10
+ }
11
+
12
+ function rt_wp_nginx_helper_install() {
13
+ global $wp_roles, $rt_wp_nginx_helper;
14
+
15
+ if ( ! current_user_can( 'activate_plugins' ) ) {
16
+ return;
17
+ }
18
+
19
+ $role = get_role( 'administrator' );
20
+
21
+ if ( empty( $role ) ) {
22
+ update_site_option( "rt_wp_nginx_helper_init_check", __( 'Sorry, you need to be an administrator to use Nginx Helper', 'nginx-helper' ) );
23
+ return;
24
+ }
25
+
26
+ $role->add_cap( 'Nginx Helper | Config' );
27
+ $role->add_cap( 'Nginx Helper | Purge cache' );
28
+
29
+ $rt_wp_nginx_helper_get_options = get_site_option( 'rt_wp_nginx_helper_global_options' );
30
+
31
+ if ( empty( $rt_wp_nginx_helper_get_options ) ) {
32
+ $rt_wp_nginx_helper_get_options = rt_wp_nginx_helper_get_options();
33
+ update_site_option( "rt_wp_nginx_helper_global_options", $rt_wp_nginx_helper_get_options );
34
+ }
35
+
36
+ if ( is_multisite() ) {
37
+ $blogs = get_blogs_of_user( true );
38
+ foreach ( $blogs as $b ) {
39
+ $rt_wp_nginx_helper_options = get_blog_option( $b->userblog_id, 'rt_wp_nginx_helper_options' );
40
+ if ( empty( $rt_wp_nginx_helper_options ) ) {
41
+ $rt_wp_nginx_helper_options = rt_wp_nginx_helper_get_options();
42
+ update_blog_option( $b->userblog_id, "rt_wp_nginx_helper_options", $rt_wp_nginx_helper_options );
43
+ }
44
+ }
45
+ } else {
46
+ $rt_wp_nginx_helper_options = get_option( 'rt_wp_nginx_helper_options' );
47
+ if ( empty( $rt_wp_nginx_helper_options ) ) {
48
+ $rt_wp_nginx_helper_options = rt_wp_nginx_helper_get_options();
49
+ update_option( "rt_wp_nginx_helper_options", $rt_wp_nginx_helper_options );
50
+ }
51
+ }
52
+ wp_schedule_event( time(), 'daily', 'rt_wp_nginx_helper_check_log_file_size_daily' );
53
+ }
54
+
55
+ function rt_wp_nginx_helper_uninstall() {
56
+ wp_clear_scheduled_hook( 'rt_wp_nginx_helper_check_log_file_size_daily' );
57
+ delete_site_option( 'rt_wp_nginx_helper_options' );
58
+ rt_wp_nginx_helper_remove_capability( 'Nginx Helper | Config' );
59
+ rt_wp_nginx_helper_remove_capability( 'Nginx Helper | Purge cache' );
60
+ }
61
+
62
+ function rt_wp_nginx_helper_remove_capability( $capability ) {
63
+ $check_order = array( "subscriber", "contributor", "author", "editor", "administrator" );
64
+
65
+ foreach ( $check_order as $role ) {
66
+ $role = get_role( $role );
67
+ $role->remove_cap( $capability );
68
+ }
69
+ }
70
+
71
+ function rt_wp_nginx_helper_get_options() {
72
+ $rt_wp_nginx_helper_get_options = array( );
73
+ $rt_wp_nginx_helper_get_options[ 'log_level' ] = 'INFO';
74
+ $rt_wp_nginx_helper_get_options[ 'log_filesize' ] = 5;
75
+
76
+ $rt_wp_nginx_helper_get_options[ 'enable_purge' ] = 0;
77
+ $rt_wp_nginx_helper_get_options[ 'enable_map' ] = 0;
78
+ $rt_wp_nginx_helper_get_options[ 'enable_log' ] = 0;
79
+ $rt_wp_nginx_helper_get_options[ 'enable_stamp' ] = 0;
80
+
81
+ $rt_wp_nginx_helper_get_options[ 'purge_homepage_on_new' ] = 1;
82
+ $rt_wp_nginx_helper_get_options[ 'purge_homepage_on_edit' ] = 1;
83
+ $rt_wp_nginx_helper_get_options[ 'purge_homepage_on_del' ] = 1;
84
+
85
+ $rt_wp_nginx_helper_get_options[ 'purge_archive_on_new' ] = 1;
86
+ $rt_wp_nginx_helper_get_options[ 'purge_archive_on_edit' ] = 1;
87
+ $rt_wp_nginx_helper_get_options[ 'purge_archive_on_del' ] = 1;
88
+
89
+ $rt_wp_nginx_helper_get_options[ 'purge_archive_on_new_comment' ] = 0;
90
+ $rt_wp_nginx_helper_get_options[ 'purge_archive_on_deleted_comment' ] = 0;
91
+
92
+ $rt_wp_nginx_helper_get_options[ 'purge_page_on_mod' ] = 1;
93
+ $rt_wp_nginx_helper_get_options[ 'purge_page_on_new_comment' ] = 1;
94
+ $rt_wp_nginx_helper_get_options[ 'purge_page_on_deleted_comment' ] = 1;
95
+
96
+ return $rt_wp_nginx_helper_get_options;
97
+ }
98
+ }
trunk/admin/lib/nginx-general.php ADDED
@@ -0,0 +1,374 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace rtCamp\WP\Nginx {
4
+
5
+ function nginx_general_options_page() {
6
+ global $rt_wp_nginx_helper, $rt_wp_nginx_purger;
7
+
8
+ $update = 0;
9
+ $error_time = false;
10
+ $error_log_filesize = false;
11
+ $rt_wp_nginx_helper->options['enable_purge'] = (isset( $_POST['enable_purge'] ) and ( $_POST['enable_purge'] == 1) ) ? 1 : 0;
12
+ $rt_wp_nginx_helper->options['enable_map'] = (isset( $_POST['enable_map'] ) and ( $_POST['enable_map'] == 1) ) ? 1 : 0;
13
+ $rt_wp_nginx_helper->options['enable_log'] = (isset( $_POST['enable_log'] ) and ( $_POST['enable_log'] == 1) ) ? 1 : 0;
14
+ $rt_wp_nginx_helper->options['enable_stamp'] = (isset( $_POST['enable_stamp'] ) and ( $_POST['enable_stamp'] == 1) ) ? 1 : 0;
15
+
16
+ if ( isset( $_POST['is_submit'] ) && ( $_POST['is_submit'] == 1 ) ) {
17
+ if ( !(!is_network_admin() && is_multisite() ) ) {
18
+ if ( $rt_wp_nginx_helper->options['enable_log'] ) {
19
+ if ( isset( $_POST['log_level'] ) && !empty( $_POST['log_level'] ) && $_POST['log_level'] != '' ) {
20
+ $rt_wp_nginx_helper->options['log_level'] = $_POST['log_level'];
21
+ } else {
22
+ $rt_wp_nginx_helper->options['log_level'] = 'INFO';
23
+ }
24
+ if ( isset( $_POST['log_filesize'] ) && !empty( $_POST['log_filesize'] ) && $_POST['log_filesize'] != '' ) {
25
+ if ( (!is_numeric( $_POST['log_filesize'] ) ) || ( empty( $_POST['log_filesize'] ) ) ) {
26
+ $error_log_filesize = __( 'Log file size must be a number', 'nginx-helper' );
27
+ } else {
28
+ $rt_wp_nginx_helper->options['log_filesize'] = $_POST['log_filesize'];
29
+ }
30
+ } else {
31
+ $rt_wp_nginx_helper->options['log_filesize'] = 5;
32
+ }
33
+ }
34
+ if ( $rt_wp_nginx_helper->options['enable_map'] ) {
35
+ $rt_wp_nginx_helper->update_map();
36
+ }
37
+ }
38
+ if ( isset( $_POST['enable_purge'] ) ) {
39
+ $rt_wp_nginx_helper->options['purge_homepage_on_edit'] = ( isset( $_POST['purge_homepage_on_edit'] ) and ( $_POST['purge_homepage_on_edit'] == 1 ) ) ? 1 : 0;
40
+ $rt_wp_nginx_helper->options['purge_homepage_on_del'] = ( isset( $_POST['purge_homepage_on_del'] ) and ( $_POST['purge_homepage_on_del'] == 1 ) ) ? 1 : 0;
41
+
42
+ $rt_wp_nginx_helper->options['purge_archive_on_edit'] = ( isset( $_POST['purge_archive_on_edit'] ) and ( $_POST['purge_archive_on_edit'] == 1 ) ) ? 1 : 0;
43
+ $rt_wp_nginx_helper->options['purge_archive_on_del'] = ( isset( $_POST['purge_archive_on_del'] ) and ( $_POST['purge_archive_on_del'] == 1 ) ) ? 1 : 0;
44
+
45
+ $rt_wp_nginx_helper->options['purge_archive_on_new_comment'] = ( isset( $_POST['purge_archive_on_new_comment'] ) and ( $_POST['purge_archive_on_new_comment'] == 1 ) ) ? 1 : 0;
46
+ $rt_wp_nginx_helper->options['purge_archive_on_deleted_comment'] = ( isset( $_POST['purge_archive_on_deleted_comment'] ) and ( $_POST['purge_archive_on_deleted_comment'] == 1 ) ) ? 1 : 0;
47
+
48
+ $rt_wp_nginx_helper->options['purge_page_on_mod'] = ( isset( $_POST['purge_page_on_mod'] ) and ( $_POST['purge_page_on_mod'] == 1 ) ) ? 1 : 0;
49
+ $rt_wp_nginx_helper->options['purge_page_on_new_comment'] = ( isset( $_POST['purge_page_on_new_comment'] ) and ( $_POST['purge_page_on_new_comment'] == 1 ) ) ? 1 : 0;
50
+ $rt_wp_nginx_helper->options['purge_page_on_deleted_comment'] = ( isset( $_POST['purge_page_on_deleted_comment'] ) and ( $_POST['purge_page_on_deleted_comment'] == 1 ) ) ? 1 : 0;
51
+
52
+ $rt_wp_nginx_helper->options['purge_method'] = ( isset( $_POST['purge_method'] ) ) ? $_POST['purge_method'] : 'get_request';
53
+ }
54
+ update_site_option( 'rt_wp_nginx_helper_options', $rt_wp_nginx_helper->options );
55
+ $update = 1;
56
+ }
57
+ $rt_wp_nginx_helper->options = get_site_option( 'rt_wp_nginx_helper_options' );
58
+
59
+ /**
60
+ * Show Update Message
61
+ */
62
+ if ( isset( $_POST['smart_http_expire_save'] ) ) {
63
+ echo '<div class="updated"><p>' . __( 'Settings saved.', 'nginx-helper' ) . '</p></div>';
64
+ }
65
+
66
+ /**
67
+ * Check for single multiple with subdomain OR multiple with subdirectory site
68
+ */
69
+ $nginx_setting_link = '#';
70
+ if ( is_multisite() ) {
71
+ if ( SUBDOMAIN_INSTALL == false ) {
72
+ $nginx_setting_link = 'https://rtcamp.com/wordpress-nginx/tutorials/multisite/subdirectories/fastcgi-cache-with-purging/';
73
+ } else {
74
+ $nginx_setting_link = 'https://rtcamp.com/wordpress-nginx/tutorials/multisite/subdomains/fastcgi-cache-with-purging/';
75
+ }
76
+ } else {
77
+ $nginx_setting_link = 'https://rtcamp.com/wordpress-nginx/tutorials/single-site/fastcgi-cache-with-purging/';
78
+ }
79
+ ?>
80
+ <div class="postbox">
81
+ <h3 class="hndle">
82
+ <span><?php _e( 'Purge Cache', 'nginx-helper' ); ?></span>
83
+ </h3>
84
+ <form id="purgeall" action="" method="post" class="clearfix">
85
+ <div class="inside">
86
+ <?php $purge_url = add_query_arg( array( 'nginx_helper_action' => 'purge', 'nginx_helper_urls' => 'all' ) ); ?>
87
+ <?php $nonced_url = wp_nonce_url( $purge_url, 'nginx_helper-purge_all' ); ?>
88
+ <table class="form-table">
89
+ <tr valign="top">
90
+ <th><?php _e( 'Purge All Cache', 'nginx-helper' ); ?></th>
91
+ <td>
92
+ <a href="<?php echo $nonced_url; ?>" class="button-primary"><?php _e( 'Purge Cache', 'nginx-helper' ); ?></a>
93
+ </td>
94
+ </tr>
95
+ </table>
96
+ </div>
97
+ </form>
98
+ </div> <!-- End of .postbox -->
99
+ <form id="post_form" method="post" action="#" name="smart_http_expire_form" class="clearfix">
100
+ <div class="postbox">
101
+ <h3 class="hndle">
102
+ <span><?php _e( 'Plugin Options', 'nginx-helper' ); ?></span>
103
+ </h3>
104
+ <?php if ( !(!is_network_admin() && is_multisite() ) ) { ?>
105
+ <div class="inside">
106
+ <input type="hidden" name="is_submit" value="1" />
107
+ <table class="form-table">
108
+ <tr valign="top">
109
+ <td>
110
+ <input type="checkbox" value="1" id="enable_purge" name="enable_purge" <?php checked( $rt_wp_nginx_helper->options['enable_purge'], 1 ); ?> />
111
+ <label for="enable_purge">
112
+ <?php printf( __( 'Enable Cache Purge (<a target="_blank" href="%s" title="External settings for nginx">requires external settings for nginx</a>)', 'nginx-helper' ), $nginx_setting_link ); ?>
113
+ </label>
114
+ </td>
115
+ </tr>
116
+ <?php if ( is_network_admin() ) { ?>
117
+ <tr valign="top">
118
+ <td>
119
+ <input type="checkbox" value="1" id="enable_map" name="enable_map"<?php checked( $rt_wp_nginx_helper->options['enable_map'], 1 ); ?> />
120
+ <label for="enable_map"><?php _e( 'Enable Nginx Map.', 'nginx-helper' ); ?></label>
121
+ </td>
122
+ </tr>
123
+ <?php } ?>
124
+ <tr valign="top">
125
+ <td>
126
+ <input type="checkbox" value="1" id="enable_log" name="enable_log"<?php checked( $rt_wp_nginx_helper->options['enable_log'], 1 ); ?> />
127
+ <label for="enable_log"><?php _e( 'Enable Logging', 'nginx-helper' ); ?></label>
128
+ </td>
129
+ </tr>
130
+ <tr valign="top">
131
+ <td>
132
+ <input type="checkbox" value="1" id="enable_stamp" name="enable_stamp"<?php checked( $rt_wp_nginx_helper->options['enable_stamp'], 1 ); ?> />
133
+ <label for="enable_stamp"><?php _e( 'Enable Nginx Timestamp in HTML', 'nginx-helper' ); ?></label>
134
+ </td>
135
+ </tr>
136
+ </table>
137
+ </div> <!-- End of .inside -->
138
+ </div>
139
+
140
+ <div class="postbox enable_purge"<?php echo ( $rt_wp_nginx_helper->options['enable_purge'] == false ) ? ' style="display: none;"' : ''; ?>>
141
+ <h3 class="hndle">
142
+ <span><?php _e( 'Purging Options', 'nginx-helper' ); ?></span>
143
+ </h3>
144
+ <div class="inside">
145
+
146
+ <table class="form-table rtnginx-table">
147
+ <tr valign="top">
148
+ <th scope="row"><h4><?php _e( 'Purge Homepage:', 'nginx-helper' ); ?></h4></th>
149
+ <td>
150
+ <fieldset>
151
+ <legend class="screen-reader-text">
152
+ <span>&nbsp;<?php _e( 'when a post/page/custom post is modified or added.', 'nginx-helper' ); ?></span>
153
+ </legend>
154
+ <label for="purge_homepage_on_edit">
155
+ <input type="checkbox" value="1" id="purge_homepage_on_edit" name="purge_homepage_on_edit"<?php checked( $rt_wp_nginx_helper->options['purge_homepage_on_edit'], 1 ); ?> />
156
+ &nbsp;<?php _e( 'when a <strong>post</strong> (or page/custom post) is <strong>modified</strong> or <strong>added</strong>.', 'nginx-helper' ); ?>
157
+ </label><br />
158
+ </fieldset>
159
+ <fieldset>
160
+ <legend class="screen-reader-text">
161
+ <span>&nbsp;<?php _e( 'when an existing post/page/custom post is modified.', 'nginx-helper' ); ?></span>
162
+ </legend>
163
+ <label for="purge_homepage_on_del">
164
+ <input type="checkbox" value="1" id="purge_homepage_on_del" name="purge_homepage_on_del"<?php checked( $rt_wp_nginx_helper->options['purge_homepage_on_del'], 1 ); ?> />
165
+ &nbsp;<?php _e( 'when a <strong>published post</strong> (or page/custom post) is <strong>trashed</strong>.', 'nginx-helper' ); ?></label><br />
166
+ </fieldset>
167
+ </td>
168
+ </tr>
169
+ </table>
170
+ <table class="form-table rtnginx-table">
171
+ <tr valign="top">
172
+ <th scope="row">
173
+ <h4><?php _e( 'Purge Post/Page/Custom Post Type:', 'nginx-helper' ); ?></h4>
174
+ </th>
175
+ <td>
176
+ <fieldset>
177
+ <legend class="screen-reader-text">
178
+ <span>&nbsp;<?php _e( 'when a post/page/custom post is published.', 'nginx-helper' ); ?></span>
179
+ </legend>
180
+ <label for="purge_page_on_mod">
181
+ <input type="checkbox" value="1" id="purge_page_on_mod" name="purge_page_on_mod"<?php checked( $rt_wp_nginx_helper->options['purge_page_on_mod'], 1 ); ?>>
182
+ &nbsp;<?php _e( 'when a <strong>post</strong> is <strong>published</strong>.', 'nginx-helper' ); ?>
183
+ </label><br />
184
+ </fieldset>
185
+ <fieldset>
186
+ <legend class="screen-reader-text">
187
+ <span>&nbsp;<?php _e( 'when a comment is approved/published.', 'nginx-helper' ); ?></span>
188
+ </legend>
189
+ <label for="purge_page_on_new_comment">
190
+ <input type="checkbox" value="1" id="purge_page_on_new_comment" name="purge_page_on_new_comment"<?php checked( $rt_wp_nginx_helper->options['purge_page_on_new_comment'], 1 ); ?>>
191
+ &nbsp;<?php _e( 'when a <strong>comment</strong> is <strong>approved/published</strong>.', 'nginx-helper' ); ?>
192
+ </label><br />
193
+ </fieldset>
194
+ <fieldset>
195
+ <legend class="screen-reader-text">
196
+ <span>&nbsp;<?php _e( 'when a comment is unapproved/deleted.', 'nginx-helper' ); ?></span>
197
+ </legend>
198
+ <label for="purge_page_on_deleted_comment">
199
+ <input type="checkbox" value="1" id="purge_page_on_deleted_comment" name="purge_page_on_deleted_comment"<?php checked( $rt_wp_nginx_helper->options['purge_page_on_deleted_comment'], 1 ); ?>>
200
+ &nbsp;<?php _e( 'when a <strong>comment</strong> is <strong>unapproved/deleted</strong>.', 'nginx-helper' ); ?>
201
+ </label><br />
202
+ </fieldset>
203
+ </td>
204
+ </tr>
205
+ </table>
206
+ <table class="form-table rtnginx-table">
207
+ <tr valign="top">
208
+ <th scope="row">
209
+ <h4><?php _e( 'Purge Archives:', 'nginx-helper' ); ?></h4>
210
+ <small><?php _e( '(date, category, tag, author, custom taxonomies)', 'nginx-helper' ); ?></small>
211
+ </th>
212
+ <td>
213
+ <fieldset>
214
+ <legend class="screen-reader-text">
215
+ <span>&nbsp;<?php _e( 'when an post/page/custom post is modified or added.</span>', 'nginx-helper' ); ?>
216
+ </legend>
217
+ <label for="purge_archive_on_edit">
218
+ <input type="checkbox" value="1" id="purge_archive_on_edit" name="purge_archive_on_edit"<?php checked( $rt_wp_nginx_helper->options['purge_archive_on_edit'], 1 ); ?> />
219
+ &nbsp;<?php _e( 'when a <strong>post</strong> (or page/custom post) is <strong>modified</strong> or <strong>added</strong>.', 'nginx-helper' ); ?>
220
+ </label><br />
221
+ </fieldset>
222
+ <fieldset>
223
+ <legend class="screen-reader-text">
224
+ <span>&nbsp;<?php _e( 'when an existing post/page/custom post is trashed.</span>', 'nginx-helper' ); ?>
225
+ </legend>
226
+ <label for="purge_archive_on_del">
227
+ <input type="checkbox" value="1" id="purge_archive_on_del" name="purge_archive_on_del"<?php checked( $rt_wp_nginx_helper->options['purge_archive_on_del'], 1 ); ?> />
228
+ &nbsp;<?php _e( 'when a <strong>published post</strong> (or page/custom post) is <strong>trashed</strong>.', 'nginx-helper' ); ?>
229
+ </label><br />
230
+ </fieldset>
231
+ <br />
232
+ <fieldset>
233
+ <legend class="screen-reader-text">
234
+ <span>&nbsp;<?php _e( 'when a comment is approved/published.</span>', 'nginx-helper' ); ?>
235
+ </legend>
236
+ <label for="purge_archive_on_new_comment">
237
+ <input type="checkbox" value="1" id="purge_archive_on_new_comment" name="purge_archive_on_new_comment"<?php checked( $rt_wp_nginx_helper->options['purge_archive_on_new_comment'], 1 ); ?> />
238
+ &nbsp;<?php _e( 'when a <strong>comment</strong> is <strong>approved/published</strong>.', 'nginx-helper' ); ?>
239
+ </label><br />
240
+ </fieldset>
241
+ <fieldset>
242
+ <legend class="screen-reader-text">
243
+ <span>&nbsp;<?php _e( 'when a comment is unapproved/deleted.</span>', 'nginx-helper' ); ?>
244
+ </legend>
245
+ <label for="purge_archive_on_deleted_comment">
246
+ <input type="checkbox" value="1" id="purge_archive_on_deleted_comment" name="purge_archive_on_deleted_comment"<?php checked( $rt_wp_nginx_helper->options['purge_archive_on_deleted_comment'], 1 ); ?> />
247
+ &nbsp;<?php _e( 'when a <strong>comment</strong> is <strong>unapproved/deleted</strong>.', 'nginx-helper' ); ?>
248
+ </label><br />
249
+ </fieldset>
250
+
251
+ </td>
252
+ </tr>
253
+ </table>
254
+ <table class="form-table rtnginx-table">
255
+ <tr valign="top">
256
+ <th scope="row">
257
+ <h4><?php _e( 'Purge Method:', 'nginx-helper' ); ?></h4>
258
+ </th>
259
+ <td>
260
+ <fieldset>
261
+ <legend class="screen-reader-text">
262
+ <span>&nbsp;<?php _e( 'when a post/page/custom post is published.', 'nginx-helper' ); ?></span>
263
+ </legend>
264
+ <label for="purge_method_get_request">
265
+ <input type="radio" value="get_request" id="purge_method_get_request" name="purge_method"<?php checked( isset( $rt_wp_nginx_helper->options['purge_method'] ) ? $rt_wp_nginx_helper->options['purge_method'] : 'get_request', 'get_request' ); ?>>
266
+ &nbsp;<?php _e( 'Using a GET request to <strong>PURGE/url</strong> (Default option)', 'nginx-helper' ); ?><br />
267
+ <small><?php _e( 'Uses the <strong><a href="https://github.com/FRiCKLE/ngx_cache_purge">ngx_cache_purge</a></strong> module. ', 'nginx-helper' ); ?></small>
268
+ </label><br />
269
+ <label for="purge_method_unlink_files">
270
+ <input type="radio" value="unlink_files" id="purge_method_unlink_files" name="purge_method"<?php checked( isset( $rt_wp_nginx_helper->options['purge_method'] ) ? $rt_wp_nginx_helper->options['purge_method'] : '', 'unlink_files' ); ?>>
271
+ &nbsp;<?php _e( 'Delete local server cache files', 'nginx-helper' ); ?><br />
272
+ <small><?php _e( 'Checks for matching cache file in <strong>RT_WP_NGINX_HELPER_CACHE_PATH</strong>. Does not require any other modules. Requires that the cache be stored on the same server as WordPress. You must also be using the default nginx cache options (levels=1:2) and (fastcgi_cache_key "$scheme$request_method$host$request_uri"). ', 'nginx-helper' ); ?></small>
273
+
274
+ </label><br />
275
+ </fieldset>
276
+ </td>
277
+ </tr>
278
+ </table>
279
+ </div> <!-- End of .inside -->
280
+ </div><?php
281
+ } // End of if ( !( !is_network_admin() && is_multisite() ) )
282
+
283
+
284
+ if ( is_network_admin() ) {
285
+ ?>
286
+ <div class="postbox enable_map"<?php echo ( $rt_wp_nginx_helper->options['enable_map'] == false ) ? ' style="display: none;"' : ''; ?>>
287
+ <h3 class="hndle">
288
+ <span><?php _e( 'Nginx Map', 'nginx-helper' ); ?></span>
289
+ </h3>
290
+ <div class="inside"><?php if ( !is_writable( $rt_wp_nginx_helper->functional_asset_path() . 'map.conf' ) ) { ?>
291
+ <span class="error fade" style="display: block"><p><?php printf( __( 'Can\'t write on map file.<br /><br />Check you have write permission on <strong>%s</strong>', 'nginx-helper' ), $rt_wp_nginx_helper->functional_asset_path() . 'map.conf' ); ?></p></span><?php }
292
+ ?>
293
+
294
+ <table class="form-table rtnginx-table">
295
+ <tr>
296
+ <th><?php _e( 'Nginx Map path to include in nginx settings<br /><small>(recommended)</small>', 'nginx-helper' ); ?></th>
297
+ <td>
298
+ <pre><?php echo $rt_wp_nginx_helper->functional_asset_path() . 'map.conf'; ?></pre>
299
+ </td>
300
+ </tr>
301
+ <tr>
302
+ <th><?php _e( 'Or,<br />Text to manually copy and paste in nginx settings<br /><small>(if your network is small and new sites are not added frequently)</small>', 'nginx-helper' ); ?></th>
303
+ <td>
304
+ <pre id="map"><?php echo $rt_wp_nginx_helper->get_map() ?></pre>
305
+ </td>
306
+ </tr>
307
+ </table>
308
+ </div> <!-- End of