ModuleStatus.php
3.14 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
namespace W3TC;
class ModuleStatus {
private $_opcode_engines = array(
'apc',
'eaccelerator',
'xcache',
'wincache'
);
private $_file_engines = array(
'file',
'file_generic'
);
private $_config;
public function __construct() {
$this->_config = Dispatcher::config();
}
/**
*
*
* @return bool
*/
public function plugin_is_enabled() {
return $this->is_enabled( 'pgcache' )
|| $this->is_enabled( 'minify' )
|| $this->is_enabled( 'dbcache' )
|| $this->is_enabled( 'objectcache' )
|| $this->is_enabled( 'browsercache' )
|| $this->is_enabled( 'cdn' )
|| $this->is_enabled( 'varnish' )
|| $this->is_enabled( 'newrelic' )
|| $this->is_enabled( 'fragmentcache' );
}
/**
*
*
* @param unknown $module
* @return bool
*/
public function is_enabled( $module ) {
return $this->_config->get_boolean( "$module.enabled" );
}
/**
* Verifies that the module is actually running and not only enabled.
*
* @param unknown $module
* @return mixed|void
*/
public function is_running( $module ) {
return apply_filters( "w3tc_module_is_running-{$module}", $this->is_enabled( $module ) );
}
/**
*
*
* @return bool
*/
public function all_modules_enabled() {
return $this->is_enabled( 'pgcache' )
&& $this->is_enabled( 'minify' )
&& $this->is_enabled( 'dbcache' )
&& $this->is_enabled( 'objectcache' )
&& $this->is_enabled( 'browsercache' )
&& $this->is_enabled( 'cdn' )
&& $this->is_enabled( 'varnish' )
&& $this->is_enabled( 'fragmentcache' );
}
/**
*
*
* @return bool
*/
public function can_empty_memcache() {
return $this->_enabled_module_uses_engine( 'pgcache', 'memcached' )
|| $this->_enabled_module_uses_engine( 'dbcache', 'memcached' )
|| $this->_enabled_module_uses_engine( 'objectcache', 'memcached' )
|| $this->_enabled_module_uses_engine( 'minify', 'memcached' )
|| $this->_enabled_module_uses_engine( 'fragmentcache', 'memcached' );
}
/**
*
*
* @return bool
*/
public function can_empty_opcode() {
$o = Dispatcher::component( 'SystemOpCache_Core' );
return $o->is_enabled();
}
/**
*
*
* @return bool
*/
public function can_empty_file() {
return $this->_enabled_module_uses_engine( 'pgcache', $this->_file_engines )
|| $this->_enabled_module_uses_engine( 'dbcache', $this->_file_engines )
|| $this->_enabled_module_uses_engine( 'objectcache', $this->_file_engines )
|| $this->_enabled_module_uses_engine( 'minify', $this->_file_engines )
|| $this->_enabled_module_uses_engine( 'fragmentcache', $this->_file_engines );
}
/**
*
*
* @return mixed
*/
public function can_empty_varnish() {
return $this->_config->get_boolean( 'varnish.enabled' );
}
/**
*
*
* @param unknown $module
* @return mixed
*/
public function get_module_engine( $module ) {
return $this->_config->get_string( "$module.engine" );
}
private function _enabled_module_uses_engine( $module, $engine ) {
if ( is_array( $engine ) )
return $this->is_enabled( $module ) && in_array( $this->get_module_engine( $module ), $engine );
else
return $this->is_enabled( $module ) && $this->get_module_engine( $module ) == $engine;
}
}