Nginx Helper - Version 1.9.12

Version Description

  • Allow override Redis host/port/prefix by defining constant in wp-config.php #152 - by vincent-lu
Download this release

Release Info

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

Code changes from version 1.9.11 to 1.9.12

admin/admin.php CHANGED
@@ -133,9 +133,7 @@ namespace rtCamp\WP\Nginx {
133
  wp_enqueue_style('rt-nginx-admin-css', plugin_dir_url(__FILE__) . 'assets/style.css');
134
 
135
  /* Load Plugin Scripts */
136
- $admin_js = trailingslashit( site_url() ) . '?get_feeds=1';
137
  wp_enqueue_script( 'nginx-js', plugin_dir_url( __FILE__ ) . 'assets/nginx.js', '', '', true );
138
- wp_localize_script( 'nginx-js', 'news_url', $admin_js );
139
  }
140
  }
141
  }
133
  wp_enqueue_style('rt-nginx-admin-css', plugin_dir_url(__FILE__) . 'assets/style.css');
134
 
135
  /* Load Plugin Scripts */
 
136
  wp_enqueue_script( 'nginx-js', plugin_dir_url( __FILE__ ) . 'assets/nginx.js', '', '', true );
 
137
  }
138
  }
139
  }
admin/assets/nginx.js CHANGED
@@ -1,7 +1,7 @@
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
  }
