Nginx Helper - Version 1.9.8

Version Description

  • Fixed homepage cache cleared when WPML plugin used #116 - by Niwreg
  • Fixed Purge Cache clears the whole Redis cache #113 - by HansVanEijsden
  • One log file for all site in WPMU.
  • Single site Redis cache purge when click on Purge Cache button in WPMU #122 - by Lars Stttrup Nielsen
  • Fixed notices and warnings.
Download this release

Release Info

Developer bhargavbhandari90
Plugin Icon 128x128 Nginx Helper
Version 1.9.8
Comparing to
See all releases

Code changes from version 1.9.7 to 1.9.8

Files changed (5) hide show
  1. composer.json +2 -2
  2. nginx-helper.php +4 -6
  3. purger.php +14 -7
  4. readme.txt +16 -6
  5. redis-purger.php +37 -15
composer.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "name": "rtcamp/nginx-helper",
3
- "description": "Cleans nginx's fastcgi/proxy cache or redis-cahce whenever a post is edited/published. Also does a few more things.",
4
- "keywords": ["wordpress", "plugin", "nginx", "nginx-helper", "fastcgi", "redis-cahce", "redis", "cache"],
5
  "homepage": "https://rtcamp.com/nginx-helper/",
6
  "license": "GPL-2.0+",
