Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ramyakrishnai committed Aug 20, 2024
1 parent 7ab3595 commit 593c99b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 36 deletions.
5 changes: 5 additions & 0 deletions includes/Services/InstaMigrateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ class InstaMigrateService {
*/
private $insta_api_key = '';

/**
* Retry count
*
* @var $count
*/
private $count = 0;
/**
* Set required api keys for insta to initiate the migration
Expand Down
52 changes: 16 additions & 36 deletions includes/import-tools-changes.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,42 +28,7 @@ node.setAttribute("id", "migration-progress-modal")

document.getElementById("wpbody-content").appendChild(node)

// load a pop up when user clicks on run importer for wordpress migration tool
document.querySelector('a[href*="import=site_migration_wordpress_importer"]')?.addEventListener('click', function(e) {
e.preventDefault();
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!")
// }
})
.catch(err => console.error(err))

});


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

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

fetch(
Expand All @@ -87,4 +52,19 @@ if(canMigrateSite === "true"){
// // alert("please try again in sometime. Thanks!")
// }
})
}
// load a pop up when user clicks on run importer for wordpress migration tool
document.querySelector('a[href*="import=site_migration_wordpress_importer"]')?.addEventListener('click', function(e) {
e.preventDefault();
startMigration();

});


// trigger migration when user lands on tools page with migrate param
const params = new URLSearchParams(document.location.search);
const canMigrateSite = params.get("migrate");

if(canMigrateSite === "true"){
startMigration()
}

0 comments on commit 593c99b

Please sign in to comment.