Nginx Helper - Version 1.7.6

Version Description

  • Update Backend UI
  • Added Language Support
Download this release

Release Info

Developer faishal
Plugin Icon 128x128 Nginx Helper
Version 1.7.6
Comparing to
See all releases

Code changes from version 1.7.5 to 1.7.6

admin/admin.php CHANGED
@@ -2,353 +2,421 @@
2
 
3
  namespace rtCamp\WP\Nginx {
4
 
5
- class Admin {
6
-
7
- function __construct() {
8
- if ( is_multisite() ) {
9
- add_action( 'network_admin_menu', array( &$this, 'add_network_menu' ) );
10
- } else {
11
- add_action( 'admin_menu', array( &$this, 'add_menu' ) );
12
- }
13
- add_action( 'admin_print_scripts', array( &$this, 'load_scripts' ) );
14
- add_action( 'admin_print_styles', array( &$this, 'load_styles' ) );
15
- add_action( 'admin_bar_menu', array( &$this, 'add_toolbar_purge_item' ), 100 );
16
- }
17
-
18
- function add_menu() {
19
- add_submenu_page( 'options-general.php', 'Nginx Helper', __( 'Nginx Helper', 'rt_wp_nginx_helper' ), 'install_plugins', 'nginx', array( &$this, 'show_menu' ) );
20
- //add_submenu_page($parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function)
21
- }
22
-
23
- function add_network_menu() {
24
- add_submenu_page( 'settings.php', 'Nginx Helper', __( 'Nginx Helper', 'rt_wp_nginx_helper' ), 'install_plugins', 'nginx', array( &$this, 'show_menu' ) );
25
- }
26
-
27
- // load the script for the defined page and load only this code
28
- function show_menu() {
29
-
30
- global $rt_wp_nginx_helper, $rt_wp_nginx_purger;;
31
-
32
- $required_page = $_GET[ 'page' ];
33
- switch ( $required_page ) {
34
-
35
- default :
36
-
37
- $update = 0;
38
- $error_time = false;
39
- $error_log_filesize = false;
40
- $rt_wp_nginx_helper->options[ 'enable_purge' ] = (isset( $_POST[ 'enable_purge' ] ) and ($_POST[ 'enable_purge' ] == 1) ) ? 1 : 0;
41
- $rt_wp_nginx_helper->options[ 'enable_map' ] = (isset( $_POST[ 'enable_map' ] ) and ($_POST[ 'enable_map' ] == 1) ) ? 1 : 0;
42
- $rt_wp_nginx_helper->options[ 'enable_log' ] = (isset( $_POST[ 'enable_log' ] ) and ($_POST[ 'enable_log' ] == 1) ) ? 1 : 0;
43
- $rt_wp_nginx_helper->options[ 'enable_stamp' ] = (isset( $_POST[ 'enable_stamp' ] ) and ($_POST[ 'enable_stamp' ] == 1) ) ? 1 : 0;
44
-
45
- if ( isset( $_POST[ 'is_submit' ] ) && ($_POST[ 'is_submit' ] == 1) ) {
46
- if ( ! ( ! is_network_admin() && is_multisite()) ) {
47
- if ( $rt_wp_nginx_helper->options[ 'enable_log' ] ) {
48
- if ( isset( $_POST[ 'log_level' ] ) && ! empty( $_POST[ 'log_level' ] ) && $_POST[ 'log_level' ] != '' ) {
49
- $rt_wp_nginx_helper->options[ 'log_level' ] = $_POST[ 'log_level' ];
50
- } else {
51
- $rt_wp_nginx_helper->options[ 'log_level' ] = 'INFO';
52
- }
53
- if ( isset( $_POST[ 'log_filesize' ] ) && ! empty( $_POST[ 'log_filesize' ] ) && $_POST[ 'log_filesize' ] != '' ) {
54
- if ( ( ! is_numeric( $_POST[ 'log_filesize' ] )) || (empty( $_POST[ 'log_filesize' ] )) ) {
55
- $error_log_filesize = "Log file size must be a number";
56
- } else {
57
- $rt_wp_nginx_helper->options[ 'log_filesize' ] = $_POST[ 'log_filesize' ];
58
- }
59
- } else {
60
- $rt_wp_nginx_helper->options[ 'log_filesize' ] = 5;
61
- }
62
- }
63
- if ( $rt_wp_nginx_helper->options[ 'enable_map' ] ) {
64
- $rt_wp_nginx_helper->update_map();
65
- }
66
- }
67
- if ( isset( $_POST[ 'enable_purge' ] ) ) {
68
-
69
- $rt_wp_nginx_helper->options[ 'purge_homepage_on_edit' ] = (isset( $_POST[ 'purge_homepage_on_edit' ] ) and ($_POST[ 'purge_homepage_on_edit' ] == 1) ) ? 1 : 0;
70
- $rt_wp_nginx_helper->options[ 'purge_homepage_on_del' ] = (isset( $_POST[ 'purge_homepage_on_del' ] ) and ($_POST[ 'purge_homepage_on_del' ] == 1) ) ? 1 : 0;
71
-
72
- $rt_wp_nginx_helper->options[ 'purge_archive_on_edit' ] = (isset( $_POST[ 'purge_archive_on_edit' ] ) and ($_POST[ 'purge_archive_on_edit' ] == 1) ) ? 1 : 0;
73
- $rt_wp_nginx_helper->options[ 'purge_archive_on_del' ] = (isset( $_POST[ 'purge_archive_on_del' ] ) and ($_POST[ 'purge_archive_on_del' ] == 1) ) ? 1 : 0;
74
-
75
- $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;
76
- $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;
77
-
78
- $rt_wp_nginx_helper->options[ 'purge_page_on_mod' ] = (isset( $_POST[ 'purge_page_on_mod' ] ) and ($_POST[ 'purge_page_on_mod' ] == 1) ) ? 1 : 0;
79
- $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;
80
- $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;
81
- }
82
- update_site_option( "rt_wp_nginx_helper_options", $rt_wp_nginx_helper->options );
83
-
84
-
85
- $update = 1;
86
- }
87
- $rt_wp_nginx_helper->options = get_site_option( "rt_wp_nginx_helper_options" );
88
- ?>
89
-
90
- <div class="wrap">
91
-
92
- <div class="icon32" id="icon-options-nginx"><br /></div>
93
- <h2>Nginx Settings</h2>
94
- <div id="content_block" class="align_left">
95
- <form id="purgeall" action="" method="post">
96
- <?php $purge_url = add_query_arg( array( 'nginx_helper_action' => 'purge', 'nginx_helper_urls' => 'all' ) ); ?>
97
- <?php $nonced_url = wp_nonce_url( $purge_url, 'nginx_helper-purge_all' ); ?>
98
- <a href="<?php echo $nonced_url; ?>" class="button-primary">Purge Cache</a>
99
- </form>
100
- <form id="post_form" method="post" action="#" name="smart_http_expire_form">
101
- <?php if ( ! ( ! is_network_admin() && is_multisite()) ) { ?>
102
-
103
- <input type="hidden" name="is_submit" value="1" />
104
-
105
- <h3>Plugin Options</h3>
106
-
107
- <table class="form-table">
108
- <tr valign="top">
109
- <td>
110
- <label for="enable_purge"><input type="checkbox" value="1" id="enable_purge" name="enable_purge"<?php checked( $rt_wp_nginx_helper->options[ 'enable_purge' ], 1 ); ?>>&nbsp;Enable Cache Purge (requires external settings for nginx).</label><br />
111
- <?php if ( is_network_admin() ) { ?>
112
- <label for="enable_map"><input type="checkbox" value="1" id="enable_map" name="enable_map"<?php checked( $rt_wp_nginx_helper->options[ 'enable_map' ], 1 ); ?>>&nbsp;Enable Nginx Map.</label><br />
113
- <?php } ?>
114
- <label for="enable_log"><input type="checkbox" value="1" id="enable_log" name="enable_log"<?php checked( $rt_wp_nginx_helper->options[ 'enable_log' ], 1 ); ?>>&nbsp;Enable Logging</label><br />
115
- <label for="enable_stamp"><input type="checkbox" value="1" id="enable_stamp" name="enable_stamp"<?php checked( $rt_wp_nginx_helper->options[ 'enable_stamp' ], 1 ); ?>>&nbsp;Enable Nginx Timestamp in HTML</label>
116
- </td>
117
- </tr>
118
- </table>
119
-
120
- <?php
121
- $displayvar = '';
122
- if ( $rt_wp_nginx_helper->options[ 'enable_purge' ] == false ) {
123
- $displayvar = ' style="display:none"';
124
- }
125
- ?>
126
- <h3<?php echo $displayvar; ?>>Purging Options</h3>
127
-
128
- <table class="form-table rtnginx-table"<?php echo $displayvar; ?>>
129
- <tr valign="top">
130
- <th scope="row"><h4>Purge Homepage:</h4></th>
131
- <td>
132
- <fieldset>
133
- <legend class="screen-reader-text"><span>&nbsp;when a post/page/custom post is modified or added.</span></legend>
134
- <label for="purge_homepage_on_edit"><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 ); ?>>&nbsp;when a <strong>post</strong> (or page/custom post) is <strong>modified</strong> or <strong>added</strong>.</label><br />
135
- </fieldset>
136
- <fieldset>
137
- <legend class="screen-reader-text"><span>&nbsp;when an existing post/page/custom post is modified.</span></legend>
138
- <label for="purge_homepage_on_del"><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 ); ?>>&nbsp;when a <strong>published post</strong> (or page/custom post) is <strong>trashed</strong>.</label><br />
139
- </fieldset>
140
- </td>
141
- </tr>
142
- </table>
143
- <table class="form-table rtnginx-table"<?php echo $displayvar; ?>>
144
- <tr valign="top">
145
- <th scope="row">
146
- <h4>Purge Post/Page/Custom Post Type:</h4>
147
- </th>
148
- <td>
149
- <fieldset>
150
- <legend class="screen-reader-text"><span>&nbsp;when a post/page/custom post is published.</span></legend>
151
- <label for="purge_page_on_mod"><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 ); ?>>&nbsp;when a <strong>post</strong> is <strong>published</strong>.</label><br />
152
- </fieldset>
153
- <fieldset>
154
- <legend class="screen-reader-text"><span>&nbsp;when a comment is approved/published.</span></legend>
155
- <label for="purge_page_on_new_comment"><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 ); ?>>&nbsp;when a <strong>comment</strong> is <strong>approved/published</strong>.</label><br />
156
- </fieldset>
157
- <fieldset>
158
- <legend class="screen-reader-text"><span>&nbsp;when a comment is unapproved/deleted.</span></legend>
159
- <label for="purge_page_on_deleted_comment"><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 ); ?>>&nbsp;when a <strong>comment</strong> is <strong>unapproved/deleted</strong>.</label><br />
160
- </fieldset>
161
- </td>
162
- </tr>
163
- </table>
164
- <table class="form-table rtnginx-table"<?php echo $displayvar; ?>>
165
- <tr valign="top">
166
- <th scope="row">
167
- <h4>Purge Archives:</h4>
168
- <small>(date, category, tag, author, custom taxonomies)</small>
169
- </th>
170
- <td>
171
- <fieldset>
172
- <legend class="screen-reader-text"><span>&nbsp;when an post/page/custom post is modified or added.</span></legend>
173
- <label for="purge_archive_on_edit"><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 ); ?>>&nbsp;when a <strong>post</strong> (or page/custom post) is <strong>modified</strong> or <strong>added</strong>.</label><br />
174
- </fieldset>
175
- <fieldset>
176
- <legend class="screen-reader-text"><span>&nbsp;when an existing post/page/custom post is trashed.</span></legend>
177
- <label for="purge_archive_on_del"><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 ); ?>>&nbsp;when a <strong>published post</strong> (or page/custom post) is <strong>trashed</strong>.</label><br />
178
- </fieldset>
179
- <br />
180
- <fieldset>
181
- <legend class="screen-reader-text"><span>&nbsp;when a comment is approved/published.</span></legend>
182
- <label for="purge_archive_on_new_comment"><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 ); ?>>&nbsp;when a <strong>comment</strong> is <strong>approved/published</strong>.</label><br />
183
- </fieldset>
184
- <fieldset>
185
- <legend class="screen-reader-text"><span>&nbsp;when a comment is unapproved/deleted.</span></legend>
186
- <label for="purge_archive_on_deleted_comment"><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 ); ?>>&nbsp;when a <strong>comment</strong> is <strong>unapproved/deleted</strong>.</label><br />
187
- </fieldset>
188
-
189
- </td>
190
- </tr>
191
- </table>
192
-
193
- <?php
194
- }
195
- if ( is_network_admin() && $rt_wp_nginx_helper->options[ 'enable_map' ] != false ) {
196
- ?>
197
- <h3>Nginx Map</h3>
198
- <?php if ( ! is_writable( $rt_wp_nginx_helper->functional_asset_path() . 'map.conf' ) ) { ?>
199
- <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>", "rt_wp_nginx_helper" ), $rt_wp_nginx_helper->functional_asset_path() . 'map.conf' ); ?></p></span>
200
- <?php } ?>
201
-
202
- <table class="form-table rtnginx-table">
203
- <tr>
204
- <th>
205
- Nginx Map path to include in nginx settings<br />
206
- <small>(recommended)</small>
207
- </th>
208
- <td>
209
- <?php echo $rt_wp_nginx_helper->functional_asset_path() . 'map.conf'; ?>
210
- </td>
211
- </tr>
212
- <tr>
213
- <th>
214
- Or,<br />
215
- Text to manually copy and paste in nginx settings<br />
216
- <small>(if your network is small and new sites are not added frequently)</small>
217
- </th>
218
- <td>
219
- <pre id="map"><?php echo $rt_wp_nginx_helper->get_map() ?></pre>
220
- </td>
221
- </tr>
222
- </table>
223
- <?php } ?>
224
-
225
- <?php
226
- if ( $rt_wp_nginx_helper->options[ 'enable_log' ] != false ) {
227
- ?>
228
- <h3>Logging</h3>
229
-
230
- <?php
231
- $path = $rt_wp_nginx_helper->functional_asset_path();
232
- if (!is_dir($path)){
233
- mkdir($path);
234
- }
235
- if (!file_exists($path . 'nginx.log')) {
236
- $log = fopen($path . 'nginx.log', 'w');
237
- fclose($log);
238
- }
239
- if ( is_writable( $path . 'nginx.log' ) ) {
240
- $rt_wp_nginx_purger->log( "+++++++++" );
241
- $rt_wp_nginx_purger->log( "+Log Test" );
242
- $rt_wp_nginx_purger->log( "+++++++++" );
243
- }
244
- if ( ! is_writable( $path . 'nginx.log' ) ) {
245
- ?>
246
- <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>", "rt_wp_nginx_helper" ), $rt_wp_nginx_helper->functional_asset_path() . 'nginx.log' ); ?></p></span>
247
- <?php } ?>
248
-
249
- <table class="form-table rtnginx-table">
250
- <tbody>
251
- <tr>
252
- <th><label for="rt_wp_nginx_helper_logs_path"><?php _e( 'Logs path', 'rt_wp_nginx_helper' ); ?></label></th>
253
- <td><?php echo $rt_wp_nginx_helper->functional_asset_path(); ?>nginx.log</td>
254
- </tr>
255
- <tr>
256
- <th><label for="rt_wp_nginx_helper_logs_link"><?php _e( 'View Log', 'rt_wp_nginx_helper' ); ?></label></th>
257
- <td><a target="_blank" href="<?php echo $rt_wp_nginx_helper->functional_asset_url(); ?>nginx.log">Log</a></td>
258
- </tr>
259
-
260
- <tr>
261
- <th><label for="rt_wp_nginx_helper_log_level"><?php _e( 'Log level', 'rt_wp_nginx_helper' ); ?></label></th>
262
- <td>
263
- <select name="log_level">
264
- <option value="NONE"<?php selected( $rt_wp_nginx_helper->options[ 'log_level' ], 'NONE' ); ?>><?php _e( 'None', 'rt_wp_nginx_helper' ); ?></option>
265
- <option value="INFO"<?php selected( $rt_wp_nginx_helper->options[ 'log_level' ], 'INFO' ); ?>><?php _e( 'Info', 'rt_wp_nginx_helper' ); ?></option>
266
- <option value="WARNING"<?php selected( $rt_wp_nginx_helper->options[ 'log_level' ], 'WARNING' ); ?>><?php _e( 'Warning', 'rt_wp_nginx_helper' ); ?></option>
267
- <option value="ERROR"<?php selected( $rt_wp_nginx_helper->options[ 'log_level' ], 'ERROR' ); ?>><?php _e( 'Error', 'rt_wp_nginx_helper' ); ?></option>
268
- </select>
269
- </td>
270
- </tr>
271
-
272
- <tr>
273
- <th><label for="log_filesize"><?php _e( 'Max log file size', 'rt_wp_nginx_helper' ); ?></label></th>
274
- <td>
275
- <input id="log_filesize" class="small-text" type="text" name="log_filesize" value="<?php echo $rt_wp_nginx_helper->options[ 'log_filesize' ] ?>" /> Mb
276
- <?php if ( $error_log_filesize ) { ?>
277
- <span class="error fade" style="display : block"><p><strong><?php echo $error_log_filesize; ?></strong></p></span>
278
- <?php } ?>
279
- </td>
280
- </tr>
281
- </tbody>
282
- </table>
283
-
284
- <br />
285
- <?php } ?>
286
-
287
- <p class="submit">
288
- <input type="submit" name="smart_http_expire_save" class="button-primary" value="Save" />
289
- </p>
290
- </form>
291
-
292
- </div>
293
- <div id="rtads" class="metabox-holder align_left">
294
- <?php $this->default_admin_sidebar(); ?>
295
- </div>
296
- </div>
297
- <?php
298
- break;
299
- }
300
- }
301
-
302
- function add_toolbar_purge_item( $admin_bar ) {
303
- $purge_url = add_query_arg( array( 'nginx_helper_action' => 'purge', 'nginx_helper_urls' => 'all' ) );
304
- $nonced_url = wp_nonce_url( $purge_url, 'nginx_helper-purge_all' );
305
- $admin_bar->add_menu( array(
306
- 'id' => 'nginx-helper-purge-all',
307
- 'title' => __( 'Purge Cache', 'rt-nginx' ),
308
- 'href' => $nonced_url,
309
- 'meta' => array(
310
- 'title' => __( 'Purge Cache', 'rt-nginx' ),
311
- ),
312
- )
313
- );
314
- }
315
-
316
- function default_admin_sidebar() {
317
- ?>
318
- <div class="postbox" id="support">
319
- <div title="<?php _e( 'Click to toggle', 'bp-media' ); ?>" class="handlediv"><br /></div>
320
- <h3 class="hndle"><span><?php _e( 'Need Help?', 'bp-media' ); ?></span></h3>
321
- <div class="inside"><p><?php printf( __( ' Please use our <a href="%s">free support forum</a>.<br/><span class="bpm-aligncenter">OR</span><br/>
322
- <a href="%s">Hire us!</a> for wordpress on nginx solutions ', 'rt-nginx' ), 'http://rtcamp.com/support/forum/wordpress-nginx/', 'http://rtcamp.com/wordpress-nginx/' ); ?>.</p></div>
323
- </div>
324
- <div class="postbox" id="social">
325
- <div title="<?php _e( 'Click to toggle', 'bp-media' ); ?>" class="handlediv"><br /></div>
326
- <h3 class="hndle"><span><?php _e( 'Getting Social is Good', 'bp-media' ); ?></span></h3>
327
- <div class="inside" style="text-align:center;">
328
- <a href="<?php printf( '%s', 'http://www.facebook.com/rtCamp.solutions/' ); ?>" target="_blank" title="<?php _e( 'Become a fan on Facebook', 'bp-media' ); ?>" class="rt-nginx-facebook rt-nginx-social"><?php _e( 'Facebook', 'bp-media' ); ?></a>
329
- <a href="<?php printf( '%s', 'https://twitter.com/rtcamp/' ); ?>" target="_blank" title="<?php _e( 'Follow us on Twitter', 'bp-media' ); ?>" class="rt-nginx-twitter rt-nginx-social"><?php _e( 'Twitter', 'bp-media' ); ?></a>
330
- <a href="<?php printf( '%s', 'http://feeds.feedburner.com/rtcamp/' ); ?>" target="_blank" title="<?php _e( 'Subscribe to our feeds', 'bp-media' ); ?>" class="rt-nginx-rss rt-nginx-social"><?php _e( 'RSS Feed', 'bp-media' ); ?></a>
331
- </div>
332
- </div>
333
-
334
- <div class="postbox" id="latest_news">
335
- <div title="<?php _e( 'Click to toggle', 'bp-media' ); ?>" class="handlediv"><br /></div>
336
- <h3 class="hndle"><span><?php _e( 'Latest News', 'bp-media' ); ?></span></h3>
337
- <div class="inside"><img src ="<?php echo admin_url(); ?>/images/wpspin_light.gif" /> Loading...</div>
338
- </div><?php
339
- }
340
-
341
- function load_styles() {
342
- wp_enqueue_style( 'rt-nginx-admin-css', plugins_url( 'admin/assets/style.css', dirname( __FILE__ ) ) );
343
- }
344
-
345
- function load_scripts() {
346
- $admin_js = trailingslashit( site_url() ) . '?get_feeds=1';
347
- wp_enqueue_script( 'nginx-js', plugins_url( 'admin/assets/nginx.js', dirname( __FILE__ ) ) );
348
- wp_localize_script( 'nginx-js', 'news_url', $admin_js );
349
- }
350
-
351
- }
352
-
353
- }
354
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  namespace rtCamp\WP\Nginx {
4
 
5
+ class Admin {
6
+
7
+ function __construct() {
8
+ if (is_multisite()) {
9
+ add_action('network_admin_menu', array(&$this, 'add_network_menu'));
10
+ } else {
11
+ add_action('admin_menu', array(&$this, 'add_menu'));
12
+ }
13
+ add_action('admin_print_scripts-settings_page_nginx', array(&$this, 'load_scripts'));
14
+ add_action('admin_print_styles-settings_page_nginx', array(&$this, 'load_styles'));
15
+ add_action('admin_bar_menu', array(&$this, 'add_toolbar_purge_item'), 100);
16
+ }
17
+
18
+ function add_menu() {
19
+ add_submenu_page('options-general.php', 'Nginx Helper', __('Nginx Helper', 'nginx-helper'), 'install_plugins', 'nginx', array(&$this, 'show_menu'));
20
+ //add_submenu_page($parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function)
21
+ }
22
+
23
+ function add_network_menu() {
24
+ add_submenu_page('settings.php', 'Nginx Helper', __('Nginx Helper', 'nginx-helper'), 'install_plugins', 'nginx', array(&$this, 'show_menu'));
25
+ }
26
+
27
+ // load the script for the defined page and load only this code
28
+ function show_menu() {
29
+
30
+ global $rt_wp_nginx_helper, $rt_wp_nginx_purger;
31
+ ;
32
+
33
+ $required_page = $_GET['page'];
34
+ switch ($required_page) {
35
+
36
+ default :
37
+
38
+ $update = 0;
39
+ $error_time = false;
40
+ $error_log_filesize = false;
41
+ $rt_wp_nginx_helper->options['enable_purge'] = (isset($_POST['enable_purge']) and ($_POST['enable_purge'] == 1) ) ? 1 : 0;
42
+ $rt_wp_nginx_helper->options['enable_map'] = (isset($_POST['enable_map']) and ($_POST['enable_map'] == 1) ) ? 1 : 0;
43
+ $rt_wp_nginx_helper->options['enable_log'] = (isset($_POST['enable_log']) and ($_POST['enable_log'] == 1) ) ? 1 : 0;
44
+ $rt_wp_nginx_helper->options['enable_stamp'] = (isset($_POST['enable_stamp']) and ($_POST['enable_stamp'] == 1) ) ? 1 : 0;
45
+
46
+ if (isset($_POST['is_submit']) && ($_POST['is_submit'] == 1)) {
47
+ if (!(!is_network_admin() && is_multisite())) {
48
+ if ($rt_wp_nginx_helper->options['enable_log']) {
49
+ if (isset($_POST['log_level']) && !empty($_POST['log_level']) && $_POST['log_level'] != '') {
50
+ $rt_wp_nginx_helper->options['log_level'] = $_POST['log_level'];
51
+ } else {
52
+ $rt_wp_nginx_helper->options['log_level'] = 'INFO';
53
+ }
54
+ if (isset($_POST['log_filesize']) && !empty($_POST['log_filesize']) && $_POST['log_filesize'] != '') {
55
+ if ((!is_numeric($_POST['log_filesize'])) || (empty($_POST['log_filesize']))) {
56
+ $error_log_filesize = "Log file size must be a number";
57
+ } else {
58
+ $rt_wp_nginx_helper->options['log_filesize'] = $_POST['log_filesize'];
59
+ }
60
+ } else {
61
+ $rt_wp_nginx_helper->options['log_filesize'] = 5;
62
+ }
63
+ }
64
+ if ($rt_wp_nginx_helper->options['enable_map']) {
65
+ $rt_wp_nginx_helper->update_map();
66
+ }
67
+ }
68
+ if (isset($_POST['enable_purge'])) {
69
+
70
+ $rt_wp_nginx_helper->options['purge_homepage_on_edit'] = (isset($_POST['purge_homepage_on_edit']) and ($_POST['purge_homepage_on_edit'] == 1) ) ? 1 : 0;
71
+ $rt_wp_nginx_helper->options['purge_homepage_on_del'] = (isset($_POST['purge_homepage_on_del']) and ($_POST['purge_homepage_on_del'] == 1) ) ? 1 : 0;
72
+
73
+ $rt_wp_nginx_helper->options['purge_archive_on_edit'] = (isset($_POST['purge_archive_on_edit']) and ($_POST['purge_archive_on_edit'] == 1) ) ? 1 : 0;
74
+ $rt_wp_nginx_helper->options['purge_archive_on_del'] = (isset($_POST['purge_archive_on_del']) and ($_POST['purge_archive_on_del'] == 1) ) ? 1 : 0;
75
+
76
+ $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;
77
+ $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;
78
+
79
+ $rt_wp_nginx_helper->options['purge_page_on_mod'] = (isset($_POST['purge_page_on_mod']) and ($_POST['purge_page_on_mod'] == 1) ) ? 1 : 0;
80
+ $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;
81
+ $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;
82
+ }
83
+ update_site_option("rt_wp_nginx_helper_options", $rt_wp_nginx_helper->options);
84
+
85
+
86
+ $update = 1;
87
+ }
88
+ $rt_wp_nginx_helper->options = get_site_option("rt_wp_nginx_helper_options");
89
+ ?>
90
+
91
+ <div class="wrap rt-nginx-wrapper">
92
+ <h2><?php _e('Nginx Settings', 'nginx-helper') ?></h2>
93
+ <div id="poststuff">
94
+ <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
95
+ <div id="post-body-content" class="postbox">
96
+ <h3 class="hndle">
97
+ <span><?php _e('Plugin Options', 'nginx-helper'); ?></span>
98
+ </h3>
99
+ <form id="purgeall" action="" method="post" class="clearfix">
100
+ <div class="inside">
101
+ <?php $purge_url = add_query_arg(array('nginx_helper_action' => 'purge', 'nginx_helper_urls' => 'all')); ?>
102
+ <?php $nonced_url = wp_nonce_url($purge_url, 'nginx_helper-purge_all'); ?>
103
+ <a href="<?php echo $nonced_url; ?>" class="button-primary"><?php _e('Purge Cache', 'nginx-helper'); ?></a>
104
+ </div>
105
+ </form>
106
+ <form id="post_form" method="post" action="#" name="smart_http_expire_form" class="clearfix">
107
+ <?php if ( !( !is_network_admin() && is_multisite() ) ) { ?>
108
+ <div class="inside">
109
+ <input type="hidden" name="is_submit" value="1" />
110
+ <table class="form-table">
111
+ <tr valign="top">
112
+ <td>
113
+ <input type="checkbox" value="1" id="enable_purge" name="enable_purge" <?php checked($rt_wp_nginx_helper->options['enable_purge'], 1); ?> />
114
+ <label for="enable_purge"><?php _e('Enable Cache Purge (requires external settings for nginx)', 'nginx-helper'); ?></label>
115
+ </td>
116
+ </tr>
117
+ <?php if (is_network_admin()) { ?>
118
+ <tr valign="top">
119
+ <td>
120
+ <input type="checkbox" value="1" id="enable_map" name="enable_map"<?php checked($rt_wp_nginx_helper->options['enable_map'], 1); ?> />
121
+ <label for="enable_map"><?php _e('Enable Nginx Map.', 'nginx-helper'); ?></label>
122
+ </td>
123
+ </tr>
124
+ <?php } ?>
125
+ <tr valign="top">
126
+ <td>
127
+ <input type="checkbox" value="1" id="enable_log" name="enable_log"<?php checked($rt_wp_nginx_helper->options['enable_log'], 1); ?> />
128
+ <label for="enable_log"><?php _e('Enable Logging', 'nginx-helper'); ?></label>
129
+ </td>
130
+ </tr>
131
+ <tr valign="top">
132
+ <td>
133
+ <input type="checkbox" value="1" id="enable_stamp" name="enable_stamp"<?php checked($rt_wp_nginx_helper->options['enable_stamp'], 1); ?> />
134
+ <label for="enable_stamp"><?php _e('Enable Nginx Timestamp in HTML', 'nginx-helper'); ?></label>
135
+ </td>
136
+ </tr>
137
+ </table>
138
+ </div> <!-- End of .inside -->
139
+ <?php
140
+ $displayvar = '';
141
+ if ($rt_wp_nginx_helper->options['enable_purge'] == false) {
142
+ $displayvar = ' style="display:none"';
143
+ }
144
+ ?>
145
+ <h3 class="hndle"<?php echo $displayvar; ?>>
146
+ <span><?php _e('Purging Options', 'nginx-helper'); ?></span>
147
+ </h3>
148
+ <div class="inside">
149
+
150
+ <table class="form-table rtnginx-table"<?php echo $displayvar; ?>>
151
+ <tr valign="top">
152
+ <th scope="row"><h4><?php _e('Purge Homepage:', 'nginx-helper'); ?></h4></th>
153
+ <td>
154
+ <fieldset>
155
+ <legend class="screen-reader-text">
156
+ <span>&nbsp;<?php _e('when a post/page/custom post is modified or added.', 'nginx-helper'); ?></span>
157
+ </legend>
158
+ <label for="purge_homepage_on_edit">
159
+ <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); ?> />
160
+ &nbsp;<?php _e('when a <strong>post</strong> (or page/custom post) is <strong>modified</strong> or <strong>added</strong>.', 'nginx-helper'); ?>
161
+ </label><br />
162
+ </fieldset>
163
+ <fieldset>
164
+ <legend class="screen-reader-text">
165
+ <span>&nbsp;<?php _e('when an existing post/page/custom post is modified.', 'nginx-helper'); ?></span>
166
+ </legend>
167
+ <label for="purge_homepage_on_del">
168
+ <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); ?> />
169
+ &nbsp;<?php _e('when a <strong>published post</strong> (or page/custom post) is <strong>trashed</strong>.', 'nginx-helper'); ?></label><br />
170
+ </fieldset>
171
+ </td>
172
+ </tr>
173
+ </table>
174
+ <table class="form-table rtnginx-table"<?php echo $displayvar; ?>>
175
+ <tr valign="top">
176
+ <th scope="row">
177
+ <h4><?php _e('Purge Post/Page/Custom Post Type:', 'nginx-helper'); ?></h4>
178
+ </th>
179
+ <td>
180
+ <fieldset>
181
+ <legend class="screen-reader-text">
182
+ <span>&nbsp;<?php _e('when a post/page/custom post is published.', 'nginx-helper'); ?></span>
183
+ </legend>
184
+ <label for="purge_page_on_mod">
185
+ <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); ?>>
186
+ &nbsp;<?php _e('when a <strong>post</strong> is <strong>published</strong>.', 'nginx-helper'); ?>
187
+ </label><br />
188
+ </fieldset>
189
+ <fieldset>
190
+ <legend class="screen-reader-text">
191
+ <span>&nbsp;<?php _e('when a comment is approved/published.', 'nginx-helper'); ?></span>
192
+ </legend>
193
+ <label for="purge_page_on_new_comment">
194
+ <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); ?>>
195
+ &nbsp;<?php _e('when a <strong>comment</strong> is <strong>approved/published</strong>.', 'nginx-helper'); ?>
196
+ </label><br />
197
+ </fieldset>
198
+ <fieldset>
199
+ <legend class="screen-reader-text">
200
+ <span>&nbsp;<?php _e('when a comment is unapproved/deleted.', 'nginx-helper'); ?></span>
201
+ </legend>
202
+ <label for="purge_page_on_deleted_comment">
203
+ <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); ?>>
204
+ &nbsp;<?php _e('when a <strong>comment</strong> is <strong>unapproved/deleted</strong>.', 'nginx-helper'); ?>
205
+ </label><br />
206
+ </fieldset>
207
+ </td>
208
+ </tr>
209
+ </table>
210
+ <table class="form-table rtnginx-table"<?php echo $displayvar; ?>>
211
+ <tr valign="top">
212
+ <th scope="row">
213
+ <h4><?php _e('Purge Archives:', 'nginx-helper'); ?></h4>
214
+ <small><?php _e('(date, category, tag, author, custom taxonomies)', 'nginx-helper'); ?></small>
215
+ </th>
216
+ <td>
217
+ <fieldset>
218
+ <legend class="screen-reader-text">
219
+ <span>&nbsp;<?php _e('when an post/page/custom post is modified or added.</span>', 'nginx-helper'); ?>
220
+ </legend>
221
+ <label for="purge_archive_on_edit">
222
+ <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); ?> />
223
+ &nbsp;<?php _e('when a <strong>post</strong> (or page/custom post) is <strong>modified</strong> or <strong>added</strong>.', 'nginx-helper'); ?>
224
+ </label><br />
225
+ </fieldset>
226
+ <fieldset>
227
+ <legend class="screen-reader-text">
228
+ <span>&nbsp;<?php _e('when an existing post/page/custom post is trashed.</span>', 'nginx-helper'); ?>
229
+ </legend>
230
+ <label for="purge_archive_on_del">
231
+ <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); ?> />
232
+ &nbsp;<?php _e('when a <strong>published post</strong> (or page/custom post) is <strong>trashed</strong>.', 'nginx-helper'); ?>
233
+ </label><br />
234
+ </fieldset>
235
+ <br />
236
+ <fieldset>
237
+ <legend class="screen-reader-text">
238
+ <span>&nbsp;<?php _e('when a comment is approved/published.</span>', 'nginx-helper'); ?>
239
+ </legend>
240
+ <label for="purge_archive_on_new_comment">
241
+ <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); ?> />
242
+ &nbsp;<?php _e('when a <strong>comment</strong> is <strong>approved/published</strong>.', 'nginx-helper'); ?>
243
+ </label><br />
244
+ </fieldset>
245
+ <fieldset>
246
+ <legend class="screen-reader-text">
247
+ <span>&nbsp;<?php _e('when a comment is unapproved/deleted.</span>', 'nginx-helper'); ?>
248
+ </legend>
249
+ <label for="purge_archive_on_deleted_comment">
250
+ <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); ?> />
251
+ &nbsp;<?php _e('when a <strong>comment</strong> is <strong>unapproved/deleted</strong>.', 'nginx-helper'); ?>
252
+ </label><br />
253
+ </fieldset>
254
+
255
+ </td>
256
+ </tr>
257
+ </table>
258
+ </div> <!-- End of .inside --><?php
259
+ } // End of if ( !( !is_network_admin() && is_multisite() ) )
260
+
261
+
262
+ if (is_network_admin() && $rt_wp_nginx_helper->options['enable_map'] != false) { ?>
263
+ <h3 class="hndle">
264
+ <span><?php _e('Nginx Map', 'nginx-helper'); ?></span>
265
+ </h3>
266
+ <div class="inside">
267
+ <?php if ( !is_writable( $rt_wp_nginx_helper->functional_asset_path() . 'map.conf' ) ) { ?>
268
+ <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>
269
+ <?php } ?>
270
+
271
+ <table class="form-table rtnginx-table">
272
+ <tr>
273
+ <th><?php _e('Nginx Map path to include in nginx settings<br /><small>(recommended)</small>', 'nginx-helper'); ?></th>
274
+ <td>
275
+ <?php echo $rt_wp_nginx_helper->functional_asset_path() . 'map.conf'; ?>
276
+ </td>
277
+ </tr>
278
+ <tr>
279
+ <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>
280
+ <td>
281
+ <pre id="map"><?php echo $rt_wp_nginx_helper->get_map() ?></pre>
282
+ </td>
283
+ </tr>
284
+ </table>
285
+ </div> <!-- End of .inside -->
286
+ <?php } ?>
287
+
288
+ <?php if ($rt_wp_nginx_helper->options['enable_log'] != false) { ?>
289
+ <h3 class="hndle">
290
+ <span><?php _e('Logging', 'nginx-helper'); ?></span>
291
+ </h3>
292
+ <div class="inside">
293
+ <?php
294
+ $path = $rt_wp_nginx_helper->functional_asset_path();
295
+ if (!is_dir($path)) {
296
+ mkdir($path);
297
+ }
298
+ if (!file_exists($path . 'nginx.log')) {
299
+ $log = fopen($path . 'nginx.log', 'w');
300
+ fclose($log);
301
+ }
302
+ if (is_writable($path . 'nginx.log')) {
303
+ $rt_wp_nginx_purger->log("+++++++++");
304
+ $rt_wp_nginx_purger->log("+Log Test");
305
+ $rt_wp_nginx_purger->log("+++++++++");
306
+ }
307
+ if (!is_writable($path . 'nginx.log')) {
308
+ ?>
309
+ <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>
310
+ <?php } ?>
311
+
312
+ <table class="form-table rtnginx-table">
313
+ <tbody>
314
+ <tr>
315
+ <th><label for="rt_wp_nginx_helper_logs_path"><?php _e('Logs path', 'nginx-helper'); ?></label></th>
316
+ <td><?php echo $rt_wp_nginx_helper->functional_asset_path(); ?>nginx.log</td>
317
+ </tr>
318
+ <tr>
319
+ <th><label for="rt_wp_nginx_helper_logs_link"><?php _e('View Log', 'nginx-helper'); ?></label></th>
320
+ <td><a target="_blank" href="<?php echo $rt_wp_nginx_helper->functional_asset_url(); ?>nginx.log"><?php _e('Log', 'nginx-helper'); ?></a></td>
321
+ </tr>
322
+ <tr>
323
+ <th><label for="rt_wp_nginx_helper_log_level"><?php _e('Log level', 'nginx-helper'); ?></label></th>
324
+ <td>
325
+ <select name="log_level">
326
+ <option value="NONE"<?php selected($rt_wp_nginx_helper->options['log_level'], 'NONE'); ?>><?php _e('None', 'nginx-helper'); ?></option>
327
+ <option value="INFO"<?php selected($rt_wp_nginx_helper->options['log_level'], 'INFO'); ?>><?php _e('Info', 'nginx-helper'); ?></option>
328
+ <option value="WARNING"<?php selected($rt_wp_nginx_helper->options['log_level'], 'WARNING'); ?>><?php _e('Warning', 'nginx-helper'); ?></option>
329
+ <option value="ERROR"<?php selected($rt_wp_nginx_helper->options['log_level'], 'ERROR'); ?>><?php _e('Error', 'nginx-helper'); ?></option>
330
+ </select>
331
+ </td>
332
+ </tr>
333
+ <tr>
334
+ <th><label for="log_filesize"><?php _e('Max log file size', 'nginx-helper'); ?></label></th>
335
+ <td>
336
+ <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');
337
+ if ($error_log_filesize) {
338
+ ?>
339
+ <span class="error fade" style="display: block;">
340
+ <p>
341
+ <strong><?php echo $error_log_filesize; ?></strong>
342
+ </p>
343
+ </span><?php }
344
+ ?>
345
+ </td>
346
+ </tr>
347
+ </tbody>
348
+ </table>
349
+ </div> <!-- End of .inside -->
350
+ <?php } ?>
351
+ <div class="inside">
352
+ <p class="submit">
353
+ <input type="submit" name="smart_http_expire_save" class="button-primary" value="<?php _e('Save', 'nginx-helper'); ?>" />
354
+ </p>
355
+ </div>
356
+ </form>
357
+
358
+ </div>
359
+ <div id="postbox-container-1" class="postbox-container">
360
+ <?php $this->default_admin_sidebar(); ?>
361
+ </div>
362
+ </div> <!-- End of #post-body -->
363
+ </div> <!-- End of #poststuff -->
364
+ </div> <!-- End of .wrap -->
365
+ <?php
366
+ break;
367
+ }
368
+ }
369
+
370
+ function add_toolbar_purge_item($admin_bar) {
371
+ if (!current_user_can('manage_options')) {
372
+ return;
373
+ }
374
+ $purge_url = add_query_arg(array('nginx_helper_action' => 'purge', 'nginx_helper_urls' => 'all'));
375
+ $nonced_url = wp_nonce_url($purge_url, 'nginx_helper-purge_all');
376
+ $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'),),));
377
+ }
378
+
379
+ function default_admin_sidebar() {
380
+ ?>
381
+ <div class="postbox" id="support">
382
+ <div title="<?php _e('Click to toggle', 'nginx-helper'); ?>" class="handlediv"><br /></div>
383
+ <h3 class="hndle"><span><?php _e('Need Help?', 'nginx-helper'); ?></span></h3>
384
+ <div class="inside">
385
+ <p>
386
+ <?php printf(__('Please use our <a href="%s">free support forum</a>.<span class="nh-aligncenter">OR</span><a href="%s">Hire us!</a> for wordpress on nginx solutions.', 'nginx-helper'), 'http://rtcamp.com/support/forum/wordpress-nginx/', 'http://rtcamp.com/wordpress-nginx/'); ?>
387
+ </p>
388
+ </div>
389
+ </div>
390
+ <div class="postbox" id="social">
391
+ <div title="<?php _e('Click to toggle', 'nginx-helper'); ?>" class="handlediv"><br /></div>
392
+ <h3 class="hndle">
393
+ <span><?php _e('Getting Social is Good', 'nginx-helper'); ?></span>
394
+ </h3>
395
+ <div style="text-align:center;" class="inside">
396
+ <a class="nginx-helper-facebook" title="<?php _e('Become a fan on Facebook', 'nginx-helper'); ?>" target="_blank" href="http://www.facebook.com/rtCamp.solutions/"></a>
397
+ <a class="nginx-helper-twitter" title="<?php _e('Follow us on Twitter', 'nginx-helper'); ?>" target="_blank" href="https://twitter.com/rtcamp/"></a>
398
+ <a class="nginx-helper-rss" title="<?php _e('Subscribe to our feeds', 'nginx-helper'); ?>" target="_blank" href="http://feeds.feedburner.com/rtcamp/"></a>
399
+ </div>
400
+ </div>
401
+
402
+ <div class="postbox" id="latest_news">
403
+ <div title="<?php _e('Click to toggle', 'nginx-helper'); ?>" class="handlediv"><br /></div>
404
+ <h3 class="hndle"><span><?php _e('Latest News', 'nginx-helper'); ?></span></h3>
405
+ <div class="inside"><img src ="<?php echo admin_url(); ?>/images/wpspin_light.gif" /><?php _e('Loading...', 'nginx-helper'); ?></div>
406
+ </div><?php
407
+ }
408
+
409
+ function load_styles() {
410
+ wp_enqueue_style('rt-nginx-admin-icon', plugins_url('admin/assets/nginx-helper-icons/css/nginx-fontello.css', dirname(__FILE__)));
411
+ wp_enqueue_style('rt-nginx-admin-css', plugins_url('admin/assets/style.css', dirname(__FILE__)));
412
+ }
413
+
414
+ function load_scripts() {
415
+ $admin_js = trailingslashit(site_url()) . '?get_feeds=1';
416
+ wp_enqueue_script('nginx-js', plugins_url('admin/assets/nginx.js', dirname(__FILE__)));
417
+ wp_localize_script('nginx-js', 'news_url', $admin_js);
418
+ }
419
+
420
+ }
421
+
422
+ }
admin/assets/nginx-helper-icons/config.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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": "3e617d8049807e128c80d0344ba09e37",
11
+ "css": "rss",
12
+ "code": 59394,
13
+ "src": "entypo"
14
+ },
15
+ {
16
+ "uid": "d090355c31f497b61d676416c1fd39fb",
17
+ "css": "twitter",
18
+ "code": 59393,
19
+ "src": "entypo"
20
+ },
21
+ {
22
+ "uid": "bc50457410acf467b8b5721240768742",
23
+ "css": "facebook",
24
+ "code": 59392,
25
+ "src": "entypo"
26
+ }
27
+ ]
28
+ }
admin/assets/nginx-helper-icons/css/nginx-fontello.css ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @font-face {
2
+ font-family: 'nginx-fontello';
3
+ src: url('../font/nginx-fontello.eot?11827046');
4
+ src: url('../font/nginx-fontello.eot?11827046#iefix') format('embedded-opentype'),
5
+ url('../font/nginx-fontello.woff?11827046') format('woff'),
6
+ url('../font/nginx-fontello.ttf?11827046') format('truetype'),
7
+ url('../font/nginx-fontello.svg?11827046#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?11827046#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: '\e802'; } /* '' */
54
+ .nginx-helper-twitter:before { content: '\e801'; } /* '' */
55
+ .nginx-helper-facebook:before { content: '\e800'; } /* '' */
admin/assets/nginx-helper-icons/font/nginx-fontello.eot ADDED
Binary file
admin/assets/nginx-helper-icons/font/nginx-fontello.svg ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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="&#xe802;" d="m0 730q314 0 537-223t223-537l-118 0q0 266-188 453t-454 187l0 120z m0-238q218 0 371-153t153-369l-118 0q0 166-119 285t-287 119l0 118z m114-296q46 0 80-33t34-81q0-46-34-79t-80-33t-80 33t-34 79q0 48 34 81t80 33z" horiz-adv-x="760" />
10
+ <glyph glyph-name="twitter" unicode="&#xe801;" d="m920 636q-36-54-94-98l0-24q0-130-60-250t-186-203t-290-83q-160 0-290 84q14-2 46-2q132 0 234 80q-62 2-110 38t-66 94q10-4 34-4q26 0 50 6q-66 14-108 66t-42 120l0 2q36-20 84-24q-84 58-84 158q0 48 26 94q154-188 390-196q-6 18-6 42q0 78 55 133t135 55q82 0 136-58q60 12 120 44q-20-66-82-104q56 8 108 30z" horiz-adv-x="920" />
11
+ <glyph glyph-name="facebook" unicode="&#xe800;" 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
+ </font>
13
+ </defs>
14
+ </svg>
admin/assets/nginx-helper-icons/font/nginx-fontello.ttf ADDED
Binary file
admin/assets/nginx-helper-icons/font/nginx-fontello.woff ADDED
Binary file
admin/assets/nginx.js CHANGED
@@ -1,8 +1,8 @@
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
  });
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
  });
