Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update/press0 1764 #58

Merged
merged 3 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions includes/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ class Migration {
'NewfoldLabs\\WP\\Module\\Migration\\RestApi\\MigrateController',
);

/**
* Option settings
*
* @var array
*/
protected $options = array(
'nfd_migrate_site' => 'boolean',
);

/**
* Migration constructor.
*
Expand Down Expand Up @@ -62,6 +71,7 @@ public function register_routes() {
$rest_api = new $controller();
$rest_api->register_routes();
}
self::register_settings();
}

/**
Expand All @@ -87,4 +97,21 @@ public function on_update_instawp_last_migration_details( $new_option ) {
}
return $new_option;
}

/**
* Register settings.
*/
public function register_settings() {
foreach ( $this->options as $option => $type ) {
\register_setting(
'general',
$option,
array(
'show_in_rest' => true,
'type' => $type,
'description' => __( 'NFD migration Options', 'wp-module-migration' ),
)
);
}
}
}
5 changes: 4 additions & 1 deletion includes/RestApi/MigrateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ public function connect_instawp() {
$insta_service = new InstaMigrateService();
$response = $insta_service->install_instawp_connect();

return $response;
if ( is_wp_error( $response ) ) {
return $response;
}
return wp_send_json_success( $response );
}

/**
Expand Down
10 changes: 4 additions & 6 deletions includes/Services/InstaMigrateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,10 @@ public function install_instawp_connect() {
return new \WP_Error( 'Bad request', esc_html__( 'Connect plugin is installed but no connect ID.' ), array( 'status' => 400 ) );
}

return wp_send_json_success(
array(
'message' => esc_html__( 'Connect plugin is installed and ready to start the migration.' ),
'response' => true,
'redirect_url' => esc_url( NFD_MIGRATION_PROXY_WORKER . '/' . INSTAWP_MIGRATE_ENDPOINT . '?d_id=' . Helper::get_connect_uuid() ),
)
return array(
'message' => esc_html__( 'Connect plugin is installed and ready to start the migration.' ),
'response' => true,
'redirect_url' => esc_url( NFD_MIGRATION_PROXY_WORKER . '/' . INSTAWP_MIGRATE_ENDPOINT . '?d_id=' . Helper::get_connect_uuid() ),
);
}

Expand Down
Loading