PluginProbe
Friends / 4.3.0
Friends v4.3.0
4.3.2 4.3.1 4.3.0 4.2.2 4.2.1 4.2.0 4.1.0 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.0 2.9.1 All 88 releases
friends / site-health.js

site-health.js in Friends 4.3.0, at site-health.js

71 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 }