Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ramyakrishnai committed Aug 19, 2024
1 parent fb96af2 commit 7ab3595
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
12 changes: 10 additions & 2 deletions includes/Services/InstaMigrateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class InstaMigrateService {
* @var $insta_api_key
*/
private $insta_api_key = '';

private $count = 0;
/**
* Set required api keys for insta to initiate the migration
*/
Expand Down Expand Up @@ -57,7 +59,7 @@ public function install_instawp_connect() {
}

// Connect the website with InstaWP server
if ( empty( Helper::get_api_key() ) ) {
if ( empty( Helper::get_api_key() ) || empty( Helper::get_connect_id() ) ) {
$api_key = Helper::get_api_key( false, $this->insta_api_key );
$connect_response = Helper::instawp_generate_api_key( $api_key );

Expand All @@ -73,7 +75,13 @@ public function install_instawp_connect() {
if ( function_exists( 'instawp' ) ) {
// Check if there is a connect ID
if ( empty( Helper::get_connect_id() ) ) {
return new \WP_Error( 'Bad request', esc_html__( 'Connect plugin is installed but no connect ID.' ), array( 'status' => 400 ) );
if( $count < 2 ) {
$count++;
delete_option( 'instawp_api_options' );
self::install_instawp_connect();
} else {
return new \WP_Error( 'Bad request', esc_html__( 'Connect plugin is installed but no connect ID.' ), array( 'status' => 400 ) );
}
}

return array(
Expand Down
35 changes: 33 additions & 2 deletions includes/import-tools-changes.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,41 @@ document.getElementById("wpbody-content").appendChild(node)
window.open(res?.data?.redirect_url, "_self")
}
// else{
// alert("please try again in sometime. Thanks!")
// document.getElementsByClassName("wrap")[0];
// // alert("please try again in sometime. Thanks!")
// }
})
.catch(err => console.error(err))

});



let params = new URLSearchParams(document.location.search);
let canMigrateSite = params.get("migrate");

if(canMigrateSite === "true"){
console.log("helloo")
document.getElementById("migration-progress-modal").style.display = "flex";

fetch(
nfdplugin.restApiUrl + "/newfold-migration/v1/migrate/connect&_locale=user",
{
credentials: 'same-origin',
headers: {
'Content-Type': 'application/json',
'X-WP-Nonce': nfdplugin.restApiNonce,
},
}
)
.then((response) => response.json())
.then(res => {
document.getElementById("migration-progress-modal").style.display = "none";
if(res?.success){
window.open(res?.data?.redirect_url, "_self")
}
// else{
// document.getElementsByClassName("wrap")[0];
// // alert("please try again in sometime. Thanks!")
// }
})
}

0 comments on commit 7ab3595

Please sign in to comment.