Nginx Helper - Version 1.2

Version Description

  • Fixed map generation error.
  • Fixed purging logic.
  • Fixed UI where purge settings were lost on disabling and re-enabling purge.
  • Minor Ui rearrangement.
Download this release

Release Info

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

Code changes from version 1.0 to 1.2

admin/admin.php CHANGED
@@ -13,12 +13,12 @@ namespace rtCamp\WP\Nginx{
13
  }
14
 
15
  function add_menu() {
16
- add_submenu_page( 'options-general.php', 'Nginx', __( 'Nginx', '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', __( 'Nginx', '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
@@ -61,14 +61,14 @@ namespace rtCamp\WP\Nginx{
61
  }
62
 
63
  }
64
- if($rt_wp_nginx_helper->options['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
 
@@ -77,12 +77,12 @@ namespace rtCamp\WP\Nginx{
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_option( "rt_wp_nginx_helper_options", $rt_wp_nginx_helper->options );
81
 
82
 
83
  $update = 1;
84
  }
85
- $rt_wp_nginx_helper->options = get_option("rt_wp_nginx_helper_options");
86
 
87
 
88
  ?>
@@ -112,11 +112,13 @@ namespace rtCamp\WP\Nginx{
112
  </table>
113
 
114
  <?php
115
- if($rt_wp_nginx_helper->options['enable_purge']!=false){
 
 
116
  ?>
117
- <h3>Purging Options</h3>
118
 
119
- <table class="form-table rtnginx-table">
120
  <tr valign="top">
121
  <th scope="row"><h4>Purge Homepage:</h4></th>
122
  <td>
@@ -131,52 +133,52 @@ namespace rtCamp\WP\Nginx{
131
  </td>
132
  </tr>
133
  </table>
134
- <table class="form-table rtnginx-table">
135
  <tr valign="top">
136
  <th scope="row">
137
- <h4>Purge Archives:</h4>
138
- <small>(date, category, tag, author, custom taxonomies)</small>
139
  </th>
140
  <td>
141
  <fieldset>
142
- <legend class="screen-reader-text"><span>&nbsp;when an post/page/custom post is modified or added.</span></legend>
143
- <label for="purge_archive_on_edit"><input type="checkbox" value="1" id="purge_archive_on_edit" name="purge_archive_on_edit"<?php checked( $rt_wp_nginx_helper->options['purge_archive_on_edit'], 1 ); ?>>&nbsp;when a <strong>post</strong> (or page/custom post) is <strong>modified</strong> or <strong>added</strong>.</label><br />
144
- </fieldset>
145
- <fieldset>
146
- <legend class="screen-reader-text"><span>&nbsp;when an existing post/page/custom post is trashed.</span></legend>
147
- <label for="purge_archive_on_del"><input type="checkbox" value="1" id="purge_archive_on_del" name="purge_archive_on_del"<?php checked( $rt_wp_nginx_helper->options['purge_archive_on_del'], 1 ); ?>>&nbsp;when a <strong>published post</strong> (or page/custom post) is <strong>trashed</strong>.</label><br />
148
  </fieldset>
149
- <br />
150
  <fieldset>
151
  <legend class="screen-reader-text"><span>&nbsp;when a comment is approved/published.</span></legend>
152
- <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 ); ?>>&nbsp;when a <strong>comment</strong> is <strong>approved/published</strong>.</label><br />
153
  </fieldset>
154
  <fieldset>
155
  <legend class="screen-reader-text"><span>&nbsp;when a comment is unapproved/deleted.</span></legend>
156
- <label for="purge_archive_on_deleted_comment"><input type="checkbox" value="1" id="purge_archive_on_deleted_comment" name="purge_archive_on_deleted_comment"<?php checked( $rt_wp_nginx_helper->options['purge_archive_on_deleted_comment'], 1 ); ?>>&nbsp;when a <strong>comment</strong> is <strong>unapproved/deleted</strong>.</label><br />
157
  </fieldset>
158
-
159
  </td>
160
  </tr>
161
  </table>
162
- <table class="form-table rtnginx-table">
163
  <tr valign="top">
164
  <th scope="row">
165
- <h4>Purge Post/Page/Custom Post Type:</h4>
 
166
  </th>
167
  <td>
168
  <fieldset>
169
- <legend class="screen-reader-text"><span>&nbsp;when a post/page/custom post is published.</span></legend>
170
- <label for="purge_page_on_mod"><input type="checkbox" value="1" id="purge_page_on_mod" name="purge_page_on_mod"<?php checked( $rt_wp_nginx_helper->options['purge_page_on_mod'], 1 ); ?>>&nbsp;when a <strong>post</strong> is <strong>published</strong>.</label><br />
171
  </fieldset>
 
 
 
 
 
172
  <fieldset>
173
  <legend class="screen-reader-text"><span>&nbsp;when a comment is approved/published.</span></legend>
174
- <label for="purge_page_on_new_comment"><input type="checkbox" value="1" id="purge_page_on_new_comment" name="purge_page_on_new_comment"<?php checked( $rt_wp_nginx_helper->options['purge_page_on_new_comment'], 1 ); ?>>&nbsp;when a <strong>comment</strong> is <strong>approved/published</strong>.</label><br />
175
  </fieldset>
176
  <fieldset>
177
  <legend class="screen-reader-text"><span>&nbsp;when a comment is unapproved/deleted.</span></legend>
178
- <label for="purge_page_on_deleted_comment"><input type="checkbox" value="1" id="purge_page_on_deleted_comment" name="purge_page_on_deleted_comment"<?php checked( $rt_wp_nginx_helper->options['purge_page_on_deleted_comment'], 1 ); ?>>&nbsp;when a <strong>comment</strong> is <strong>unapproved/deleted</strong>.</label><br />
179
  </fieldset>
 
180
  </td>
181
  </tr>
182
  </table>
@@ -211,7 +213,6 @@ namespace rtCamp\WP\Nginx{
211
  </td>
212
  </tr>
213
  </table>
214
- <?php } ?>
215
 
216
  <?php
217
  if($rt_wp_nginx_helper->options['enable_log']!=false){
@@ -315,4 +316,4 @@ namespace rtCamp\WP\Nginx{
315
  }
316
  }
317
  }
318
- ?>
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
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
 
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
  ?>
112
  </table>
113
 
114
  <?php
115
+ if($rt_wp_nginx_helper->options['enable_purge']==false){
116
+ $displayvar = ' style="display:none"';
117
+ }
118
  ?>
119
+ <h3<?php echo $displayvar; ?>>Purging Options</h3>
120
 
121
+ <table class="form-table rtnginx-table"<?php echo $displayvar; ?>>
122
  <tr valign="top">
123
  <th scope="row"><h4>Purge Homepage:</h4></th>
124
  <td>
133
  </td>
134
  </tr>
135
  </table>
136
+ <table class="form-table rtnginx-table"<?php echo $displayvar; ?>>
137
  <tr valign="top">
138
  <th scope="row">
139
+ <h4>Purge Post/Page/Custom Post Type:</h4>
 
140
  </th>
141
  <td>
142
  <fieldset>
143
+ <legend class="screen-reader-text"><span>&nbsp;when a post/page/custom post is published.</span></legend>
144
+ <label for="purge_page_on_mod"><input type="checkbox" value="1" id="purge_page_on_mod" name="purge_page_on_mod"<?php checked( $rt_wp_nginx_helper->options['purge_page_on_mod'], 1 ); ?>>&nbsp;when a <strong>post</strong> is <strong>published</strong>.</label><br />
 
 
 
 
145
  </fieldset>
 
146
  <fieldset>
147
  <legend class="screen-reader-text"><span>&nbsp;when a comment is approved/published.</span></legend>
148
+ <label for="purge_page_on_new_comment"><input type="checkbox" value="1" id="purge_page_on_new_comment" name="purge_page_on_new_comment"<?php checked( $rt_wp_nginx_helper->options['purge_page_on_new_comment'], 1 ); ?>>&nbsp;when a <strong>comment</strong> is <strong>approved/published</strong>.</label><br />
149
  </fieldset>
150
  <fieldset>
151
  <legend class="screen-reader-text"><span>&nbsp;when a comment is unapproved/deleted.</span></legend>
152
+ <label for="purge_page_on_deleted_comment"><input type="checkbox" value="1" id="purge_page_on_deleted_comment" name="purge_page_on_deleted_comment"<?php checked( $rt_wp_nginx_helper->options['purge_page_on_deleted_comment'], 1 ); ?>>&nbsp;when a <strong>comment</strong> is <strong>unapproved/deleted</strong>.</label><br />
153
  </fieldset>
 
154
  </td>
155
  </tr>
156
  </table>
157
+ <table class="form-table rtnginx-table"<?php echo $displayvar; ?>>
158
  <tr valign="top">
159
  <th scope="row">
160
+ <h4>Purge Archives:</h4>
161
+ <small>(date, category, tag, author, custom taxonomies)</small>
162
  </th>
163
  <td>
164
  <fieldset>
165
+ <legend class="screen-reader-text"><span>&nbsp;when an post/page/custom post is modified or added.</span></legend>
166
+ <label for="purge_archive_on_edit"><input type="checkbox" value="1" id="purge_archive_on_edit" name="purge_archive_on_edit"<?php checked( $rt_wp_nginx_helper->options['purge_archive_on_edit'], 1 ); ?>>&nbsp;when a <strong>post</strong> (or page/custom post) is <strong>modified</strong> or <strong>added</strong>.</label><br />
167
  </fieldset>
168
+ <fieldset>
169
+ <legend class="screen-reader-text"><span>&nbsp;when an existing post/page/custom post is trashed.</span></legend>
170
+ <label for="purge_archive_on_del"><input type="checkbox" value="1" id="purge_archive_on_del" name="purge_archive_on_del"<?php checked( $rt_wp_nginx_helper->options['purge_archive_on_del'], 1 ); ?>>&nbsp;when a <strong>published post</strong> (or page/custom post) is <strong>trashed</strong>.</label><br />
171
+ </fieldset>
172
+ <br />
173
  <fieldset>
174
  <legend class="screen-reader-text"><span>&nbsp;when a comment is approved/published.</span></legend>
175
+ <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 ); ?>>&nbsp;when a <strong>comment</strong> is <strong>approved/published</strong>.</label><br />
176
  </fieldset>
177
  <fieldset>
178
  <legend class="screen-reader-text"><span>&nbsp;when a comment is unapproved/deleted.</span></legend>
179
+ <label for="purge_archive_on_deleted_comment"><input type="checkbox" value="1" id="purge_archive_on_deleted_comment" name="purge_archive_on_deleted_comment"<?php checked( $rt_wp_nginx_helper->options['purge_archive_on_deleted_comment'], 1 ); ?>>&nbsp;when a <strong>comment</strong> is <strong>unapproved/deleted</strong>.</label><br />
180
  </fieldset>
181
+
182
  </td>
183
  </tr>
184
  </table>
213
  </td>
214
  </tr>
215
  </table>
 
216
 
217
  <?php
218
  if($rt_wp_nginx_helper->options['enable_log']!=false){
316
  }
317
  }
318
  }
319
+ ?>
admin/assets/nginx-icon-32x32.png CHANGED
Binary file
admin/assets/rtp-social-icons-32-32.png CHANGED
Binary file
nginx.php → nginx-helper.php RENAMED
@@ -1,9 +1,9 @@
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.0
7
  Author: rtCamp
8
  Author URI: http://rtcamp.com
9
  Requires at least: 3.0
@@ -230,7 +230,7 @@ namespace rtCamp\WP\Nginx {
230
  }
231
  function update_map(){
232
  if (is_multisite()){
233
- $rt_nginx_map = $this->read_map();
234
  if ($fp = fopen(RT_WP_NGINX_HELPER_PATH .'map.conf','w+')) {
235
  fwrite($fp, $rt_nginx_map);
236
  fclose($fp);
@@ -333,4 +333,4 @@ namespace{
333
  }
334
  add_action('init','fetch_feeds');
335
  }
336
- ?>
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.2
7
  Author: rtCamp
8
  Author URI: http://rtcamp.com
9
  Requires at least: 3.0
230
  }
231
  function update_map(){
232
  if (is_multisite()){
233
+ $rt_nginx_map = $this->get_map();
234
  if ($fp = fopen(RT_WP_NGINX_HELPER_PATH .'map.conf','w+')) {
235
  fwrite($fp, $rt_nginx_map);
236
  fclose($fp);
333
  }
334
  add_action('init','fetch_feeds');
335
  }
336
+ ?>
readme.txt CHANGED
@@ -1,28 +1,80 @@
1
  === Nginx ===
2
- Contributors: rtcamp,rahul286,saurabhshukla
3
- Tags: nginx, cache, purge, nginx map, nginx cache
4
  Requires at least: 3.0
5
  Tested up to: 3.4.2
6
- Stable tag: 1.0
 
 
 
7
 
8
- Makes WordPress super fast and super friendly with nginx!
9
 
10
  == Description ==
11
 
12
-  
 
 
 
 
 
 
13
 
14
- 1. Adds index.php redirection to make your wordpress installation compatible with nginx.
15
- 2. Adds nginx proxy purge with detailed settings.
16
- 3. Adds support for nginx maps on a multisite/network installation to optimise performance, as described here:
17
- <a href=\"http://rtcamp.com/tutorials/wordpress-nginx-multisite-subdirectories-nginx-map/\">http://rtcamp.com/tutorials/wordpress-nginx-multisite-subdirectories-nginx-map/</a>
18
 
19
  == Installation ==
20
 
21
- Extract the zip file and just drop the contents in the wp-content/plugins/ directory of your WordPress installation and then activate the Plugin from Plugins page.
22
- == Screenshots ==
23
- 1. nginx plugin settings
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
- 2. remaining settings
 
 
 
 
 
 
 
 
 
26
 
27
  == Changelog ==
28
- 1.0: First release
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.2
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. Add 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
+ * [Nginx maps + WordPress-Multisite + Static Files Handling](http://rtcamp.com/tutorials/nginx-maps-wordpress-multisite-static-files-handling/)
21
+ * [Other WordPress-Nginx Tutorials](http://rtcamp.com/wordpress-nginx/tutorials/)
22
 
 
 
 
 
23
 
24
  == Installation ==
25
 
26
+ 1. Extract the zip file.
27
+ 1. Upload them to `/wp-content/plugins/` directory on your WordPress installation.
28
+ 1. Then activate the Plugin from Plugins page.
29
+
30
+ = Tutorials =
31
+ * [Nginx maps + WordPress-Multisite + Static Files Handling](http://rtcamp.com/tutorials/nginx-maps-wordpress-multisite-static-files-handling/)
32
+ * [Other WordPress-Nginx Tutorials](http://rtcamp.com/wordpress-nginx/tutorials/)
33
+
34
+ == Frequently Asked Questions ==
35
+
36
+ Please check list of [WordPress-Nginx tutorials](http://rtcamp.com/wordpress-nginx/tutorials/) we have created before you jump to support forums.
37
+
38
+ **Q. Will this work out of the box?**
39
+
40
+ No. You need to make some changes at Nginx end. Please see ^above^ tutorials for guidance.
41
+
42
+
43
+ **Q. On my Multisite, I am alredy using `WPMU_ACCEL_REDIRECT`. Do I still need Nginx Map?**
44
+
45
+ Definietly yes. `WPMU_ACCEL_REDIRECT` reduceds 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 handles files by itself which gives you much better performance without using a CDN.
46
+
47
+ **Q. I am using X plugin. Will it work on Nginx?**
48
+
49
+ 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.
50
 
51
+
52
+ **Q. I am stuck. I need help!**
53
+
54
+ 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.
55
+ Its just that we are hyperactive on our own forum!
56
+
57
+
58
+ == Screenshots ==
59
+ 1. Nginx plugin settings
60
+ 2. Remaining settings
61
 
62
  == Changelog ==
63
+ = 1.2 =
64
+
65
+ * Fixed map generation error.
66
+ * Fixed purging logic.
67
+ * Fixed UI where purge settings were lost on disabling and re-enabling purge.
68
+ * Minor Ui rearrangement.
69
+
70
+ = 1.1 =
71
+
72
+ * Improved readme.txt. Added Screenshots.
73
+
74
+ = 1.0 =
75
+ * First release
76
+
77
+ == Upgrade Notice ==
78
+
79
+ = 1.2 =
80
+ This release fixes a couple of bugs with nginx maps and purging logic.