| 1 |
<?php |
| 2 |
|
| 3 |
/* |
| 4 |
* This file is part of the WindPress package. |
| 5 |
* |
| 6 |
* (c) Joshua Gugun Siagian <suabahasa@gmail.com> |
| 7 |
* |
| 8 |
* For the full copyright and license information, please view the LICENSE |
| 9 |
* file that was distributed with this source code. |
| 10 |
*/ |
| 11 |
declare (strict_types=1); |
| 12 |
namespace WindPress\WindPress\Utils; |
| 13 |
|
| 14 |
/** |
| 15 |
* Cache utility functions for the plugin. |
| 16 |
* |
| 17 |
* @since 3.0.0 |
| 18 |
*/ |
| 19 |
class Cache |
| 20 |
{ |
| 21 |
/** |
| 22 |
* Clear the cache from various cache plugins. |
| 23 |
*/ |
| 24 |
public static function flush_cache_plugin() |
| 25 |
{ |
| 26 |
/** |
| 27 |
* WordPress Object Cache |
| 28 |
* @see https://developer.wordpress.org/reference/classes/wp_object_cache/ |
| 29 |
*/ |
| 30 |
\wp_cache_flush(); |
| 31 |
/** |
| 32 |
* WP Rocket |
| 33 |
* @see https://docs.wp-rocket.me/article/92-rocketcleandomain |
| 34 |
*/ |
| 35 |
if (\function_exists('rocket_clean_domain')) { |
| 36 |
\rocket_clean_domain(); |
| 37 |
} |
| 38 |
/** |
| 39 |
* WP Super Cache |
| 40 |
* @see https://github.com/Automattic/wp-super-cache/blob/a0872032b1b3fc6847f490eadfabf74c12ad0135/wp-cache-phase2.php#L3013 |
| 41 |
*/ |
| 42 |
if (\function_exists('wp_cache_clear_cache')) { |
| 43 |
\wp_cache_clear_cache(); |
| 44 |
} |
| 45 |
/** |
| 46 |
* W3 Total Cache |
| 47 |
* @see https://github.com/BoldGrid/w3-total-cache/blob/3a094493064ea60d727b3389dee813639860ef49/w3-total-cache-api.php#L259 |
| 48 |
*/ |
| 49 |
if (\function_exists('w3tc_flush_all')) { |
| 50 |
\w3tc_flush_all(); |
| 51 |
} |
| 52 |
/** |
| 53 |
* WP Fastest Cache |
| 54 |
* @see https://www.wpfastestcache.com/tutorial/delete-the-cache-by-calling-the-function/ |
| 55 |
*/ |
| 56 |
if (\function_exists('wpfc_clear_all_cache')) { |
| 57 |
\wpfc_clear_all_cache(\true); |
| 58 |
} |
| 59 |
/** |
| 60 |
* LiteSpeed Cache |
| 61 |
* @see https://docs.litespeedtech.com/lscache/lscwp/api/#purge-all-existing-caches |
| 62 |
*/ |
| 63 |
\do_action('litespeed_purge_all'); |
| 64 |
/** |
| 65 |
* SG Optimizer |
| 66 |
* @see https://plugins.trac.wordpress.org/browser/sg-cachepress/trunk/core/Supercacher/Supercacher.php |
| 67 |
* @see https://plugins.trac.wordpress.org/browser/sg-cachepress/trunk/core/File_Cacher/File_Cacher.php |
| 68 |
*/ |
| 69 |
if (\class_exists('\\SiteGround_Optimizer\\Supercacher\\Supercacher')) { |
| 70 |
\SiteGround_Optimizer\Supercacher\Supercacher::purge_cache(); |
| 71 |
\SiteGround_Optimizer\File_Cacher\File_Cacher::get_instance()->purge_everything(); |
| 72 |
} |
| 73 |
} |
| 74 |
} |
| 75 |
|