Skip to content

Commit cfccc36

Browse files
phpcs error resolved, code refactoring and added new functionalities from master
1 parent 83f6a0b commit cfccc36

23 files changed

+892
-291
lines changed

README.md

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Nginx Helper #
22
**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
33

4-
**Tags:** nginx, cache, purge, nginx map, nginx cache, maps, fastcgi, proxy, redis, redis-cache, rewrite, permalinks
5-
**Requires at least:** 3.0
6-
**Tested up to:** 4.9.5
7-
**Stable tag:** 1.9.11
8-
**License:** GPLv2 or later (of-course)
9-
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html
10-
**Donate Link:** http://rtcamp.com/donate/
4+
**Tags:** nginx, cache, purge, nginx map, nginx cache, maps, fastcgi, proxy, redis, redis-cache, rewrite, permalinks
5+
**Requires at least:** 3.0
6+
**Tested up to:** 4.9.8
7+
**Stable tag:** 1.9.12
8+
**License:** GPLv2 or later (of-course)
9+
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html
10+
**Donate Link:** http://rtcamp.com/donate/
1111

1212
Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also does a few more things.
1313

@@ -94,6 +94,21 @@ To purge a page immediately, follow these instructions:
9494
* Needless to say, this won't work, if you have a page or taxonomy called 'purge'.
9595

9696

97+
### FAQ - Nginx Redis Cache ###
98+
99+
**Q. Can I override the redis hostname, port and prefix?**
100+
101+
Yes, you can force override the redis hostname, port or prefix by defining constant in wp-config.php. For example:
102+
103+
```
104+
define( 'RT_WP_NGINX_HELPER_REDIS_HOSTNAME', '10.0.0.1' );
105+
106+
define( 'RT_WP_NGINX_HELPER_REDIS_PORT', '6000' );
107+
108+
define( 'RT_WP_NGINX_HELPER_REDIS_PREFIX', 'page-cache:' );
109+
```
110+
111+
97112
### FAQ - Nginx Map ###
98113

99114
**Q. My multisite already uses `WPMU_ACCEL_REDIRECT`. Do I still need Nginx Map?**
@@ -119,6 +134,9 @@ Please post your problem in [our free support forum](http://community.rtcamp.com
119134

120135
## Changelog ##
121136

137+
### 1.9.12 ###
138+
* 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)
139+
122140
### 1.9.11 ###
123141
* Fixed issue where permalinks without trailing slash does not purging [#124](https://github.com/rtCamp/nginx-helper/issues/124) - by Patrick
124142
* Check whether role exist or not before removing capability. [#134](https://github.com/rtCamp/nginx-helper/pull/134) - by [1gor](https://github.com/1gor)
@@ -349,6 +367,5 @@ Fix url escaping [#82](https://github.com/rtCamp/nginx-helper/pull/82) - by
349367

350368
## Upgrade Notice ##
351369

352-
### 1.9.11 ###
353-
* Fixed issue where permalinks without trailing slash does not purging [#124](https://github.com/rtCamp/nginx-helper/issues/124) - by Patrick
354-
* Check whether role exist or not before removing capability. [#134](https://github.com/rtCamp/nginx-helper/pull/134) - by [1gor](https://github.com/1gor)
370+
### 1.9.12 ###
371+
* 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)

admin/class-fastcgi-purger.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class FastCGI_Purger extends Purger {
2424
* @param string $url URL.
2525
* @param bool $feed Weather it is feed or not.
2626
*/
27-
public function purgeUrl( $url, $feed = true ) {
27+
public function purge_url( $url, $feed = true ) {
2828

2929
global $nginx_helper_admin;
3030

@@ -49,16 +49,17 @@ public function purgeUrl( $url, $feed = true ) {
4949
$this->_delete_cache_file_for( $_url_purge );
5050

5151
if ( $feed ) {
52+
5253
$feed_url = rtrim( $_url_purge_base, '/' ) . '/feed/';
5354
$this->_delete_cache_file_for( $feed_url );
5455
$this->_delete_cache_file_for( $feed_url . 'atom/' );
5556
$this->_delete_cache_file_for( $feed_url . 'rdf/' );
57+
5658
}
5759
break;
5860

5961
case 'get_request':
60-
// Go to default case
61-
62+
// Go to default case.
6263
default:
6364
$_url_purge_base = $parse['scheme'] . '://' . $parse['host'] . '/purge' . $parse['path'];
6465
$_url_purge = $_url_purge_base;
@@ -86,7 +87,7 @@ public function purgeUrl( $url, $feed = true ) {
8687
/**
8788
* Function to custom purge urls.
8889
*/
89-
public function customPurgeUrls() {
90+
public function custom_purge_urls() {
9091

9192
global $nginx_helper_admin;
9293

@@ -95,7 +96,7 @@ public function customPurgeUrls() {
9596
$purge_urls = isset( $nginx_helper_admin->options['purge_url'] ) && ! empty( $nginx_helper_admin->options['purge_url'] ) ?
9697
explode( "\r\n", $nginx_helper_admin->options['purge_url'] ) : array();
9798

98-
// Allow plugins/themes to modify/extend urls. Pass urls array in first parameter, second says if wildcards are allowed
99+
// Allow plugins/themes to modify/extend urls. Pass urls array in first parameter, second says if wildcards are allowed.
99100
$purge_urls = apply_filters( 'rt_nginx_helper_purge_urls', $purge_urls, false );
100101

101102
switch ( $nginx_helper_admin->options['purge_method'] ) {
@@ -123,8 +124,7 @@ public function customPurgeUrls() {
123124
break;
124125

125126
case 'get_request':
126-
// Go to default case
127-
127+
// Go to default case.
128128
default:
129129
$_url_purge_base = $parse['scheme'] . '://' . $parse['host'] . '/purge';
130130

@@ -154,9 +154,9 @@ public function customPurgeUrls() {
154154
/**
155155
* Purge everything.
156156
*/
157-
public function purgeAll() {
157+
public function purge_all() {
158158

159-
$this->unlinkRecursive( RT_WP_NGINX_HELPER_CACHE_PATH, false );
159+
$this->unlink_recursive( RT_WP_NGINX_HELPER_CACHE_PATH, false );
160160
$this->log( '* * * * *' );
161161
$this->log( '* Purged Everything!' );
162162
$this->log( '* * * * *' );

0 commit comments

Comments
 (0)