admin/assets/style.css CHANGED
@@ -1,59 +1,17 @@
1
- table.rtnginx-table{
2
- padding: 10px;
3
- border: 1px #CCC solid;
4
- width: 95%;
5
- margin-bottom: 10px;
6
- }
7
- pre#map{
8
- background: #e5e5e5 none;
9
- border-radius:10px;
10
- padding:10px;
11
- }
12
- #icon-options-nginx{
13
- background:transparent url(nginx-icon-32x32.png) center center no-repeat;
14
- }
15
- div#content_block form { padding-left: 25px }
16
- div#content_block { width: 70% }
17
- div#rtads{ width:30%}
18
- .align_left, .alignleft {
19
- float: left;
20
- }
21
- form#purgeall .button-primary{
22
- float: right;
23
- margin-right: 100px;
24
- height: 32px;
25
- line-height: 32px;
26
- font-weight: bold;
27
- font-size: 16px;
28
- }
29
-
30
- #social .inside a {
31
- background: url(rtp-social-icons-32-32.png) no-repeat;
32
- display: inline-block;
33
- height: 35px;
34
- margin: 0 0 0 9px;
35
- padding: 0;
36
- text-indent: -9999px;
37
- text-transform: uppercase;
38
- width: 35px;
39
- }
40
- #social .inside a.rt-nginx-facebook {
41
- background-position: 0 0;
42
- }
43
- #social .inside a.rt-nginx-facebook:hover {
44
- background-position: 0 -44px;
45
- }
46
- #social .inside a.rt-nginx-twitter {
47
- background-position: -44px 0;
48
- }
49
- #social .inside a.rt-nginx-twitter:hover {
50
- background-position: -44px -44px;
51
- }
52
- #social .inside a.rt-nginx-rss {
53
- background-position: -88px 0;
54
- }
55
- #social .inside a.rt-nginx-rss:hover {
56
- background-position: -88px -44px;
57
- }
58
-
59
-
1
+ .clearfix { *zoom: 1; }
2
+ .clearfix:before, .clearfix:after { content: " "; display: table; }
3
+ .clearfix:after { clear: both; }
4
+ h4 { margin: 0; }
5
+ .rt-nginx-wrapper .form-table td { padding: 5px; }
6
+ .form-table th, .form-wrap label { vertical-align: middle; }
7
+ table.rtnginx-table { border-bottom: 1px solid #EEE; }
8
+ pre#map { background: #e5e5e5 none; border-radius: 10px; padding: 10px; }
9
+ .wrap h2 { background: url(nginx-icon-32x32.png) 0 6px no-repeat rgba(0, 0, 0, 0); padding-left: 40px; }
10
+ form#purgeall .button-primary { float: right; height: 32px; line-height: 32px; font-weight: bold; font-size: 16px; }
11
+ .nh-aligncenter { display: block; text-align: center; line-height: 2; }
12
+ #latest_news .inside ul { margin: 0 0 0 12px }
13
+ #latest_news .inside ul li { list-style: square; padding: 0 0 7px; }
14
+ #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; }
15
+ #social .inside .nginx-helper-rss:hover { background-color: #FAA33D; }
16
+ #social .inside .nginx-helper-facebook:hover { background-color: #537BBD; }
17
+ #social .inside .nginx-helper-twitter:hover { background-color: #40BFF5; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/install.php CHANGED
@@ -10,17 +10,16 @@ namespace rtCamp\WP\Nginx {
10
  }
11
 
12
  function rt_wp_nginx_helper_install() {
13
-
14
  global $wp_roles, $rt_wp_nginx_helper;
15
 
16
- if ( ! current_user_can( 'activate_plugins' ) )
17
- return;
 
18
 
19
  $role = get_role( 'administrator' );
20
 
21
-
22
  if ( empty( $role ) ) {
23
- update_site_option( "rt_wp_nginx_helper_init_check", __( 'Sorry, you need to be an administrator to use Nginx Helper', "rt_wp_nginx_helper" ) );
24
  return;
25
  }
26
 
@@ -54,12 +53,8 @@ namespace rtCamp\WP\Nginx {
54
  }
55
 
56
  function rt_wp_nginx_helper_uninstall() {
57
-
58
  wp_clear_scheduled_hook( 'rt_wp_nginx_helper_check_log_file_size_daily' );
59
-
60
  delete_site_option( 'rt_wp_nginx_helper_options' );
61
-
62
-
63
  rt_wp_nginx_helper_remove_capability( 'Nginx Helper | Config' );
64
  rt_wp_nginx_helper_remove_capability( 'Nginx Helper | Purge cache' );
65
  }
@@ -74,10 +69,7 @@ namespace rtCamp\WP\Nginx {
74
  }
75
 
76
  function rt_wp_nginx_helper_get_options() {
77
-
78
  $rt_wp_nginx_helper_get_options = array( );
79
-
80
-
81
  $rt_wp_nginx_helper_get_options[ 'log_level' ] = 'INFO';
82
  $rt_wp_nginx_helper_get_options[ 'log_filesize' ] = 5;
83
 
@@ -103,6 +95,4 @@ namespace rtCamp\WP\Nginx {
103
 
104
  return $rt_wp_nginx_helper_get_options;
105
  }
106
-
107
- }
108
- ?>
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
 
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
  }
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
 
95
 
96
  return $rt_wp_nginx_helper_get_options;
97
  }