7
  "authors": [{
1
  {
2
  "name": "rtcamp/nginx-helper",
3
+ "description": "Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also does a few more things.",
4
+ "keywords": ["wordpress", "plugin", "nginx", "nginx-helper", "fastcgi", "redis-cache", "redis", "cache"],
5
  "homepage": "https://rtcamp.com/nginx-helper/",
6
  "license": "GPL-2.0+",
7
  "authors": [{
nginx-helper.php CHANGED
@@ -3,12 +3,12 @@
3
  Plugin Name: Nginx Helper
4
  Plugin URI: https://rtcamp.com/nginx-helper/
5
  Description: Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also does a few more things.
6
- Version: 1.9.7
7
  Author: rtCamp
8
  Author URI: https://rtcamp.com
9
  Text Domain: nginx-helper
10
  Requires at least: 3.0
11
- Tested up to: 4.5.2
12
  */
13
 
14
  namespace rtCamp\WP\Nginx {
@@ -227,15 +227,13 @@ namespace rtCamp\WP\Nginx {
227
 
228
  function functional_asset_path()
229
  {
230
- $dir = wp_upload_dir();
231
- $path = $dir['basedir'] . '/nginx-helper/';
232
  return apply_filters( 'nginx_asset_path', $path );
233
  }
234
 
235
  function functional_asset_url()
236
  {
237
- $dir = wp_upload_dir();
238
- $url = $dir['baseurl'] . '/nginx-helper/';
239
  return apply_filters( 'nginx_asset_url', $url );
240
  }
241
 
3
  Plugin Name: Nginx Helper
4
  Plugin URI: https://rtcamp.com/nginx-helper/
5
  Description: Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also does a few more things.
6
+ Version: 1.9.8
7
  Author: rtCamp
8
  Author URI: https://rtcamp.com
9
  Text Domain: nginx-helper
10
  Requires at least: 3.0
11
+ Tested up to: 4.6
12
  */
13
 
14
  namespace rtCamp\WP\Nginx {
227
 
228
  function functional_asset_path()
229
  {
230
+ $path = WP_CONTENT_DIR . '/uploads/nginx-helper/';
 
231
  return apply_filters( 'nginx_asset_path', $path );
232
  }
233
 
234
  function functional_asset_url()
235
  {
236
+ $url = WP_CONTENT_URL . '/uploads/nginx-helper/';
 
237
  return apply_filters( 'nginx_asset_url', $url );
238
  }
239
 
purger.php CHANGED
@@ -102,10 +102,7 @@ namespace rtCamp\WP\Nginx {
102
  $this->log( "Function purgePost BEGIN ===" );
103
 
104
  if ( $rt_wp_nginx_helper->options[ 'purge_homepage_on_edit' ] == 1 ) {
105
- $homepage_url = trailingslashit( home_url() );
106
-
107
- $this->log( "Purging homepage '$homepage_url'" );
108
- $this->purgeUrl( $homepage_url );
109
  }
110
 
111
 
@@ -207,6 +204,8 @@ namespace rtCamp\WP\Nginx {
207
  function purgeUrl( $url, $feed = true ) {
208
 
209
  global $rt_wp_nginx_helper;
 
 
210
 
211
  $this->log( "- Purging URL | " . $url );
212
 
@@ -435,10 +434,18 @@ namespace rtCamp\WP\Nginx {
435
  }
436
 
437
  private function _purge_homepage() {
 
 
 
 
 
 
 
 
 
 
 
438
 
439
- $homepage_url = trailingslashit( home_url() );
440
-
441
- $this->log( sprintf( __( "Purging homepage '%s'", "nginx-helper" ), $homepage_url ) );
442
  $this->purgeUrl( $homepage_url );
443
 
444
  return true;
102
  $this->log( "Function purgePost BEGIN ===" );
103
 
104
  if ( $rt_wp_nginx_helper->options[ 'purge_homepage_on_edit' ] == 1 ) {
105
+ $this->_purge_homepage();
 
 
 
106
  }
107
 
108
 
204
  function purgeUrl( $url, $feed = true ) {
205
 
206
  global $rt_wp_nginx_helper;
207
+
208
+ $url = trailingslashit( $url );
209
 
210
  $this->log( "- Purging URL | " . $url );
211
 
434
  }
435
 
436
  private function _purge_homepage() {
437
+ // WPML installetd?
438
+ if ( function_exists('icl_get_home_url') )
439
+ {
440
+ $homepage_url = trailingslashit( icl_get_home_url() );
441
+ $this->log( sprintf( __( "Purging homepage (WPML) '%s'", "nginx-helper" ), $homepage_url ) );
442
+ }
443
+ else
444
+ {
445
+ $homepage_url = trailingslashit( home_url() );
446
+ $this->log( sprintf( __( "Purging homepage '%s'", "nginx-helper" ), $homepage_url ) );
447
+ }
448
 
 
 
 
449
  $this->purgeUrl( $homepage_url );
450
 
451
  return true;
readme.txt CHANGED
@@ -1,14 +1,14 @@
1
  === Nginx Helper ===
2
- Contributors: rtcamp, rahul286, saurabhshukla, manishsongirkar36, faishal, desaiuditd, darren-slatten, jk3us, daankortenbach, telofy, pjv, llonchj, jinnko, weskoop, bcole808, gungeekatx, rohanveer, chandrapatel, gagan0123, ravanh, michaelbeil, samedwards
3
  Tags: nginx, cache, purge, nginx map, nginx cache, maps, fastcgi, proxy, redis, redis-cache, rewrite, permalinks
4
  Requires at least: 3.0
5
- Tested up to: 4.5.2
6
- Stable tag: 1.9.7
7
  License: GPLv2 or later (of-course)
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
  Donate Link: http://rtcamp.com/donate/
10
 
11
- Cleans nginx's fastcgi/proxy cache or redis-cahce whenever a post is edited/published. Also does a few more things.
12
 
13
  == Description ==
14
 
@@ -114,6 +114,13 @@ Please post your problem in [our free support forum](http://community.rtcamp.com
114
 
115
  == Changelog ==
116
 
 
 
 
 
 
 
 
117
  = 1.9.7 =
118
  * Remove timestamp if cron or wp-cli [#114](https://github.com/rtCamp/nginx-helper/pull/114) - by [samedwards](https://profiles.wordpress.org/samedwards/)
119
  * Fixed notices and warnings.
@@ -326,6 +333,9 @@ Fix url escaping [#82](https://github.com/rtCamp/nginx-helper/pull/82) - by
326
 
327
  == Upgrade Notice ==
328
 
329
- = 1.9.7 =
330
- * Remove timestamp if cron or wp-cli [#114](https://github.com/rtCamp/nginx-helper/pull/114) - by [samedwards](https://profiles.wordpress.org/samedwards/)
 
 
 
331
  * Fixed notices and warnings.
1
  === Nginx Helper ===
2
+ Contributors: rtcamp, rahul286, saurabhshukla, manishsongirkar36, faishal, desaiuditd, darren-slatten, jk3us, daankortenbach, telofy, pjv, llonchj, jinnko, weskoop, bcole808, gungeekatx, rohanveer, chandrapatel, gagan0123, ravanh, michaelbeil, samedwards, niwreg, entr
3
  Tags: nginx, cache, purge, nginx map, nginx cache, maps, fastcgi, proxy, redis, redis-cache, rewrite, permalinks
4
  Requires at least: 3.0
5
+ Tested up to: 4.7
6
+ Stable tag: 1.9.8
7
  License: GPLv2 or later (of-course)
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
  Donate Link: http://rtcamp.com/donate/
10
 
11
+ Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also does a few more things.
12
 
13
  == Description ==
14
 
114
 
115
  == Changelog ==
116
 
117
+ = 1.9.8 =
118
+ * Fixed homepage cache cleared when WPML plugin used [#116](https://github.com/rtCamp/nginx-helper/pull/116) - by [Niwreg](https://profiles.wordpress.org/niwreg/)
119
+ * Fixed Purge Cache clears the whole Redis cache [#113](https://github.com/rtCamp/nginx-helper/issues/113) - by HansVanEijsden
120
+ * One log file for all site in WPMU.
121
+ * Single site Redis cache purge when click on Purge Cache button in WPMU [#122](https://github.com/rtCamp/nginx-helper/pull/122) - by Lars Støttrup Nielsen
122
+ * Fixed notices and warnings.
123
+
124
  = 1.9.7 =
125
  * Remove timestamp if cron or wp-cli [#114](https://github.com/rtCamp/nginx-helper/pull/114) - by [samedwards](https://profiles.wordpress.org/samedwards/)
126
  * Fixed notices and warnings.
333
 
334
  == Upgrade Notice ==
335
 
336
+ = 1.9.8 =
337
+ * Fixed homepage cache cleared when WPML plugin used [#116](https://github.com/rtCamp/nginx-helper/pull/116) - by [Niwreg](https://profiles.wordpress.org/niwreg/)
338
+ * Fixed Purge Cache clears the whole Redis cache [#113](https://github.com/rtCamp/nginx-helper/issues/113) - by HansVanEijsden
339
+ * One log file for all site in WPMU.
340
+ * Single site Redis cache purge when click on Purge Cache button in WPMU [#122](https://github.com/rtCamp/nginx-helper/pull/122) - by Lars Støttrup Nielsen
341
  * Fixed notices and warnings.
redis-purger.php CHANGED
@@ -109,10 +109,7 @@ namespace rtCamp\WP\Nginx {
109
  $this->log( "Function purgePost BEGIN ===" );
110
 
111
  if ( $rt_wp_nginx_helper->options['purge_homepage_on_edit'] == 1 ) {
112
- $homepage_url = trailingslashit( home_url() );
113
-
114
- $this->log( "Purging homepage '$homepage_url'" );
115
- $this->purgeUrl( $homepage_url );
116
  }
117
 
118
 
@@ -214,13 +211,19 @@ namespace rtCamp\WP\Nginx {
214
  function purgeUrl( $url, $feed = true )
215
  {
216
  global $rt_wp_nginx_helper;
217
-
 
 
218
  $this->log( "- Purging URL | " . $url );
219
-
220
  $parse = parse_url( $url );
 
221
  $host = $rt_wp_nginx_helper->options['redis_hostname'];
 
222
  $prefix = $rt_wp_nginx_helper->options['redis_prefix'];
 
223
  $_url_purge_base = $prefix . $parse['scheme'] . 'GET' . $parse['host'] . $parse['path'];
 
224
  delete_single_key( $_url_purge_base );
225
  }
226
 
@@ -329,10 +332,18 @@ namespace rtCamp\WP\Nginx {
329
 
330
  private function _purge_homepage()
331
  {
 
 
 
 
 
 
 
 
 
 
 
332
 
333
- $homepage_url = trailingslashit( home_url() );
334
-
335
- $this->log( sprintf( __( "Purging homepage '%s'", "nginx-helper" ), $homepage_url ) );
336
  $this->purgeUrl( $homepage_url );
337
 
338
  return true;
@@ -661,11 +672,22 @@ namespace rtCamp\WP\Nginx {
661
  function true_purge_all()
662
  {
663
  global $rt_wp_nginx_helper;
664
- $this->log( "* * * * *" );
665
- $this->log( "* Purged Everything!" );
666
- $this->log( "* * * * *" );
667
- //delete_multi_keys("*");
668
- delete_keys_by_wildcard("*");
 
 
 
 
 
 
 
 
 
 
 
669
  }
670
 
671
  function purge_urls()
@@ -705,7 +727,7 @@ namespace rtCamp\WP\Nginx {
705
  }
706
  }
707
  }
708
- }
709
  }
710
 
711
  }
109
  $this->log( "Function purgePost BEGIN ===" );
110
 
111
  if ( $rt_wp_nginx_helper->options['purge_homepage_on_edit'] == 1 ) {
112
+ $this->_purge_homepage();
 
 
 
113
  }
114
 
115
 
211
  function purgeUrl( $url, $feed = true )
212
  {
213
  global $rt_wp_nginx_helper;
214
+
215
+ $url = trailingslashit( $url );
216
+
217
  $this->log( "- Purging URL | " . $url );
218
+
219
  $parse = parse_url( $url );
220
+
221
  $host = $rt_wp_nginx_helper->options['redis_hostname'];
222
+
223
  $prefix = $rt_wp_nginx_helper->options['redis_prefix'];
224
+
225
  $_url_purge_base = $prefix . $parse['scheme'] . 'GET' . $parse['host'] . $parse['path'];
226
+
227
  delete_single_key( $_url_purge_base );
228
  }
229
 
332
 
333
  private function _purge_homepage()
334
  {
335
+ // WPML installetd?
336
+ if ( function_exists('icl_get_home_url') )
337
+ {
338
+ $homepage_url = trailingslashit( icl_get_home_url() );
339
+ $this->log( sprintf( __( "Purging homepage (WPML) '%s'", "nginx-helper" ), $homepage_url ) );
340
+ }
341
+ else
342
+ {
343
+ $homepage_url = trailingslashit( home_url() );
344
+ $this->log( sprintf( __( "Purging homepage '%s'", "nginx-helper" ), $homepage_url ) );
345
+ }
346
 
 
 
 
347
  $this->purgeUrl( $homepage_url );
348
 
349
  return true;
672
  function true_purge_all()
673
  {
674
  global $rt_wp_nginx_helper;
675
+ $prefix = trim( $rt_wp_nginx_helper->options['redis_prefix'] );
676
+
677
+ $this->log( '* * * * *' );
678
+
679
+ // If Purge Cache link click from network admin then purge all
680
+ if( is_network_admin() ) {
681
+ delete_keys_by_wildcard( $prefix . '*' );
682
+ $this->log( '* Purged Everything! * ' );
683
+ } else { // Else purge only site specific cache
684
+ $parse = wp_parse_url( get_site_url() );
685
+ $parse['path'] = empty( $parse['path'] ) ? '/' : $parse['path'];
686
+ delete_keys_by_wildcard( $prefix . $parse['scheme'] . 'GET' . $parse['host'] . $parse['path'] . '*' );
687
+ $this->log( '* ' . get_site_url() . ' Purged! * ' );
688
+ }
689
+
690
+ $this->log( '* * * * *' );
691
  }
692
 
693
  function purge_urls()
727
  }
728
  }
729
  }
730
+ }
731
  }
732
 
733
  }