| 1 |
<?php |
| 2 |
/** |
| 3 |
* Handles adding a new section to the site health data screen. |
| 4 |
* |
| 5 |
* @since 0.1.0 |
| 6 |
* |
| 7 |
* @package SolidWP\Performance |
| 8 |
*/ |
| 9 |
|
| 10 |
namespace SolidWP\Performance\Telemetry; |
| 11 |
|
| 12 |
/** |
| 13 |
* Handles adding a new section to the site health data screen. |
| 14 |
* |
| 15 |
* @since 0.1.0 |
| 16 |
* |
| 17 |
* @package SolidWP\Performance |
| 18 |
*/ |
| 19 |
class Health_Data { |
| 20 |
|
| 21 |
/** |
| 22 |
* Adds a new Solid Performance section to site health data. |
| 23 |
* |
| 24 |
* @since 0.1.0 |
| 25 |
* |
| 26 |
* @filter debug_information |
| 27 |
* |
| 28 |
* @param array $info The array of site health data. |
| 29 |
* |
| 30 |
* @return array |
| 31 |
*/ |
| 32 |
public function add_summary_to_telemetry( array $info ): array { |
| 33 |
$page_cache = swpsp_config_get( 'page_cache' ); |
| 34 |
$page_cache_status = $page_cache['enabled'] ? esc_html__( 'Enabled', 'solid-performance' ) : esc_html__( 'Disabled', 'solid-performance' ); |
| 35 |
$cache_dir_writeable = swpsp_direct_filesystem()->is_writable( $page_cache['cache_dir'] ) ? esc_html__( 'Writable', 'solid-performance' ) : esc_html__( 'Not Writable', 'solid-performance' ); |
| 36 |
$debug_mode_status = $page_cache['debug'] ? esc_html__( 'Enabled', 'solid-performance' ) : esc_html__( 'Disabled', 'solid-performance' ); |
| 37 |
$exclusion_count = count( $page_cache['exclusions'] ); |
| 38 |
|
| 39 |
$info['solid-performance'] = [ |
| 40 |
'label' => esc_html__( 'Solid Performance', 'solid-performance' ), |
| 41 |
'fields' => [ |
| 42 |
'page_cache_status' => [ |
| 43 |
'label' => esc_html__( 'Page Cache', 'solid-performance' ), |
| 44 |
'value' => $page_cache_status, |
| 45 |
'debug' => strtolower( $page_cache_status ), |
| 46 |
], |
| 47 |
'cache_directory' => [ |
| 48 |
'label' => esc_html__( 'Cache Directory', 'solid-performance' ), |
| 49 |
'value' => $page_cache['cache_dir'], |
| 50 |
'debug' => $page_cache['cache_dir'], |
| 51 |
], |
| 52 |
'cache_directory_writable' => [ |
| 53 |
'label' => esc_html__( 'Cache Directory Permissions', 'solid-performance' ), |
| 54 |
'value' => $cache_dir_writeable, |
| 55 |
'debug' => strtolower( $cache_dir_writeable ), |
| 56 |
], |
| 57 |
'debug_mode' => [ |
| 58 |
'label' => esc_html__( 'Debug Mode', 'solid-performance' ), |
| 59 |
'value' => $debug_mode_status, |
| 60 |
'debug' => strtolower( $debug_mode_status ), |
| 61 |
], |
| 62 |
'exclusion_count' => [ |
| 63 |
'label' => esc_html__( 'Number of custom exclusions', 'solid-performance' ), |
| 64 |
'value' => $exclusion_count, |
| 65 |
], |
| 66 |
], |
| 67 |
]; |
| 68 |
|
| 69 |
return $info; |
| 70 |
} |
| 71 |
} |
| 72 |
|