migrate_global_enabled_option(); $this->migrate_option( 'wpai_feature_review-notes_enabled', 'wpai_feature_editorial-notes_enabled' ); $this->migrate_option( 'wpai_feature_refine-notes_enabled', 'wpai_feature_editorial-updates_enabled' ); } /** * Repairs legacy and incorrect global enabled option names. * * @since 1.0.0 */ private function migrate_global_enabled_option(): void { foreach ( array( 'ai_experiments_enabled', 'ai_experiment_enabled', 'wpai_feature_enabled' ) as $old_option ) { $this->migrate_option( $old_option, 'wpai_features_enabled' ); } } /** * Migrates an individual option from the old name. * * Will skip migration if the new option already has a value. * * @param string $old_option The old option name. * @param string $new_option The new option name. */ private function migrate_option( string $old_option, string $new_option ): void { $old_value = get_option( $old_option, '' ); if ( '' === $old_value || '' !== get_option( $new_option, '' ) ) { return; } update_option( $new_option, $old_value ); delete_option( $old_option ); } }