1
  jQuery( document ).ready( function() {
2
  var news_section = jQuery( '#latest_news' );
3
  if ( news_section.length > 0 ) {
4
+ jQuery.get( ajaxurl, { action: 'rt_nginx_get_news' }, function( data ) {
5
  news_section.find( '.inside' ).html( data );
6
  } );
7
  }
admin/lib/nginx-general.php CHANGED
@@ -52,8 +52,8 @@ namespace rtCamp\WP\Nginx {
52
  $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;
53
 
54
  $rt_wp_nginx_helper->options['purge_method'] = ( isset( $_POST['purge_method'] ) ) ? $_POST['purge_method'] : 'get_request';
55
-
56
- $rt_wp_nginx_helper->options['purge_url'] = ( isset( $_POST['purge_url'] ) && ! empty( $_POST['purge_url'] ) ) ? esc_textarea( $_POST['purge_url'] ) : '';
57
  }
58
  if ( isset( $_POST['cache_method'] ) && $_POST['cache_method'] = "enable_redis" ) {
59
  $rt_wp_nginx_helper->options['redis_hostname'] = ( isset( $_POST['redis_hostname'] ) ) ? $_POST['redis_hostname'] : '127.0.0.1';
@@ -173,23 +173,34 @@ namespace rtCamp\WP\Nginx {
173
  $redis_hostname = ( empty( $rt_wp_nginx_helper->options['redis_hostname'] ) ) ? '127.0.0.1' : $rt_wp_nginx_helper->options['redis_hostname'];
174
  $redis_port = ( empty( $rt_wp_nginx_helper->options['redis_port'] ) ) ? '6379' : $rt_wp_nginx_helper->options['redis_port'];
175
  $redis_prefix = ( empty( $rt_wp_nginx_helper->options['redis_prefix'] ) ) ? 'nginx-cache:' : $rt_wp_nginx_helper->options['redis_prefix'];
 
 
 
 
 
 
 
 
176
  ?>
177
  <tr>
178
  <th><label for="redis_hostname"><?php _e( 'Hostname', 'nginx-helper' ); ?></label></th>
179
  <td>
180
- <input id="redis_hostname" class="medium-text" type="text" name="redis_hostname" value="<?php echo $redis_hostname; ?>" />
 
181
  </td>
182
  </tr>
183
  <tr>
184
  <th><label for="redis_port"><?php _e( 'Port', 'nginx-helper' ); ?></label></th>
185
  <td>
186
- <input id="redis_port" class="medium-text" type="text" name="redis_port" value="<?php echo $redis_port; ?>" />
 
187
  </td>
188
  </tr>
189
  <tr>
190
  <th><label for="redis_prefix"><?php _e( 'Prefix', 'nginx-helper' ); ?></label></th>
191
  <td>
192
- <input id="redis_prefix" class="medium-text" type="text" name="redis_prefix" value="<?php echo $redis_prefix; ?>" />
 
193
  </td>
194
  </tr>
195
  </table>
@@ -405,7 +416,7 @@ namespace rtCamp\WP\Nginx {
405
  $log = fopen( $path . 'nginx.log', 'w' );
406
  fclose( $log );
407
  }
408
-
409
  if ( !is_writable( $path . 'nginx.log' ) ) {
410
  ?>
411
  <span class="error fade" style="display : block"><p><?php printf( __( 'Can\'t write on log file.<br /><br />Check you have write permission on <strong>%s</strong>', 'nginx-helper' ), $rt_wp_nginx_helper->functional_asset_path() . 'nginx.log' ); ?></p></span><?php }
52
  $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;
53
 
54
  $rt_wp_nginx_helper->options['purge_method'] = ( isset( $_POST['purge_method'] ) ) ? $_POST['purge_method'] : 'get_request';
55
+
56
+ $rt_wp_nginx_helper->options['purge_url'] = ( isset( $_POST['purge_url'] ) && ! empty( $_POST['purge_url'] ) ) ? esc_textarea( $_POST['purge_url'] ) : '';
57
  }
58
  if ( isset( $_POST['cache_method'] ) && $_POST['cache_method'] = "enable_redis" ) {
59
  $rt_wp_nginx_helper->options['redis_hostname'] = ( isset( $_POST['redis_hostname'] ) ) ? $_POST['redis_hostname'] : '127.0.0.1';
173
  $redis_hostname = ( empty( $rt_wp_nginx_helper->options['redis_hostname'] ) ) ? '127.0.0.1' : $rt_wp_nginx_helper->options['redis_hostname'];
174
  $redis_port = ( empty( $rt_wp_nginx_helper->options['redis_port'] ) ) ? '6379' : $rt_wp_nginx_helper->options['redis_port'];
175
  $redis_prefix = ( empty( $rt_wp_nginx_helper->options['redis_prefix'] ) ) ? 'nginx-cache:' : $rt_wp_nginx_helper->options['redis_prefix'];
176
+
177
+ $redis_hostname = defined('RT_WP_NGINX_HELPER_REDIS_HOSTNAME') ? RT_WP_NGINX_HELPER_REDIS_HOSTNAME : $redis_hostname;
178
+ $redis_port = defined('RT_WP_NGINX_HELPER_REDIS_PORT') ? RT_WP_NGINX_HELPER_REDIS_PORT : $redis_port;
179
+ $redis_prefix = defined('RT_WP_NGINX_HELPER_REDIS_PREFIX') ? RT_WP_NGINX_HELPER_REDIS_PREFIX : $redis_prefix;
180
+
181
+ $redis_hostname_readonly = defined('RT_WP_NGINX_HELPER_REDIS_HOSTNAME') ? 'readonly="readonly"' : '';
182
+ $redis_port_readonly = defined('RT_WP_NGINX_HELPER_REDIS_PORT') ? 'readonly="readonly"' : '';
183
+ $redis_prefix_readonly = defined('RT_WP_NGINX_HELPER_REDIS_PREFIX') ? 'readonly="readonly"' : '';
184
  ?>
185
  <tr>
186
  <th><label for="redis_hostname"><?php _e( 'Hostname', 'nginx-helper' ); ?></label></th>
187
  <td>
188
+ <input id="redis_hostname" class="medium-text" type="text" name="redis_hostname" value="<?php echo $redis_hostname; ?>" <?php echo $redis_hostname_readonly; ?> />
189
+ <?php if ($redis_hostname_readonly) echo '<p class="description">Overridden by global define</p>'; ?>
190
  </td>
191
  </tr>
192
  <tr>
193
  <th><label for="redis_port"><?php _e( 'Port', 'nginx-helper' ); ?></label></th>
194
  <td>
195
+ <input id="redis_port" class="medium-text" type="text" name="redis_port" value="<?php echo $redis_port; ?>" <?php echo $redis_port_readonly; ?> />
196
+ <?php if ($redis_port_readonly) echo '<p class="description">Overridden by global define</p>'; ?>
197
  </td>
198
  </tr>
199
  <tr>
200
  <th><label for="redis_prefix"><?php _e( 'Prefix', 'nginx-helper' ); ?></label></th>
201
  <td>
202
+ <input id="redis_prefix" class="medium-text" type="text" name="redis_prefix" value="<?php echo $redis_prefix; ?>" <?php echo $redis_prefix_readonly; ?> />
203
+ <?php if ($redis_prefix_readonly) echo '<p class="description">Overridden by global define</p>'; ?>
204
  </td>
205
  </tr>
206
  </table>
416
  $log = fopen( $path . 'nginx.log', 'w' );
417
  fclose( $log );
418
  }
419
+
420
  if ( !is_writable( $path . 'nginx.log' ) ) {
421
  ?>
422
  <span class="error fade" style="display : block"><p><?php printf( __( 'Can\'t write on log file.<br /><br />Check you have write permission on <strong>%s</strong>', 'nginx-helper' ), $rt_wp_nginx_helper->functional_asset_path() . 'nginx.log' ); ?></p></span><?php }
includes/redis-delete.php CHANGED
@@ -5,8 +5,9 @@
5
 
6
  global $myredis, $rt_wp_nginx_helper, $redis_api, $lua, $rt_wp_nginx_purger;
7
 
8
- $host = $rt_wp_nginx_helper->options['redis_hostname'];
9
- $port = $rt_wp_nginx_helper->options['redis_port'];
 
10
  $redis_api = '';
11
 
12
  if ( class_exists( 'Redis' ) ) { // Use PHP5-Redis if installed.
@@ -14,9 +15,9 @@ if ( class_exists( 'Redis' ) ) { // Use PHP5-Redis if installed.
14
  $myredis = new Redis();
15
  $myredis->connect( $host, $port, 5 );
16
  $redis_api = 'php-redis';
17
- } catch ( Exception $e ) {
18
  if( isset($rt_wp_nginx_purger) && !empty($rt_wp_nginx_purger) ) {
19
- $rt_wp_nginx_purger->log( $e->getMessage(), 'ERROR' );
20
  }
21
  }
22
  } else {
@@ -24,7 +25,7 @@ if ( class_exists( 'Redis' ) ) { // Use PHP5-Redis if installed.
24
  require_once 'predis.php';
25
  }
26
  Predis\Autoloader::register();
27
-
28
  //redis server parameter
29
  $myredis = new Predis\Client( [
30
  'host' => $host,
@@ -34,9 +35,9 @@ if ( class_exists( 'Redis' ) ) { // Use PHP5-Redis if installed.
34
  try {
35
  $myredis->connect();
36
  $redis_api = 'predis';
37
- } catch ( Exception $e ) {
38
  if( isset($rt_wp_nginx_purger) && !empty($rt_wp_nginx_purger) ) {
39
- $rt_wp_nginx_purger->log( $e->getMessage(), 'ERROR' );
40
  }
41
  }
42
  }
@@ -57,9 +58,9 @@ LUA;
57
  */
58
 
59
  function delete_multi_keys( $key )
60
- {
61
  global $myredis, $redis_api, $rt_wp_nginx_purger;
62
-
63
  try {
64
  if ( !empty( $myredis ) ) {
65
  $matching_keys = $myredis->keys( $key );
@@ -143,4 +144,4 @@ function delete_keys_by_wildcard( $pattern )
143
  } catch ( Exception $e ) { $rt_wp_nginx_purger->log( $e->getMessage(), 'ERROR' ); }
144
  }
145
 
146
- ?>
5
 
6
  global $myredis, $rt_wp_nginx_helper, $redis_api, $lua, $rt_wp_nginx_purger;
7
 
8
+ $host = defined( 'RT_WP_NGINX_HELPER_REDIS_HOSTNAME' ) ? RT_WP_NGINX_HELPER_REDIS_HOSTNAME : $rt_wp_nginx_helper->options['redis_hostname'];
9
+ $port = defined( 'RT_WP_NGINX_HELPER_REDIS_PORT' ) ? RT_WP_NGINX_HELPER_REDIS_PORT : $rt_wp_nginx_helper->options['redis_port'];
10
+
11
  $redis_api = '';
12
 
13
  if ( class_exists( 'Redis' ) ) { // Use PHP5-Redis if installed.
15
  $myredis = new Redis();
16
  $myredis->connect( $host, $port, 5 );
17
  $redis_api = 'php-redis';
18
+ } catch ( Exception $e ) {
19
  if( isset($rt_wp_nginx_purger) && !empty($rt_wp_nginx_purger) ) {
20
+ $rt_wp_nginx_purger->log( $e->getMessage(), 'ERROR' );
21
  }
22
  }
23
  } else {
25
  require_once 'predis.php';
26
  }
27
  Predis\Autoloader::register();
28
+
29
  //redis server parameter
30
  $myredis = new Predis\Client( [
31
  'host' => $host,
35
  try {
36
  $myredis->connect();
37
  $redis_api = 'predis';
38
+ } catch ( Exception $e ) {
39
  if( isset($rt_wp_nginx_purger) && !empty($rt_wp_nginx_purger) ) {
40
+ $rt_wp_nginx_purger->log( $e->getMessage(), 'ERROR' );
41
  }
42
  }
43
  }
58
  */
59
 
60
  function delete_multi_keys( $key )
61
+ {
62
  global $myredis, $redis_api, $rt_wp_nginx_purger;
63
+
64
  try {
65
  if ( !empty( $myredis ) ) {
66
  $matching_keys = $myredis->keys( $key );
144
  } catch ( Exception $e ) { $rt_wp_nginx_purger->log( $e->getMessage(), 'ERROR' ); }
145
  }
146
 
147
+ ?>
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.11
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.9.5
12
  *
13
  * @package nginx-helper
14
  */
@@ -401,44 +401,58 @@ namespace {
401
  add_filter( "plugin_action_links_" . plugin_basename( __FILE__ ), 'nginx_settings_link' );
402
  }
403
 
404
- function get_feeds( $feed_url = 'http://rtcamp.com/blog/feed/' )
405
- {
406
- // Get RSS Feed(s)
407
- require_once( ABSPATH . WPINC . '/feed.php' );
 
 
 
 
 
 
 
 
 
 
 
408
  $maxitems = 0;
 
409
  // Get a SimplePie feed object from the specified feed source.
410
- $rss = fetch_feed( $feed_url );
411
- if ( !is_wp_error( $rss ) ) { // Checks that the object is created correctly
 
 
 
412
  // Figure out how many total items there are, but limit it to 5.
413
  $maxitems = $rss->get_item_quantity( 5 );
414
 
415
  // Build an array of all the items, starting with element 0 (first element).
416
  $rss_items = $rss->get_items( 0, $maxitems );
417
  }
418
- ?>
419
- <ul role="list"><?php
420
- if ( $maxitems == 0 ) {
421
- echo '<li role="listitem">' . __( 'No items', 'nginx-helper' ) . '.</li>';
 
422
  } else {
423
  // Loop through each feed item and display each item as a hyperlink.
424
  foreach ( $rss_items as $item ) {
425
- ?>
426
  <li role="listitem">
427
- <a href='<?php echo $item->get_permalink(); ?>' title='<?php echo __( 'Posted ', 'nginx-helper' ) . $item->get_date( 'j F Y | g:i a' ); ?>'><?php echo $item->get_title(); ?></a>
428
- </li><?php
 
 
 
429
  }
430
  }
431
  ?>
432
- </ul><?php
 
 
433
  }
434
 
435
- function fetch_feeds()
436
- {
437
- if ( isset( $_GET['get_feeds'] ) && $_GET['get_feeds'] == '1' ) {
438
- get_feeds();
439
- die();
440
- }
441
- }
442
 
443
- add_action( 'init', 'fetch_feeds' );
444
  }
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.12
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.9.8
12
  *
13
  * @package nginx-helper
14
  */
401
  add_filter( "plugin_action_links_" . plugin_basename( __FILE__ ), 'nginx_settings_link' );
402
  }
403
 
404
+ /**
405
+ * Get latest news
406
+ *
407
+ * @return void
408
+ */
409
+ function rt_nginx_get_news() {
410
+
411
+ $is_rt_news_request = sanitize_text_field( filter_input( INPUT_GET, 'action' ) );
412
+
413
+ if ( empty( $is_rt_news_request ) || 'rt_nginx_get_news' !== $is_rt_news_request ) {
414
+ return;
415
+ }
416
+
417
+ require_once ABSPATH . WPINC . '/feed.php';
418
+
419
  $maxitems = 0;
420
+
421
  // Get a SimplePie feed object from the specified feed source.
422
+ $rss = fetch_feed( 'https://rtcamp.com/blog/feed/' );
423
+
424
+ // Checks that the object is created correctly.
425
+ if ( ! is_wp_error( $rss ) ) {
426
+
427
  // Figure out how many total items there are, but limit it to 5.
428
  $maxitems = $rss->get_item_quantity( 5 );
429
 
430
  // Build an array of all the items, starting with element 0 (first element).
431
  $rss_items = $rss->get_items( 0, $maxitems );
432
  }
433
+ ?>
434
+ <ul role="list">
435
+ <?php
436
+ if ( 0 === $maxitems ) {
437
+ echo '<li role="listitem">' . esc_html__( 'No items', 'nginx-helper' ) . '.</li>';
438
  } else {
439
  // Loop through each feed item and display each item as a hyperlink.
440
  foreach ( $rss_items as $item ) {
441
+ ?>
442
  <li role="listitem">
443
+ <a href='<?php echo esc_url( $item->get_permalink() ); ?>' title='<?php echo esc_attr__( 'Posted ', 'nginx-helper' ) . esc_attr( $item->get_date( 'j F Y | g:i a' ) ); ?>'>
444
+ <?php echo esc_html( $item->get_title() ); ?>
445
+ </a>
446
+ </li>
447
+ <?php
448
  }
449
  }
450
  ?>
451
+ </ul>
452
+ <?php
453
+ die();
454
  }
455
 
456
+ add_action( 'wp_ajax_rt_nginx_get_news', 'rt_nginx_get_news' );
 
 
 
 
 
 
457
 
 
458
  }
readme.txt CHANGED
@@ -5,8 +5,8 @@ Tags: nginx, cache, purge, nginx map, nginx cache, maps, fastcgi, proxy, redis,
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.5
9
- Stable tag: 1.9.11
10
 
11
  Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also does a few more things.
12
 
@@ -92,6 +92,19 @@ To purge a page immediately, follow these instructions:
92
  * Just open this in a browser and the page will be purged instantly.
93
  * Needless to say, this won't work, if you have a page or taxonomy called 'purge'.
94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
 
96
  = FAQ - Nginx Map =
97
 
@@ -114,6 +127,9 @@ Please post your problem in [our free support forum](http://community.rtcamp.com
114
 
115
  == Changelog ==
116
 
 
 
 
117
  = 1.9.11 =
118
  * Fixed issue where permalinks without trailing slash does not purging [#124](https://github.com/rtCamp/nginx-helper/issues/124) - by Patrick
119
  * Check whether role exist or not before removing capability. [#134](https://github.com/rtCamp/nginx-helper/pull/134) - by [1gor](https://github.com/1gor)
@@ -344,6 +360,5 @@ Fix url escaping [#82](https://github.com/rtCamp/nginx-helper/pull/82) - by
344
 
345
  == Upgrade Notice ==
346
 
347
- = 1.9.11 =
348
- * Fixed issue where permalinks without trailing slash does not purging [#124](https://github.com/rtCamp/nginx-helper/issues/124) - by Patrick
349
- * Check whether role exist or not before removing capability. [#134](https://github.com/rtCamp/nginx-helper/pull/134) - by [1gor](https://github.com/1gor)
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: 1.9.12
10
 
11
  Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also does a few more things.
12
 
92
  * Just open this in a browser and the page will be purged instantly.
93
  * Needless to say, this won't work, if you have a page or taxonomy called 'purge'.
94
 
95
+ = FAQ - Nginx Redis Cache =
96
+
97
+ **Q. Can I override the redis hostname, port and prefix?**
98
+
99
+ Yes, you can force override the redis hostname, port or prefix by defining constant in wp-config.php. For example:
100
+
101
+ ```
102
+ define('RT_WP_NGINX_HELPER_REDIS_HOSTNAME', '10.0.0.1');
103
+
104
+ define('RT_WP_NGINX_HELPER_REDIS_PORT', '6000');
105
+
106
+ define('RT_WP_NGINX_HELPER_REDIS_PREFIX', 'page-cache:');
107
+ ```
108
 
109
  = FAQ - Nginx Map =
110
 
127
 
128
  == Changelog ==
129
 
130
+ = 1.9.12 =
131
+ * 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)
132
+
133
  = 1.9.11 =
134
  * Fixed issue where permalinks without trailing slash does not purging [#124](https://github.com/rtCamp/nginx-helper/issues/124) - by Patrick
135
  * Check whether role exist or not before removing capability. [#134](https://github.com/rtCamp/nginx-helper/pull/134) - by [1gor](https://github.com/1gor)
360
 
361
  == Upgrade Notice ==
362
 
363
+ = 1.9.12 =
364
+ * 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)
 
redis-purger.php CHANGED
@@ -118,9 +118,9 @@ namespace rtCamp\WP\Nginx {
118
  } else {
119
  $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'] );
120
  }
121
-
122
  $this->purge_urls();
123
-
124
  $this->log( "Function purgePost END ^^^" );
125
  }
126
 
@@ -220,9 +220,9 @@ namespace rtCamp\WP\Nginx {
220
  $parse['path'] = '';
221
  }
222
 
223
- $host = $rt_wp_nginx_helper->options['redis_hostname'];
224
 
225
- $prefix = $rt_wp_nginx_helper->options['redis_prefix'];
226
 
227
  $_url_purge_base = $prefix . $parse['scheme'] . 'GET' . $parse['host'] . $parse['path'];
228
 
@@ -675,10 +675,12 @@ namespace rtCamp\WP\Nginx {
675
  function true_purge_all()
676
  {
677
  global $rt_wp_nginx_helper;
678
- $prefix = trim( $rt_wp_nginx_helper->options['redis_prefix'] );
679
-
 
 
680
  $this->log( '* * * * *' );
681
-
682
  // If Purge Cache link click from network admin then purge all
683
  if( is_network_admin() ) {
684
  delete_keys_by_wildcard( $prefix . '*' );
@@ -689,49 +691,51 @@ namespace rtCamp\WP\Nginx {
689
  delete_keys_by_wildcard( $prefix . $parse['scheme'] . 'GET' . $parse['host'] . $parse['path'] . '*' );
690
  $this->log( '* ' . get_home_url() . ' Purged! * ' );
691
  }
692
-
693
  $this->log( '* * * * *' );
694
  }
695
-
696
  function purge_urls()
697
  {
698
  global $rt_wp_nginx_helper;
699
-
700
  $parse = parse_url( site_url() );
701
- $host = $rt_wp_nginx_helper->options['redis_hostname'];
702
- $prefix = $rt_wp_nginx_helper->options['redis_prefix'];
 
 
703
  $_url_purge_base = $prefix . $parse['scheme'] . 'GET' . $parse['host'];
704
-
705
  $purge_urls = isset( $rt_wp_nginx_helper->options['purge_url'] ) && ! empty( $rt_wp_nginx_helper->options['purge_url'] ) ?
706
  explode( "\r\n", $rt_wp_nginx_helper->options['purge_url'] ) : array();
707
-
708
- // Allow plugins/themes to modify/extend urls. Pass urls array in first parameter, second says if wildcards are allowed
709
- $purge_urls = apply_filters('rt_nginx_helper_purge_urls', $purge_urls, true);
710
-
711
- if( is_array( $purge_urls ) && ! empty( $purge_urls ) ) {
712
  foreach ($purge_urls as $purge_url ) {
713
  $purge_url = trim( $purge_url );
714
-
715
  if( strpos( $purge_url, '*' ) === false ) {
716
  $purge_url = $_url_purge_base . $purge_url;
717
  $status = delete_single_key( $purge_url );
718
  if( $status ) {
719
- $this->log( "- Purge URL | " . $purge_url );
720
  } else {
721
- $this->log( "- Not Found | " . $purge_url, 'ERROR' );
722
  }
723
  } else {
724
  $purge_url = $_url_purge_base . $purge_url;
725
  $status = delete_keys_by_wildcard( $purge_url );
726
  if( $status ) {
727
- $this->log( "- Purge Wild Card URL | " . $purge_url . " | ". $status . " url purged" );
728
  } else {
729
- $this->log( "- Not Found | " . $purge_url, 'ERROR' );
730
  }
731
  }
732
  }
733
  }
734
  }
735
-
736
  }
737
  }
118
  } else {
119
  $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'] );
120
  }
121
+
122
  $this->purge_urls();
123
+
124
  $this->log( "Function purgePost END ^^^" );
125
  }
126
 
220
  $parse['path'] = '';
221
  }
222
 
223
+ $host = defined( 'RT_WP_NGINX_HELPER_REDIS_HOSTNAME' ) ? RT_WP_NGINX_HELPER_REDIS_HOSTNAME : $rt_wp_nginx_helper->options['redis_hostname'];
224
 
225
+ $prefix = defined( 'RT_WP_NGINX_HELPER_REDIS_PREFIX' ) ? RT_WP_NGINX_HELPER_REDIS_PREFIX : $rt_wp_nginx_helper->options['redis_prefix'];
226
 
227
  $_url_purge_base = $prefix . $parse['scheme'] . 'GET' . $parse['host'] . $parse['path'];
228
 
675
  function true_purge_all()
676
  {
677
  global $rt_wp_nginx_helper;
678
+
679
+ $prefix = defined( 'RT_WP_NGINX_HELPER_REDIS_PREFIX' ) ? RT_WP_NGINX_HELPER_REDIS_PREFIX : $rt_wp_nginx_helper->options['redis_prefix'];
680
+ $prefix = trim( $prefix );
681
+
682
  $this->log( '* * * * *' );
683
+
684
  // If Purge Cache link click from network admin then purge all
685
  if( is_network_admin() ) {
686
  delete_keys_by_wildcard( $prefix . '*' );
691
  delete_keys_by_wildcard( $prefix . $parse['scheme'] . 'GET' . $parse['host'] . $parse['path'] . '*' );
692
  $this->log( '* ' . get_home_url() . ' Purged! * ' );
693
  }
694
+
695
  $this->log( '* * * * *' );
696
  }
697
+
698
  function purge_urls()
699
  {
700
  global $rt_wp_nginx_helper;
701
+
702
  $parse = parse_url( site_url() );
703
+
704
+ $host = defined( 'RT_WP_NGINX_HELPER_REDIS_HOSTNAME' ) ? RT_WP_NGINX_HELPER_REDIS_HOSTNAME : $rt_wp_nginx_helper->options['redis_hostname'];
705
+ $prefix = defined( 'RT_WP_NGINX_HELPER_REDIS_PREFIX' ) ? RT_WP_NGINX_HELPER_REDIS_PREFIX : $rt_wp_nginx_helper->options['redis_prefix'];
706
+
707
  $_url_purge_base = $prefix . $parse['scheme'] . 'GET' . $parse['host'];
708
+
709
  $purge_urls = isset( $rt_wp_nginx_helper->options['purge_url'] ) && ! empty( $rt_wp_nginx_helper->options['purge_url'] ) ?
710
  explode( "\r\n", $rt_wp_nginx_helper->options['purge_url'] ) : array();
711
+
712
+ // Allow plugins/themes to modify/extend urls. Pass urls array in first parameter, second says if wildcards are allowed
713
+ $purge_urls = apply_filters('rt_nginx_helper_purge_urls', $purge_urls, true);
714
+
715
+ if( is_array( $purge_urls ) && ! empty( $purge_urls ) ) {
716
  foreach ($purge_urls as $purge_url ) {
717
  $purge_url = trim( $purge_url );
718
+
719
  if( strpos( $purge_url, '*' ) === false ) {
720
  $purge_url = $_url_purge_base . $purge_url;
721
  $status = delete_single_key( $purge_url );
722
  if( $status ) {
723
+ $this->log( "- Purge URL | " . $purge_url );
724
  } else {
725
+ $this->log( "- Not Found | " . $purge_url, 'ERROR' );
726
  }
727
  } else {
728
  $purge_url = $_url_purge_base . $purge_url;
729
  $status = delete_keys_by_wildcard( $purge_url );
730
  if( $status ) {
731
+ $this->log( "- Purge Wild Card URL | " . $purge_url . " | ". $status . " url purged" );
732
  } else {
733
+ $this->log( "- Not Found | " . $purge_url, 'ERROR' );
734
  }
735
  }
736
  }
737
  }
738
  }
739
+
740
  }
741
  }