-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathWcpSettingUtils.php
39 lines (35 loc) · 1.5 KB
/
WcpSettingUtils.php
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
34
35
36
37
38
39
<?php
namespace WebSharks\CometCache\Pro\Traits\Plugin;
use WebSharks\CometCache\Pro\Classes;
trait WcpSettingUtils
{
/**
* Automatically clears all cache files for current blog under various conditions;
* used to check for conditions that don't have a hook that we can attach to.
*
* @since 150422 Rewrite.
*
* @attaches-to `admin_init` hook.
*/
public function autoClearCacheOnSettingChanges()
{
$counter = 0; // Initialize.
$pagenow = !empty($GLOBALS['pagenow']) ? $GLOBALS['pagenow'] : '';
$settings_updated = !empty($_REQUEST['settings-updated']);
if (!is_null($done = &$this->cacheKey('autoClearCacheOnSettingChanges', [$pagenow, $settings_updated]))) {
return $counter; // Already did this.
}
$done = true; // Flag as having been done.
if ($pagenow === 'options-general.php' && $settings_updated) {
$this->addWpHtaccess(); // Update .htaccess if applicable
$counter += $this->autoClearCache();
} elseif ($pagenow === 'options-reading.php' && $settings_updated) {
$counter += $this->autoClearCache();
} elseif ($pagenow === 'options-discussion.php' && $settings_updated) {
$counter += $this->autoClearCache();
} elseif ($pagenow === 'options-permalink.php' && $settings_updated) {
$this->addWpHtaccess(); // Update .htaccess if applicable
$counter += $this->autoClearCache();
}
}
}