From 3273df144faf73dfe340d8982987245e5507a214 Mon Sep 17 00:00:00 2001 From: Ramya krishna Date: Thu, 16 May 2024 15:24:50 +0530 Subject: [PATCH 1/4] update option hook --- includes/Migration.php | 41 +++++++++++++---------------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/includes/Migration.php b/includes/Migration.php index 7760b78..89b98ce 100644 --- a/includes/Migration.php +++ b/includes/Migration.php @@ -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 ); } @@ -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 * @@ -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; } From 1e2d7f3c4c92d7882d28107883654bbe5325b46d Mon Sep 17 00:00:00 2001 From: Ramya krishna Date: Thu, 16 May 2024 15:38:36 +0530 Subject: [PATCH 2/4] linting and PHP warning issues --- includes/Migration.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/Migration.php b/includes/Migration.php index 89b98ce..53c51f7 100644 --- a/includes/Migration.php +++ b/includes/Migration.php @@ -71,7 +71,7 @@ public function on_update_nfd_migrate_site() { * @param array $new_option status of migration */ public function on_update_instawp_last_migration_details( $new_option ) { - $value_updated = $new_option['status']; + $value_updated = array_key_exists( 'status', $new_option ) && $new_option['status']; if ( 'completed' === $value_updated ) { update_option( 'showMigrationSteps', true ); $event = array( @@ -80,7 +80,7 @@ public function on_update_instawp_last_migration_details( $new_option ) { 'data' => array(), ); EventService::send( $event ); - }elseif ( 'failed' === $value_updated ) { + } elseif ( 'failed' === $value_updated ) { $event = array( 'category' => 'wonder_start', 'action' => 'migration_failed', From dd2e0d99e921e7e1c05b18789ac0beccc15695a2 Mon Sep 17 00:00:00 2001 From: Ramya krishna Date: Thu, 16 May 2024 16:46:20 +0530 Subject: [PATCH 3/4] removed conidtion check --- includes/Migration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Migration.php b/includes/Migration.php index 53c51f7..0ea5ee7 100644 --- a/includes/Migration.php +++ b/includes/Migration.php @@ -71,7 +71,7 @@ public function on_update_nfd_migrate_site() { * @param array $new_option status of migration */ public function on_update_instawp_last_migration_details( $new_option ) { - $value_updated = array_key_exists( 'status', $new_option ) && $new_option['status']; + $value_updated = $new_option['status']; if ( 'completed' === $value_updated ) { update_option( 'showMigrationSteps', true ); $event = array( From 9aebcf5aa5375d74428c7fce95b6e61ca4cf3896 Mon Sep 17 00:00:00 2001 From: Ramya krishna Date: Thu, 16 May 2024 17:38:41 +0530 Subject: [PATCH 4/4] update version --- bootstrap.php | 2 +- composer.lock | 12 ++++++------ package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/bootstrap.php b/bootstrap.php index 1550f7c..347cb3a 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -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' ) ) { diff --git a/composer.lock b/composer.lock index 733cc89..18fd84f 100644 --- a/composer.lock +++ b/composer.lock @@ -258,16 +258,16 @@ }, { "name": "wp-forge/wp-options", - "version": "1.1", + "version": "1.1.1", "source": { "type": "git", "url": "https://github.com/wp-forge/wp-options.git", - "reference": "df8899255dee19365599caa8801c75803e94e413" + "reference": "511b1c5e626582dd4c3c1b5602e7a20352dabc1b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wp-forge/wp-options/zipball/df8899255dee19365599caa8801c75803e94e413", - "reference": "df8899255dee19365599caa8801c75803e94e413", + "url": "https://api.github.com/repos/wp-forge/wp-options/zipball/511b1c5e626582dd4c3c1b5602e7a20352dabc1b", + "reference": "511b1c5e626582dd4c3c1b5602e7a20352dabc1b", "shasum": "" }, "type": "library", @@ -289,9 +289,9 @@ "description": "A WordPress helper class for managing plugin options.", "support": { "issues": "https://github.com/wp-forge/wp-options/issues", - "source": "https://github.com/wp-forge/wp-options/tree/1.1" + "source": "https://github.com/wp-forge/wp-options/tree/1.1.1" }, - "time": "2022-03-04T16:23:42+00:00" + "time": "2024-05-10T14:57:37+00:00" } ], "packages-dev": [ diff --git a/package-lock.json b/package-lock.json index 29322d8..7617345 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@newfold-labs/wp-module-migration", - "version": "1.0.1", + "version": "1.0.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@newfold-labs/wp-module-migration", - "version": "1.0.1", + "version": "1.0.2", "license": "GPL-2.0-or-later", "dependencies": { "@heroicons/react": "^2.0.18", diff --git a/package.json b/package.json index 70f0664..8b6c65b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@newfold-labs/wp-module-migration", - "version": "1.0.1", + "version": "1.0.2", "description": "", "main": "build/index.js", "scripts": {