| @@ -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,9 +34,9 @@ | ||
| 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 | 42 | $this->get_orders_search_group(), |
| @@ -49,9 +49,9 @@ | ||
| 49 | 49 | * Process the ElasticPress.io Autosuggest allowed parameters. |
| 50 | 50 | * |
| 51 | 51 | * @return array |
| 52 | 52 | */ |
| 53 | - protected function get_autosuggest_group() : array { | |
| 53 | + protected function get_autosuggest_group(): array { | |
| 54 | 54 | $autosuggest_feature = \ElasticPress\Features::factory()->get_registered_feature( 'autosuggest' ); |
| 55 | 55 | |
| 56 | 56 | if ( ! $autosuggest_feature->is_active() ) { |
| 57 | 57 | return []; |
| @@ -59,12 +59,26 @@ | ||
| 59 | 59 | |
| 60 | 60 | $title = __( 'Allowed Autosuggest Parameters', 'elasticpress' ); |
| 61 | 61 | $allowed_params = $autosuggest_feature->epio_autosuggest_set_and_get(); |
| 62 | 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 | + | |
| 63 | 74 | if ( empty( $allowed_params ) ) { |
| 64 | - $fields['not_available'] = [ | |
| 65 | - 'label' => __( 'Allowed Autosuggest Parameters', 'elasticpress' ), | |
| 66 | - '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, | |
| 67 | 81 | ]; |
| 68 | 82 | |
| 69 | 83 | return [ |
| 70 | 84 | 'title' => $title, |
| @@ -97,8 +111,10 @@ | ||
| 97 | 111 | 'value' => $value, |
| 98 | 112 | ]; |
| 99 | 113 | } |
| 100 | 114 | |
| 115 | + $formatted_fields['url'] = $reset_url; | |
| 116 | + | |
| 101 | 117 | return [ |
| 102 | 118 | 'title' => $title, |
| 103 | 119 | 'fields' => $formatted_fields, |
| 104 | 120 | ]; |
| @@ -108,9 +124,9 @@ | ||
| 108 | 124 | * Process the ElasticPress.io Instant Results templates. |
| 109 | 125 | * |
| 110 | 126 | * @return array |
| 111 | 127 | */ |
| 112 | - protected function get_instant_results_group() : array { | |
| 128 | + protected function get_instant_results_group(): array { | |
| 113 | 129 | $instant_results_feature = \ElasticPress\Features::factory()->get_registered_feature( 'instant-results' ); |
| 114 | 130 | |
| 115 | 131 | if ( ! $instant_results_feature->is_active() ) { |
| 116 | 132 | return []; |
| @@ -119,15 +135,11 @@ | ||
| 119 | 135 | $title = __( 'Instant Results Template', 'elasticpress' ); |
| 120 | 136 | $fields = []; |
| 121 | 137 | |
| 122 | 138 | if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { |
| 123 | - $sites = Utils\get_sites(); | |
| 139 | + $sites = Utils\get_sites( 0, true ); | |
| 124 | 140 | |
| 125 | 141 | foreach ( $sites as $site ) { |
| 126 | - if ( ! Utils\is_site_indexable( $site['blog_id'] ) ) { | |
| 127 | - continue; | |
| 128 | - } | |
| 129 | - | |
| 130 | 142 | switch_to_blog( $site['blog_id'] ); |
| 131 | 143 | |
| 132 | 144 | $field = $this->get_instant_results_field(); |
| 133 | 145 | $fields = array_merge( $fields, $field ); |
| @@ -149,9 +161,9 @@ | ||
| 149 | 161 | * |
| 150 | 162 | * @since 4.5.0 |
| 151 | 163 | * @return array |
| 152 | 164 | */ |
| 153 | - protected function get_orders_search_group() : array { | |
| 165 | + protected function get_orders_search_group(): array { | |
| 154 | 166 | $woocommerce_feature = \ElasticPress\Features::factory()->get_registered_feature( 'woocommerce' ); |
| 155 | 167 | |
| 156 | 168 | if ( ! $woocommerce_feature->is_active() ) { |
| 157 | 169 | return []; |
| @@ -164,15 +176,11 @@ | ||
| 164 | 176 | $title = __( 'Orders Search Template', 'elasticpress' ); |
| 165 | 177 | $fields = []; |
| 166 | 178 | |
| 167 | 179 | if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { |
| 168 | - $sites = Utils\get_sites(); | |
| 180 | + $sites = Utils\get_sites( 0, true ); | |
| 169 | 181 | |
| 170 | 182 | foreach ( $sites as $site ) { |
| 171 | - if ( ! Utils\is_site_indexable( $site['blog_id'] ) ) { | |
| 172 | - continue; | |
| 173 | - } | |
| 174 | - | |
| 175 | 183 | switch_to_blog( $site['blog_id'] ); |
| 176 | 184 | |
| 177 | 185 | $field = $this->get_orders_search_field(); |
| 178 | 186 | $fields = array_merge( $fields, $field ); |
| @@ -193,9 +201,9 @@ | ||
| 193 | 201 | * Process the ElasticPress.io Instant Results template. |
| 194 | 202 | * |
| 195 | 203 | * @return array |
| 196 | 204 | */ |
| 197 | - protected function get_instant_results_field() : array { | |
| 205 | + protected function get_instant_results_field(): array { | |
| 198 | 206 | $index = Indexables::factory()->get( 'post' )->get_index_name(); |
| 199 | 207 | |
| 200 | 208 | if ( ! $index ) { |
| 201 | 209 | return []; |
| @@ -226,10 +234,10 @@ | ||
| 226 | 234 | * |
| 227 | 235 | * @return array |
| 228 | 236 | * @since 4.5.0 |
| 229 | 237 | */ |
| 230 | - public function get_messages() : array { | |
| 231 | - $messages = \ElasticPress\ElasticPressIo::factory()->get_endpoint_messages( true ); | |
| 238 | + public function get_messages(): array { | |
| 239 | + $messages = \ElasticPress\get_container()->get( '\ElasticPress\ElasticPressIo' )->get_endpoint_messages( true ); | |
| 232 | 240 | $messages = array_values( $messages ); |
| 233 | 241 | |
| 234 | 242 | return $messages; |
| 235 | 243 | } |
| @@ -239,9 +247,9 @@ | ||
| 239 | 247 | * |
| 240 | 248 | * @since 4.5.0 |
| 241 | 249 | * @return array |
| 242 | 250 | */ |
| 243 | - protected function get_orders_search_field() : array { | |
| 251 | + protected function get_orders_search_field(): array { | |
| 244 | 252 | $index = Indexables::factory()->get( 'post' )->get_index_name(); |
| 245 | 253 | |
| 246 | 254 | if ( ! $index ) { |
| 247 | 255 | return []; |
| @@ -247,9 +255,9 @@ | ||
| 247 | 255 | return []; |
| 248 | 256 | } |
| 249 | 257 | |
| 250 | 258 | $woocommerce_feature = \ElasticPress\Features::factory()->get_registered_feature( 'woocommerce' ); |
| 251 | - $template = $woocommerce_feature->orders->get_search_template(); | |
| 259 | + $template = $woocommerce_feature->orders_autosuggest->get_search_template(); | |
| 252 | 260 | |
| 253 | 261 | if ( is_wp_error( $template ) ) { |
| 254 | 262 | return [ |
| 255 | 263 | $index => [ |