| 1 |
<?php |
| 2 |
/** |
| 3 |
* ElasticPress report class |
| 4 |
* |
| 5 |
* @since 4.4.0 |
| 6 |
* @package elasticpress |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace ElasticPress\StatusReport; |
| 10 |
|
| 11 |
use ElasticPress\Utils; |
| 12 |
|
| 13 |
defined( 'ABSPATH' ) || exit; |
| 14 |
|
| 15 |
/** |
| 16 |
* ElasticPress report class |
| 17 |
* |
| 18 |
* @package ElasticPress |
| 19 |
*/ |
| 20 |
class ElasticPress extends Report { |
| 21 |
|
| 22 |
/** |
| 23 |
* Return the report title |
| 24 |
* |
| 25 |
* @return string |
| 26 |
*/ |
| 27 |
public function get_title(): string { |
| 28 |
return __( 'ElasticPress', 'elasticpress' ); |
| 29 |
} |
| 30 |
|
| 31 |
/** |
| 32 |
* Return the report fields |
| 33 |
* |
| 34 |
* @return array |
| 35 |
*/ |
| 36 |
public function get_groups(): array { |
| 37 |
return [ |
| 38 |
$this->get_basic_settings(), |
| 39 |
$this->get_timeouts(), |
| 40 |
]; |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Process ElasticPress's basic settings. |
| 45 |
* |
| 46 |
* @return array |
| 47 |
*/ |
| 48 |
protected function get_basic_settings(): array { |
| 49 |
$is_epio = Utils\is_epio(); |
| 50 |
|
| 51 |
$fields = []; |
| 52 |
|
| 53 |
$fields['host'] = [ |
| 54 |
'label' => $is_epio ? __( 'ElasticPress.io Host URL', 'elasticpress' ) : __( 'Elasticsearch Host URL', 'elasticpress' ), |
| 55 |
'value' => Utils\get_host(), |
| 56 |
]; |
| 57 |
|
| 58 |
$fields['index_prefix'] = [ |
| 59 |
'label' => __( 'Index Prefix', 'elasticpress' ), |
| 60 |
'value' => Utils\get_index_prefix(), |
| 61 |
]; |
| 62 |
|
| 63 |
$fields['language'] = [ |
| 64 |
'label' => __( 'Elasticsearch Language', 'elasticpress' ), |
| 65 |
'value' => Utils\get_language(), |
| 66 |
]; |
| 67 |
|
| 68 |
$fields['per_page'] = [ |
| 69 |
'label' => __( 'Content Items per Index Cycle', 'elasticpress' ), |
| 70 |
'value' => \ElasticPress\IndexHelper::factory()->get_index_default_per_page(), |
| 71 |
]; |
| 72 |
|
| 73 |
$fields['network_active'] = [ |
| 74 |
'label' => __( 'Network Active', 'elasticpress' ), |
| 75 |
'value' => is_multisite() && defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK, |
| 76 |
]; |
| 77 |
|
| 78 |
return [ |
| 79 |
'title' => __( 'Settings', 'elasticpress' ), |
| 80 |
'fields' => $fields, |
| 81 |
]; |
| 82 |
} |
| 83 |
|
| 84 |
/** |
| 85 |
* Process ElasticPress timeouts. |
| 86 |
* |
| 87 |
* @return array |
| 88 |
*/ |
| 89 |
protected function get_timeouts() { |
| 90 |
$default_index_document_timeout = 15; |
| 91 |
$fields['index_document_timeout'] = [ |
| 92 |
'label' => sprintf( |
| 93 |
/* translators: default time */ |
| 94 |
__( 'Single Document Sync Requests Timeout (default: %s)', 'elasticpress' ), |
| 95 |
$default_index_document_timeout |
| 96 |
), |
| 97 |
'value' => apply_filters( 'ep_index_document_timeout', $default_index_document_timeout ), |
| 98 |
]; |
| 99 |
|
| 100 |
$default_bulk_request_timeout = 30; |
| 101 |
$fields['bulk_request_timeout'] = [ |
| 102 |
'label' => sprintf( |
| 103 |
/* translators: default time */ |
| 104 |
__( 'Multiple Document Sync Requests Timeout (default: %s)', 'elasticpress' ), |
| 105 |
$default_bulk_request_timeout |
| 106 |
), |
| 107 |
'value' => apply_filters( 'bulk_request_timeout', $default_bulk_request_timeout ), |
| 108 |
]; |
| 109 |
|
| 110 |
$default_request_timeout = 5; |
| 111 |
$fields['request_timeout'] = [ |
| 112 |
'label' => sprintf( |
| 113 |
/* translators: default time */ |
| 114 |
__( 'Other HTTP Requests Timeout (default: %s)', 'elasticpress' ), |
| 115 |
$default_request_timeout |
| 116 |
), |
| 117 |
'value' => apply_filters( 'http_request_timeout', $default_request_timeout, Utils\get_host() ), |
| 118 |
]; |
| 119 |
|
| 120 |
return [ |
| 121 |
'title' => __( 'Timeouts', 'elasticpress' ), |
| 122 |
'fields' => $fields, |
| 123 |
]; |
| 124 |
} |
| 125 |
} |
| 126 |
|