Nginx Helper - Version 1.6.9

Version Description

  • Added Faux to Purge all buttons, to avoid misleading users.
Download this release

Release Info

Developer saurabhshukla
Plugin Icon 128x128 Nginx Helper
Version 1.6.9
Comparing to
See all releases

Code changes from version 1.6.8 to 1.6.9

admin/admin.php CHANGED
@@ -95,7 +95,7 @@ namespace rtCamp\WP\Nginx {
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 all URLs</a>
99
  </form>
100
  <form id="post_form" method="post" action="#" name="smart_http_expire_form">
101
  <?php if ( ! ( ! is_network_admin() && is_multisite()) ) { ?>
@@ -289,10 +289,10 @@ namespace rtCamp\WP\Nginx {
289
  $nonced_url = wp_nonce_url( $purge_url, 'nginx_helper-purge_all' );
290
  $admin_bar->add_menu( array(
291
  'id' => 'nginx-helper-purge-all',
292
- 'title' => __( 'Purge Cache', 'rt-nginx' ),
293
  'href' => $nonced_url,
294
  'meta' => array(
295
- 'title' => __( 'Purge Cache', 'rt-nginx' ),
296
  ),
297
  )
298
  );
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">Faux Purge all URLs</a>
99
  </form>
100
  <form id="post_form" method="post" action="#" name="smart_http_expire_form">
101
  <?php if ( ! ( ! is_network_admin() && is_multisite()) ) { ?>
289
  $nonced_url = wp_nonce_url( $purge_url, 'nginx_helper-purge_all' );
290
  $admin_bar->add_menu( array(
291
  'id' => 'nginx-helper-purge-all',
292
+ 'title' => __( 'Faux Purge Cache', 'rt-nginx' ),
293
  'href' => $nonced_url,
294
  'meta' => array(
295
+ 'title' => __( 'Faux Purge Cache', 'rt-nginx' ),
296
  ),
297
  )
298
  );
nginx-helper.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Nginx Helper
4
  Plugin URI: http://rtcamp.com/
5
  Description: An nginx helper that serves various functions.
6
- Version: 1.6.8
7
  Author: rtCamp
8
  Author URI: http://rtcamp.com
9
  Requires at least: 3.0
3
  Plugin Name: Nginx Helper
4
  Plugin URI: http://rtcamp.com/
5
  Description: An nginx helper that serves various functions.
6
+ Version: 1.6.9
7
  Author: rtCamp
8
  Author URI: http://rtcamp.com
9
  Requires at least: 3.0
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: rtcamp, rahul286, saurabhshukla, Darren Slatten, jk3us, daankorten
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.5
6
- Stable tag: 1.6.8
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/
@@ -86,6 +86,10 @@ So, in the above eg, the purge url will be http://yoursite.com/purge/about/
86
  Just open this in a browser and the page will be purged instantly.
87
  Needless to say, this won't work, if you have a page or taxonomy called 'purge'.
88
 
 
 
 
 
89
  = FAQ - Nginx Map =
90
 
91
  **Q. I am using X plugin. Will it work on Nginx?**
@@ -105,6 +109,9 @@ Its just that we are hyperactive on our own forum!
105
 
106
  == Changelog ==
107
 
 
 
 
108
  = 1.6.8 =
109
  * [daankortenbach](http://profiles.wordpress.org/daankortenbach) added Purge Cache link to wp-admin bar
110
 
@@ -201,5 +208,5 @@ Its just that we are hyperactive on our own forum!
201
 
202
  == Upgrade Notice ==
203
 
204
- = 1.6.7 =
205
- Improved cache verification comments.
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.5
6
+ Stable tag: 1.6.9
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/
86
  Just open this in a browser and the page will be purged instantly.
87
  Needless to say, this won't work, if you have a page or taxonomy called 'purge'.
88
 
89
+ **Q. There's a 'faux purge all' button? Does it purge the whole site?**
90
+
91
+ This is a faux purge all. This just tries to cleanse all the cache in its own limited manner. There isn't and can't be a true purge all. See this discussion: http://wordpress.org/support/topic/feature-suggestion-for-additional-purge-options?replies=13.
92
+
93
  = FAQ - Nginx Map =
94
 
95
  **Q. I am using X plugin. Will it work on Nginx?**
109
 
110
  == Changelog ==
111
 
112
+ = 1.6.9 =
113
+ * Added Faux to Purge all buttons, to avoid misleading users.
114
+
115
  = 1.6.8 =
116
  * [daankortenbach](http://profiles.wordpress.org/daankortenbach) added Purge Cache link to wp-admin bar
117
 
208
 
209
  == Upgrade Notice ==
210
 
211
+ = 1.6.9 =
212
+ Added faux to all purge all buttons.
trunk/admin/admin.php DELETED
@@ -1,339 +0,0 @@
1
- <?php
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;
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 all URLs</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_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_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_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
-
224
- <?php
225
- if ( $rt_wp_nginx_helper->options[ 'enable_log' ] != false ) {
226
- ?>
227
- <h3>Logging</h3>
228
-
229
- <?php if ( ! is_writable( RT_WP_NGINX_HELPER_PATH . 'nginx.log' ) ) { ?>
230
- <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_PATH . 'nginx.log' ); ?></p></span>
231
- <?php } ?>
232
-
233
- <table class="form-table rtnginx-table">
234
- <tbody>
235
- <tr>
236
- <th><label for="rt_wp_nginx_helper_logs_path"><?php _e( 'Logs path', 'rt_wp_nginx_helper' ); ?></label></th>
237
- <td><?php echo RT_WP_NGINX_HELPER_PATH ?>nginx.log</td>
238
- </tr>
239
- <tr>
240
- <th><label for="rt_wp_nginx_helper_logs_link"><?php _e( 'View Log', 'rt_wp_nginx_helper' ); ?></label></th>
241
- <td><a target="_blank" href="<?php echo RT_WP_NGINX_HELPER_URL ?>nginx.log">Log</a></td>
242
- </tr>
243
-
244
- <tr>
245
- <th><label for="rt_wp_nginx_helper_log_level"><?php _e( 'Log level', 'rt_wp_nginx_helper' ); ?></label></th>
246
- <td>
247
- <select name="log_level">
248
- <option value="NONE"<?php selected( $rt_wp_nginx_helper->options[ 'log_level' ], 'NONE' ); ?>><?php _e( 'None', 'rt_wp_nginx_helper' ); ?></option>
249
- <option value="INFO"<?php selected( $rt_wp_nginx_helper->options[ 'log_level' ], 'INFO' ); ?>><?php _e( 'Info', 'rt_wp_nginx_helper' ); ?></option>
250
- <option value="WARNING"<?php selected( $rt_wp_nginx_helper->options[ 'log_level' ], 'WARNING' ); ?>><?php _e( 'Warning', 'rt_wp_nginx_helper' ); ?></option>
251
- <option value="ERROR"<?php selected( $rt_wp_nginx_helper->options[ 'log_level' ], 'ERROR' ); ?>><?php _e( 'Error', 'rt_wp_nginx_helper' ); ?></option>
252
- </select>
253
- </td>
254
- </tr>
255
-
256
- <tr>
257
- <th><label for="log_filesize"><?php _e( 'Max log file size', 'rt_wp_nginx_helper' ); ?></label></th>
258
- <td>
259
- <input id="log_filesize" class="small-text" type="text" name="log_filesize" value="<?php echo $rt_wp_nginx_helper->options[ 'log_filesize' ] ?>" /> Mb
260
- <?php if ( $error_log_filesize ) { ?>
261
- <span class="error fade" style="display : block"><p><strong><?php echo $error_log_filesize; ?></strong></p></span>
262
- <?php } ?>
263
- </td>
264
- </tr>
265
- </tbody>
266
- </table>
267
-
268
- <br />
269
- <?php } ?>
270
- <?php } ?>
271
-
272
- <p class="submit">
273
- <input type="submit" name="smart_http_expire_save" class="button-primary" value="Save" />
274
- </p>
275
- </form>
276
-
277
- </div>
278
- <div id="rtads" class="metabox-holder align_left">
279
- <?php $this->default_admin_sidebar(); ?>
280
- </div>
281
- </div>
282
- <?php
283
- break;
284
- }
285
- }
286
-
287
- function add_toolbar_purge_item( $admin_bar ) {
288
- $purge_url = add_query_arg( array( 'nginx_helper_action' => 'purge', 'nginx_helper_urls' => 'all' ) );
289
- $nonced_url = wp_nonce_url( $purge_url, 'nginx_helper-purge_all' );
290
- $admin_bar->add_menu( array(
291
- 'id' => 'nginx-helper-purge-all',
292
- 'title' => __( 'Purge Cache', 'rt-nginx' ),
293
- 'href' => $nonced_url,
294
- 'meta' => array(
295
- 'title' => __( 'Purge Cache', 'rt-nginx' ),
296
- ),
297
- )
298
- );
299
- }
300
-
301
- function default_admin_sidebar() {
302
- ?>
303
- <div class="postbox" id="support">
304
- <div title="<?php _e( 'Click to toggle', 'bp-media' ); ?>" class="handlediv"><br /></div>
305
- <h3 class="hndle"><span><?php _e( 'Need Help?', 'bp-media' ); ?></span></h3>
306
- <div class="inside"><p><?php printf( __( ' Please use our <a href="%s">free support forum</a>.<br/><span class="bpm-aligncenter">OR</span><br/>
307
- <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>
308
- </div>
309
- <div class="postbox" id="social">
310
- <div title="<?php _e( 'Click to toggle', 'bp-media' ); ?>" class="handlediv"><br /></div>
311
- <h3 class="hndle"><span><?php _e( 'Getting Social is Good', 'bp-media' ); ?></span></h3>
312
- <div class="inside" style="text-align:center;">
313
- <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>
314
- <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>
315
- <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>
316
- </div>
317
- </div>
318
-
319
- <div class="postbox" id="latest_news">
320
- <div title="<?php _e( 'Click to toggle', 'bp-media' ); ?>" class="handlediv"><br /></div>
321
- <h3 class="hndle"><span><?php _e( 'Latest News', 'bp-media' ); ?></span></h3>
322
- <div class="inside"><img src ="<?php echo admin_url(); ?>/images/wpspin_light.gif" /> Loading...</div>
323
- </div><?php
324
- }
325
-
326
- function load_styles() {
327
- wp_enqueue_style( 'rt-nginx-admin-css', plugins_url( 'admin/assets/style.css', dirname( __FILE__ ) ) );
328
- }
329
-
330
- function load_scripts() {
331
- $admin_js = trailingslashit( site_url() ) . '?get_feeds=1';
332
- wp_enqueue_script( 'nginx-js', plugins_url( 'admin/assets/nginx.js', dirname( __FILE__ ) ) );
333
- wp_localize_script( 'nginx-js', 'news_url', $admin_js );
334
- }
335
-
336
- }
337
-
338
- }
339
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/admin/assets/logo.png DELETED
Binary file
trunk/admin/assets/nginx-icon-32x32.png DELETED
Binary file
trunk/admin/assets/nginx.js DELETED
@@ -1,8 +0,0 @@
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
- });
 
 
 
 
 
 
 
 
trunk/admin/assets/rtp-social-icons-32-32.png DELETED
Binary file
trunk/admin/assets/style.css DELETED
@@ -1,59 +0,0 @@
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
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/admin/install.php DELETED
@@ -1,113 +0,0 @@
1
- <?php
2
-
3
- namespace rtCamp\WP\Nginx {
4
- if ( preg_match( '#' . basename( __FILE__ ) . '#', $_SERVER[ 'PHP_SELF' ] ) ) {
5
- die( 'You are not allowed to call this page directly.' );
6
- }
7
-
8
- function rt_wp_nginx_helper_install() {
9
-
10
- global $wp_roles, $rt_wp_nginx_helper;
11
-
12
- if ( ! current_user_can( 'activate_plugins' ) )
13
- return;
14
-
15
- $role = get_role( 'administrator' );
16
-
17
-
18
- if ( empty( $role ) ) {
19
- update_site_option( "rt_wp_nginx_helper_init_check", __( 'Sorry, you need to be an administrator to use Nginx Helper', "rt_wp_nginx_helper" ) );
20
- return;
21
- }
22
-
23
- $role->add_cap( 'Nginx Helper | Config' );
24
- $role->add_cap( 'Nginx Helper | Purge cache' );
25
-
26
- $rt_wp_nginx_helper_get_options = get_site_option( 'rt_wp_nginx_helper_global_options' );
27
-
28
- if ( empty( $rt_wp_nginx_helper_get_options ) ) {
29
- $rt_wp_nginx_helper_get_options = rt_wp_nginx_helper_get_options();
30
- update_site_option( "rt_wp_nginx_helper_global_options", $rt_wp_nginx_helper_get_options );
31
- }
32
-
33
- if ( is_multisite() ) {
34
- $blogs = get_blogs_of_user( true );
35
- foreach ( $blogs as $b ) {
36
- $rt_wp_nginx_helper_options = get_blog_option( $b->userblog_id, 'rt_wp_nginx_helper_options' );
37
- if ( empty( $rt_wp_nginx_helper_options ) ) {
38
- $rt_wp_nginx_helper_options = rt_wp_nginx_helper_get_options();
39
- update_blog_option( $b->userblog_id, "rt_wp_nginx_helper_options", $rt_wp_nginx_helper_options );
40
- }
41
- }
42
- } else {
43
- $rt_wp_nginx_helper_options = get_option( 'rt_wp_nginx_helper_options' );
44
- if ( empty( $rt_wp_nginx_helper_options ) ) {
45
- $rt_wp_nginx_helper_options = rt_wp_nginx_helper_get_options();
46
- update_option( "rt_wp_nginx_helper_options", $rt_wp_nginx_helper_options );
47
- }
48
- }
49
- wp_schedule_event( time(), 'daily', 'rt_wp_nginx_helper_check_log_file_size_daily' );
50
- }
51
-
52
- function rt_wp_nginx_helper_uninstall() {
53
-
54
- global $rt_wp_nginx_helper, $rt_wp_nginx_purger;
55
-
56
- wp_clear_scheduled_hook( 'rt_wp_nginx_helper_check_log_file_size_daily' );
57
-
58
- delete_site_option( 'rt_wp_nginx_helper_options' );
59
-
60
-
61
- rt_wp_nginx_helper_remove_capability( 'Nginx Helper | Config' );
62
- rt_wp_nginx_helper_remove_capability( 'Nginx Helper | Purge cache' );
63
- }
64
-
65
- function rt_wp_nginx_helper_remove_capability( $capability ) {
66
- $check_order = array( "subscriber", "contributor", "author", "editor", "administrator" );
67
-
68
- foreach ( $check_order as $role ) {
69
- $role = get_role( $role );
70
- $role->remove_cap( $capability );
71
- }
72
- }
73
-
74
- function rt_wp_nginx_helper_get_options() {
75
-
76
- global $rt_wp_nginx_helper;
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
-
84
- $rt_wp_nginx_helper_get_options[ 'current_db_version' ] = $rt_wp_nginx_helper->db_version;
85
-
86
- $rt_wp_nginx_helper_get_options[ 'mobile_uncache' ] = 1;
87
- $rt_wp_nginx_helper_get_options[ 'mobile_regexp' ] = '#2.0 MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo Wii|Nitro|Nokia|Opera Mini|Palm|PlayStation Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows CE|WinWAP|YahooSeeker/M1A1-R2D2|NF-Browser|iPhone|iPod|Android|BlackBerry9530|G-TU915 Obigo|LGE VX|webOS|Nokia5800#';
88
-
89
- $rt_wp_nginx_helper_get_options[ 'enable_purge' ] = 1;
90
- $rt_wp_nginx_helper_get_options[ 'enable_map' ] = 0;
91
- $rt_wp_nginx_helper_get_options[ 'enable_log' ] = 0;
92
- $rt_wp_nginx_helper_get_options[ 'enable_stamp' ] = 1;
93
-
94
- $rt_wp_nginx_helper_get_options[ 'purge_homepage_on_new' ] = 1;
95
- $rt_wp_nginx_helper_get_options[ 'purge_homepage_on_edit' ] = 1;
96
- $rt_wp_nginx_helper_get_options[ 'purge_homepage_on_del' ] = 1;
97
-
98
- $rt_wp_nginx_helper_get_options[ 'purge_archive_on_new' ] = 1;
99
- $rt_wp_nginx_helper_get_options[ 'purge_archive_on_edit' ] = 1;
100
- $rt_wp_nginx_helper_get_options[ 'purge_archive_on_del' ] = 1;
101
-
102
- $rt_wp_nginx_helper_get_options[ 'purge_archive_on_new_comment' ] = 0;
103
- $rt_wp_nginx_helper_get_options[ 'purge_archive_on_deleted_comment' ] = 0;
104
-
105
- $rt_wp_nginx_helper_get_options[ 'purge_page_on_mod' ] = 1;
106
- $rt_wp_nginx_helper_get_options[ 'purge_page_on_new_comment' ] = 1;
107
- $rt_wp_nginx_helper_get_options[ 'purge_page_on_deleted_comment' ] = 1;
108
-
109
- return $rt_wp_nginx_helper_get_options;
110
- }
111
-
112
- }
113
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/compatibility.php DELETED
@@ -1,41 +0,0 @@
1
- <?php
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
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/nginx-helper.php DELETED
@@ -1,402 +0,0 @@
1
- <?php
2
- /*
3
- Plugin Name: Nginx Helper
4
- Plugin URI: http://rtcamp.com/
5
- Description: An nginx helper that serves various functions.
6
- Version: 1.6.8
7
- Author: rtCamp
8
- Author URI: http://rtcamp.com
9
- Requires at least: 3.0
10
- Tested up to: 3.5
11
- */
12
-
13
- namespace rtCamp\WP\Nginx {
14
- define( 'rtCamp\WP\Nginx\RT_WP_NGINX_HELPER_PATH', plugin_dir_path( __FILE__ ) );
15
- define( 'rtCamp\WP\Nginx\RT_WP_NGINX_HELPER_URL', plugin_dir_url( __FILE__ ) );
16
-
17
- class Helper {
18
-
19
- var $version = '1.4'; // Plugin version
20
- var $db_version = '0.1'; // DB version, change it to show the upgrade page
21
- var $minium_WP = '3.0';
22
- var $minimum_PHP = '5.3';
23
- var $options = null;
24
-
25
- function __construct() {
26
-
27
- if ( ! $this->required_wp_version() )
28
- if ( ! $this->required_php_version() )
29
- return;
30
-
31
- $this->load_options();
32
- $this->define_constant();
33
- $this->plugin_name = plugin_basename( __FILE__ );
34
-
35
- register_activation_hook( $this->plugin_name, array( &$this, 'activate' ) );
36
- register_deactivation_hook( $this->plugin_name, array( &$this, 'deactivate' ) );
37
-
38
- add_action( 'init', array( &$this, 'start_helper' ), 15 );
39
- }
40
-
41
- function start_helper() {
42
-
43
- global $rt_wp_nginx_purger;
44
- add_action( 'shutdown', array( &$this, 'add_timestamps' ), 99999 );
45
- add_action( 'add_init', array( &$this, 'update_map' ) );
46
-
47
- add_action( 'publish_post', array( &$rt_wp_nginx_purger, 'purgePost' ), 200, 1 );
48
- add_action( 'publish_page', array( &$rt_wp_nginx_purger, 'purgePost' ), 200, 1 );
49
- add_action( 'wp_insert_comment', array( &$rt_wp_nginx_purger, 'purgePostOnComment' ), 200, 2 );
50
- add_action( 'transition_comment_status', array( &$rt_wp_nginx_purger, 'purgePostOnCommentChange' ), 200, 3 );
51
-
52
- $args = array( '_builtin' => false );
53
- $_rt_custom_post_types = get_post_types( $args );
54
- if ( isset( $post_types ) && ! empty( $post_types ) ) {
55
- if ( $this->options[ 'rt_wp_custom_post_types' ] == true ) {
56
- foreach ( $_rt_custom_post_types as $post_type ) {
57
- add_action( 'publish_' . trim( $post_type ), array( &$rt_wp_nginx_purger, 'purgePost' ), 200, 1 );
58
- }
59
- }
60
- }
61
-
62
- add_action( 'transition_post_status', array( &$this, 'set_future_post_option_on_future_status' ), 20, 3 );
63
- add_action( 'delete_post', array( &$this, 'unset_future_post_option_on_delete' ), 20, 1 );
64
-
65
- add_action( 'nm_check_log_file_size_daily', array( &$rt_wp_nginx_purger, 'checkAndTruncateLogFile' ), 100, 1 );
66
-
67
- add_action( 'edit_attachment', array( &$rt_wp_nginx_purger, 'purgeImageOnEdit' ), 100, 1 );
68
-
69
- add_action( 'wpmu_new_blog', array( &$this, 'update_new_blog_options' ), 10, 1 );
70
-
71
- add_action( 'transition_post_status', array( &$rt_wp_nginx_purger, 'purge_on_post_moved_to_trash' ), 20, 3 );
72
-
73
- add_action( 'edit_term', array( &$rt_wp_nginx_purger, 'purge_on_term_taxonomy_edited' ), 20, 3 );
74
- add_action( 'delete_term', array( &$rt_wp_nginx_purger, 'purge_on_term_taxonomy_edited' ), 20, 3 );
75
-
76
- add_action( 'check_ajax_referer', array( &$rt_wp_nginx_purger, 'purge_on_check_ajax_referer' ), 20, 2 );
77
- add_action( 'admin_init', array( &$this, 'purge_all' ) );
78
- }
79
-
80
- function activate() {
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 define_constant() {
91
- define( 'RT_WP_NGINX_HELPER_VERSION', $this->version );
92
- define( 'RT_WP_NGINX_HELPER_DB_VERSION', $this->db_version );
93
- define( 'RT_WP_NGINX_HELPER_FOLDER', plugin_basename( dirname( __FILE__ ) ) );
94
- }
95
-
96
- function required_wp_version() {
97
-
98
- global $wp_version;
99
- $wp_ok = version_compare( $wp_version, $this->minium_WP, '>=' );
100
-
101
- if ( ($wp_ok == FALSE ) ) {
102
- add_action(
103
- 'admin_notices', create_function(
104
- '', '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 );'
105
- )
106
- );
107
- return false;
108
- }
109
-
110
- return true;
111
- }
112
-
113
- function required_php_version() {
114
-
115
- $php_ok = version_compare( PHP_VERSION, '5.3', '>=' );
116
- if ( ($php_ok == FALSE ) ) {
117
- add_action(
118
- 'admin_notices', create_function(
119
- '', 'global $rt_wp_nginx_helper; printf (\'<div id="message" class="error"><p><strong>\' . __(\'Sorry, Nginx Helper requires PHP %s or higher\', "rt_wp_nginx_helper" ) . \'</strong></p></div>\', $rt_wp_nginx_helper->minium_PHP );'
120
- )
121
- );
122
- return false;
123
- }
124
-
125
- return true;
126
- }
127
-
128
- function load_options() {
129
- $this->options = get_site_option( 'rt_wp_nginx_helper_options' );
130
- }
131
-
132
- function set_future_post_option_on_future_status( $new_status, $old_status, $post ) {
133
-
134
- global $blog_id, $rt_wp_nginx_purger;
135
- if ( ! $this->options[ 'enable_purge' ] ) {
136
- return;
137
- }
138
- if ( $old_status != $new_status
139
- && $old_status != 'inherit'
140
- && $new_status != 'inherit'
141
- && $old_status != 'auto-draft'
142
- && $new_status != 'auto-draft'
143
- && $new_status != 'publish'
144
- && ! wp_is_post_revision( $post->ID ) ) {
145
- $rt_wp_nginx_purger->log( "Purge post on transition post STATUS from " . $old_status . " to " . $new_status );
146
- $rt_wp_nginx_purger->purgePost( $post->ID );
147
- }
148
-
149
- if ( $new_status == 'future' ) {
150
- 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' ] ) ) ) ) {
151
- $rt_wp_nginx_purger->log( "Set/update future_posts option (post id = " . $post->ID . " and blog id = " . $blog_id . ")" );
152
- $this->options[ 'future_posts' ][ $blog_id ][ $post->ID ] = strtotime( $post->post_date_gmt ) + 60;
153
- update_site_option( "rt_wp_nginx_helper_global_options", $this->options );
154
- }
155
- }
156
- }
157
-
158
- function unset_future_post_option_on_delete( $post_id ) {
159
-
160
- global $blog_id, $rt_wp_nginx_purger;
161
- if ( ! $this->options[ 'enable_purge' ] ) {
162
- return;
163
- }
164
- if ( $post_id && ! wp_is_post_revision( $post_id ) ) {
165
-
166
- if ( isset( $this->options[ 'future_posts' ][ $blog_id ][ $post_id ] ) && count( $this->options[ 'future_posts' ][ $blog_id ][ $post_id ] ) ) {
167
- $rt_wp_nginx_purger->log( "Unset future_posts option (post id = " . $post_id . " and blog id = " . $blog_id . ")" );
168
- unset( $this->options[ 'future_posts' ][ $blog_id ][ $post_id ] );
169
- update_site_option( "rt_wp_nginx_helper_global_options", $this->options );
170
-
171
- if ( ! count( $this->options[ 'future_posts' ][ $blog_id ] ) ) {
172
- unset( $this->options[ 'future_posts' ][ $blog_id ] );
173
- update_site_option( "rt_wp_nginx_helper_global_options", $this->options );
174
- }
175
- }
176
- }
177
- }
178
-
179
- function update_new_blog_options( $blog_id ) {
180
-
181
- global $rt_wp_nginx_purger;
182
-
183
- include_once (RT_WP_NGINX_HELPER_PATH . 'admin/install.php');
184
-
185
- $rt_wp_nginx_purger->log( "New site added (id $blog_id)" );
186
-
187
- $this->update_map();
188
-
189
- $rt_wp_nginx_purger->log( "New site added to nginx map (id $blog_id)" );
190
-
191
- $helper_options = rt_wp_nginx_helper_get_options();
192
-
193
- update_blog_option( $blog_id, "rt_wp_nginx_helper_options", $helper_options, true );
194
-
195
- $rt_wp_nginx_purger->log( "Default options updated for the new blog (id $blog_id)" );
196
- }
197
-
198
- function get_map() {
199
- if ( ! $this->options[ 'enable_map' ] ) {
200
- return;
201
- }
202
-
203
- if ( is_multisite() ) {
204
-
205
- global $wpdb;
206
-
207
- $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 ) );
208
- $wpdb->dmtable = $wpdb->base_prefix . 'domain_mapping';
209
- if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->dmtable}'" ) == $wpdb->dmtable ) {
210
- $rt_domain_map_sites = $wpdb->get_results( "SELECT blog_id, domain FROM {$wpdb->dmtable} ORDER BY id DESC" );
211
- }
212
- $rt_nginx_map = "";
213
- $rt_nginx_map_array = array( );
214
-
215
-
216
- if ( $rt_all_blogs )
217
- foreach ( $rt_all_blogs as $blog ) {
218
- if ( SUBDOMAIN_INSTALL == "yes" ) {
219
- $rt_nginx_map_array[ $blog->domain ] = $blog->blog_id;
220
- } else {
221
- if ( $blog->blog_id != 1 ) {
222
- $rt_nginx_map_array[ $blog->path ] = $blog->blog_id;
223
- }
224
- }
225
- }
226
-
227
- if ( $rt_domain_map_sites ) {
228
- foreach ( $rt_domain_map_sites as $site ) {
229
- $rt_nginx_map_array[ $site->domain ] = $site->blog_id;
230
- }
231
- }
232
-
233
- foreach ( $rt_nginx_map_array as $domain => $domain_id ) {
234
- $rt_nginx_map .= "\t" . $domain . "\t" . $domain_id . ";\n";
235
- }
236
-
237
- return $rt_nginx_map;
238
- }
239
- }
240
-
241
- function update_map() {
242
- if ( is_multisite() ) {
243
- $rt_nginx_map = $this->get_map();
244
- if ( $fp = fopen( RT_WP_NGINX_HELPER_PATH . 'map.conf', 'w+' ) ) {
245
- fwrite( $fp, $rt_nginx_map );
246
- fclose( $fp );
247
- return true;
248
- }
249
- }
250
- }
251
-
252
- function add_timestamps() {
253
- if ( $this->options[ 'enable_purge' ] != 1 )
254
- return;
255
- if ( $this->options[ 'enable_stamp' ] != 1 )
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
- if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
265
- return;
266
- $timestamps = "\n<!--" .
267
- "Cached using Nginx-Helper on " . current_time( 'mysql' ) . ". " .
268
- "It took " . get_num_queries() . " queries executed in " . timer_stop() . " seconds." .
269
- "-->\n" .
270
- "<!--Visit http://wordpress.org/extend/plugins/nginx-helper/faq/ for more details-->";
271
- echo $timestamps;
272
- }
273
-
274
- function show_notice() {
275
- echo '<div class="updated"><p>Purge initiated</p></div>';
276
- }
277
-
278
- function purge_all() {
279
- global $rt_wp_nginx_purger;
280
- if ( ! isset( $_REQUEST[ 'nginx_helper_action' ] ) )
281
- return;
282
-
283
- if ( ! current_user_can( 'manage_options' ) )
284
- wp_die( 'Sorry, you do not have the necessary privileges to edit these options.' );
285
-
286
- $action = $_REQUEST[ 'nginx_helper_action' ];
287
-
288
- if ( $action == 'done' ) {
289
- add_action( 'admin_notices', array( &$this, 'show_notice' ) );
290
- return;
291
- }
292
-
293
- check_admin_referer( 'nginx_helper-purge_all' );
294
-
295
- switch ( $action ) {
296
- case 'purge':
297
- $rt_wp_nginx_purger->purge_them_all();
298
- break;
299
- }
300
-
301
- wp_redirect( add_query_arg( array( 'nginx_helper_action' => 'done' ) ) );
302
- }
303
-
304
- }
305
-
306
- }
307
-
308
- namespace {
309
- global $current_blog;
310
-
311
- if ( is_admin() ) {
312
- require_once (rtCamp\WP\Nginx\RT_WP_NGINX_HELPER_PATH . '/admin/admin.php');
313
- $rtwpAdminPanel = new \rtCamp\WP\Nginx\Admin();
314
- }
315
-
316
- require_once (rtCamp\WP\Nginx\RT_WP_NGINX_HELPER_PATH . 'purger.php');
317
-
318
- require_once (rtCamp\WP\Nginx\RT_WP_NGINX_HELPER_PATH . 'compatibility.php');
319
-
320
- global $rt_wp_nginx_helper, $rt_wp_nginx_purger, $rt_wp_nginx_compatibility;
321
- $rt_wp_nginx_helper = new \rtCamp\WP\Nginx\Helper;
322
- $rt_wp_nginx_purger = new \rtCamp\WP\Nginx\Purger;
323
- $rt_wp_nginx_compatibility = namespace\rtCamp\WP\Nginx\Compatibility::instance();
324
- if ( $rt_wp_nginx_compatibility->haveNginx() && ! function_exists( 'wp_redirect' ) ) {
325
-
326
- function wp_redirect( $location, $status = 302 ) {
327
- $location = apply_filters( 'wp_redirect', $location, $status );
328
-
329
- if ( empty( $location ) ) {
330
- return false;
331
- }
332
-
333
- $status = apply_filters( 'wp_redirect_status', $status, $location );
334
- if ( $status < 300 || $status > 399 ) {
335
- $status = 302;
336
- }
337
-
338
- $location = wp_sanitize_redirect( $location );
339
- header( 'Location: ' . $location, true, $status );
340
- }
341
-
342
- }
343
-
344
- // Add settings link on plugin page
345
- function nginx_settings_link( $links ) {
346
- if ( is_network_admin() ) {
347
- $u = 'settings.php';
348
- } else {
349
- $u = 'options-general.php';
350
- }
351
- $settings_link = '<a href="' . $u . '?page=nginx">Settings</a>';
352
- array_unshift( $links, $settings_link );
353
- return $links;
354
- }
355
-
356
- $plugin = plugin_basename( __FILE__ );
357
- if ( is_multisite() ) {
358
- add_filter( "network_admin_plugin_action_links_$plugin", 'nginx_settings_link' );
359
- } else {
360
- add_filter( "plugin_action_links_$plugin", 'nginx_settings_link' );
361
- }
362
-
363
- function get_feeds( $feed_url = 'http://rtcamp.com/blog/feed/' ) {
364
- // Get RSS Feed(s)
365
- require_once( ABSPATH . WPINC . '/feed.php' );
366
- $maxitems = 0;
367
- // Get a SimplePie feed object from the specified feed source.
368
- $rss = fetch_feed( $feed_url );
369
- if ( ! is_wp_error( $rss ) ) { // Checks that the object is created correctly
370
- // Figure out how many total items there are, but limit it to 5.
371
- $maxitems = $rss->get_item_quantity( 5 );
372
-
373
- // Build an array of all the items, starting with element 0 (first element).
374
- $rss_items = $rss->get_items( 0, $maxitems );
375
- }
376
- ?>
377
- <ul><?php
378
- if ( $maxitems == 0 ) {
379
- echo '<li>' . __( 'No items', 'bp-media' ) . '.</li>';
380
- } else {
381
- // Loop through each feed item and display each item as a hyperlink.
382
- foreach ( $rss_items as $item ) {
383
- ?>
384
- <li>
385
- <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>
386
- </li><?php
387
- }
388
- }
389
- ?>
390
- </ul><?php
391
- }
392
-
393
- function fetch_feeds() {
394
- if ( isset( $_GET[ 'get_feeds' ] ) && $_GET[ 'get_feeds' ] == '1' ) {
395
- get_feeds();
396
- die();
397
- }
398
- }
399
-
400
- add_action( 'init', 'fetch_feeds' );
401
- }
402
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/purger.php DELETED
@@ -1,675 +0,0 @@
1
- <?php
2
-
3
- namespace rtCamp\WP\Nginx {
4
-
5
- class Purger {
6
-
7
- function purgePostOnComment( $comment_id, $comment ) {
8
- $oldstatus = '';
9
- $approved = $comment->comment_approved;
10
-
11
- if ( $approved == null )
12
- $newstatus = false;
13
- elseif ( $approved == '1' )
14
- $newstatus = 'approved';
15
- elseif ( $approved == '0' )
16
- $newstatus = 'unapproved';
17
- elseif ( $approved == 'spam' )
18
- $newstatus = 'spam';
19
- elseif ( $approved == 'trash' )
20
- $newstatus = 'trash';
21
- else
22
- $newstatus = false;
23
-
24
- $this->purgePostOnCommentChange( $newstatus, $oldstatus, $comment );
25
- }
26
-
27
- function purgePostOnCommentChange( $newstatus, $oldstatus, $comment ) {
28
-
29
- global $rt_wp_nginx_helper, $blog_id;
30
- if ( ! $rt_wp_nginx_helper->options[ 'enable_purge' ] ) {
31
- return;
32
- }
33
-
34
-
35
- $_post_id = $comment->comment_post_ID;
36
- $_comment_id = $comment->comment_ID;
37
-
38
- $this->log( "* * * * *" );
39
- $this->log( "* Blog :: " . addslashes( get_bloginfo( 'name' ) ) . " ($blog_id)." );
40
- $this->log( "* Post :: " . get_the_title( $_post_id ) . " ($_post_id)." );
41
- $this->log( "* Comment :: $_comment_id." );
42
- $this->log( "* Status Changed from $oldstatus to $newstatus" );
43
- switch ( $newstatus ) {
44
- case 'approved':
45
- if ( $rt_wp_nginx_helper->options[ 'purge_page_on_new_comment' ] == 1 ) {
46
- $this->log( "* Comment ($_comment_id) approved. Post ($_post_id) purging..." );
47
- $this->log( "* * * * *" );
48
- $this->purgePost( $_post_id );
49
- }
50
- break;
51
- case 'spam':
52
- case 'unapproved':
53
- case 'trash':
54
- if ( $oldstatus == 'approve' ) {
55
- if ( $rt_wp_nginx_helper->options[ 'purge_page_on_deleted_comment' ] == 1 ) {
56
- $this->log( "* Comment ($_comment_id) removed as ($newstatus). Post ($_post_id) purging..." );
57
- $this->log( "* * * * *" );
58
- $this->purgePost( $_post_id );
59
- }
60
- }
61
- break;
62
- }
63
- }
64
-
65
- function purgePost( $_ID ) {
66
-
67
- global $rt_wp_nginx_helper, $blog_id;
68
- if ( ! $rt_wp_nginx_helper->options[ 'enable_purge' ] ) {
69
- return;
70
- }
71
- switch ( current_filter() ) {
72
- case 'publish_post':
73
- $this->log( "* * * * *" );
74
- $this->log( "* Blog :: " . addslashes( get_bloginfo( 'name' ) ) . " ($blog_id)." );
75
- $this->log( "* Post :: " . get_the_title( $_ID ) . " ($_ID)." );
76
- $this->log( "* Post ($_ID) published or edited and its status is published" );
77
- $this->log( "* * * * *" );
78
- break;
79
-
80
- case 'publish_page':
81
- $this->log( "* * * * *" );
82
- $this->log( "* Blog :: " . addslashes( get_bloginfo( 'name' ) ) . " ($blog_id)." );
83
- $this->log( "* Page :: " . get_the_title( $_ID ) . " ($_ID)." );
84
- $this->log( "* Page ($_ID) published or edited and its status is published" );
85
- $this->log( "* * * * *" );
86
- break;
87
-
88
- case 'comment_post':
89
- case 'wp_set_comment_status':
90
- break;
91
-
92
- default:
93
- $_post_type = get_post_type( $_ID );
94
- $this->log( "* * * * *" );
95
- $this->log( "* Blog :: " . addslashes( get_bloginfo( 'name' ) ) . " ($blog_id)." );
96
- $this->log( "* Custom post type '$_post_type' :: " . get_the_title( $_ID ) . " ($_ID)." );
97
- $this->log( "* CPT '$_post_type' ($_ID) published or edited and its status is published" );
98
- $this->log( "* * * * *" );
99
- break;
100
- }
101
-
102
- $this->log( "Function purgePost BEGIN ===" );
103
-
104
- if ( $rt_wp_nginx_helper->options[ 'purge_homepage_on_edit' ] == 1 ) {
105
- $homepage_url = trailingslashit( get_option( 'siteurl' ) );
106
-
107
- $this->log( "Purging homepage '$homepage_url'" );
108
- $this->purgeUrl( $homepage_url );
109
- }
110
-
111
-
112
- if ( current_filter() == 'comment_post' || current_filter() == 'wp_set_comment_status' ) {
113
- $this->_purge_by_options( $_ID, $blog_id, $rt_wp_nginx_helper->options[ 'purge_page_on_new_comment' ], $rt_wp_nginx_helper->options[ 'purge_archive_on_new_comment' ], $rt_wp_nginx_helper->options[ 'purge_archive_on_new_comment' ] );
114
- } else {
115
- $this->_purge_by_options( $_ID, $blog_id, $rt_wp_nginx_helper->options[ 'purge_page_on_mod' ], $rt_wp_nginx_helper->options[ 'purge_archive_on_edit' ], $rt_wp_nginx_helper->options[ 'purge_archive_on_edit' ] );
116
- }
117
-
118
- $this->log( "Function purgePost END ^^^" );
119
- }
120
-
121
- private function _purge_by_options( $_post_ID, $blog_id, $_purge_page, $_purge_archive, $_purge_custom_taxa ) {
122
-
123
- global $rt_wp_nginx_helper;
124
-
125
- $_post_type = get_post_type( $_post_ID );
126
-
127
- if ( $_purge_page ) {
128
- if ( $_post_type == 'post' || $_post_type == 'page' ) {
129
- $this->log( "Purging $_post_type (id $_post_ID, blog id $blog_id)" );
130
- } else {
131
- $this->log( "Purging custom post type '$_post_type' (id $_post_ID, blog id $blog_id)" );
132
- }
133
-
134
- $this->purgeUrl( get_permalink( $_post_ID ) );
135
- }
136
-
137
- if ( $_purge_archive ) {
138
-
139
- if ( function_exists( 'get_post_type_archive_link' ) && ( $_post_type_archive_link = get_post_type_archive_link( $_post_type ) ) ) {
140
- $this->log( "Purging post type archive (" . $_post_type . ")" );
141
- $this->purgeUrl( $_post_type_archive_link );
142
- }
143
-
144
- if ( $_post_type == 'post' ) {
145
- $this->log( "Purging date" );
146
-
147
- $day = get_the_time( 'd', $_post_ID );
148
- $month = get_the_time( 'm', $_post_ID );
149
- $year = get_the_time( 'Y', $_post_ID );
150
-
151
- if ( $year ) {
152
- $this->purgeUrl( get_year_link( $year ) );
153
- if ( $month ) {
154
- $this->purgeUrl( get_month_link( $year, $month ) );
155
- if ( $day )
156
- $this->purgeUrl( get_day_link( $year, $month, $day ) );
157
- }
158
- }
159
- }
160
-
161
- if ( $categories = wp_get_post_categories( $_post_ID ) ) {
162
- $this->log( "Purging category archives" );
163
-
164
- foreach ( $categories as $category_id ) {
165
- $this->log( "Purging category " . $category_id );
166
- $this->purgeUrl( get_category_link( $category_id ) );
167
- }
168
- }
169
-
170
- if ( $tags = get_the_tags( $_post_ID ) ) {
171
- $this->log( "Purging tag archives" );
172
-
173
- foreach ( $tags as $tag ) {
174
- $this->log( "Purging tag " . $tag->term_id );
175
- $this->purgeUrl( get_tag_link( $tag->term_id ) );
176
- }
177
- }
178
-
179
- if ( $author_id = get_post( $_post_ID )->post_author ) {
180
- $this->log( "Purging author archive" );
181
- $this->purgeUrl( get_author_posts_url( $author_id ) );
182
- }
183
- }
184
-
185
- if ( $_purge_custom_taxa ) {
186
- if ( $custom_taxonomies = get_taxonomies( array( 'public' => true, '_builtin' => false ) ) ) {
187
- $this->log( "Purging custom taxonomies related" );
188
- foreach ( $custom_taxonomies as $taxon ) {
189
-
190
- if ( ! in_array( $taxon, array( 'category', 'post_tag', 'link_category' ) ) ) {
191
-
192
- if ( $terms = get_the_terms( $_post_ID, $taxon ) ) {
193
- foreach ( $terms as $term ) {
194
- $this->purgeUrl( get_term_link( $term, $taxon ) );
195
- }
196
- }
197
- } else {
198
- $this->log( "Your built-in taxonomy '" . $taxon . "' has param '_builtin' set to false.", "WARNING" );
199
- }
200
- }
201
- }
202
- }
203
- }
204
-
205
- function purgeUrl( $url, $feed = true ) {
206
-
207
- $this->log( "- Purging URL | " . $url );
208
-
209
- $parse = parse_url( $url );
210
-
211
- $_url_purge = $parse[ 'scheme' ] . '://' . $parse[ 'host' ] . '/purge' . $parse[ 'path' ];
212
-
213
- if ( isset( $parse[ 'query' ] ) && $parse[ 'query' ] != '' ) {
214
- $_url_purge .= '?' . $parse[ 'query' ];
215
- }
216
-
217
- $this->_do_remote_get( $_url_purge );
218
-
219
- if ( $feed ) {
220
- $feed_string = (substr( $parse[ 'path' ], -1 ) != '/') ? "/feed/" : "feed/";
221
- $this->_do_remote_get( $parse[ 'scheme' ] . '://' . $parse[ 'host' ] . '/purge' . $parse[ 'path' ] . $feed_string );
222
- }
223
- }
224
-
225
- private function _do_remote_get( $url ) {
226
-
227
- $response = wp_remote_get( $url );
228
-
229
- if ( is_wp_error( $response ) ) {
230
- $_errors_str = implode( " - ", $response->get_error_messages() );
231
- $this->log( "Error while purging URL. " . $_errors_str, "ERROR" );
232
- } else {
233
- if ( $response[ 'response' ][ 'code' ] ) {
234
- switch ( $response[ 'response' ][ 'code' ] ) {
235
- case 200:
236
- $this->log( "- - " . $url . " *** PURGED ***" );
237
- break;
238
- case 404:
239
- $this->log( "- - " . $url . " is currently not cached" );
240
- break;
241
- default:
242
- $this->log( "- - " . $url . " not found (" . $response[ 'response' ][ 'code' ] . ")", "WARNING" );
243
- }
244
- }
245
- }
246
- }
247
-
248
- function checkHttpConnection() {
249
-
250
- $purgeURL = plugins_url( "nginx-manager/check-proxy.php" );
251
- $response = wp_remote_get( $purgeURL );
252
-
253
- if ( ! is_wp_error( $response ) && ($response[ 'body' ] == 'HTTP Connection OK') ) {
254
- return "OK";
255
- }
256
-
257
- return "KO";
258
- }
259
-
260
- function log( $msg, $level = 'INFO' ) {
261
-
262
- global $rt_wp_nginx_helper;
263
- if ( ! $rt_wp_nginx_helper->options[ 'enable_log' ] ) {
264
- return;
265
- }
266
-
267
- $log_levels = array( "INFO" => 0, "WARNING" => 1, "ERROR" => 2, "NONE" => 3 );
268
-
269
- if ( $log_levels[ $level ] >= $log_levels[ $rt_wp_nginx_helper->options[ 'log_level' ] ] ) {
270
- if ( $fp = fopen( RT_WP_NGINX_HELPER_PATH . 'nginx.log', "a+" ) ) {
271
- fwrite( $fp, "\n" . gmdate( "Y-m-d H:i:s " ) . " | " . $level . " | " . $msg );
272
- fclose( $fp );
273
- }
274
- }
275
-
276
- return true;
277
- }
278
-
279
- function checkAndTruncateLogFile() {
280
-
281
- global $rt_wp_nginx_helper;
282
-
283
- $maxSizeAllowed = (is_numeric( $rt_wp_nginx_helper->options[ 'log_filesize' ] )) ? $rt_wp_nginx_helper->options[ 'log_filesize' ] * 1048576 : 5242880;
284
-
285
- $fileSize = filesize( RT_WP_NGINX_HELPER_PATH . 'nginx.log' );
286
-
287
- if ( $fileSize > $maxSizeAllowed ) {
288
-
289
- $offset = $fileSize - $maxSizeAllowed;
290
-
291
- if ( $file_content = file_get_contents( RT_WP_NGINX_HELPER_PATH . 'nginx.log', NULL, NULL, $offset ) ) {
292
-
293
- if ( $file_content = strstr( $file_content, "\n" ) ) {
294
-
295
- if ( $fp = fopen( RT_WP_NGINX_HELPER_PATH . 'nginx.log', "w+" ) ) {
296
- fwrite( $fp, $file_content );
297
- fclose( $fp );
298
- }
299
- }
300
- }
301
- }
302
- }
303
-
304
- function purgeImageOnEdit( $attachment_id ) {
305
-
306
- $this->log( "Purging media on edit BEGIN ===" );
307
-
308
- if ( wp_attachment_is_image( $attachment_id ) ) {
309
-
310
- $this->purgeUrl( wp_get_attachment_url( $attachment_id ), false );
311
- $attachment = wp_get_attachment_metadata( $attachment_id );
312
-
313
- if ( $attachment[ 'sizes' ] ) {
314
- foreach ( $attachment[ 'sizes' ] as $size_name => $size ) {
315
- $resize_image = wp_get_attachment_image_src( $attachment_id, $size_name );
316
- if ( $resize_image )
317
- $this->purgeUrl( $resize_image[ 0 ], false );
318
- }
319
- }
320
- } else {
321
- $this->log( "Media (id $attachment_id) edited: no image", "WARNING" );
322
- }
323
-
324
- $this->log( "Purging media on edit END ^^^" );
325
- }
326
-
327
- function purge_on_post_moved_to_trash( $new_status, $old_status, $post ) {
328
-
329
- global $rt_wp_nginx_helper, $blog_id;
330
- if ( ! $rt_wp_nginx_helper->options[ 'enable_purge' ] ) {
331
- return;
332
- }
333
- if ( $new_status == 'trash' ) {
334
-
335
- $this->log( "# # # # #" );
336
- $this->log( "# Post '$post->post_title' (id $post->ID) moved to the trash." );
337
- $this->log( "# # # # #" );
338
-
339
- $this->log( "Function purge_on_post_moved_to_trash (post id $post->ID) BEGIN ===" );
340
-
341
-
342
-
343
- if ( $rt_wp_nginx_helper->options[ 'purge_homepage_on_delete' ] == 1 ) {
344
- $this->_purge_homepage();
345
- }
346
-
347
-
348
- $this->_purge_by_options( $post->ID, $blog_id, false, $rt_wp_nginx_helper->options[ 'purge_archive_on_delete' ], $rt_wp_nginx_helper->options[ 'purge_archive_on_delete' ] );
349
-
350
-
351
-
352
- $this->log( "Function purge_on_post_moved_to_trash (post id $post->ID) END ===" );
353
- }
354
-
355
- return true;
356
- }
357
-
358
- private function _purge_homepage() {
359
-
360
- $homepage_url = trailingslashit( get_option( 'siteurl' ) );
361
-
362
- $this->log( sprintf( __( "Purging homepage '%s'", "rt_wp_nginx_helper" ), $homepage_url ) );
363
- $this->purgeUrl( $homepage_url );
364
-
365
- return true;
366
- }
367
-
368
- private function _purge_personal_urls() {
369
-
370
- global $rt_wp_nginx_helper;
371
-
372
- $this->log( __( "Purging personal urls", "rt_wp_nginx_helper" ) );
373
-
374
- if ( isset( $rt_wp_nginx_helper->options[ 'purgeable_url' ][ 'urls' ] ) ) {
375
-
376
- foreach ( $rt_wp_nginx_helper->options[ 'purgeable_url' ][ 'urls' ] as $u ) {
377
- $this->purgeUrl( $u, false );
378
- }
379
- } else {
380
- $this->log( "- " . __( "No personal urls available", "rt_wp_nginx_helper" ) );
381
- }
382
-
383
- return true;
384
- }
385
-
386
- private function _purge_post_categories( $_post_id ) {
387
-
388
- $this->log( __( "Purging category archives", "rt_wp_nginx_helper" ) );
389
-
390
- if ( $categories = wp_get_post_categories( $_post_id ) ) {
391
- foreach ( $categories as $category_id ) {
392
- $this->log( sprintf( __( "Purging category '%d'", "rt_wp_nginx_helper" ), $category_id ) );
393
- $this->purgeUrl( get_category_link( $category_id ) );
394
- }
395
- }
396
-
397
- return true;
398
- }
399
-
400
- private function _purge_post_tags( $_post_id ) {
401
-
402
- $this->log( __( "Purging tags archives", "rt_wp_nginx_helper" ) );
403
-
404
- if ( $tags = get_the_tags( $_post_id ) ) {
405
- foreach ( $tags as $tag ) {
406
- $this->log( sprintf( __( "Purging tag '%s' (id %d)", "rt_wp_nginx_helper" ), $tag->name, $tag->term_id ) );
407
- $this->purgeUrl( get_tag_link( $tag->term_id ) );
408
- }
409
- }
410
-
411
- return true;
412
- }
413
-
414
- private function _purge_post_custom_taxa( $_post_id ) {
415
-
416
- $this->log( __( "Purging post custom taxonomies related", "rt_wp_nginx_helper" ) );
417
-
418
- if ( $custom_taxonomies = get_taxonomies( array( 'public' => true, '_builtin' => false ) ) ) {
419
- foreach ( $custom_taxonomies as $taxon ) {
420
- $this->log( sprintf( "+ " . __( "Purging custom taxonomy '%s'", "rt_wp_nginx_helper" ), $taxon ) );
421
-
422
- if ( ! in_array( $taxon, array( 'category', 'post_tag', 'link_category' ) ) ) {
423
-
424
- if ( $terms = get_the_terms( $_post_id, $taxon ) ) {
425
- foreach ( $terms as $term ) {
426
- $this->purgeUrl( get_term_link( $term, $taxon ) );
427
- }
428
- }
429
- } else {
430
- $this->log( sprintf( "- " . __( "Your built-in taxonomy '%s' has param '_builtin' set to false.", "rt_wp_nginx_helper" ), $taxon ), "WARNING" );
431
- }
432
- }
433
- } else {
434
- $this->log( "- " . __( "No custom taxonomies", "rt_wp_nginx_helper" ) );
435
- }
436
-
437
- return true;
438
- }
439
-
440
- private function _purge_all_categories() {
441
-
442
- $this->log( __( "Purging all categories", "rt_wp_nginx_helper" ) );
443
-
444
- if ( $_categories = get_categories() ) {
445
-
446
- foreach ( $_categories as $c ) {
447
- $this->log( sprintf( __( "Purging category '%s' (id %d)", "rt_wp_nginx_helper" ), $c->name, $c->term_id ) );
448
- $this->purgeUrl( get_category_link( $c->term_id ) );
449
- }
450
- } else {
451
- $this->log( __( "No categories archives", "rt_wp_nginx_helper" ) );
452
- }
453
-
454
- return true;
455
- }
456
-
457
- private function _purge_all_posttags() {
458
-
459
- $this->log( __( "Purging all tags", "rt_wp_nginx_helper" ) );
460
-
461
- if ( $_posttags = get_tags() ) {
462
-
463
- foreach ( $_posttags as $t ) {
464
- $this->log( sprintf( __( "Purging tag '%s' (id %d)", "rt_wp_nginx_helper" ), $t->name, $t->term_id ) );
465
- $this->purgeUrl( get_tag_link( $t->term_id ) );
466
- }
467
- } else {
468
- $this->log( __( "No tags archives", "rt_wp_nginx_helper" ) );
469
- }
470
-
471
- return true;
472
- }
473
-
474
- private function _purge_all_customtaxa() {
475
-
476
- $this->log( __( "Purging all custom taxonomies", "rt_wp_nginx_helper" ) );
477
-
478
- if ( $custom_taxonomies = get_taxonomies( array( 'public' => true, '_builtin' => false ) ) ) {
479
-
480
- foreach ( $custom_taxonomies as $taxon ) {
481
- $this->log( sprintf( "+ " . __( "Purging custom taxonomy '%s'", "rt_wp_nginx_helper" ), $taxon ) );
482
-
483
- if ( ! in_array( $taxon, array( 'category', 'post_tag', 'link_category' ) ) ) {
484
-
485
- if ( $terms = get_terms( $taxon ) ) {
486
- foreach ( $terms as $term ) {
487
- $this->purgeUrl( get_term_link( $term, $taxon ) );
488
- }
489
- }
490
- } else {
491
- $this->log( sprintf( "- " . __( "Your built-in taxonomy '%s' has param '_builtin' set to false.", "rt_wp_nginx_helper" ), $taxon ), "WARNING" );
492
- }
493
- }
494
- } else {
495
- $this->log( "- " . __( "No custom taxonomies", "rt_wp_nginx_helper" ) );
496
- }
497
-
498
- return true;
499
- }
500
-
501
- private function _purge_all_taxonomies() {
502
-
503
- $this->_purge_all_categories();
504
- $this->_purge_all_posttags();
505
- $this->_purge_all_customtaxa();
506
-
507
- return true;
508
- }
509
-
510
- private function _purge_all_posts() {
511
-
512
- $this->log( __( "Purging all posts, pages and custom post types.", "rt_wp_nginx_helper" ) );
513
-
514
- $args = array(
515
- 'numberposts' => 0,
516
- 'post_type' => 'any',
517
- 'post_status' => 'publish' );
518
-
519
- if ( $_posts = get_posts( $args ) ) {
520
-
521
- foreach ( $_posts as $p ) {
522
- $this->log( sprintf( "+ " . __( "Purging post id '%d' (post type '%s')", "rt_wp_nginx_helper" ), $p->ID, $p->post_type ) );
523
- $this->purgeUrl( get_permalink( $p->ID ) );
524
- }
525
- } else {
526
- $this->log( "- " . __( "No posts", "rt_wp_nginx_helper" ) );
527
- }
528
-
529
- return true;
530
- }
531
-
532
- private function _purge_all_date_archives() {
533
-
534
- $this->log( __( "Purging all date-based archives.", "rt_wp_nginx_helper" ) );
535
-
536
- $this->_purge_all_daily_archives();
537
-
538
- $this->_purge_all_monthly_archives();
539
-
540
- $this->_purge_all_yearly_archives();
541
-
542
- return true;
543
- }
544
-
545
- private function _purge_all_daily_archives() {
546
-
547
- global $wpdb;
548
-
549
- $this->log( __( "Purging all daily archives.", "rt_wp_nginx_helper" ) );
550
-
551
- $_query_daily_archives = $wpdb->prepare(
552
- "SELECT YEAR(post_date) AS 'year', MONTH(post_date) AS 'month', DAYOFMONTH(post_date) AS 'dayofmonth', count(ID) as posts
553
- FROM $wpdb->posts
554
- WHERE post_type = 'post' AND post_status = 'publish'
555
- GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date)
556
- ORDER BY post_date DESC"
557
- );
558
-
559
- if ( $_daily_archives = $wpdb->get_results( $_query_daily_archives ) ) {
560
-
561
- foreach ( $_daily_archives as $_da ) {
562
- $this->log( sprintf( "+ " . __( "Purging daily archive '%s/%s/%s'", "rt_wp_nginx_helper" ), $_da->year, $_da->month, $_da->dayofmonth ) );
563
- $this->purgeUrl( get_day_link( $_da->year, $_da->month, $_da->dayofmonth ) );
564
- }
565
- } else {
566
- $this->log( "- " . __( "No daily archives", "rt_wp_nginx_helper" ) );
567
- }
568
- }
569
-
570
- private function _purge_all_monthly_archives() {
571
-
572
- global $wpdb;
573
-
574
- $this->log( __( "Purging all monthly archives.", "rt_wp_nginx_helper" ) );
575
-
576
- $_query_monthly_archives = $wpdb->prepare(
577
- "SELECT YEAR(post_date) AS 'year', MONTH(post_date) AS 'month', count(ID) as posts
578
- FROM $wpdb->posts
579
- WHERE post_type = 'post' AND post_status = 'publish'
580
- GROUP BY YEAR(post_date), MONTH(post_date)
581
- ORDER BY post_date DESC"
582
- );
583
-
584
- if ( $_monthly_archives = $wpdb->get_results( $_query_monthly_archives ) ) {
585
-
586
- foreach ( $_monthly_archives as $_ma ) {
587
- $this->log( sprintf( "+ " . __( "Purging monthly archive '%s/%s'", "rt_wp_nginx_helper" ), $_ma->year, $_ma->month ) );
588
- $this->purgeUrl( get_month_link( $_ma->year, $_ma->month ) );
589
- }
590
- } else {
591
- $this->log( "- " . __( "No monthly archives", "rt_wp_nginx_helper" ) );
592
- }
593
- }
594
-
595
- private function _purge_all_yearly_archives() {
596
-
597
- global $wpdb;
598
-
599
- $this->log( __( "Purging all yearly archives.", "rt_wp_nginx_helper" ) );
600
-
601
- $_query_yearly_archives = $wpdb->prepare(
602
- "SELECT YEAR(post_date) AS 'year', count(ID) as posts
603
- FROM $wpdb->posts
604
- WHERE post_type = 'post' AND post_status = 'publish'
605
- GROUP BY YEAR(post_date)
606
- ORDER BY post_date DESC"
607
- );
608
-
609
- if ( $_yearly_archives = $wpdb->get_results( $_query_yearly_archives ) ) {
610
-
611
- foreach ( $_yearly_archives as $_ya ) {
612
- $this->log( sprintf( "+ " . __( "Purging yearly archive '%s'", "rt_wp_nginx_helper" ), $_ya->year ) );
613
- $this->purgeUrl( get_year_link( $_ya->year ) );
614
- }
615
- } else {
616
- $this->log( "- " . __( "No yearly archives", "rt_wp_nginx_helper" ) );
617
- }
618
- }
619
-
620
- function purge_them_all() {
621
-
622
- $this->log( __( "Let's purge everything!", "rt_wp_nginx_helper" ) );
623
-
624
- $this->_purge_homepage();
625
-
626
- $this->_purge_personal_urls();
627
-
628
- $this->_purge_all_posts();
629
-
630
- $this->_purge_all_taxonomies();
631
-
632
- $this->_purge_all_date_archives();
633
-
634
- $this->log( __( "Everthing purged!", "rt_wp_nginx_helper" ) );
635
-
636
- return true;
637
- }
638
-
639
- function purge_on_term_taxonomy_edited( $term_id, $tt_id, $taxon ) {
640
-
641
- $this->log( __( "Term taxonomy edited or deleted", "rt_wp_nginx_helper" ) );
642
-
643
- if ( current_filter() == 'edit_term' && $term = get_term( $term_id, $taxon ) ) {
644
- $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 ) );
645
- } else if ( current_filter() == 'delete_term' ) {
646
- $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 ) );
647
- }
648
-
649
- $this->_purge_homepage();
650
-
651
- return true;
652
- }
653
-
654
- function purge_on_check_ajax_referer( $action, $result ) {
655
-
656
- switch ( $action ) {
657
- case 'save-sidebar-widgets' :
658
-
659
- $this->log( __( "Widget saved, moved or removed in a sidebar", "rt_wp_nginx_helper" ) );
660
-
661
- $this->_purge_homepage();
662
-
663
- break;
664
-
665
- default :
666
- break;
667
- }
668
-
669
- return true;
670
- }
671
-
672
- }
673
-
674
- }
675
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/readme.txt DELETED
@@ -1,205 +0,0 @@
1
- === Nginx ===
2
- Contributors: rtcamp, rahul286, saurabhshukla, Darren Slatten, jk3us, daankortenbach
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.5
6
- Stable tag: 1.6.8
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/
10
-
11
- Helps WordPress-Nginx work together nicely using fastcgi/proxy cache purging, nginx map{}, rewrite support for permalinks & more
12
-
13
- == Description ==
14
-
15
- 1. Removes `index.php` from permalinks when using WordPress with nginx.
16
- 1. Adds support for nginx fastcgi_cache_purge & proxy_cache_purge directive from [module](https://github.com/FRiCKLE/ngx_cache_purge "ngx_cache_purge module"). Provides settings so you can customize purging rules.
17
- 1. Adds support for nginx `map{..}` on a WordPress-multisite network installation. Using it Nginx can serve PHP file uploads even if PHP/MySQL crashes. Please check tutorials list below for related Nginx config.
18
-
19
- = Tutorials =
20
-
21
- You will need to follow one ore more tutorials below to get desired functionality:
22
-
23
- * [Nginx Map + WordPress-Multisite + Static Files Handling](http://rtcamp.com/tutorials/nginx-maps-wordpress-multisite-static-files-handling/)
24
- * [Nginx + WordPress + fastcgi_purge_cache](http://rtcamp.com/tutorials/wordpress-nginx-fastcgi-cache-purge-conditional/)
25
- * [Nginx + WordPress-Multisite (Subdirectories) + fastcgi_purge_cache](http://rtcamp.com/tutorials/wordpress-multisite-subdirectories-nginx-fastcgi-cache-purge/)
26
- * [Nginx + WordPress-Multisite (Subdomains/domain-mapping) + fastcgi_purge_cache](http://rtcamp.com/tutorials/wordpress-multisite-subdomains-domain-mapping-nginx-fastcgi-cache-purge/)
27
- * [Other WordPress-Nginx Tutorials](http://rtcamp.com/wordpress-nginx/tutorials/)
28
-
29
-
30
- == Installation ==
31
-
32
- Automatic Installation
33
-
34
- 1. Log in to your WordPress admin panel, navigate to the Plugins menu and click Add New.
35
- 1. In the search field type “Nginx Helper” and click Search Plugins. From the search results, pick Nginx Helper and click Install Now. Wordpress will ask you to confirm to complete the installation.
36
-
37
- Manual Installation
38
-
39
- 1. Extract the zip file.
40
- 1. Upload them to `/wp-content/plugins/` directory on your WordPress installation.
41
- 1. Then activate the Plugin from Plugins page.
42
-
43
- For proper configuration, check **tutorial list** of [Description tab](http://wordpress.org/extend/plugins/nginx-helper/)
44
-
45
- == Frequently Asked Questions ==
46
-
47
- = FAQ - Installation/Comptability =
48
-
49
- **Q. Will this work out of the box?**
50
-
51
- No. You need to make some changes at the Nginx end. Please check **tutorial list** of [Description tab](http://wordpress.org/extend/plugins/nginx-helper/)
52
-
53
- = FAQ - Nginx Map =
54
-
55
- **Q. My multisite already uses `WPMU_ACCEL_REDIRECT`. Do I still need Nginx Map?**
56
-
57
- Definitely. `WPMU_ACCEL_REDIRECT` reduces the load on PHP, but it still ask WordPress i.e. PHP/MySQL to do some work for static files e.g. images in your post. Nginx map lets nginx handle files on its own bypassing wordpress which gives you much better performance without using a CDN.
58
-
59
- = FAQ - Nginx Fastcgi Cache Purge =
60
-
61
- **Q. Does it work for custom posts and taxonomies?**
62
- Yes. It handles all post-types same way.
63
-
64
- **Q. How do I know my Nginx config is correct for fastcgi purging?**
65
-
66
- Manually purging any page from the cache, by following instructions in the previous answer.
67
-
68
- Version 1.3.4 onwards, Nginx Helper adds a comment at the end of the html source ('view source' in your favourite browser):
69
- &lt;!--Cached using Nginx-Helper on 2012-10-08 07:01:45. It took 42 queries executed in 0.280 seconds.--&gt;
70
- This shows the time when the page was last cached. This date/time will be reset whenever this page is purged and refreshed in the cache.
71
-
72
- Just check this comment before and after a manual purge.
73
- As long as you don't purge the page (or make changes that purge it from the cache), the timestamp will remain as it is, even if you keep refreshing the page. This means the page was served from the cache and it's working!
74
-
75
- The rest shows you the database queries and time saved on loading this page. (This would have been the additional resource load, if you weren't using fast-cgi-cache.)
76
-
77
-
78
- **Q. I need to flush a cached page immediately! How do I do that?**
79
-
80
- Nginx helper plugin handles usual scenarios, when a page in the cache will need purging. For example, when a post is edited or a comment is approved on a post.
81
-
82
- To purge a page immediately, follow these instructions:
83
- (eg. http://yoursite.com/about/)
84
- Between the domain name and the rest of the url, insert '/purge/'.
85
- So, in the above eg, the purge url will be http://yoursite.com/purge/about/
86
- Just open this in a browser and the page will be purged instantly.
87
- Needless to say, this won't work, if you have a page or taxonomy called 'purge'.
88
-
89
- = FAQ - Nginx Map =
90
-
91
- **Q. I am using X plugin. Will it work on Nginx?**
92
-
93
- Most likely yes. A wordpress plugin, if not using explictly any Apache-only mod, should work on Nginx. Some plugin may need some extra work.
94
-
95
-
96
- = Still need help! =
97
-
98
- Post your problem in [our free support forum](http://rtcamp.com/support/forum/wordpress-nginx/) or wordpress.org forum here. We answer questions everywhere. Including Nginx official forum, serverfault, stackoverflow, etc.
99
- Its just that we are hyperactive on our own forum!
100
-
101
-
102
- == Screenshots ==
103
- 1. Nginx plugin settings
104
- 2. Remaining settings
105
-
106
- == Changelog ==
107
-
108
- = 1.6.8 =
109
- * [daankortenbach](http://profiles.wordpress.org/daankortenbach) added Purge Cache link to wp-admin bar
110
-
111
- = 1.6.7 =
112
- * [jk3us](http://profiles.wordpress.org/jk3us) added better content-type detection for cache verification comments
113
-
114
- = 1.6.6 =
115
- * [darren-slatten](http://profiles.wordpress.org/darren-slatten/) added Manual 'Purge all URLs' functionality
116
-
117
- = 1.6.5 =
118
- * Fixed typo that interfered with archive purge settings. Thanks to [Daan Kortenbach](http://profiles.wordpress.org/daankortenbach/) for pointing this out.
119
-
120
- = 1.6.4 =
121
- * Improved code for map generation to better conventions since the nesting confused some servers.
122
- * Added map update process to admin_init for frequent refreshes.
123
-
124
- = 1.6.3 =
125
- * Fixed duplicate entries.
126
-
127
- = 1.6.2 =
128
- * Another bug fix in the revised code for improved multisite and multidomain mapping.
129
-
130
- = 1.6.1 =
131
- * Fixed bug in the revised code for improved multisite and multidomain mapping.
132
-
133
- = 1.6 =
134
- * Revised code for improved multisite and multidomain mapping.
135
-
136
- = 1.5 =
137
- * Timestamp now only gets added to content-type text/html
138
- * Added option to toggle timestamp creation
139
-
140
- = 1.4 =
141
- * Fixed bug related to nomenclature of comment status that caused purge to fail.
142
-
143
- = 1.3.9 =
144
- * Removed extraneous headers.
145
-
146
- = 1.3.8 =
147
-
148
- * Fixed bug in single post/page/post-type purging code. Thanks to Greg for pointing this out here: http://rtcamp.com/support/topic/updating-post-nginx-helper-purge-cache-post/.
149
-
150
- = 1.3.7 =
151
-
152
- * Changed the action hook, back to 'shutdown' from 'wp_footer' to add verification comments.
153
- * Added a check to prevent adding comments to ajax requests,
154
-
155
- = 1.3.6 =
156
-
157
- * Changed the action hook, from 'shutdown' to 'wp_footer' to add verification comments. This was interfering with other plugins.
158
-
159
- = 1.3.5 =
160
-
161
- * Improved Readme.
162
- * Improved cache verification comments.
163
-
164
- = 1.3.4 =
165
-
166
- * Fixed duplicate entries generated for maps (Harmless, but doesn't look good!)
167
- * Added timestamp html comments for cache verification, as described here: http://rtcamp.com/tutorials/checklist-verify-wordpress-nginx-setup/
168
-
169
- = 1.3.3 =
170
-
171
- * Fixed map generation for multi domain installs using domain mapping plugin, where blog ids were not displayed.
172
-
173
- = 1.3.2 =
174
-
175
- * Fixed map generation for multi domain installs with domain mapping plugin.
176
-
177
- = 1.3.1 =
178
-
179
- * Minor fixes for directory structure and file names.
180
-
181
- = 1.3 =
182
-
183
- * Improved Readme.
184
-
185
-
186
- = 1.2 =
187
-
188
- * Fixed map generation error.
189
- * Fixed purging logic.
190
- * Fixed UI where purge settings were lost on disabling and re-enabling purge.
191
- * Minor Ui rearrangement.
192
-
193
- = 1.1 =
194
-
195
- * Improved readme.txt. Added Screenshots.
196
-
197
- = 1.0 =
198
-
199
- * First release
200
-
201
-
202
- == Upgrade Notice ==
203
-
204
- = 1.6.8 =
205
- Added purge cache to admin bar.