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