| 1 |
<?php |
| 2 |
// flush as many page cache plugin's caches as possible |
| 3 |
// hyper cache and gator cache hook into AO, so we don't need to :-) |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 6 |
|
| 7 |
function autoptimize_flush_pagecache() { |
| 8 |
if(function_exists('wp_cache_clear_cache')) { |
| 9 |
if (is_multisite()) { |
| 10 |
$blog_id = get_current_blog_id(); |
| 11 |
wp_cache_clear_cache($blog_id); |
| 12 |
} else { |
| 13 |
wp_cache_clear_cache(); |
| 14 |
} |
| 15 |
} else if ( has_action('cachify_flush_cache') ) { |
| 16 |
do_action('cachify_flush_cache'); |
| 17 |
} else if ( function_exists('w3tc_pgcache_flush') ) { |
| 18 |
w3tc_pgcache_flush(); |
| 19 |
} else if ( function_exists('wp_fast_cache_bulk_delete_all') ) { |
| 20 |
wp_fast_cache_bulk_delete_all(); // still to retest |
| 21 |
} else if (class_exists("WpFastestCache")) { |
| 22 |
$wpfc = new WpFastestCache(); |
| 23 |
$wpfc -> deleteCache(); |
| 24 |
} else if ( class_exists("c_ws_plugin__qcache_purging_routines") ) { |
| 25 |
c_ws_plugin__qcache_purging_routines::purge_cache_dir(); // quick cache, still to retest |
| 26 |
} else if ( class_exists("zencache") ) { |
| 27 |
zencache::clear(); |
| 28 |
} else if ( class_exists("comet_cache") ) { |
| 29 |
comet_cache::clear(); |
| 30 |
} else if ( class_exists("WpeCommon") ) { |
| 31 |
if ( apply_filters('autoptimize_flush_wpengine_aggressive', false) ) { |
| 32 |
if ( method_exists( "WpeCommon", "purge_memcached" ) ) { |
| 33 |
WpeCommon::purge_memcached(); |
| 34 |
} |
| 35 |
if ( method_exists( "WpeCommon", "clear_maxcdn_cache" ) ) { |
| 36 |
WpeCommon::clear_maxcdn_cache(); |
| 37 |
} |
| 38 |
} |
| 39 |
if ( method_exists( "WpeCommon", "purge_varnish_cache" ) ) { |
| 40 |
WpeCommon::purge_varnish_cache(); |
| 41 |
} |
| 42 |
} else if ( function_exists('sg_cachepress_purge_cache') ) { |
| 43 |
sg_cachepress_purge_cache(); |
| 44 |
} else if(file_exists(WP_CONTENT_DIR.'/wp-cache-config.php') && function_exists('prune_super_cache')){ |
| 45 |
// fallback for WP-Super-Cache |
| 46 |
global $cache_path; |
| 47 |
if (is_multisite()) { |
| 48 |
$blog_id = get_current_blog_id(); |
| 49 |
prune_super_cache( get_supercache_dir( $blog_id ), true ); |
| 50 |
prune_super_cache( $cache_path . 'blogs/', true ); |
| 51 |
} else { |
| 52 |
prune_super_cache($cache_path.'supercache/',true); |
| 53 |
prune_super_cache($cache_path,true); |
| 54 |
} |
| 55 |
} |
| 56 |
} |