Skip to content

Commit

Permalink
Merge pull request #18 from newfold-labs/update/event_hook
Browse files Browse the repository at this point in the history
Changing the delete_hook to update_option
  • Loading branch information
ramyakrishnai authored May 16, 2024
2 parents 06bef1f + 9aebcf5 commit 6c14249
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 38 deletions.
2 changes: 1 addition & 1 deletion bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function () {
'callback' => function ( Container $container ) {

if ( ! defined( 'NFD_MIGRATION_MODULE_VERSION' ) ) {
define( 'NFD_MIGRATION_MODULE_VERSION', '1.0.1' );
define( 'NFD_MIGRATION_MODULE_VERSION', '1.0.2' );
}
$brand = $container->plugin()->id;
if ( 'atomic' === getContext( 'platform' ) ) {
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 13 additions & 28 deletions includes/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ 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( 'deleted_plugin', array( $this, 'delete_plugin' ), 10, 1 );
add_action( 'pre_update_option_instawp_last_migration_details', array( $this, 'on_update_instawp_last_migration_details' ), 10, 1 );
}

Expand All @@ -66,33 +65,6 @@ public function on_update_nfd_migrate_site() {
$response = $this->insta_service->install_instawp_connect();
}

/**
* Updates showMigrationSteps option based on instawp_last_migration_details
*
* @param string $file path of plugin installed
*/
public function delete_plugin( $file ) {
$migrationDetails = (array) get_option( 'instawp_last_migration_details', array() );
$isMigrationCompleted = $migrationDetails['status'];
if ( 'instawp-connect/instawp-connect.php' === $file ) {
if ( 'completed' === $isMigrationCompleted ) {
$event = array(
'category' => 'wonder_start',
'action' => 'migration_completed',
'data' => array(),
);
EventService::send( $event );
} elseif ( 'failed' === $isMigrationCompleted ) {
$event = array(
'category' => 'wonder_start',
'action' => 'migration_failed',
'data' => array(),
);
EventService::send( $event );
}
}
}

/**
* Updates showMigrationSteps option based on instawp_last_migration_details
*
Expand All @@ -102,6 +74,19 @@ public function on_update_instawp_last_migration_details( $new_option ) {
$value_updated = $new_option['status'];
if ( 'completed' === $value_updated ) {
update_option( 'showMigrationSteps', true );
$event = array(
'category' => 'wonder_start',
'action' => 'migration_completed',
'data' => array(),
);
EventService::send( $event );
} elseif ( 'failed' === $value_updated ) {
$event = array(
'category' => 'wonder_start',
'action' => 'migration_failed',
'data' => array(),
);
EventService::send( $event );
}
return $new_option;
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@newfold-labs/wp-module-migration",
"version": "1.0.1",
"version": "1.0.2",
"description": "",
"main": "build/index.js",
"scripts": {
Expand Down

0 comments on commit 6c14249

Please sign in to comment.