Nginx Helper - Version 2.0.2

Version Description

  • Fix undefined error when we install the plugin for the first time and if Redis is not available. #162 - by Joel-James
  • Remove extra spacing for nginx map section. #169 - by ShashwatMittal
  • Purge Cache menu in front-end admibar now purge current page. #173 - by imranhsayed
  • Fix issue where cache is not cleared when page is swiched from publish to draft. #174 - by imranhsayed
  • Fix an issue where custom purge url option does not show newlines when using multiple urls. #184 - by mist-webit
Download this release

Release Info

Developer chandrapatel
Plugin Icon 128x128 Nginx Helper
Version 2.0.2
Comparing to
See all releases

Code changes from version 2.0.1 to 2.0.2

admin/class-nginx-helper-admin.php CHANGED
@@ -201,10 +201,18 @@ class Nginx_Helper_Admin {
201
  return;
202
  }
203
 
 
 
 
 
 
 
 
 
204
  $purge_url = add_query_arg(
205
  array(
206
  'nginx_helper_action' => 'purge',
207
- 'nginx_helper_urls' => 'all',
208
  )
209
  );
210
 
@@ -213,9 +221,9 @@ class Nginx_Helper_Admin {
213
  $wp_admin_bar->add_menu(
214
  array(
215
  'id' => 'nginx-helper-purge-all',
216
- 'title' => __( 'Purge Cache', 'nginx-helper' ),
217
  'href' => $nonced_url,
218
- 'meta' => array( 'title' => __( 'Purge Cache', 'nginx-helper' ) ),
219
  )
220
  );
221
 
@@ -262,6 +270,7 @@ class Nginx_Helper_Admin {
262
  'redis_port' => '6379',
263
  'redis_prefix' => 'nginx-cache:',
264
  'purge_url' => '',
 
265
  );
266
 
267
  }
@@ -641,12 +650,14 @@ class Nginx_Helper_Admin {
641
 
642
  /**
643
  * Purge all urls.
 
 
644
  *
645
  * @global object $nginx_purger
646
  */
647
  public function purge_all() {
648
 
649
- global $nginx_purger;
650
 
651
  $method = filter_input( INPUT_SERVER, 'REQUEST_METHOD', FILTER_SANITIZE_STRING );
652
 
@@ -673,13 +684,26 @@ class Nginx_Helper_Admin {
673
  }
674
 
675
  check_admin_referer( 'nginx_helper-purge_all' );
 
 
 
 
 
 
 
 
 
 
676
  switch ( $action ) {
677
  case 'purge':
678
  $nginx_purger->purge_all();
679
  break;
 
 
 
680
  }
681
 
682
- wp_redirect( esc_url_raw( add_query_arg( array( 'nginx_helper_action' => 'done' ) ) ) );
683
  exit();
684
 
685
  }
201
  return;
202
  }
203
 
204
+ if ( is_admin() ) {
205
+ $nginx_helper_urls = 'all';
206
+ $link_title = __( 'Purge Cache', 'nginx-helper' );
207
+ } else {
208
+ $nginx_helper_urls = 'current-url';
209
+ $link_title = __( 'Purge Current Page', 'nginx-helper' );
210
+ }
211
+
212
  $purge_url = add_query_arg(
213
  array(
214
  'nginx_helper_action' => 'purge',
215
+ 'nginx_helper_urls' => $nginx_helper_urls,
216
  )
217
  );
218
 
221
  $wp_admin_bar->add_menu(
222
  array(
223
  'id' => 'nginx-helper-purge-all',
224
+ 'title' => $link_title,
225
  'href' => $nonced_url,
226
+ 'meta' => array( 'title' => $link_title ),
227
  )
228
  );
229
 
270
  'redis_port' => '6379',
271
  'redis_prefix' => 'nginx-cache:',
272
  'purge_url' => '',
273
+ 'redis_enabled_by_constant' => 0,
274
  );
275
 
276
  }
650
 
651
  /**
652
  * Purge all urls.
653
+ * Purge current page cache when purging is requested from front
654
+ * and all urls when requested from admin dashboard.
655
  *
656
  * @global object $nginx_purger
657
  */
