| 1 |
<?php |
| 2 |
/** |
| 3 |
* Health info screen. |
| 4 |
* |
| 5 |
* @package ElasticPress |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace ElasticPress\Screen; |
| 9 |
|
| 10 |
use ElasticPress\Features; |
| 11 |
use ElasticPress\Utils; |
| 12 |
|
| 13 |
/** |
| 14 |
* Health info screen Class. |
| 15 |
*/ |
| 16 |
class HealthInfo { |
| 17 |
|
| 18 |
/** |
| 19 |
* Initialize class. |
| 20 |
*/ |
| 21 |
public function setup() { |
| 22 |
add_filter( 'debug_information', [ $this, 'last_sync_health_info' ] ); |
| 23 |
add_filter( 'debug_information', [ $this, 'epio_autosuggest_health_check_info' ] ); |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Display sync info in site health screen. |
| 28 |
* |
| 29 |
* @param array $debug_info The debug info for site health screen. |
| 30 |
* @return array The debug info for site health screen. |
| 31 |
*/ |
| 32 |
public function last_sync_health_info( $debug_info ) { |
| 33 |
$last_sync_report = new \ElasticPress\StatusReport\LastSync(); |
| 34 |
|
| 35 |
$groups = $last_sync_report->get_groups(); |
| 36 |
$first_group = reset( $groups ); |
| 37 |
|
| 38 |
$debug_info['ep-last-sync'] = [ |
| 39 |
'label' => esc_html__( 'ElasticPress - Last Sync', 'elasticpress' ), |
| 40 |
'fields' => $first_group['fields'], |
| 41 |
]; |
| 42 |
|
| 43 |
return $debug_info; |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* Add Autosuggest info for EP.io Users in Health Check Info Screen. |
| 48 |
* |
| 49 |
* @since 3.5.x |
| 50 |
* @param array $debug_info Debug Info set so far. |
| 51 |
* @return array |
| 52 |
*/ |
| 53 |
public function epio_autosuggest_health_check_info( $debug_info ) { |
| 54 |
if ( ! Utils\is_epio() ) { |
| 55 |
return $debug_info; |
| 56 |
} |
| 57 |
|
| 58 |
$feature = Features::factory()->get_registered_feature( 'autosuggest' ); |
| 59 |
|
| 60 |
if ( ! $feature || ! $feature->is_active() ) { |
| 61 |
return $debug_info; |
| 62 |
} |
| 63 |
|
| 64 |
$epio_report = new \ElasticPress\StatusReport\ElasticPressIo(); |
| 65 |
$groups = $epio_report->get_groups(); |
| 66 |
$first_group = reset( $groups ); |
| 67 |
|
| 68 |
$debug_info['epio-autosuggest'] = [ |
| 69 |
'label' => esc_html__( 'ElasticPress.io - Autosuggest', 'elasticpress' ), |
| 70 |
'fields' => $first_group['fields'], |
| 71 |
]; |
| 72 |
|
| 73 |
return $debug_info; |
| 74 |
} |
| 75 |
} |
| 76 |
|