| 1 |
<?php |
| 2 |
if (!defined('ABSPATH')) exit; |
| 3 |
|
| 4 |
class berqStackCDN extends berqIntegrations { |
| 5 |
function __construct() { |
| 6 |
add_action('berqwp_flush_all_cache', [$this, 'flush_cache']); |
| 7 |
add_action('berqwp_stored_page_cache', [$this, 'flush_page_cache']); |
| 8 |
add_action('berqwp_flush_page_cache', [$this, 'flush_page_cache']); |
| 9 |
} |
| 10 |
|
| 11 |
function is_stackcdn() { |
| 12 |
// WPStackCache class is instantiated by the 20i StackCache MU plugin (wp-stack-cache.php) |
| 13 |
return class_exists('WPStackCache'); |
| 14 |
} |
| 15 |
|
| 16 |
function flush_cache() { |
| 17 |
if (!$this->is_stackcdn()) { |
| 18 |
return; |
| 19 |
} |
| 20 |
berqReverseProxyCache::flush_all(); |
| 21 |
} |
| 22 |
|
| 23 |
function flush_page_cache($slug) { |
| 24 |
if (!$this->is_stackcdn()) { |
| 25 |
return; |
| 26 |
} |
| 27 |
if (empty($slug)) { |
| 28 |
$slug = '/'; |
| 29 |
} |
| 30 |
berqReverseProxyCache::purge_cache(home_url($slug)); |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
new berqStackCDN(); |
| 35 |
|