public static function clear_cache() { // W3 Total Cache plugin if (function_exists('w3tc_pgcache_flush')) { w3tc_pgcache_flush(); } // WP Super Cache if (function_exists('wp_cache_clear_cache')) { wp_cache_clear_cache(); } // Hyper Cache if (function_exists('hyper_cache_invalidate')) { hyper_cache_invalidate(); } // Quick Cache if (function_exists('auto_clear_cache')) { auto_clear_cache(); } }
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); } } } } } } } } } }
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; }