forked from newfold-labs/wp-module-deactivation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Deactivation.php
64 lines (55 loc) · 1.21 KB
/
Deactivation.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
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
<?php
/**
* Deactivation class file.
*
* @package NewfoldLabs\WP\Module\Deactivation
*/
namespace NewfoldLabs\WP\Module\Deactivation;
use NewfoldLabs\WP\ModuleLoader\Container;
use NewfoldLabs\WP\Module\Deactivation\DeactivationSurvey;
/**
* Deactivation class.
*/
class Deactivation {
/**
* Dependency injection container.
*
* @var Container
*/
protected $container;
/**
* Constructor.
*
* @param Container $container The plugin container.
*/
public function __construct( Container $container ) {
$this->container = $container;
register_deactivation_hook(
$container->plugin()->file,
array( $this, 'handle' )
);
// Plugin deactivation survey.
add_action( 'admin_head-plugins.php', function () {
new DeactivationSurvey();
} );
}
/**
* Handle deactivation.
*
* @return void
*/
public function handle() {
$this->disable_coming_soon();
}
/**
* Disable the coming soon page.
*
* @return void
*/
public function disable_coming_soon() {
$coming_soon_service = $this->container->has( 'comingSoon' ) ? $this->container->get( 'comingSoon' ) : null;
if ( $coming_soon_service && $coming_soon_service->is_enabled() ) {
$coming_soon_service->disable();
}
}
}