From 2933d6ecc70b6808f664cbbccc89d8349e27a1d4 Mon Sep 17 00:00:00 2001 From: Ramya krishna Date: Thu, 25 Apr 2024 13:27:31 +0530 Subject: [PATCH 1/5] update the show MIgration key on completed status --- includes/Migration.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/includes/Migration.php b/includes/Migration.php index dfe0caa..b37ae79 100644 --- a/includes/Migration.php +++ b/includes/Migration.php @@ -43,6 +43,7 @@ public function __construct( Container $container ) { add_action( 'rest_api_init', array( $this, 'register_routes' ) ); add_action( 'pre_update_option_nfd_migrate_site', array( $this, 'on_update_nfd_migrate_site' ) ); + add_action( 'pre_update_option_instawp_last_migration_details', array( $this, 'on_update_instawp_last_migration_details' ), 10, 1 ); } /** @@ -61,4 +62,17 @@ public function register_routes() { public function on_update_nfd_migrate_site() { $response = $this->insta_service->install_instawp_connect(); } + + /** + * Updates showMigrationSteps option based on instawp_last_migration_details + * + * @param array $new_option array values + */ + public function on_update_instawp_last_migration_details( $new_option ) { + $value_updated = $new_option['status']; + if ( 'completed' === $value_updated ) { + update_option( 'showMigrationSteps', true ); + } + return $new_option; + } } From 326a07521b989ce28c8fb6d987527edb833cde47 Mon Sep 17 00:00:00 2001 From: Ramya krishna Date: Fri, 26 Apr 2024 11:18:18 +0530 Subject: [PATCH 2/5] bh-cloud end point added and end point based on brand --- bootstrap.php | 8 ++++++-- includes/Migration.php | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bootstrap.php b/bootstrap.php index 50f51dc..0b8b47c 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -3,6 +3,7 @@ use NewfoldLabs\WP\Module\Migration\Migration; use NewfoldLabs\WP\Module\Migration\Services\UtilityService; use NewfoldLabs\WP\ModuleLoader\Container; +use function NewfoldLabs\WP\Context\getContext; use function NewfoldLabs\WP\ModuleLoader\register; @@ -24,12 +25,15 @@ function () { if ( ! defined( 'NFD_MIGRATION_MODULE_VERSION' ) ) { define( 'NFD_MIGRATION_MODULE_VERSION', '1.0.0' ); } - + $migrate_endpoint = 'migrate/'. $container->plugin()->id; + if ( 'atomic' === getContext( 'platform' ) ) { + $migrate_endpoint = 'migrate/bh-cloud'; + } defined( 'NFD_PROXY_ACCESS_WORKER' ) || define( 'NFD_PROXY_ACCESS_WORKER', 'https://hiive.cloud/workers/migration-token-proxy' ); $response = UtilityService::get_insta_api_key(); defined( 'INSTAWP_API_KEY' ) || define( 'INSTAWP_API_KEY', $response ); defined( 'INSTAWP_API_DOMAIN' ) || define( 'INSTAWP_API_DOMAIN', 'https://app.instawp.io' ); - defined( 'INSTAWP_MIGRATE_ENDPOINT' ) || define( 'INSTAWP_MIGRATE_ENDPOINT', 'migrate/bluehost' ); + defined( 'INSTAWP_MIGRATE_ENDPOINT' ) || define( 'INSTAWP_MIGRATE_ENDPOINT', $migrate_endpoint ); new Migration( $container ); }, diff --git a/includes/Migration.php b/includes/Migration.php index b37ae79..d9df076 100644 --- a/includes/Migration.php +++ b/includes/Migration.php @@ -66,7 +66,7 @@ public function on_update_nfd_migrate_site() { /** * Updates showMigrationSteps option based on instawp_last_migration_details * - * @param array $new_option array values + * @param array $new_option status of migration */ public function on_update_instawp_last_migration_details( $new_option ) { $value_updated = $new_option['status']; From cfcb6100ab2e630be5140b41f8f5d773f32872aa Mon Sep 17 00:00:00 2001 From: Ramya krishna Date: Fri, 26 Apr 2024 11:19:39 +0530 Subject: [PATCH 3/5] linting fixes --- bootstrap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap.php b/bootstrap.php index 0b8b47c..0136af2 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -25,7 +25,7 @@ function () { if ( ! defined( 'NFD_MIGRATION_MODULE_VERSION' ) ) { define( 'NFD_MIGRATION_MODULE_VERSION', '1.0.0' ); } - $migrate_endpoint = 'migrate/'. $container->plugin()->id; + $migrate_endpoint = 'migrate/' . $container->plugin()->id; if ( 'atomic' === getContext( 'platform' ) ) { $migrate_endpoint = 'migrate/bh-cloud'; } From 9b227d536d80473d3e347f0bd28632ef7d9ab5b6 Mon Sep 17 00:00:00 2001 From: Ramya krishna Date: Fri, 26 Apr 2024 15:51:43 +0530 Subject: [PATCH 4/5] Passing the brand instead of key --- bootstrap.php | 8 ++++---- includes/Services/UtilityService.php | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/bootstrap.php b/bootstrap.php index 0136af2..8dd4f72 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -25,15 +25,15 @@ function () { if ( ! defined( 'NFD_MIGRATION_MODULE_VERSION' ) ) { define( 'NFD_MIGRATION_MODULE_VERSION', '1.0.0' ); } - $migrate_endpoint = 'migrate/' . $container->plugin()->id; + $brand = $container->plugin()->id; if ( 'atomic' === getContext( 'platform' ) ) { - $migrate_endpoint = 'migrate/bh-cloud'; + $brand = 'bh-cloud'; } defined( 'NFD_PROXY_ACCESS_WORKER' ) || define( 'NFD_PROXY_ACCESS_WORKER', 'https://hiive.cloud/workers/migration-token-proxy' ); - $response = UtilityService::get_insta_api_key(); + $response = UtilityService::get_insta_api_key( $brand ); defined( 'INSTAWP_API_KEY' ) || define( 'INSTAWP_API_KEY', $response ); defined( 'INSTAWP_API_DOMAIN' ) || define( 'INSTAWP_API_DOMAIN', 'https://app.instawp.io' ); - defined( 'INSTAWP_MIGRATE_ENDPOINT' ) || define( 'INSTAWP_MIGRATE_ENDPOINT', $migrate_endpoint ); + defined( 'INSTAWP_MIGRATE_ENDPOINT' ) || define( 'INSTAWP_MIGRATE_ENDPOINT', 'migrate/' . $migrate_endpoint ); new Migration( $container ); }, diff --git a/includes/Services/UtilityService.php b/includes/Services/UtilityService.php index 8e7bfcc..17d907f 100644 --- a/includes/Services/UtilityService.php +++ b/includes/Services/UtilityService.php @@ -7,9 +7,11 @@ class UtilityService { /** * Get the api key from worker + * + * @param string $brand name of the brand */ - public static function get_insta_api_key() { - $insta_cf_worker = NFD_PROXY_ACCESS_WORKER . '/get/token?access_token=BH_MIGRATION_API_KEY'; + public static function get_insta_api_key( $brand ) { + $insta_cf_worker = NFD_PROXY_ACCESS_WORKER . '/get/token?brand=' . $brand; $insta_cf_data = wp_remote_get( $insta_cf_worker, array( From 1a2bd4181c27584d7a79bf18234eb7078f3642e4 Mon Sep 17 00:00:00 2001 From: Ramya krishna Date: Mon, 29 Apr 2024 15:25:09 +0530 Subject: [PATCH 5/5] brand variable replaced --- bootstrap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap.php b/bootstrap.php index 8dd4f72..fd2877c 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -33,7 +33,7 @@ function () { $response = UtilityService::get_insta_api_key( $brand ); defined( 'INSTAWP_API_KEY' ) || define( 'INSTAWP_API_KEY', $response ); defined( 'INSTAWP_API_DOMAIN' ) || define( 'INSTAWP_API_DOMAIN', 'https://app.instawp.io' ); - defined( 'INSTAWP_MIGRATE_ENDPOINT' ) || define( 'INSTAWP_MIGRATE_ENDPOINT', 'migrate/' . $migrate_endpoint ); + defined( 'INSTAWP_MIGRATE_ENDPOINT' ) || define( 'INSTAWP_MIGRATE_ENDPOINT', 'migrate/' . $brand ); new Migration( $container ); },