Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 50 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 1 |
BluehostPlugin | |
0.00% |
0 / 50 |
|
0.00% |
0 / 7 |
56 | |
0.00% |
0 / 1 |
register_hooks | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 | |||
site_launch | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 | |||
sso_success | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
sso_fail | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
staging | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
feature_enable | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
feature_disable | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace NewfoldLabs\WP\Module\Data\Listeners; |
4 | |
5 | /** |
6 | * Monitors generic plugin events |
7 | */ |
8 | class BluehostPlugin extends Listener { |
9 | |
10 | /** |
11 | * Register the hooks for the subscriber |
12 | * |
13 | * @return void |
14 | */ |
15 | public function register_hooks() { |
16 | |
17 | // Site Launched - Coming Soon page disabled |
18 | add_action( 'newfold/coming-soon/disabled', array( $this, 'site_launch' ) ); |
19 | |
20 | // SSO (Legacy) |
21 | add_action( 'eig_sso_success', array( $this, 'sso_success' ), 10, 2 ); |
22 | add_action( 'eig_sso_fail', array( $this, 'sso_fail' ) ); |
23 | |
24 | // SSO |
25 | add_action( 'newfold_sso_success', array( $this, 'sso_success' ), 10, 2 ); |
26 | add_action( 'newfold_sso_fail', array( $this, 'sso_fail' ) ); |
27 | |
28 | // Staging |
29 | add_action( 'bh_staging_command', array( $this, 'staging' ) ); |
30 | |
31 | // Features |
32 | add_action( 'newfold/features/action/onEnable', array( $this, 'feature_enable' ) ); |
33 | add_action( 'newfold/features/action/onDisable', array( $this, 'feature_disable' ) ); |
34 | } |
35 | |
36 | /** |
37 | * Disable Coming Soon |
38 | */ |
39 | public function site_launch() { |
40 | $mm_install_time = get_option( 'mm_install_date', gmdate( 'M d, Y' ) ); |
41 | $install_time = apply_filters( 'nfd_install_date_filter', strtotime( $mm_install_time ) ); |
42 | |
43 | $this->push( |
44 | 'site_launched', |
45 | array( |
46 | 'ttl' => time() - $install_time, |
47 | ) |
48 | ); |
49 | } |
50 | |
51 | /** |
52 | * Successful SSO |
53 | * |
54 | * @param \WP_User $user User who logged in |
55 | * @param string $redirect URL redirected to after login |
56 | * |
57 | * @return void |
58 | */ |
59 | public function sso_success( $user, $redirect ) { |
60 | $data = array( |
61 | 'label_key' => 'status', |
62 | 'status' => 'success', |
63 | 'landing_page' => $redirect, |
64 | ); |
65 | $this->push( 'sso', $data ); |
66 | } |
67 | |
68 | /** |
69 | * SSO failure |
70 | * |
71 | * @return void |
72 | */ |
73 | public function sso_fail() { |
74 | $this->push( |
75 | 'sso', |
76 | array( |
77 | 'label_key' => 'status', |
78 | 'status' => 'fail', |
79 | ) |
80 | ); |
81 | } |
82 | |
83 | /** |
84 | * Staging commands executed |
85 | * |
86 | * @param string $command The staging command executed |
87 | * |
88 | * @return void |
89 | */ |
90 | public function staging( $command ) { |
91 | $this->push( |
92 | 'staging', |
93 | array( |
94 | 'label_key' => 'command', |
95 | 'command' => $command, |
96 | ) |
97 | ); |
98 | } |
99 | |
100 | /** |
101 | * Feature Enable event |
102 | * |
103 | * @param string $name The feature name |
104 | * |
105 | * @return void |
106 | */ |
107 | public function feature_enable( $name ) { |
108 | $this->push( |
109 | 'features', |
110 | array( |
111 | 'label_key' => 'enabled', |
112 | 'feature' => $name, |
113 | ) |
114 | ); |
115 | } |
116 | |
117 | /** |
118 | * Feature Disable event |
119 | * |
120 | * @param string $name The feature name |
121 | * |
122 | * @return void |
123 | */ |
124 | public function feature_disable( $name ) { |
125 | $this->push( |
126 | 'features', |
127 | array( |
128 | 'label_key' => 'disabled', |
129 | 'feature' => $name, |
130 | ) |
131 | ); |
132 | } |
133 | } |