98
+ }
 
 
compatibility.php CHANGED
@@ -2,40 +2,36 @@
2
 
3
  namespace rtCamp\WP\Nginx {
4
 
5
- class Compatibility {
6
-
7
- protected $have_nginx;
8
-
9
- public static function instance() {
10
- static $self = false;
11
- if ( ! $self ) {
12
- $self = new Compatibility();
13
- }
14
-
15
- return $self;
16
- }
17
-
18
- private function __construct() {
19
- $this->have_nginx = ('nginx' == substr( $_SERVER[ 'SERVER_SOFTWARE' ], 0, 5 ));
20
- if ( $this->have_nginx ) {
21
- add_filter( 'got_rewrite', array( $this, 'got_rewrite' ), 999 );
22
-
23
- // For compatibility with several plugins and nginx HTTPS proxying schemes
24
- if ( empty( $_SERVER[ 'HTTPS' ] ) || 'off' == $_SERVER[ 'HTTPS' ] ) {
25
- unset( $_SERVER[ 'HTTPS' ] );
26
- }
27
- }
28
- }
29
-
30
- public function got_rewrite( $got ) {
31
- return true;
32
- }
33
-
34
- public function haveNginx() {
35
- return $this->have_nginx;
36
- }
37
-
38
- }
39
-
40
- }
41
- ?>
2
 
