Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| Deactivate_WPSC | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
| handle | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Automattic\Jetpack_Boost\Modules\Optimizations\Page_Cache\Data_Sync_Actions; |
| 4 | |
| 5 | use Automattic\Jetpack\WP_JS_Data_Sync\Contracts\Data_Sync_Action; |
| 6 | |
| 7 | /** |
| 8 | * Cache Action: Disable Super Cache |
| 9 | */ |
| 10 | class Deactivate_WPSC implements Data_Sync_Action { |
| 11 | |
| 12 | /** |
| 13 | * Handles the action logic. |
| 14 | * |
| 15 | * @param mixed $_data JSON Data passed to the action. |
| 16 | * @param null|\WP_REST_Request $_request The request object. |
| 17 | */ |
| 18 | public function handle( $_data = null, $_request = null ) { |
| 19 | // Super Cache will define WPCACHEHOME if it's active. |
| 20 | if ( ! defined( 'WPCACHEHOME' ) ) { |
| 21 | return true; |
| 22 | } |
| 23 | |
| 24 | // Find the plugin base path for super cache. |
| 25 | $super_cache_dir = basename( WPCACHEHOME ); |
| 26 | $plugin = $super_cache_dir . '/wp-cache.php'; |
| 27 | |
| 28 | // Load the necessary files to deactivate the plugin. |
| 29 | require_once ABSPATH . 'wp-admin/includes/misc.php'; |
| 30 | require_once ABSPATH . 'wp-admin/includes/file.php'; |
| 31 | deactivate_plugins( $plugin ); |
| 32 | |
| 33 | $success = ! is_plugin_active( $plugin ); |
| 34 | |
| 35 | return $success; |
| 36 | } |
| 37 | } |