From b093809804d1c37e739771fac00481a21101fc34 Mon Sep 17 00:00:00 2001 From: Eldon Yoder Date: Mon, 6 May 2024 10:45:29 -0400 Subject: [PATCH 1/2] add compatability for Cloudflare plugin to clear cloudflare cache when clearing all from SpinupWP --- src/Compatibility.php | 2 ++ src/Compatibility/CloudflarePlugin.php | 41 ++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 src/Compatibility/CloudflarePlugin.php diff --git a/src/Compatibility.php b/src/Compatibility.php index eb80007..3581b7b 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, ); /** diff --git a/src/Compatibility/CloudflarePlugin.php b/src/Compatibility/CloudflarePlugin.php new file mode 100644 index 0000000..cf26eda --- /dev/null +++ b/src/Compatibility/CloudflarePlugin.php @@ -0,0 +1,41 @@ +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(); + } +} \ No newline at end of file From 77cb679796ae98bf9cb7e6aa6ccbbd15f40ef82e Mon Sep 17 00:00:00 2001 From: Eldon Yoder Date: Mon, 6 May 2024 10:51:05 -0400 Subject: [PATCH 2/2] =?UTF-8?q?format=20code...=20=F0=9F=99=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Compatibility.php | 4 +- src/Compatibility/CloudflarePlugin.php | 51 +++++++++++++------------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/Compatibility.php b/src/Compatibility.php index 3581b7b..729968b 100644 --- a/src/Compatibility.php +++ b/src/Compatibility.php @@ -16,7 +16,7 @@ class Compatibility { */ protected $compatibilityClasses = array( ElementorPlugin::class, - CloudflarePlugin::class, + CloudflarePlugin::class, ); /** @@ -36,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 index cf26eda..ec7be22 100644 --- a/src/Compatibility/CloudflarePlugin.php +++ b/src/Compatibility/CloudflarePlugin.php @@ -5,37 +5,36 @@ use SpinupWp\Cache; class CloudflarePlugin { - /** - * @var Cache - */ - protected $cache; + /** + * @var Cache + */ + protected $cache; - /** - * @var Cache - */ - protected $cloudflareHooks; + /** + * @var Cache + */ + protected $cloudflareHooks; /** * Compatibility constructor. - * */ public function __construct( Cache $cache ) { - $this->cache = $cache; + $this->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(); - } -} \ No newline at end of file + 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(); + } +}