3
  namespace rtCamp\WP\Nginx {
4
 
5
+ class Compatibility {
6
+
7
+ protected $have_nginx;
8
+
9
+ public static function instance() {
10
+ static $self = false;
11
+ if (!$self) {
12
+ $self = new Compatibility();
13
+ }
14
+ return $self;
15
+ }
16
+
17
+ private function __construct() {
18
+ $this->have_nginx = ('nginx' == substr($_SERVER['SERVER_SOFTWARE'], 0, 5));
19
+ if ($this->have_nginx) {
20
+ add_filter('got_rewrite', array($this, 'got_rewrite'), 999);
21
+
22
+ // For compatibility with several plugins and nginx HTTPS proxying schemes
23
+ if (empty($_SERVER['HTTPS']) || 'off' == $_SERVER['HTTPS']) {
24
+ unset($_SERVER['HTTPS']);
25
+ }
26
+ }
27
+ }
28
+
29
+ public function got_rewrite($got) {
30
+ return true;
31
+ }
32
+
33
+ public function haveNginx() {
34
+ return $this->have_nginx;
35
+ }
36
+ }
37
+ }
 
 
 
 
languages/nginx-helper.mo ADDED
Binary file
languages/nginx-helper.po ADDED
@@ -0,0 +1,424 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Nginx Helper 1.7.6\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2013-12-23 15:39+0530\n"
6
+ "PO-Revision-Date: 2013-12-23 15:39+0530\n"
7
+ "Last-Translator: rtCamp <support@rtcamp.com>\n"
8
+ "Language-Team: rtCampers <support@rtcamp.com>\n"
9
+ "Language: en\n"
10
+ "MIME-Version: 1.0\n"
11
+ "Content-Type: text/plain; charset=UTF-8\n"
12
+ "Content-Transfer-Encoding: 8bit\n"
13
+ "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c\n"
14
+ "X-Poedit-Basepath: .\n"
15
+ "Plural-Forms: nplurals=2; plural=n != 1;\n"
16
+ "X-Generator: Poedit 1.6.3\n"
17
+ "X-Poedit-SearchPath-0: ..\n"
18
+
19
+ #: ../nginx-helper.php:257
20
+ msgid "Purge initiated"
21
+ msgstr ""
22
+
23
+ #: ../nginx-helper.php:340
24
+ msgid "Settings"
25
+ msgstr ""
26
+
27
+ #: ../nginx-helper.php:367
28
+ msgid "No items"
29
+ msgstr ""
30
+
31
+ #: ../nginx-helper.php:372
32
+ msgid "Posted "
33
+ msgstr ""
34
+
35
+ #: ../purger.php:366
36
+ #, php-format
37
+ msgid "Purging homepage '%s'"
38
+ msgstr ""
39
+
40
+ #: ../purger.php:376
41
+ msgid "Purging personal urls"
42
+ msgstr ""
43
+
44
+ #: ../purger.php:384
45
+ msgid "No personal urls available"
46
+ msgstr ""
47
+
48
+ #: ../purger.php:392
49
+ msgid "Purging category archives"
50
+ msgstr ""
51
+
52
+ #: ../purger.php:396
53
+ #, php-format
54
+ msgid "Purging category '%d'"
55
+ msgstr ""
56
+
57
+ #: ../purger.php:406
58
+ msgid "Purging tags archives"
59
+ msgstr ""
60
+
61
+ #: ../purger.php:410 ../purger.php:468
62
+ #, php-format
63
+ msgid "Purging tag '%s' (id %d)"
64
+ msgstr ""
65
+
66
+ #: ../purger.php:420
67
+ msgid "Purging post custom taxonomies related"
68
+ msgstr ""
69
+
70
+ #: ../purger.php:424 ../purger.php:485
71
+ #, php-format
72
+ msgid "Purging custom taxonomy '%s'"
73
+ msgstr ""
74
+
75
+ #: ../purger.php:434 ../purger.php:495
76
+ #, php-format
77
+ msgid "Your built-in taxonomy '%s' has param '_builtin' set to false."
78
+ msgstr ""
79
+
80
+ #: ../purger.php:438 ../purger.php:499
81
+ msgid "No custom taxonomies"
82
+ msgstr ""
83
+
84
+ #: ../purger.php:446
85
+ msgid "Purging all categories"
86
+ msgstr ""
87
+
88
+ #: ../purger.php:451
89
+ #, php-format
90
+ msgid "Purging category '%s' (id %d)"
91
+ msgstr ""
92
+
93
+ #: ../purger.php:455
94
+ msgid "No categories archives"
95
+ msgstr ""
96
+
97
+ #: ../purger.php:463
98
+ msgid "Purging all tags"
99
+ msgstr ""
100
+
101
+ #: ../purger.php:472
102
+ msgid "No tags archives"
103
+ msgstr ""
104
+
105
+ #: ../purger.php:480
106
+ msgid "Purging all custom taxonomies"
107
+ msgstr ""
108
+
109
+ #: ../purger.php:516
110
+ msgid "Purging all posts, pages and custom post types."
111
+ msgstr ""
112
+
113
+ #: ../purger.php:526
114
+ #, php-format
115
+ msgid "Purging post id '%d' (post type '%s')"
116
+ msgstr ""
117
+
118
+ #: ../purger.php:530
119
+ msgid "No posts"
120
+ msgstr ""
121
+
122
+ #: ../purger.php:538
123
+ msgid "Purging all date-based archives."
124
+ msgstr ""
125
+
126
+ #: ../purger.php:553
127
+ msgid "Purging all daily archives."
128
+ msgstr ""
129
+
130
+ #: ../purger.php:566
131
+ #, php-format
132
+ msgid "Purging daily archive '%s/%s/%s'"
133
+ msgstr ""
134
+
135
+ #: ../purger.php:570
136
+ msgid "No daily archives"
137
+ msgstr ""
138
+
139
+ #: ../purger.php:578
140
+ msgid "Purging all monthly archives."
141
+ msgstr ""
142
+
143
+ #: ../purger.php:591
144
+ #, php-format
145
+ msgid "Purging monthly archive '%s/%s'"
146
+ msgstr ""
147
+
148
+ #: ../purger.php:595
149
+ msgid "No monthly archives"
150
+ msgstr ""
151
+
152
+ #: ../purger.php:603
153
+ msgid "Purging all yearly archives."
154
+ msgstr ""
155
+
156
+ #: ../purger.php:616
157
+ #, php-format
158
+ msgid "Purging yearly archive '%s'"
159
+ msgstr ""
160
+
161
+ #: ../purger.php:620
162
+ msgid "No yearly archives"
163
+ msgstr ""
164
+
165
+ #: ../purger.php:626
166
+ msgid "Let's purge everything!"
167
+ msgstr ""
168
+
169
+ #: ../purger.php:638
170
+ msgid "Everthing purged!"
171
+ msgstr ""
172
+
173
+ #: ../purger.php:645
174
+ msgid "Term taxonomy edited or deleted"
175
+ msgstr ""
176
+
177
+ #: ../purger.php:648
178
+ #, php-format
179
+ msgid "Term taxonomy '%s' edited, (tt_id '%d', term_id '%d', taxonomy '%s')"
180
+ msgstr ""
181
+
182
+ #: ../purger.php:650
183
+ #, php-format
184
+ msgid ""
185
+ "A term taxonomy has been deleted from taxonomy '%s', (tt_id '%d', term_id "
186
+ "'%d')"
187
+ msgstr ""
188
+
189
+ #: ../purger.php:663
190
+ msgid "Widget saved, moved or removed in a sidebar"
191
+ msgstr ""
192
+
193
+ #: ../admin/admin.php:19 ../admin/admin.php:24
194
+ msgid "Nginx Helper"
195
+ msgstr ""
196
+
197
+ #: ../admin/admin.php:92
198
+ msgid "Nginx Settings"
199
+ msgstr ""
200
+
201
+ #: ../admin/admin.php:97
202
+ msgid "Plugin Options"
203
+ msgstr ""
204
+
205
+ #: ../admin/admin.php:103 ../admin/admin.php:376
206
+ msgid "Purge Cache"
207
+ msgstr ""
208
+
209
+ #: ../admin/admin.php:114
210
+ msgid "Enable Cache Purge (requires external settings for nginx)"
211
+ msgstr ""
212
+
213
+ #: ../admin/admin.php:121
214
+ msgid "Enable Nginx Map."
215
+ msgstr ""
216
+
217
+ #: ../admin/admin.php:128
218
+ msgid "Enable Logging"
219
+ msgstr ""
220
+
221
+ #: ../admin/admin.php:134
222
+ msgid "Enable Nginx Timestamp in HTML"
223
+ msgstr ""
224
+
225
+ #: ../admin/admin.php:146
226
+ msgid "Purging Options"
227
+ msgstr ""
228
+
229
+ #: ../admin/admin.php:152
230
+ msgid "Purge Homepage:"
231
+ msgstr ""
232
+
233
+ #: ../admin/admin.php:156
234
+ msgid "when a post/page/custom post is modified or added."
235
+ msgstr ""
236
+
237
+ #: ../admin/admin.php:160 ../admin/admin.php:223
238
+ msgid ""
239
+ "when a <strong>post</strong> (or page/custom post) is <strong>modified</"
240
+ "strong> or <strong>added</strong>."
241
+ msgstr ""
242
+
243
+ #: ../admin/admin.php:165
244
+ msgid "when an existing post/page/custom post is modified."
245
+ msgstr ""
246
+
247
+ #: ../admin/admin.php:169 ../admin/admin.php:232
248
+ msgid ""
249
+ "when a <strong>published post</strong> (or page/custom post) is "
250
+ "<strong>trashed</strong>."
251
+ msgstr ""
252
+
253
+ #: ../admin/admin.php:177
254
+ msgid "Purge Post/Page/Custom Post Type:"
255
+ msgstr ""
256
+
257
+ #: ../admin/admin.php:182
258
+ msgid "when a post/page/custom post is published."
259
+ msgstr ""
260
+
261
+ #: ../admin/admin.php:186
262
+ msgid "when a <strong>post</strong> is <strong>published</strong>."
263
+ msgstr ""
264
+
265
+ #: ../admin/admin.php:191
266
+ msgid "when a comment is approved/published."
267
+ msgstr ""
268
+
269
+ #: ../admin/admin.php:195 ../admin/admin.php:242
270
+ msgid "when a <strong>comment</strong> is <strong>approved/published</strong>."
271
+ msgstr ""
272
+
273
+ #: ../admin/admin.php:200
274
+ msgid "when a comment is unapproved/deleted."
275
+ msgstr ""
276
+
277
+ #: ../admin/admin.php:204 ../admin/admin.php:251
278
+ msgid "when a <strong>comment</strong> is <strong>unapproved/deleted</strong>."
279
+ msgstr ""
280
+
281
+ #: ../admin/admin.php:213
282
+ msgid "Purge Archives:"
283
+ msgstr ""
284
+
285
+ #: ../admin/admin.php:214
286
+ msgid "(date, category, tag, author, custom taxonomies)"
287
+ msgstr ""
288
+
289
+ #: ../admin/admin.php:219
290
+ msgid "when an post/page/custom post is modified or added.</span>"
291
+ msgstr ""
292
+
293
+ #: ../admin/admin.php:228
294
+ msgid "when an existing post/page/custom post is trashed.</span>"
295
+ msgstr ""
296
+
297
+ #: ../admin/admin.php:238
298
+ msgid "when a comment is approved/published.</span>"
299
+ msgstr ""
300
+
301
+ #: ../admin/admin.php:247
302
+ msgid "when a comment is unapproved/deleted.</span>"
303
+ msgstr ""
304
+
305
+ #: ../admin/admin.php:264
306
+ msgid "Nginx Map"
307
+ msgstr ""
308
+
309
+ #: ../admin/admin.php:268
310
+ #, php-format
311
+ msgid ""
312
+ "Can't write on map file.<br /><br />Check you have write permission on "
313
+ "<strong>%s</strong>"
314
+ msgstr ""
315
+
316
+ #: ../admin/admin.php:273
317
+ msgid ""
318
+ "Nginx Map path to include in nginx settings<br /><small>(recommended)</small>"
319
+ msgstr ""
320
+
321
+ #: ../admin/admin.php:279
322
+ msgid ""
323
+ "Or,<br />Text to manually copy and paste in nginx settings<br /><small>(if "
324
+ "your network is small and new sites are not added frequently)</small>"
325
+ msgstr ""
326
+
327
+ #: ../admin/admin.php:290
328
+ msgid "Logging"
329
+ msgstr ""
330
+
331
+ #: ../admin/admin.php:309
332
+ #, php-format
333
+ msgid ""
334
+ "Can't write on log file.<br /><br />Check you have write permission on "
335
+ "<strong>%s</strong>"
336
+ msgstr ""
337
+
338
+ #: ../admin/admin.php:315
339
+ msgid "Logs path"
340
+ msgstr ""
341
+
342
+ #: ../admin/admin.php:319
343
+ msgid "View Log"
344
+ msgstr ""
345
+
346
+ #: ../admin/admin.php:320
347
+ msgid "Log"
348
+ msgstr ""
349
+
350
+ #: ../admin/admin.php:323
351
+ msgid "Log level"
352
+ msgstr ""
353
+
354
+ #: ../admin/admin.php:326
355
+ msgid "None"
356
+ msgstr ""
357
+
358
+ #: ../admin/admin.php:327
359
+ msgid "Info"
360
+ msgstr ""
361
+
362
+ #: ../admin/admin.php:328
363
+ msgid "Warning"
364
+ msgstr ""
365
+
366
+ #: ../admin/admin.php:329
367
+ msgid "Error"
368
+ msgstr ""
369
+
370
+ #: ../admin/admin.php:334
371
+ msgid "Max log file size"
372
+ msgstr ""
373
+
374
+ #: ../admin/admin.php:336
375
+ msgid "Mb"
376
+ msgstr ""
377
+
378
+ #: ../admin/admin.php:353
379
+ msgid "Save"
380
+ msgstr ""
381
+
382
+ #: ../admin/admin.php:382 ../admin/admin.php:391 ../admin/admin.php:403
383
+ msgid "Click to toggle"
384
+ msgstr ""
385
+
386
+ #: ../admin/admin.php:383
387
+ msgid "Need Help?"
388
+ msgstr ""
389
+
390
+ #: ../admin/admin.php:386
391
+ #, php-format
392
+ msgid ""
393
+ "Please use our <a href=\"%s\">free support forum</a>.<span class=\"nh-"
394
+ "aligncenter\">OR</span><a href=\"%s\">Hire us!</a> for wordpress on nginx "
395
+ "solutions."
396
+ msgstr ""
397
+
398
+ #: ../admin/admin.php:393
399
+ msgid "Getting Social is Good"
400
+ msgstr ""
401
+
402
+ #: ../admin/admin.php:396
403
+ msgid "Become a fan on Facebook"
404
+ msgstr ""
405
+
406
+ #: ../admin/admin.php:397
407
+ msgid "Follow us on Twitter"
408
+ msgstr ""
409
+
410
+ #: ../admin/admin.php:398
411
+ msgid "Subscribe to our feeds"
412
+ msgstr ""
413
+
414
+ #: ../admin/admin.php:404
415
+ msgid "Latest News"
416
+ msgstr ""
417
+
418
+ #: ../admin/admin.php:405
419
+ msgid "Loading..."
420
+ msgstr ""
421
+
422
+ #: ../admin/install.php:22
423
+ msgid "Sorry, you need to be an administrator to use Nginx Helper"
424
+ msgstr ""
nginx-helper.php CHANGED
@@ -3,405 +3,385 @@
3
  Plugin Name: Nginx Helper
