the caches that were cleared, by name */ public static function purge(): array { $cleared = []; if (function_exists('wp_cache_flush')) { wp_cache_flush(); } if (function_exists('rocket_clean_domain')) { rocket_clean_domain(); $cleared[] = 'WP Rocket'; } if (defined('LSCWP_V') || class_exists('\LiteSpeed\Purge')) { do_action('litespeed_purge_all'); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- LiteSpeed Cache's own purge hook. $cleared[] = 'LiteSpeed Cache'; } if (function_exists('w3tc_flush_all')) { w3tc_flush_all(); $cleared[] = 'W3 Total Cache'; } if (function_exists('wp_cache_clear_cache')) { wp_cache_clear_cache(); $cleared[] = 'WP Super Cache'; } if (class_exists('\Cache_Enabler')) { do_action('cache_enabler_clear_complete_cache'); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Cache Enabler's own purge hook. $cleared[] = 'Cache Enabler'; } if (isset($GLOBALS['wp_fastest_cache']) && is_object($GLOBALS['wp_fastest_cache']) && method_exists($GLOBALS['wp_fastest_cache'], 'deleteCache')) { $GLOBALS['wp_fastest_cache']->deleteCache(true); $cleared[] = 'WP Fastest Cache'; } if (class_exists('\autoptimizeCache') && method_exists('\autoptimizeCache', 'clearall')) { \autoptimizeCache::clearall(); $cleared[] = 'Autoptimize'; } if (function_exists('sg_cachepress_purge_cache')) { sg_cachepress_purge_cache(); $cleared[] = 'SiteGround Optimizer'; } if (class_exists('\WpeCommon') && method_exists('\WpeCommon', 'purge_varnish_cache')) { \WpeCommon::purge_varnish_cache(); $cleared[] = 'WP Engine'; } if (function_exists('breeze_clear_all_cache')) { breeze_clear_all_cache(); $cleared[] = 'Breeze'; } do_action('sarcio_cache_purged', $cleared); return $cleared; } /** Once per request, after a change was made for real. */ public static function purgeAfterChange(): void { if (self::$purgedThisRequest) { return; } self::$purgedThisRequest = true; self::purge(); } public static function reset(): void { self::$purgedThisRequest = false; } }