diff --git a/src/Compatibility.php b/src/Compatibility.php index eb80007..729968b 100644 --- a/src/Compatibility.php +++ b/src/Compatibility.php @@ -3,6 +3,7 @@ namespace SpinupWp; use SpinupWp\Compatibility\ElementorPlugin; +use SpinupWp\Compatibility\CloudflarePlugin; class Compatibility { /** @@ -15,6 +16,7 @@ class Compatibility { */ protected $compatibilityClasses = array( ElementorPlugin::class, + CloudflarePlugin::class, ); /** @@ -34,4 +36,4 @@ public function init() { ( new $compatibilityClass( $this->cache ) )->init(); } } -} \ No newline at end of file +} diff --git a/src/Compatibility/CloudflarePlugin.php b/src/Compatibility/CloudflarePlugin.php new file mode 100644 index 0000000..ec7be22 --- /dev/null +++ b/src/Compatibility/CloudflarePlugin.php @@ -0,0 +1,40 @@ +cache = $cache; + } + + public function init() { + if ( class_exists( 'CF\WordPress\Hooks' ) ) { + $this->cloudflareHooks = new \CF\WordPress\Hooks(); + add_filter( 'spinupwp_site_purged', array( $this, 'clear_cloudflare_cache' ) ); + } + } + + /** + * Purge the cache when the site is purged in SpinupWP. + */ + public function clear_cloudflare_cache() { + // log debug message + error_log( 'Purging Cloudflare cache from SpinupWP' ); + $this->cloudflareHooks->purgeCacheEverything(); + } +}