| 1 |
/** |
| 2 |
* Site Health JavaScript functionality for Friends plugin |
| 3 |
*/ |
| 4 |
|
| 5 |
function friendsRestartMigration(button) { |
| 6 |
if (confirm(friendsSiteHealth.confirmRestart)) { |
| 7 |
button.disabled = true; |
| 8 |
button.textContent = 'Starting...'; |
| 9 |
friendsRunMigration(); |
| 10 |
} |
| 11 |
} |
| 12 |
|
| 13 |
function friendsCleanupPostTags(button) { |
| 14 |
if (confirm(friendsSiteHealth.confirmCleanup)) { |
| 15 |
button.disabled = true; |
| 16 |
button.textContent = 'Cleaning up...'; |
| 17 |
friendsRunCleanup(); |
| 18 |
} |
| 19 |
} |
| 20 |
|
| 21 |
function friendsRunMigration() { |
| 22 |
fetch(friendsSiteHealth.ajaxUrl, { |
| 23 |
method: 'POST', |
| 24 |
headers: { |
| 25 |
'Content-Type': 'application/x-www-form-urlencoded', |
| 26 |
}, |
| 27 |
body: new URLSearchParams({ |
| 28 |
action: 'friends_restart_migration', |
| 29 |
nonce: friendsSiteHealth.restartMigrationNonce |
| 30 |
}) |
| 31 |
}) |
| 32 |
.then(response => response.json()) |
| 33 |
.then(data => { |
| 34 |
if (data.success) { |
| 35 |
alert(data.data.message); |
| 36 |
location.reload(); |
| 37 |
} else { |
| 38 |
alert('Error: ' + (data.data || 'Unknown error')); |
| 39 |
} |
| 40 |
}) |
| 41 |
.catch(error => { |
| 42 |
console.error('Error:', error); |
| 43 |
alert('An error occurred while starting the migration.'); |
| 44 |
}); |
| 45 |
} |
| 46 |
|
| 47 |
function friendsRunCleanup() { |
| 48 |
fetch(friendsSiteHealth.ajaxUrl, { |
| 49 |
method: 'POST', |
| 50 |
headers: { |
| 51 |
'Content-Type': 'application/x-www-form-urlencoded', |
| 52 |
}, |
| 53 |
body: new URLSearchParams({ |
| 54 |
action: 'friends_cleanup_post_tags', |
| 55 |
nonce: friendsSiteHealth.cleanupPostTagsNonce |
| 56 |
}) |
| 57 |
}) |
| 58 |
.then(response => response.json()) |
| 59 |
.then(data => { |
| 60 |
if (data.success) { |
| 61 |
alert(data.data.message); |
| 62 |
location.reload(); |
| 63 |
} else { |
| 64 |
alert('Error: ' + (data.data || 'Unknown error')); |
| 65 |
} |
| 66 |
}) |
| 67 |
.catch(error => { |
| 68 |
console.error('Error:', error); |
| 69 |
alert('An error occurred while cleaning up tags.'); |
| 70 |
}); |
| 71 |
} |