CacheService.php
2 weeks ago
CacheServiceProvider.php
2 weeks ago
DoNotCachePageService.php
2 weeks ago
LiteSpeedCacheService.php
4 months ago
W3TotalCacheService.php
4 months ago
WpFastestCacheService.php
4 months ago
DoNotCachePageService.php
34 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCart\WordPress\Cache; |
| 4 | |
| 5 | /** |
| 6 | * Generic, plugin-agnostic cache service. |
| 7 | * |
| 8 | * Defines the DONOTCACHEPAGE constant on SureCart dynamic pages so any |
| 9 | * caching layer honoring the WordPress convention (WP Rocket, WP Super Cache, |
| 10 | * SWIS, host caches, etc.) skips them without a dedicated integration. |
| 11 | */ |
| 12 | class DoNotCachePageService extends CacheService { |
| 13 | /** |
| 14 | * Always active — the constant is a WordPress-wide convention, not specific to any cache plugin. |
| 15 | * |
| 16 | * @return bool |
| 17 | */ |
| 18 | protected function isCachePluginActive(): bool { |
| 19 | return true; |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * Disable cache for the current page. |
| 24 | * |
| 25 | * @param string $reason Reason for disabling cache. |
| 26 | * @return void |
| 27 | */ |
| 28 | protected function disableCache( string $reason ): void { |
| 29 | if ( ! defined( 'DONOTCACHEPAGE' ) ) { |
| 30 | define( 'DONOTCACHEPAGE', true ); |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 |