Skip to content

Commit 02c58a6

Browse files
authored
Merge pull request #25 from stodorovic/fixes-commands-enable-disable
Fixes discrepancy between commands ena/dis and status
2 parents dccc426 + 7eb716c commit 02c58a6

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/WP_Super_Cache_Command.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,20 @@ public function status( $args = array(), $assoc_args = array() ) {
115115
* @when after_wp_load
116116
*/
117117
public function enable( $args = array(), $assoc_args = array() ) {
118-
global $super_cache_enabled;
118+
global $cache_enabled, $wp_cache_mod_rewrite;
119119

120120
$this->load();
121-
wp_super_cache_enable();
122121

123-
if ( $super_cache_enabled ) {
122+
wp_cache_enable();
123+
if ( ! defined( 'DISABLE_SUPERCACHE' ) ) {
124+
wp_super_cache_enable();
125+
}
126+
127+
if ( $wp_cache_mod_rewrite ) {
128+
add_mod_rewrite_rules();
129+
}
130+
131+
if ( $cache_enabled ) {
124132
WP_CLI::success( 'The WP Super Cache is enabled.' );
125133
} else {
126134
WP_CLI::error( 'The WP Super Cache is not enabled, check its settings page for more info.' );
@@ -133,12 +141,14 @@ public function enable( $args = array(), $assoc_args = array() ) {
133141
* @when after_wp_load
134142
*/
135143
public function disable( $args = array(), $assoc_args = array() ) {
136-
global $super_cache_enabled;
144+
global $cache_enabled;
137145

138146
$this->load();
147+
148+
wp_cache_disable();
139149
wp_super_cache_disable();
140150

141-
if ( ! $super_cache_enabled ) {
151+
if ( ! $cache_enabled ) {
142152
WP_CLI::success( 'The WP Super Cache is disabled.' );
143153
} else {
144154
WP_CLI::error( 'The WP Super Cache is still enabled, check its settings page for more info.' );

0 commit comments

Comments
 (0)