Example #1
0
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 (class_exists("zencache")) {
                                    zencache::clear();
                                    // zen 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);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Example #2
0
 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_CACHEFILE_PREFIX) !== false && is_file($thisAoCacheDir . $file)) {
                 @unlink($thisAoCacheDir . $file);
             }
         }
     }
     @unlink(AUTOPTIMIZE_CACHE_DIR . "/.htaccess");
     delete_transient("autoptimize_stats");
     // 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 (class_exists("zencache")) {
                                 zencache::clear();
                                 // zen cache, tbc
                             } 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()));
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if (!function_exists('autoptimize_do_cachepurged_action')) {
         function autoptimize_do_cachepurged_action()
         {
             do_action("autoptimize_action_cachepurged");
         }
     }
     add_action("after_setup_theme", "autoptimize_do_cachepurged_action");
     return true;
 }
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);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
 /**
  * Perform cache clear action
  */
 public function do_clear_pagecache()
 {
     if (!class_exists('zencache')) {
         return;
     }
     // clear zencache
     try {
         zencache::clear();
     } catch (Exception $e) {
         // auch
     }
 }