© MainWP - WordPress Management for Professionals 2014 - 2023 - Terms of Service - Privacy Policy - Cookie Policy - Support Policy - Refund Policy
The MainWP Cache Control Extension itself is designed to give the ability to tap into a class file that actually lives within the MainWP Child Plugin. So in order to add additional support for other 3rd-party Cache Plugins – you simply need to add the correct hooks to the class-mainwp-child-cache-purge.php file & then perform a Pull request on GitHub. Our Development team will go over your code & then perform the merge within a future release.
How to fork a repository, push to GitHub & perform a GitHub Pull Request is out of the scope of this tutorial. You may read how to perform these tasks here:
Pushing commits to a remote repository
'swis-performance/swis-performance.php' => 'Swis Performance',
case 'Swis Performance':
$information = $this->swis_performance_auto_purge_cache();
break;
This is our custom method that will finally fire off the custom purge action. Each new addition will be slightly different due to the nature of “custom methods”, however, there are only a few lines within each custom method that need to stay the same in order to function seamlessly with the MainWP Dashboard.
We will need to have our $success_message & $error_message & $bypass-Message pre-written for when we return the purge_result() array once our plugin has purged its cache.
You will usually need to check if the plugins class has been initialized in order to call its methods. This method first checks if the public `swis` function is loaded & callable – If the public `swis` function is not found it will throw the error message – if it is found it will continue on with the operation…
Next it will grab the saved cache settings & check to see if the built-in auto-purge function is active, so that two cache purge routines are not run simultaneously. If the setting is not set it will proceed to fire off the ‘swis_clear_complete_cache’ action & then record / return the purge_result() array.
/**
* Purge Swis Performance plugin cache.
*
* @return array Purge results array.
*/
public function swis_performance_auto_purge_cache() {
$success_message = 'Swis Performance => Cache auto cleared on: (' . current_time( 'mysql' ) . ')';
$error_message = 'Swis Performance => There was an issue purging your cache.';
$bypass_message = 'Swis Performance => Purge was bypassed due to Swis Auto Purge Settings.';
if ( is_callable( 'swis' ) ) {
$swis_cache_settings = swis()->cache->get_settings();
if ( empty( $swis_cache_settings['clear_complete_cache_on_changed_plugin'] ) ) {
do_action( 'swis_clear_complete_cache' );
} else {
return $this->purge_result( $bypass_message, 'SUCCESS' );
}
// record results. ( below needs to stay untouched )
update_option( 'mainwp_cache_control_last_purged', time() );
return $this->purge_result( $success_message, 'SUCCESS' );
} else {
return $this->purge_result( $error_message, 'ERROR' );
}
}
After everything has been added the newly supported plugin data should be available after a Re-Sync & First Purge. This data is automatically displayed on the Sites Management Page under the “Cache Solution” & “Last Purged Cache” columns as well as on the Extensions > Cache Control > Logs page as shown below.