/** * Try to clear Cache files when certain plugins are present. * Only happens after redirects or settings are saved or deleted. * * Expirimental to try to stop some caching plugins from holding the cached redirects. * @since 5.1.2 */ function qppr_try_to_clear_cache_plugins() { // make sure the function is present if (!function_exists('is_plugin_active')) { require_once ABSPATH . '/wp-admin/includes/plugin.php'; } // WP Super Cache if (is_plugin_active('wp-super-cache/wp-cache.php') && function_exists('wp_cache_clear_cache')) { wp_cache_clear_cache(); } // W3 Total Cache if (is_plugin_active('w3-total-cache/w3-total-cache.php') && function_exists('w3tc_pgcache_flush')) { w3tc_pgcache_flush(); } // WP Fast Cache if (is_plugin_active('wp-fastest-cache/wpFastestCache.php') && class_exists('WpFastestCache')) { $newCache = new WpFastestCache(); $newCache->deleteCache(); } }
function autoptimize_flush_pagecache($nothing) { if (function_exists('wp_cache_clear_cache')) { if (is_multisite()) { $blog_id = get_current_blog_id(); wp_cache_clear_cache($blog_id); } else { wp_cache_clear_cache(); } } else { if (has_action('cachify_flush_cache')) { do_action('cachify_flush_cache'); } else { if (function_exists('w3tc_pgcache_flush')) { w3tc_pgcache_flush(); // w3 total cache } else { if (function_exists('hyper_cache_invalidate')) { hyper_cache_invalidate(); // hypercache } else { if (function_exists('wp_fast_cache_bulk_delete_all')) { wp_fast_cache_bulk_delete_all(); // wp fast cache } else { if (class_exists("WpFastestCache")) { $wpfc = new WpFastestCache(); // wp fastest cache $wpfc->deleteCache(); } else { if (class_exists("c_ws_plugin__qcache_purging_routines")) { c_ws_plugin__qcache_purging_routines::purge_cache_dir(); // quick cache } else { if (file_exists(WP_CONTENT_DIR . '/wp-cache-config.php') && function_exists('prune_super_cache')) { // fallback for WP-Super-Cache global $cache_path; if (is_multisite()) { $blog_id = get_current_blog_id(); prune_super_cache(get_supercache_dir($blog_id), true); prune_super_cache($cache_path . 'blogs/', true); } else { prune_super_cache($cache_path . 'supercache/', true); prune_super_cache($cache_path, true); } } } } } } } } } }
public function deactivate() { $wpfc = new WpFastestCache(); $path = ABSPATH; if ($wpfc->is_subdirectory_install()) { $path = $wpfc->getABSPATH(); } if (is_file($path . ".htaccess") && is_writable($path . ".htaccess")) { $htaccess = file_get_contents($path . ".htaccess"); $htaccess = preg_replace("/#\\s?BEGIN\\s?WpFastestCache.*?#\\s?END\\s?WpFastestCache/s", "", $htaccess); $htaccess = preg_replace("/#\\s?BEGIN\\s?GzipWpFastestCache.*?#\\s?END\\s?GzipWpFastestCache/s", "", $htaccess); $htaccess = preg_replace("/#\\s?BEGIN\\s?LBCWpFastestCache.*?#\\s?END\\s?LBCWpFastestCache/s", "", $htaccess); file_put_contents($path . ".htaccess", $htaccess); } wp_clear_scheduled_hook("wp_fastest_cache"); wp_clear_scheduled_hook($wpfc->slug() . "_regular"); delete_option("WpFastestCache"); delete_option("WpFcDeleteCacheLogs"); $wpfc->deleteCache(); }
function autoptimize_flush_pagecache() { if (function_exists('wp_cache_clear_cache')) { if (is_multisite()) { $blog_id = get_current_blog_id(); wp_cache_clear_cache($blog_id); } else { wp_cache_clear_cache(); } } else { if (has_action('cachify_flush_cache')) { do_action('cachify_flush_cache'); } else { if (function_exists('w3tc_pgcache_flush')) { w3tc_pgcache_flush(); } else { if (function_exists('wp_fast_cache_bulk_delete_all')) { wp_fast_cache_bulk_delete_all(); // still to retest } else { if (class_exists("WpFastestCache")) { $wpfc = new WpFastestCache(); $wpfc->deleteCache(); } else { if (class_exists("c_ws_plugin__qcache_purging_routines")) { c_ws_plugin__qcache_purging_routines::purge_cache_dir(); // quick cache, still to retest } else { if (class_exists("zencache")) { zencache::clear(); } else { if (class_exists("comet_cache")) { comet_cache::clear(); } else { if (class_exists("WpeCommon")) { if (apply_filters('autoptimize_flush_wpengine_aggressive', false)) { if (method_exists("WpeCommon", "purge_memcached")) { WpeCommon::purge_memcached(); } if (method_exists("WpeCommon", "clear_maxcdn_cache")) { WpeCommon::clear_maxcdn_cache(); } } if (method_exists("WpeCommon", "purge_varnish_cache")) { WpeCommon::purge_varnish_cache(); } } else { if (file_exists(WP_CONTENT_DIR . '/wp-cache-config.php') && function_exists('prune_super_cache')) { // fallback for WP-Super-Cache global $cache_path; if (is_multisite()) { $blog_id = get_current_blog_id(); prune_super_cache(get_supercache_dir($blog_id), true); prune_super_cache($cache_path . 'blogs/', true); } else { prune_super_cache($cache_path . 'supercache/', true); prune_super_cache($cache_path, true); } } } } } } } } } } } }
static function clearall() { if (!autoptimizeCache::cacheavail()) { return false; } // scan the cachedirs foreach (array("", "js", "css") as $scandirName) { $scan[$scandirName] = scandir(AUTOPTIMIZE_CACHE_DIR . $scandirName); } // clear the cachedirs foreach ($scan as $scandirName => $scanneddir) { $thisAoCacheDir = rtrim(AUTOPTIMIZE_CACHE_DIR . $scandirName, "/") . "/"; foreach ($scanneddir as $file) { if (!in_array($file, array('.', '..')) && strpos($file, 'autoptimize') !== false && is_file($thisAoCacheDir . $file)) { @unlink($thisAoCacheDir . $file); } } } @unlink(AUTOPTIMIZE_CACHE_DIR . "/.htaccess"); // Do we need to clean any caching plugins cache-files? if (function_exists('wp_cache_clear_cache')) { if (is_multisite()) { $blog_id = get_current_blog_id(); wp_cache_clear_cache($blog_id); } else { wp_cache_clear_cache(); } } else { if (function_exists('w3tc_pgcache_flush')) { w3tc_pgcache_flush(); // w3 total cache } else { if (function_exists('hyper_cache_invalidate')) { hyper_cache_invalidate(); // hypercache } else { if (function_exists('wp_fast_cache_bulk_delete_all')) { wp_fast_cache_bulk_delete_all(); // wp fast cache } else { if (class_exists("WpFastestCache")) { $wpfc = new WpFastestCache(); // wp fastest cache $wpfc->deleteCache(); } else { if (class_exists("c_ws_plugin__qcache_purging_routines")) { c_ws_plugin__qcache_purging_routines::purge_cache_dir(); // quick cache } else { if (file_exists(WP_CONTENT_DIR . '/wp-cache-config.php') && function_exists('prune_super_cache')) { // fallback for WP-Super-Cache global $cache_path; if (is_multisite()) { $blog_id = get_current_blog_id(); prune_super_cache(get_supercache_dir($blog_id), true); prune_super_cache($cache_path . 'blogs/', true); } else { prune_super_cache($cache_path . 'supercache/', true); prune_super_cache($cache_path, true); } } else { // fallback; schedule event and try to clear there wp_schedule_single_event(time() + 1, 'ao_flush_pagecache', array(time())); } } } } } } } return true; }
public function uninstall() { $wpfc = new WpFastestCache(); $wpfc->deactivate(); // wp_clear_scheduled_hook("wp_fastest_cache"); // wp_clear_scheduled_hook("wp_fastest_cache_regular"); delete_option("WpFastestCache"); delete_option("WpFcDeleteCacheLogs"); delete_option("WpFastestCacheCDN"); delete_option("WpFastestCacheExclude"); delete_option("WpFastestCachePreLoad"); delete_option("WpFastestCacheCSS"); delete_option("WpFastestCacheCSSSIZE"); delete_option("WpFastestCacheJS"); delete_option("WpFastestCacheJSSIZE"); foreach ((array) _get_cron_array() as $cron_key => $cron_value) { foreach ((array) $cron_value as $hook => $events) { if (preg_match("/^wp\\_fastest\\_cache/", $hook)) { $args = array(); foreach ((array) $events as $event_key => $event) { if (isset($event["args"]) && isset($event["args"][0])) { $args = array(json_encode(json_decode($event["args"][0]))); } } wp_clear_scheduled_hook($hook, $args); } } } }