Skip to content

Commit

Permalink
Merge pull request #6 from newfold-labs/PRESS0-1140
Browse files Browse the repository at this point in the history
update the show MIgration key on completed status
  • Loading branch information
diwanshuster authored Apr 29, 2024
2 parents e28730c + 1a2bd41 commit 27e994a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
10 changes: 7 additions & 3 deletions bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -24,12 +25,15 @@ function () {
if ( ! defined( 'NFD_MIGRATION_MODULE_VERSION' ) ) {
define( 'NFD_MIGRATION_MODULE_VERSION', '1.0.0' );
}

$brand = $container->plugin()->id;
if ( 'atomic' === getContext( 'platform' ) ) {
$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/bluehost' );
defined( 'INSTAWP_MIGRATE_ENDPOINT' ) || define( 'INSTAWP_MIGRATE_ENDPOINT', 'migrate/' . $brand );

new Migration( $container );
},
Expand Down
14 changes: 14 additions & 0 deletions includes/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

/**
Expand All @@ -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 status of migration
*/
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;
}
}
6 changes: 4 additions & 2 deletions includes/Services/UtilityService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 27e994a

Please sign in to comment.