-
Notifications
You must be signed in to change notification settings - Fork 4
/
BluehostPlugin.php
133 lines (118 loc) · 2.55 KB
/
BluehostPlugin.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
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
<?php
namespace NewfoldLabs\WP\Module\Data\Listeners;
/**
* Monitors generic plugin events
*/
class BluehostPlugin extends Listener {
/**
* Register the hooks for the subscriber
*
* @return void
*/
public function register_hooks() {
// Site Launched - Coming Soon page disabled
add_action( 'newfold/coming-soon/disabled', array( $this, 'site_launch' ) );
// SSO (Legacy)
add_action( 'eig_sso_success', array( $this, 'sso_success' ), 10, 2 );
add_action( 'eig_sso_fail', array( $this, 'sso_fail' ) );
// SSO
add_action( 'newfold_sso_success', array( $this, 'sso_success' ), 10, 2 );
add_action( 'newfold_sso_fail', array( $this, 'sso_fail' ) );
// Staging
add_action( 'bh_staging_command', array( $this, 'staging' ) );
// Features
add_action( 'newfold/features/action/onEnable', array( $this, 'feature_enable' ) );
add_action( 'newfold/features/action/onDisable', array( $this, 'feature_disable' ) );
}
/**
* Disable Coming Soon
*/
public function site_launch() {
$mm_install_time = get_option( 'mm_install_date', gmdate( 'M d, Y' ) );
$install_time = apply_filters( 'nfd_install_date_filter', strtotime( $mm_install_time ) );
$this->push(
'site_launched',
array(
'ttl' => time() - $install_time,
)
);
}
/**
* Successful SSO
*
* @param \WP_User $user User who logged in
* @param string $redirect URL redirected to after login
*
* @return void
*/
public function sso_success( $user, $redirect ) {
$data = array(
'label_key' => 'status',
'status' => 'success',
'landing_page' => $redirect,
);
$this->push( 'sso', $data );
}
/**
* SSO failure
*
* @return void
*/
public function sso_fail() {
$this->push(
'sso',
array(
'label_key' => 'status',
'status' => 'fail',
)
);
}
/**
* Staging commands executed
*
* @param string $command The staging command executed
*
* @return void
*/
public function staging( $command ) {
$this->push(
'staging',
array(
'label_key' => 'command',
'command' => $command,
)
);
}
/**
* Feature Enable event
*
* @param string $name The feature name
*
* @return void
*/
public function feature_enable( $name ) {
$this->push(
'features',
array(
'label_key' => 'enabled',
'feature' => $name,
)
);
}
/**
* Feature Disable event
*
* @param string $name The feature name
*
* @return void
*/
public function feature_disable( $name ) {
$this->push(
'features',
array(
'label_key' => 'disabled',
'feature' => $name,
)
);
}
}