| 1 |
<?php |
| 2 |
/** |
| 3 |
* Main plugin bootstrap. |
| 4 |
* |
| 5 |
* @package XSpeed |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace XSpeed; |
| 9 |
|
| 10 |
defined( 'ABSPATH' ) || exit; |
| 11 |
|
| 12 |
class Plugin { |
| 13 |
|
| 14 |
private static $instance = null; |
| 15 |
|
| 16 |
public static function instance() { |
| 17 |
if ( null === self::$instance ) { |
| 18 |
self::$instance = new self(); |
| 19 |
} |
| 20 |
return self::$instance; |
| 21 |
} |
| 22 |
|
| 23 |
public function init() { |
| 24 |
new Admin(); |
| 25 |
new Rest_Api(); |
| 26 |
new Cache(); |
| 27 |
new Minifier(); |
| 28 |
} |
| 29 |
|
| 30 |
public static function activate() { |
| 31 |
Settings::set_defaults(); |
| 32 |
|
| 33 |
if ( ! file_exists( XSPEED_CACHE_DIR ) ) { |
| 34 |
wp_mkdir_p( XSPEED_CACHE_DIR ); |
| 35 |
} |
| 36 |
Cache::write_silence( XSPEED_CACHE_DIR ); |
| 37 |
|
| 38 |
// Drop-in installation (advanced-cache.php) and the WP_CACHE constant |
| 39 |
// edit happen only when the user explicitly enables caching from the |
| 40 |
// admin UI — never on activation. See Cache::toggle() and |
| 41 |
// Rest_Api::toggle_cache(). This is a WordPress.org review requirement. |
| 42 |
} |
| 43 |
|
| 44 |
public static function deactivate() { |
| 45 |
Cache::remove_dropin(); |
| 46 |
Cache::set_wp_cache_constant( false ); |
| 47 |
Cache::purge_all(); |
| 48 |
Minifier::purge_minified(); |
| 49 |
Gzip::apply( false ); |
| 50 |
} |
| 51 |
} |
| 52 |
|