4
  Plugin URI: http://rtcamp.com/nginx-helper/
5
  Description: An nginx helper that serves various functions.
6
- Version: 1.7.5
7
  Author: rtCamp
8
  Author URI: http://rtcamp.com
 
9
  Requires at least: 3.0
10
- Tested up to: 3.6
11
  */
12
- namespace rtCamp\WP\Nginx {
13
- define( 'rtCamp\WP\Nginx\RT_WP_NGINX_HELPER_PATH', plugin_dir_path( __FILE__ ) );
14
- define( 'rtCamp\WP\Nginx\RT_WP_NGINX_HELPER_URL', plugin_dir_url( __FILE__ ) );
15
-
16
-
17
- class Helper {
18
-
19
- var $minium_WP = '3.0';
20
- var $options = null;
21
- var $plugin_name = 'nginx-helper';
22
-
23
- function __construct() {
24
-
25
- if ( ! $this->required_wp_version() )
26
- if ( ! $this->required_php_version() )
27
- return;
28
-
29
- $this->load_options();
30
- $this->plugin_name = plugin_basename( __FILE__ );
31
-
32
- register_activation_hook( $this->plugin_name, array( &$this, 'activate' ) );
33
- register_deactivation_hook( $this->plugin_name, array( &$this, 'deactivate' ) );
34
-
35
- add_action( 'init', array( &$this, 'start_helper' ), 15 );
36
- }
37
-
38
- function start_helper() {
39
-
40
- global $rt_wp_nginx_purger;
41
- add_action( 'shutdown', array( &$this, 'add_timestamps' ), 99999 );
42
- add_action( 'add_init', array( &$this, 'update_map' ) );
43
-
44
- add_action( 'publish_post', array( &$rt_wp_nginx_purger, 'purgePost' ), 200, 1 );
45
- add_action( 'publish_page', array( &$rt_wp_nginx_purger, 'purgePost' ), 200, 1 );
46
- add_action( 'wp_insert_comment', array( &$rt_wp_nginx_purger, 'purgePostOnComment' ), 200, 2 );
47
- add_action( 'transition_comment_status', array( &$rt_wp_nginx_purger, 'purgePostOnCommentChange' ), 200, 3 );
48
-
49
- $args = array( '_builtin' => false );
50
- $_rt_custom_post_types = get_post_types( $args );
51
- if ( isset( $post_types ) && ! empty( $post_types ) ) {
52
- if ( $this->options[ 'rt_wp_custom_post_types' ] == true ) {
53
- foreach ( $_rt_custom_post_types as $post_type ) {
54
- add_action( 'publish_' . trim( $post_type ), array( &$rt_wp_nginx_purger, 'purgePost' ), 200, 1 );
55
- }
56
- }
57
- }
58
-
59
- add_action( 'transition_post_status', array( &$this, 'set_future_post_option_on_future_status' ), 20, 3 );
60
- add_action( 'delete_post', array( &$this, 'unset_future_post_option_on_delete' ), 20, 1 );
61
-
62
- add_action( 'nm_check_log_file_size_daily', array( &$rt_wp_nginx_purger, 'checkAndTruncateLogFile' ), 100, 1 );
63
-
64
- add_action( 'edit_attachment', array( &$rt_wp_nginx_purger, 'purgeImageOnEdit' ), 100, 1 );
65
-
66
- add_action( 'wpmu_new_blog', array( &$this, 'update_new_blog_options' ), 10, 1 );
67
-
68
- add_action( 'transition_post_status', array( &$rt_wp_nginx_purger, 'purge_on_post_moved_to_trash' ), 20, 3 );
69
-
70
- add_action( 'edit_term', array( &$rt_wp_nginx_purger, 'purge_on_term_taxonomy_edited' ), 20, 3 );
71
- add_action( 'delete_term', array( &$rt_wp_nginx_purger, 'purge_on_term_taxonomy_edited' ), 20, 3 );
72
-
73
- add_action( 'check_ajax_referer', array( &$rt_wp_nginx_purger, 'purge_on_check_ajax_referer' ), 20, 2 );
74
- add_action( 'admin_init', array( &$this, 'purge_all' ) );
75
- }
76
-
77
- function activate() {
78
-
79
- $path = $this->functional_asset_path();
80
- if(!is_dir($path)){
81
- mkdir($path);
82
- }
83
- include_once (RT_WP_NGINX_HELPER_PATH . 'admin/install.php');
84
-
85
- rt_wp_nginx_helper_install();
86
- }
87
-
88
- function deactivate() {
89
- include_once (RT_WP_NGINX_HELPER_PATH . 'admin/install.php');
90
- rt_wp_nginx_helper_uninstall();
91
- }
92
-
93
-
94
- function required_wp_version() {
95
-
96
- global $wp_version;
97
- $wp_ok = version_compare( $wp_version, $this->minium_WP, '>=' );
98
-
99
- if ( ($wp_ok == FALSE ) ) {
100
- add_action(
101
- 'admin_notices', create_function(
102
- '', 'global $rt_wp_nginx_helper; printf (\'<div id="message" class="error"><p><strong>\' . __(\'Sorry, Nginx Helper requires WordPress %s or higher\', "rt_wp_nginx_helper" ) . \'</strong></p></div>\', $rt_wp_nginx_helper->minium_WP );'
103
- )
104
- );
105
- return false;
106
- }
107
-
108
- return true;
109
- }
110
-
111
-
112
- function load_options() {
113
- $this->options = get_site_option( 'rt_wp_nginx_helper_options' );
114
- }
115
-
116
- function set_future_post_option_on_future_status( $new_status, $old_status, $post ) {
117
-
118
- global $blog_id, $rt_wp_nginx_purger;
119
- if ( ! $this->options[ 'enable_purge' ] ) {
120
- return;
121
- }
122
- if ( $old_status != $new_status
123
- && $old_status != 'inherit'
124
- && $new_status != 'inherit'
125
- && $old_status != 'auto-draft'
126
- && $new_status != 'auto-draft'
127
- && $new_status != 'publish'
128
- && ! wp_is_post_revision( $post->ID ) ) {
129
- $rt_wp_nginx_purger->log( "Purge post on transition post STATUS from " . $old_status . " to " . $new_status );
130
- $rt_wp_nginx_purger->purgePost( $post->ID );
131
- }
132
-
133
- if ( $new_status == 'future' ) {
134
- if ( $post && $post->post_status == 'future' && ( ( $post->post_type == 'post' || $post->post_type == 'page' ) || ( in_array( $post->post_type, $this->options[ 'custom_post_types_recognized' ] ) ) ) ) {
135
- $rt_wp_nginx_purger->log( "Set/update future_posts option (post id = " . $post->ID . " and blog id = " . $blog_id . ")" );
136
- $this->options[ 'future_posts' ][ $blog_id ][ $post->ID ] = strtotime( $post->post_date_gmt ) + 60;
137
- update_site_option( "rt_wp_nginx_helper_global_options", $this->options );
138
- }
139
- }
140
- }
141
-
142
- function unset_future_post_option_on_delete( $post_id ) {
143
-
144
- global $blog_id, $rt_wp_nginx_purger;
145
- if ( ! $this->options[ 'enable_purge' ] ) {
146
- return;
147
- }
148
- if ( $post_id && ! wp_is_post_revision( $post_id ) ) {
149
-
150
- if ( isset( $this->options[ 'future_posts' ][ $blog_id ][ $post_id ] ) && count( $this->options[ 'future_posts' ][ $blog_id ][ $post_id ] ) ) {
151
- $rt_wp_nginx_purger->log( "Unset future_posts option (post id = " . $post_id . " and blog id = " . $blog_id . ")" );
152
- unset( $this->options[ 'future_posts' ][ $blog_id ][ $post_id ] );
153
- update_site_option( "rt_wp_nginx_helper_global_options", $this->options );
154
-
155
- if ( ! count( $this->options[ 'future_posts' ][ $blog_id ] ) ) {
156
- unset( $this->options[ 'future_posts' ][ $blog_id ] );
157
- update_site_option( "rt_wp_nginx_helper_global_options", $this->options );
158
- }
159
- }
160
- }
161
- }
162
-
163
- function update_new_blog_options( $blog_id ) {
164
-
165
- global $rt_wp_nginx_purger;
166
-
167
- include_once (RT_WP_NGINX_HELPER_PATH . 'admin/install.php');
168
-
169
- $rt_wp_nginx_purger->log( "New site added (id $blog_id)" );
170
-
171
- $this->update_map();
172
-
173
- $rt_wp_nginx_purger->log( "New site added to nginx map (id $blog_id)" );
174
-
175
- $helper_options = rt_wp_nginx_helper_get_options();
176
-
177
- update_blog_option( $blog_id, "rt_wp_nginx_helper_options", $helper_options, true );
178
-
179
- $rt_wp_nginx_purger->log( "Default options updated for the new blog (id $blog_id)" );
180
- }
181
-
182
- function get_map() {
183
- if ( ! $this->options[ 'enable_map' ] ) {
184
- return;
185
- }
186
-
187
- if ( is_multisite() ) {
188
-
189
- global $wpdb;
190
-
191
- $rt_all_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT blog_id, domain, path FROM " . $wpdb->blogs . " WHERE site_id = %d AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0'", $wpdb->siteid ) );
192
- $wpdb->dmtable = $wpdb->base_prefix . 'domain_mapping';
193
- if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->dmtable}'" ) == $wpdb->dmtable ) {
194
- $rt_domain_map_sites = $wpdb->get_results( "SELECT blog_id, domain FROM {$wpdb->dmtable} ORDER BY id DESC" );
195
- }
196
- $rt_nginx_map = "";
197
- $rt_nginx_map_array = array( );
198
-
199
-
200
- if ( $rt_all_blogs )
201
- foreach ( $rt_all_blogs as $blog ) {
202
- if ( SUBDOMAIN_INSTALL == "yes" ) {
203
- $rt_nginx_map_array[ $blog->domain ] = $blog->blog_id;
204
- } else {
205
- if ( $blog->blog_id != 1 ) {
206
- $rt_nginx_map_array[ $blog->path ] = $blog->blog_id;
207
- }
208
- }
209
- }
210
-
211
- if ( $rt_domain_map_sites ) {
212
- foreach ( $rt_domain_map_sites as $site ) {
213
- $rt_nginx_map_array[ $site->domain ] = $site->blog_id;
214
- }
215
- }
216
-
217
- foreach ( $rt_nginx_map_array as $domain => $domain_id ) {
218
- $rt_nginx_map .= "\t" . $domain . "\t" . $domain_id . ";\n";
219
- }
220
-
221
- return $rt_nginx_map;
222
- }
223
- }
224
-
225
- function functional_asset_path(){
226
- $dir = wp_upload_dir();
227
- $path = $dir['basedir'].'/nginx-helper/';
228
- return $path;
229
- }
230
-
231
- function functional_asset_url(){
232
- $dir = wp_upload_dir();
233
- $url = $dir['baseurl'].'/nginx-helper/';
234
-
235
- return $url;
236
- }
237
-
238
- function update_map() {
239
- if ( is_multisite() ) {
240
- $rt_nginx_map = $this->get_map();
241
-
242
- if ( $fp = fopen( $this->functional_asset_path() . 'map.conf', 'w+' ) ) {
243
- fwrite( $fp, $rt_nginx_map );
244
- fclose( $fp );
245
- return true;
246
- }
247
- }
248
- }
249
-
250
- function add_timestamps() {
251
- if ( $this->options[ 'enable_purge' ] != 1 )
252
- return;
253
- if ( $this->options[ 'enable_stamp' ] != 1 )
254
- return;
255
- if (is_admin())
256
- return;
257
- foreach (headers_list() as $header) {
258
- list($key,$value) = explode(':',$header,2);
259
- if($key == 'Content-Type' && strpos(trim($value),'text/html') !== 0) {
260
- return;
261
- }
262
- if($key == 'Content-Type') break;
263
- }
264
-
265
- if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
266
- return;
267
- $timestamps = "\n<!--" .
268
- "Cached using Nginx-Helper on " . current_time( 'mysql' ) . ". " .
269
- "It took " . get_num_queries() . " queries executed in " . timer_stop() . " seconds." .
270
- "-->\n" .
271
- "<!--Visit http://wordpress.org/extend/plugins/nginx-helper/faq/ for more details-->";
272
- echo $timestamps;
273
- }
274
-
275
- function show_notice() {
276
- echo '<div class="updated"><p>Purge initiated</p></div>';
277
- }
278
-
279
- function purge_all() {
280
- global $rt_wp_nginx_purger;
281
- if ( ! isset( $_REQUEST[ 'nginx_helper_action' ] ) )
282
- return;
283
-
284
- if ( ! current_user_can( 'manage_options' ) )
285
- wp_die( 'Sorry, you do not have the necessary privileges to edit these options.' );
286
-
287
- $action = $_REQUEST[ 'nginx_helper_action' ];
288
-
289
- if ( $action == 'done' ) {
290
- add_action( 'admin_notices', array( &$this, 'show_notice' ) );
291
- return;
292
- }
293
-
294
- check_admin_referer( 'nginx_helper-purge_all' );
295
-
296
- switch ( $action ) {
297
- case 'purge':
298
- $rt_wp_nginx_purger->true_purge_all();
299
- break;
300
- }
301
-
302
- wp_redirect( add_query_arg( array( 'nginx_helper_action' => 'done' ) ) );
303
- }
304
-
305
- }
306
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
307
  }
