public static function deactivate()
 {
     do_action("ws_plugin__qcache_before_deactivation", get_defined_vars());
     /**/
     c_ws_plugin__qcache_wp_cache::delete_wp_cache();
     c_ws_plugin__qcache_advanced_cache::delete_advanced();
     c_ws_plugin__qcache_garbage_collection::delete_garbage_collector();
     c_ws_plugin__qcache_auto_cache::delete_auto_cache_engine();
     /**/
     if ($GLOBALS["WS_PLUGIN__"]["qcache"]["o"]["run_deactivation_routines"]) {
         delete_option("ws_plugin__qcache_activated_version");
         delete_option("ws_plugin__qcache_configured");
         delete_option("ws_plugin__qcache_notices");
         delete_option("ws_plugin__qcache_options");
     }
     /**/
     c_ws_plugin__qcache_purging_routines::purge_cache_dir(false, false, false);
     /**/
     do_action("ws_plugin__qcache_after_deactivation", get_defined_vars());
     /**/
     return;
     /* Return for uniformity. */
 }
Beispiel #2
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 (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;
 }
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);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
 public static function ajax_clear()
 {
     global $current_site, $current_blog;
     /* Multisite details. */
     /**/
     do_action("ws_plugin__qcache_before_ajax_clear", get_defined_vars());
     /**/
     if (($nonce = $_POST["ws_plugin__qcache_ajax_clear"]) && wp_verify_nonce($nonce, "ws-plugin--qcache-ajax-clear")) {
         if (is_multisite() && !is_main_site() && is_object($current_blog) && $current_blog->blog_id) {
             c_ws_plugin__qcache_purging_routines::purge_cache_dir($current_blog);
             /**/
             header("Content-Type: text/plain; charset=utf-8");
             /**/
             $status = 'Cleared ( this blog )';
             /* Indicate "this blog" to the Super Admin. */
             /**/
             echo "jQuery ('input#ws-plugin--qcache-ajax-clear').css ('background-image', 'url(\\'" . c_ws_plugin__qcache_utils_strings::esc_sq($GLOBALS["WS_PLUGIN__"]["qcache"]["c"]["dir_url"]) . "/images/ajax-clear.png\\')');";
             echo "setTimeout (function (){ jQuery ('input#ws-plugin--qcache-ajax-clear').val ('Clear Cache'); }, 2000);";
             echo "jQuery ('input#ws-plugin--qcache-ajax-clear').val ('" . c_ws_plugin__qcache_utils_strings::esc_sq($status) . "');";
             echo "jQuery ('input#ws-plugin--qcache-ajax-clear').each (function (){ this.blur(); });";
         } else {
             c_ws_plugin__qcache_purging_routines::purge_cache_dir();
             /**/
             header("Content-Type: text/plain; charset=utf-8");
             /**/
             $status = is_multisite() ? 'Cleared ( all blogs )' : '( Cleared )';
             /**/
             echo "jQuery ('input#ws-plugin--qcache-ajax-clear').css ('background-image', 'url(\\'" . c_ws_plugin__qcache_utils_strings::esc_sq($GLOBALS["WS_PLUGIN__"]["qcache"]["c"]["dir_url"]) . "/images/ajax-clear.png\\')');";
             echo "setTimeout (function (){ jQuery ('input#ws-plugin--qcache-ajax-clear').val ('Clear Cache'); }, 2000);";
             echo "jQuery ('input#ws-plugin--qcache-ajax-clear').val ('" . c_ws_plugin__qcache_utils_strings::esc_sq($status) . "');";
             echo "jQuery ('input#ws-plugin--qcache-ajax-clear').each (function (){ this.blur(); });";
         }
         /**/
         do_action("ws_plugin__qcache_during_ajax_clear", get_defined_vars());
     }
     /**/
     do_action("ws_plugin__qcache_after_ajax_clear", get_defined_vars());
     /**/
     exit;
     /* Clean exit. */
 }