| @@ -7,8 +7,9 @@ | ||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | namespace ElasticPress; |
| 10 | 10 | |
| 11 | +use ElasticPress\Features; | |
| 11 | 12 | use ElasticPress\Utils; |
| 12 | 13 | |
| 13 | 14 | if ( ! defined( 'ABSPATH' ) ) { |
| 14 | 15 | exit; // Exit if accessed directly. |
| @@ -48,8 +49,9 @@ | ||
| 48 | 49 | '4.2.2' => [ 'upgrade_4_2_2', 'init' ], |
| 49 | 50 | '4.4.0' => [ 'upgrade_4_4_0', 'init' ], |
| 50 | 51 | '4.5.0' => [ 'upgrade_4_5_0', 'init' ], |
| 51 | 52 | '4.7.0' => [ 'upgrade_4_7_0', 'init' ], |
| 53 | + '5.0.0' => [ 'upgrade_5_0_0', 'init' ], | |
| 52 | 54 | ]; |
| 53 | 55 | |
| 54 | 56 | array_walk( $routines, [ $this, 'run_upgrade_routine' ] ); |
| 55 | 57 | |
| @@ -245,8 +247,48 @@ | ||
| 245 | 247 | delete_transient( 'ep_autosuggest_query_request_cache' ); |
| 246 | 248 | } |
| 247 | 249 | |
| 248 | 250 | /** |
| 251 | + * Upgrade routine of v5.0.0. | |
| 252 | + */ | |
| 253 | + public function upgrade_5_0_0() { | |
| 254 | + $features_in_settings = Features::factory()->get_feature_settings(); | |
| 255 | + if ( ! empty( $features_in_settings ) ) { | |
| 256 | + foreach ( $features_in_settings as $feature_slug => $feature_settings ) { | |
| 257 | + $feature = Features::factory()->get_registered_feature( $feature_slug ); | |
| 258 | + if ( ! $feature ) { | |
| 259 | + continue; | |
| 260 | + } | |
| 261 | + | |
| 262 | + $settings_schema = $feature->get_settings_schema(); | |
| 263 | + foreach ( $settings_schema as $setting_schema ) { | |
| 264 | + if ( ! isset( $feature_settings[ $setting_schema['key'] ] ) ) { | |
| 265 | + continue; | |
| 266 | + } | |
| 267 | + | |
| 268 | + $value = $feature_settings[ $setting_schema['key'] ]; | |
| 269 | + | |
| 270 | + if ( ! in_array( $setting_schema['type'], [ 'checkbox', 'radio' ], true ) || ! is_bool( $value ) ) { | |
| 271 | + continue; | |
| 272 | + } | |
| 273 | + | |
| 274 | + $features_in_settings[ $feature_slug ][ $setting_schema['key'] ] = $value ? '1' : '0'; | |
| 275 | + } | |
| 276 | + } | |
| 277 | + Utils\update_option( 'ep_feature_settings', $features_in_settings ); | |
| 278 | + } | |
| 279 | + | |
| 280 | + /** | |
| 281 | + * Remove the 'ep_last_index' option and store it as an entry of 'ep_sync_history' | |
| 282 | + */ | |
| 283 | + $last_sync = Utils\get_option( 'ep_last_index', [] ); | |
| 284 | + if ( ! empty( $last_sync ) ) { | |
| 285 | + Utils\delete_option( 'ep_last_index' ); | |
| 286 | + Utils\update_option( 'ep_sync_history', [ $last_sync ] ); | |
| 287 | + } | |
| 288 | + } | |
| 289 | + | |
| 290 | + /** | |
| 249 | 291 | * Adjust the upgrade sync notice to warn users about Instant Results. |
| 250 | 292 | * |
| 251 | 293 | * As 4.0.0 introduces this new feature and it requires a resync, admin users |
| 252 | 294 | * might want to enable the feature before the resync (and then resync only once.) |
| @@ -266,9 +308,9 @@ | ||
| 266 | 308 | } |
| 267 | 309 | |
| 268 | 310 | $feature_status = $instant_results->requirements_status(); |
| 269 | 311 | $appended_message = ''; |
| 270 | - if ( 1 >= $feature_status->code ) { | |
| 312 | + if ( 1 >= $feature_status->get_code() ) { | |
| 271 | 313 | if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { |
| 272 | 314 | $features_url = admin_url( 'network/admin.php?page=elasticpress' ); |
| 273 | 315 | } else { |
| 274 | 316 | $features_url = admin_url( 'admin.php?page=elasticpress' ); |
| @@ -275,11 +317,11 @@ | ||
| 275 | 317 | } |
| 276 | 318 | |
| 277 | 319 | $appended_message = wp_kses_post( |
| 278 | 320 | sprintf( |
| 279 | - /* translators: 1: <a> tag (Zendesk article); 2. </a>; 3: <a> tag (link to Features screen); 4. </a>; */ | |
| 321 | + /* translators: 1: <a> tag (Support article); 2. </a>; 3: <a> tag (link to Features screen); 4. </a>; */ | |
| 280 | 322 | __( '%1$sInstant Results%2$s is now available in ElasticPress, but requires a re-sync before activation. If you would like to use Instant Results, click %3$shere%4$s to activate the feature and start your sync.', 'elasticpress' ), |
| 281 | - '<a href="https://elasticpress.zendesk.com/hc/en-us/articles/360050447492#instant-results">', | |
| 323 | + '<a href="https://www.elasticpress.io/resources/articles/configuring-elasticpress-via-the-plugin-dashboard/#instant-results">', | |
| 282 | 324 | '</a>', |
| 283 | 325 | '<a href="' . $features_url . '">', |
| 284 | 326 | '</a>' |
| 285 | 327 | ) |
| @@ -286,13 +328,13 @@ | ||
| 286 | 328 | ); |
| 287 | 329 | } else { |
| 288 | 330 | $appended_message = wp_kses_post( |
| 289 | 331 | sprintf( |
| 290 | - /* translators: 1: <a> tag (Zendesk article about Instant Results); 2. </a>; 3: <a> tag (Zendesk article about self hosted Elasticsearch setups); 4. </a>; */ | |
| 332 | + /* translators: 1: <a> tag (Support article about Instant Results); 2. </a>; 3: <a> tag (Support article about self hosted Elasticsearch setups); 4. </a>; */ | |
| 291 | 333 | __( '%1$sInstant Results%2$s is now available in ElasticPress, but requires a re-sync before activation. If you would like to use Instant Results, since you are not using ElasticPress.io, you will also need to %3$sinstall and configure a PHP proxy%4$s.', 'elasticpress' ), |
| 292 | - '<a href="https://elasticpress.zendesk.com/hc/en-us/articles/360050447492#instant-results">', | |
| 334 | + '<a href="https://www.elasticpress.io/resources/articles/configuring-elasticpress-via-the-plugin-dashboard/#instant-results">', | |
| 293 | 335 | '</a>', |
| 294 | - '<a href="https://elasticpress.zendesk.com/hc/en-us/articles/4413938931853-Considerations-for-self-hosted-Elasticsearch-setups">', | |
| 336 | + '<a href="https://www.elasticpress.io/resources/articles/considerations-for-self-hosted-elasticsearch-setups/">', | |
| 295 | 337 | '</a>' |
| 296 | 338 | ) |
| 297 | 339 | ); |
| 298 | 340 | } |