658
  public function purge_all() {
659
 
660
+ global $nginx_purger, $wp;
661
 
662
  $method = filter_input( INPUT_SERVER, 'REQUEST_METHOD', FILTER_SANITIZE_STRING );
663
 
684
  }
685
 
686
  check_admin_referer( 'nginx_helper-purge_all' );
687
+
688
+ $current_url = user_trailingslashit( home_url( $wp->request ) );
689
+
690
+ if ( ! is_admin() ) {
691
+ $action = 'purge_current_page';
692
+ $redirect_url = $current_url;
693
+ } else {
694
+ $redirect_url = add_query_arg( array( 'nginx_helper_action' => 'done' ) );
695
+ }
696
+
697
  switch ( $action ) {
698
  case 'purge':
699
  $nginx_purger->purge_all();
700
  break;
701
+ case 'purge_current_page':
702
+ $nginx_purger->purge_url( $current_url );
703
+ break;
704
  }
705
 
706
+ wp_redirect( esc_url_raw( $redirect_url ) );
707
  exit();
708
 
709
  }
admin/class-purger.php CHANGED
@@ -213,7 +213,29 @@ abstract class Purger {
213
  $this->log( "Purging custom post type '" . $_post_type . "' ( id " . $post_id . ', blog id ' . $blog_id . ' )' );
214
  }
215
 
216
- $url = get_permalink( $post_id );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
 
218
  if ( 'trash' === get_post_status( $post_id ) ) {
219
  $url = str_replace( '__trashed', '', $url );
213
  $this->log( "Purging custom post type '" . $_post_type . "' ( id " . $post_id . ', blog id ' . $blog_id . ' )' );
214
  }
215
 
216
+ $post_status = get_post_status( $post_id );
217
+
218
+ if ( 'publish' !== $post_status ) {
219
+
220
+ if ( ! function_exists( 'get_sample_permalink' ) ) {
221
+ require_once ABSPATH . '/wp-admin/includes/post.php';
222
+ }
223
+
224
+ $url = get_sample_permalink( $post_id );
225
+
226
+ if ( ! empty( $url[0] ) && ! empty( $url[1] ) ) {
227
+ $url = str_replace( '%postname%', $url[1], $url[0] );
228
+ } else {
229
+ $url = '';
230
+ }
231
+
232
+ } else {
233
+ $url = get_permalink( $post_id );
234
+ }
235
+
236
+ if ( empty( $url ) && ! is_array( $url ) ) {
237
+ return;
238
+ }
239
 
