/** * Clear the caches! */ function ccfm_clear_cache_for_me($source) { global $wp_fastest_cache; do_action('ccfm_clear_cache_for_me_before', $source); // if W3 Total Cache is being used, clear the cache if (function_exists('w3tc_pgcache_flush')) { w3tc_pgcache_flush(); } else { if (function_exists('wp_cache_clean_cache')) { global $file_prefix, $supercachedir; if (empty($supercachedir) && function_exists('get_supercache_dir')) { $supercachedir = get_supercache_dir(); } wp_cache_clean_cache($file_prefix); } else { if (class_exists('WpeCommon')) { //be extra careful, just in case 3rd party changes things on us if (method_exists('WpeCommon', 'purge_memcached')) { WpeCommon::purge_memcached(); } if (method_exists('WpeCommon', 'purge_memcached')) { WpeCommon::clear_maxcdn_cache(); } if (method_exists('WpeCommon', 'purge_memcached')) { WpeCommon::purge_varnish_cache(); } } else { if (method_exists('WpFastestCache', 'deleteCache') && !empty($wp_fastest_cache)) { $wp_fastest_cache->deleteCache(); } } } } do_action('ccfm_clear_cache_for_me', $source); }
static function run() { error_log('pl5 - run() at ' . __CLASS__); if (!class_exists('WpeCommon')) { return false; } WpeCommon::purge_memcached(); WpeCommon::clear_maxcdn_cache(); WpeCommon::purge_varnish_cache(); error_log('pl5 - cleared WPE caches.'); }
/** * Clear cache from: * - W3TC, * - WordPress Total Cache * - WPEngine * - Varnish */ public function clear_cache() { /** * if W3 Total Cache is being used, clear the cache */ if (function_exists('w3tc_pgcache_flush')) { w3tc_pgcache_flush(); } else { if (function_exists('wp_cache_clean_cache')) { global $file_prefix; wp_cache_clean_cache($file_prefix); } else { if (class_exists('WpeCommon')) { WpeCommon::purge_memcached(); WpeCommon::clear_maxcdn_cache(); WpeCommon::purge_varnish_cache(); } } } /** * Clear Varnish caches */ if ('file' == $this->mode() && Avada()->settings->get('cache_server_ip')) { $this->clear_varnish_cache($this->file('url')); } }
public function process_internal_command() { // Ensure this is an internal command; process normally otherwise $cmd = wpe_param('wp-cmd'); if (!$cmd) { return; // without a command, it's not an internal request } if (!$this->from_allowed_ip()) { print "Ignoring request from non-local host: " . $_SERVER['REMOTE_ADDR'] . " to " . $_SERVER['SERVER_ADDR'] . "\n"; exit(0); // local requests only -- security! Meaning our public IP address or localhost } @ob_get_clean(); error_reporting(-1); header("Content-Type: text/plain"); // just in case we're viewing inside a browser, but typically is commandline define('WPE_NO_HTML_FILTER', TRUE); // Execute command switch ($cmd) { case 'ping': header("Content-Type: text/plain"); header("X-WPE-Host: " . gethostname() . " " . $_SERVER['SERVER_ADDR']); print "pong\n"; break; case 'ensure': header("Content-Type: text/plain"); $this->ensure_standard_settings(); break; case 'ensure-user': header("Content-Type: text/plain"); $this->ensure_account_user(); break; case 'nada': return; // ignore, just to get into some other page // ignore, just to get into some other page case 'cron': header("Content-Type: text/plain"); $this->do_frequently(); break; case 'refresh-notices': delete_option('wpe_notices_ttl'); delete_transient('wpe_notices_ttl'); wp_cache_delete('wpe_notices_ttl', 'transient'); break; case 'sso': $key = $_POST['key']; if (sha1('wpe-sso|' . WPE_APIKEY . '|' . PWP_NAME) == $key) { global $wpdb; $token = sha1($key . mt_rand() . mt_rand() . mt_rand() . mt_rand() . mt_rand() . mt_rand() . mt_rand() . mt_rand()); set_transient('wpe_sso', $token, 60); echo $token; } break; case 'purge-all-caches': ob_start(); WpeCommon::purge_memcached(); WpeCommon::clear_maxcdn_cache(); WpeCommon::purge_varnish_cache(); // refresh our own cache (after CDN purge, in case that needed to clear before we access new content) $this->empty_all_caches(); $errors = ob_get_contents(); ob_end_clean(); header("Content-Type: text/plain"); header("X-WPE-Host: " . gethostname() . " " . $_SERVER['SERVER_ADDR']); print "All Caches were purged!"; break; case 'purge-varnish-cache': WpeCommon::purge_varnish_cache(); print "Varnish cache was purged! "; break; case 'purge-object-cache': WpeCommon::purge_memcached(); print "Object cache was purged! "; break; default: die("ERROR: unknown command: `{$cmd}`\n"); } // Stop processing exit(0); }
$http = new WP_Http(); $msg = $http->get($url); if (is_a($msg, 'WP_Error')) { return false; } if (!isset($msg['body'])) { return false; } $data = json_decode($msg['body'], true); $message = @$data['message']; } // Process purging all caches if (wpe_param('purge-all')) { check_admin_referer(PWP_NAME . '-config'); // check_admin_referer(PWP_NAME.'-config'); DO NOT CHECK because it's OK to just hit it from anywhere, and in fact we do. WpeCommon::purge_memcached(); WpeCommon::clear_maxcdn_cache(); WpeCommon::purge_varnish_cache(); // refresh our own cache (after CDN purge, in case that needed to clear before we access new content) $message = "All of these caches have been purged: HTML-page-caching, CDN (statics), and WordPress Object/Transient Caches."; } if (is_wpe_snapshot()) { $error = "Cannot use the standard WPEngine controls from a staging server!<br/><br/>This is valid only from your live site."; $have_snapshot = FALSE; } else { $snapshot_state = $plugin->get_staging_status(); if ($just_started_snapshot && $snapshot_state['have_snapshot']) { // if this, fake it! $snapshot_state['status'] = "Starting the staging snapshot process..."; $snapshot_state['is_ready'] = false; }
private function clear_cache_plugins() { /* Not implemented yet - still testing */ /*** * Automatically clears page caches after plugin install or upgrade * Called from upgrade_check() * Added 1.9.6.2 ***/ global $wpss_cache_check, $wp_fastest_cache; if (empty($wpss_cache_check)) { $wpss_cache_check = rs_wpss_check_cache_status(); } if ($wpss_cache_check['cache_check_status'] === 'ACTIVE') { if (rs_wpss_is_plugin_active('w3-total-cache/w3-total-cache.php') && function_exists('w3tc_pgcache_flush')) { /* W3 Total Cache */ w3tc_pgcache_flush(); } if (rs_wpss_is_plugin_active('wp-super-cache/wp-cache.php') && function_exists('wp_cache_clean_cache')) { /* WP Super Cache */ global $file_prefix; wp_cache_clean_cache($file_prefix); } if (rs_wpss_is_plugin_active('wp-fastest-cache/wpFastestCache.php') && !empty($wp_fastest_cache) && method_exists('WpFastestCache', 'deleteCache')) { /* WP Fastest Cache */ $wp_fastest_cache->deleteCache(); } if (class_exists('WPE_API', FALSE) && class_exists('WpeCommon')) { /* WP Engine Hosting */ 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(); } } } }
private function clear_cache_plugins() { /* Not fully implemented yet - still testing */ /** * Automatically clears page caches after plugin install or upgraded * Called from upgrade_check() * Added 1.9.6.2, Modified 1.9.7.5 */ global $wpss_cache_check, $wp_fastest_cache, $file_prefix, $supercachedir; /* Flush Memcache(d) */ $flush_memcache = wp_cache_flush(); return; /* Temp - 1.9.7.5 */ /* Check if cache plugins or server-side caching active */ if (empty($wpss_cache_check)) { $wpss_cache_check = rs_wpss_check_cache_status(); } if ($wpss_cache_check['cache_check_status'] === 'ACTIVE') { if (WPSS_Compatibility::is_plugin_active('w3-total-cache/w3-total-cache.php') && function_exists('w3tc_pgcache_flush')) { /* W3 Total Cache */ w3tc_pgcache_flush(); } if (WPSS_Compatibility::is_plugin_active('wp-super-cache/wp-cache.php') && function_exists('wp_cache_clean_cache')) { /* WP Super Cache */ if (empty($supercachedir) && function_exists('get_supercache_dir')) { $supercachedir = get_supercache_dir(); } wp_cache_clean_cache($file_prefix); } if (WPSS_Compatibility::is_plugin_active('wp-fastest-cache/wpFastestCache.php') && method_exists('WpFastestCache', 'deleteCache') && !empty($wp_fastest_cache)) { /* WP Fastest Cache */ $wp_fastest_cache->deleteCache(); } if (class_exists('WPE_API', FALSE) && class_exists('WpeCommon')) { /* WP Engine Hosting */ 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(); } } /* Add Autoptimize & other Cache Plugins... */ } }
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); } } } } } } } } } } } }
/** * Clear cache from: * - W3TC, * - WordPress Total Cache * - WPEngine * - Varnish */ public function clear_cache() { // if W3 Total Cache is being used, clear the cache if (function_exists('w3tc_pgcache_flush')) { w3tc_pgcache_flush(); } else { if (function_exists('wp_cache_clean_cache')) { global $file_prefix; wp_cache_clean_cache($file_prefix); } else { if (class_exists('WpeCommon')) { WpeCommon::purge_memcached(); WpeCommon::clear_maxcdn_cache(); WpeCommon::purge_varnish_cache(); } } } // Clear Varnish caches if (Avada()->settings->get('dynamic_css_compiler') && Avada()->settings->get('cache_server_ip')) { $this->clear_varnish_cache(self::file('url')); } }
/** * Call the cache server to purge the cache with WP Engine hosting. * * @since 2.6.4 * * @return void */ function rocket_clean_wpengine() { if (class_exists('WpeCommon')) { WpeCommon::purge_memcached(); WpeCommon::purge_varnish_cache(); } }