308
 
309
  namespace {
310
 
311
- if (!defined('RT_WP_NGINX_HELPER_CACHE_PATH')){
312
- define( 'RT_WP_NGINX_HELPER_CACHE_PATH','/var/run/nginx-cache');
313
- }
314
- global $current_blog;
315
-
316
- if ( is_admin() ) {
317
- require_once (rtCamp\WP\Nginx\RT_WP_NGINX_HELPER_PATH . '/admin/admin.php');
318
- $rtwpAdminPanel = new \rtCamp\WP\Nginx\Admin();
319
- }
320
-
321
- require_once (rtCamp\WP\Nginx\RT_WP_NGINX_HELPER_PATH . 'purger.php');
322
-
323
- require_once (rtCamp\WP\Nginx\RT_WP_NGINX_HELPER_PATH . 'compatibility.php');
324
-
325
- global $rt_wp_nginx_helper, $rt_wp_nginx_purger, $rt_wp_nginx_compatibility;
326
- $rt_wp_nginx_helper = new \rtCamp\WP\Nginx\Helper;
327
- $rt_wp_nginx_purger = new \rtCamp\WP\Nginx\Purger;
328
- $rt_wp_nginx_compatibility = namespace\rtCamp\WP\Nginx\Compatibility::instance();
329
- if ( $rt_wp_nginx_compatibility->haveNginx() && ! function_exists( 'wp_redirect' ) ) {
330
-
331
- function wp_redirect( $location, $status = 302 ) {
332
- $location = apply_filters( 'wp_redirect', $location, $status );
333
-
334
- if ( empty( $location ) ) {
335
- return false;
336
- }
337
-
338
- $status = apply_filters( 'wp_redirect_status', $status, $location );
339
- if ( $status < 300 || $status > 399 ) {
340
- $status = 302;
341
- }
342
-
343
- $location = wp_sanitize_redirect( $location );
344
- header( 'Location: ' . $location, true, $status );
345
- }
346
-
347
- }
348
-
349
- // Add settings link on plugin page
350
- function nginx_settings_link( $links ) {
351
- if ( is_network_admin() ) {
352
- $u = 'settings.php';
353
- } else {
354
- $u = 'options-general.php';
355
- }
356
- $settings_link = '<a href="' . $u . '?page=nginx">Settings</a>';
357
- array_unshift( $links, $settings_link );
358
- return $links;
359
- }
360
-
361
- $plugin = plugin_basename( __FILE__ );
362
- if ( is_multisite() ) {
363
- add_filter( "network_admin_plugin_action_links_$plugin", 'nginx_settings_link' );
364
- } else {
365
- add_filter( "plugin_action_links_$plugin", 'nginx_settings_link' );
366
- }
367
-
368
- function get_feeds( $feed_url = 'http://rtcamp.com/blog/feed/' ) {
369
- // Get RSS Feed(s)
370
- require_once( ABSPATH . WPINC . '/feed.php' );
371
- $maxitems = 0;
372
- // Get a SimplePie feed object from the specified feed source.
373
- $rss = fetch_feed( $feed_url );
374
- if ( ! is_wp_error( $rss ) ) { // Checks that the object is created correctly
375
- // Figure out how many total items there are, but limit it to 5.
376
- $maxitems = $rss->get_item_quantity( 5 );
377
-
378
- // Build an array of all the items, starting with element 0 (first element).
379
- $rss_items = $rss->get_items( 0, $maxitems );
380
- }
381
- ?>
382
- <ul><?php
383
- if ( $maxitems == 0 ) {
384
- echo '<li>' . __( 'No items', 'bp-media' ) . '.</li>';
385
- } else {
386
- // Loop through each feed item and display each item as a hyperlink.
387
- foreach ( $rss_items as $item ) {
388
- ?>
389
- <li>
390
- <a href='<?php echo $item->get_permalink(); ?>' title='<?php echo __( 'Posted ', 'bp-media' ) . $item->get_date( 'j F Y | g:i a' ); ?>'><?php echo $item->get_title(); ?></a>
391
- </li><?php
392
- }
393
- }
394
- ?>
395
- </ul><?php
396
- }
397
-
398
- function fetch_feeds() {
399
- if ( isset( $_GET[ 'get_feeds' ] ) && $_GET[ 'get_feeds' ] == '1' ) {
400
- get_feeds();
401
- die();
402
- }
403
- }
404
-
405
- add_action( 'init', 'fetch_feeds' );
406
- }
407
- ?>
3
  Plugin Name: Nginx Helper
4
  Plugin URI: http://rtcamp.com/nginx-helper/
5
  Description: An nginx helper that serves various functions.
6
+ Version: 1.7.6
7
  Author: rtCamp
8
  Author URI: http://rtcamp.com
9
+ Text Domain: nginx-helper
10
  Requires at least: 3.0
11
+ Tested up to: 3.8
12
  */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
+ namespace rtCamp\WP\Nginx {
15
+ define('rtCamp\WP\Nginx\RT_WP_NGINX_HELPER_PATH', plugin_dir_path(__FILE__));
16
+ define('rtCamp\WP\Nginx\RT_WP_NGINX_HELPER_URL', plugin_dir_url(__FILE__));
17
+
18
+ class Helper {
19
+
20
+ var $minium_WP = '3.0';
21
+ var $options = null;
22
+ var $plugin_name = 'nginx-helper';
23
+
24
+ function __construct() {
25
+
26
+ if (!$this->required_wp_version())
27
+ if (!$this->required_php_version())
28
+ return;
29
+
30
+ // Load Plugin Text Domain
31
+ add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
32
+
33
+ $this->load_options();
34
+ $this->plugin_name = plugin_basename(__FILE__);
35
+
36
+ register_activation_hook($this->plugin_name, array(&$this, 'activate'));
37
+ register_deactivation_hook($this->plugin_name, array(&$this, 'deactivate'));
38
+
39
+ add_action( 'init', array( &$this, 'start_helper' ), 15 );
40
+ }
41
+
42
+ function start_helper() {
43
+
44
+ global $rt_wp_nginx_purger;
45
+ add_action('shutdown', array(&$this, 'add_timestamps'), 99999);
46
+ add_action('add_init', array(&$this, 'update_map'));
47
+
48
+ add_action('publish_post', array(&$rt_wp_nginx_purger, 'purgePost'), 200, 1);
49
+ add_action('publish_page', array(&$rt_wp_nginx_purger, 'purgePost'), 200, 1);
50
+ add_action('wp_insert_comment', array(&$rt_wp_nginx_purger, 'purgePostOnComment'), 200, 2);
51
+ add_action('transition_comment_status', array(&$rt_wp_nginx_purger, 'purgePostOnCommentChange'), 200, 3);
52
+
53
+ $args = array('_builtin' => false);
54
+ $_rt_custom_post_types = get_post_types($args);
55
+ if (isset($post_types) && !empty($post_types)) {
56
+ if ($this->options['rt_wp_custom_post_types'] == true) {
57
+ foreach ($_rt_custom_post_types as $post_type) {
58
+ add_action('publish_' . trim($post_type), array(&$rt_wp_nginx_purger, 'purgePost'), 200, 1);
59
+ }
60
+ }
61
+ }
62
+
63
+ add_action('transition_post_status', array(&$this, 'set_future_post_option_on_future_status'), 20, 3);
64
+ add_action('delete_post', array(&$this, 'unset_future_post_option_on_delete'), 20, 1);
65
+ add_action('nm_check_log_file_size_daily', array(&$rt_wp_nginx_purger, 'checkAndTruncateLogFile'), 100, 1);
66
+ add_action('edit_attachment', array(&$rt_wp_nginx_purger, 'purgeImageOnEdit'), 100, 1);
67
+ add_action('wpmu_new_blog', array(&$this, 'update_new_blog_options'), 10, 1);
68
+ add_action('transition_post_status', array(&$rt_wp_nginx_purger, 'purge_on_post_moved_to_trash'), 20, 3);
69
+ add_action('edit_term', array(&$rt_wp_nginx_purger, 'purge_on_term_taxonomy_edited'), 20, 3);
70
+ add_action('delete_term', array(&$rt_wp_nginx_purger, 'purge_on_term_taxonomy_edited'), 20, 3);
71
+ add_action('check_ajax_referer', array(&$rt_wp_nginx_purger, 'purge_on_check_ajax_referer'), 20, 2);
72
+ add_action('admin_init', array(&$this, 'purge_all'));
73
+ }
74
+
75
+ function activate() {
76
+
77
+ $path = $this->functional_asset_path();
78
+ if (!is_dir($path)) {
79
+ mkdir($path);
80
+ }
81
+ include_once (RT_WP_NGINX_HELPER_PATH . 'admin/install.php');
82
+ rt_wp_nginx_helper_install();
83
+ }
84
+
85
+ function deactivate() {
86
+ include_once (RT_WP_NGINX_HELPER_PATH . 'admin/install.php');
87
+ rt_wp_nginx_helper_uninstall();
88
+ }
89
+
90
+ function required_wp_version() {
91
+
92
+ global $wp_version;
93
+ $wp_ok = version_compare($wp_version, $this->minium_WP, '>=');
94
+ if (($wp_ok == FALSE)) {
95
+ add_action(
96
+ 'admin_notices', create_function(
97
+ '', 'global $rt_wp_nginx_helper; printf (\'<div id="message" class="error"><p><strong>\' . __(\'Sorry, Nginx Helper requires WordPress %s or higher\', "nginx-helper" ) . \'</strong></p></div>\', $rt_wp_nginx_helper->minium_WP );'
98
+ )
99
+ );
100
+ return false;
101
+ }
102
+
103
+ return true;
104
+ }
105
+
106
+ function load_options() {
107
+ $this->options = get_site_option('rt_wp_nginx_helper_options');
108
+ }
109
+
110
+ function set_future_post_option_on_future_status($new_status, $old_status, $post) {
111
+
112
+ global $blog_id, $rt_wp_nginx_purger;
113
+ if (!$this->options['enable_purge']) {
114
+ return;
115
+ }
116
+ if ($old_status != $new_status && $old_status != 'inherit' && $new_status != 'inherit' && $old_status != 'auto-draft' && $new_status != 'auto-draft' && $new_status != 'publish' && !wp_is_post_revision($post->ID)) {
117
+ $rt_wp_nginx_purger->log("Purge post on transition post STATUS from " . $old_status . " to " . $new_status);
118
+ $rt_wp_nginx_purger->purgePost($post->ID);
119
+ }
120
+
121
+ if ($new_status == 'future') {
122
+ if ($post && $post->post_status == 'future' && ( ( $post->post_type == 'post' || $post->post_type == 'page' ) || ( in_array($post->post_type, $this->options['custom_post_types_recognized']) ) )) {
123
+ $rt_wp_nginx_purger->log("Set/update future_posts option (post id = " . $post->ID . " and blog id = " . $blog_id . ")");
124
+ $this->options['future_posts'][$blog_id][$post->ID] = strtotime($post->post_date_gmt) + 60;
125
+ update_site_option("rt_wp_nginx_helper_global_options", $this->options);
126
+ }
127
+ }
128
+ }
129
+
130
+ function unset_future_post_option_on_delete($post_id) {
131
+
132
+ global $blog_id, $rt_wp_nginx_purger;
133
+ if (!$this->options['enable_purge']) {
134
+ return;
135
+ }
136
+ if ($post_id && !wp_is_post_revision($post_id)) {
137
+
138
+ if (isset($this->options['future_posts'][$blog_id][$post_id]) && count($this->options['future_posts'][$blog_id][$post_id])) {
139
+ $rt_wp_nginx_purger->log("Unset future_posts option (post id = " . $post_id . " and blog id = " . $blog_id . ")");
140
+ unset($this->options['future_posts'][$blog_id][$post_id]);
141
+ update_site_option("rt_wp_nginx_helper_global_options", $this->options);
142
+
143
+ if (!count($this->options['future_posts'][$blog_id])) {
144
+ unset($this->options['future_posts'][$blog_id]);
145
+ update_site_option("rt_wp_nginx_helper_global_options", $this->options);
146
+ }
147
+ }
148
+ }
149
+ }
150
+
151
+ function update_new_blog_options($blog_id) {
152
+ global $rt_wp_nginx_purger;
153
+ include_once (RT_WP_NGINX_HELPER_PATH . 'admin/install.php');
154
+ $rt_wp_nginx_purger->log("New site added (id $blog_id)");
155
+ $this->update_map();
156
+ $rt_wp_nginx_purger->log("New site added to nginx map (id $blog_id)");
157
+ $helper_options = rt_wp_nginx_helper_get_options();
158
+ update_blog_option($blog_id, "rt_wp_nginx_helper_options", $helper_options, true);
159
+ $rt_wp_nginx_purger->log("Default options updated for the new blog (id $blog_id)");
160
+ }
161
+
162
+ function get_map() {
163
+ if (!$this->options['enable_map']) {
164
+ return;
165
+ }
166
+
167
+ if (is_multisite()) {
168
+
169
+ global $wpdb;
170
+
171
+ $rt_all_blogs = $wpdb->get_results($wpdb->prepare("SELECT blog_id, domain, path FROM " . $wpdb->blogs . " WHERE site_id = %d AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0'", $wpdb->siteid));
172
+ $wpdb->dmtable = $wpdb->base_prefix . 'domain_mapping';
173
+ $rt_domain_map_sites = '';
174
+ if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->dmtable}'") == $wpdb->dmtable) {
175
+ $rt_domain_map_sites = $wpdb->get_results("SELECT blog_id, domain FROM {$wpdb->dmtable} ORDER BY id DESC");
176
+ }
177
+ $rt_nginx_map = "";
178
+ $rt_nginx_map_array = array();
179
+
180
+
181
+ if ($rt_all_blogs)
182
+ foreach ($rt_all_blogs as $blog) {
183
+ if (SUBDOMAIN_INSTALL == "yes") {
184
+ $rt_nginx_map_array[$blog->domain] = $blog->blog_id;
185
+ } else {
186
+ if ($blog->blog_id != 1) {
187
+ $rt_nginx_map_array[$blog->path] = $blog->blog_id;
188
+ }
189
+ }
190
+ }
191
+
192
+ if ($rt_domain_map_sites) {
193
+ foreach ($rt_domain_map_sites as $site) {
194
+ $rt_nginx_map_array[$site->domain] = $site->blog_id;
195
+ }
196
+ }
197
+
198
+ foreach ($rt_nginx_map_array as $domain => $domain_id) {
199
+ $rt_nginx_map .= "\t" . $domain . "\t" . $domain_id . ";\n";
200
+ }
201
+
202
+ return $rt_nginx_map;
203
+ }
204
+ }
205
+
206
+ function functional_asset_path() {
207
+ $dir = wp_upload_dir();
208
+ $path = $dir['basedir'] . '/nginx-helper/';
209
+ return apply_filters('nginx_asset_path', $path);
210
+ }
211
+
212
+ function functional_asset_url() {
213
+ $dir = wp_upload_dir();
214
+ $url = $dir['baseurl'] . '/nginx-helper/';
215
+ return apply_filters('nginx_asset_url', $url);
216
+ }
217
+
218
+ function update_map() {
219
+ if (is_multisite()) {
220
+ $rt_nginx_map = $this->get_map();
221
+
222
+ if ($fp = fopen($this->functional_asset_path() . 'map.conf', 'w+')) {
223
+ fwrite($fp, $rt_nginx_map);
224
+ fclose($fp);
225
+ return true;
226
+ }
227
+ }
228
+ }
229
+
230
+ function add_timestamps() {
231
+ if ($this->options['enable_purge'] != 1)
232
+ return;
233
+ if ($this->options['enable_stamp'] != 1)
234
+ return;
235
+ if (is_admin())
236
+ return;
237
+ foreach (headers_list() as $header) {
238
+ list($key, $value) = explode(':', $header, 2);
239
+ if ($key == 'Content-Type' && strpos(trim($value), 'text/html') !== 0) {
240
+ return;
241
+ }
242
+ if ($key == 'Content-Type')
243
+ break;
244
+ }
245
+
246
+ if (defined('DOING_AJAX') && DOING_AJAX)
247
+ return;
248
+ $timestamps = "\n<!--" .
249
+ "Cached using Nginx-Helper on " . current_time('mysql') . ". " .
250
+ "It took " . get_num_queries() . " queries executed in " . timer_stop() . " seconds." .
251
+ "-->\n" .
252
+ "<!--Visit http://wordpress.org/extend/plugins/nginx-helper/faq/ for more details-->";
253
+ echo $timestamps;
254
+ }
255
+
256
+ function show_notice() {
257
+ echo '<div class="updated"><p>' . __('Purge initiated', 'nginx-helper') . '</p></div>';
258
+ }
259
+
260
+ function purge_all() {
261
+ global $rt_wp_nginx_purger;
262
+ if (!isset($_REQUEST['nginx_helper_action']))
263
+ return;
264
+
265
+ if (!current_user_can('manage_options'))
266
+ wp_die('Sorry, you do not have the necessary privileges to edit these options.');
267
+
268
+ $action = $_REQUEST['nginx_helper_action'];
269
+
270
+ if ($action == 'done') {
271
+ add_action('admin_notices', array(&$this, 'show_notice'));
272
+ return;
273
+ }
274
+
275
+ check_admin_referer('nginx_helper-purge_all');
276
+
277
+ switch ($action) {
278
+ case 'purge':
279
+ $rt_wp_nginx_purger->true_purge_all();
280
+ break;
281
+ }
282
+ wp_redirect(add_query_arg(array('nginx_helper_action' => 'done')));
283
+ }
284
+
285
+ /**
286
+ * Load the translation file for current language.
287
+ */
288
+ function load_plugin_textdomain() {
289
+ load_plugin_textdomain( 'nginx-helper', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
290
+ }
291
+ }
292
  }
