Feature – SpinupWP
-
Are you able to add SpinupWP to the list of providers.
<?php
/*
* Add this to your theme functions.php, or add to a plugin.
*
*/
/**
* Clear the SpinupWP Cache for the entire website.
*/
function clear_spinup_cache(): bool
{
if (! class_exists('SpinupWp\Cache')) {
return false;
}
$class_spinup_admin = new SpinupWp\AdminBar('/wp-content/plugins/spinupwp/');
$class_spinup_cli = new SpinupWp\Cli;
$class_spinup_cache = new SpinupWp\Cache($class_spinup_admin, $class_spinup_cli);
if ($class_spinup_cache->is_page_cache_enabled()) {
$purge = $GLOBALS['spinupwp']->cache->purge_page_cache();
$type = 'Page cache';
$res = $purge ? 'Cleared' : 'Not Cleared';
helpers\log("Purging {$type} result: {$res}");
}
if ($class_spinup_cache->is_object_cache_enabled()) {
$purge = $GLOBALS['spinupwp']->cache->purge_object_cache();
$type = 'Object cache';
$res = $purge ? 'Cleared' : 'Not Cleared';
// Commenting out because this helper class is unique to stafflink.
//helpers\log("Purging {$type} result: {$res}");
}
return true;
}
/**
* Clear the cache for the specific URL only.
*/
function clear_spinup_cache_for_this_url(): bool
{
// exit quickly if spinup plugin does not exist
if (! class_exists('SpinupWp\Cache')) {
return false;
}
$url = home_url().'/wp-content/plugins/spinupwp/';
$class_spinup_admin = new SpinupWp\AdminBar($url);
$class_spinup_cli = new SpinupWp\Cli;
$class_spinup_cache = new SpinupWp\Cache($class_spinup_admin, $class_spinup_cli);
if ($class_spinup_cache->is_page_cache_enabled()) {
$url = $_SERVER['HTTP_REFERER'];
$purge = $GLOBALS['spinupwp']->cache->purge_url($url);
$type = 'URL page cache';
$res = $purge ? 'Cleared' : 'Not Cleared';
// Log page cache if success
// Commented out because this helper class is unique to STAFFLINK.
//helpers\log("Purging {$type} result: {$res}");
}
}
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- You must be logged in to reply to this topic.