Skip to content

Commit 4e98368

Browse files
committed
merge: fix conflicts
2 parents 2918b73 + 6271490 commit 4e98368

24 files changed

+1627
-412
lines changed

.github/ci/main.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function start_services() {
2626
# Create, setup and populate learn.rtcamp.com base site with data
2727
function create_and_configure_site () {
2828

29-
ee site create $SITE_NAME --wp --php74
29+
ee site create $SITE_NAME --wp --php74
3030
cd $SITE_ROOT/wp-content/plugins/
3131
rm -rf nginx-helper
3232
ls
@@ -36,7 +36,6 @@ function create_and_configure_site () {
3636
ls
3737
wp plugin activate nginx-helper --allow-root
3838
wp user create automation [email protected] --role=administrator --user_pass=automation --allow-root
39-
wp theme activate twentytwentyone --allow-root
4039
}
4140

4241

@@ -55,7 +54,7 @@ function build_package(){
5554
}
5655

5756
function install_playwright(){
58-
cd $GITHUB_WORKSPACE/tests/e2e-playwright
57+
cd $GITHUB_WORKSPACE/tests/e2e-playwright
5958
npx playwright install
6059
}
6160

@@ -96,4 +95,4 @@ function main() {
9695
run_playwright_tests
9796
}
9897

99-
main
98+
main

.github/workflows/create.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ jobs:
1515
EXCLUDE_LIST: .gitattributes .gitignore .travis.yml README.md deploy.sh readme.sh
1616
tests map.conf nginx.log wercker.yml vendor
1717
SLUG: nginx-helper
18-
WORDPRESS_PASSWORD: ${{ secrets.WORDPRESS_PASSWORD }}
19-
WORDPRESS_USERNAME: ${{ secrets.WORDPRESS_USERNAME }}
18+
WORDPRESS_PASSWORD: ${{ secrets.SVN_PASSWORD }}
19+
WORDPRESS_USERNAME: ${{ secrets.SVN_USERNAME }}

.github/workflows/e2e-test.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ name: End-to-End Tests
55
# Controls when the workflow will run
66
on:
77
# Triggers the workflow on push or pull request events but only for the main branch
8-
push:
9-
branches:
10-
- develop
11-
- master
12-
13-
pull_request:
14-
branches:
15-
- develop
16-
- master
8+
# push:
9+
# branches:
10+
# - develop
11+
# - master
12+
13+
# pull_request:
14+
# branches:
15+
# - develop
16+
# - master
1717

1818
# Allows you to run this workflow manually from the Actions tab
1919
workflow_dispatch:
@@ -23,14 +23,14 @@ jobs:
2323
# The type of runner that the job will run on
2424
name: Playwright Tests
2525
runs-on: ubuntu-latest
26-
env:
26+
env:
2727
TESRESULT_TOKEN: ${{ secrets.TESRESULT_TOKEN }}
2828
TOKEN: ${{ secrets.GITHUB_TOKEN }}
2929
SHA: ${{ github.event.pull_request.head.sha }}
3030
COMMIT_SHA: ${{ github.sha }}
3131
PR_NUMBER: ${{ github.event.pull_request.number }}
3232
working-directory: ./tests/e2e-playwright
33-
33+
3434
# Steps represent a sequence of tasks that will be executed as part of the job
3535
steps:
3636
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
@@ -52,7 +52,7 @@ jobs:
5252

5353
- name: Archive HTML Report on failure
5454
if: failure()
55-
uses: actions/upload-artifact@v1
55+
uses: actions/upload-artifact@v4
5656
with:
5757
name: report
5858
path: ./tests/e2e-playwright/config

Development.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Development
2+
[ For internal contributors only ]
3+
4+
## Getting Started
5+
6+
To set up the repo locally, choose one of the following methods:
7+
8+
### Method 1 (For FastCGI or Srcache)
9+
10+
1. Create a WordPress website.
11+
2. Clone the [nginx](https://github.com/nginx/nginx) source code in a separate directory.
12+
3. Set up nginx using either FastCGI cache or Srcache module.
13+
4. Manually compile the binary for Nginx.
14+
5. Add a configuration block to redirect incoming requests to the WordPress website.
15+
6. Clone this repository inside the `wp-content/plugins` directory.
16+
17+
### Method 2 (For Redis Cache)
18+
19+
1. Install EasyEngine by following the [instructions](https://easyengine.io/cli/handbook/install/).
20+
2. Create a site with caching enabled using the command: `ee site create <site_name> --cache`
21+
22+
3. Clone this repository inside the `wp-content/plugins` directory of the newly created site.
23+
24+
## Testing
25+
26+
To verify if a page is cached:
27+
28+
1. Enable the timestamp option in Nginx Helper from the WordPress Admin Page:
29+
- This adds a comment with cache time and query count.
30+
- Cached pages should show only 1 query.
31+
32+
2. Manually check the Redis database:
33+
- Search for keys beginning with the prefix specified in your Redis config, followed by a URL.
34+
35+
## Contributing
36+
37+
### Raising a Pull Request (PR)
38+
39+
1. Create a new branch from `master` for your changes.
40+
2. Make your changes and commit them to your branch.
41+
3. Raise a PR targeting the `develop` branch.
42+
4. Assign the PR to a reviewer.
43+
5. Address any feedback and make necessary changes.
44+
6. Once approved, merge the PR into the `develop` branch.
45+
46+
### Merging to Master
47+
48+
1. After thorough testing on the `develop` branch, create a new PR.
49+
2. Set the source branch as the original feature branch that was merged into `develop`.
50+
3. Set the target branch as `master`.
51+
4. Assign reviewers and await final approval.
52+
5. Once approved, merge the PR into the `master` branch.

README.md

Lines changed: 100 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Nginx Helper #
22
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
33

4-
**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, sudhiryadav, thrijith, stayallive, jaredwsmith, abhijitrakas, umeshnevase, sid177, souptik, arafatkn, subscriptiongroup
4+
**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, bryant1410, 1gor, matt-h, dotsam, nathanielks, rigagoogoo, dslatten, jinschoi, kelin1003, vaishuagola27, rahulsprajapati, utkarshpatel, gsayed786, shashwatmittal, sudhiryadav, thrijith, stayallive, jaredwsmith, abhijitrakas, umeshnevase, sid177, souptik, arafatkn, subscriptiongroup, akrocks, vedantgandhi28, GridPane, stefanfisk, SGr33n, agvs, diepbui4157, pratiklondhe, webdados, ghost, ravanh, tjalexander70, mrrobot47, alexliii, joelmcdwebworks, bozzmedia, millionleave, kubajosef, alexsina, tomeryatir, minzak, peterdowney01, rayeason, gnif
55

6-
**Tags:** nginx, cache, purge, nginx map, nginx cache, maps, fastcgi, proxy, redis, redis-cache, rewrite, permalinks
6+
**Tags:** nginx, cache-purge, fastcgi, permalinks, redis-cache
77

88
**Requires at least:** 3.0
99

10-
**Tested up to:** 6.1
10+
**Tested up to:** 6.8
1111

12-
**Stable tag:** 2.2.3
12+
**Stable tag:** 2.3.5
1313

1414
**License:** GPLv2 or later (of-course)
1515

@@ -76,6 +76,16 @@ Replace the path with your own.
7676

7777
Yes. It handles all post-types the same way.
7878

79+
**Q. How can I purge cache automatically after WordPress/plugin/theme updates?**
80+
81+
By default, Nginx Helper does **not** purge cache on WordPress core, plugin, or theme updates.
82+
If you want this behavior, you can enable it using a filter:
83+
84+
`add_filter( 'rt_wp_nginx_helper_enable_auto_purge_on_any_update', '__return_true' );`
85+
86+
Once enabled, cache will be purged automatically whenever WordPress core, plugins, or themes are updated.
87+
If left disabled (default), Nginx Helper will instead show an admin notice after updates, reminding you to purge cache manually.
88+
7989
**Q. How do I know my Nginx config is correct for fastcgi purging?**
8090

8191
Manually purging any page from the cache, by following instructions in the previous answer.
@@ -99,6 +109,24 @@ To purge a page immediately, follow these instructions:
99109
* Just open this in a browser and the page will be purged instantly.
100110
* Needless to say, this won't work, if you have a page or taxonomy called 'purge'.
101111

112+
**Q. Does it need any kind of URL structure?**
113+
114+
Yes. When setting the URL structure in Nginx configuration file a trailing slash should always be added.
115+
116+
**Q. How can I automatically purge cache when WooCommerce product stock reduces after purchase?**
117+
118+
Nginx Helper now includes optional WooCommerce integration.
119+
If enabled, cache for purchased products or products updated via REST API will be purged automatically.
120+
121+
To use it:
122+
123+
1. Go to Nginx Helper → Settings → WooCommerce Options.
124+
2. Tick “Purge product cache on updates”.
125+
126+
This ensures customers always see up-to-date stock status and product information without stale cache.
127+
128+
Note: This option will only be visible if WooCommerce is active.
129+
102130
### FAQ - Nginx Redis Cache ###
103131

104132
**Q. Can I override the redis hostname, port and prefix?**
@@ -113,6 +141,18 @@ define( 'RT_WP_NGINX_HELPER_REDIS_PORT', '6000' );
113141
define( 'RT_WP_NGINX_HELPER_REDIS_PREFIX', 'page-cache:' );
114142
```
115143

144+
**Q. Can I override the redis socket path, username, password?**
145+
146+
Yes, you can force override the redis socket path, username, password by defining constant in wp-config.php. For example:
147+
148+
```php
149+
define( 'RT_WP_NGINX_HELPER_REDIS_UNIX_SOCKET', '/var/run/redis/redis.sock' );
150+
151+
define( 'RT_WP_NGINX_HELPER_REDIS_USERNAME', 'admin' );
152+
153+
define( 'RT_WP_NGINX_HELPER_REDIS_PASSWORD', 'admin' );
154+
```
155+
116156
### FAQ - Nginx Map ###
117157

118158
**Q. My multisite already uses `WPMU_ACCEL_REDIRECT`. Do I still need Nginx Map?**
@@ -123,6 +163,16 @@ Definitely. `WPMU_ACCEL_REDIRECT` reduces the load on PHP, but it still ask Word
123163

124164
Most likely yes. A wordpress plugin, if not using explicitly any Apache-only mod, should work on Nginx. Some plugin may need some extra work.
125165

166+
167+
### FAQ - WP-CLI ###
168+
169+
**Q. How can I update the options using WP-CLI?**
170+
171+
```shell
172+
wp option patch update rt_wp_nginx_helper_options <option_name> <option_value>
173+
```
174+
175+
126176
### Still need help! ###
127177

128178
Please post your problem in [our free support forum](https://github.com/rtCamp/nginx-helper/issues).
@@ -139,6 +189,52 @@ Please post your problem in [our free support forum](https://github.com/rtCamp/n
139189

140190
## Changelog ##
141191

192+
### 2.3.5 ###
193+
194+
* Purge not working. [#Issue](https://wordpress.org/support/topic/purge-not-working-7/) - by [tjalexander70](https://profiles.wordpress.org/tjalexander70/), [mrrobot47](https://github.com/mrrobot47)
195+
196+
### 2.3.4 ###
197+
198+
* Cannot uncheck Purge Homephae options. [#Issue](https://wordpress.org/support/topic/cannot-uncheck-purge-homephae-options/) - by [diepbui4157](https://profiles.wordpress.org/diepbui4157/)
199+
* fastcgi cache purge fails if not using trailing slashes in URI structure. [#Issue](https://wordpress.org/support/topic/fastcgi-cache-purge-fails-if-not-using-trailing-slashes-in-uri-structure/) - by [agvs](https://profiles.wordpress.org/agvs/), [Vedant-Gandhi](https://github.com/Vedant-Gandhi)
200+
* What's _purge_personal_urls() for?. [#Issue](https://wordpress.org/support/topic/whats-_purge_personal_urls-for/) - by [Rolf Allard van Hagen](https://profiles.wordpress.org/ravanh/), [pratik-londhe4](https://github.com/pratik-londhe4)
201+
* Broken link in the useful links section. [#358](https://github.com/rtCamp/nginx-helper/issues/358) - by [diepbui4157](https://profiles.wordpress.org/diepbui4157/), [pratik-londhe4](https://github.com/pratik-londhe4)
202+
* Small issues with translatable strings. [#348](https://github.com/rtCamp/nginx-helper/issues/348) - by [webdados](https://github.com/webdados)
203+
* New filter for RT_WP_NGINX_HELPER_CACHE_PATH default constant value. [#298](https://github.com/rtCamp/nginx-helper/issues/298) - by [SGr33n](https://github.com/SGr33n) [Vedant-Gandhi](https://github.com/Vedant-Gandhi)
204+
* PURGUE FOR EDITOR. [#243](https://github.com/rtCamp/nginx-helper/issues/243) - by [ghost](https://github.com/ghost), [pratik-londhe4](https://github.com/pratik-londhe4)
205+
206+
207+
### 2.3.3 ###
208+
209+
* Fix AMP Purge for method unlink. [#396](https://github.com/rtCamp/nginx-helper/issues/343) - by [Stefan Fisk](https://github.com/stefanfisk)
210+
211+
### 2.3.2 ###
212+
213+
* Update the contributors list for the plugin. [#343](https://github.com/rtCamp/nginx-helper/issues/343) - by [Vedant Gandhi](https://github.com/Vedant-Gandhi)
214+
215+
### 2.3.1 ###
216+
217+
* Update the contributors list and tags for the plugin. [#378](https://github.com/rtCamp/nginx-helper/issues/378) - by [Vedant Gandhi](https://github.com/Vedant-Gandhi)
218+
219+
### 2.3.0 ###
220+
221+
* Disable the purge functionality when importing data. [#52](https://github.com/rtCamp/nginx-helper/pull/52) - by [Vedant Gandhi](https://github.com/Vedant-Gandhi)
222+
* Added option to preload cache for all Post and Pages. [#47](https://github.com/rtCamp/nginx-helper/pull/47) - by [Vedant Gandhi](https://github.com/Vedant-Gandhi)
223+
* Added the capability to purge Amp URL's. [#135](https://github.com/rtCamp/nginx-helper/pull/135) - by [Vedant Gandhi](https://github.com/Vedant-Gandhi)
224+
* Add support for adding Username, Password support for Redis. It also includes the support for Unix Socket Path for Redis along with Database selection. [#343](https://github.com/rtCamp/nginx-helper/pull/343),[#350](https://github.com/rtCamp/nginx-helper/pull/350) - by [Vedant Gandhi](https://github.com/Vedant-Gandhi)
225+
* Add capability to allow modifying options using WP-CLI. [#307](https://github.com/rtCamp/nginx-helper/pull/307) - by [Vedant Gandhi](https://github.com/Vedant-Gandhi)
226+
* Fix the plugin crash issue due to internationalization after upgrading to WordPress Version 6.7. [#364](https://github.com/rtCamp/nginx-helper/pull/364) - by [Vedant Gandhi](https://github.com/Vedant-Gandhi)
227+
228+
### 2.2.5 ###
229+
230+
* Add the capability to enable/disable purging of feeds. [#281](https://github.com/rtCamp/nginx-helper/issues/281) - by [Amaan Khan](https://github.com/pathan-amaankhan)
231+
* Fix undefined port error when Redis port is set to empty string. [#333](https://github.com/rtCamp/nginx-helper/issues/333) - by [Amaan Khan](https://github.com/pathan-amaankhan)
232+
233+
### 2.2.4 ###
234+
235+
* Introduces the capability to specify the `NGINX_HELPER_LOG` constant, allowing users to activate the logging feature. [#318](https://github.com/rtCamp/nginx-helper/pull/318) - by [Vishal Kakadiya](https://github.com/vishalkakadiya)
236+
* Existing users employing the nginx-helper plugin with logging enabled will experience no disruptions. However, if logging is disabled, users must define the `NGINX_HELPER_LOG` constant to re-enable the logging feature.
237+
142238
### 2.2.3 ###
143239

144240
* Add the URL being purged as parameter in `rt_nginx_helper_purge_cached_file` hook. [#271](https://github.com/rtCamp/nginx-helper/pull/271) - by [Arafat Islam](https://github.com/arafatkn)

admin/class-fastcgi-purger.php

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function purge_url( $url, $feed = true ) {
5757

5858
$this->delete_cache_file_for( $_url_purge );
5959

60-
if ( $feed ) {
60+
if ( $feed && ! empty( $nginx_helper_admin->options['purge_feeds'] ) ) {
6161

6262
$feed_url = rtrim( $_url_purge_base, '/' ) . '/feed/';
6363
$this->delete_cache_file_for( $feed_url );
@@ -83,7 +83,7 @@ public function purge_url( $url, $feed = true ) {
8383

8484
$this->do_remote_get( $_url_purge );
8585

86-
if ( $feed ) {
86+
if ( $feed && ! empty( $nginx_helper_admin->options['purge_feeds'] ) ) {
8787

8888
$feed_url = rtrim( $_url_purge_base, '/' ) . '/feed/';
8989
$this->do_remote_get( $feed_url );
@@ -94,7 +94,30 @@ public function purge_url( $url, $feed = true ) {
9494
break;
9595

9696
}
97+
98+
if( ( is_page() || is_single() ) && $nginx_helper_admin->options['purge_amp_urls'] ) {
99+
$this->purge_amp_version( $url );
100+
}
101+
102+
}
103+
104+
/**
105+
* Purge AMP version of a URL.
106+
*
107+
* @param string $url_base The base URL to purge.
108+
*/
109+
private function purge_amp_version( $url_base ) {
110+
global $nginx_helper_admin;
97111

112+
$amp_url = sprintf( '%s/amp/', rtrim( $url_base, '/' ) );
113+
114+
$this->log( '- Purging AMP URL | ' . $amp_url );
115+
116+
if ( 'unlink_files' === $nginx_helper_admin->options['purge_method'] ) {
117+
$this->delete_cache_file_for( $amp_url );
118+
} else {
119+
$this->do_remote_get( $amp_url );
120+
}
98121
}
99122

100123
/**

0 commit comments

Comments
 (0)