293
 
294
  namespace {
295
 
296
+ if (!defined('RT_WP_NGINX_HELPER_CACHE_PATH')) {
297
+ define('RT_WP_NGINX_HELPER_CACHE_PATH', '/var/run/nginx-cache');
298
+ }
299
+ global $current_blog;
300
+
301
+ if (is_admin()) {
302
+ require_once (rtCamp\WP\Nginx\RT_WP_NGINX_HELPER_PATH . '/admin/admin.php');
303
+ $rtwpAdminPanel = new \rtCamp\WP\Nginx\Admin();
304
+ }
305
+
306
+ require_once (rtCamp\WP\Nginx\RT_WP_NGINX_HELPER_PATH . 'purger.php');
307
+ require_once (rtCamp\WP\Nginx\RT_WP_NGINX_HELPER_PATH . 'compatibility.php');
308
+
309
+ global $rt_wp_nginx_helper, $rt_wp_nginx_purger, $rt_wp_nginx_compatibility;
310
+ $rt_wp_nginx_helper = new \rtCamp\WP\Nginx\Helper;
311
+ $rt_wp_nginx_purger = new \rtCamp\WP\Nginx\Purger;
312
+ $rt_wp_nginx_compatibility = namespace\rtCamp\WP\Nginx\Compatibility::instance();
313
+ if ($rt_wp_nginx_compatibility->haveNginx() && !function_exists('wp_redirect')) {
314
+
315
+ function wp_redirect($location, $status = 302) {
316
+ $location = apply_filters('wp_redirect', $location, $status);
317
+
318
+ if (empty($location)) {
319
+ return false;
320
+ }
321
+
322
+ $status = apply_filters('wp_redirect_status', $status, $location);
323
+ if ($status < 300 || $status > 399) {
324
+ $status = 302;
325
+ }
326
+
327
+ $location = wp_sanitize_redirect($location);
328
+ header('Location: ' . $location, true, $status);
329
+ }
330
+
331
+ }
332
+
333
+ // Add settings link on plugin page
334
+ function nginx_settings_link($links) {
335
+ if (is_network_admin()) {
336
+ $u = 'settings.php';
337
+ } else {
338
+ $u = 'options-general.php';
339
+ }
340
+ $settings_link = '<a href="' . $u . '?page=nginx">' . __('Settings', 'nginx-helper') . '</a>';
341
+ array_unshift($links, $settings_link);
342
+ return $links;
343
+ }
344
+
345
+ $plugin = plugin_basename(__FILE__);
346
+ if (is_multisite()) {
347
+ add_filter("network_admin_plugin_action_links_$plugin", 'nginx_settings_link');
348
+ } else {
349
+ add_filter("plugin_action_links_$plugin", 'nginx_settings_link');
350
+ }
351
+
352
+ function get_feeds($feed_url = 'http://rtcamp.com/blog/feed/') {
353
+ // Get RSS Feed(s)
354
+ require_once( ABSPATH . WPINC . '/feed.php' );
355
+ $maxitems = 0;
356
+ // Get a SimplePie feed object from the specified feed source.
357
+ $rss = fetch_feed($feed_url);
358
+ if (!is_wp_error($rss)) { // Checks that the object is created correctly
359
+ // Figure out how many total items there are, but limit it to 5.
360
+ $maxitems = $rss->get_item_quantity(5);
361
+
362
+ // Build an array of all the items, starting with element 0 (first element).
363
+ $rss_items = $rss->get_items(0, $maxitems);
364
+ } ?>
365
+ <ul role="list"><?php
366
+ if ($maxitems == 0) {
367
+ echo '<li role="listitem">' . __('No items', 'nginx-helper') . '.</li>';
368
+ } else {
369
+ // Loop through each feed item and display each item as a hyperlink.
370
+ foreach ($rss_items as $item) { ?>
371
+ <li role="listitem">
372
+ <a href='<?php echo $item->get_permalink(); ?>' title='<?php echo __('Posted ', 'nginx-helper') . $item->get_date('j F Y | g:i a'); ?>'><?php echo $item->get_title(); ?></a>
373
+ </li><?php
374
+ }
375
+ } ?>
376
+ </ul><?php
377
+ }
378
+
379
+ function fetch_feeds() {
380
+ if (isset($_GET['get_feeds']) && $_GET['get_feeds'] == '1') {
381
+ get_feeds();
382
+ die();
383
+ }
384
+ }
385
+
386
+ add_action('init', 'fetch_feeds');
387
+ }
 
 
 
 
 
