| 1 |
<?php |
| 2 |
|
| 3 |
namespace DeliciousBrains\SpinupWp\Compatibility; |
| 4 |
|
| 5 |
use DeliciousBrains\SpinupWp\Cache; |
| 6 |
|
| 7 |
class ElementorPlugin { |
| 8 |
/** |
| 9 |
* @var Cache |
| 10 |
*/ |
| 11 |
protected $cache; |
| 12 |
|
| 13 |
/** |
| 14 |
* Compatibility constructor. |
| 15 |
* |
| 16 |
* @param Cache $cache |
| 17 |
*/ |
| 18 |
public function __construct( Cache $cache ) { |
| 19 |
$this->cache = $cache; |
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* Init |
| 24 |
*/ |
| 25 |
public function init() { |
| 26 |
add_action( 'elementor/core/files/clear_cache', array( $this, 'purge_caches' ) ); |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Clear both the object and page caches. |
| 31 |
*/ |
| 32 |
public function purge_caches() { |
| 33 |
if ( $this->cache->is_object_cache_enabled() ) { |
| 34 |
$this->cache->purge_object_cache(); |
| 35 |
} |
| 36 |
|
| 37 |
if ( $this->cache->is_page_cache_enabled() ) { |
| 38 |
$this->cache->purge_page_cache(); |
| 39 |
} |
| 40 |
} |
| 41 |
} |