-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathWcpPluginUtils.php
More file actions
33 lines (29 loc) · 1.09 KB
/
WcpPluginUtils.php
File metadata and controls
33 lines (29 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
namespace WebSharks\CometCache\Pro\Traits\Plugin;
use WebSharks\CometCache\Pro\Classes;
trait WcpPluginUtils
{
/**
* Automatically wipes/clears on plugin activation/deactivation.
*
* @since 151220 Adding auto-wipe|clear on plugin activations/deactivations.
*
* @attaches-to `activated_plugin` hook.
* @attaches-to `deactivated_plugin` hook.
*
* @param string $plugin Plugin basename.
* @param bool True if activating|deactivating network-wide. Defaults to boolean `FALSE` in case parameter is not passed to hook.
*
* @return int Total files wiped|cleared by this routine (if any).
*
* @note Also wipes the PHP OPCache.
*/
public function autoClearOnPluginActivationDeactivation($plugin, $network_wide = false)
{
if (!apply_filters(GLOBAL_NS.'_auto_clear_on_plugin_activation_deactivation', true)) {
return 0; // Nothing to do here.
}
add_action('shutdown', [$this, 'wipeOpcacheByForce'], PHP_INT_MAX);
return $this->{($network_wide ? 'autoWipeCache' : 'autoClearCache')}();
}
}