Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 14 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
SiteHealth | |
0.00% |
0 / 14 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
register_hooks | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
tests_run | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace NewfoldLabs\WP\Module\Data\Listeners; |
4 | |
5 | use NewfoldLabs\WP\Module\Data\Helpers\SiteHealth as SiteHealthHelper; |
6 | |
7 | /** |
8 | * Monitors Site Health events |
9 | */ |
10 | class SiteHealth extends Listener { |
11 | |
12 | /** |
13 | * Register the hooks for the subscriber |
14 | * |
15 | * @since 1.7.0 |
16 | * |
17 | * @return void |
18 | */ |
19 | public function register_hooks() { |
20 | // Site Health tests have run and the transient is updated. |
21 | add_action( 'set_transient_health-check-site-status-result', array( $this, 'tests_run' ) ); |
22 | } |
23 | |
24 | /** |
25 | * Report Site Health related data |
26 | * |
27 | * @since 1.7.0 |
28 | * |
29 | * @param string $value A JSON string with the results of Site Health tests |
30 | * @return void |
31 | */ |
32 | public function tests_run( $value ) { |
33 | $this->push( |
34 | 'site_health_score', |
35 | array( |
36 | 'label_key' => 'score', |
37 | 'score' => SiteHealthHelper::calculate_score( $value ), |
38 | ) |
39 | ); |
40 | $this->push( |
41 | 'site_health_debug', |
42 | array( |
43 | 'debug_data' => wp_json_encode( SiteHealthHelper::get_safe_data() ), |
44 | ) |
45 | ); |
46 | } |
47 | } |