| 1 |
<?php |
| 2 |
/** |
| 3 |
* Feature report class |
| 4 |
* |
| 5 |
* @since 4.4.0 |
| 6 |
* @package elasticpress |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace ElasticPress\StatusReport; |
| 10 |
|
| 11 |
use \ElasticPress\Features as EP_Features; |
| 12 |
|
| 13 |
defined( 'ABSPATH' ) || exit; |
| 14 |
|
| 15 |
/** |
| 16 |
* Feature report class |
| 17 |
* |
| 18 |
* @package ElasticPress |
| 19 |
*/ |
| 20 |
class Features extends Report { |
| 21 |
|
| 22 |
/** |
| 23 |
* Return the report title |
| 24 |
* |
| 25 |
* @return string |
| 26 |
*/ |
| 27 |
public function get_title() : string { |
| 28 |
return __( 'Feature Settings', 'elasticpress' ); |
| 29 |
} |
| 30 |
|
| 31 |
/** |
| 32 |
* Return the report fields |
| 33 |
* |
| 34 |
* @return array |
| 35 |
*/ |
| 36 |
public function get_groups() : array { |
| 37 |
$features_settings = \ElasticPress\Utils\get_option( 'ep_feature_settings', [] ); |
| 38 |
|
| 39 |
$features = array_filter( |
| 40 |
EP_Features::factory()->registered_features, |
| 41 |
function( $feature ) { |
| 42 |
return $feature->is_active(); |
| 43 |
} |
| 44 |
); |
| 45 |
$features = wp_list_sort( $features, 'title' ); |
| 46 |
|
| 47 |
$groups = []; |
| 48 |
foreach ( $features as $feature ) { |
| 49 |
$feature_settings = $features_settings[ $feature->slug ] ?? []; |
| 50 |
|
| 51 |
$fields = []; |
| 52 |
foreach ( $feature_settings as $feature_setting => $value ) { |
| 53 |
$fields[ $feature_setting ] = [ |
| 54 |
'label' => $feature_setting, |
| 55 |
'value' => $value, |
| 56 |
]; |
| 57 |
} |
| 58 |
ksort( $fields ); |
| 59 |
|
| 60 |
$groups[] = [ |
| 61 |
'title' => $feature->get_short_title(), |
| 62 |
'fields' => $fields, |
| 63 |
]; |
| 64 |
} |
| 65 |
|
| 66 |
return $groups; |
| 67 |
} |
| 68 |
} |
| 69 |
|