purger.php CHANGED
@@ -363,7 +363,7 @@ namespace rtCamp\WP\Nginx {
363
 
364
  $homepage_url = trailingslashit( home_url() );
365
 
366
- $this->log( sprintf( __( "Purging homepage '%s'", "rt_wp_nginx_helper" ), $homepage_url ) );
367
  $this->purgeUrl( $homepage_url );
368
 
369
  return true;
@@ -373,7 +373,7 @@ namespace rtCamp\WP\Nginx {
373
 
374
  global $rt_wp_nginx_helper;
375
 
376
- $this->log( __( "Purging personal urls", "rt_wp_nginx_helper" ) );
377
 
378
  if ( isset( $rt_wp_nginx_helper->options[ 'purgeable_url' ][ 'urls' ] ) ) {
379
 
@@ -381,7 +381,7 @@ namespace rtCamp\WP\Nginx {
381
  $this->purgeUrl( $u, false );
382
  }
383
  } else {
384
- $this->log( "- " . __( "No personal urls available", "rt_wp_nginx_helper" ) );
385
  }
386
 
387
  return true;
@@ -389,11 +389,11 @@ namespace rtCamp\WP\Nginx {
389
 
390
  private function _purge_post_categories( $_post_id ) {
391
 
392
- $this->log( __( "Purging category archives", "rt_wp_nginx_helper" ) );
393
 
394
  if ( $categories = wp_get_post_categories( $_post_id ) ) {
395
  foreach ( $categories as $category_id ) {
396
- $this->log( sprintf( __( "Purging category '%d'", "rt_wp_nginx_helper" ), $category_id ) );
397
  $this->purgeUrl( get_category_link( $category_id ) );
398
  }
399
  }
@@ -403,11 +403,11 @@ namespace rtCamp\WP\Nginx {
403
 
404
  private function _purge_post_tags( $_post_id ) {
405
 
406
- $this->log( __( "Purging tags archives", "rt_wp_nginx_helper" ) );
407
 
408
  if ( $tags = get_the_tags( $_post_id ) ) {
409
  foreach ( $tags as $tag ) {
410
- $this->log( sprintf( __( "Purging tag '%s' (id %d)", "rt_wp_nginx_helper" ), $tag->name, $tag->term_id ) );
411
  $this->purgeUrl( get_tag_link( $tag->term_id ) );
412
  }
413
  }
@@ -417,11 +417,11 @@ namespace rtCamp\WP\Nginx {
417
 
418
  private function _purge_post_custom_taxa( $_post_id ) {
419
 
420
- $this->log( __( "Purging post custom taxonomies related", "rt_wp_nginx_helper" ) );
421
 
422
  if ( $custom_taxonomies = get_taxonomies( array( 'public' => true, '_builtin' => false ) ) ) {
423
  foreach ( $custom_taxonomies as $taxon ) {
424
- $this->log( sprintf( "+ " . __( "Purging custom taxonomy '%s'", "rt_wp_nginx_helper" ), $taxon ) );
425
 
426
  if ( ! in_array( $taxon, array( 'category', 'post_tag', 'link_category' ) ) ) {
427
 
@@ -431,11 +431,11 @@ namespace rtCamp\WP\Nginx {
431
  }
432
  }
433
  } else {
434
- $this->log( sprintf( "- " . __( "Your built-in taxonomy '%s' has param '_builtin' set to false.", "rt_wp_nginx_helper" ), $taxon ), "WARNING" );
435
  }
436
  }
437
  } else {
438
- $this->log( "- " . __( "No custom taxonomies", "rt_wp_nginx_helper" ) );
439
  }
440
 
441
  return true;
@@ -443,16 +443,16 @@ namespace rtCamp\WP\Nginx {
443
 
444
  private function _purge_all_categories() {
445
 
446
- $this->log( __( "Purging all categories", "rt_wp_nginx_helper" ) );
447
 
448
  if ( $_categories = get_categories() ) {
449
 
450
  foreach ( $_categories as $c ) {
451
- $this->log( sprintf( __( "Purging category '%s' (id %d)", "rt_wp_nginx_helper" ), $c->name, $c->term_id ) );
452
  $this->purgeUrl( get_category_link( $c->term_id ) );
453
  }
454
  } else {
455
- $this->log( __( "No categories archives", "rt_wp_nginx_helper" ) );
456
  }
457
 
458
  return true;
@@ -460,16 +460,16 @@ namespace rtCamp\WP\Nginx {
460
 
461
  private function _purge_all_posttags() {
462
 
463
- $this->log( __( "Purging all tags", "rt_wp_nginx_helper" ) );
464
 
465
  if ( $_posttags = get_tags() ) {
466
 
467
  foreach ( $_posttags as $t ) {
468
- $this->log( sprintf( __( "Purging tag '%s' (id %d)", "rt_wp_nginx_helper" ), $t->name, $t->term_id ) );
469
  $this->purgeUrl( get_tag_link( $t->term_id ) );
470
  }
471
  } else {
472
- $this->log( __( "No tags archives", "rt_wp_nginx_helper" ) );
473
  }
474
 
475
  return true;
@@ -477,12 +477,12 @@ namespace rtCamp\WP\Nginx {
477
 
478
  private function _purge_all_customtaxa() {
479
 
480
- $this->log( __( "Purging all custom taxonomies", "rt_wp_nginx_helper" ) );
481
 
482
  if ( $custom_taxonomies = get_taxonomies( array( 'public' => true, '_builtin' => false ) ) ) {
483
 
484
  foreach ( $custom_taxonomies as $taxon ) {
485
- $this->log( sprintf( "+ " . __( "Purging custom taxonomy '%s'", "rt_wp_nginx_helper" ), $taxon ) );
486
 
487
  if ( ! in_array( $taxon, array( 'category', 'post_tag', 'link_category' ) ) ) {
488
 
@@ -492,11 +492,11 @@ namespace rtCamp\WP\Nginx {
492
  }
493
  }
494
  } else {
495
- $this->log( sprintf( "- " . __( "Your built-in taxonomy '%s' has param '_builtin' set to false.", "rt_wp_nginx_helper" ), $taxon ), "WARNING" );
496
  }
497
  }
498
  } else {
499
- $this->log( "- " . __( "No custom taxonomies", "rt_wp_nginx_helper" ) );
500
  }
501
 
502
  return true;
@@ -513,7 +513,7 @@ namespace rtCamp\WP\Nginx {
513
 
514
  private function _purge_all_posts() {
515
 
516
- $this->log( __( "Purging all posts, pages and custom post types.", "rt_wp_nginx_helper" ) );
517
 
518
  $args = array(
519
  'numberposts' => 0,
@@ -523,11 +523,11 @@ namespace rtCamp\WP\Nginx {
523
  if ( $_posts = get_posts( $args ) ) {
524
 
525
  foreach ( $_posts as $p ) {
526
- $this->log( sprintf( "+ " . __( "Purging post id '%d' (post type '%s')", "rt_wp_nginx_helper" ), $p->ID, $p->post_type ) );
527
  $this->purgeUrl( get_permalink( $p->ID ) );
528
  }
529
  } else {
530
- $this->log( "- " . __( "No posts", "rt_wp_nginx_helper" ) );
531
  }
532
 
533
  return true;
@@ -535,7 +535,7 @@ namespace rtCamp\WP\Nginx {
535
 
536
  private function _purge_all_date_archives() {
537
 
538
- $this->log( __( "Purging all date-based archives.", "rt_wp_nginx_helper" ) );
539
 
540
  $this->_purge_all_daily_archives();
541
 
@@ -550,7 +550,7 @@ namespace rtCamp\WP\Nginx {
550
 
551
  global $wpdb;
552
 
553
- $this->log( __( "Purging all daily archives.", "rt_wp_nginx_helper" ) );
554
 
555
  $_query_daily_archives = $wpdb->prepare(
556
  "SELECT YEAR(post_date) AS 'year', MONTH(post_date) AS 'month', DAYOFMONTH(post_date) AS 'dayofmonth', count(ID) as posts
@@ -563,11 +563,11 @@ namespace rtCamp\WP\Nginx {
563
  if ( $_daily_archives = $wpdb->get_results( $_query_daily_archives ) ) {
564
 
565
  foreach ( $_daily_archives as $_da ) {
566
- $this->log( sprintf( "+ " . __( "Purging daily archive '%s/%s/%s'", "rt_wp_nginx_helper" ), $_da->year, $_da->month, $_da->dayofmonth ) );
567
  $this->purgeUrl( get_day_link( $_da->year, $_da->month, $_da->dayofmonth ) );
568
  }
569
  } else {
570
- $this->log( "- " . __( "No daily archives", "rt_wp_nginx_helper" ) );
571
  }
572
  }
573
 
@@ -575,7 +575,7 @@ namespace rtCamp\WP\Nginx {
575
 
576
  global $wpdb;
577
 
578
- $this->log( __( "Purging all monthly archives.", "rt_wp_nginx_helper" ) );
579
 
580
  $_query_monthly_archives = $wpdb->prepare(
581
  "SELECT YEAR(post_date) AS 'year', MONTH(post_date) AS 'month', count(ID) as posts
@@ -588,11 +588,11 @@ namespace rtCamp\WP\Nginx {
588
  if ( $_monthly_archives = $wpdb->get_results( $_query_monthly_archives ) ) {
589
 
590
  foreach ( $_monthly_archives as $_ma ) {
591
- $this->log( sprintf( "+ " . __( "Purging monthly archive '%s/%s'", "rt_wp_nginx_helper" ), $_ma->year, $_ma->month ) );
592
  $this->purgeUrl( get_month_link( $_ma->year, $_ma->month ) );
593
  }
594
  } else {
595
- $this->log( "- " . __( "No monthly archives", "rt_wp_nginx_helper" ) );
596
  }
597
  }
598
 
@@ -600,7 +600,7 @@ namespace rtCamp\WP\Nginx {
600
 
601
  global $wpdb;
602
 
603
- $this->log( __( "Purging all yearly archives.", "rt_wp_nginx_helper" ) );
604
 
605
  $_query_yearly_archives = $wpdb->prepare(
606
  "SELECT YEAR(post_date) AS 'year', count(ID) as posts
@@ -613,17 +613,17 @@ namespace rtCamp\WP\Nginx {
613
  if ( $_yearly_archives = $wpdb->get_results( $_query_yearly_archives ) ) {
614
 
615
  foreach ( $_yearly_archives as $_ya ) {
616
- $this->log( sprintf( "+ " . __( "Purging yearly archive '%s'", "rt_wp_nginx_helper" ), $_ya->year ) );
617
  $this->purgeUrl( get_year_link( $_ya->year ) );
618
  }
619
  } else {
620
- $this->log( "- " . __( "No yearly archives", "rt_wp_nginx_helper" ) );
621
  }
622
  }
623
 
624
  function purge_them_all() {
625
 
626
- $this->log( __( "Let's purge everything!", "rt_wp_nginx_helper" ) );
627
 
628
  $this->_purge_homepage();
629
 
@@ -635,19 +635,19 @@ namespace rtCamp\WP\Nginx {
635
 
636
  $this->_purge_all_date_archives();
637
 
638
- $this->log( __( "Everthing purged!", "rt_wp_nginx_helper" ) );
639
 
640
  return true;
641
  }
642
 
643
  function purge_on_term_taxonomy_edited( $term_id, $tt_id, $taxon ) {
644
 
645
- $this->log( __( "Term taxonomy edited or deleted", "rt_wp_nginx_helper" ) );
646
 
647
  if ( current_filter() == 'edit_term' && $term = get_term( $term_id, $taxon ) ) {
648
- $this->log( sprintf( __( "Term taxonomy '%s' edited, (tt_id '%d', term_id '%d', taxonomy '%s')", "rt_wp_nginx_helper" ), $term->name, $tt_id, $term_id, $taxon ) );
649
  } else if ( current_filter() == 'delete_term' ) {
650
- $this->log( sprintf( __( "A term taxonomy has been deleted from taxonomy '%s', (tt_id '%d', term_id '%d')", "rt_wp_nginx_helper" ), $taxon, $term_id, $tt_id ) );
651
  }
652
 
653
  $this->_purge_homepage();
@@ -660,7 +660,7 @@ namespace rtCamp\WP\Nginx {
660
  switch ( $action ) {
661
  case 'save-sidebar-widgets' :
662
 
663
- $this->log( __( "Widget saved, moved or removed in a sidebar", "rt_wp_nginx_helper" ) );
664
 
665
  $this->_purge_homepage();
666
 
@@ -704,8 +704,5 @@ namespace rtCamp\WP\Nginx {
704
 
705
  return;
706
  }
707
-
708
  }
709
-
710
- }
711
- ?>
363
 
364
  $homepage_url = trailingslashit( home_url() );
365
 
366
+ $this->log( sprintf( __( "Purging homepage '%s'", "nginx-helper" ), $homepage_url ) );
367
  $this->purgeUrl( $homepage_url );
368
 
369
  return true;
373
 
374
  global $rt_wp_nginx_helper;
375
 
376
+ $this->log( __( "Purging personal urls", "nginx-helper" ) );
377
 
378
  if ( isset( $rt_wp_nginx_helper->options[ 'purgeable_url' ][ 'urls' ] ) ) {
379
 
381
  $this->purgeUrl( $u, false );
382
  }
383
  } else {
384
+ $this->log( "- " . __( "No personal urls available", "nginx-helper" ) );
385
  }
386
 
387
  return true;
389
 
390
  private function _purge_post_categories( $_post_id ) {
391
 
392
+ $this->log( __( "Purging category archives", "nginx-helper" ) );
393
 
394
  if ( $categories = wp_get_post_categories( $_post_id ) ) {
395
  foreach ( $categories as $category_id ) {
396
+ $this->log( sprintf( __( "Purging category '%d'", "nginx-helper" ), $category_id ) );
397
  $this->purgeUrl( get_category_link( $category_id ) );
398
  }
399
  }
403
 
404
  private function _purge_post_tags( $_post_id ) {
405
 
406
+ $this->log( __( "Purging tags archives", "nginx-helper" ) );
407
 
408
  if ( $tags = get_the_tags( $_post_id ) ) {
409
  foreach ( $tags as $tag ) {
410
+ $this->log( sprintf( __( "Purging tag '%s' (id %d)", "nginx-helper" ), $tag->name, $tag->term_id ) );
411
  $this->purgeUrl( get_tag_link( $tag->term_id ) );
412
  }
413
  }
417
 
418
  private function _purge_post_custom_taxa( $_post_id ) {
419
 
420
+ $this->log( __( "Purging post custom taxonomies related", "nginx-helper" ) );
421
 
422
  if ( $custom_taxonomies = get_taxonomies( array( 'public' => true, '_builtin' => false ) ) ) {
423
  foreach ( $custom_taxonomies as $taxon ) {
424
+ $this->log( sprintf( "+ " . __( "Purging custom taxonomy '%s'", "nginx-helper" ), $taxon ) );
425
 
426
  if ( ! in_array( $taxon, array( 'category', 'post_tag', 'link_category' ) ) ) {
427
 
431
  }
432
  }
433
  } else {
434
+ $this->log( sprintf( "- " . __( "Your built-in taxonomy '%s' has param '_builtin' set to false.", "nginx-helper" ), $taxon ), "WARNING" );
435
  }
436
  }
437
  } else {
438
+ $this->log( "- " . __( "No custom taxonomies", "nginx-helper" ) );
439
  }
440
 
441
  return true;
443
 
444
  private function _purge_all_categories() {
445
 
446
+ $this->log( __( "Purging all categories", "nginx-helper" ) );
447
 
448
  if ( $_categories = get_categories() ) {
449
 
450
  foreach ( $_categories as $c ) {
451
+ $this->log( sprintf( __( "Purging category '%s' (id %d)", "nginx-helper" ), $c->name, $c->term_id ) );
452
  $this->purgeUrl( get_category_link( $c->term_id ) );
453
  }
454
  } else {
455
+ $this->log( __( "No categories archives", "nginx-helper" ) );
456
  }
457
 
458
  return true;
460
 
461
  private function _purge_all_posttags() {
462
 
463
+ $this->log( __( "Purging all tags", "nginx-helper" ) );
464
 
465
  if ( $_posttags = get_tags() ) {
466
 
467
  foreach ( $_posttags as $t ) {
468
+ $this->log( sprintf( __( "Purging tag '%s' (id %d)", "nginx-helper" ), $t->name, $t->term_id ) );
469
  $this->purgeUrl( get_tag_link( $t->term_id ) );
470
  }
471
  } else {
472
+ $this->log( __( "No tags archives", "nginx-helper" ) );
473
  }
474
 
475
  return true;
477
 
478
  private function _purge_all_customtaxa() {
479
 
480
+ $this->log( __( "Purging all custom taxonomies", "nginx-helper" ) );
481
 
482
  if ( $custom_taxonomies = get_taxonomies( array( 'public' => true, '_builtin' => false ) ) ) {
483
 
484
  foreach ( $custom_taxonomies as $taxon ) {
485
+ $this->log( sprintf( "+ " . __( "Purging custom taxonomy '%s'", "nginx-helper" ), $taxon ) );
486
 
487
  if ( ! in_array( $taxon, array( 'category', 'post_tag', 'link_category' ) ) ) {
488
 
492
  }
493
  }
494
  } else {
495
+ $this->log( sprintf( "- " . __( "Your built-in taxonomy '%s' has param '_builtin' set to false.", "nginx-helper" ), $taxon ), "WARNING" );
496
  }
497
  }
498
  } else {
499
+ $this->log( "- " . __( "No custom taxonomies", "nginx-helper" ) );
500
  }
501
 
502
  return true;
513
 
514
  private function _purge_all_posts() {
515
 
516
+ $this->log( __( "Purging all posts, pages and custom post types.", "nginx-helper" ) );
517
 
518
  $args = array(
519
  'numberposts' => 0,
523
  if ( $_posts = get_posts( $args ) ) {
524
 
525
  foreach ( $_posts as $p ) {
526
+ $this->log( sprintf( "+ " . __( "Purging post id '%d' (post type '%s')", "nginx-helper" ), $p->ID, $p->post_type ) );
527
  $this->purgeUrl( get_permalink( $p->ID ) );
528
  }
529
  } else {
530
+ $this->log( "- " . __( "No posts", "nginx-helper" ) );
531
  }
532
 
533
  return true;
535
 
536
  private function _purge_all_date_archives() {
537
 
538
+ $this->log( __( "Purging all date-based archives.", "nginx-helper" ) );
539
 
540
  $this->_purge_all_daily_archives();
541
 
550
 
551
  global $wpdb;
552
 
553
+ $this->log( __( "Purging all daily archives.", "nginx-helper" ) );
554
 
555
  $_query_daily_archives = $wpdb->prepare(
556
  "SELECT YEAR(post_date) AS 'year', MONTH(post_date) AS 'month', DAYOFMONTH(post_date) AS 'dayofmonth', count(ID) as posts
563
  if ( $_daily_archives = $wpdb->get_results( $_query_daily_archives ) ) {
564
 
565
  foreach ( $_daily_archives as $_da ) {
566
+ $this->log( sprintf( "+ " . __( "Purging daily archive '%s/%s/%s'", "nginx-helper" ), $_da->year, $_da->month, $_da->dayofmonth ) );
567
  $this->purgeUrl( get_day_link( $_da->year, $_da->month, $_da->dayofmonth ) );
568
  }
569
  } else {
570
+ $this->log( "- " . __( "No daily archives", "nginx-helper" ) );
571
  }
572
  }
573
 
575
 
576
  global $wpdb;
577
 
578
+ $this->log( __( "Purging all monthly archives.", "nginx-helper" ) );
579
 
580
  $_query_monthly_archives = $wpdb->prepare(
581
  "SELECT YEAR(post_date) AS 'year', MONTH(post_date) AS 'month', count(ID) as posts
588
  if ( $_monthly_archives = $wpdb->get_results( $_query_monthly_archives ) ) {
589
 
590
  foreach ( $_monthly_archives as $_ma ) {
591
+ $this->log( sprintf( "+ " . __( "Purging monthly archive '%s/%s'", "nginx-helper" ), $_ma->year, $_ma->month ) );
592
  $this->purgeUrl( get_month_link( $_ma->year, $_ma->month ) );
593
  }
594
  } else {
595
+ $this->log( "- " . __( "No monthly archives", "nginx-helper" ) );
596
  }
597
  }
598
 
600
 
601
  global $wpdb;
602
 
603
+ $this->log( __( "Purging all yearly archives.", "nginx-helper" ) );
604
 
605
  $_query_yearly_archives = $wpdb->prepare(
606
  "SELECT YEAR(post_date) AS 'year', count(ID) as posts
613
  if ( $_yearly_archives = $wpdb->get_results( $_query_yearly_archives ) ) {
614
 
615
  foreach ( $_yearly_archives as $_ya ) {
616
+ $this->log( sprintf( "+ " . __( "Purging yearly archive '%s'", "nginx-helper" ), $_ya->year ) );
617
  $this->purgeUrl( get_year_link( $_ya->year ) );
618
  }
619
  } else {
620
+ $this->log( "- " . __( "No yearly archives", "nginx-helper" ) );
621
  }
622
  }
623
 
624
  function purge_them_all() {
625
 
626
+ $this->log( __( "Let's purge everything!", "nginx-helper" ) );
627
 
628
  $this->_purge_homepage();
629
 
635
 
636
  $this->_purge_all_date_archives();
637
 
638
+ $this->log( __( "Everthing purged!", "nginx-helper" ) );
639
 
640
  return true;
641
  }
642
 
643
  function purge_on_term_taxonomy_edited( $term_id, $tt_id, $taxon ) {
644
 
645
+ $this->log( __( "Term taxonomy edited or deleted", "nginx-helper" ) );
646
 
647
  if ( current_filter() == 'edit_term' && $term = get_term( $term_id, $taxon ) ) {
648
+ $this->log( sprintf( __( "Term taxonomy '%s' edited, (tt_id '%d', term_id '%d', taxonomy '%s')", "nginx-helper" ), $term->name, $tt_id, $term_id, $taxon ) );
649
  } else if ( current_filter() == 'delete_term' ) {
650
+ $this->log( sprintf( __( "A term taxonomy has been deleted from taxonomy '%s', (tt_id '%d', term_id '%d')", "nginx-helper" ), $taxon, $term_id, $tt_id ) );
651
  }
652
 
653
  $this->_purge_homepage();
660
  switch ( $action ) {
661
  case 'save-sidebar-widgets' :
662
 
663
+ $this->log( __( "Widget saved, moved or removed in a sidebar", "nginx-helper" ) );
664
 
665
  $this->_purge_homepage();
666
 
704
 
705
  return;
706
  }
 
707
  }
708
+ }
 
 
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Nginx ===
2
- Contributors: rtcamp, rahul286, saurabhshukla, faishal, Darren Slatten, jk3us, daankortenbach, telofy, pjv
3
  Tags: nginx, cache, purge, nginx map, nginx cache, maps, fastcgi, proxy, rewrite, permalinks
4
  Requires at least: 3.0
5
- Tested up to: 3.6
6
- Stable tag: 1.7.5
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/
@@ -116,6 +116,10 @@ Its just that we are hyperactive on our own forum!
116
 
117
  == Changelog ==
118
 
 
 
 
 
119
  = 1.7.5 =
120
  * Fixed option name mismatch issue to purge homepage on delete.
121
 
@@ -249,5 +253,5 @@ Its just that we are hyperactive on our own forum!
249
 
250
  == Upgrade Notice ==
251
 
252
- = 1.7.5 =
253
- Fixed option name mismatch issue to purge homepage on delete.
1
  === Nginx ===
2
+ Contributors: rtcamp, rahul286, saurabhshukla, faishal, Darren Slatten, jk3us, daankortenbach, telofy, pjv, llonchj, manishsongirkar36
3
  Tags: nginx, cache, purge, nginx map, nginx cache, maps, fastcgi, proxy, rewrite, permalinks
4
  Requires at least: 3.0
5
+ Tested up to: 3.8
6
+ Stable tag: 1.7.6
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/
116
 
117
  == Changelog ==
118
 
119
+ = 1.7.6 =
120
+ * Update Backend UI
121
+ * Added Language Support
122
+
123
  = 1.7.5 =
124
  * Fixed option name mismatch issue to purge homepage on delete.
125
 
253
 
254
  == Upgrade Notice ==
255
 
256
+ = 1.7.6 =
257
+ Update backed ui issue and add language support.