Version Description
- Added option to purge cache without nginx purge module - by bcole808
Download this release
Release Info
Developer | rtcamp |
Plugin | Nginx Helper |
Version | 1.8.8 |
Comparing to | |
See all releases |
Code changes from version 1.8.7 to 1.8.8
- admin/lib/nginx-general.php +27 -0
- nginx-helper.php +2 -2
- purger.php +83 -10
- readme.txt +5 -3
- trunk/admin/admin.php +141 -0
- trunk/admin/assets/logo.png +0 -0
- trunk/admin/assets/nginx-helper-icons/config.json +34 -0
- trunk/admin/assets/nginx-helper-icons/css/nginx-fontello.css +56 -0
- trunk/admin/assets/nginx-helper-icons/font/nginx-fontello.eot +0 -0
- trunk/admin/assets/nginx-helper-icons/font/nginx-fontello.svg +15 -0
- trunk/admin/assets/nginx-helper-icons/font/nginx-fontello.ttf +0 -0
- trunk/admin/assets/nginx-helper-icons/font/nginx-fontello.woff +0 -0
- trunk/admin/assets/nginx-icon-32x32.png +0 -0
- trunk/admin/assets/nginx.js +26 -0
- trunk/admin/assets/rtp-social-icons-32-32.png +0 -0
- trunk/admin/assets/style.css +21 -0
- trunk/admin/install.php +98 -0
- trunk/admin/lib/nginx-general.php +373 -0
- trunk/admin/lib/nginx-sidebar.php +58 -0
- trunk/admin/lib/nginx-support.php +29 -0
- trunk/compatibility.php +37 -0
- trunk/languages/nginx-helper.mo +0 -0
- trunk/languages/nginx-helper.po +501 -0
- trunk/nginx-helper.php +400 -0
- trunk/purger.php +781 -0
- trunk/readme.txt +282 -0
- trunk/wercker.yml +22 -0
- trunk/wp-cli.php +37 -0
admin/lib/nginx-general.php
CHANGED
@@ -48,6 +48,8 @@ namespace rtCamp\WP\Nginx {
|
|
48 |
$rt_wp_nginx_helper->options['purge_page_on_mod'] = ( isset( $_POST['purge_page_on_mod'] ) and ( $_POST['purge_page_on_mod'] == 1 ) ) ? 1 : 0;
|
49 |
$rt_wp_nginx_helper->options['purge_page_on_new_comment'] = ( isset( $_POST['purge_page_on_new_comment'] ) and ( $_POST['purge_page_on_new_comment'] == 1 ) ) ? 1 : 0;
|
50 |
$rt_wp_nginx_helper->options['purge_page_on_deleted_comment'] = ( isset( $_POST['purge_page_on_deleted_comment'] ) and ( $_POST['purge_page_on_deleted_comment'] == 1 ) ) ? 1 : 0;
|
|
|
|
|
51 |
}
|
52 |
update_site_option( 'rt_wp_nginx_helper_options', $rt_wp_nginx_helper->options );
|
53 |
$update = 1;
|
@@ -248,6 +250,31 @@ namespace rtCamp\WP\Nginx {
|
|
248 |
</td>
|
249 |
</tr>
|
250 |
</table>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
</div> <!-- End of .inside -->
|
252 |
</div><?php
|
253 |
} // End of if ( !( !is_network_admin() && is_multisite() ) )
|
48 |
$rt_wp_nginx_helper->options['purge_page_on_mod'] = ( isset( $_POST['purge_page_on_mod'] ) and ( $_POST['purge_page_on_mod'] == 1 ) ) ? 1 : 0;
|
49 |
$rt_wp_nginx_helper->options['purge_page_on_new_comment'] = ( isset( $_POST['purge_page_on_new_comment'] ) and ( $_POST['purge_page_on_new_comment'] == 1 ) ) ? 1 : 0;
|
50 |
$rt_wp_nginx_helper->options['purge_page_on_deleted_comment'] = ( isset( $_POST['purge_page_on_deleted_comment'] ) and ( $_POST['purge_page_on_deleted_comment'] == 1 ) ) ? 1 : 0;
|
51 |
+
|
52 |
+
$rt_wp_nginx_helper->options['purge_method'] = ( isset( $_POST['purge_method'] ) ) ? $_POST['purge_method'] : 'get_request';
|
53 |
}
|
54 |
update_site_option( 'rt_wp_nginx_helper_options', $rt_wp_nginx_helper->options );
|
55 |
$update = 1;
|
250 |
</td>
|
251 |
</tr>
|
252 |
</table>
|
253 |
+
<table class="form-table rtnginx-table">
|
254 |
+
<tr valign="top">
|
255 |
+
<th scope="row">
|
256 |
+
<h4><?php _e('Purge Method:', 'nginx-helper'); ?></h4>
|
257 |
+
</th>
|
258 |
+
<td>
|
259 |
+
<fieldset>
|
260 |
+
<legend class="screen-reader-text">
|
261 |
+
<span> <?php _e('when a post/page/custom post is published.', 'nginx-helper'); ?></span>
|
262 |
+
</legend>
|
263 |
+
<label for="purge_method_get_request">
|
264 |
+
<input type="radio" value="get_request" id="purge_method_get_request" name="purge_method"<?php checked($rt_wp_nginx_helper->options['purge_method'], 'get_request'); ?>>
|
265 |
+
<?php _e('Using a GET request to <strong>PURGE/url</strong> (Default option)', 'nginx-helper'); ?><br />
|
266 |
+
<small><?php _e('Uses the <strong><a href="https://github.com/FRiCKLE/ngx_cache_purge">ngx_cache_purge</a></strong> module. ', 'nginx-helper'); ?></small>
|
267 |
+
</label><br />
|
268 |
+
<label for="purge_method_unlink_files">
|
269 |
+
<input type="radio" value="unlink_files" id="purge_method_unlink_files" name="purge_method"<?php checked($rt_wp_nginx_helper->options['purge_method'], 'unlink_files'); ?>>
|
270 |
+
<?php _e('Delete local server cache files', 'nginx-helper'); ?><br />
|
271 |
+
<small><?php _e('Checks for matching cache file in <strong>RT_WP_NGINX_HELPER_CACHE_PATH</strong>. Does not require any other modules. Requires that the cache be stored on the same server as WordPress. You must also be using the default nginx cache options (levels=1:2) and (fastcgi_cache_key "$scheme$request_method$host$request_uri"). ', 'nginx-helper'); ?></small>
|
272 |
+
|
273 |
+
</label><br />
|
274 |
+
</fieldset>
|
275 |
+
</td>
|
276 |
+
</tr>
|
277 |
+
</table>
|
278 |
</div> <!-- End of .inside -->
|
279 |
</div><?php
|
280 |
} // End of if ( !( !is_network_admin() && is_multisite() ) )
|
nginx-helper.php
CHANGED
@@ -3,12 +3,12 @@
|
|
3 |
Plugin Name: Nginx Helper
|
4 |
Plugin URI: http://rtcamp.com/nginx-helper/
|
5 |
Description: Cleans nginx's fastcgi/proxy cache whenever a post is edited/published. Also does few more things.
|
6 |
-
Version: 1.8.
|
7 |
Author: rtCamp
|
8 |
Author URI: http://rtcamp.com
|
9 |
Text Domain: nginx-helper
|
10 |
Requires at least: 3.0
|
11 |
-
Tested up to: 4.
|
12 |
*/
|
13 |
|
14 |
namespace rtCamp\WP\Nginx {
|
3 |
Plugin Name: Nginx Helper
|
4 |
Plugin URI: http://rtcamp.com/nginx-helper/
|
5 |
Description: Cleans nginx's fastcgi/proxy cache whenever a post is edited/published. Also does few more things.
|
6 |
+
Version: 1.8.8
|
7 |
Author: rtCamp
|
8 |
Author URI: http://rtcamp.com
|
9 |
Text Domain: nginx-helper
|
10 |
Requires at least: 3.0
|
11 |
+
Tested up to: 4.2
|
12 |
*/
|
13 |
|
14 |
namespace rtCamp\WP\Nginx {
|
purger.php
CHANGED
@@ -204,24 +204,97 @@ namespace rtCamp\WP\Nginx {
|
|
204 |
|
205 |
function purgeUrl( $url, $feed = true ) {
|
206 |
|
|
|
|
|
207 |
$this->log( "- Purging URL | " . $url );
|
208 |
|
209 |
$parse = parse_url( $url );
|
210 |
|
211 |
-
|
212 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
213 |
|
214 |
-
|
215 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
}
|
217 |
|
218 |
-
|
|
|
|
|
|
|
|
|
|
|
219 |
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
}
|
226 |
}
|
227 |
|
204 |
|
205 |
function purgeUrl( $url, $feed = true ) {
|
206 |
|
207 |
+
global $rt_wp_nginx_helper;
|
208 |
+
|
209 |
$this->log( "- Purging URL | " . $url );
|
210 |
|
211 |
$parse = parse_url( $url );
|
212 |
|
213 |
+
switch ($rt_wp_nginx_helper->options['purge_method']) {
|
214 |
+
case 'unlink_files':
|
215 |
+
$_url_purge_base = $parse[ 'scheme' ] . '://' . $parse[ 'host' ] . $parse[ 'path' ];
|
216 |
+
$_url_purge = $_url_purge_base;
|
217 |
+
|
218 |
+
if ( isset( $parse[ 'query' ] ) && $parse[ 'query' ] != '' ) {
|
219 |
+
$_url_purge .= '?' . $parse[ 'query' ];
|
220 |
+
}
|
221 |
+
|
222 |
+
$this->_delete_cache_file_for( $_url_purge );
|
223 |
+
|
224 |
+
if ( $feed ) {
|
225 |
+
$feed_url = rtrim( $_url_purge_base, '/' ) . '/feed/';
|
226 |
+
$this->_delete_cache_file_for( $feed_url );
|
227 |
+
$this->_delete_cache_file_for( $feed_url . 'atom/' );
|
228 |
+
$this->_delete_cache_file_for( $feed_url . 'rdf/' );
|
229 |
+
}
|
230 |
+
break;
|
231 |
+
case 'get_request':
|
232 |
+
// Go to default case
|
233 |
+
default:
|
234 |
+
$_url_purge_base = $parse[ 'scheme' ] . '://' . $parse[ 'host' ] . '/purge' . $parse[ 'path' ];
|
235 |
+
$_url_purge = $_url_purge_base;
|
236 |
+
|
237 |
+
if ( isset( $parse[ 'query' ] ) && $parse[ 'query' ] != '' ) {
|
238 |
+
$_url_purge .= '?' . $parse[ 'query' ];
|
239 |
+
}
|
240 |
+
|
241 |
+
$this->_do_remote_get( $_url_purge );
|
242 |
+
|
243 |
+
if ( $feed ) {
|
244 |
+
$feed_url = rtrim( $_url_purge_base, '/' ) . '/feed/';
|
245 |
+
$this->_do_remote_get( $feed_url );
|
246 |
+
$this->_do_remote_get( $feed_url . 'atom/' );
|
247 |
+
$this->_do_remote_get( $feed_url . 'rdf/' );
|
248 |
+
}
|
249 |
+
break;
|
250 |
+
}
|
251 |
|
252 |
+
}
|
253 |
+
|
254 |
+
/*********************
|
255 |
+
* Deletes local cache files without a 3rd party nginx module.
|
256 |
+
*
|
257 |
+
* Does not require any other modules. Requires that the cache be stored on the same server as WordPress. You must also be using the default nginx cache options (levels=1:2) and (fastcgi_cache_key "$scheme$request_method$host$request_uri").
|
258 |
+
*
|
259 |
+
* Read more on how this works here:
|
260 |
+
* https://www.digitalocean.com/community/tutorials/how-to-setup-fastcgi-caching-with-nginx-on-your-vps#purging-the-cache
|
261 |
+
**********************/
|
262 |
+
private function _delete_cache_file_for( $url ) {
|
263 |
+
|
264 |
+
// Verify cache path is set
|
265 |
+
if (!defined('RT_WP_NGINX_HELPER_CACHE_PATH')) {
|
266 |
+
$this->log('Error purging because RT_WP_NGINX_HELPER_CACHE_PATH was not defined. URL: '.$url, 'ERROR');
|
267 |
+
return false;
|
268 |
}
|
269 |
|
270 |
+
// Verify URL is valid
|
271 |
+
$url_data = parse_url($url);
|
272 |
+
if(!$url_data) {
|
273 |
+
$this->log('Error purging because specified URL did not appear to be valid. URL: '.$url, 'ERROR');
|
274 |
+
return false;
|
275 |
+
}
|
276 |
|
277 |
+
// Build a hash of the URL
|
278 |
+
$hash = md5($url_data['scheme'].'GET'.$url_data['host'].$url_data['path']);
|
279 |
+
|
280 |
+
// Ensure trailing slash
|
281 |
+
$cache_path = RT_WP_NGINX_HELPER_CACHE_PATH;
|
282 |
+
$cache_path = (substr($cache_path, -1) == '/') ? $cache_path : $cache_path.'/';
|
283 |
+
|
284 |
+
// Set path to cached file
|
285 |
+
$cached_file = $cache_path . substr($hash, -1) . '/' . substr($hash,-3,2) . '/' . $hash;
|
286 |
+
|
287 |
+
// Verify cached file exists
|
288 |
+
if (!file_exists($cached_file)) {
|
289 |
+
$this->log( "- - " . $url . " is currently not cached (checked for file: $cached_file)" );
|
290 |
+
return false;
|
291 |
+
}
|
292 |
+
|
293 |
+
// Delete the cached file
|
294 |
+
if (unlink($cached_file)) {
|
295 |
+
$this->log( "- - " . $url . " *** PURGED ***" );
|
296 |
+
} else {
|
297 |
+
$this->log("- - An error occurred deleting the cache file. Check the server logs for a PHP warning.", "ERROR");
|
298 |
}
|
299 |
}
|
300 |
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: rtcamp, rahul286, saurabhshukla, manishsongirkar36, faishal, desaiuditd, Darren Slatten, jk3us, daankortenbach, telofy, pjv, llonchj, jinnko,weskoop
|
3 |
Tags: nginx, cache, purge, nginx map, nginx cache, maps, fastcgi, proxy, rewrite, permalinks
|
4 |
Requires at least: 3.0
|
5 |
-
Tested up to: 4.
|
6 |
-
Stable tag: 1.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/
|
@@ -114,6 +114,9 @@ Please post your problem in [our free support forum](http://community.rtcamp.com
|
|
114 |
|
115 |
== Changelog ==
|
116 |
|
|
|
|
|
|
|
117 |
= 1.8.7 =
|
118 |
* Added action `rt_nginx_helper_purge_all` to purge cache from other plugins - by [gungeekatx](https://profiles.wordpress.org/gungeekatx/)
|
119 |
|
@@ -273,7 +276,6 @@ Please post your problem in [our free support forum](http://community.rtcamp.com
|
|
273 |
|
274 |
* First release
|
275 |
|
276 |
-
|
277 |
== Upgrade Notice ==
|
278 |
|
279 |
= 1.8.4 =
|
2 |
Contributors: rtcamp, rahul286, saurabhshukla, manishsongirkar36, faishal, desaiuditd, Darren Slatten, jk3us, daankortenbach, telofy, pjv, llonchj, jinnko,weskoop
|
3 |
Tags: nginx, cache, purge, nginx map, nginx cache, maps, fastcgi, proxy, rewrite, permalinks
|
4 |
Requires at least: 3.0
|
5 |
+
Tested up to: 4.2
|
6 |
+
Stable tag: 1.8.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/
|
114 |
|
115 |
== Changelog ==
|
116 |
|
117 |
+
= 1.8.8 =
|
118 |
+
* Added option to purge cache without nginx purge module - by [bcole808](https://profiles.wordpress.org/bcole808/)
|
119 |
+
|
120 |
= 1.8.7 =
|
121 |
* Added action `rt_nginx_helper_purge_all` to purge cache from other plugins - by [gungeekatx](https://profiles.wordpress.org/gungeekatx/)
|
122 |
|
276 |
|
277 |
* First release
|
278 |
|
|
|
279 |
== Upgrade Notice ==
|
280 |
|
281 |
= 1.8.4 =
|
trunk/admin/admin.php
ADDED
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace rtCamp\WP\Nginx {
|
4 |
+
|
5 |
+
class Admin {
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Holds the values to be used in the fields callbacks
|
9 |
+
*/
|
10 |
+
private $nginx_helper_tabs;
|
11 |
+
|
12 |
+
function __construct() {
|
13 |
+
if ( is_multisite() ) {
|
14 |
+
add_action( 'network_admin_menu', array( &$this, 'add_network_menu' ) );
|
15 |
+
} else {
|
16 |
+
add_action( 'admin_menu', array( &$this, 'add_menu' ) );
|
17 |
+
}
|
18 |
+
|
19 |
+
add_action( 'admin_init', array( $this, 'nginx_admin_page_init' ) );
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Define Tabs
|
23 |
+
*/
|
24 |
+
$this->nginx_helper_tabs = apply_filters( 'rt_nginx_helper_tabs', array(
|
25 |
+
'general' => array(
|
26 |
+
'menu_title' => __( 'General', 'nginx-helper' ),
|
27 |
+
'menu_slug' => 'general'
|
28 |
+
),
|
29 |
+
'support' => array(
|
30 |
+
'menu_title' => __( 'Support', 'nginx-helper' ),
|
31 |
+
'menu_slug' => 'support'
|
32 |
+
) )
|
33 |
+
);
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Add setting sub-menu for single site
|
38 |
+
*/
|
39 |
+
function add_menu() {
|
40 |
+
add_submenu_page( 'options-general.php', __( 'Nginx Helper', 'nginx-helper' ), __( 'Nginx Helper', 'nginx-helper' ), 'manage_options', 'nginx', array( &$this, 'nginx_create_admin_page' ) );
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Add setting sub-menu for multi site
|
45 |
+
*/
|
46 |
+
function add_network_menu() {
|
47 |
+
add_submenu_page( 'settings.php', __( 'Nginx Helper', 'nginx-helper' ), __( 'Nginx Helper', 'nginx-helper' ), 'manage_options', 'nginx', array( &$this, 'nginx_create_admin_page' ) );
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Create tab with links
|
52 |
+
*
|
53 |
+
* @param type $current current tab
|
54 |
+
*/
|
55 |
+
function nginx_admin_page_tabs( $current = 'general' ) {
|
56 |
+
echo '<h2 class="nav-tab-wrapper">';
|
57 |
+
foreach ( $this->nginx_helper_tabs as $tab => $name ) {
|
58 |
+
$class = ( $tab == $current ) ? ' nav-tab-active' : '';
|
59 |
+
echo '<a class="nav-tab' . $class . '" href="?page=nginx&tab=' . $name['menu_slug'] . '">' . $name['menu_title'] . '</a>';
|
60 |
+
}
|
61 |
+
echo '</h2>';
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Options page callback
|
66 |
+
*/
|
67 |
+
function nginx_create_admin_page() {
|
68 |
+
global $pagenow;
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Includes PHP files located in 'admin/lib/' folder
|
72 |
+
*/
|
73 |
+
foreach (glob(plugin_dir_path(__FILE__) . "lib/*.php") as $lib_filename) {
|
74 |
+
require_once( $lib_filename );
|
75 |
+
} ?>
|
76 |
+
|
77 |
+
<div class="wrap rt-nginx-wrapper">
|
78 |
+
<h2 class="rt_option_title"><?php _e( 'Nginx Settings', 'nginx-helper' ); ?></h2>
|
79 |
+
<div id="poststuff">
|
80 |
+
<div id="post-body" class="metabox-holder columns-2">
|
81 |
+
<div id="post-body-content"><?php
|
82 |
+
|
83 |
+
/* Show Tabs */
|
84 |
+
if ( ( 'options-general.php' == $pagenow || 'settings.php' == $pagenow ) && isset( $_GET['tab'] ) ) {
|
85 |
+
$this->nginx_admin_page_tabs( $_GET['tab'] );
|
86 |
+
} else {
|
87 |
+
$this->nginx_admin_page_tabs( 'general' );
|
88 |
+
}
|
89 |
+
|
90 |
+
/* Fetch Page Content */
|
91 |
+
$current = isset( $_GET['tab'] ) ? $_GET['tab'] : 'general';
|
92 |
+
if ( ( 'options-general.php' == $pagenow || 'settings.php' == $pagenow ) && isset( $_GET['page'] ) ) {
|
93 |
+
switch ( $current ) {
|
94 |
+
case 'general' :
|
95 |
+
nginx_general_options_page();
|
96 |
+
break;
|
97 |
+
case 'support' :
|
98 |
+
nginx_support_options_page();
|
99 |
+
break;
|
100 |
+
}
|
101 |
+
} ?>
|
102 |
+
</div> <!-- End of #post-body-content -->
|
103 |
+
<div id="postbox-container-1" class="postbox-container"><?php
|
104 |
+
default_admin_sidebar(); ?>
|
105 |
+
</div> <!-- End of #postbox-container-1 -->
|
106 |
+
</div> <!-- End of #post-body -->
|
107 |
+
</div> <!-- End of #poststuff -->
|
108 |
+
</div> <!-- End of .wrap .rt-nginx-wrapper -->
|
109 |
+
<?php
|
110 |
+
}
|
111 |
+
|
112 |
+
function nginx_admin_page_init() {
|
113 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'nginx_admin_enqueue_assets' ), 999 );
|
114 |
+
add_action( 'admin_bar_menu', array( &$this, 'nginx_toolbar_purge_item' ), 100 );
|
115 |
+
}
|
116 |
+
|
117 |
+
function nginx_toolbar_purge_item( $admin_bar ) {
|
118 |
+
if ( !current_user_can( 'manage_options' ) ) {
|
119 |
+
return;
|
120 |
+
}
|
121 |
+
$purge_url = add_query_arg( array( 'nginx_helper_action' => 'purge', 'nginx_helper_urls' => 'all' ) );
|
122 |
+
$nonced_url = wp_nonce_url( $purge_url, 'nginx_helper-purge_all' );
|
123 |
+
$admin_bar->add_menu( array( 'id' => 'nginx-helper-purge-all', 'title' => __( 'Purge Cache', 'nginx-helper' ), 'href' => $nonced_url, 'meta' => array( 'title' => __( 'Purge Cache', 'nginx-helper' ), ), ) );
|
124 |
+
}
|
125 |
+
|
126 |
+
function nginx_admin_enqueue_assets($hook) {
|
127 |
+
if ( 'settings_page_nginx' != $hook ) {
|
128 |
+
return;
|
129 |
+
}
|
130 |
+
|
131 |
+
/* Load Plugin CSS */
|
132 |
+
wp_enqueue_style('rt-nginx-admin-icon', plugin_dir_url(__FILE__) . 'assets/nginx-helper-icons/css/nginx-fontello.css');
|
133 |
+
wp_enqueue_style('rt-nginx-admin-css', plugin_dir_url(__FILE__) . 'assets/style.css');
|
134 |
+
|
135 |
+
/* Load Plugin Scripts */
|
136 |
+
$admin_js = trailingslashit( site_url() ) . '?get_feeds=1';
|
137 |
+
wp_enqueue_script( 'nginx-js', plugin_dir_url( __FILE__ ) . 'assets/nginx.js', '', '', true );
|
138 |
+
wp_localize_script( 'nginx-js', 'news_url', $admin_js );
|
139 |
+
}
|
140 |
+
}
|
141 |
+
}
|
trunk/admin/assets/logo.png
ADDED
Binary file
|
trunk/admin/assets/nginx-helper-icons/config.json
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "nginx-fontello",
|
3 |
+
"css_prefix_text": "nginx-helper-",
|
4 |
+
"css_use_suffix": false,
|
5 |
+
"hinting": true,
|
6 |
+
"units_per_em": 1000,
|
7 |
+
"ascent": 850,
|
8 |
+
"glyphs": [
|
9 |
+
{
|
10 |
+
"uid": "72b1277834cba5b7944b0a6cac7ddb0d",
|
11 |
+
"css": "rss",
|
12 |
+
"code": 59395,
|
13 |
+
"src": "fontawesome"
|
14 |
+
},
|
15 |
+
{
|
16 |
+
"uid": "627abcdb627cb1789e009c08e2678ef9",
|
17 |
+
"css": "twitter",
|
18 |
+
"code": 59394,
|
19 |
+
"src": "fontawesome"
|
20 |
+
},
|
21 |
+
{
|
22 |
+
"uid": "bc50457410acf467b8b5721240768742",
|
23 |
+
"css": "facebook",
|
24 |
+
"code": 59393,
|
25 |
+
"src": "entypo"
|
26 |
+
},
|
27 |
+
{
|
28 |
+
"uid": "b945f4ac2439565661e8e4878e35d379",
|
29 |
+
"css": "gplus",
|
30 |
+
"code": 59392,
|
31 |
+
"src": "entypo"
|
32 |
+
}
|
33 |
+
]
|
34 |
+
}
|
trunk/admin/assets/nginx-helper-icons/css/nginx-fontello.css
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
@font-face {
|
2 |
+
font-family: 'nginx-fontello';
|
3 |
+
src: url('../font/nginx-fontello.eot?7388141');
|
4 |
+
src: url('../font/nginx-fontello.eot?7388141#iefix') format('embedded-opentype'),
|
5 |
+
url('../font/nginx-fontello.woff?7388141') format('woff'),
|
6 |
+
url('../font/nginx-fontello.ttf?7388141') format('truetype'),
|
7 |
+
url('../font/nginx-fontello.svg?7388141#nginx-fontello') format('svg');
|
8 |
+
font-weight: normal;
|
9 |
+
font-style: normal;
|
10 |
+
}
|
11 |
+
/* Chrome hack: SVG is rendered more smooth in Windozze. 100% magic, uncomment if you need it. */
|
12 |
+
/* Note, that will break hinting! In other OS-es font will be not as sharp as it could be */
|
13 |
+
/*
|
14 |
+
@media screen and (-webkit-min-device-pixel-ratio:0) {
|
15 |
+
@font-face {
|
16 |
+
font-family: 'nginx-fontello';
|
17 |
+
src: url('../font/nginx-fontello.svg?7388141#nginx-fontello') format('svg');
|
18 |
+
}
|
19 |
+
}
|
20 |
+
*/
|
21 |
+
|
22 |
+
[class^="nginx-helper-"]:before, [class*=" nginx-helper-"]:before {
|
23 |
+
font-family: "nginx-fontello";
|
24 |
+
font-style: normal;
|
25 |
+
font-weight: normal;
|
26 |
+
speak: none;
|
27 |
+
|
28 |
+
display: inline-block;
|
29 |
+
text-decoration: inherit;
|
30 |
+
width: 1em;
|
31 |
+
margin-right: .2em;
|
32 |
+
text-align: center;
|
33 |
+
/* opacity: .8; */
|
34 |
+
|
35 |
+
/* For safety - reset parent styles, that can break glyph codes*/
|
36 |
+
font-variant: normal;
|
37 |
+
text-transform: none;
|
38 |
+
|
39 |
+
/* fix buttons height, for twitter bootstrap */
|
40 |
+
line-height: 1em;
|
41 |
+
|
42 |
+
/* Animation center compensation - margins should be symmetric */
|
43 |
+
/* remove if not needed */
|
44 |
+
margin-left: .2em;
|
45 |
+
|
46 |
+
/* you can be more comfortable with increased icons size */
|
47 |
+
/* font-size: 120%; */
|
48 |
+
|
49 |
+
/* Uncomment for 3D effect */
|
50 |
+
/* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */
|
51 |
+
}
|
52 |
+
|
53 |
+
.nginx-helper-rss:before { content: '\e803'; } /* '' */
|
54 |
+
.nginx-helper-twitter:before { content: '\e802'; } /* '' */
|
55 |
+
.nginx-helper-facebook:before { content: '\e801'; } /* '' */
|
56 |
+
.nginx-helper-gplus:before { content: '\e800'; } /* '' */
|
trunk/admin/assets/nginx-helper-icons/font/nginx-fontello.eot
ADDED
Binary file
|
trunk/admin/assets/nginx-helper-icons/font/nginx-fontello.svg
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" standalone="no"?>
|
2 |
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
3 |
+
<svg xmlns="http://www.w3.org/2000/svg">
|
4 |
+
<metadata>Copyright (C) 2013 by original authors @ fontello.com</metadata>
|
5 |
+
<defs>
|
6 |
+
<font id="nginx-fontello" horiz-adv-x="1000" >
|
7 |
+
<font-face font-family="nginx-fontello" font-weight="400" font-stretch="normal" units-per-em="1000" ascent="850" descent="-150" />
|
8 |
+
<missing-glyph horiz-adv-x="1000" />
|
9 |
+
<glyph glyph-name="rss" unicode="" d="m214 100q0-45-31-76t-76-31t-76 31t-31 76t31 76t76 31t76-31t31-76z m286-69q1-15-9-26q-11-12-27-12h-75q-14 0-24 9t-11 23q-12 128-103 219t-219 103q-14 1-23 11t-9 24v75q0 16 12 26q9 10 24 10h3q89-7 170-45t145-101q63-63 101-145t45-171z m286-1q1-15-10-26q-10-11-26-11h-80q-14 0-25 10t-11 23q-6 120-56 228t-129 188t-188 129t-227 57q-14 0-24 11t-10 24v80q0 15 11 26q10 10 25 10h1q147-8 280-67t238-164q104-104 164-238t67-280z" horiz-adv-x="785.7" />
|
10 |
+
<glyph glyph-name="twitter" unicode="" d="m904 622q-37-54-90-93q0-8 0-23q0-73-21-145t-64-139t-103-117t-144-82t-181-30q-151 0-276 81q19-3 43-3q126 0 224 77q-59 2-105 36t-64 89q19-2 34-2q24 0 48 6q-63 13-104 62t-41 115v2q38-21 82-23q-37 25-59 64t-22 86q0 49 25 91q68-83 164-133t208-55q-5 21-5 41q0 75 53 127t127 53q79 0 132-57q61 12 114 44q-20-64-79-100q52 6 104 28z" horiz-adv-x="928.6" />
|
11 |
+
<glyph glyph-name="facebook" unicode="" d="m500 644l-142 0q-14 0-25-15t-11-37l0-102l178 0l0-148l-178 0l0-442l-170 0l0 442l-152 0l0 148l152 0l0 86q0 94 59 159t147 65l142 0l0-156z" horiz-adv-x="500" />
|
12 |
+
<glyph glyph-name="gplus" unicode="" d="m48 572q0 58 25 102t56 65t69 34t56 15t26 2l230 0l0-4q0-22-78-36q-28 0-38-6q40-20 54-56t14-96q0-102-68-158q-38-38-38-54q0-18 50-64q104-90 104-178q0-140-116-194q-68-34-150-34l-4 0l-4 2q-2-2-4-2q-24 0-54 5t-75 21t-74 57t-29 103q0 60 32 101t83 57t88 22t71 6l2 0q-16 22-24 47t-8 39l2 14l-14 0q-64 0-110 30q-74 44-74 160z m370-452q-4 52-43 84t-103 32l-16 0q-64-2-114-46q-46-42-42-94t53-80t119-24q68 4 109 40t37 88z m-60 500q-30 108-122 108q-12 0-20-2q-40-12-58-62q-16-50-2-106q14-52 47-85t71-33q12 0 18 2q42 12 63 65t3 113z m388-174l150 0l0-94l-150 0l0-150l-94 0l0 150l-150 0l0 94l150 0l0 150l94 0l0-150z" horiz-adv-x="896" />
|
13 |
+
</font>
|
14 |
+
</defs>
|
15 |
+
</svg>
|
trunk/admin/assets/nginx-helper-icons/font/nginx-fontello.ttf
ADDED
Binary file
|
trunk/admin/assets/nginx-helper-icons/font/nginx-fontello.woff
ADDED
Binary file
|
trunk/admin/assets/nginx-icon-32x32.png
ADDED
Binary file
|
trunk/admin/assets/nginx.js
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery(document).ready(function() {
|
2 |
+
var news_section = jQuery('#latest_news');
|
3 |
+
if (news_section.length > 0) {
|
4 |
+
jQuery.get(news_url, function(data) {
|
5 |
+
news_section.find('.inside').html(data);
|
6 |
+
});
|
7 |
+
}
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Show OR Hide options on option checkbox
|
11 |
+
* @param {type} selector Selector of Checkbox and PostBox
|
12 |
+
*/
|
13 |
+
function nginx_show_option( selector ) {
|
14 |
+
jQuery( '#'+selector ).on( 'change', function (){
|
15 |
+
if ( jQuery(this).is( ':checked' ) ) {
|
16 |
+
jQuery( '.'+selector ).show();
|
17 |
+
} else {
|
18 |
+
jQuery( '.'+selector ).hide();
|
19 |
+
}
|
20 |
+
} );
|
21 |
+
}
|
22 |
+
/* Function call with parameter */
|
23 |
+
nginx_show_option( 'enable_purge' );
|
24 |
+
nginx_show_option( 'enable_map' );
|
25 |
+
nginx_show_option( 'enable_log' );
|
26 |
+
});
|
trunk/admin/assets/rtp-social-icons-32-32.png
ADDED
Binary file
|
trunk/admin/assets/style.css
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.clearfix { *zoom: 1; }
|
2 |
+
.clearfix:before, .clearfix:after { content: " "; display: table; }
|
3 |
+
.clearfix:after { clear: both; }
|
4 |
+
h4 { margin: 0; }
|
5 |
+
.form-table th, .form-wrap label { vertical-align: middle; }
|
6 |
+
table.rtnginx-table { border-bottom: 1px solid #EEE; }
|
7 |
+
table.rtnginx-table:last-child { border-bottom: 0; }
|
8 |
+
.rtnginx-table p.error { color: red; }
|
9 |
+
pre#map { background: #e5e5e5 none; border-radius: 10px; padding: 10px; }
|
10 |
+
.wrap h2.rt_option_title { background: url(nginx-icon-32x32.png) 0 6px no-repeat rgba(0, 0, 0, 0); padding-left: 40px; }
|
11 |
+
#poststuff h2 { padding: 0 0 0 10px; margin-top: 0; }
|
12 |
+
form#purgeall .button-primary { box-shadow: inset 0 -2px rgba(0, 0, 0, 0.14);padding: 15px 30px;font-size: 1rem;border: 0;border-radius: 5px;color: #FFF;background: #DD3D36; height: auto; }
|
13 |
+
form#purgeall .button-primary:hover, form#purgeall .button-primary:focus { background: #d52c24; }
|
14 |
+
.nh-aligncenter { display: block; text-align: center; line-height: 2; }
|
15 |
+
#latest_news .inside ul, #useful-links .inside ul { margin: 0 0 0 12px }
|
16 |
+
#latest_news .inside ul li, #useful-links .inside ul li { list-style: square; padding: 0 0 7px; }
|
17 |
+
#social .inside a { background-color: #666;color: #FFF;display: inline-block;height: 30px;font-size: 1.25rem;line-height: 30px;margin: 10px 20px 0 0;overflow: hidden;padding: 0;text-align: center;text-decoration: none;width: 30px;-webkit-border-radius: 1000px;-moz-border-radius: 1000px;border-radius: 1000px; }
|
18 |
+
#social .inside .nginx-helper-rss:hover { background-color: #FAA33D; }
|
19 |
+
#social .inside .nginx-helper-facebook:hover { background-color: #537BBD; }
|
20 |
+
#social .inside .nginx-helper-twitter:hover { background-color: #40BFF5; }
|
21 |
+
#social .inside .nginx-helper-gplus:hover { background-color: #DD4B39; }
|
trunk/admin/install.php
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author: Saurabh Shukla <saurabh.shukla@rtcamp.com>
|
4 |
+
*
|
5 |
+
* Parts of code based off http://wordpress.org/extend/plugins/nginx-manager/ by http://profiles.wordpress.org/hpatoio/ and http://profiles.wordpress.org/rukbat/
|
6 |
+
*/
|
7 |
+
namespace rtCamp\WP\Nginx {
|
8 |
+
if ( preg_match( '#' . basename( __FILE__ ) . '#', $_SERVER[ 'PHP_SELF' ] ) ) {
|
9 |
+
die( 'You are not allowed to call this page directly.' );
|
10 |
+
}
|
11 |
+
|
12 |
+
function rt_wp_nginx_helper_install() {
|
13 |
+
global $wp_roles, $rt_wp_nginx_helper;
|
14 |
+
|
15 |
+
if ( ! current_user_can( 'activate_plugins' ) ) {
|
16 |
+
return;
|
17 |
+
}
|
18 |
+
|
19 |
+
$role = get_role( 'administrator' );
|
20 |
+
|
21 |
+
if ( empty( $role ) ) {
|
22 |
+
update_site_option( "rt_wp_nginx_helper_init_check", __( 'Sorry, you need to be an administrator to use Nginx Helper', 'nginx-helper' ) );
|
23 |
+
return;
|
24 |
+
}
|
25 |
+
|
26 |
+
$role->add_cap( 'Nginx Helper | Config' );
|
27 |
+
$role->add_cap( 'Nginx Helper | Purge cache' );
|
28 |
+
|
29 |
+
$rt_wp_nginx_helper_get_options = get_site_option( 'rt_wp_nginx_helper_global_options' );
|
30 |
+
|
31 |
+
if ( empty( $rt_wp_nginx_helper_get_options ) ) {
|
32 |
+
$rt_wp_nginx_helper_get_options = rt_wp_nginx_helper_get_options();
|
33 |
+
update_site_option( "rt_wp_nginx_helper_global_options", $rt_wp_nginx_helper_get_options );
|
34 |
+
}
|
35 |
+
|
36 |
+
if ( is_multisite() ) {
|
37 |
+
$blogs = get_blogs_of_user( true );
|
38 |
+
foreach ( $blogs as $b ) {
|
39 |
+
$rt_wp_nginx_helper_options = get_blog_option( $b->userblog_id, 'rt_wp_nginx_helper_options' );
|
40 |
+
if ( empty( $rt_wp_nginx_helper_options ) ) {
|
41 |
+
$rt_wp_nginx_helper_options = rt_wp_nginx_helper_get_options();
|
42 |
+
update_blog_option( $b->userblog_id, "rt_wp_nginx_helper_options", $rt_wp_nginx_helper_options );
|
43 |
+
}
|
44 |
+
}
|
45 |
+
} else {
|
46 |
+
$rt_wp_nginx_helper_options = get_option( 'rt_wp_nginx_helper_options' );
|
47 |
+
if ( empty( $rt_wp_nginx_helper_options ) ) {
|
48 |
+
$rt_wp_nginx_helper_options = rt_wp_nginx_helper_get_options();
|
49 |
+
update_option( "rt_wp_nginx_helper_options", $rt_wp_nginx_helper_options );
|
50 |
+
}
|
51 |
+
}
|
52 |
+
wp_schedule_event( time(), 'daily', 'rt_wp_nginx_helper_check_log_file_size_daily' );
|
53 |
+
}
|
54 |
+
|
55 |
+
function rt_wp_nginx_helper_uninstall() {
|
56 |
+
wp_clear_scheduled_hook( 'rt_wp_nginx_helper_check_log_file_size_daily' );
|
57 |
+
delete_site_option( 'rt_wp_nginx_helper_options' );
|
58 |
+
rt_wp_nginx_helper_remove_capability( 'Nginx Helper | Config' );
|
59 |
+
rt_wp_nginx_helper_remove_capability( 'Nginx Helper | Purge cache' );
|
60 |
+
}
|
61 |
+
|
62 |
+
function rt_wp_nginx_helper_remove_capability( $capability ) {
|
63 |
+
$check_order = array( "subscriber", "contributor", "author", "editor", "administrator" );
|
64 |
+
|
65 |
+
foreach ( $check_order as $role ) {
|
66 |
+
$role = get_role( $role );
|
67 |
+
$role->remove_cap( $capability );
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
function rt_wp_nginx_helper_get_options() {
|
72 |
+
$rt_wp_nginx_helper_get_options = array( );
|
73 |
+
$rt_wp_nginx_helper_get_options[ 'log_level' ] = 'INFO';
|
74 |
+
$rt_wp_nginx_helper_get_options[ 'log_filesize' ] = 5;
|
75 |
+
|
76 |
+
$rt_wp_nginx_helper_get_options[ 'enable_purge' ] = 0;
|
77 |
+
$rt_wp_nginx_helper_get_options[ 'enable_map' ] = 0;
|
78 |
+
$rt_wp_nginx_helper_get_options[ 'enable_log' ] = 0;
|
79 |
+
$rt_wp_nginx_helper_get_options[ 'enable_stamp' ] = 0;
|
80 |
+
|
81 |
+
$rt_wp_nginx_helper_get_options[ 'purge_homepage_on_new' ] = 1;
|
82 |
+
$rt_wp_nginx_helper_get_options[ 'purge_homepage_on_edit' ] = 1;
|
83 |
+
$rt_wp_nginx_helper_get_options[ 'purge_homepage_on_del' ] = 1;
|
84 |
+
|
85 |
+
$rt_wp_nginx_helper_get_options[ 'purge_archive_on_new' ] = 1;
|
86 |
+
$rt_wp_nginx_helper_get_options[ 'purge_archive_on_edit' ] = 1;
|
87 |
+
$rt_wp_nginx_helper_get_options[ 'purge_archive_on_del' ] = 1;
|
88 |
+
|
89 |
+
$rt_wp_nginx_helper_get_options[ 'purge_archive_on_new_comment' ] = 0;
|
90 |
+
$rt_wp_nginx_helper_get_options[ 'purge_archive_on_deleted_comment' ] = 0;
|
91 |
+
|
92 |
+
$rt_wp_nginx_helper_get_options[ 'purge_page_on_mod' ] = 1;
|
93 |
+
$rt_wp_nginx_helper_get_options[ 'purge_page_on_new_comment' ] = 1;
|
94 |
+
$rt_wp_nginx_helper_get_options[ 'purge_page_on_deleted_comment' ] = 1;
|
95 |
+
|
96 |
+
return $rt_wp_nginx_helper_get_options;
|
97 |
+
}
|
98 |
+
}
|
trunk/admin/lib/nginx-general.php
ADDED
@@ -0,0 +1,373 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace rtCamp\WP\Nginx {
|
4 |
+
|
5 |
+
function nginx_general_options_page() {
|
6 |
+
global $rt_wp_nginx_helper, $rt_wp_nginx_purger;
|
7 |
+
|
8 |
+
$update = 0;
|
9 |
+
$error_time = false;
|
10 |
+
$error_log_filesize = false;
|
11 |
+
$rt_wp_nginx_helper->options['enable_purge'] = (isset($_POST['enable_purge']) and ($_POST['enable_purge'] == 1) ) ? 1 : 0;
|
12 |
+
$rt_wp_nginx_helper->options['enable_map'] = (isset($_POST['enable_map']) and ($_POST['enable_map'] == 1) ) ? 1 : 0;
|
13 |
+
$rt_wp_nginx_helper->options['enable_log'] = (isset($_POST['enable_log']) and ($_POST['enable_log'] == 1) ) ? 1 : 0;
|
14 |
+
$rt_wp_nginx_helper->options['enable_stamp'] = (isset($_POST['enable_stamp']) and ($_POST['enable_stamp'] == 1) ) ? 1 : 0;
|
15 |
+
|
16 |
+
if ( isset( $_POST['is_submit'] ) && ( $_POST['is_submit'] == 1 ) ) {
|
17 |
+
if ( !( !is_network_admin() && is_multisite() ) ) {
|
18 |
+
if ( $rt_wp_nginx_helper->options['enable_log'] ) {
|
19 |
+
if ( isset( $_POST['log_level'] ) && !empty( $_POST['log_level'] ) && $_POST['log_level'] != '' ) {
|
20 |
+
$rt_wp_nginx_helper->options['log_level'] = $_POST['log_level'];
|
21 |
+
} else {
|
22 |
+
$rt_wp_nginx_helper->options['log_level'] = 'INFO';
|
23 |
+
}
|
24 |
+
if ( isset( $_POST['log_filesize'] ) && !empty( $_POST['log_filesize'] ) && $_POST['log_filesize'] != '' ) {
|
25 |
+
if ( ( !is_numeric( $_POST['log_filesize'] ) ) || ( empty( $_POST['log_filesize'] ) ) ) {
|
26 |
+
$error_log_filesize = __( 'Log file size must be a number', 'nginx-helper' );
|
27 |
+
} else {
|
28 |
+
$rt_wp_nginx_helper->options['log_filesize'] = $_POST['log_filesize'];
|
29 |
+
}
|
30 |
+
} else {
|
31 |
+
$rt_wp_nginx_helper->options['log_filesize'] = 5;
|
32 |
+
}
|
33 |
+
}
|
34 |
+
if ( $rt_wp_nginx_helper->options['enable_map'] ) {
|
35 |
+
$rt_wp_nginx_helper->update_map();
|
36 |
+
}
|
37 |
+
}
|
38 |
+
if ( isset( $_POST['enable_purge'] ) ) {
|
39 |
+
$rt_wp_nginx_helper->options['purge_homepage_on_edit'] = ( isset($_POST['purge_homepage_on_edit'] ) and ( $_POST['purge_homepage_on_edit'] == 1 ) ) ? 1 : 0;
|
40 |
+
$rt_wp_nginx_helper->options['purge_homepage_on_del'] = ( isset($_POST['purge_homepage_on_del'] ) and ( $_POST['purge_homepage_on_del'] == 1 ) ) ? 1 : 0;
|
41 |
+
|
42 |
+
$rt_wp_nginx_helper->options['purge_archive_on_edit'] = ( isset($_POST['purge_archive_on_edit'] ) and ( $_POST['purge_archive_on_edit'] == 1 ) ) ? 1 : 0;
|
43 |
+
$rt_wp_nginx_helper->options['purge_archive_on_del'] = ( isset($_POST['purge_archive_on_del'] ) and ( $_POST['purge_archive_on_del'] == 1 ) ) ? 1 : 0;
|
44 |
+
|
45 |
+
$rt_wp_nginx_helper->options['purge_archive_on_new_comment'] = ( isset( $_POST['purge_archive_on_new_comment'] ) and ( $_POST['purge_archive_on_new_comment'] == 1 ) ) ? 1 : 0;
|
46 |
+
$rt_wp_nginx_helper->options['purge_archive_on_deleted_comment'] = ( isset( $_POST['purge_archive_on_deleted_comment'] ) and ( $_POST['purge_archive_on_deleted_comment'] == 1 ) ) ? 1 : 0;
|
47 |
+
|
48 |
+
$rt_wp_nginx_helper->options['purge_page_on_mod'] = ( isset( $_POST['purge_page_on_mod'] ) and ( $_POST['purge_page_on_mod'] == 1 ) ) ? 1 : 0;
|
49 |
+
$rt_wp_nginx_helper->options['purge_page_on_new_comment'] = ( isset( $_POST['purge_page_on_new_comment'] ) and ( $_POST['purge_page_on_new_comment'] == 1 ) ) ? 1 : 0;
|
50 |
+
$rt_wp_nginx_helper->options['purge_page_on_deleted_comment'] = ( isset( $_POST['purge_page_on_deleted_comment'] ) and ( $_POST['purge_page_on_deleted_comment'] == 1 ) ) ? 1 : 0;
|
51 |
+
|
52 |
+
$rt_wp_nginx_helper->options['purge_method'] = ( isset( $_POST['purge_method'] ) ) ? $_POST['purge_method'] : 'get_request';
|
53 |
+
}
|
54 |
+
update_site_option( 'rt_wp_nginx_helper_options', $rt_wp_nginx_helper->options );
|
55 |
+
$update = 1;
|
56 |
+
}
|
57 |
+
$rt_wp_nginx_helper->options = get_site_option( 'rt_wp_nginx_helper_options' );
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Show Update Message
|
61 |
+
*/
|
62 |
+
if ( isset( $_POST['smart_http_expire_save'] ) ) {
|
63 |
+
echo '<div class="updated"><p>' . __( 'Settings saved.', 'nginx-helper' ) . '</p></div>';
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Check for single multiple with subdomain OR multiple with subdirectory site
|
68 |
+
*/
|
69 |
+
$nginx_setting_link = '#';
|
70 |
+
if ( is_multisite() ) {
|
71 |
+
if ( SUBDOMAIN_INSTALL == false ) {
|
72 |
+
$nginx_setting_link = 'https://rtcamp.com/wordpress-nginx/tutorials/multisite/subdirectories/fastcgi-cache-with-purging/';
|
73 |
+
} else {
|
74 |
+
$nginx_setting_link = 'https://rtcamp.com/wordpress-nginx/tutorials/multisite/subdomains/fastcgi-cache-with-purging/';
|
75 |
+
}
|
76 |
+
} else {
|
77 |
+
$nginx_setting_link = 'https://rtcamp.com/wordpress-nginx/tutorials/single-site/fastcgi-cache-with-purging/';
|
78 |
+
} ?>
|
79 |
+
<div class="postbox">
|
80 |
+
<h3 class="hndle">
|
81 |
+
<span><?php _e( 'Purge Cache', 'nginx-helper' ); ?></span>
|
82 |
+
</h3>
|
83 |
+
<form id="purgeall" action="" method="post" class="clearfix">
|
84 |
+
<div class="inside">
|
85 |
+
<?php $purge_url = add_query_arg( array( 'nginx_helper_action' => 'purge', 'nginx_helper_urls' => 'all' ) ); ?>
|
86 |
+
<?php $nonced_url = wp_nonce_url( $purge_url, 'nginx_helper-purge_all' ); ?>
|
87 |
+
<table class="form-table">
|
88 |
+
<tr valign="top">
|
89 |
+
<th><?php _e( 'Purge All Cache', 'nginx-helper' ); ?></th>
|
90 |
+
<td>
|
91 |
+
<a href="<?php echo $nonced_url; ?>" class="button-primary"><?php _e( 'Purge Cache', 'nginx-helper' ); ?></a>
|
92 |
+
</td>
|
93 |
+
</tr>
|
94 |
+
</table>
|
95 |
+
</div>
|
96 |
+
</form>
|
97 |
+
</div> <!-- End of .postbox -->
|
98 |
+
<form id="post_form" method="post" action="#" name="smart_http_expire_form" class="clearfix">
|
99 |
+
<div class="postbox">
|
100 |
+
<h3 class="hndle">
|
101 |
+
<span><?php _e('Plugin Options', 'nginx-helper'); ?></span>
|
102 |
+
</h3>
|
103 |
+
<?php if ( !( !is_network_admin() && is_multisite() ) ) { ?>
|
104 |
+
<div class="inside">
|
105 |
+
<input type="hidden" name="is_submit" value="1" />
|
106 |
+
<table class="form-table">
|
107 |
+
<tr valign="top">
|
108 |
+
<td>
|
109 |
+
<input type="checkbox" value="1" id="enable_purge" name="enable_purge" <?php checked($rt_wp_nginx_helper->options['enable_purge'], 1); ?> />
|
110 |
+
<label for="enable_purge">
|
111 |
+
<?php printf( __( 'Enable Cache Purge (<a target="_blank" href="%s" title="External settings for nginx">requires external settings for nginx</a>)', 'nginx-helper' ), $nginx_setting_link ); ?>
|
112 |
+
</label>
|
113 |
+
</td>
|
114 |
+
</tr>
|
115 |
+
<?php if ( is_network_admin() ) { ?>
|
116 |
+
<tr valign="top">
|
117 |
+
<td>
|
118 |
+
<input type="checkbox" value="1" id="enable_map" name="enable_map"<?php checked($rt_wp_nginx_helper->options['enable_map'], 1); ?> />
|
119 |
+
<label for="enable_map"><?php _e('Enable Nginx Map.', 'nginx-helper'); ?></label>
|
120 |
+
</td>
|
121 |
+
</tr>
|
122 |
+
<?php } ?>
|
123 |
+
<tr valign="top">
|
124 |
+
<td>
|
125 |
+
<input type="checkbox" value="1" id="enable_log" name="enable_log"<?php checked($rt_wp_nginx_helper->options['enable_log'], 1); ?> />
|
126 |
+
<label for="enable_log"><?php _e('Enable Logging', 'nginx-helper'); ?></label>
|
127 |
+
</td>
|
128 |
+
</tr>
|
129 |
+
<tr valign="top">
|
130 |
+
<td>
|
131 |
+
<input type="checkbox" value="1" id="enable_stamp" name="enable_stamp"<?php checked($rt_wp_nginx_helper->options['enable_stamp'], 1); ?> />
|
132 |
+
<label for="enable_stamp"><?php _e('Enable Nginx Timestamp in HTML', 'nginx-helper'); ?></label>
|
133 |
+
</td>
|
134 |
+
</tr>
|
135 |
+
</table>
|
136 |
+
</div> <!-- End of .inside -->
|
137 |
+
</div>
|
138 |
+
|
139 |
+
<div class="postbox enable_purge"<?php echo ( $rt_wp_nginx_helper->options['enable_purge'] == false ) ? ' style="display: none;"' : ''; ?>>
|
140 |
+
<h3 class="hndle">
|
141 |
+
<span><?php _e('Purging Options', 'nginx-helper'); ?></span>
|
142 |
+
</h3>
|
143 |
+
<div class="inside">
|
144 |
+
|
145 |
+
<table class="form-table rtnginx-table">
|
146 |
+
<tr valign="top">
|
147 |
+
<th scope="row"><h4><?php _e('Purge Homepage:', 'nginx-helper'); ?></h4></th>
|
148 |
+
<td>
|
149 |
+
<fieldset>
|
150 |
+
<legend class="screen-reader-text">
|
151 |
+
<span> <?php _e('when a post/page/custom post is modified or added.', 'nginx-helper'); ?></span>
|
152 |
+
</legend>
|
153 |
+
<label for="purge_homepage_on_edit">
|
154 |
+
<input type="checkbox" value="1" id="purge_homepage_on_edit" name="purge_homepage_on_edit"<?php checked($rt_wp_nginx_helper->options['purge_homepage_on_edit'], 1); ?> />
|
155 |
+
<?php _e('when a <strong>post</strong> (or page/custom post) is <strong>modified</strong> or <strong>added</strong>.', 'nginx-helper'); ?>
|
156 |
+
</label><br />
|
157 |
+
</fieldset>
|
158 |
+
<fieldset>
|
159 |
+
<legend class="screen-reader-text">
|
160 |
+
<span> <?php _e('when an existing post/page/custom post is modified.', 'nginx-helper'); ?></span>
|
161 |
+
</legend>
|
162 |
+
<label for="purge_homepage_on_del">
|
163 |
+
<input type="checkbox" value="1" id="purge_homepage_on_del" name="purge_homepage_on_del"<?php checked($rt_wp_nginx_helper->options['purge_homepage_on_del'], 1); ?> />
|
164 |
+
<?php _e('when a <strong>published post</strong> (or page/custom post) is <strong>trashed</strong>.', 'nginx-helper'); ?></label><br />
|
165 |
+
</fieldset>
|
166 |
+
</td>
|
167 |
+
</tr>
|
168 |
+
</table>
|
169 |
+
<table class="form-table rtnginx-table">
|
170 |
+
<tr valign="top">
|
171 |
+
<th scope="row">
|
172 |
+
<h4><?php _e('Purge Post/Page/Custom Post Type:', 'nginx-helper'); ?></h4>
|
173 |
+
</th>
|
174 |
+
<td>
|
175 |
+
<fieldset>
|
176 |
+
<legend class="screen-reader-text">
|
177 |
+
<span> <?php _e('when a post/page/custom post is published.', 'nginx-helper'); ?></span>
|
178 |
+
</legend>
|
179 |
+
<label for="purge_page_on_mod">
|
180 |
+
<input type="checkbox" value="1" id="purge_page_on_mod" name="purge_page_on_mod"<?php checked($rt_wp_nginx_helper->options['purge_page_on_mod'], 1); ?>>
|
181 |
+
<?php _e('when a <strong>post</strong> is <strong>published</strong>.', 'nginx-helper'); ?>
|
182 |
+
</label><br />
|
183 |
+
</fieldset>
|
184 |
+
<fieldset>
|
185 |
+
<legend class="screen-reader-text">
|
186 |
+
<span> <?php _e('when a comment is approved/published.', 'nginx-helper'); ?></span>
|
187 |
+
</legend>
|
188 |
+
<label for="purge_page_on_new_comment">
|
189 |
+
<input type="checkbox" value="1" id="purge_page_on_new_comment" name="purge_page_on_new_comment"<?php checked($rt_wp_nginx_helper->options['purge_page_on_new_comment'], 1); ?>>
|
190 |
+
<?php _e('when a <strong>comment</strong> is <strong>approved/published</strong>.', 'nginx-helper'); ?>
|
191 |
+
</label><br />
|
192 |
+
</fieldset>
|
193 |
+
<fieldset>
|
194 |
+
<legend class="screen-reader-text">
|
195 |
+
<span> <?php _e('when a comment is unapproved/deleted.', 'nginx-helper'); ?></span>
|
196 |
+
</legend>
|
197 |
+
<label for="purge_page_on_deleted_comment">
|
198 |
+
<input type="checkbox" value="1" id="purge_page_on_deleted_comment" name="purge_page_on_deleted_comment"<?php checked($rt_wp_nginx_helper->options['purge_page_on_deleted_comment'], 1); ?>>
|
199 |
+
<?php _e('when a <strong>comment</strong> is <strong>unapproved/deleted</strong>.', 'nginx-helper'); ?>
|
200 |
+
</label><br />
|
201 |
+
</fieldset>
|
202 |
+
</td>
|
203 |
+
</tr>
|
204 |
+
</table>
|
205 |
+
<table class="form-table rtnginx-table">
|
206 |
+
<tr valign="top">
|
207 |
+
<th scope="row">
|
208 |
+
<h4><?php _e('Purge Archives:', 'nginx-helper'); ?></h4>
|
209 |
+
<small><?php _e('(date, category, tag, author, custom taxonomies)', 'nginx-helper'); ?></small>
|
210 |
+
</th>
|
211 |
+
<td>
|
212 |
+
<fieldset>
|
213 |
+
<legend class="screen-reader-text">
|
214 |
+
<span> <?php _e('when an post/page/custom post is modified or added.</span>', 'nginx-helper'); ?>
|
215 |
+
</legend>
|
216 |
+
<label for="purge_archive_on_edit">
|
217 |
+
<input type="checkbox" value="1" id="purge_archive_on_edit" name="purge_archive_on_edit"<?php checked($rt_wp_nginx_helper->options['purge_archive_on_edit'], 1); ?> />
|
218 |
+
<?php _e('when a <strong>post</strong> (or page/custom post) is <strong>modified</strong> or <strong>added</strong>.', 'nginx-helper'); ?>
|
219 |
+
</label><br />
|
220 |
+
</fieldset>
|
221 |
+
<fieldset>
|
222 |
+
<legend class="screen-reader-text">
|
223 |
+
<span> <?php _e('when an existing post/page/custom post is trashed.</span>', 'nginx-helper'); ?>
|
224 |
+
</legend>
|
225 |
+
<label for="purge_archive_on_del">
|
226 |
+
<input type="checkbox" value="1" id="purge_archive_on_del" name="purge_archive_on_del"<?php checked($rt_wp_nginx_helper->options['purge_archive_on_del'], 1); ?> />
|
227 |
+
<?php _e('when a <strong>published post</strong> (or page/custom post) is <strong>trashed</strong>.', 'nginx-helper'); ?>
|
228 |
+
</label><br />
|
229 |
+
</fieldset>
|
230 |
+
<br />
|
231 |
+
<fieldset>
|
232 |
+
<legend class="screen-reader-text">
|
233 |
+
<span> <?php _e('when a comment is approved/published.</span>', 'nginx-helper'); ?>
|
234 |
+
</legend>
|
235 |
+
<label for="purge_archive_on_new_comment">
|
236 |
+
<input type="checkbox" value="1" id="purge_archive_on_new_comment" name="purge_archive_on_new_comment"<?php checked($rt_wp_nginx_helper->options['purge_archive_on_new_comment'], 1); ?> />
|
237 |
+
<?php _e('when a <strong>comment</strong> is <strong>approved/published</strong>.', 'nginx-helper'); ?>
|
238 |
+
</label><br />
|
239 |
+
</fieldset>
|
240 |
+
<fieldset>
|
241 |
+
<legend class="screen-reader-text">
|
242 |
+
<span> <?php _e('when a comment is unapproved/deleted.</span>', 'nginx-helper'); ?>
|
243 |
+
</legend>
|
244 |
+
<label for="purge_archive_on_deleted_comment">
|
245 |
+
<input type="checkbox" value="1" id="purge_archive_on_deleted_comment" name="purge_archive_on_deleted_comment"<?php checked($rt_wp_nginx_helper->options['purge_archive_on_deleted_comment'], 1); ?> />
|
246 |
+
<?php _e('when a <strong>comment</strong> is <strong>unapproved/deleted</strong>.', 'nginx-helper'); ?>
|
247 |
+
</label><br />
|
248 |
+
</fieldset>
|
249 |
+
|
250 |
+
</td>
|
251 |
+
</tr>
|
252 |
+
</table>
|
253 |
+
<table class="form-table rtnginx-table">
|
254 |
+
<tr valign="top">
|
255 |
+
<th scope="row">
|
256 |
+
<h4><?php _e('Purge Method:', 'nginx-helper'); ?></h4>
|
257 |
+
</th>
|
258 |
+
<td>
|
259 |
+
<fieldset>
|
260 |
+
<legend class="screen-reader-text">
|
261 |
+
<span> <?php _e('when a post/page/custom post is published.', 'nginx-helper'); ?></span>
|
262 |
+
</legend>
|
263 |
+
<label for="purge_method_get_request">
|
264 |
+
<input type="radio" value="get_request" id="purge_method_get_request" name="purge_method"<?php checked(($rt_wp_nginx_helper->options['purge_method']) ? $rt_wp_nginx_helper->options['purge_method'] : 'get_request', 'get_request'); ?>>
|
265 |
+
<?php _e('Using a GET request to <strong>PURGE/url</strong> (Default option)', 'nginx-helper'); ?><br />
|
266 |
+
<small><?php _e('Uses the <strong><a href="https://github.com/FRiCKLE/ngx_cache_purge">ngx_cache_purge</a></strong> module. ', 'nginx-helper'); ?></small>
|
267 |
+
</label><br />
|
268 |
+
<label for="purge_method_unlink_files">
|
269 |
+
<input type="radio" value="unlink_files" id="purge_method_unlink_files" name="purge_method"<?php checked($rt_wp_nginx_helper->options['purge_method'], 'unlink_files'); ?>>
|
270 |
+
<?php _e('Delete local server cache files', 'nginx-helper'); ?><br />
|
271 |
+
<small><?php _e('Checks for matching cache file in <strong>RT_WP_NGINX_HELPER_CACHE_PATH</strong>. Does not require any other modules. Requires that the cache be stored on the same server as WordPress. You must also be using the default nginx cache options (levels=1:2) and (fastcgi_cache_key "$scheme$request_method$host$request_uri"). ', 'nginx-helper'); ?></small>
|
272 |
+
|
273 |
+
</label><br />
|
274 |
+
</fieldset>
|
275 |
+
</td>
|
276 |
+
</tr>
|
277 |
+
</table>
|
278 |
+
</div> <!-- End of .inside -->
|
279 |
+
</div><?php
|
280 |
+
} // End of if ( !( !is_network_admin() && is_multisite() ) )
|
281 |
+
|
282 |
+
|
283 |
+
if ( is_network_admin() ) { ?>
|
284 |
+
<div class="postbox enable_map"<?php echo ( $rt_wp_nginx_helper->options['enable_map'] == false ) ? ' style="display: none;"' : ''; ?>>
|
285 |
+
<h3 class="hndle">
|
286 |
+
<span><?php _e('Nginx Map', 'nginx-helper'); ?></span>
|
287 |
+
</h3>
|
288 |
+
<div class="inside"><?php
|
289 |
+
if ( !is_writable( $rt_wp_nginx_helper->functional_asset_path() . 'map.conf' ) ) { ?>
|
290 |
+
<span class="error fade" style="display: block"><p><?php printf(__('Can\'t write on map file.<br /><br />Check you have write permission on <strong>%s</strong>', 'nginx-helper'), $rt_wp_nginx_helper->functional_asset_path() . 'map.conf'); ?></p></span><?php
|
291 |
+
} ?>
|
292 |
+
|
293 |
+
<table class="form-table rtnginx-table">
|
294 |
+
<tr>
|
295 |
+
<th><?php _e('Nginx Map path to include in nginx settings<br /><small>(recommended)</small>', 'nginx-helper'); ?></th>
|
296 |
+
<td>
|
297 |
+
<pre><?php echo $rt_wp_nginx_helper->functional_asset_path() . 'map.conf'; ?></pre>
|
298 |
+
</td>
|
299 |
+
</tr>
|
300 |
+
<tr>
|
301 |
+
<th><?php _e('Or,<br />Text to manually copy and paste in nginx settings<br /><small>(if your network is small and new sites are not added frequently)</small>', 'nginx-helper'); ?></th>
|
302 |
+
<td>
|
303 |
+
<pre id="map"><?php echo $rt_wp_nginx_helper->get_map() ?></pre>
|
304 |
+
</td>
|
305 |
+
</tr>
|
306 |
+
</table>
|
307 |
+
</div> <!-- End of .inside -->
|
308 |
+
</div>
|
309 |
+
<?php } ?>
|
310 |
+
|
311 |
+
<div class="postbox enable_log"<?php echo ( $rt_wp_nginx_helper->options['enable_log'] == false ) ? ' style="display: none;"' : ''; ?>>
|
312 |
+
<h3 class="hndle">
|
313 |
+
<span><?php _e('Logging Options', 'nginx-helper'); ?></span>
|
314 |
+
</h3>
|
315 |
+
<div class="inside">
|
316 |
+
<?php
|
317 |
+
$path = $rt_wp_nginx_helper->functional_asset_path();
|
318 |
+
if (!is_dir($path)) {
|
319 |
+
mkdir($path);
|
320 |
+
}
|
321 |
+
if (!file_exists($path . 'nginx.log')) {
|
322 |
+
$log = fopen($path . 'nginx.log', 'w');
|
323 |
+
fclose($log);
|
324 |
+
}
|
325 |
+
if (is_writable($path . 'nginx.log')) {
|
326 |
+
$rt_wp_nginx_purger->log("+++++++++");
|
327 |
+
$rt_wp_nginx_purger->log("+Log Test");
|
328 |
+
$rt_wp_nginx_purger->log("+++++++++");
|
329 |
+
}
|
330 |
+
if (!is_writable($path . 'nginx.log')) { ?>
|
331 |
+
<span class="error fade" style="display : block"><p><?php printf(__('Can\'t write on log file.<br /><br />Check you have write permission on <strong>%s</strong>', 'nginx-helper'), $rt_wp_nginx_helper->functional_asset_path() . 'nginx.log'); ?></p></span><?php
|
332 |
+
} ?>
|
333 |
+
|
334 |
+
<table class="form-table rtnginx-table">
|
335 |
+
<tbody>
|
336 |
+
<tr>
|
337 |
+
<th><label for="rt_wp_nginx_helper_logs_path"><?php _e('Logs path', 'nginx-helper'); ?></label></th>
|
338 |
+
<td><pre><?php echo $rt_wp_nginx_helper->functional_asset_path(); ?>nginx.log</pre></td>
|
339 |
+
</tr>
|
340 |
+
<tr>
|
341 |
+
<th><label for="rt_wp_nginx_helper_logs_link"><?php _e('View Log', 'nginx-helper'); ?></label></th>
|
342 |
+
<td><a target="_blank" href="<?php echo $rt_wp_nginx_helper->functional_asset_url(); ?>nginx.log"><?php _e('Log', 'nginx-helper'); ?></a></td>
|
343 |
+
</tr>
|
344 |
+
<tr>
|
345 |
+
<th><label for="rt_wp_nginx_helper_log_level"><?php _e('Log level', 'nginx-helper'); ?></label></th>
|
346 |
+
<td>
|
347 |
+
<select name="log_level">
|
348 |
+
<option value="NONE"<?php selected($rt_wp_nginx_helper->options['log_level'], 'NONE'); ?>><?php _e('None', 'nginx-helper'); ?></option>
|
349 |
+
<option value="INFO"<?php selected($rt_wp_nginx_helper->options['log_level'], 'INFO'); ?>><?php _e('Info', 'nginx-helper'); ?></option>
|
350 |
+
<option value="WARNING"<?php selected($rt_wp_nginx_helper->options['log_level'], 'WARNING'); ?>><?php _e('Warning', 'nginx-helper'); ?></option>
|
351 |
+
<option value="ERROR"<?php selected($rt_wp_nginx_helper->options['log_level'], 'ERROR'); ?>><?php _e('Error', 'nginx-helper'); ?></option>
|
352 |
+
</select>
|
353 |
+
</td>
|
354 |
+
</tr>
|
355 |
+
<tr>
|
356 |
+
<th><label for="log_filesize"><?php _e('Max log file size', 'nginx-helper'); ?></label></th>
|
357 |
+
<td>
|
358 |
+
<input id="log_filesize" class="small-text" type="text" name="log_filesize" value="<?php echo $rt_wp_nginx_helper->options['log_filesize'] ?>" /> <?php _e( 'Mb', 'nginx-helper' );
|
359 |
+
if ( $error_log_filesize ) { ?>
|
360 |
+
<p class="error fade" style="display: block;"><?php echo $error_log_filesize; ?></p><?php
|
361 |
+
} ?>
|
362 |
+
</td>
|
363 |
+
</tr>
|
364 |
+
</tbody>
|
365 |
+
</table>
|
366 |
+
</div> <!-- End of .inside -->
|
367 |
+
</div><?php
|
368 |
+
|
369 |
+
submit_button( __( 'Save All Changes', 'nginx-helper' ), 'primary large', 'smart_http_expire_save', true ); ?>
|
370 |
+
</form><!-- End of #post_form --><?php
|
371 |
+
}
|
372 |
+
|
373 |
+
}
|
trunk/admin/lib/nginx-sidebar.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace rtCamp\WP\Nginx {
|
4 |
+
|
5 |
+
function default_admin_sidebar() { ?>
|
6 |
+
<div class="postbox" id="support">
|
7 |
+
<h3 class="hndle">
|
8 |
+
<span><?php _e( 'Need Help?', 'nginx-helper' ); ?></span>
|
9 |
+
</h3>
|
10 |
+
<div class="inside">
|
11 |
+
<p><?php printf( __( 'Please use our <a href="%s">free support forum</a>.', 'nginx-helper' ), 'http://rtcamp.com/support/forum/wordpress-nginx/' ); ?></p>
|
12 |
+
</div>
|
13 |
+
</div>
|
14 |
+
|
15 |
+
<div class="postbox" id="social">
|
16 |
+
<h3 class="hndle">
|
17 |
+
<span><?php _e( 'Getting Social is Good', 'nginx-helper' ); ?></span>
|
18 |
+
</h3>
|
19 |
+
<div style="text-align:center;" class="inside">
|
20 |
+
<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>
|
21 |
+
<a class="nginx-helper-twitter" title="<?php _e( 'Follow us on Twitter', 'nginx-helper' ); ?>" target="_blank" href="https://twitter.com/rtcamp/"></a>
|
22 |
+
<a class="nginx-helper-gplus" title="<?php _e( 'Add to Circle', 'nginx-helper' ); ?>" target="_blank" href="https://plus.google.com/110214156830549460974/posts"></a>
|
23 |
+
<a class="nginx-helper-rss" title="<?php _e( 'Subscribe to our feeds', 'nginx-helper' ); ?>" target="_blank" href="http://feeds.feedburner.com/rtcamp/"></a>
|
24 |
+
</div>
|
25 |
+
</div>
|
26 |
+
|
27 |
+
<div class="postbox" id="useful-links">
|
28 |
+
<h3 class="hndle">
|
29 |
+
<span><?php _e( 'Useful Links', 'nginx-helper' ); ?></span>
|
30 |
+
</h3>
|
31 |
+
<div class="inside">
|
32 |
+
<ul role="list">
|
33 |
+
<li role="listitem">
|
34 |
+
<a href="https://rtcamp.com/wordpress-nginx/" title="<?php _e( 'WordPress-Nginx Solutions', 'nginx-helper' ); ?>"><?php _e( 'WordPress-Nginx Solutions', 'nginx-helper' ); ?></a>
|
35 |
+
</li>
|
36 |
+
<li role="listitem">
|
37 |
+
<a href="https://rtcamp.com/services/wordPress-themes-design-development/" title="<?php _e( 'WordPress Theme Devleopment', 'nginx-helper' ); ?>"><?php _e( 'WordPress Theme Devleopment', 'nginx-helper' ); ?></a>
|
38 |
+
</li>
|
39 |
+
<li role="listitem">
|
40 |
+
<a href="http://rtcamp.com/services/wordpress-plugins/" title="<?php _e( 'WordPress Plugin Development', 'nginx-helper' ); ?>"><?php _e( 'WordPress Plugin Development', 'nginx-helper' ); ?></a>
|
41 |
+
</li>
|
42 |
+
<li role="listitem">
|
43 |
+
<a href="http://rtcamp.com/services/custom-wordpress-solutions/" title="<?php _e( 'WordPress Consultancy', 'nginx-helper' ); ?>"><?php _e( 'WordPress Consultancy', 'nginx-helper' ); ?></a>
|
44 |
+
</li>
|
45 |
+
<li role="listitem">
|
46 |
+
<a href="https://rtcamp.com/easyengine/" title="<?php _e( 'easyengine (ee)', 'nginx-helper' ); ?>"><?php _e( 'easyengine (ee)', 'nginx-helper' ); ?></a>
|
47 |
+
</li>
|
48 |
+
</ul>
|
49 |
+
</div>
|
50 |
+
</div>
|
51 |
+
|
52 |
+
<div class="postbox" id="latest_news">
|
53 |
+
<div title="<?php _e( 'Click to toggle', 'nginx-helper' ); ?>" class="handlediv"><br /></div>
|
54 |
+
<h3 class="hndle"><span><?php _e( 'Latest News', 'nginx-helper' ); ?></span></h3>
|
55 |
+
<div class="inside"><img src ="<?php echo admin_url(); ?>/images/wpspin_light.gif" /><?php _e( 'Loading...', 'nginx-helper' ); ?></div>
|
56 |
+
</div><?php
|
57 |
+
} // End of default_admin_sidebar()
|
58 |
+
}
|
trunk/admin/lib/nginx-support.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace rtCamp\WP\Nginx {
|
4 |
+
function nginx_support_options_page() { ?>
|
5 |
+
<form id="support" action="" method="post" class="clearfix">
|
6 |
+
<div class="postbox">
|
7 |
+
<h3 class="hndle">
|
8 |
+
<span><?php _e( 'Support Forums', 'nginx-helper' ); ?></span>
|
9 |
+
</h3>
|
10 |
+
<div class="inside">
|
11 |
+
<table class="form-table">
|
12 |
+
<tr valign="top">
|
13 |
+
<th><?php _e( 'Free Support', 'nginx-helper' ); ?></th>
|
14 |
+
<td>
|
15 |
+
<a href="https://rtcamp.com/support/forum/wordpress-nginx/" title="<?php _e( 'Free Support Forum', 'nginx-helper' ); ?>" target="_blank"><?php _e( 'Link to forum', 'nginx-helper' ); ?></a>
|
16 |
+
</td>
|
17 |
+
</tr>
|
18 |
+
<tr valign="top">
|
19 |
+
<th><?php _e( 'Premium Support', 'nginx-helper' ); ?></th>
|
20 |
+
<td>
|
21 |
+
<a href="https://rtcamp.com/wordpress-nginx/pricing/" title="<?php _e( 'Premium Support Forum', 'nginx-helper' ); ?>" target="_blank"><?php _e( 'Link to forum', 'nginx-helper' ); ?></a>
|
22 |
+
</td>
|
23 |
+
</tr>
|
24 |
+
</table>
|
25 |
+
</div>
|
26 |
+
</div>
|
27 |
+
</form><?php
|
28 |
+
}
|
29 |
+
}
|
trunk/compatibility.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
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 |
+
}
|
trunk/languages/nginx-helper.mo
ADDED
Binary file
|
trunk/languages/nginx-helper.po
ADDED
@@ -0,0 +1,501 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: Nginx Helper 1.7.6\n"
|
4 |
+
"Report-Msgid-Bugs-To: \n"
|
5 |
+
"POT-Creation-Date: 2014-01-02 17:41+0530\n"
|
6 |
+
"PO-Revision-Date: 2014-01-02 17:41+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.5.4\n"
|
17 |
+
"X-Poedit-SearchPath-0: ..\n"
|
18 |
+
|
19 |
+
#: ../nginx-helper.php:254
|
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:26
|
194 |
+
msgid "General"
|
195 |
+
msgstr ""
|
196 |
+
|
197 |
+
#: ../admin/admin.php:30
|
198 |
+
msgid "Support"
|
199 |
+
msgstr ""
|
200 |
+
|
201 |
+
#: ../admin/admin.php:40 ../admin/admin.php:47
|
202 |
+
msgid "Nginx Helper"
|
203 |
+
msgstr ""
|
204 |
+
|
205 |
+
#: ../admin/admin.php:78
|
206 |
+
msgid "Nginx Settings"
|
207 |
+
msgstr ""
|
208 |
+
|
209 |
+
#: ../admin/admin.php:123 ../admin/lib/nginx-general.php:79
|
210 |
+
#: ../admin/lib/nginx-general.php:89
|
211 |
+
msgid "Purge Cache"
|
212 |
+
msgstr ""
|
213 |
+
|
214 |
+
#: ../admin/install.php:22
|
215 |
+
msgid "Sorry, you need to be an administrator to use Nginx Helper"
|
216 |
+
msgstr ""
|
217 |
+
|
218 |
+
#: ../admin/lib/nginx-general.php:26
|
219 |
+
msgid "Log file size must be a number"
|
220 |
+
msgstr ""
|
221 |
+
|
222 |
+
#: ../admin/lib/nginx-general.php:61
|
223 |
+
msgid "Settings saved."
|
224 |
+
msgstr ""
|
225 |
+
|
226 |
+
#: ../admin/lib/nginx-general.php:87
|
227 |
+
msgid "Purge All Cache"
|
228 |
+
msgstr ""
|
229 |
+
|
230 |
+
#: ../admin/lib/nginx-general.php:99
|
231 |
+
msgid "Plugin Options"
|
232 |
+
msgstr ""
|
233 |
+
|
234 |
+
#: ../admin/lib/nginx-general.php:109
|
235 |
+
#, php-format
|
236 |
+
msgid ""
|
237 |
+
"Enable Cache Purge (<a target=\"_blank\" href=\"%s\" title=\"External "
|
238 |
+
"settings for nginx\">requires external settings for nginx</a>)"
|
239 |
+
msgstr ""
|
240 |
+
|
241 |
+
#: ../admin/lib/nginx-general.php:117
|
242 |
+
msgid "Enable Nginx Map."
|
243 |
+
msgstr ""
|
244 |
+
|
245 |
+
#: ../admin/lib/nginx-general.php:124
|
246 |
+
msgid "Enable Logging"
|
247 |
+
msgstr ""
|
248 |
+
|
249 |
+
#: ../admin/lib/nginx-general.php:130
|
250 |
+
msgid "Enable Nginx Timestamp in HTML"
|
251 |
+
msgstr ""
|
252 |
+
|
253 |
+
#: ../admin/lib/nginx-general.php:139
|
254 |
+
msgid "Purging Options"
|
255 |
+
msgstr ""
|
256 |
+
|
257 |
+
#: ../admin/lib/nginx-general.php:145
|
258 |
+
msgid "Purge Homepage:"
|
259 |
+
msgstr ""
|
260 |
+
|
261 |
+
#: ../admin/lib/nginx-general.php:149
|
262 |
+
msgid "when a post/page/custom post is modified or added."
|
263 |
+
msgstr ""
|
264 |
+
|
265 |
+
#: ../admin/lib/nginx-general.php:153 ../admin/lib/nginx-general.php:216
|
266 |
+
msgid ""
|
267 |
+
"when a <strong>post</strong> (or page/custom post) is <strong>modified</"
|
268 |
+
"strong> or <strong>added</strong>."
|
269 |
+
msgstr ""
|
270 |
+
|
271 |
+
#: ../admin/lib/nginx-general.php:158
|
272 |
+
msgid "when an existing post/page/custom post is modified."
|
273 |
+
msgstr ""
|
274 |
+
|
275 |
+
#: ../admin/lib/nginx-general.php:162 ../admin/lib/nginx-general.php:225
|
276 |
+
msgid ""
|
277 |
+
"when a <strong>published post</strong> (or page/custom post) is "
|
278 |
+
"<strong>trashed</strong>."
|
279 |
+
msgstr ""
|
280 |
+
|
281 |
+
#: ../admin/lib/nginx-general.php:170
|
282 |
+
msgid "Purge Post/Page/Custom Post Type:"
|
283 |
+
msgstr ""
|
284 |
+
|
285 |
+
#: ../admin/lib/nginx-general.php:175
|
286 |
+
msgid "when a post/page/custom post is published."
|
287 |
+
msgstr ""
|
288 |
+
|
289 |
+
#: ../admin/lib/nginx-general.php:179
|
290 |
+
msgid "when a <strong>post</strong> is <strong>published</strong>."
|
291 |
+
msgstr ""
|
292 |
+
|
293 |
+
#: ../admin/lib/nginx-general.php:184
|
294 |
+
msgid "when a comment is approved/published."
|
295 |
+
msgstr ""
|
296 |
+
|
297 |
+
#: ../admin/lib/nginx-general.php:188 ../admin/lib/nginx-general.php:235
|
298 |
+
msgid "when a <strong>comment</strong> is <strong>approved/published</strong>."
|
299 |
+
msgstr ""
|
300 |
+
|
301 |
+
#: ../admin/lib/nginx-general.php:193
|
302 |
+
msgid "when a comment is unapproved/deleted."
|
303 |
+
msgstr ""
|
304 |
+
|
305 |
+
#: ../admin/lib/nginx-general.php:197 ../admin/lib/nginx-general.php:244
|
306 |
+
msgid "when a <strong>comment</strong> is <strong>unapproved/deleted</strong>."
|
307 |
+
msgstr ""
|
308 |
+
|
309 |
+
#: ../admin/lib/nginx-general.php:206
|
310 |
+
msgid "Purge Archives:"
|
311 |
+
msgstr ""
|
312 |
+
|
313 |
+
#: ../admin/lib/nginx-general.php:207
|
314 |
+
msgid "(date, category, tag, author, custom taxonomies)"
|
315 |
+
msgstr ""
|
316 |
+
|
317 |
+
#: ../admin/lib/nginx-general.php:212
|
318 |
+
msgid "when an post/page/custom post is modified or added.</span>"
|
319 |
+
msgstr ""
|
320 |
+
|
321 |
+
#: ../admin/lib/nginx-general.php:221
|
322 |
+
msgid "when an existing post/page/custom post is trashed.</span>"
|
323 |
+
msgstr ""
|
324 |
+
|
325 |
+
#: ../admin/lib/nginx-general.php:231
|
326 |
+
msgid "when a comment is approved/published.</span>"
|
327 |
+
msgstr ""
|
328 |
+
|
329 |
+
#: ../admin/lib/nginx-general.php:240
|
330 |
+
msgid "when a comment is unapproved/deleted.</span>"
|
331 |
+
msgstr ""
|
332 |
+
|
333 |
+
#: ../admin/lib/nginx-general.php:259
|
334 |
+
msgid "Nginx Map"
|
335 |
+
msgstr ""
|
336 |
+
|
337 |
+
#: ../admin/lib/nginx-general.php:263
|
338 |
+
#, php-format
|
339 |
+
msgid ""
|
340 |
+
"Can't write on map file.<br /><br />Check you have write permission on "
|
341 |
+
"<strong>%s</strong>"
|
342 |
+
msgstr ""
|
343 |
+
|
344 |
+
#: ../admin/lib/nginx-general.php:268
|
345 |
+
msgid ""
|
346 |
+
"Nginx Map path to include in nginx settings<br /><small>(recommended)</small>"
|
347 |
+
msgstr ""
|
348 |
+
|
349 |
+
#: ../admin/lib/nginx-general.php:274
|
350 |
+
msgid ""
|
351 |
+
"Or,<br />Text to manually copy and paste in nginx settings<br /><small>(if "
|
352 |
+
"your network is small and new sites are not added frequently)</small>"
|
353 |
+
msgstr ""
|
354 |
+
|
355 |
+
#: ../admin/lib/nginx-general.php:286
|
356 |
+
msgid "Logging Options"
|
357 |
+
msgstr ""
|
358 |
+
|
359 |
+
#: ../admin/lib/nginx-general.php:304
|
360 |
+
#, php-format
|
361 |
+
msgid ""
|
362 |
+
"Can't write on log file.<br /><br />Check you have write permission on "
|
363 |
+
"<strong>%s</strong>"
|
364 |
+
msgstr ""
|
365 |
+
|
366 |
+
#: ../admin/lib/nginx-general.php:310
|
367 |
+
msgid "Logs path"
|
368 |
+
msgstr ""
|
369 |
+
|
370 |
+
#: ../admin/lib/nginx-general.php:314
|
371 |
+
msgid "View Log"
|
372 |
+
msgstr ""
|
373 |
+
|
374 |
+
#: ../admin/lib/nginx-general.php:315
|
375 |
+
msgid "Log"
|
376 |
+
msgstr ""
|
377 |
+
|
378 |
+
#: ../admin/lib/nginx-general.php:318
|
379 |
+
msgid "Log level"
|
380 |
+
msgstr ""
|
381 |
+
|
382 |
+
#: ../admin/lib/nginx-general.php:321
|
383 |
+
msgid "None"
|
384 |
+
msgstr ""
|
385 |
+
|
386 |
+
#: ../admin/lib/nginx-general.php:322
|
387 |
+
msgid "Info"
|
388 |
+
msgstr ""
|
389 |
+
|
390 |
+
#: ../admin/lib/nginx-general.php:323
|
391 |
+
msgid "Warning"
|
392 |
+
msgstr ""
|
393 |
+
|
394 |
+
#: ../admin/lib/nginx-general.php:324
|
395 |
+
msgid "Error"
|
396 |
+
msgstr ""
|
397 |
+
|
398 |
+
#: ../admin/lib/nginx-general.php:329
|
399 |
+
msgid "Max log file size"
|
400 |
+
msgstr ""
|
401 |
+
|
402 |
+
#: ../admin/lib/nginx-general.php:331
|
403 |
+
msgid "Mb"
|
404 |
+
msgstr ""
|
405 |
+
|
406 |
+
#: ../admin/lib/nginx-general.php:342
|
407 |
+
msgid "Save All Changes"
|
408 |
+
msgstr ""
|
409 |
+
|
410 |
+
#: ../admin/lib/nginx-sidebar.php:8
|
411 |
+
msgid "Need Help?"
|
412 |
+
msgstr ""
|
413 |
+
|
414 |
+
#: ../admin/lib/nginx-sidebar.php:11
|
415 |
+
#, php-format
|
416 |
+
msgid "Please use our <a href=\"%s\">free support forum</a>."
|
417 |
+
msgstr ""
|
418 |
+
|
419 |
+
#: ../admin/lib/nginx-sidebar.php:17
|
420 |
+
msgid "Getting Social is Good"
|
421 |
+
msgstr ""
|
422 |
+
|
423 |
+
#: ../admin/lib/nginx-sidebar.php:20
|
424 |
+
msgid "Become a fan on Facebook"
|
425 |
+
msgstr ""
|
426 |
+
|
427 |
+
#: ../admin/lib/nginx-sidebar.php:21
|
428 |
+
msgid "Follow us on Twitter"
|
429 |
+
msgstr ""
|
430 |
+
|
431 |
+
#: ../admin/lib/nginx-sidebar.php:22
|
432 |
+
msgid "Add to Circle"
|
433 |
+
msgstr ""
|
434 |
+
|
435 |
+
#: ../admin/lib/nginx-sidebar.php:23
|
436 |
+
msgid "Subscribe to our feeds"
|
437 |
+
msgstr ""
|
438 |
+
|
439 |
+
#: ../admin/lib/nginx-sidebar.php:29
|
440 |
+
msgid "Useful Links"
|
441 |
+
msgstr ""
|
442 |
+
|
443 |
+
#: ../admin/lib/nginx-sidebar.php:34
|
444 |
+
msgid "WordPress-Nginx Solutions"
|
445 |
+
msgstr ""
|
446 |
+
|
447 |
+
#: ../admin/lib/nginx-sidebar.php:37
|
448 |
+
msgid "WordPress Theme Devleopment"
|
449 |
+
msgstr ""
|
450 |
+
|
451 |
+
#: ../admin/lib/nginx-sidebar.php:40
|
452 |
+
msgid "WordPress Plugin Development"
|
453 |
+
msgstr ""
|
454 |
+
|
455 |
+
#: ../admin/lib/nginx-sidebar.php:43
|
456 |
+
msgid "WordPress Consultancy"
|
457 |
+
msgstr ""
|
458 |
+
|
459 |
+
#: ../admin/lib/nginx-sidebar.php:46
|
460 |
+
msgid "easyengine (ee)"
|
461 |
+
msgstr ""
|
462 |
+
|
463 |
+
#: ../admin/lib/nginx-sidebar.php:53
|
464 |
+
msgid "Click to toggle"
|
465 |
+
msgstr ""
|
466 |
+
|
467 |
+
#: ../admin/lib/nginx-sidebar.php:54
|
468 |
+
msgid "Latest News"
|
469 |
+
msgstr ""
|
470 |
+
|
471 |
+
#: ../admin/lib/nginx-sidebar.php:55
|
472 |
+
msgid "Loading..."
|
473 |
+
msgstr ""
|
474 |
+
|
475 |
+
#: ../admin/lib/nginx-support.php:8
|
476 |
+
msgid "Support Forums"
|
477 |
+
msgstr ""
|
478 |
+
|
479 |
+
#: ../admin/lib/nginx-support.php:13
|
480 |
+
msgid "Need Help!, ask your queries on our forums:"
|
481 |
+
msgstr ""
|
482 |
+
|
483 |
+
#: ../admin/lib/nginx-support.php:16
|
484 |
+
msgid "Free Support"
|
485 |
+
msgstr ""
|
486 |
+
|
487 |
+
#: ../admin/lib/nginx-support.php:18
|
488 |
+
msgid "Free Support Forum"
|
489 |
+
msgstr ""
|
490 |
+
|
491 |
+
#: ../admin/lib/nginx-support.php:18 ../admin/lib/nginx-support.php:24
|
492 |
+
msgid "Link to forum"
|
493 |
+
msgstr ""
|
494 |
+
|
495 |
+
#: ../admin/lib/nginx-support.php:22
|
496 |
+
msgid "Premium Support"
|
497 |
+
msgstr ""
|
498 |
+
|
499 |
+
#: ../admin/lib/nginx-support.php:24
|
500 |
+
msgid "Premium Support Forum"
|
501 |
+
msgstr ""
|
trunk/nginx-helper.php
ADDED
@@ -0,0 +1,400 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Nginx Helper
|
4 |
+
Plugin URI: http://rtcamp.com/nginx-helper/
|
5 |
+
Description: Cleans nginx's fastcgi/proxy cache whenever a post is edited/published. Also does few more things.
|
6 |
+
Version: 1.8.8
|
7 |
+
Author: rtCamp
|
8 |
+
Author URI: http://rtcamp.com
|
9 |
+
Text Domain: nginx-helper
|
10 |
+
Requires at least: 3.0
|
11 |
+
Tested up to: 4.2
|
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 |
+
const WP_CLI_COMMAND = 'nginx-helper';
|
24 |
+
|
25 |
+
function __construct() {
|
26 |
+
|
27 |
+
if (!$this->required_wp_version())
|
28 |
+
if (!$this->required_php_version())
|
29 |
+
return;
|
30 |
+
|
31 |
+
// Load Plugin Text Domain
|
32 |
+
add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
|
33 |
+
|
34 |
+
$this->load_options();
|
35 |
+
$this->plugin_name = plugin_basename(__FILE__);
|
36 |
+
|
37 |
+
register_activation_hook($this->plugin_name, array(&$this, 'activate'));
|
38 |
+
register_deactivation_hook($this->plugin_name, array(&$this, 'deactivate'));
|
39 |
+
|
40 |
+
add_action( 'init', array( &$this, 'start_helper' ), 15 );
|
41 |
+
}
|
42 |
+
|
43 |
+
function start_helper() {
|
44 |
+
|
45 |
+
global $rt_wp_nginx_purger;
|
46 |
+
add_action('shutdown', array(&$this, 'add_timestamps'), 99999);
|
47 |
+
add_action('add_init', array(&$this, 'update_map'));
|
48 |
+
|
49 |
+
add_action('publish_post', array(&$rt_wp_nginx_purger, 'purgePost'), 200, 1);
|
50 |
+
add_action('publish_page', array(&$rt_wp_nginx_purger, 'purgePost'), 200, 1);
|
51 |
+
add_action('wp_insert_comment', array(&$rt_wp_nginx_purger, 'purgePostOnComment'), 200, 2);
|
52 |
+
add_action('transition_comment_status', array(&$rt_wp_nginx_purger, 'purgePostOnCommentChange'), 200, 3);
|
53 |
+
|
54 |
+
$args = array('_builtin' => false);
|
55 |
+
$_rt_custom_post_types = get_post_types($args);
|
56 |
+
if (isset($post_types) && !empty($post_types)) {
|
57 |
+
if ($this->options['rt_wp_custom_post_types'] == true) {
|
58 |
+
foreach ($_rt_custom_post_types as $post_type) {
|
59 |
+
add_action('publish_' . trim($post_type), array(&$rt_wp_nginx_purger, 'purgePost'), 200, 1);
|
60 |
+
}
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
add_action('transition_post_status', array(&$this, 'set_future_post_option_on_future_status'), 20, 3);
|
65 |
+
add_action('delete_post', array(&$this, 'unset_future_post_option_on_delete'), 20, 1);
|
66 |
+
add_action('nm_check_log_file_size_daily', array(&$rt_wp_nginx_purger, 'checkAndTruncateLogFile'), 100, 1);
|
67 |
+
add_action('edit_attachment', array(&$rt_wp_nginx_purger, 'purgeImageOnEdit'), 100, 1);
|
68 |
+
add_action('wpmu_new_blog', array(&$this, 'update_new_blog_options'), 10, 1);
|
69 |
+
add_action('transition_post_status', array(&$rt_wp_nginx_purger, 'purge_on_post_moved_to_trash'), 20, 3);
|
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 |
+
add_action('check_ajax_referer', array(&$rt_wp_nginx_purger, 'purge_on_check_ajax_referer'), 20, 2);
|
73 |
+
add_action('admin_init', array(&$this, 'purge_all'));
|
74 |
+
|
75 |
+
// expose action to allow other plugins to purge the cache
|
76 |
+
add_action('rt_nginx_helper_purge_all', array(&$this, 'true_purge_all'));
|
77 |
+
|
78 |
+
// Load WP-CLI command
|
79 |
+
if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
80 |
+
require_once RT_WP_NGINX_HELPER_PATH . 'wp-cli.php';
|
81 |
+
\WP_CLI::add_command( self::WP_CLI_COMMAND, 'Nginx_Helper_WP_CLI_Command' );
|
82 |
+
}
|
83 |
+
}
|
84 |
+
|
85 |
+
function activate() {
|
86 |
+
|
87 |
+
$path = $this->functional_asset_path();
|
88 |
+
if (!is_dir($path)) {
|
89 |
+
mkdir($path);
|
90 |
+
}
|
91 |
+
include_once (RT_WP_NGINX_HELPER_PATH . 'admin/install.php');
|
92 |
+
rt_wp_nginx_helper_install();
|
93 |
+
}
|
94 |
+
|
95 |
+
function deactivate() {
|
96 |
+
include_once (RT_WP_NGINX_HELPER_PATH . 'admin/install.php');
|
97 |
+
rt_wp_nginx_helper_uninstall();
|
98 |
+
}
|
99 |
+
|
100 |
+
function required_wp_version() {
|
101 |
+
|
102 |
+
global $wp_version;
|
103 |
+
$wp_ok = version_compare($wp_version, $this->minium_WP, '>=');
|
104 |
+
if (($wp_ok == FALSE)) {
|
105 |
+
add_action( 'admin_notices', create_function( '', '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 );' ) );
|
106 |
+
add_action( 'network_admin_notices', create_function( '', '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 );' ) );
|
107 |
+
return false;
|
108 |
+
}
|
109 |
+
|
110 |
+
return true;
|
111 |
+
}
|
112 |
+
|
113 |
+
function load_options() {
|
114 |
+
$this->options = get_site_option('rt_wp_nginx_helper_options');
|
115 |
+
}
|
116 |
+
|
117 |
+
function set_future_post_option_on_future_status($new_status, $old_status, $post) {
|
118 |
+
|
119 |
+
global $blog_id, $rt_wp_nginx_purger;
|
120 |
+
if (!$this->options['enable_purge']) {
|
121 |
+
return;
|
122 |
+
}
|
123 |
+
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)) {
|
124 |
+
$rt_wp_nginx_purger->log("Purge post on transition post STATUS from " . $old_status . " to " . $new_status);
|
125 |
+
$rt_wp_nginx_purger->purgePost($post->ID);
|
126 |
+
}
|
127 |
+
|
128 |
+
if ($new_status == 'future') {
|
129 |
+
if ($post && $post->post_status == 'future' && ( ( $post->post_type == 'post' || $post->post_type == 'page' ) || ( isset( $this->options['custom_post_types_recognized'] ) && in_array($post->post_type, $this->options['custom_post_types_recognized']) ) )) {
|
130 |
+
$rt_wp_nginx_purger->log("Set/update future_posts option (post id = " . $post->ID . " and blog id = " . $blog_id . ")");
|
131 |
+
$this->options['future_posts'][$blog_id][$post->ID] = strtotime($post->post_date_gmt) + 60;
|
132 |
+
update_site_option("rt_wp_nginx_helper_global_options", $this->options);
|
133 |
+
}
|
134 |
+
}
|
135 |
+
}
|
136 |
+
|
137 |
+
function unset_future_post_option_on_delete($post_id) {
|
138 |
+
|
139 |
+
global $blog_id, $rt_wp_nginx_purger;
|
140 |
+
if (!$this->options['enable_purge']) {
|
141 |
+
return;
|
142 |
+
}
|
143 |
+
if ($post_id && !wp_is_post_revision($post_id)) {
|
144 |
+
|
145 |
+
if (isset($this->options['future_posts'][$blog_id][$post_id]) && count($this->options['future_posts'][$blog_id][$post_id])) {
|
146 |
+
$rt_wp_nginx_purger->log("Unset future_posts option (post id = " . $post_id . " and blog id = " . $blog_id . ")");
|
147 |
+
unset($this->options['future_posts'][$blog_id][$post_id]);
|
148 |
+
update_site_option("rt_wp_nginx_helper_global_options", $this->options);
|
149 |
+
|
150 |
+
if (!count($this->options['future_posts'][$blog_id])) {
|
151 |
+
unset($this->options['future_posts'][$blog_id]);
|
152 |
+
update_site_option("rt_wp_nginx_helper_global_options", $this->options);
|
153 |
+
}
|
154 |
+
}
|
155 |
+
}
|
156 |
+
}
|
157 |
+
|
158 |
+
function update_new_blog_options($blog_id) {
|
159 |
+
global $rt_wp_nginx_purger;
|
160 |
+
include_once (RT_WP_NGINX_HELPER_PATH . 'admin/install.php');
|
161 |
+
$rt_wp_nginx_purger->log("New site added (id $blog_id)");
|
162 |
+
$this->update_map();
|
163 |
+
$rt_wp_nginx_purger->log("New site added to nginx map (id $blog_id)");
|
164 |
+
$helper_options = rt_wp_nginx_helper_get_options();
|
165 |
+
update_blog_option($blog_id, "rt_wp_nginx_helper_options", $helper_options);
|
166 |
+
$rt_wp_nginx_purger->log("Default options updated for the new blog (id $blog_id)");
|
167 |
+
}
|
168 |
+
|
169 |
+
function get_map() {
|
170 |
+
if (!$this->options['enable_map']) {
|
171 |
+
return;
|
172 |
+
}
|
173 |
+
|
174 |
+
if (is_multisite()) {
|
175 |
+
|
176 |
+
global $wpdb;
|
177 |
+
|
178 |
+
$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));
|
179 |
+
$wpdb->dmtable = $wpdb->base_prefix . 'domain_mapping';
|
180 |
+
$rt_domain_map_sites = '';
|
181 |
+
if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->dmtable}'") == $wpdb->dmtable) {
|
182 |
+
$rt_domain_map_sites = $wpdb->get_results("SELECT blog_id, domain FROM {$wpdb->dmtable} ORDER BY id DESC");
|
183 |
+
}
|
184 |
+
$rt_nginx_map = "";
|
185 |
+
$rt_nginx_map_array = array();
|
186 |
+
|
187 |
+
|
188 |
+
if ($rt_all_blogs)
|
189 |
+
foreach ($rt_all_blogs as $blog) {
|
190 |
+
if (SUBDOMAIN_INSTALL == "yes") {
|
191 |
+
$rt_nginx_map_array[$blog->domain] = $blog->blog_id;
|
192 |
+
} else {
|
193 |
+
if ($blog->blog_id != 1) {
|
194 |
+
$rt_nginx_map_array[$blog->path] = $blog->blog_id;
|
195 |
+
}
|
196 |
+
}
|
197 |
+
}
|
198 |
+
|
199 |
+
if ($rt_domain_map_sites) {
|
200 |
+
foreach ($rt_domain_map_sites as $site) {
|
201 |
+
$rt_nginx_map_array[$site->domain] = $site->blog_id;
|
202 |
+
}
|
203 |
+
}
|
204 |
+
|
205 |
+
foreach ($rt_nginx_map_array as $domain => $domain_id) {
|
206 |
+
$rt_nginx_map .= "\t" . $domain . "\t" . $domain_id . ";\n";
|
207 |
+
}
|
208 |
+
|
209 |
+
return $rt_nginx_map;
|
210 |
+
}
|
211 |
+
}
|
212 |
+
|
213 |
+
function functional_asset_path() {
|
214 |
+
$dir = wp_upload_dir();
|
215 |
+
$path = $dir['basedir'] . '/nginx-helper/';
|
216 |
+
return apply_filters('nginx_asset_path', $path);
|
217 |
+
}
|
218 |
+
|
219 |
+
function functional_asset_url() {
|
220 |
+
$dir = wp_upload_dir();
|
221 |
+
$url = $dir['baseurl'] . '/nginx-helper/';
|
222 |
+
return apply_filters('nginx_asset_url', $url);
|
223 |
+
}
|
224 |
+
|
225 |
+
function update_map() {
|
226 |
+
if (is_multisite()) {
|
227 |
+
$rt_nginx_map = $this->get_map();
|
228 |
+
|
229 |
+
if ($fp = fopen($this->functional_asset_path() . 'map.conf', 'w+')) {
|
230 |
+
fwrite($fp, $rt_nginx_map);
|
231 |
+
fclose($fp);
|
232 |
+
return true;
|
233 |
+
}
|
234 |
+
}
|
235 |
+
}
|
236 |
+
|
237 |
+
function add_timestamps() {
|
238 |
+
if ($this->options['enable_purge'] != 1)
|
239 |
+
return;
|
240 |
+
if ($this->options['enable_stamp'] != 1)
|
241 |
+
return;
|
242 |
+
if (is_admin())
|
243 |
+
return;
|
244 |
+
foreach (headers_list() as $header) {
|
245 |
+
list($key, $value) = explode(':', $header, 2);
|
246 |
+
if ($key == 'Content-Type' && strpos(trim($value), 'text/html') !== 0) {
|
247 |
+
return;
|
248 |
+
}
|
249 |
+
if ($key == 'Content-Type')
|
250 |
+
break;
|
251 |
+
}
|
252 |
+
|
253 |
+
if (defined('DOING_AJAX') && DOING_AJAX)
|
254 |
+
return;
|
255 |
+
$timestamps = "\n<!--" .
|
256 |
+
"Cached using Nginx-Helper on " . current_time('mysql') . ". " .
|
257 |
+
"It took " . get_num_queries() . " queries executed in " . timer_stop() . " seconds." .
|
258 |
+
"-->\n" .
|
259 |
+
"<!--Visit http://wordpress.org/extend/plugins/nginx-helper/faq/ for more details-->";
|
260 |
+
echo $timestamps;
|
261 |
+
}
|
262 |
+
|
263 |
+
function show_notice() {
|
264 |
+
echo '<div class="updated"><p>' . __('Purge initiated', 'nginx-helper') . '</p></div>';
|
265 |
+
}
|
266 |
+
|
267 |
+
function purge_all() {
|
268 |
+
if (!isset($_REQUEST['nginx_helper_action']))
|
269 |
+
return;
|
270 |
+
|
271 |
+
if (!current_user_can('manage_options'))
|
272 |
+
wp_die('Sorry, you do not have the necessary privileges to edit these options.');
|
273 |
+
|
274 |
+
$action = $_REQUEST['nginx_helper_action'];
|
275 |
+
|
276 |
+
if ($action == 'done') {
|
277 |
+
add_action('admin_notices', array(&$this, 'show_notice'));
|
278 |
+
add_action('network_admin_notices', array(&$this, 'show_notice'));
|
279 |
+
return;
|
280 |
+
}
|
281 |
+
|
282 |
+
check_admin_referer('nginx_helper-purge_all');
|
283 |
+
|
284 |
+
switch ($action) {
|
285 |
+
case 'purge':
|
286 |
+
$this->true_purge_all();
|
287 |
+
break;
|
288 |
+
}
|
289 |
+
wp_redirect(add_query_arg(array('nginx_helper_action' => 'done')));
|
290 |
+
}
|
291 |
+
|
292 |
+
function true_purge_all() {
|
293 |
+
global $rt_wp_nginx_purger;
|
294 |
+
$rt_wp_nginx_purger->true_purge_all();
|
295 |
+
}
|
296 |
+
|
297 |
+
/**
|
298 |
+
* Load the translation file for current language.
|
299 |
+
*/
|
300 |
+
function load_plugin_textdomain() {
|
301 |
+
load_plugin_textdomain( 'nginx-helper', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
302 |
+
}
|
303 |
+
}
|
304 |
+
}
|
305 |
+
|
306 |
+
namespace {
|
307 |
+
|
308 |
+
if (!defined('RT_WP_NGINX_HELPER_CACHE_PATH')) {
|
309 |
+
define('RT_WP_NGINX_HELPER_CACHE_PATH', '/var/run/nginx-cache');
|
310 |
+
}
|
311 |
+
global $current_blog;
|
312 |
+
|
313 |
+
if (is_admin()) {
|
314 |
+
require_once (rtCamp\WP\Nginx\RT_WP_NGINX_HELPER_PATH . '/admin/admin.php');
|
315 |
+
$rtwpAdminPanel = new \rtCamp\WP\Nginx\Admin();
|
316 |
+
}
|
317 |
+
|
318 |
+
require_once (rtCamp\WP\Nginx\RT_WP_NGINX_HELPER_PATH . 'purger.php');
|
319 |
+
require_once (rtCamp\WP\Nginx\RT_WP_NGINX_HELPER_PATH . 'compatibility.php');
|
320 |
+
|
321 |
+
global $rt_wp_nginx_helper, $rt_wp_nginx_purger, $rt_wp_nginx_compatibility;
|
322 |
+
$rt_wp_nginx_helper = new \rtCamp\WP\Nginx\Helper;
|
323 |
+
$rt_wp_nginx_purger = new \rtCamp\WP\Nginx\Purger;
|
324 |
+
$rt_wp_nginx_compatibility = namespace\rtCamp\WP\Nginx\Compatibility::instance();
|
325 |
+
if ($rt_wp_nginx_compatibility->haveNginx() && !function_exists('wp_redirect')) {
|
326 |
+
|
327 |
+
function wp_redirect($location, $status = 302) {
|
328 |
+
$location = apply_filters('wp_redirect', $location, $status);
|
329 |
+
|
330 |
+
if (empty($location)) {
|
331 |
+
return false;
|
332 |
+
}
|
333 |
+
|
334 |
+
$status = apply_filters('wp_redirect_status', $status, $location);
|
335 |
+
if ($status < 300 || $status > 399) {
|
336 |
+
$status = 302;
|
337 |
+
}
|
338 |
+
|
339 |
+
if (function_exists('wp_sanitize_redirect')) {
|
340 |
+
$location = wp_sanitize_redirect($location);
|
341 |
+
}
|
342 |
+
header('Location: ' . $location, true, $status);
|
343 |
+
}
|
344 |
+
|
345 |
+
}
|
346 |
+
|
347 |
+
// Add settings link on plugin page
|
348 |
+
function nginx_settings_link($links) {
|
349 |
+
if (is_network_admin()) {
|
350 |
+
$u = 'settings.php';
|
351 |
+
} else {
|
352 |
+
$u = 'options-general.php';
|
353 |
+
}
|
354 |
+
$settings_link = '<a href="' . $u . '?page=nginx">' . __('Settings', 'nginx-helper') . '</a>';
|
355 |
+
array_unshift($links, $settings_link);
|
356 |
+
return $links;
|
357 |
+
}
|
358 |
+
|
359 |
+
if (is_multisite()) {
|
360 |
+
add_filter("network_admin_plugin_action_links_" . plugin_basename(__FILE__), 'nginx_settings_link');
|
361 |
+
} else {
|
362 |
+
add_filter("plugin_action_links_" . plugin_basename(__FILE__), 'nginx_settings_link');
|
363 |
+
}
|
364 |
+
|
365 |
+
function get_feeds($feed_url = 'http://rtcamp.com/blog/feed/') {
|
366 |
+
// Get RSS Feed(s)
|
367 |
+
require_once( ABSPATH . WPINC . '/feed.php' );
|
368 |
+
$maxitems = 0;
|
369 |
+
// Get a SimplePie feed object from the specified feed source.
|
370 |
+
$rss = fetch_feed($feed_url);
|
371 |
+
if (!is_wp_error($rss)) { // Checks that the object is created correctly
|
372 |
+
// Figure out how many total items there are, but limit it to 5.
|
373 |
+
$maxitems = $rss->get_item_quantity(5);
|
374 |
+
|
375 |
+
// Build an array of all the items, starting with element 0 (first element).
|
376 |
+
$rss_items = $rss->get_items(0, $maxitems);
|
377 |
+
} ?>
|
378 |
+
<ul role="list"><?php
|
379 |
+
if ($maxitems == 0) {
|
380 |
+
echo '<li role="listitem">' . __('No items', 'nginx-helper') . '.</li>';
|
381 |
+
} else {
|
382 |
+
// Loop through each feed item and display each item as a hyperlink.
|
383 |
+
foreach ($rss_items as $item) { ?>
|
384 |
+
<li role="listitem">
|
385 |
+
<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>
|
386 |
+
</li><?php
|
387 |
+
}
|
388 |
+
} ?>
|
389 |
+
</ul><?php
|
390 |
+
}
|
391 |
+
|
392 |
+
function fetch_feeds() {
|
393 |
+
if (isset($_GET['get_feeds']) && $_GET['get_feeds'] == '1') {
|
394 |
+
get_feeds();
|
395 |
+
die();
|
396 |
+
}
|
397 |
+
}
|
398 |
+
|
399 |
+
add_action('init', 'fetch_feeds');
|
400 |
+
}
|
trunk/purger.php
ADDED
@@ -0,0 +1,781 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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( home_url() );
|
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 |
+
global $rt_wp_nginx_helper;
|
208 |
+
|
209 |
+
$this->log( "- Purging URL | " . $url );
|
210 |
+
|
211 |
+
$parse = parse_url( $url );
|
212 |
+
|
213 |
+
switch ($rt_wp_nginx_helper->options['purge_method']) {
|
214 |
+
case 'unlink_files':
|
215 |
+
$_url_purge_base = $parse[ 'scheme' ] . '://' . $parse[ 'host' ] . $parse[ 'path' ];
|
216 |
+
$_url_purge = $_url_purge_base;
|
217 |
+
|
218 |
+
if ( isset( $parse[ 'query' ] ) && $parse[ 'query' ] != '' ) {
|
219 |
+
$_url_purge .= '?' . $parse[ 'query' ];
|
220 |
+
}
|
221 |
+
|
222 |
+
$this->_delete_cache_file_for( $_url_purge );
|
223 |
+
|
224 |
+
if ( $feed ) {
|
225 |
+
$feed_url = rtrim( $_url_purge_base, '/' ) . '/feed/';
|
226 |
+
$this->_delete_cache_file_for( $feed_url );
|
227 |
+
$this->_delete_cache_file_for( $feed_url . 'atom/' );
|
228 |
+
$this->_delete_cache_file_for( $feed_url . 'rdf/' );
|
229 |
+
}
|
230 |
+
break;
|
231 |
+
case 'get_request':
|
232 |
+
// Go to default case
|
233 |
+
default:
|
234 |
+
$_url_purge_base = $parse[ 'scheme' ] . '://' . $parse[ 'host' ] . '/purge' . $parse[ 'path' ];
|
235 |
+
$_url_purge = $_url_purge_base;
|
236 |
+
|
237 |
+
if ( isset( $parse[ 'query' ] ) && $parse[ 'query' ] != '' ) {
|
238 |
+
$_url_purge .= '?' . $parse[ 'query' ];
|
239 |
+
}
|
240 |
+
|
241 |
+
$this->_do_remote_get( $_url_purge );
|
242 |
+
|
243 |
+
if ( $feed ) {
|
244 |
+
$feed_url = rtrim( $_url_purge_base, '/' ) . '/feed/';
|
245 |
+
$this->_do_remote_get( $feed_url );
|
246 |
+
$this->_do_remote_get( $feed_url . 'atom/' );
|
247 |
+
$this->_do_remote_get( $feed_url . 'rdf/' );
|
248 |
+
}
|
249 |
+
break;
|
250 |
+
}
|
251 |
+
|
252 |
+
}
|
253 |
+
|
254 |
+
/*********************
|
255 |
+
* Deletes local cache files without a 3rd party nginx module.
|
256 |
+
*
|
257 |
+
* Does not require any other modules. Requires that the cache be stored on the same server as WordPress. You must also be using the default nginx cache options (levels=1:2) and (fastcgi_cache_key "$scheme$request_method$host$request_uri").
|
258 |
+
*
|
259 |
+
* Read more on how this works here:
|
260 |
+
* https://www.digitalocean.com/community/tutorials/how-to-setup-fastcgi-caching-with-nginx-on-your-vps#purging-the-cache
|
261 |
+
**********************/
|
262 |
+
private function _delete_cache_file_for( $url ) {
|
263 |
+
|
264 |
+
// Verify cache path is set
|
265 |
+
if (!defined('RT_WP_NGINX_HELPER_CACHE_PATH')) {
|
266 |
+
$this->log('Error purging because RT_WP_NGINX_HELPER_CACHE_PATH was not defined. URL: '.$url, 'ERROR');
|
267 |
+
return false;
|
268 |
+
}
|
269 |
+
|
270 |
+
// Verify URL is valid
|
271 |
+
$url_data = parse_url($url);
|
272 |
+
if(!$url_data) {
|
273 |
+
$this->log('Error purging because specified URL did not appear to be valid. URL: '.$url, 'ERROR');
|
274 |
+
return false;
|
275 |
+
}
|
276 |
+
|
277 |
+
// Build a hash of the URL
|
278 |
+
$hash = md5($url_data['scheme'].'GET'.$url_data['host'].$url_data['path']);
|
279 |
+
|
280 |
+
// Ensure trailing slash
|
281 |
+
$cache_path = RT_WP_NGINX_HELPER_CACHE_PATH;
|
282 |
+
$cache_path = (substr($cache_path, -1) == '/') ? $cache_path : $cache_path.'/';
|
283 |
+
|
284 |
+
// Set path to cached file
|
285 |
+
$cached_file = $cache_path . substr($hash, -1) . '/' . substr($hash,-3,2) . '/' . $hash;
|
286 |
+
|
287 |
+
// Verify cached file exists
|
288 |
+
if (!file_exists($cached_file)) {
|
289 |
+
$this->log( "- - " . $url . " is currently not cached (checked for file: $cached_file)" );
|
290 |
+
return false;
|
291 |
+
}
|
292 |
+
|
293 |
+
// Delete the cached file
|
294 |
+
if (unlink($cached_file)) {
|
295 |
+
$this->log( "- - " . $url . " *** PURGED ***" );
|
296 |
+
} else {
|
297 |
+
$this->log("- - An error occurred deleting the cache file. Check the server logs for a PHP warning.", "ERROR");
|
298 |
+
}
|
299 |
+
}
|
300 |
+
|
301 |
+
private function _do_remote_get( $url ) {
|
302 |
+
|
303 |
+
$response = wp_remote_get( $url );
|
304 |
+
|
305 |
+
if ( is_wp_error( $response ) ) {
|
306 |
+
$_errors_str = implode( " - ", $response->get_error_messages() );
|
307 |
+
$this->log( "Error while purging URL. " . $_errors_str, "ERROR" );
|
308 |
+
} else {
|
309 |
+
if ( $response[ 'response' ][ 'code' ] ) {
|
310 |
+
switch ( $response[ 'response' ][ 'code' ] ) {
|
311 |
+
case 200:
|
312 |
+
$this->log( "- - " . $url . " *** PURGED ***" );
|
313 |
+
break;
|
314 |
+
case 404:
|
315 |
+
$this->log( "- - " . $url . " is currently not cached" );
|
316 |
+
break;
|
317 |
+
default:
|
318 |
+
$this->log( "- - " . $url . " not found (" . $response[ 'response' ][ 'code' ] . ")", "WARNING" );
|
319 |
+
}
|
320 |
+
}
|
321 |
+
}
|
322 |
+
}
|
323 |
+
|
324 |
+
function checkHttpConnection() {
|
325 |
+
|
326 |
+
$purgeURL = plugins_url( "nginx-manager/check-proxy.php" );
|
327 |
+
$response = wp_remote_get( $purgeURL );
|
328 |
+
|
329 |
+
if ( ! is_wp_error( $response ) && ($response[ 'body' ] == 'HTTP Connection OK') ) {
|
330 |
+
return "OK";
|
331 |
+
}
|
332 |
+
|
333 |
+
return "KO";
|
334 |
+
}
|
335 |
+
|
336 |
+
function log( $msg, $level = 'INFO' ) {
|
337 |
+
|
338 |
+
global $rt_wp_nginx_helper;
|
339 |
+
if ( ! $rt_wp_nginx_helper->options[ 'enable_log' ] ) {
|
340 |
+
return;
|
341 |
+
}
|
342 |
+
|
343 |
+
$log_levels = array( "INFO" => 0, "WARNING" => 1, "ERROR" => 2, "NONE" => 3 );
|
344 |
+
|
345 |
+
if ( $log_levels[ $level ] >= $log_levels[ $rt_wp_nginx_helper->options[ 'log_level' ] ] ) {
|
346 |
+
if ( $fp = fopen( $rt_wp_nginx_helper->functional_asset_path() . 'nginx.log', "a+" ) ) {
|
347 |
+
fwrite( $fp, "\n" . gmdate( "Y-m-d H:i:s " ) . " | " . $level . " | " . $msg );
|
348 |
+
fclose( $fp );
|
349 |
+
}
|
350 |
+
}
|
351 |
+
|
352 |
+
return true;
|
353 |
+
}
|
354 |
+
|
355 |
+
function checkAndTruncateLogFile() {
|
356 |
+
|
357 |
+
global $rt_wp_nginx_helper;
|
358 |
+
|
359 |
+
$maxSizeAllowed = (is_numeric( $rt_wp_nginx_helper->options[ 'log_filesize' ] )) ? $rt_wp_nginx_helper->options[ 'log_filesize' ] * 1048576 : 5242880;
|
360 |
+
|
361 |
+
$fileSize = filesize( $rt_wp_nginx_helper->functional_asset_path() . 'nginx.log' );
|
362 |
+
|
363 |
+
if ( $fileSize > $maxSizeAllowed ) {
|
364 |
+
|
365 |
+
$offset = $fileSize - $maxSizeAllowed;
|
366 |
+
|
367 |
+
if ( $file_content = file_get_contents( $rt_wp_nginx_helper->functional_asset_path() . 'nginx.log', NULL, NULL, $offset ) ) {
|
368 |
+
|
369 |
+
if ( $file_content = strstr( $file_content, "\n" ) ) {
|
370 |
+
|
371 |
+
if ( $fp = fopen( $rt_wp_nginx_helper->functional_asset_path() . 'nginx.log', "w+" ) ) {
|
372 |
+
fwrite( $fp, $file_content );
|
373 |
+
fclose( $fp );
|
374 |
+
}
|
375 |
+
}
|
376 |
+
}
|
377 |
+
}
|
378 |
+
}
|
379 |
+
|
380 |
+
function purgeImageOnEdit( $attachment_id ) {
|
381 |
+
|
382 |
+
$this->log( "Purging media on edit BEGIN ===" );
|
383 |
+
|
384 |
+
if ( wp_attachment_is_image( $attachment_id ) ) {
|
385 |
+
|
386 |
+
$this->purgeUrl( wp_get_attachment_url( $attachment_id ), false );
|
387 |
+
$attachment = wp_get_attachment_metadata( $attachment_id );
|
388 |
+
|
389 |
+
if ( ! empty( $attachment[ 'sizes' ] ) && is_array( $attachment[ 'sizes' ] ) ) {
|
390 |
+
foreach ( $attachment[ 'sizes' ] as $size_name => $size ) {
|
391 |
+
$resize_image = wp_get_attachment_image_src( $attachment_id, $size_name );
|
392 |
+
if ( $resize_image )
|
393 |
+
$this->purgeUrl( $resize_image[ 0 ], false );
|
394 |
+
}
|
395 |
+
}
|
396 |
+
$this->purgeURL( get_attachment_link( $attachment_id ) );
|
397 |
+
} else {
|
398 |
+
$this->log( "Media (id $attachment_id) edited: no image", "WARNING" );
|
399 |
+
}
|
400 |
+
|
401 |
+
$this->log( "Purging media on edit END ^^^" );
|
402 |
+
}
|
403 |
+
|
404 |
+
function purge_on_post_moved_to_trash( $new_status, $old_status, $post ) {
|
405 |
+
|
406 |
+
global $rt_wp_nginx_helper, $blog_id;
|
407 |
+
if ( ! $rt_wp_nginx_helper->options[ 'enable_purge' ] ) {
|
408 |
+
return;
|
409 |
+
}
|
410 |
+
if ( $new_status == 'trash' ) {
|
411 |
+
|
412 |
+
$this->log( "# # # # #" );
|
413 |
+
$this->log( "# Post '$post->post_title' (id $post->ID) moved to the trash." );
|
414 |
+
$this->log( "# # # # #" );
|
415 |
+
|
416 |
+
$this->log( "Function purge_on_post_moved_to_trash (post id $post->ID) BEGIN ===" );
|
417 |
+
|
418 |
+
|
419 |
+
|
420 |
+
if ( $rt_wp_nginx_helper->options[ 'purge_homepage_on_del' ] == 1 ) {
|
421 |
+
$this->_purge_homepage();
|
422 |
+
}
|
423 |
+
|
424 |
+
|
425 |
+
$this->_purge_by_options( $post->ID, $blog_id, false, $rt_wp_nginx_helper->options[ 'purge_archive_on_del' ], $rt_wp_nginx_helper->options[ 'purge_archive_on_del' ] );
|
426 |
+
|
427 |
+
|
428 |
+
|
429 |
+
$this->log( "Function purge_on_post_moved_to_trash (post id $post->ID) END ===" );
|
430 |
+
}
|
431 |
+
|
432 |
+
return true;
|
433 |
+
}
|
434 |
+
|
435 |
+
private function _purge_homepage() {
|
436 |
+
|
437 |
+
$homepage_url = trailingslashit( home_url() );
|
438 |
+
|
439 |
+
$this->log( sprintf( __( "Purging homepage '%s'", "nginx-helper" ), $homepage_url ) );
|
440 |
+
$this->purgeUrl( $homepage_url );
|
441 |
+
|
442 |
+
return true;
|
443 |
+
}
|
444 |
+
|
445 |
+
private function _purge_personal_urls() {
|
446 |
+
|
447 |
+
global $rt_wp_nginx_helper;
|
448 |
+
|
449 |
+
$this->log( __( "Purging personal urls", "nginx-helper" ) );
|
450 |
+
|
451 |
+
if ( isset( $rt_wp_nginx_helper->options[ 'purgeable_url' ][ 'urls' ] ) ) {
|
452 |
+
|
453 |
+
foreach ( $rt_wp_nginx_helper->options[ 'purgeable_url' ][ 'urls' ] as $u ) {
|
454 |
+
$this->purgeUrl( $u, false );
|
455 |
+
}
|
456 |
+
} else {
|
457 |
+
$this->log( "- " . __( "No personal urls available", "nginx-helper" ) );
|
458 |
+
}
|
459 |
+
|
460 |
+
return true;
|
461 |
+
}
|
462 |
+
|
463 |
+
private function _purge_post_categories( $_post_id ) {
|
464 |
+
|
465 |
+
$this->log( __( "Purging category archives", "nginx-helper" ) );
|
466 |
+
|
467 |
+
if ( $categories = wp_get_post_categories( $_post_id ) ) {
|
468 |
+
foreach ( $categories as $category_id ) {
|
469 |
+
$this->log( sprintf( __( "Purging category '%d'", "nginx-helper" ), $category_id ) );
|
470 |
+
$this->purgeUrl( get_category_link( $category_id ) );
|
471 |
+
}
|
472 |
+
}
|
473 |
+
|
474 |
+
return true;
|
475 |
+
}
|
476 |
+
|
477 |
+
private function _purge_post_tags( $_post_id ) {
|
478 |
+
|
479 |
+
$this->log( __( "Purging tags archives", "nginx-helper" ) );
|
480 |
+
|
481 |
+
if ( $tags = get_the_tags( $_post_id ) ) {
|
482 |
+
foreach ( $tags as $tag ) {
|
483 |
+
$this->log( sprintf( __( "Purging tag '%s' (id %d)", "nginx-helper" ), $tag->name, $tag->term_id ) );
|
484 |
+
$this->purgeUrl( get_tag_link( $tag->term_id ) );
|
485 |
+
}
|
486 |
+
}
|
487 |
+
|
488 |
+
return true;
|
489 |
+
}
|
490 |
+
|
491 |
+
private function _purge_post_custom_taxa( $_post_id ) {
|
492 |
+
|
493 |
+
$this->log( __( "Purging post custom taxonomies related", "nginx-helper" ) );
|
494 |
+
|
495 |
+
if ( $custom_taxonomies = get_taxonomies( array( 'public' => true, '_builtin' => false ) ) ) {
|
496 |
+
foreach ( $custom_taxonomies as $taxon ) {
|
497 |
+
$this->log( sprintf( "+ " . __( "Purging custom taxonomy '%s'", "nginx-helper" ), $taxon ) );
|
498 |
+
|
499 |
+
if ( ! in_array( $taxon, array( 'category', 'post_tag', 'link_category' ) ) ) {
|
500 |
+
|
501 |
+
if ( $terms = get_the_terms( $_post_id, $taxon ) ) {
|
502 |
+
foreach ( $terms as $term ) {
|
503 |
+
$this->purgeUrl( get_term_link( $term, $taxon ) );
|
504 |
+
}
|
505 |
+
}
|
506 |
+
} else {
|
507 |
+
$this->log( sprintf( "- " . __( "Your built-in taxonomy '%s' has param '_builtin' set to false.", "nginx-helper" ), $taxon ), "WARNING" );
|
508 |
+
}
|
509 |
+
}
|
510 |
+
} else {
|
511 |
+
$this->log( "- " . __( "No custom taxonomies", "nginx-helper" ) );
|
512 |
+
}
|
513 |
+
|
514 |
+
return true;
|
515 |
+
}
|
516 |
+
|
517 |
+
private function _purge_all_categories() {
|
518 |
+
|
519 |
+
$this->log( __( "Purging all categories", "nginx-helper" ) );
|
520 |
+
|
521 |
+
if ( $_categories = get_categories() ) {
|
522 |
+
|
523 |
+
foreach ( $_categories as $c ) {
|
524 |
+
$this->log( sprintf( __( "Purging category '%s' (id %d)", "nginx-helper" ), $c->name, $c->term_id ) );
|
525 |
+
$this->purgeUrl( get_category_link( $c->term_id ) );
|
526 |
+
}
|
527 |
+
} else {
|
528 |
+
$this->log( __( "No categories archives", "nginx-helper" ) );
|
529 |
+
}
|
530 |
+
|
531 |
+
return true;
|
532 |
+
}
|
533 |
+
|
534 |
+
private function _purge_all_posttags() {
|
535 |
+
|
536 |
+
$this->log( __( "Purging all tags", "nginx-helper" ) );
|
537 |
+
|
538 |
+
if ( $_posttags = get_tags() ) {
|
539 |
+
|
540 |
+
foreach ( $_posttags as $t ) {
|
541 |
+
$this->log( sprintf( __( "Purging tag '%s' (id %d)", "nginx-helper" ), $t->name, $t->term_id ) );
|
542 |
+
$this->purgeUrl( get_tag_link( $t->term_id ) );
|
543 |
+
}
|
544 |
+
} else {
|
545 |
+
$this->log( __( "No tags archives", "nginx-helper" ) );
|
546 |
+
}
|
547 |
+
|
548 |
+
return true;
|
549 |
+
}
|
550 |
+
|
551 |
+
private function _purge_all_customtaxa() {
|
552 |
+
|
553 |
+
$this->log( __( "Purging all custom taxonomies", "nginx-helper" ) );
|
554 |
+
|
555 |
+
if ( $custom_taxonomies = get_taxonomies( array( 'public' => true, '_builtin' => false ) ) ) {
|
556 |
+
|
557 |
+
foreach ( $custom_taxonomies as $taxon ) {
|
558 |
+
$this->log( sprintf( "+ " . __( "Purging custom taxonomy '%s'", "nginx-helper" ), $taxon ) );
|
559 |
+
|
560 |
+
if ( ! in_array( $taxon, array( 'category', 'post_tag', 'link_category' ) ) ) {
|
561 |
+
|
562 |
+
if ( $terms = get_terms( $taxon ) ) {
|
563 |
+
foreach ( $terms as $term ) {
|
564 |
+
$this->purgeUrl( get_term_link( $term, $taxon ) );
|
565 |
+
}
|
566 |
+
}
|
567 |
+
} else {
|
568 |
+
$this->log( sprintf( "- " . __( "Your built-in taxonomy '%s' has param '_builtin' set to false.", "nginx-helper" ), $taxon ), "WARNING" );
|
569 |
+
}
|
570 |
+
}
|
571 |
+
} else {
|
572 |
+
$this->log( "- " . __( "No custom taxonomies", "nginx-helper" ) );
|
573 |
+
}
|
574 |
+
|
575 |
+
return true;
|
576 |
+
}
|
577 |
+
|
578 |
+
private function _purge_all_taxonomies() {
|
579 |
+
|
580 |
+
$this->_purge_all_categories();
|
581 |
+
$this->_purge_all_posttags();
|
582 |
+
$this->_purge_all_customtaxa();
|
583 |
+
|
584 |
+
return true;
|
585 |
+
}
|
586 |
+
|
587 |
+
private function _purge_all_posts() {
|
588 |
+
|
589 |
+
$this->log( __( "Purging all posts, pages and custom post types.", "nginx-helper" ) );
|
590 |
+
|
591 |
+
$args = array(
|
592 |
+
'numberposts' => 0,
|
593 |
+
'post_type' => 'any',
|
594 |
+
'post_status' => 'publish' );
|
595 |
+
|
596 |
+
if ( $_posts = get_posts( $args ) ) {
|
597 |
+
|
598 |
+
foreach ( $_posts as $p ) {
|
599 |
+
$this->log( sprintf( "+ " . __( "Purging post id '%d' (post type '%s')", "nginx-helper" ), $p->ID, $p->post_type ) );
|
600 |
+
$this->purgeUrl( get_permalink( $p->ID ) );
|
601 |
+
}
|
602 |
+
} else {
|
603 |
+
$this->log( "- " . __( "No posts", "nginx-helper" ) );
|
604 |
+
}
|
605 |
+
|
606 |
+
return true;
|
607 |
+
}
|
608 |
+
|
609 |
+
private function _purge_all_date_archives() {
|
610 |
+
|
611 |
+
$this->log( __( "Purging all date-based archives.", "nginx-helper" ) );
|
612 |
+
|
613 |
+
$this->_purge_all_daily_archives();
|
614 |
+
|
615 |
+
$this->_purge_all_monthly_archives();
|
616 |
+
|
617 |
+
$this->_purge_all_yearly_archives();
|
618 |
+
|
619 |
+
return true;
|
620 |
+
}
|
621 |
+
|
622 |
+
private function _purge_all_daily_archives() {
|
623 |
+
|
624 |
+
global $wpdb;
|
625 |
+
|
626 |
+
$this->log( __( "Purging all daily archives.", "nginx-helper" ) );
|
627 |
+
|
628 |
+
$_query_daily_archives = $wpdb->prepare(
|
629 |
+
"SELECT YEAR(post_date) AS 'year', MONTH(post_date) AS 'month', DAYOFMONTH(post_date) AS 'dayofmonth', count(ID) as posts
|
630 |
+
FROM $wpdb->posts
|
631 |
+
WHERE post_type = 'post' AND post_status = 'publish'
|
632 |
+
GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date)
|
633 |
+
ORDER BY post_date DESC"
|
634 |
+
);
|
635 |
+
|
636 |
+
if ( $_daily_archives = $wpdb->get_results( $_query_daily_archives ) ) {
|
637 |
+
|
638 |
+
foreach ( $_daily_archives as $_da ) {
|
639 |
+
$this->log( sprintf( "+ " . __( "Purging daily archive '%s/%s/%s'", "nginx-helper" ), $_da->year, $_da->month, $_da->dayofmonth ) );
|
640 |
+
$this->purgeUrl( get_day_link( $_da->year, $_da->month, $_da->dayofmonth ) );
|
641 |
+
}
|
642 |
+
} else {
|
643 |
+
$this->log( "- " . __( "No daily archives", "nginx-helper" ) );
|
644 |
+
}
|
645 |
+
}
|
646 |
+
|
647 |
+
private function _purge_all_monthly_archives() {
|
648 |
+
|
649 |
+
global $wpdb;
|
650 |
+
|
651 |
+
$this->log( __( "Purging all monthly archives.", "nginx-helper" ) );
|
652 |
+
|
653 |
+
$_query_monthly_archives = $wpdb->prepare(
|
654 |
+
"SELECT YEAR(post_date) AS 'year', MONTH(post_date) AS 'month', count(ID) as posts
|
655 |
+
FROM $wpdb->posts
|
656 |
+
WHERE post_type = 'post' AND post_status = 'publish'
|
657 |
+
GROUP BY YEAR(post_date), MONTH(post_date)
|
658 |
+
ORDER BY post_date DESC"
|
659 |
+
);
|
660 |
+
|
661 |
+
if ( $_monthly_archives = $wpdb->get_results( $_query_monthly_archives ) ) {
|
662 |
+
|
663 |
+
foreach ( $_monthly_archives as $_ma ) {
|
664 |
+
$this->log( sprintf( "+ " . __( "Purging monthly archive '%s/%s'", "nginx-helper" ), $_ma->year, $_ma->month ) );
|
665 |
+
$this->purgeUrl( get_month_link( $_ma->year, $_ma->month ) );
|
666 |
+
}
|
667 |
+
} else {
|
668 |
+
$this->log( "- " . __( "No monthly archives", "nginx-helper" ) );
|
669 |
+
}
|
670 |
+
}
|
671 |
+
|
672 |
+
private function _purge_all_yearly_archives() {
|
673 |
+
|
674 |
+
global $wpdb;
|
675 |
+
|
676 |
+
$this->log( __( "Purging all yearly archives.", "nginx-helper" ) );
|
677 |
+
|
678 |
+
$_query_yearly_archives = $wpdb->prepare(
|
679 |
+
"SELECT YEAR(post_date) AS 'year', count(ID) as posts
|
680 |
+
FROM $wpdb->posts
|
681 |
+
WHERE post_type = 'post' AND post_status = 'publish'
|
682 |
+
GROUP BY YEAR(post_date)
|
683 |
+
ORDER BY post_date DESC"
|
684 |
+
);
|
685 |
+
|
686 |
+
if ( $_yearly_archives = $wpdb->get_results( $_query_yearly_archives ) ) {
|
687 |
+
|
688 |
+
foreach ( $_yearly_archives as $_ya ) {
|
689 |
+
$this->log( sprintf( "+ " . __( "Purging yearly archive '%s'", "nginx-helper" ), $_ya->year ) );
|
690 |
+
$this->purgeUrl( get_year_link( $_ya->year ) );
|
691 |
+
}
|
692 |
+
} else {
|
693 |
+
$this->log( "- " . __( "No yearly archives", "nginx-helper" ) );
|
694 |
+
}
|
695 |
+
}
|
696 |
+
|
697 |
+
function purge_them_all() {
|
698 |
+
|
699 |
+
$this->log( __( "Let's purge everything!", "nginx-helper" ) );
|
700 |
+
|
701 |
+
$this->_purge_homepage();
|
702 |
+
|
703 |
+
$this->_purge_personal_urls();
|
704 |
+
|
705 |
+
$this->_purge_all_posts();
|
706 |
+
|
707 |
+
$this->_purge_all_taxonomies();
|
708 |
+
|
709 |
+
$this->_purge_all_date_archives();
|
710 |
+
|
711 |
+
$this->log( __( "Everthing purged!", "nginx-helper" ) );
|
712 |
+
|
713 |
+
return true;
|
714 |
+
}
|
715 |
+
|
716 |
+
function purge_on_term_taxonomy_edited( $term_id, $tt_id, $taxon ) {
|
717 |
+
|
718 |
+
$this->log( __( "Term taxonomy edited or deleted", "nginx-helper" ) );
|
719 |
+
|
720 |
+
if ( current_filter() == 'edit_term' && $term = get_term( $term_id, $taxon ) ) {
|
721 |
+
$this->log( sprintf( __( "Term taxonomy '%s' edited, (tt_id '%d', term_id '%d', taxonomy '%s')", "nginx-helper" ), $term->name, $tt_id, $term_id, $taxon ) );
|
722 |
+
} else if ( current_filter() == 'delete_term' ) {
|
723 |
+
$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 ) );
|
724 |
+
}
|
725 |
+
|
726 |
+
$this->_purge_homepage();
|
727 |
+
|
728 |
+
return true;
|
729 |
+
}
|
730 |
+
|
731 |
+
function purge_on_check_ajax_referer( $action, $result ) {
|
732 |
+
|
733 |
+
switch ( $action ) {
|
734 |
+
case 'save-sidebar-widgets' :
|
735 |
+
|
736 |
+
$this->log( __( "Widget saved, moved or removed in a sidebar", "nginx-helper" ) );
|
737 |
+
|
738 |
+
$this->_purge_homepage();
|
739 |
+
|
740 |
+
break;
|
741 |
+
|
742 |
+
default :
|
743 |
+
break;
|
744 |
+
}
|
745 |
+
|
746 |
+
return true;
|
747 |
+
}
|
748 |
+
|
749 |
+
function true_purge_all(){
|
750 |
+
$this->unlinkRecursive(RT_WP_NGINX_HELPER_CACHE_PATH, false);
|
751 |
+
$this->log( "* * * * *" );
|
752 |
+
$this->log( "* Purged Everything!" );
|
753 |
+
$this->log( "* * * * *" );
|
754 |
+
}
|
755 |
+
|
756 |
+
/** Source - http://stackoverflow.com/a/1360437/156336 **/
|
757 |
+
|
758 |
+
function unlinkRecursive( $dir, $deleteRootToo ) {
|
759 |
+
if ( ! $dh = opendir( $dir ) ) {
|
760 |
+
return;
|
761 |
+
}
|
762 |
+
while ( false !== ($obj = readdir( $dh )) ) {
|
763 |
+
if ( $obj == '.' || $obj == '..' ) {
|
764 |
+
continue;
|
765 |
+
}
|
766 |
+
|
767 |
+
if ( ! @unlink( $dir . '/' . $obj ) ) {
|
768 |
+
$this->unlinkRecursive( $dir . '/' . $obj, true );
|
769 |
+
}
|
770 |
+
}
|
771 |
+
|
772 |
+
if ($deleteRootToo){
|
773 |
+
rmdir($dir);
|
774 |
+
}
|
775 |
+
|
776 |
+
closedir( $dh );
|
777 |
+
|
778 |
+
return;
|
779 |
+
}
|
780 |
+
}
|
781 |
+
}
|
trunk/readme.txt
ADDED
@@ -0,0 +1,282 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Nginx Helper ===
|
2 |
+
Contributors: rtcamp, rahul286, saurabhshukla, manishsongirkar36, faishal, desaiuditd, Darren Slatten, jk3us, daankortenbach, telofy, pjv, llonchj, jinnko,weskoop
|
3 |
+
Tags: nginx, cache, purge, nginx map, nginx cache, maps, fastcgi, proxy, rewrite, permalinks
|
4 |
+
Requires at least: 3.0
|
5 |
+
Tested up to: 4.2
|
6 |
+
Stable tag: 1.8.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 |
+
Cleans nginx's fastcgi/proxy cache whenever a post is edited/published. Also does few more things.
|
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 |
+
**Important** - Please refer to [http://rtcamp.com/nginx-helper/faq](http://rtcamp.com/nginx-helper/faq) for uptodate FAQ's.
|
48 |
+
|
49 |
+
= FAQ - Installation/Comptability =
|
50 |
+
|
51 |
+
**Q. Will this work out of the box?**
|
52 |
+
|
53 |
+
No. You need to make some changes at the Nginx end. Please check [tutorial list](http://rtcamp.com/wordpress-nginx/tutorials)
|
54 |
+
|
55 |
+
= FAQ - Nginx Fastcgi Cache Purge =
|
56 |
+
|
57 |
+
**Q. There's a 'purge all' button? Does it purge the whole site?**
|
58 |
+
|
59 |
+
Yes, it does. It physically empties the cache directory. It is set by default to `/var/run/nginx-cache/`.
|
60 |
+
|
61 |
+
If your cache directory is different, you can override this in your wp-config.php by adding
|
62 |
+
`define('RT_WP_NGINX_HELPER_CACHE_PATH','/var/run/nginx-cache/');`
|
63 |
+
|
64 |
+
Replace the path with your own.
|
65 |
+
|
66 |
+
**Q. Does it work for custom posts and taxonomies?**
|
67 |
+
|
68 |
+
Yes. It handles all post-types same way.
|
69 |
+
|
70 |
+
**Q. How do I know my Nginx config is correct for fastcgi purging?**
|
71 |
+
|
72 |
+
Manually purging any page from the cache, by following instructions in the previous answer.
|
73 |
+
|
74 |
+
Version 1.3.4 onwards, Nginx Helper adds a comment at the end of the html source ('view source' in your favourite browser):
|
75 |
+
<!--Cached using Nginx-Helper on 2012-10-08 07:01:45. It took 42 queries executed in 0.280 seconds.-->
|
76 |
+
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.
|
77 |
+
|
78 |
+
Just check this comment before and after a manual purge.
|
79 |
+
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!
|
80 |
+
|
81 |
+
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.)
|
82 |
+
|
83 |
+
|
84 |
+
**Q. I need to flush a cached page immediately! How do I do that?**
|
85 |
+
|
86 |
+
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.
|
87 |
+
|
88 |
+
To purge a page immediately, follow these instructions:
|
89 |
+
(eg. http://yoursite.com/about/)
|
90 |
+
Between the domain name and the rest of the url, insert '/purge/'.
|
91 |
+
So, in the above eg, the purge url will be http://yoursite.com/purge/about/
|
92 |
+
Just open this in a browser and the page will be purged instantly.
|
93 |
+
Needless to say, this won't work, if you have a page or taxonomy called 'purge'.
|
94 |
+
|
95 |
+
|
96 |
+
= FAQ - Nginx Map =
|
97 |
+
|
98 |
+
**Q. My multisite already uses `WPMU_ACCEL_REDIRECT`. Do I still need Nginx Map?**
|
99 |
+
|
100 |
+
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.
|
101 |
+
|
102 |
+
**Q. I am using X plugin. Will it work on Nginx?**
|
103 |
+
|
104 |
+
Most likely yes. A wordpress plugin, if not using explicitly any Apache-only mod, should work on Nginx. Some plugin may need some extra work.
|
105 |
+
|
106 |
+
|
107 |
+
= Still need help! =
|
108 |
+
|
109 |
+
Please post your problem in [our free support forum](http://community.rtcamp.com/c/wordpress-nginx).
|
110 |
+
|
111 |
+
== Screenshots ==
|
112 |
+
1. Nginx plugin settings
|
113 |
+
2. Remaining settings
|
114 |
+
|
115 |
+
== Changelog ==
|
116 |
+
|
117 |
+
= 1.8.8 =
|
118 |
+
* Added option to purge cache without nginx purge module - by [bcole808](https://profiles.wordpress.org/bcole808/)
|
119 |
+
|
120 |
+
= 1.8.7 =
|
121 |
+
* Added action `rt_nginx_helper_purge_all` to purge cache from other plugins - by [gungeekatx](https://profiles.wordpress.org/gungeekatx/)
|
122 |
+
|
123 |
+
= 1.8.6 =
|
124 |
+
* Removed wercker.yml from plugin zip/svn.
|
125 |
+
* Updated readme
|
126 |
+
|
127 |
+
= 1.8.5 =
|
128 |
+
* Added WP_CLI support - by [Udit Desai](https://profiles.wordpress.org/desaiuditd/)
|
129 |
+
|
130 |
+
= 1.8.4 =
|
131 |
+
* Fix undefined index issue and correct "purge_archive_on_del" key
|
132 |
+
|
133 |
+
= 1.8.3 =
|
134 |
+
* Tested with WordPress 4.0
|
135 |
+
* Fix issue #69
|
136 |
+
|
137 |
+
= 1.8.1 =
|
138 |
+
* Tested with wordpress 3.9.1
|
139 |
+
* Fix confilct with Mailchimp's Social plugin
|
140 |
+
|
141 |
+
= 1.8 =
|
142 |
+
* New admin UI
|
143 |
+
* Fix missing wp_sanitize_redirect function call
|
144 |
+
|
145 |
+
= 1.7.6 =
|
146 |
+
* Update Backend UI
|
147 |
+
* Added Language Support
|
148 |
+
|
149 |
+
= 1.7.5 =
|
150 |
+
* Fixed option name mismatch issue to purge homepage on delete.
|
151 |
+
|
152 |
+
= 1.7.4 =
|
153 |
+
* Disable purge and stamp by default.
|
154 |
+
|
155 |
+
= 1.7.3 =
|
156 |
+
* Suppressed `unlink` related error-messages which can be safely ignored.
|
157 |
+
* Fixed a bug in purge-all option.
|
158 |
+
|
159 |
+
= 1.7.2 =
|
160 |
+
* [pjv](http://profiles.wordpress.org/pjv/) fixed bug in logging file.
|
161 |
+
|
162 |
+
= 1.7.1 =
|
163 |
+
* Fixes bug in true purge and admin screen.
|
164 |
+
|
165 |
+
= 1.7 =
|
166 |
+
* True full cache purge added.
|
167 |
+
* Map file location changed to uploads' directory to fix http://rtcamp.com/support/topic/plugin-update-removes-map-file/
|
168 |
+
* Log file location also changed to uploads' directory.
|
169 |
+
|
170 |
+
= 1.6.13 =
|
171 |
+
* [pjv](http://profiles.wordpress.org/pjv/) changed the way home url is accessed. Instead of site option, the plugin now uses home_url() function.
|
172 |
+
|
173 |
+
= 1.6.12 =
|
174 |
+
* [telofy](http://wordpress.org/support/profile/telofy) added purging of atom and RDF feeds.
|
175 |
+
|
176 |
+
= 1.6.11 =
|
177 |
+
* Removed comments from Admin screens since, it was interfering with media uploads in 3.5 up.
|
178 |
+
|
179 |
+
= 1.6.10 =
|
180 |
+
* Cleaned up code.
|
181 |
+
* Added credits for code.
|
182 |
+
* Improved attachment purging.
|
183 |
+
|
184 |
+
= 1.6.9 =
|
185 |
+
* Added Faux to Purge all buttons, to avoid misleading users.
|
186 |
+
|
187 |
+
= 1.6.8 =
|
188 |
+
* [daankortenbach](http://profiles.wordpress.org/daankortenbach) added Purge Cache link to wp-admin bar
|
189 |
+
|
190 |
+
= 1.6.7 =
|
191 |
+
* [jk3us](http://profiles.wordpress.org/jk3us) added better content-type detection for cache verification comments
|
192 |
+
|
193 |
+
= 1.6.6 =
|
194 |
+
* [darren-slatten](http://profiles.wordpress.org/darren-slatten/) added Manual 'Purge all URLs' functionality
|
195 |
+
|
196 |
+
= 1.6.5 =
|
197 |
+
* Fixed typo that interfered with archive purge settings. Thanks to [Daan Kortenbach](http://profiles.wordpress.org/daankortenbach/) for pointing this out.
|
198 |
+
|
199 |
+
= 1.6.4 =
|
200 |
+
* Improved code for map generation to better conventions since the nesting confused some servers.
|
201 |
+
* Added map update process to admin_init for frequent refreshes.
|
202 |
+
|
203 |
+
= 1.6.3 =
|
204 |
+
* Fixed duplicate entries.
|
205 |
+
|
206 |
+
= 1.6.2 =
|
207 |
+
* Another bug fix in the revised code for improved multisite and multidomain mapping.
|
208 |
+
|
209 |
+
= 1.6.1 =
|
210 |
+
* Fixed bug in the revised code for improved multisite and multidomain mapping.
|
211 |
+
|
212 |
+
= 1.6 =
|
213 |
+
* Revised code for improved multisite and multidomain mapping.
|
214 |
+
|
215 |
+
= 1.5 =
|
216 |
+
* Timestamp now only gets added to content-type text/html
|
217 |
+
* Added option to toggle timestamp creation
|
218 |
+
|
219 |
+
= 1.4 =
|
220 |
+
* Fixed bug related to nomenclature of comment status that caused purge to fail.
|
221 |
+
|
222 |
+
= 1.3.9 =
|
223 |
+
* Removed extraneous headers.
|
224 |
+
|
225 |
+
= 1.3.8 =
|
226 |
+
|
227 |
+
* 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/.
|
228 |
+
|
229 |
+
= 1.3.7 =
|
230 |
+
|
231 |
+
* Changed the action hook, back to 'shutdown' from 'wp_footer' to add verification comments.
|
232 |
+
* Added a check to prevent adding comments to ajax requests,
|
233 |
+
|
234 |
+
= 1.3.6 =
|
235 |
+
|
236 |
+
* Changed the action hook, from 'shutdown' to 'wp_footer' to add verification comments. This was interfering with other plugins.
|
237 |
+
|
238 |
+
= 1.3.5 =
|
239 |
+
|
240 |
+
* Improved Readme.
|
241 |
+
* Improved cache verification comments.
|
242 |
+
|
243 |
+
= 1.3.4 =
|
244 |
+
|
245 |
+
* Fixed duplicate entries generated for maps (Harmless, but doesn't look good!)
|
246 |
+
* Added timestamp html comments for cache verification, as described here: http://rtcamp.com/wordpress-nginx/tutorials/checklist/
|
247 |
+
|
248 |
+
= 1.3.3 =
|
249 |
+
|
250 |
+
* Fixed map generation for multi domain installs using domain mapping plugin, where blog ids were not displayed.
|
251 |
+
|
252 |
+
= 1.3.2 =
|
253 |
+
|
254 |
+
* Fixed map generation for multi domain installs with domain mapping plugin.
|
255 |
+
|
256 |
+
= 1.3.1 =
|
257 |
+
|
258 |
+
* Minor fixes for directory structure and file names.
|
259 |
+
|
260 |
+
= 1.3 =
|
261 |
+
|
262 |
+
* Improved Readme.
|
263 |
+
|
264 |
+
= 1.2 =
|
265 |
+
|
266 |
+
* Fixed map generation error.
|
267 |
+
* Fixed purging logic.
|
268 |
+
* Fixed UI where purge settings were lost on disabling and re-enabling purge.
|
269 |
+
* Minor Ui rearrangement.
|
270 |
+
|
271 |
+
= 1.1 =
|
272 |
+
|
273 |
+
* Improved readme.txt. Added Screenshots.
|
274 |
+
|
275 |
+
= 1.0 =
|
276 |
+
|
277 |
+
* First release
|
278 |
+
|
279 |
+
== Upgrade Notice ==
|
280 |
+
|
281 |
+
= 1.8.4 =
|
282 |
+
Fix undefined index issue and correct "purge_archive_on_del" key
|
trunk/wercker.yml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
box: ubuntu
|
2 |
+
|
3 |
+
build:
|
4 |
+
steps:
|
5 |
+
|
6 |
+
- script:
|
7 |
+
name: placehoder
|
8 |
+
code: echo "nothing to build"
|
9 |
+
|
10 |
+
deploy:
|
11 |
+
steps:
|
12 |
+
# - install-packages:
|
13 |
+
# packages: subversion git wget
|
14 |
+
|
15 |
+
- rtcamp/wordpress-svn:
|
16 |
+
pluginslug: nginx-helper
|
17 |
+
mainfile: nginx-helper.php
|
18 |
+
svnuser: $SVNUSER
|
19 |
+
svnpass: $SVNPASS #wordpress.org password
|
20 |
+
gituser: $GITUSER
|
21 |
+
gitpass: $GITPASS #github.com password
|
22 |
+
gitemail: git@example.com #github.com password
|
trunk/wp-cli.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PhpStorm.
|
4 |
+
* User: udit
|
5 |
+
* Date: 19/3/15
|
6 |
+
* Time: 2:06 PM
|
7 |
+
*/
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Don't load this file directly!
|
11 |
+
*/
|
12 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
13 |
+
exit;
|
14 |
+
}
|
15 |
+
|
16 |
+
if ( ! class_exists( 'Nginx_Helper_WP_CLI_Command' ) ) {
|
17 |
+
|
18 |
+
class Nginx_Helper_WP_CLI_Command extends WP_CLI_Command {
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Subcommand to purge all cache from Nginx
|
22 |
+
*
|
23 |
+
* Examples:
|
24 |
+
* wp nginx-helper purge_all
|
25 |
+
*
|
26 |
+
* @subcommand purge-all
|
27 |
+
*/
|
28 |
+
public function purge_all( $args, $assoc_args ) {
|
29 |
+
global $rt_wp_nginx_purger;
|
30 |
+
$rt_wp_nginx_purger->true_purge_all();
|
31 |
+
$message = __( 'Purged Everything!' );
|
32 |
+
WP_CLI::success( $message );
|
33 |
+
}
|
34 |
+
|
35 |
+
}
|
36 |
+
|
37 |
+
}
|