PluginProbe
ElasticPress / 5.3.5
ElasticPress v5.3.5
5.3.5 5.3.4 3.6.5 3.6.6 4.0.0 4.0.1 4.1.0 4.2.0 4.2.1 4.2.2 4.3.0 4.3.1 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.6.0 4.6.1 4.7.0 4.7.1 4.7.2 5.0.0 5.0.1 5.0.2 All 108 releases
← All changes | includes/classes/StatusReport/ElasticPressIo.php +114 -14 4.4.1 → 5.3.5 View file →
@@ -25,9 +25,9 @@
25 25 * Return the report title
26 26 *
27 27 * @return string
28 28 */
29 - public function get_title() : string {
29 + public function get_title(): string {
30 30 return __( 'ElasticPress.io', 'elasticpress' );
31 31 }
32 32
33 33 /**
@@ -34,12 +34,13 @@
34 34 * Return the report fields
35 35 *
36 36 * @return array
37 37 */
38 - public function get_groups() : array {
38 + public function get_groups(): array {
39 39 $groups = [
40 40 $this->get_autosuggest_group(),
41 41 $this->get_instant_results_group(),
42 + $this->get_orders_search_group(),
42 43 ];
43 44
44 45 return array_values( array_filter( $groups ) );
45 46 }
@@ -48,9 +49,9 @@
48 49 * Process the ElasticPress.io Autosuggest allowed parameters.
49 50 *
50 51 * @return array
51 52 */
52 - protected function get_autosuggest_group() : array {
53 + protected function get_autosuggest_group(): array {
53 54 $autosuggest_feature = \ElasticPress\Features::factory()->get_registered_feature( 'autosuggest' );
54 55
55 56 if ( ! $autosuggest_feature->is_active() ) {
56 57 return [];
@@ -58,12 +59,26 @@
58 59
59 60 $title = __( 'Allowed Autosuggest Parameters', 'elasticpress' );
60 61 $allowed_params = $autosuggest_feature->epio_autosuggest_set_and_get();
61 62
63 + $reset_url = [
64 + 'label' => 'Reset URL',
65 + 'value' => wp_kses_post(
66 + sprintf(
67 + /* translators: %s: URL */
68 + __( 'If you need to reset the allowed parameters, you can do so by saving your Search Fields & Weighting settings or by visiting <a href="%s">this URL</a>.', 'elasticpress' ),
69 + $autosuggest_feature->get_epio_public_request_url()
70 + )
71 + ),
72 + ];
73 +
62 74 if ( empty( $allowed_params ) ) {
63 - $fields['not_available'] = [
64 - 'label' => __( 'Allowed Autosuggest Parameters', 'elasticpress' ),
65 - 'value' => __( 'Allowed autosuggest parameters info not available.', 'elasticpress' ),
75 + $fields = [
76 + 'not_available' => [
77 + 'label' => __( 'Allowed Autosuggest Parameters', 'elasticpress' ),
78 + 'value' => __( 'Allowed autosuggest parameters info not available.', 'elasticpress' ),
79 + ],
80 + 'url' => $reset_url,
66 81 ];
67 82
68 83 return [
69 84 'title' => $title,
@@ -96,8 +111,10 @@
96 111 'value' => $value,
97 112 ];
98 113 }
99 114
115 + $formatted_fields['url'] = $reset_url;
116 +
100 117 return [
101 118 'title' => $title,
102 119 'fields' => $formatted_fields,
103 120 ];
@@ -107,9 +124,9 @@
107 124 * Process the ElasticPress.io Instant Results templates.
108 125 *
109 126 * @return array
110 127 */
111 - protected function get_instant_results_group() : array {
128 + protected function get_instant_results_group(): array {
112 129 $instant_results_feature = \ElasticPress\Features::factory()->get_registered_feature( 'instant-results' );
113 130
114 131 if ( ! $instant_results_feature->is_active() ) {
115 132 return [];
@@ -118,15 +135,11 @@
118 135 $title = __( 'Instant Results Template', 'elasticpress' );
119 136 $fields = [];
120 137
121 138 if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) {
122 - $sites = Utils\get_sites();
139 + $sites = Utils\get_sites( 0, true );
123 140
124 141 foreach ( $sites as $site ) {
125 - if ( ! Utils\is_site_indexable( $site['blog_id'] ) ) {
126 - continue;
127 - }
128 -
129 142 switch_to_blog( $site['blog_id'] );
130 143
131 144 $field = $this->get_instant_results_field();
132 145 $fields = array_merge( $fields, $field );
@@ -143,13 +156,54 @@
143 156 ];
144 157 }
145 158
146 159 /**
160 + * Process the ElasticPress.io Orders Search templates.
161 + *
162 + * @since 4.5.0
163 + * @return array
164 + */
165 + protected function get_orders_search_group(): array {
166 + $woocommerce_feature = \ElasticPress\Features::factory()->get_registered_feature( 'woocommerce' );
167 +
168 + if ( ! $woocommerce_feature->is_active() ) {
169 + return [];
170 + }
171 +
172 + if ( ! $woocommerce_feature->orders ) {
173 + return [];
174 + }
175 +
176 + $title = __( 'Orders Search Template', 'elasticpress' );
177 + $fields = [];
178 +
179 + if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) {
180 + $sites = Utils\get_sites( 0, true );
181 +
182 + foreach ( $sites as $site ) {
183 + switch_to_blog( $site['blog_id'] );
184 +
185 + $field = $this->get_orders_search_field();
186 + $fields = array_merge( $fields, $field );
187 +
188 + restore_current_blog();
189 + }
190 + } else {
191 + $fields = $this->get_orders_search_field();
192 + }
193 +
194 + return [
195 + 'title' => $title,
196 + 'fields' => $fields,
197 + ];
198 + }
199 +
200 + /**
147 201 * Process the ElasticPress.io Instant Results template.
148 202 *
149 - * @return array|null
203 + * @return array
150 204 */
151 - protected function get_instant_results_field() : array {
205 + protected function get_instant_results_field(): array {
152 206 $index = Indexables::factory()->get( 'post' )->get_index_name();
153 207
154 208 if ( ! $index ) {
155 209 return [];
@@ -156,8 +210,54 @@
156 210 }
157 211
158 212 $feature = new InstantResults\InstantResults();
159 213 $template = $feature->epio_get_search_template();
214 +
215 + if ( is_wp_error( $template ) ) {
216 + return [
217 + $index => [
218 + 'label' => $index,
219 + 'value' => $template->get_error_message(),
220 + ],
221 + ];
222 + }
223 +
224 + return [
225 + $index => [
226 + 'label' => $index,
227 + 'value' => $template,
228 + ],
229 + ];
230 + }
231 +
232 + /**
233 + * Return the report messages.
234 + *
235 + * @return array
236 + * @since 4.5.0
237 + */
238 + public function get_messages(): array {
239 + $messages = \ElasticPress\get_container()->get( '\ElasticPress\ElasticPressIo' )->get_endpoint_messages( true );
240 + $messages = array_values( $messages );
241 +
242 + return $messages;
243 + }
244 +
245 + /**
246 + * Process the ElasticPress.io Orders Search template.
247 + *
248 + * @since 4.5.0
249 + * @return array
250 + */
251 + protected function get_orders_search_field(): array {
252 + $index = Indexables::factory()->get( 'post' )->get_index_name();
253 +
254 + if ( ! $index ) {
255 + return [];
256 + }
257 +
258 + $woocommerce_feature = \ElasticPress\Features::factory()->get_registered_feature( 'woocommerce' );
259 + $template = $woocommerce_feature->orders_autosuggest->get_search_template();
160 260
161 261 if ( is_wp_error( $template ) ) {
162 262 return [
163 263 $index => [