240
  if ( 'trash' === get_post_status( $post_id ) ) {
241
  $url = str_replace( '__trashed', '', $url );
admin/partials/nginx-helper-general-options.php CHANGED
@@ -519,7 +519,7 @@ if ( is_multisite() ) {
519
  <h4><?php esc_html_e( 'Custom Purge URL:', 'nginx-helper' ); ?></h4>
520
  </th>
521
  <td>
522
- <textarea rows="5"class="rt-purge_url" id="purge_url" name="purge_url"><?php echo esc_url( $nginx_helper_admin->options['purge_url'] ); ?></textarea>
523
  <p class="description">
524
  Add one URL per line. URL should not contain domain name.
525
  <br>
@@ -611,9 +611,7 @@ if ( is_network_admin() ) {
611
  ?>
612
  </th>
613
  <td>
614
- <pre>
615
- <?php echo esc_url( $log_path . 'map.conf' ); ?>
616
- </pre>
617
  </td>
618
  </tr>
619
  <tr>
519
  <h4><?php esc_html_e( 'Custom Purge URL:', 'nginx-helper' ); ?></h4>
520
  </th>
521
  <td>
522
+ <textarea rows="5"class="rt-purge_url" id="purge_url" name="purge_url"><?php echo esc_textarea( $nginx_helper_admin->options['purge_url'] ); ?></textarea>
523
  <p class="description">
524
  Add one URL per line. URL should not contain domain name.
525
  <br>
611
  ?>
612
  </th>
613
  <td>
614
+ <pre><?php echo esc_url( $log_path . 'map.conf' ); ?></pre>
 
 
615
  </td>
616
  </tr>
617
  <tr>
includes/class-nginx-helper.php CHANGED
@@ -221,7 +221,7 @@ class Nginx_Helper {
221
  $this->loader->add_action( 'edit_term', $nginx_purger, 'purge_on_term_taxonomy_edited', 20, 3 );
222
  $this->loader->add_action( 'delete_term', $nginx_purger, 'purge_on_term_taxonomy_edited', 20, 3 );
223
  $this->loader->add_action( 'check_ajax_referer', $nginx_purger, 'purge_on_check_ajax_referer', 20 );
224
- $this->loader->add_action( 'admin_init', $nginx_helper_admin, 'purge_all' );
225
 
226
  // expose action to allow other plugins to purge the cache.
227
  $this->loader->add_action( 'rt_nginx_helper_purge_all', $nginx_purger, 'purge_all' );
221
  $this->loader->add_action( 'edit_term', $nginx_purger, 'purge_on_term_taxonomy_edited', 20, 3 );
222
  $this->loader->add_action( 'delete_term', $nginx_purger, 'purge_on_term_taxonomy_edited', 20, 3 );
223
  $this->loader->add_action( 'check_ajax_referer', $nginx_purger, 'purge_on_check_ajax_referer', 20 );
224
+ $this->loader->add_action( 'admin_bar_init', $nginx_helper_admin, 'purge_all' );
225
 
226
  // expose action to allow other plugins to purge the cache.
227
  $this->loader->add_action( 'rt_nginx_helper_purge_all', $nginx_purger, 'purge_all' );
nginx-helper.php CHANGED
@@ -3,13 +3,13 @@
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 few more things.
6
- * Version: 2.0.1
7
  * Author: rtCamp
8
  * Author URI: https://rtcamp.com
9
  * Text Domain: nginx-helper
10
  * Domain Path: /languages
11
  * Requires at least: 3.0
12
- * Tested up to: 4.9.8
13
  *
14
  * @link https://rtcamp.com/nginx-helper/
15
  * @since 2.0.0
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 few more things.
6
+ * Version: 2.0.2
7
  * Author: rtCamp
8
  * Author URI: https://rtcamp.com
9
  * Text Domain: nginx-helper
10
  * Domain Path: /languages
11
  * Requires at least: 3.0
12
+ * Tested up to: 5.1
13
  *
14
  * @link https://rtcamp.com/nginx-helper/
15
  * @since 2.0.0
readme.txt CHANGED
@@ -1,12 +1,12 @@
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, nuvoPoint, iam404, rittesh.patel, vishalkakadiya, BhargavBhandari90, vincent-lu, murrayjbrown, bryant1410, 1gor, matt-h, pySilver, johan-chassaing, dotsam, sanketio, petenelson, nathanielks, rigagoogoo, dslatten, jinschoi, kelin1003, vaishuagola27, rahulsprajapati, Joel-James, utkarshpatel
3
  Donate Link: http://rtcamp.com/donate/
4
  Tags: nginx, cache, purge, nginx map, nginx cache, maps, fastcgi, proxy, redis, redis-cache, rewrite, permalinks
5
  License: GPLv2 or later (of-course)
6
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
  Requires at least: 3.0
8
- Tested up to: 4.9.8
9
- Stable tag: 2.0.1
10
 
11
  Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also does a few more things.
12
 
@@ -127,6 +127,13 @@ Please post your problem in [our free support forum](http://community.rtcamp.com
127
 
128
  == Changelog ==
129
 
 
 
 
 
 
 
 
130
  = 2.0.1 =
131
  * Fix settings url for multisite: use network_admin_url to get network correct settings url. [#163](https://github.com/rtCamp/nginx-helper/pull/163) - by [Joel-James](https://github.com/Joel-James)
132
  * Fix php error with arbitrary statement in empty - Prior to PHP 5.5. [#165](https://github.com/rtCamp/nginx-helper/pull/165) - by [PatelUtkarsh](https://github.com/PatelUtkarsh)
@@ -370,5 +377,9 @@ Fix url escaping [#82](https://github.com/rtCamp/nginx-helper/pull/82) - by
370
 
371
  == Upgrade Notice ==
372
 
373
- = 1.9.12 =
374
- * Allow override Redis host/port/prefix by defining constant in wp-config.php [#152](https://github.com/rtCamp/nginx-helper/pull/152) - by [vincent-lu](https://github.com/vincent-lu)
 
 
 
 
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, nuvoPoint, iam404, rittesh.patel, vishalkakadiya, BhargavBhandari90, vincent-lu, murrayjbrown, bryant1410, 1gor, matt-h, pySilver, johan-chassaing, dotsam, sanketio, petenelson, nathanielks, rigagoogoo, dslatten, jinschoi, kelin1003, vaishuagola27, rahulsprajapati, Joel-James, utkarshpatel, gsayed786, shashwatmittal
3
  Donate Link: http://rtcamp.com/donate/
4
  Tags: nginx, cache, purge, nginx map, nginx cache, maps, fastcgi, proxy, redis, redis-cache, rewrite, permalinks
5
  License: GPLv2 or later (of-course)
6
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
  Requires at least: 3.0
8
+ Tested up to: 5.1
9
+ Stable tag: 2.0.2
10
 
11
  Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also does a few more things.
12
 
127
 
128
  == Changelog ==
129
 
130
+ = 2.0.2 =
131
+ * Fix undefined error when we install the plugin for the first time and if Redis is not available. [#162](https://github.com/rtCamp/nginx-helper/pull/162) - by [Joel-James](https://github.com/Joel-James)
132
+ * Remove extra spacing for nginx map section. [#169](https://github.com/rtCamp/nginx-helper/pull/169) - by [ShashwatMittal](https://github.com/ShashwatMittal)
133
+ * Purge Cache menu in front-end admibar now purge current page. [#173](https://github.com/rtCamp/nginx-helper/pull/173) - by [imranhsayed](https://github.com/imranhsayed)
134
+ * Fix issue where cache is not cleared when page is swiched from publish to draft. [#174](https://github.com/rtCamp/nginx-helper/pull/174) - by [imranhsayed](https://github.com/imranhsayed)
135
+ * Fix an issue where custom purge url option does not show newlines when using multiple urls. [#184](https://github.com/rtCamp/nginx-helper/issues/184) - by [mist-webit](https://github.com/mist-webit)
136
+
137
  = 2.0.1 =
138
  * Fix settings url for multisite: use network_admin_url to get network correct settings url. [#163](https://github.com/rtCamp/nginx-helper/pull/163) - by [Joel-James](https://github.com/Joel-James)
139
  * Fix php error with arbitrary statement in empty - Prior to PHP 5.5. [#165](https://github.com/rtCamp/nginx-helper/pull/165) - by [PatelUtkarsh](https://github.com/PatelUtkarsh)
377
 
378
  == Upgrade Notice ==
379
 
380
+ = 2.0.2 =
381
+ * Fix undefined error when we install the plugin for the first time and if Redis is not available. [#162](https://github.com/rtCamp/nginx-helper/pull/162) - by [Joel-James](https://github.com/Joel-James)
382
+ * Remove extra spacing for nginx map section. [#169](https://github.com/rtCamp/nginx-helper/pull/169) - by [ShashwatMittal](https://github.com/ShashwatMittal)
383
+ * Purge Cache menu in front-end admibar now purge current page. [#173](https://github.com/rtCamp/nginx-helper/pull/173) - by [imranhsayed](https://github.com/imranhsayed)
384
+ * Fix issue where cache is not cleared when page is swiched from publish to draft. [#174](https://github.com/rtCamp/nginx-helper/pull/174) - by [imranhsayed](https://github.com/imranhsayed)
385
+ * Fix an issue where custom purge url option does not show newlines when using multiple urls. [#184](https://github.com/rtCamp/nginx-helper/issues/184) - by [mist-webit](https://github.com/mist-webit)