PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.3
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.3
6.3 6.2.3 6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 All 157 releases
← All changes | modules/api-backups/assets/js/module-api-backups-manager.js +963 -941 5.0 → 6.2.3 View file →
@@ -9,9 +9,9 @@
9 9 */
10 10
11 11 /* eslint complexity: ["error", 100] */
12 12
13 -jQuery(document).ready(function () {
13 +jQuery(function(){
14 14
15 15 /********************************************************
16 16 * Ajax Event Hooks.
17 17 */
@@ -20,35 +20,35 @@
20 20 * CloudWays Ajax Hooks
21 21 */
22 22
23 23 // Trigger action_backup.
24 - jQuery('.mainwp_3rd_party_api_cloudways_action_backup').on('click', function (event) {
25 - cloudways_action_backup(this, event);
24 + jQuery('.mainwp_3rd_party_api_cloudways_action_backup').on('click', function () {
25 + cloudways_action_backup(this);
26 26 });
27 27
28 28 // Trigger action_backup.
29 - jQuery('#mainwp_3rd_party_api_cloudways_action_individual_create_backup').on('click', function (event) {
30 - cloudways_action_backup(this, event);
29 + jQuery('#mainwp_3rd_party_api_cloudways_action_individual_create_backup').on('click', function () {
30 + cloudways_action_backup(this);
31 31 });
32 32
33 33 // Trigger action_update_ids.
34 - jQuery('.mainwp_3rd_party_api_cloudways_action_update_ids').on('click', function (event) {
35 - cloudways_action_update_ids(this, event);
34 + jQuery('.mainwp_3rd_party_api_cloudways_action_update_ids').on('click', function () {
35 + cloudways_action_update_ids(this);
36 36 });
37 37
38 38 //Trigger action_refresh_available_backups.
39 - jQuery('#mainwp_3rd_party_api_cloudways_action_refresh_available_backups').on('click', function (event) {
40 - cloudways_action_refresh_available_backups(this, event);
39 + jQuery('#mainwp_3rd_party_api_cloudways_action_refresh_available_backups').on('click', function () {
40 + cloudways_action_refresh_available_backups(this);
41 41 });
42 42
43 43 // Trigger action_restore_backup.
44 - jQuery(document).on('click', '.mainwp_3rd_party_api_cloudways_action_restore_backup', function (event) {
45 - cloudways_action_restore_backup(this, event);
44 + jQuery(document).on('click', '.mainwp_3rd_party_api_cloudways_action_restore_backup', function () {
45 + cloudways_action_restore_backup(this);
46 46 });
47 47
48 48 // Trigger action_delete_backup. This will delete the 24hr restore point allowing for a new restoration to be created.
49 - jQuery('#mainwp_3rd_party_api_cloudways_action_delete_backup').on('click', function (event) {
50 - cloudways_action_delete_backup(this, event);
49 + jQuery('#mainwp_3rd_party_api_cloudways_action_delete_backup').on('click', function () {
50 + cloudways_action_delete_backup(this);
51 51 });
52 52
53 53 /**
54 54 * Vultr Ajax Hooks
@@ -54,35 +54,35 @@
54 54 * Vultr Ajax Hooks
55 55 */
56 56
57 57 // Trigger action_backup.
58 - jQuery('.mainwp_3rd_party_api_vultr_action_backup').on('click', function (event) {
59 - vultr_action_create_snapshot(this, event);
58 + jQuery('.mainwp_3rd_party_api_vultr_action_backup').on('click', function () {
59 + vultr_action_create_snapshot(this);
60 60 });
61 61
62 62 // Trigger action_backup.
63 - jQuery('#mainwp_3rd_party_api_vultr_action_individual_create_backup').on('click', function (event) {
64 - vultr_action_create_snapshot(this, event);
63 + jQuery('#mainwp_3rd_party_api_vultr_action_individual_create_backup').on('click', function () {
64 + vultr_action_create_snapshot(this);
65 65 });
66 66
67 67 // Trigger action_update_ids.
68 - jQuery('.mainwp_3rd_party_api_vultr_action_update_ids').on('click', function (event) {
69 - vultr_action_update_ids(this, event);
68 + jQuery('.mainwp_3rd_party_api_vultr_action_update_ids').on('click', function () {
69 + vultr_action_update_ids(this);
70 70 });
71 71
72 72 //Trigger action_refresh_available_backups.
73 - jQuery('#mainwp_3rd_party_api_vultr_action_refresh_available_backups').on('click', function (event) {
74 - vultr_action_refresh_available_backups(this, event);
73 + jQuery('#mainwp_3rd_party_api_vultr_action_refresh_available_backups').on('click', function () {
74 + vultr_action_refresh_available_backups(this);
75 75 });
76 76
77 77 // Trigger action_restore_backup.
78 - jQuery(document).on('click', '.mainwp_3rd_party_api_vultr_action_restore_backup', function (event) {
79 - vultr_action_restore_backup(this, event);
78 + jQuery(document).on('click', '.mainwp_3rd_party_api_vultr_action_restore_backup', function () {
79 + vultr_action_restore_backup(this);
80 80 });
81 81
82 82 // Trigger action_delete_backup.
83 - jQuery(document).on('click', '.mainwp_3rd_party_api_vultr_action_delete_backup', function (event) {
84 - vultr_action_delete_backup(this, event);
83 + jQuery(document).on('click', '.mainwp_3rd_party_api_vultr_action_delete_backup', function () {
84 + vultr_action_delete_backup(this);
85 85 });
86 86
87 87 /**
88 88 * GridPane Ajax Hooks
@@ -88,35 +88,35 @@
88 88 * GridPane Ajax Hooks
89 89 */
90 90
91 91 // Trigger action_backup.
92 - jQuery('.mainwp_3rd_party_api_gridpane_action_backup').on('click', function (event) {
93 - gridpane_action_create_backup(this, event);
92 + jQuery('.mainwp_3rd_party_api_gridpane_action_backup').on('click', function () {
93 + gridpane_action_create_backup(this);
94 94 });
95 95
96 96 // Trigger action_backup.
97 - jQuery('#mainwp_3rd_party_api_gridpane_action_individual_create_backup').on('click', function (event) {
98 - gridpane_action_create_backup(this, event);
97 + jQuery('#mainwp_3rd_party_api_gridpane_action_individual_create_backup').on('click', function () {
98 + gridpane_action_create_backup(this);
99 99 });
100 100
101 101 // Trigger action_update_ids.
102 - jQuery('.mainwp_3rd_party_api_gridpane_action_update_ids').on('click', function (event) {
103 - gridpane_action_update_ids(this, event);
102 + jQuery('.mainwp_3rd_party_api_gridpane_action_update_ids').on('click', function () {
103 + gridpane_action_update_ids(this);
104 104 });
105 105
106 106 // Trigger action_refresh_available_backups.
107 - jQuery('#mainwp_3rd_party_api_gridpane_action_refresh_available_backups').on('click', function (event) {
108 - gridpane_action_refresh_available_backups(this, event);
107 + jQuery('#mainwp_3rd_party_api_gridpane_action_refresh_available_backups').on('click', function () {
108 + gridpane_action_refresh_available_backups(this);
109 109 });
110 110
111 111 // Trigger action_restore_backup.
112 - jQuery(document).on('click', '.mainwp_3rd_party_api_gridpane_action_restore_backup', function (event) {
113 - gridpane_action_restore_backup(this, event);
112 + jQuery(document).on('click', '.mainwp_3rd_party_api_gridpane_action_restore_backup', function () {
113 + gridpane_action_restore_backup(this);
114 114 });
115 115
116 116 // Trigger action_delete_backup.
117 - jQuery(document).on('click', '.mainwp_3rd_party_api_gridpane_action_delete_backup', function (event) {
118 - gridpane_action_delete_backup(this, event);
117 + jQuery(document).on('click', '.mainwp_3rd_party_api_gridpane_action_delete_backup', function () {
118 + gridpane_action_delete_backup(this);
119 119 });
120 120
121 121 /**
122 122 * Linode Ajax Hooks
@@ -122,37 +122,37 @@
122 122 * Linode Ajax Hooks
123 123 */
124 124
125 125 // Trigger action_backup.
126 - jQuery('.mainwp_3rd_party_api_linode_action_backup').on('click', function (event) {
127 - linode_action_create_backup(this, event);
126 + jQuery('.mainwp_3rd_party_api_linode_action_backup').on('click', function () {
127 + linode_action_create_backup(this);
128 128 });
129 129
130 130 // Trigger action_backup.
131 - jQuery('#mainwp_3rd_party_api_linode_action_individual_create_backup').on('click', function (event) {
132 - linode_action_create_backup(this, event);
131 + jQuery('#mainwp_3rd_party_api_linode_action_individual_create_backup').on('click', function () {
132 + linode_action_create_backup(this);
133 133 });
134 134
135 135 //Trigger action_update_ids.
136 - jQuery('.mainwp_3rd_party_api_linode_action_update_ids').on('click', function (event) {
137 - linode_action_update_ids(this, event);
136 + jQuery('.mainwp_3rd_party_api_linode_action_update_ids').on('click', function () {
137 + linode_action_update_ids(this);
138 138 });
139 139
140 140 // Trigger action_refresh_available_backups.
141 - jQuery('#mainwp_3rd_party_api_linode_action_refresh_available_backups').on('click', function (event) {
142 - linode_action_refresh_available_backups(this, event);
141 + jQuery('#mainwp_3rd_party_api_linode_action_refresh_available_backups').on('click', function () {
142 + linode_action_refresh_available_backups(this);
143 143 });
144 144
145 145 // Trigger action_restore_backup.
146 - jQuery(document).on('click', '.mainwp_3rd_party_api_linode_action_restore_backup', function (event) {
147 - linode_action_restore_backup(this, event);
146 + jQuery(document).on('click', '.mainwp_3rd_party_api_linode_action_restore_backup', function () {
147 + linode_action_restore_backup(this);
148 148 });
149 149
150 150 // Trigger action_delete_backup.
151 - jQuery('#mainwp_3rd_party_api_linode_action_cancel_backups').on('click', function (event) {
152 - var confirmMsg = __('Are you sure you want to Disable and Delete all existing backups from this Linode?');
151 + jQuery('#mainwp_3rd_party_api_linode_action_cancel_backups').on('click', function () {
152 + let confirmMsg = MainWP.I18n.t('Are you sure you want to Disable and Delete all existing backups from this Linode?');
153 153 mainwp_confirm(confirmMsg, function () {
154 - linode_action_cancel_backups(this, event);
154 + linode_action_cancel_backups(this);
155 155 });
156 156 });
157 157
158 158 /**
@@ -159,35 +159,35 @@
159 159 * digitalocean Ajax Hooks
160 160 */
161 161
162 162 //Trigger action_update_ids.
163 - jQuery('.mainwp_3rd_party_api_digitalocean_action_update_ids').on('click', function (event) {
164 - digitalocean_action_update_ids(this, event);
163 + jQuery('.mainwp_3rd_party_api_digitalocean_action_update_ids').on('click', function () {
164 + digitalocean_action_update_ids(this);
165 165 });
166 166
167 167 // Trigger action_create_backup.
168 - jQuery('.mainwp_3rd_party_api_digitalocean_action_backup').on('click', function (event) {
169 - digitalocean_action_create_backup(this, event);
168 + jQuery('.mainwp_3rd_party_api_digitalocean_action_backup').on('click', function () {
169 + digitalocean_action_create_backup(this);
170 170 });
171 171
172 172 // Trigger action_individual_create_backup.
173 - jQuery('#mainwp_3rd_party_api_digitalocean_action_individual_create_backup').on('click', function (event) {
174 - digitalocean_action_create_backup(this, event);
173 + jQuery('#mainwp_3rd_party_api_digitalocean_action_individual_create_backup').on('click', function () {
174 + digitalocean_action_create_backup(this);
175 175 });
176 176
177 177 // Trigger action_refresh_available_backups.
178 - jQuery('#mainwp_3rd_party_api_digitalocean_action_refresh_available_backups').on('click', function (event) {
179 - digitalocean_action_refresh_available_backups(this, event);
178 + jQuery('#mainwp_3rd_party_api_digitalocean_action_refresh_available_backups').on('click', function () {
179 + digitalocean_action_refresh_available_backups(this);
180 180 });
181 181
182 182 // Trigger action_delete_backup.
183 - jQuery(document).on('click', '.mainwp_3rd_party_api_digitalocean_action_delete_backup', function (event) {
184 - digitalocean_action_delete_backup(this, event);
183 + jQuery(document).on('click', '.mainwp_3rd_party_api_digitalocean_action_delete_backup', function () {
184 + digitalocean_action_delete_backup(this);
185 185 });
186 186
187 187 // Trigger action_restore_backup.
188 - jQuery(document).on('click', '.mainwp_3rd_party_api_digitalocean_action_restore_backup', function (event) {
189 - digitalocean_action_restore_backup(this, event);
188 + jQuery(document).on('click', '.mainwp_3rd_party_api_digitalocean_action_restore_backup', function () {
189 + digitalocean_action_restore_backup(this);
190 190 });
191 191
192 192 /**
193 193 * CPanel Ajax Hooks
@@ -193,81 +193,80 @@
193 193 * CPanel Ajax Hooks
194 194 */
195 195
196 196 // Trigger action_refresh_available_backups.
197 - jQuery('#mainwp_3rd_party_api_cpanel_action_refresh_available_backups').on('click', function (event) {
198 - cpanel_action_refresh_available_backups(this, event);
197 + jQuery('#mainwp_3rd_party_api_cpanel_action_refresh_available_backups').on('click', function () {
198 + cpanel_action_refresh_available_backups(this);
199 199 });
200 200
201 201 // Trigger action_restore_backup.
202 - jQuery(document).on('click', '.mainwp_3rd_party_api_cpanel_action_restore_backup', function (event) {
203 - var confirmMsg = __('Are you sure you want to Restore this backup?');
202 + jQuery(document).on('click', '.mainwp_3rd_party_api_cpanel_action_restore_backup', function () {
203 + let confirmMsg = MainWP.I18n.t('Are you sure you want to Restore this backup?');
204 204 mainwp_confirm(confirmMsg, function () {
205 - cPanel_action_restore_backup(this, event);
205 + cPanel_action_restore_backup(this);
206 206 });
207 207 });
208 208
209 209 // Trigger action_restore_database_backup.
210 - jQuery(document).on('click', '.mainwp_3rd_party_api_cpanel_action_restore_database_backup', function (event) {
211 - var confirmMsg = __('Are you sure you want to Restore this backup?');
212 - var btObj = this;
213 - mainwp_confirm(confirmMsg, function () {
214 - cpanel_action_restore_database_backup(btObj, event);
210 + jQuery(document).on('click', '.mainwp_3rd_party_api_cpanel_action_restore_database_backup', function () {
211 + let confirmMsg = MainWP.I18n.t('Are you sure you want to Restore this backup?');
212 + mainwp_confirm(confirmMsg, () => {
213 + cpanel_action_restore_database_backup(this);
215 214 });
216 215 });
217 216
218 217 // Trigger action_restore_manual_backup.
219 - jQuery(document).on('click', '.mainwp_3rd_party_api_cpanel_action_restore_manual_backup', function (event) {
220 - var confirmMsg = __('Are you sure you want to Restore this backup?');
218 + jQuery(document).on('click', '.mainwp_3rd_party_api_cpanel_action_restore_manual_backup', function () {
219 + let confirmMsg = MainWP.I18n.t('Are you sure you want to Restore this backup?');
221 220 mainwp_confirm(confirmMsg, function () {
222 - cpanel_action_restore_manual_backup(this, event);
221 + cpanel_action_restore_manual_backup();
223 222 });
224 223 });
225 224
226 225 // Trigger action_backup.
227 - jQuery('#mainwp_3rd_party_api_cpanel_action_individual_create_backup').on('click', function (event) {
228 - cpanel_action_create_backup(this, event);
226 + jQuery('#mainwp_3rd_party_api_cpanel_action_individual_create_backup').on('click', function () {
227 + cpanel_action_create_backup(this);
229 228 });
230 229
231 230 // Trigger action_create_wptk_backup.
232 - jQuery('#mainwp_3rd_party_api_cpanel_action_create_wptk_backup').on('click', function (event) {
233 - cpanel_action_create_wptk_backup(this, event);
231 + jQuery('#mainwp_3rd_party_api_cpanel_action_create_wptk_backup').on('click', function () {
232 + cpanel_action_create_wptk_backup(this);
234 233 });
235 234
236 235 // Trigger action_backup for bulk backups.
237 - jQuery('.mainwp_3rd_party_api_cpanel_action_full_backup').on('click', function (event) {
238 - cpanel_action_create_full_backup(this, event);
236 + jQuery('.mainwp_3rd_party_api_cpanel_action_full_backup').on('click', function () {
237 + cpanel_action_create_full_backup(this);
239 238 });
240 239
241 240 // Trigger action_database_backup.
242 - jQuery('#mainwp_3rd_party_api_cpanel_action_create_database_backup').on('click', function (event) {
243 - cpanel_action_create_database_backup(this, event);
241 + jQuery('#mainwp_3rd_party_api_cpanel_action_create_database_backup').on('click', function () {
242 + cpanel_action_create_database_backup(this);
244 243 });
245 244
246 245 // Trigger action_backup for full backups. Database & Files.
247 - jQuery('#mainwp_3rd_party_api_cpanel_action_create_full_backup').on('click', function (event) {
248 - cpanel_action_create_full_backup(this, event);
246 + jQuery('#mainwp_3rd_party_api_cpanel_action_create_full_backup').on('click', function () {
247 + cpanel_action_create_full_backup(this);
249 248 });
250 249
251 250 // Trigger action_restore_wptk_backup.
252 - jQuery('.mainwp_3rd_party_api_cpanel_action_restore_wptk_backup').on('click', function (event) {
253 - var confirmMsg = __('Are you sure you want to Restore this backup?');
251 + jQuery('.mainwp_3rd_party_api_cpanel_action_restore_wptk_backup').on('click', function () {
252 + let confirmMsg = MainWP.I18n.t('Are you sure you want to Restore this backup?');
254 253 mainwp_confirm(confirmMsg, function () {
255 - cpanel_action_restore_wptk_backup(this, event);
254 + cpanel_action_restore_wptk_backup(this);
256 255 });
257 256 });
258 257
259 258 // Trigger action_delete_wptk_backup.
260 - jQuery('.mainwp_3rd_party_api_cpanel_action_delete_wptk_backup').on('click', function (event) {
261 - var confirmMsg = __('Are you sure you want to Delete this backup?');
259 + jQuery('.mainwp_3rd_party_api_cpanel_action_delete_wptk_backup').on('click', function () {
260 + let confirmMsg = MainWP.I18n.t('Are you sure you want to Delete this backup?');
262 261 mainwp_confirm(confirmMsg, function () {
263 - cpanel_action_delete_wptk_backup(this, event);
262 + cpanel_action_delete_wptk_backup(this);
264 263 });
265 264 });
266 265
267 266 // Trigger action_download_wptk_backup
268 - jQuery('.mainwp_3rd_party_api_cpanel_action_download_wptk_backup').on('click', function (event) {
269 - cpanel_action_download_wptk_backup(this, event);
267 + jQuery('.mainwp_3rd_party_api_cpanel_action_download_wptk_backup').on('click', function () {
268 + cpanel_action_download_wptk_backup();
270 269 });
271 270
272 271 /**
273 272 * Plesk Ajax Hooks
@@ -273,41 +272,81 @@
273 272 * Plesk Ajax Hooks
274 273 */
275 274
276 275 // Trigger action_refresh_available_backups.
277 - jQuery('#mainwp_3rd_party_api_plesk_action_refresh_available_backups').on('click', function (event) {
278 - plesk_action_refresh_available_backups(this, event);
276 + jQuery('#mainwp_3rd_party_api_plesk_action_refresh_available_backups').on('click', function () {
277 + plesk_action_refresh_available_backups(this);
279 278 });
280 279
281 280 //Trigger action_backup.
282 - jQuery('#mainwp_3rd_party_api_plesk_action_individual_create_backup').on('click', function (event) {
283 - plesk_action_create_backup(this, event);
281 + jQuery('#mainwp_3rd_party_api_plesk_action_individual_create_backup').on('click', function () {
282 + plesk_action_create_backup(this);
284 283 });
285 284
286 285 // Trigger action_backup. ( bulk )
287 - jQuery('.mainwp_3rd_party_api_plesk_action_backup ').on('click', function (event) {
288 - plesk_action_create_backup(this, event);
286 + jQuery('.mainwp_3rd_party_api_plesk_action_backup ').on('click', function () {
287 + plesk_action_create_backup(this);
289 288 });
290 289
291 290 // Trigger action_restore_backup.
292 - jQuery(document).on('click', '.mainwp_3rd_party_api_plesk_action_restore_backup', function (event) {
293 - var confirmMsg = __('Are you sure you want to Restore this backup?');
291 + jQuery(document).on('click', '.mainwp_3rd_party_api_plesk_action_restore_backup', function () {
292 + let confirmMsg = MainWP.I18n.t('Are you sure you want to Restore this backup?');
294 293 mainwp_confirm(confirmMsg, function () {
295 - plesk_action_restore_backup(this, event);
294 + plesk_action_restore_backup();
296 295 });
297 296 });
298 297
299 298 // Trigger action_delete_backup.
300 - jQuery(document).on('click', '.mainwp_3rd_party_api_plesk_action_delete_backup', function (event) {
301 - var confirmMsg = __('Are you sure you want to Delete this backup?');
299 + jQuery(document).on('click', '.mainwp_3rd_party_api_plesk_action_delete_backup', function () {
300 + let confirmMsg = MainWP.I18n.t('Are you sure you want to Delete this backup?');
302 301 mainwp_confirm(confirmMsg, function () {
303 - plesk_action_delete_backup(this, event);
302 + plesk_action_delete_backup();
304 303 });
305 304 });
306 305
306 + /**
307 + * Kinsta Ajax Hooks
308 + */
309 + // Trigger action_refresh_available_backups.
310 + jQuery('#mainwp_3rd_party_api_kinsta_action_refresh_available_backups').on('click', function () {
311 + kinsta_action_refresh_available_backups(this);
312 + });
313 +
314 + //Trigger action_backup.
315 + jQuery('#mainwp_3rd_party_api_kinsta_action_individual_create_backup').on('click', function () {
316 + kinsta_action_create_backup(this);
317 + });
318 +
319 + // Trigger Bulk action_create_backup.
320 + jQuery('.mainwp_3rd_party_api_kinsta_action_backup').on('click', function () {
321 + kinsta_action_create_backup(this);
322 + });
323 +
324 + // Trigger action_delete_backup.
325 + jQuery('.mainwp_3rd_party_api_kinsta_action_delete_backup').on('click', function () {
326 + let confirmMsg = MainWP.I18n.t('Are you sure you want to Delete this backup?');
327 + let backupId = jQuery(this).attr('backup_id');
328 + mainwp_confirm(confirmMsg, function () {
329 + kinsta_action_delete_backup(this, backupId);
330 + });
331 + });
332 +
333 + // Trigger action_restore_backup.
334 + jQuery('.mainwp_3rd_party_api_kinsta_action_restore_backup').on('click', function () {
335 + let confirmMsg = MainWP.I18n.t('Are you sure you want to Restore this backup?');
336 + let backupId = jQuery(this).attr('backup_id');
337 + mainwp_confirm(confirmMsg, function () {
338 + kinsta_action_restore_backup(this, backupId);
339 + });
340 + });
341 +
342 + /**
343 + * Global Bulk Action: backup selected sites.
344 + */
345 +
307 346 // Trigger action_backup_selected_sites.
308 - jQuery('#action_backup_selected_sites').on('click', function (event) {
309 - action_backup_selected_sites(this, event);
347 + jQuery('#action_backup_selected_sites').on('click', function () {
348 + action_backup_selected_sites(this);
310 349 });
311 350
312 351 /********************************************************
313 352 * Fomantic-ui Tabs Event Hooks.
@@ -329,10 +368,10 @@
329 368 */
330 369 jQuery('#mainwp_api_cpanel_backup_tabs .item').tab();
331 370
332 371 // Trigger action_check_tab. Handle the click event on the TAB Buttons.
333 - jQuery('#mainwp_api_cpanel_backup_tabs .item').on('click', function (event) {
334 - action_check_tab(this, event);
372 + jQuery('#mainwp_api_cpanel_backup_tabs .item').on('click', function () {
373 + action_check_tab();
335 374 });
336 375
337 376 /**
338 377 * Handle switching TAB Buttons.
@@ -337,9 +376,9 @@
337 376 /**
338 377 * Handle switching TAB Buttons.
339 378 * Check if cPanel or Plesk is selected TAB when page loads & display the correct content.
340 379 */
341 - var ref_this = jQuery('#mainwp_api_cpanel_backup_tabs div.active');
380 + let ref_this = jQuery('#mainwp_api_cpanel_backup_tabs div.active');
342 381 if (ref_this.data('tab') === 'cpanel-native') {
343 382 jQuery('#mainwp_3rd_party_api_cpanel_action_create_full_backup').show();
344 383 jQuery('#mainwp_3rd_party_api_cpanel_action_create_wptk_backup').hide();
345 384 } else if (ref_this.data('tab') === 'cpanel-wp-toolkit') {
@@ -356,9 +395,9 @@
356 395 *
357 396 * This function is called when the "Backup Selected Sites" button is clicked.
358 397 * mainwp_api_backups_do_backups() is defined in assets/js/mainwp-api-backups.js.
359 398 */
360 -action_backup_selected_sites = function (pObj) {
399 +let action_backup_selected_sites = function (pObj) {
361 400 mainwp_api_backups_do_backups(pObj);
362 401 }
363 402
364 403 /**
@@ -364,11 +403,11 @@
364 403 /**
365 404 * Handle switching TAB Action Buttons on Individual Cpanel Backups page.
366 405 * Check if cPanel or Plesk is selected TAB when TAB is clicked & display the correct content.
367 406 */
368 -action_check_tab = function () {
407 +let action_check_tab = function () {
369 408
370 - var ref_this = jQuery('#mainwp_api_cpanel_backup_tabs div.active');
409 + let ref_this = jQuery('#mainwp_api_cpanel_backup_tabs div.active');
371 410 if (ref_this.data('tab') === 'cpanel-native') {
372 411 jQuery('#mainwp_3rd_party_api_cpanel_action_create_full_backup').show();
373 412 jQuery('#mainwp_3rd_party_api_cpanel_action_create_wptk_backup').hide();
374 413 } else if (ref_this.data('tab') === 'cpanel-wp-toolkit') {
@@ -376,27 +415,31 @@
376 415 jQuery('#mainwp_3rd_party_api_cpanel_action_create_wptk_backup').show();
377 416 }
378 417 }
379 418
419 +let module_api_backups_prepare_working_status = function(button){
420 + jQuery(button).html('<i class="notched circle loading icon"></i>');
421 +}
422 +
380 423 /********************************************************
381 424 * Cloudways Functions.
382 425 */
383 426
384 427 // Create Backup.
385 -cloudways_action_backup = function (pObj) {
428 +let cloudways_action_backup = function (pObj) {
386 429
387 430 jQuery(pObj).attr('disabled', 'true');
388 - var button = jQuery(pObj).closest('td');
389 - var lastBackup = jQuery(pObj).closest('td').prev();
390 - var websiteId = jQuery(pObj).attr('website_id');
431 + let button = jQuery(pObj).closest('td');
432 + let lastBackup = jQuery(pObj).closest('td').prev();
433 + let websiteId = jQuery(pObj).attr('website_id');
391 434
392 - var data = mainwp_secure_data({
435 + let data = mainwp_secure_data({
393 436 action: 'cloudways_action_backup',
394 437 website_id: websiteId,
395 438 backup_api: 'cloudways'
396 439 });
397 440
398 - jQuery(button).html('<i class="notched circle loading icon"></i>');
441 + module_api_backups_prepare_working_status(button);
399 442 jQuery(lastBackup).html('Requesting Backup...');
400 443
401 444 jQuery.post(ajaxurl, data, function (response) {
402 445 response = jQuery.trim(response);
@@ -402,29 +445,30 @@
402 445 response = jQuery.trim(response);
403 446
404 447 if (response === 'true') {
405 448
406 - jQuery('#backups_site_toast').addClass('green')
407 - .toast({
408 - class: 'success',
409 - position: 'top right',
410 - displayTime: 5000,
411 - message: 'A backup has been requested.',
412 - });
449 + // Show message.
450 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
451 + jQuery('#mainwp-api-backups-message-zone .content .message')
452 + .html( 'A backup has been requested. Please allow some time for the backup to complete, then Refresh Available Backups.')
453 + ;
454 +
413 455 setTimeout(function () {
414 - location.reload();
456 + mainwp_forceReload();
415 457 }, 5000);
458 +
416 459 } else {
417 - jQuery('#backups_site_toast').addClass('red')
418 - .toast({
419 - class: 'warning',
420 - position: 'top right',
421 - displayTime: 5000,
422 - message: 'There was an issue while requesting your backup. Please check that your ID and API Key are correct.',
423 - });
460 +
461 + // Show message.
462 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
463 + jQuery('#mainwp-api-backups-message-zone .content .message')
464 + .html('There was an issue while requesting your backup. Please check that your ID and API Key are correct.')
465 + ;
466 +
424 467 setTimeout(function () {
425 - location.reload();
468 + mainwp_forceReload();
426 469 }, 5000);
470 +
427 471 }
428 472 });
429 473
430 474 };
@@ -429,18 +473,18 @@
429 473
430 474 };
431 475
432 476 // Assign Apps to Child Sites.
433 -cloudways_action_update_ids = function (pObj) {
477 +let cloudways_action_update_ids = function (pObj) {
434 478
435 479 jQuery(pObj).attr('disabled', 'true');
436 - var button = jQuery(pObj).closest('td');
480 + let button = jQuery(pObj).closest('td');
437 481
438 - var data = mainwp_secure_data({
482 + let data = mainwp_secure_data({
439 483 action: 'cloudways_action_update_ids'
440 484 });
441 485
442 - jQuery(button).html('<i class="notched circle loading icon"></i>');
486 + module_api_backups_prepare_working_status(button);
443 487
444 488 jQuery.post(ajaxurl, data, function (response) {
445 489 response = jQuery.trim(response);
446 490
@@ -454,11 +498,11 @@
454 498 };
455 499
456 500
457 501 // Refresh Available Backup.
458 -cloudways_action_refresh_available_backups = function (pObj) {
502 +let cloudways_action_refresh_available_backups = function (pObj) {
459 503
460 - var websiteId = jQuery(pObj).attr('website_id');
504 + let websiteId = jQuery(pObj).attr('website_id');
461 505
462 506 // Start button animation.
463 507 jQuery(pObj).addClass('disabled loading');
464 508
@@ -464,9 +508,9 @@
464 508
465 509 // Prepare the data to send.
466 510 // The "action" is the name of the action hook to trigger.
467 511 // Anything else is data that we want to pass to the PHP function.
468 - var data = mainwp_secure_data({
512 + let data = mainwp_secure_data({
469 513 action: 'cloudways_action_refresh_available_backups',
470 514 website_id: websiteId,
471 515 backup_api: 'cloudways'
472 516 });
@@ -476,20 +520,17 @@
476 520 // response. The last parameter tells jQuery to expect a JSON response
477 521
478 522 jQuery.post(ajaxurl, data, function (response) {
479 523 response = jQuery.trim(response);
480 - console.log(response); // debugging....
481 524
482 525 if (response === 'true') {
483 - jQuery('#backups_site_toast').addClass('green')
484 - .toast({
485 - class: 'success',
486 - position: 'top right',
487 - displayTime: 5000,
488 - message: 'Available backups have been refreshed.',
489 - })
490 - ;
491 526
527 + // Show message.
528 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
529 + jQuery('#mainwp-api-backups-message-zone .content .message')
530 + .html( 'Available backups have been refreshed.' )
531 + ;
532 +
492 533 // Stop button animation.
493 534 jQuery(pObj).removeClass('disabled loading');
494 535
495 536 setInterval('location.reload()', 7000); // Using .reload() method.
@@ -494,17 +535,15 @@
494 535
495 536 setInterval('location.reload()', 7000); // Using .reload() method.
496 537
497 538 } else {
498 - jQuery('#backups_site_toast').addClass('red')
499 - .toast({
500 - class: 'warning',
501 - position: 'top right',
502 - displayTime: 5000,
503 - message: 'There was an issue while refreshing available backups.',
504 - })
505 - ;
506 539
540 + // Show message.
541 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
542 + jQuery('#mainwp-api-backups-message-zone .content .message')
543 + .html( 'There was an issue while refreshing available backups.' )
544 + ;
545 +
507 546 // Stop button animation.
508 547 jQuery(pObj).removeClass('disabled loading');
509 548
510 549 }
@@ -511,14 +550,14 @@
511 550 }, 'json');
512 551 };
513 552
514 553 // Restore backups.
515 -cloudways_action_restore_backup = function (pObj) {
516 - var button = jQuery(pObj);
517 - var websiteId = jQuery(pObj).attr('website_id');
518 - var backupDate = jQuery(pObj).attr('backup_date');
554 +let cloudways_action_restore_backup = function (pObj) {
555 + let button = jQuery(pObj);
556 + let websiteId = jQuery(pObj).attr('website_id');
557 + let backupDate = jQuery(pObj).attr('backup_date');
519 558
520 - var data = mainwp_secure_data({
559 + let data = mainwp_secure_data({
521 560 action: 'cloudways_action_restore_backup',
522 561 website_id: websiteId,
523 562 backup_date: backupDate,
524 563 backup_api: 'cloudways'
@@ -524,36 +563,32 @@
524 563 backup_api: 'cloudways'
525 564 });
526 565
527 566 // Start button animation.
528 - jQuery(button).html('<i class="notched circle loading icon"></i>');
567 + module_api_backups_prepare_working_status(button);
529 568
530 569 jQuery.post(ajaxurl, data, function (response) {
531 570 response = jQuery.trim(response);
532 571
533 572 if (response === 'true') {
534 - jQuery('#backups_site_toast').addClass('green')
535 - .toast({
536 - class: 'success',
537 - position: 'top right',
538 - displayTime: 5000,
539 - message: 'Your application is in the process of restoring. This will take a few minuets...',
540 - })
541 - ;
542 573
574 + // Show message.
575 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
576 + jQuery('#mainwp-api-backups-message-zone .content .message')
577 + .html( 'Your application is in the process of restoring. This will take a few minuets...' )
578 + ;
579 +
543 580 // Stop button animation.
544 581 jQuery(button).html('<i class="undo icon"></i>');
545 582
546 583 } else {
547 - jQuery('#backups_site_toast').addClass('red')
548 - .toast({
549 - class: 'warning',
550 - position: 'top right',
551 - displayTime: 5000,
552 - message: 'There was an issue while attempting to restore your application...',
553 - })
554 - ;
555 584
585 + // Show message.
586 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
587 + jQuery('#mainwp-api-backups-message-zone .content .message')
588 + .html( 'There was an issue while attempting to restore your application...' )
589 + ;
590 +
556 591 // Stop button animation.
557 592 jQuery(button).html('<i class="undo icon"></i>');
558 593
559 594 }
@@ -560,16 +595,16 @@
560 595 });
561 596 };
562 597
563 598 // Delete backups.
564 -cloudways_action_delete_backup = function (pObj) {
599 +let cloudways_action_delete_backup = function (pObj) {
565 600
566 601 jQuery(pObj).attr('disabled', 'true');
567 - var button = jQuery(pObj).closest('td');
602 + let button = jQuery(pObj).closest('td');
568 603
569 - var websiteId = jQuery(pObj).attr('website_id');
604 + let websiteId = jQuery(pObj).attr('website_id');
570 605
571 - var data = mainwp_secure_data({
606 + let data = mainwp_secure_data({
572 607 action: 'cloudways_action_delete_backup',
573 608 website_id: websiteId,
574 609 backup_api: 'cloudways'
575 610 });
@@ -581,31 +616,27 @@
581 616 jQuery.post(ajaxurl, data, function (response) {
582 617 response = jQuery.trim(response);
583 618
584 619 if (response === 'true') {
585 - jQuery('#backups_site_toast').addClass('green')
586 - .toast({
587 - class: 'success',
588 - position: 'top right',
589 - displayTime: 5000,
590 - message: 'The local backups done before last restore have been deleted.',
591 - })
592 - ;
593 620
621 + // Show message.
622 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
623 + jQuery('#mainwp-api-backups-message-zone .content .message')
624 + .html( 'The local backups done before last restore have been deleted.' )
625 + ;
626 +
594 627 // Stop button animation.
595 628 jQuery(button).find('i.loading').css({ 'display': 'none' });
596 629 jQuery(button).find('div').removeClass('hidden');
597 630
598 631 } else {
599 - jQuery('#backups_site_toast').addClass('red')
600 - .toast({
601 - class: 'warning',
602 - position: 'top right',
603 - displayTime: 5000,
604 - message: 'There was an issue while deleting your backups.',
605 - })
606 - ;
607 632
633 + // Show message.
634 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
635 + jQuery('#mainwp-api-backups-message-zone .content .message')
636 + .html( 'There was an issue while deleting your backups.' )
637 + ;
638 +
608 639 // Stop button animation.
609 640 jQuery(button).find('i.loading').css({ 'display': 'none' });
610 641 jQuery(button).find('div').removeClass('hidden');
611 642
@@ -617,13 +648,13 @@
617 648 * Vultr Functions.
618 649 */
619 650
620 651 // Assign Instances to Child Sites.
621 -vultr_action_update_ids = function (pObj) {
652 +let vultr_action_update_ids = function (pObj) {
622 653 jQuery(pObj).attr('disabled', 'true');
623 - var button = jQuery(pObj).closest('td');
654 + let button = jQuery(pObj).closest('td');
624 655
625 - var data = mainwp_secure_data({
656 + let data = mainwp_secure_data({
626 657 action: 'vultr_action_update_ids'
627 658 });
628 659
629 660 // Start button animation.
@@ -633,31 +664,27 @@
633 664 jQuery.post(ajaxurl, data, function (response) {
634 665 response = jQuery.trim(response);
635 666
636 667 if (response === 'true') {
637 - jQuery('#backups_table_toast')
638 - .toast({
639 - class: 'green',
640 - position: 'top right',
641 - displayTime: 5000,
642 - message: 'Backup Stats have been refreshed.',
643 - })
644 - ;
645 668
669 + // Show message.
670 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
671 + jQuery('#mainwp-api-backups-message-zone .content .message')
672 + .html('Backup Stats have been refreshed.')
673 + ;
674 +
646 675 // Stop button animation.
647 676 jQuery(button).find('i.loading').css({ 'display': 'none' });
648 677 jQuery(button).find('div').removeClass('hidden');
649 678
650 679 } else {
651 - jQuery('#backups_table_toast')
652 - .toast({
653 - class: 'red',
654 - position: 'top right',
655 - displayTime: 5000,
656 - message: 'There was an issue refreshing the Backup Stats.',
657 - })
658 - ;
659 680
681 + // Show message.
682 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
683 + jQuery('#mainwp-api-backups-message-zone .content .message')
684 + .html( 'There was an issue refreshing the Backup Stats.' )
685 + ;
686 +
660 687 // Stop button animation.
661 688 jQuery(button).find('i.loading').css({ 'display': 'none' });
662 689 jQuery(button).find('div').removeClass('hidden');
663 690
@@ -665,22 +692,22 @@
665 692 });
666 693 };
667 694
668 695 // Create Backup.
669 -vultr_action_create_snapshot = function (pObj) {
696 +let vultr_action_create_snapshot = function (pObj) {
670 697
671 698 jQuery(pObj).attr('disabled', 'true');
672 - var button = jQuery(pObj).closest('td');
673 - var lastBackup = jQuery(pObj).closest('td').prev();
674 - var websiteId = jQuery(pObj).attr('website_id');
699 + let button = jQuery(pObj).closest('td');
700 + let lastBackup = jQuery(pObj).closest('td').prev();
701 + let websiteId = jQuery(pObj).attr('website_id');
675 702
676 - var data = mainwp_secure_data({
703 + let data = mainwp_secure_data({
677 704 action: 'vultr_action_create_snapshot',
678 705 website_id: websiteId,
679 706 backup_api: 'vultr'
680 707 });
681 708
682 - jQuery(button).html('<i class="notched circle loading icon"></i>');
709 + module_api_backups_prepare_working_status(button);
683 710 jQuery(lastBackup).html('Requesting Backup...');
684 711
685 712 jQuery.post(ajaxurl, data, function (response) {
686 713 response = jQuery.trim(response);
@@ -685,42 +712,37 @@
685 712 jQuery.post(ajaxurl, data, function (response) {
686 713 response = jQuery.trim(response);
687 714 if (response === 'true') {
688 715
689 - jQuery('#backups_site_toast').addClass('green')
690 - .toast({
691 - class: 'success',
692 - position: 'top right',
693 - displayTime: 5000,
694 - message: 'A backup has been requested.',
695 - })
696 - ;
716 + // Show message.
717 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
718 + jQuery('#mainwp-api-backups-message-zone .content .message')
719 + .html('A backup has been requested.');
697 720 setTimeout(function () {
698 - location.reload();
721 + mainwp_forceReload();
699 722 }, 5000);
723 +
700 724 } else {
701 - var err_message = '' != response ? response : 'There was an issue while requesting your backup. Please check that your ID and API Key are correct.';
702 - jQuery('#backups_site_toast').addClass('red')
703 - .toast({
704 - class: 'warning',
705 - position: 'top right',
706 - displayTime: 5000,
707 - message: err_message,
708 - })
709 - ;
725 + let err_message = '' !== response ? response : 'There was an issue while requesting your backup. Please check that your ID and API Key are correct.';
726 +
727 + // Show message.
728 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
729 + jQuery('#mainwp-api-backups-message-zone .content .message')
730 + .html( err_message );
710 731 setTimeout(function () {
711 - location.reload();
732 + mainwp_forceReload();
712 733 }, 5000);
734 +
713 735 }
714 736 });
715 737 };
716 738
717 739 // Refresh Available Backup.
718 -vultr_action_refresh_available_backups = function (pObj) {
740 +let vultr_action_refresh_available_backups = function (pObj) {
719 741
720 - var websiteId = jQuery(pObj).attr('website_id');
742 + let websiteId = jQuery(pObj).attr('website_id');
721 743
722 - var data = mainwp_secure_data({
744 + let data = mainwp_secure_data({
723 745 action: 'vultr_action_refresh_available_backups',
724 746 website_id: websiteId,
725 747 backup_api: 'vultr'
726 748 });
@@ -731,17 +753,15 @@
731 753 jQuery.post(ajaxurl, data, function (response) {
732 754 response = jQuery.trim(response);
733 755
734 756 if (response === 'true') {
735 - jQuery('#backups_site_toast').addClass('green')
736 - .toast({
737 - class: 'success',
738 - position: 'top right',
739 - displayTime: 5000,
740 - message: 'Available backups have been refreshed.',
741 - })
742 - ;
743 757
758 + // Show message.
759 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
760 + jQuery('#mainwp-api-backups-message-zone .content .message')
761 + .html('Available backups have been refreshed.')
762 + ;
763 +
744 764 // Stop button animation.
745 765 jQuery(pObj).removeClass('disabled loading');
746 766
747 767 setInterval('location.reload()', 7000); // Using .reload() method.
@@ -746,17 +766,15 @@
746 766
747 767 setInterval('location.reload()', 7000); // Using .reload() method.
748 768
749 769 } else {
750 - jQuery('#backups_site_toast').addClass('red')
751 - .toast({
752 - class: 'warning',
753 - position: 'top right',
754 - displayTime: 5000,
755 - message: 'There was an issue while refreshing available backups.',
756 - })
757 - ;
758 770
771 + // Show message.
772 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
773 + jQuery('#mainwp-api-backups-message-zone .content .message')
774 + .html('There was an issue while refreshing available backups.' )
775 + ;
776 +
759 777 // Stop button animation.
760 778 jQuery(pObj).removeClass('disabled loading');
761 779
762 780 }
@@ -762,15 +780,15 @@
762 780 }
763 781 });
764 782 };
765 783 // Restore Backup.
766 -vultr_action_restore_backup = function (pObj) {
784 +let vultr_action_restore_backup = function (pObj) {
767 785
768 - var button = jQuery(pObj);
769 - var websiteId = jQuery(pObj).attr('website_id');
770 - var snapshotID = jQuery(pObj).attr('snapshot_id');
786 + let button = jQuery(pObj);
787 + let websiteId = jQuery(pObj).attr('website_id');
788 + let snapshotID = jQuery(pObj).attr('snapshot_id');
771 789
772 - var data = mainwp_secure_data({
790 + let data = mainwp_secure_data({
773 791 action: 'vultr_action_restore_backup',
774 792 website_id: websiteId,
775 793 backup_api: 'vultr',
776 794 snapshot_id: snapshotID
@@ -776,36 +794,32 @@
776 794 snapshot_id: snapshotID
777 795 });
778 796
779 797 // Start button animation.
780 - jQuery(button).html('<i class="notched circle loading icon"></i>');
798 + module_api_backups_prepare_working_status(button);
781 799
782 800 jQuery.post(ajaxurl, data, function (response) {
783 801 response = jQuery.trim(response);
784 - console.log(response);
802 +
785 803 if (response === 'true') {
786 - jQuery('#backups_site_toast').addClass('green')
787 - .toast({
788 - class: 'success',
789 - position: 'top right',
790 - displayTime: 5000,
791 - message: 'Backup restoration process has begun. Please wait a few moments and then check the site.',
792 - })
793 - ;
794 804
805 + // Show message.
806 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
807 + jQuery('#mainwp-api-backups-message-zone .content .message')
808 + .html('Backup restoration process has begun. Please wait a few moments and then check the site.')
809 + ;
810 +
795 811 // Stop button animation.
796 812 jQuery(button).html('<i class="undo icon"></i>');
797 813
798 814 } else {
799 - jQuery('#backups_site_toast').addClass('red')
800 - .toast({
801 - class: 'warning',
802 - position: 'top right',
803 - displayTime: 5000,
804 - message: 'There was an issue while restoring your backup.',
805 - })
806 - ;
807 815
816 + // Show message.
817 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
818 + jQuery('#mainwp-api-backups-message-zone .content .message')
819 + .html('There was an issue while restoring your backup.')
820 + ;
821 +
808 822 // Stop button animation.
809 823 jQuery(button).html('<i class="undo icon"></i>');
810 824
811 825 }
@@ -813,15 +827,15 @@
813 827 };
814 828
815 829
816 830 // Delete Backup.
817 -vultr_action_delete_backup = function (pObj) {
831 +let vultr_action_delete_backup = function (pObj) {
818 832
819 - var button = jQuery(pObj);
820 - var websiteId = jQuery(pObj).attr('website_id');
821 - var snapshotID = jQuery(pObj).attr('snapshot_id');
833 + let button = jQuery(pObj);
834 + let websiteId = jQuery(pObj).attr('website_id');
835 + let snapshotID = jQuery(pObj).attr('snapshot_id');
822 836
823 - var data = mainwp_secure_data({
837 + let data = mainwp_secure_data({
824 838 action: 'vultr_action_delete_backup',
825 839 website_id: websiteId,
826 840 backup_api: 'vultr',
827 841 snapshot_id: snapshotID
@@ -827,36 +841,32 @@
827 841 snapshot_id: snapshotID
828 842 });
829 843
830 844 // Start button animation.
831 - jQuery(button).html('<i class="notched circle loading icon"></i>');
845 + module_api_backups_prepare_working_status(button);
832 846
833 847 jQuery.post(ajaxurl, data, function (response) {
834 848 response = jQuery.trim(response);
835 - console.log(response);
849 +
836 850 if (response === 'true') {
837 - jQuery('#backups_site_toast').addClass('green')
838 - .toast({
839 - class: 'success',
840 - position: 'top right',
841 - displayTime: 5000,
842 - message: 'The selected backup has been deleted.',
843 - })
844 - ;
845 851
852 + // Show message.
853 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
854 + jQuery('#mainwp-api-backups-message-zone .content .message')
855 + .html('The selected backup has been deleted.')
856 + ;
857 +
846 858 // Stop button animation.
847 859 jQuery(button).html('<i class="undo icon"></i>');
848 860
849 861 } else {
850 - jQuery('#backups_site_toast').addClass('red')
851 - .toast({
852 - class: 'warning',
853 - position: 'top right',
854 - displayTime: 5000,
855 - message: 'There was an issue while deleting the selected backup.',
856 - })
857 - ;
858 862
863 + // Show message.
864 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
865 + jQuery('#mainwp-api-backups-message-zone .content .message')
866 + .html('There was an issue while deleting the selected backup.')
867 + ;
868 +
859 869 // Stop button animation.
860 870 jQuery(button).html('<i class="undo icon"></i>');
861 871
862 872 }
@@ -868,17 +878,17 @@
868 878 * Gridpane Functions.
869 879 */
870 880
871 881 // Assign Site ID's to Child Sites.
872 -gridpane_action_update_ids = function (pObj) {
882 +let gridpane_action_update_ids = function (pObj) {
873 883 jQuery(pObj).attr('disabled', 'true');
874 - var button = jQuery(pObj).closest('td');
884 + let button = jQuery(pObj).closest('td');
875 885
876 - var data = mainwp_secure_data({
886 + let data = mainwp_secure_data({
877 887 action: 'gridpane_action_update_ids'
878 888 });
879 889
880 - jQuery(button).html('<i class="notched circle loading icon"></i>');
890 + module_api_backups_prepare_working_status(button);
881 891
882 892 jQuery.post(ajaxurl, data, function (response) {
883 893 response = jQuery.trim(response);
884 894
@@ -891,22 +901,22 @@
891 901 });
892 902 };
893 903
894 904 // Create Backup.
895 -gridpane_action_create_backup = function (pObj) {
905 +let gridpane_action_create_backup = function (pObj) {
896 906
897 907 jQuery(pObj).attr('disabled', 'true');
898 - var button = jQuery(pObj).closest('td');
899 - var lastBackup = jQuery(pObj).closest('td').prev();
900 - var websiteId = jQuery(pObj).attr('website_id');
908 + let button = jQuery(pObj).closest('td');
909 + let lastBackup = jQuery(pObj).closest('td').prev();
910 + let websiteId = jQuery(pObj).attr('website_id');
901 911
902 - var data = mainwp_secure_data({
912 + let data = mainwp_secure_data({
903 913 action: 'gridpane_action_create_backup',
904 914 website_id: websiteId,
905 915 backup_api: 'gridpane'
906 916 });
907 917
908 - jQuery(button).html('<i class="notched circle loading icon"></i>');
918 + module_api_backups_prepare_working_status(button);
909 919
910 920 jQuery(lastBackup).html('Requesting Backup...');
911 921
912 922 jQuery.post(ajaxurl, data, function (response) {
@@ -913,41 +923,40 @@
913 923 response = jQuery.trim(response);
914 924
915 925 if (response === 'true') {
916 926
917 - jQuery('#backups_site_toast').addClass('green')
918 - .toast({
919 - class: 'success',
920 - position: 'top right',
921 - displayTime: 5000,
922 - message: 'A backup has been requested.',
923 - })
924 - ;
927 + // Show message.
928 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
929 + jQuery('#mainwp-api-backups-message-zone .content .message')
930 + .html('A backup has been requested.')
931 + ;
932 +
925 933 setTimeout(function () {
926 - location.reload();
934 + mainwp_forceReload();
927 935 }, 5000);
936 +
928 937 } else {
929 - jQuery('#backups_site_toast').addClass('red')
930 - .toast({
931 - class: 'warning',
932 - position: 'top right',
933 - displayTime: 5000,
934 - message: 'There was an issue while requesting your backup. Please check that your ID and API Key are correct.',
935 - })
936 - ;
938 +
939 + // Show message.
940 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
941 + jQuery('#mainwp-api-backups-message-zone .content .message')
942 + .html('There was an issue while requesting your backup. Please check that your ID and API Key are correct.' )
943 + ;
944 +
937 945 setTimeout(function () {
938 - location.reload();
946 + mainwp_forceReload();
939 947 }, 5000);
948 +
940 949 }
941 950 });
942 951 };
943 952
944 953 // Refresh Available Backup.
945 -gridpane_action_refresh_available_backups = function (pObj) {
954 +let gridpane_action_refresh_available_backups = function (pObj) {
946 955
947 - var websiteId = jQuery(pObj).attr('website_id');
956 + let websiteId = jQuery(pObj).attr('website_id');
948 957
949 - var data = mainwp_secure_data({
958 + let data = mainwp_secure_data({
950 959 action: 'gridpane_action_refresh_available_backups',
951 960 website_id: websiteId,
952 961 backup_api: 'gridpane'
953 962 });
@@ -958,17 +967,15 @@
958 967 jQuery.post(ajaxurl, data, function (response) {
959 968 response = jQuery.trim(response);
960 969
961 970 if (response === 'true') {
962 - jQuery('#backups_site_toast').addClass('green')
963 - .toast({
964 - class: 'success',
965 - position: 'top right',
966 - displayTime: 5000,
967 - message: 'Available backups have been refreshed.',
968 - })
969 - ;
970 971
972 + // Show message.
973 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
974 + jQuery('#mainwp-api-backups-message-zone .content .message')
975 + .html('Available backups have been refreshed.')
976 + ;
977 +
971 978 // Stop button animation.
972 979 jQuery(pObj).removeClass('disabled loading');
973 980
974 981 setInterval('location.reload()', 7000); // Using .reload() method.
@@ -973,17 +980,15 @@
973 980
974 981 setInterval('location.reload()', 7000); // Using .reload() method.
975 982
976 983 } else {
977 - jQuery('#backups_site_toast').addClass('red')
978 - .toast({
979 - class: 'warning',
980 - position: 'top right',
981 - displayTime: 5000,
982 - message: 'There was an issue while refreshing available backups.',
983 - })
984 - ;
985 984
985 + // Show message.
986 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
987 + jQuery('#mainwp-api-backups-message-zone .content .message')
988 + .html('There was an issue while refreshing available backups.' )
989 + ;
990 +
986 991 // Stop button animation.
987 992 jQuery(pObj).removeClass('disabled loading');
988 993
989 994 }
@@ -990,16 +995,16 @@
990 995 });
991 996 };
992 997
993 998 // Restore Backup.
994 -gridpane_action_restore_backup = function (pObj) {
999 +let gridpane_action_restore_backup = function (pObj) {
995 1000
996 - var button = jQuery(pObj);
997 - var websiteId = jQuery(pObj).attr('website_id');
998 - var backupType = jQuery(pObj).attr('backup_type');
999 - var backupName = jQuery(pObj).attr('backup_name');
1001 + let button = jQuery(pObj);
1002 + let websiteId = jQuery(pObj).attr('website_id');
1003 + let backupType = jQuery(pObj).attr('backup_type');
1004 + let backupName = jQuery(pObj).attr('backup_name');
1000 1005
1001 - var data = mainwp_secure_data({
1006 + let data = mainwp_secure_data({
1002 1007 action: 'gridpane_action_restore_backup',
1003 1008 website_id: websiteId,
1004 1009 backup_api: 'gridpane',
1005 1010 backup_type: backupType,
@@ -1006,36 +1011,32 @@
1006 1011 backup_name: backupName
1007 1012 });
1008 1013
1009 1014 // Start button animation.
1010 - jQuery(button).html('<i class="notched circle loading icon"></i>');
1015 + module_api_backups_prepare_working_status(button);
1011 1016
1012 1017 jQuery.post(ajaxurl, data, function (response) {
1013 1018 response = jQuery.trim(response);
1014 - console.log(response);
1019 +
1015 1020 if (response === 'true') {
1016 - jQuery('#backups_site_toast').addClass('green')
1017 - .toast({
1018 - class: 'success',
1019 - position: 'top right',
1020 - displayTime: 5000,
1021 - message: 'Backup restoration has begun. Please wait a few moments and then check the site.',
1022 - })
1023 - ;
1024 1021
1022 + // Show message.
1023 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
1024 + jQuery('#mainwp-api-backups-message-zone .content .message')
1025 + .html('Backup restoration has begun. Please wait a few moments and then check the site.')
1026 + ;
1027 +
1025 1028 // Stop button animation.
1026 1029 jQuery(button).html('<i class="undo icon"></i>');
1027 1030
1028 1031 } else {
1029 - jQuery('#backups_site_toast').addClass('red')
1030 - .toast({
1031 - class: 'warning',
1032 - position: 'top right',
1033 - displayTime: 5000,
1034 - message: 'There was an issue while restoring your backup.',
1035 - })
1036 - ;
1037 1032
1033 + // Show message.
1034 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
1035 + jQuery('#mainwp-api-backups-message-zone .content .message')
1036 + .html('There was an issue while restoring your backup.' )
1037 + ;
1038 +
1038 1039 // Stop button animation.
1039 1040 jQuery(button).html('<i class="undo icon"></i>');
1040 1041
1041 1042 }
@@ -1042,17 +1043,17 @@
1042 1043 });
1043 1044 };
1044 1045
1045 1046 // Delete Backup.
1046 -gridpane_action_delete_backup = function (pObj) {
1047 +let gridpane_action_delete_backup = function (pObj) {
1047 1048
1048 - var button = jQuery(pObj);
1049 + let button = jQuery(pObj);
1049 1050
1050 - var websiteId = jQuery(pObj).attr('website_id');
1051 - var backupType = jQuery(pObj).attr('backup_type');
1052 - var backupName = jQuery(pObj).attr('backup_name');
1051 + let websiteId = jQuery(pObj).attr('website_id');
1052 + let backupType = jQuery(pObj).attr('backup_type');
1053 + let backupName = jQuery(pObj).attr('backup_name');
1053 1054
1054 - var data = mainwp_secure_data({
1055 + let data = mainwp_secure_data({
1055 1056 action: 'gridpane_action_delete_backup',
1056 1057 website_id: websiteId,
1057 1058 backup_api: 'gridpane',
1058 1059 backup_type: backupType,
@@ -1059,36 +1060,32 @@
1059 1060 backup_name: backupName
1060 1061 });
1061 1062
1062 1063 // Start button animation.
1063 - jQuery(button).html('<i class="notched circle loading icon"></i>');
1064 + module_api_backups_prepare_working_status(button);
1064 1065
1065 1066 jQuery.post(ajaxurl, data, function (response) {
1066 1067 response = jQuery.trim(response);
1067 - console.log(response);
1068 +
1068 1069 if (response === 'true') {
1069 - jQuery('#backups_site_toast').addClass('green')
1070 - .toast({
1071 - class: 'success',
1072 - position: 'top right',
1073 - displayTime: 5000,
1074 - message: 'The selected backup has been deleted.',
1075 - })
1076 - ;
1077 1070
1071 + // Show message.
1072 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
1073 + jQuery('#mainwp-api-backups-message-zone .content .message')
1074 + .html('The selected backup has been deleted.')
1075 + ;
1076 +
1078 1077 // Stop button animation.
1079 1078 jQuery(button).html('<i class="trash icon"></i>');
1080 1079
1081 1080 } else {
1082 - jQuery('#backups_site_toast').addClass('red')
1083 - .toast({
1084 - class: 'warning',
1085 - position: 'top right',
1086 - displayTime: 5000,
1087 - message: 'There was an issue while deleting the selected backup.',
1088 - })
1089 - ;
1090 1081
1082 + // Show message.
1083 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
1084 + jQuery('#mainwp-api-backups-message-zone .content .message')
1085 + .html('There was an issue while deleting the selected backup.')
1086 + ;
1087 +
1091 1088 // Stop button animation.
1092 1089 jQuery(button).html('<i class="trash icon"></i>');
1093 1090
1094 1091 }
@@ -1099,47 +1096,44 @@
1099 1096 * Linode Functions.
1100 1097 */
1101 1098
1102 1099 // Assign Site ID's to Child Sites.
1103 -linode_action_update_ids = function (pObj) {
1100 +let linode_action_update_ids = function (pObj) {
1104 1101 jQuery(pObj).attr('disabled', 'true');
1105 - var button = jQuery(pObj).closest('td');
1102 + let button = jQuery(pObj).closest('td');
1106 1103
1107 - var data = mainwp_secure_data({
1104 + let data = mainwp_secure_data({
1108 1105 action: 'linode_action_update_ids'
1109 1106 });
1110 1107
1111 - jQuery(button).html('<i class="notched circle loading icon"></i>');
1108 + module_api_backups_prepare_working_status(button);
1112 1109
1113 1110 jQuery.post(ajaxurl, data, function (response) {
1114 1111 response = jQuery.trim(response);
1115 - //console.log( response ); // debugging....
1116 1112
1117 -
1118 1113 if (response === 'true') {
1119 1114 window.location.search += '&update=true';
1120 1115 } else {
1121 1116 window.location.search += '&update=false';
1122 1117 }
1123 -
1124 1118 });
1125 1119 };
1126 1120
1127 1121 // Create Backup.
1128 -linode_action_create_backup = function (pObj) {
1122 +let linode_action_create_backup = function (pObj) {
1129 1123
1130 1124 jQuery(pObj).attr('disabled', 'true');
1131 - var button = jQuery(pObj).closest('td');
1132 - var lastBackup = jQuery(pObj).closest('td').prev();
1133 - var websiteId = jQuery(pObj).attr('website_id');
1125 + let button = jQuery(pObj).closest('td');
1126 + let lastBackup = jQuery(pObj).closest('td').prev();
1127 + let websiteId = jQuery(pObj).attr('website_id');
1134 1128
1135 - var data = mainwp_secure_data({
1129 + let data = mainwp_secure_data({
1136 1130 action: 'linode_action_create_backup',
1137 1131 website_id: websiteId,
1138 1132 backup_api: 'linode'
1139 1133 });
1140 1134
1141 - jQuery(button).html('<i class="notched circle loading icon"></i>');
1135 + module_api_backups_prepare_working_status(button);
1142 1136
1143 1137 jQuery(lastBackup).html('Requesting Backup...');
1144 1138
1145 1139 jQuery.post(ajaxurl, data, function (response) {
@@ -1146,30 +1140,28 @@
1146 1140 response = jQuery.trim(response);
1147 1141
1148 1142 if (response === 'true') {
1149 1143
1150 - jQuery('#backups_site_toast').addClass('green')
1151 - .toast({
1152 - class: 'success',
1153 - position: 'top right',
1154 - displayTime: 5000,
1155 - message: 'A backup has been requested.',
1156 - })
1157 - ;
1144 + // Show message.
1145 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
1146 + jQuery('#mainwp-api-backups-message-zone .content .message')
1147 + .html('A backup has been requested.')
1148 + ;
1149 +
1158 1150 setTimeout(function () {
1159 - location.reload();
1151 + mainwp_forceReload();
1160 1152 }, 5000);
1153 +
1161 1154 } else {
1162 - jQuery('#backups_site_toast').addClass('red')
1163 - .toast({
1164 - class: 'warning',
1165 - position: 'top right',
1166 - displayTime: 5000,
1167 - message: 'There was an issue while requesting your backup. Please check that your backups are enabled & ID\'s are correct.',
1168 - })
1169 - ;
1155 +
1156 + // Show message.
1157 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
1158 + jQuery('#mainwp-api-backups-message-zone .content .message')
1159 + .html('There was an issue while requesting your backup. Please check that your backups are enabled & ID\'s are correct.')
1160 + ;
1161 +
1170 1162 setTimeout(function () {
1171 - location.reload();
1163 + mainwp_forceReload();
1172 1164 }, 5000);
1173 1165 }
1174 1166 });
1175 1167 };
@@ -1174,13 +1166,13 @@
1174 1166 });
1175 1167 };
1176 1168
1177 1169 // Refresh Available Backup.
1178 -linode_action_refresh_available_backups = function (pObj) {
1170 +let linode_action_refresh_available_backups = function (pObj) {
1179 1171
1180 - var websiteId = jQuery(pObj).attr('website_id');
1172 + let websiteId = jQuery(pObj).attr('website_id');
1181 1173
1182 - var data = mainwp_secure_data({
1174 + let data = mainwp_secure_data({
1183 1175 action: 'linode_action_refresh_available_backups',
1184 1176 website_id: websiteId,
1185 1177 backup_api: 'linode'
1186 1178 });
@@ -1191,17 +1183,15 @@
1191 1183 jQuery.post(ajaxurl, data, function (response) {
1192 1184 response = jQuery.trim(response);
1193 1185
1194 1186 if (response === 'true') {
1195 - jQuery('#backups_site_toast').addClass('green')
1196 - .toast({
1197 - class: 'success',
1198 - position: 'top right',
1199 - displayTime: 5000,
1200 - message: 'Available backups have been refreshed.',
1201 - })
1202 - ;
1203 1187
1188 + // Show message.
1189 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
1190 + jQuery('#mainwp-api-backups-message-zone .content .message')
1191 + .html('Available backups have been refreshed.')
1192 + ;
1193 +
1204 1194 // Stop button animation.
1205 1195 jQuery(pObj).removeClass('disabled loading');
1206 1196
1207 1197 setInterval('location.reload()', 7000); // Using .reload() method.
@@ -1206,17 +1196,15 @@
1206 1196
1207 1197 setInterval('location.reload()', 7000); // Using .reload() method.
1208 1198
1209 1199 } else {
1210 - jQuery('#backups_site_toast').addClass('red')
1211 - .toast({
1212 - class: 'warning',
1213 - position: 'top right',
1214 - displayTime: 5000,
1215 - message: 'There was an issue while refreshing available backups.',
1216 - })
1217 - ;
1218 1200
1201 + // Show message.
1202 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
1203 + jQuery('#mainwp-api-backups-message-zone .content .message')
1204 + .html('There was an issue while refreshing available backups.')
1205 + ;
1206 +
1219 1207 // Stop button animation.
1220 1208 jQuery(pObj).removeClass('disabled loading');
1221 1209
1222 1210 }
@@ -1223,17 +1211,17 @@
1223 1211 });
1224 1212 };
1225 1213
1226 1214 // restore Backup.
1227 -linode_action_restore_backup = function (pObj) {
1215 +let linode_action_restore_backup = function (pObj) {
1228 1216
1229 1217 jQuery(pObj).attr('disabled', 'true');
1230 - var button = jQuery(pObj).closest('td');
1231 - var backupStatus = jQuery(pObj).closest('td').prev();
1232 - var websiteId = jQuery(pObj).attr('website_id');
1233 - var backupId = jQuery(pObj).attr('backup_id');
1218 + let button = jQuery(pObj).closest('td');
1219 + let backupStatus = jQuery(pObj).closest('td').prev();
1220 + let websiteId = jQuery(pObj).attr('website_id');
1221 + let backupId = jQuery(pObj).attr('backup_id');
1234 1222
1235 - var data = mainwp_secure_data({
1223 + let data = mainwp_secure_data({
1236 1224 action: 'linode_action_restore_backup',
1237 1225 website_id: websiteId,
1238 1226 backup_api: 'linode',
1239 1227 backup_id: backupId
@@ -1239,39 +1227,33 @@
1239 1227 backup_id: backupId
1240 1228 });
1241 1229
1242 1230 // Start button animation.
1243 - jQuery(button).html('<i class="notched circle loading icon"></i>');
1231 + module_api_backups_prepare_working_status(button);
1244 1232 jQuery(backupStatus).html('Restoring Backup...');
1245 1233
1246 1234 jQuery.post(ajaxurl, data, function (response) {
1247 1235 response = jQuery.trim(response);
1248 1236
1249 - console.log(response);
1237 + if (response === 'true') {
1250 1238
1239 + // Show message.
1240 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
1241 + jQuery('#mainwp-api-backups-message-zone .content .message')
1242 + .html('The backup restoration was successful. Please check your Linode Server Status...')
1243 + ;
1251 1244
1252 - if (response === 'true') {
1253 - jQuery('#backups_site_toast').addClass('green')
1254 - .toast({
1255 - class: 'success',
1256 - position: 'top right',
1257 - displayTime: 5000,
1258 - message: 'The backup restoration was successful. Please check your Linode Server Status...',
1259 - })
1260 - ;
1261 1245 jQuery(backupStatus).html('Rebooting Server...');
1262 1246 setInterval('location.reload()', 7000);// Using .reload() method.
1263 1247
1264 1248 } else {
1265 - jQuery('#backups_site_toast').addClass('red')
1266 - .toast({
1267 - class: 'warning',
1268 - position: 'top right',
1269 - displayTime: 5000,
1270 - message: 'There was an issue while restoring your backup.',
1271 - })
1272 - ;
1273 1249
1250 + // Show message.
1251 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
1252 + jQuery('#mainwp-api-backups-message-zone .content .message')
1253 + .html('There was an issue while restoring your backup.')
1254 + ;
1255 +
1274 1256 // Stop button animation.
1275 1257 setInterval('location.reload()', 7000); // Using .reload() method.
1276 1258
1277 1259 }
@@ -1278,13 +1260,13 @@
1278 1260 });
1279 1261 };
1280 1262
1281 1263 // Cancel Backup.
1282 -linode_action_cancel_backups = function (pObj) {
1264 +let linode_action_cancel_backups = function (pObj) {
1283 1265
1284 - var websiteId = jQuery(pObj).attr('website_id');
1266 + let websiteId = jQuery(pObj).attr('website_id');
1285 1267
1286 - var data = mainwp_secure_data({
1268 + let data = mainwp_secure_data({
1287 1269 action: 'linode_action_cancel_backups',
1288 1270 website_id: websiteId,
1289 1271 backup_api: 'linode'
1290 1272 });
@@ -1295,30 +1277,26 @@
1295 1277 jQuery.post(ajaxurl, data, function (response) {
1296 1278 response = jQuery.trim(response);
1297 1279
1298 1280 if (response === 'true') {
1299 - jQuery('#backups_site_toast').addClass('green')
1300 - .toast({
1301 - class: 'success',
1302 - position: 'top right',
1303 - displayTime: 5000,
1304 - message: 'The backups associated with this Linode have been removed.',
1305 - })
1306 - ;
1307 1281
1282 + // Show message.
1283 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
1284 + jQuery('#mainwp-api-backups-message-zone .content .message')
1285 + .html('The backups associated with this Linode have been removed.')
1286 + ;
1287 +
1308 1288 // Stop button animation.
1309 1289 jQuery(pObj).removeClass('disabled loading');
1310 1290
1311 1291 } else {
1312 - jQuery('#backups_site_toast').addClass('red')
1313 - .toast({
1314 - class: 'warning',
1315 - position: 'top right',
1316 - displayTime: 5000,
1317 - message: 'There was an issue while canceling your backup.',
1318 - })
1319 - ;
1320 1292
1293 + // Show message.
1294 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
1295 + jQuery('#mainwp-api-backups-message-zone .content .message')
1296 + .html('There was an issue while canceling your backup.')
1297 + ;
1298 +
1321 1299 // Stop button animation.
1322 1300 jQuery(pObj).removeClass('disabled loading');
1323 1301
1324 1302 }
@@ -1324,67 +1302,22 @@
1324 1302 }
1325 1303 });
1326 1304 };
1327 1305
1328 -// Check Linode Status.
1329 -// linode_action_linode_status = function ( pObj ) {
1330 -// var websiteId = jQuery( pObj ).attr( 'website_id' );
1331 -//
1332 -// var data = mainwp_secure_data({
1333 -// action:'linode_action_linode_status',
1334 -// website_id: '8',
1335 -// backup_api: 'linode'
1336 -// });
1337 -//
1338 -// jQuery.post( ajaxurl, data, function ( response ) {
1339 -// response = jQuery.trim( response );
1340 -//
1341 -// console.log( response );
1342 -//
1343 -// if ( response === 'true' ) {
1344 -// jQuery('#backups_site_toast').addClass( 'green' )
1345 -// .toast({
1346 -// class: 'success',
1347 -// position: 'top right',
1348 -// displayTime: 9000,
1349 -// message: 'The Linode has been restored & the server will re-boot in 15 seconds...',
1350 -// })
1351 -// ;
1352 -//
1353 -// // Stop button animation.
1354 -// //jQuery( pObj ).removeClass('disabled loading' );
1355 -//
1356 -// } else {
1357 -// jQuery('#backups_site_toast').addClass( 'red' )
1358 -// .toast({
1359 -// class: 'warning',
1360 -// position: 'top right',
1361 -// displayTime: 9000,
1362 -// message: 'There was an issue while restoring your backup...',
1363 -// })
1364 -// ;
1365 -//
1366 -// // Stop button animation.
1367 -// //jQuery( pObj ).removeClass('disabled loading' );
1368 -//
1369 -// }
1370 -// } );
1371 -// };
1372 -
1373 1306 /********************************************************
1374 1307 * Digital Ocean Functions.
1375 1308 */
1376 1309
1377 1310 // Assign Site ID's to Child Sites.
1378 -digitalocean_action_update_ids = function (pObj) {
1311 +let digitalocean_action_update_ids = function (pObj) {
1379 1312 jQuery(pObj).attr('disabled', 'true');
1380 - var button = jQuery(pObj).closest('td');
1313 + let button = jQuery(pObj).closest('td');
1381 1314
1382 - var data = mainwp_secure_data({
1315 + let data = mainwp_secure_data({
1383 1316 action: 'digitalocean_action_update_ids'
1384 1317 });
1385 1318
1386 - jQuery(button).html('<i class="notched circle loading icon"></i>');
1319 + module_api_backups_prepare_working_status(button);
1387 1320
1388 1321 jQuery.post(ajaxurl, data, function (response) {
1389 1322 response = jQuery.trim(response);
1390 1323
@@ -1397,25 +1330,22 @@
1397 1330 });
1398 1331 };
1399 1332
1400 1333 // Create Backup.
1401 -digitalocean_action_create_backup = function (pObj) {
1402 -
1334 +let digitalocean_action_create_backup = function (pObj) {
1403 1335 jQuery(pObj).attr('disabled', 'true');
1404 - var button = jQuery(pObj).closest('td');
1405 - var lastBackup = jQuery(pObj).closest('td').prev();
1406 - var websiteId = jQuery(pObj).attr('website_id');
1336 + let button = jQuery(pObj).closest('td');
1337 + let lastBackup = jQuery(pObj).closest('td').prev();
1338 + let websiteId = jQuery(pObj).attr('website_id');
1407 1339
1408 - var data = mainwp_secure_data({
1340 + let data = mainwp_secure_data({
1409 1341 action: 'digitalocean_action_create_backup',
1410 1342 website_id: websiteId,
1411 1343 backup_api: 'digitalocean'
1412 1344 });
1413 1345
1414 - console.log(data);
1346 + module_api_backups_prepare_working_status(button);
1415 1347
1416 - jQuery(button).html('<i class="notched circle loading icon"></i>');
1417 -
1418 1348 jQuery(lastBackup).html('Requesting Backup...');
1419 1349
1420 1350 jQuery.post(ajaxurl, data, function (response) {
1421 1351 response = jQuery.trim(response);
@@ -1421,30 +1351,27 @@
1421 1351 response = jQuery.trim(response);
1422 1352
1423 1353 if (response === 'true') {
1424 1354
1425 - jQuery('#backups_site_toast').addClass('green')
1426 - .toast({
1427 - class: 'success',
1428 - position: 'top right',
1429 - displayTime: 5000,
1430 - message: 'A backup has been requested.',
1431 - })
1432 - ;
1355 + // Show message.
1356 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
1357 + jQuery('#mainwp-api-backups-message-zone .content .message')
1358 + .html('A backup has been requested.')
1359 + ;
1360 +
1433 1361 setTimeout(function () {
1434 - location.reload();
1362 + mainwp_forceReload();
1435 1363 }, 5000);
1436 1364 } else {
1437 - jQuery('#backups_site_toast').addClass('red')
1438 - .toast({
1439 - class: 'warning',
1440 - position: 'top right',
1441 - displayTime: 5000,
1442 - message: 'There was an issue while requesting your backup. Please check that your ID and API Key are correct.',
1443 - })
1444 - ;
1365 +
1366 + // Show message.
1367 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
1368 + jQuery('#mainwp-api-backups-message-zone .content .message')
1369 + .html('There was an issue while requesting your backup. Please check that your ID and API Key are correct.')
1370 + ;
1371 +
1445 1372 setTimeout(function () {
1446 - location.reload();
1373 + mainwp_forceReload();
1447 1374 }, 5000);
1448 1375 }
1449 1376 });
1450 1377 };
@@ -1449,13 +1376,13 @@
1449 1376 });
1450 1377 };
1451 1378
1452 1379 // Refresh Available Backups.
1453 -digitalocean_action_refresh_available_backups = function (pObj) {
1380 +let digitalocean_action_refresh_available_backups = function (pObj) {
1454 1381
1455 - var websiteId = jQuery(pObj).attr('website_id');
1382 + let websiteId = jQuery(pObj).attr('website_id');
1456 1383
1457 - var data = mainwp_secure_data({
1384 + let data = mainwp_secure_data({
1458 1385 action: 'digitalocean_action_refresh_available_backups',
1459 1386 website_id: websiteId,
1460 1387 backup_api: 'digitalocean'
1461 1388 });
@@ -1466,17 +1393,15 @@
1466 1393 jQuery.post(ajaxurl, data, function (response) {
1467 1394 response = jQuery.trim(response);
1468 1395
1469 1396 if (response === 'true') {
1470 - jQuery('#backups_site_toast').addClass('green')
1471 - .toast({
1472 - class: 'success',
1473 - position: 'top right',
1474 - displayTime: 5000,
1475 - message: 'Available backups have been refreshed.',
1476 - })
1477 - ;
1478 1397
1398 + // Show message.
1399 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
1400 + jQuery('#mainwp-api-backups-message-zone .content .message')
1401 + .html('Available backups have been refreshed.')
1402 + ;
1403 +
1479 1404 // Stop button animation.
1480 1405 jQuery(pObj).removeClass('disabled loading');
1481 1406
1482 1407 setInterval('location.reload()', 7000);// Using .reload() method.
@@ -1481,17 +1406,15 @@
1481 1406
1482 1407 setInterval('location.reload()', 7000);// Using .reload() method.
1483 1408
1484 1409 } else {
1485 - jQuery('#backups_site_toast').addClass('red')
1486 - .toast({
1487 - class: 'warning',
1488 - position: 'top right',
1489 - displayTime: 5000,
1490 - message: 'There was an issue while refreshing available backups.',
1491 - })
1492 - ;
1493 1410
1411 + // Show message.
1412 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
1413 + jQuery('#mainwp-api-backups-message-zone .content .message')
1414 + .html('There was an issue while refreshing available backups.')
1415 + ;
1416 +
1494 1417 // Stop button animation.
1495 1418 jQuery(pObj).removeClass('disabled loading');
1496 1419
1497 1420 }
@@ -1498,16 +1421,16 @@
1498 1421 });
1499 1422 };
1500 1423
1501 1424 // restore Backup.
1502 -digitalocean_action_restore_backup = function (pObj) {
1425 +let digitalocean_action_restore_backup = function (pObj) {
1503 1426
1504 - var button = jQuery(pObj);
1505 - var lastBackup = jQuery(pObj).closest('td').prev();
1506 - var websiteId = jQuery(pObj).attr('website_id');
1507 - var snapshotId = jQuery(pObj).attr('snapshot_id');
1427 + let button = jQuery(pObj);
1428 + let lastBackup = jQuery(pObj).closest('td').prev();
1429 + let websiteId = jQuery(pObj).attr('website_id');
1430 + let snapshotId = jQuery(pObj).attr('snapshot_id');
1508 1431
1509 - var data = mainwp_secure_data({
1432 + let data = mainwp_secure_data({
1510 1433 action: 'digitalocean_action_restore_backup',
1511 1434 website_id: websiteId,
1512 1435 backup_api: 'digitalocean',
1513 1436 snapshot_id: snapshotId
@@ -1513,9 +1436,9 @@
1513 1436 snapshot_id: snapshotId
1514 1437 });
1515 1438
1516 1439 // Start button animation.
1517 - jQuery(button).html('<i class="notched circle loading icon"></i>');
1440 + module_api_backups_prepare_working_status(button);
1518 1441
1519 1442 jQuery.post(ajaxurl, data, function (response) {
1520 1443 response = jQuery.trim(response);
1521 1444
@@ -1521,79 +1444,70 @@
1521 1444
1522 1445 jQuery(lastBackup).html('');
1523 1446
1524 1447 if (response === 'true') {
1525 - jQuery('#backups_site_toast').addClass('green')
1526 - .toast({
1527 - class: 'success',
1528 - position: 'top right',
1529 - displayTime: 5000,
1530 - message: 'Backup restoration has begun. Please wait a few moments and then check the site.',
1531 - })
1532 - ;
1533 1448
1449 + // Show message.
1450 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
1451 + jQuery('#mainwp-api-backups-message-zone .content .message')
1452 + .html('Backup restoration has begun. Please wait a few moments and then check the site.')
1453 + ;
1454 +
1534 1455 // Stop button animation.
1535 1456 jQuery(button).html('<i class="undo icon"></i>');
1536 1457
1537 1458 } else {
1538 - jQuery('#backups_site_toast').addClass('red')
1539 - .toast({
1540 - class: 'warning',
1541 - position: 'top right',
1542 - displayTime: 5000,
1543 - message: 'There was an issue while restoring your backup.',
1544 - })
1545 - ;
1546 1459
1460 + // Show message.
1461 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
1462 + jQuery('#mainwp-api-backups-message-zone .content .message')
1463 + .html('There was an issue while restoring your backup.')
1464 + ;
1465 +
1547 1466 // Stop button animation.
1548 1467 jQuery(button).html('<i class="undo icon"></i>');
1549 1468 }
1550 1469
1551 -
1552 1470 });
1553 1471 };
1554 1472
1555 1473 // Delete Backup.
1556 -digitalocean_action_delete_backup = function (pObj) {
1474 +let digitalocean_action_delete_backup = function (pObj) {
1557 1475
1558 - var button = jQuery(pObj);
1476 + let button = jQuery(pObj);
1559 1477
1560 - var snapshotId = jQuery(pObj).attr('snapshot_id');
1478 + let snapshotId = jQuery(pObj).attr('snapshot_id');
1561 1479
1562 - var data = mainwp_secure_data({
1480 + let data = mainwp_secure_data({
1563 1481 action: 'digitalocean_action_delete_backup',
1564 1482 snapshot_id: snapshotId
1565 1483 });
1566 1484
1567 1485 // Start button animation.
1568 - jQuery(button).html('<i class="notched circle loading icon"></i>');
1486 + module_api_backups_prepare_working_status(button);
1569 1487
1570 1488 jQuery.post(ajaxurl, data, function (response) {
1571 1489 response = jQuery.trim(response);
1572 - console.log(response);
1490 +
1573 1491 if (response === 'true') {
1574 - jQuery('#backups_site_toast').addClass('green')
1575 - .toast({
1576 - class: 'success',
1577 - position: 'top right',
1578 - displayTime: 5000,
1579 - message: 'The selected backup has been deleted.',
1580 - })
1581 - ;
1582 1492
1493 + // Show message.
1494 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
1495 + jQuery('#mainwp-api-backups-message-zone .content .message')
1496 + .html('The selected backup has been deleted.')
1497 + ;
1498 +
1583 1499 // Stop button animation.
1584 1500 jQuery(button).html('<i class="trash icon"></i>');
1585 1501
1586 1502 } else {
1587 - jQuery('#backups_site_toast').addClass('red')
1588 - .toast({
1589 - class: 'warning',
1590 - position: 'top right',
1591 - displayTime: 5000,
1592 - message: 'There was an issue while deleting the selected backup.',
1593 - })
1594 - ;
1595 1503
1504 + // Show message.
1505 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
1506 + jQuery('#mainwp-api-backups-message-zone .content .message')
1507 + .html('There was an issue while deleting the selected backup.')
1508 + ;
1509 +
1596 1510 // Stop button animation.
1597 1511 jQuery(button).html('<i class="trash icon"></i>');
1598 1512
1599 1513 }
@@ -1603,16 +1517,17 @@
1603 1517 /********************************************************
1604 1518 * Cpanel Functions.
1605 1519 */
1606 1520
1607 -cpanel_action_create_wptk_backup = function (pObj) {
1521 +let cpanel_action_create_wptk_backup = function (pObj) {
1608 1522
1609 - var websiteId = jQuery(pObj).attr('website_id');
1523 + let websiteId = jQuery(pObj).attr('website_id');
1610 1524
1611 - var data = mainwp_secure_data({
1525 + let data = mainwp_secure_data({
1612 1526 action: 'cpanel_action_create_wptk_backup',
1613 1527 website_id: websiteId,
1614 - backup_api: 'cpanel'
1528 + backup_api: 'cpanel',
1529 + backup: 'true'
1615 1530 });
1616 1531
1617 1532 // Start button animation.
1618 1533 jQuery(pObj).addClass('disabled loading');
@@ -1620,31 +1535,25 @@
1620 1535 jQuery.post(ajaxurl, data, function (response) {
1621 1536 response = jQuery.trim(response);
1622 1537
1623 1538 if (response === 'true') {
1624 - jQuery('#backups_site_toast').addClass('green')
1625 - .toast({
1626 - class: 'success',
1627 - position: 'top right',
1628 - displayTime: 9000,
1629 - message: 'A backup has been requested. Please allow some time for the backup to complete, then Refresh Available Backups.',
1630 - })
1631 - ;
1632 1539
1540 + // Show message.
1541 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
1542 + jQuery('#mainwp-api-backups-message-zone .content .message')
1543 + .html( 'A backup has been requested. Please allow some time for the backup to complete, then Refresh Available Backups.');
1544 +
1633 1545 // Stop button animation.
1634 1546 jQuery(pObj).removeClass('disabled loading');
1635 1547
1636 1548 } else {
1637 - jQueryjQuery('#backups_site_toast').addClass('red')
1638 - .toast({
1639 - class: 'error',
1640 - position: 'top right',
1641 - showIcon: 'exclamation circle',
1642 - displayTime: 9000,
1643 - message: response,
1644 - })
1645 - ;
1646 1549
1550 + // Show message.
1551 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
1552 + jQuery('#mainwp-api-backups-message-zone .content .message')
1553 + .html( response )
1554 + ;
1555 +
1647 1556 // Stop button animation.
1648 1557 jQuery(pObj).removeClass('disabled loading');
1649 1558
1650 1559 }
@@ -1651,17 +1560,18 @@
1651 1560 });
1652 1561 };
1653 1562
1654 1563 // restore Backup.
1655 -cpanel_action_restore_wptk_backup = function (pObj) {
1656 1564
1565 +let cpanel_action_restore_wptk_backup = function (pObj) {
1566 +
1657 1567 // Disable link.
1658 1568 jQuery(pObj).attr('disabled', 'true');
1659 1569
1660 - var backupName = jQuery('.mainwp_3rd_party_api_cpanel_action_restore_wptk_backup').attr('backup_name');
1661 - var websiteId = jQuery('.mainwp_3rd_party_api_cpanel_action_restore_wptk_backup').attr('website_id');
1570 + let backupName = jQuery('.mainwp_3rd_party_api_cpanel_action_restore_wptk_backup').attr('backup_name');
1571 + let websiteId = jQuery('.mainwp_3rd_party_api_cpanel_action_restore_wptk_backup').attr('website_id');
1662 1572
1663 - var data = mainwp_secure_data({
1573 + let data = mainwp_secure_data({
1664 1574 action: 'cpanel_action_restore_wptk_backup',
1665 1575 website_id: websiteId,
1666 1576 backup_api: 'cpanel',
1667 1577 backup_name: backupName,
@@ -1671,32 +1581,28 @@
1671 1581 jQuery('.mainwp_3rd_party_api_cpanel_action_restore_wptk_backup').addClass('disabled loading');
1672 1582
1673 1583 jQuery.post(ajaxurl, data, function (response) {
1674 1584 response = jQuery.trim(response);
1675 - console.log(response);
1585 +
1676 1586 if (response === 'true') {
1677 - jQuery('#backups_site_toast').addClass('green')
1678 - .toast({
1679 - class: 'success',
1680 - position: 'top right',
1681 - displayTime: 5000,
1682 - message: 'The backup restoration process has finished. Please wait a few moments and then check the site.',
1683 - })
1684 - ;
1685 1587
1588 + // Show message.
1589 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
1590 + jQuery('#mainwp-api-backups-message-zone .content .message')
1591 + .html('The backup restoration process has finished. Please wait a few moments and then check the site.')
1592 + ;
1593 +
1686 1594 // Stop button animation. ( Using class so ALL buttons are animated not just the one clicked ).
1687 1595 jQuery('.mainwp_3rd_party_api_cpanel_action_restore_wptk_backup').removeClass('disabled loading');
1688 1596
1689 1597 } else {
1690 - jQuery('#backups_site_toast').addClass('red')
1691 - .toast({
1692 - class: 'warning',
1693 - position: 'top right',
1694 - displayTime: 5000,
1695 - message: 'There was an issue while restoring your backup.',
1696 - })
1697 - ;
1698 1598
1599 + // Show message.
1600 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
1601 + jQuery('#mainwp-api-backups-message-zone .content .message')
1602 + .html('There was an issue while restoring your backup.')
1603 + ;
1604 +
1699 1605 // Stop button animation. ( Using class so ALL buttons are animated not just the one clicked ).
1700 1606 jQuery('.mainwp_3rd_party_api_cpanel_action_restore_wptk_backup').removeClass('disabled loading');
1701 1607
1702 1608 }
@@ -1703,17 +1609,17 @@
1703 1609 });
1704 1610 };
1705 1611
1706 1612 // Delete Backup.
1707 -cpanel_action_delete_wptk_backup = function (pObj) {
1613 +let cpanel_action_delete_wptk_backup = function (pObj) {
1708 1614
1709 1615 // Disable link.
1710 1616 jQuery(pObj).attr('disabled', 'true');
1711 1617
1712 - var backupName = jQuery('.mainwp_3rd_party_api_cpanel_action_delete_wptk_backup').attr('backup_name');
1713 - var websiteId = jQuery('.mainwp_3rd_party_api_cpanel_action_delete_wptk_backup').attr('website_id');
1618 + let backupName = jQuery('.mainwp_3rd_party_api_cpanel_action_delete_wptk_backup').attr('backup_name');
1619 + let websiteId = jQuery('.mainwp_3rd_party_api_cpanel_action_delete_wptk_backup').attr('website_id');
1714 1620
1715 - var data = mainwp_secure_data({
1621 + let data = mainwp_secure_data({
1716 1622 action: 'cpanel_action_delete_wptk_backup',
1717 1623 website_id: websiteId,
1718 1624 backup_api: 'cpanel',
1719 1625 backup_name: backupName,
@@ -1723,32 +1629,28 @@
1723 1629 jQuery('.mainwp_3rd_party_api_cpanel_action_delete_wptk_backup').addClass('disabled loading');
1724 1630
1725 1631 jQuery.post(ajaxurl, data, function (response) {
1726 1632 response = jQuery.trim(response);
1727 - console.log(response);
1633 +
1728 1634 if (response === 'true') {
1729 - jQuery('#backups_site_toast').addClass('green')
1730 - .toast({
1731 - class: 'success',
1732 - position: 'top right',
1733 - displayTime: 5000,
1734 - message: 'The selected backup has been deleted.',
1735 - })
1736 - ;
1737 1635
1636 + // Show message.
1637 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
1638 + jQuery('#mainwp-api-backups-message-zone .content .message')
1639 + .html('The selected backup has been deleted.')
1640 + ;
1641 +
1738 1642 // Stop button animation. ( Using class so ALL buttons are animated not just the one clicked ).
1739 1643 jQuery('.mainwp_3rd_party_api_cpanel_action_delete_wptk_backup').removeClass('disabled loading');
1740 1644
1741 1645 } else {
1742 - jQuery('#backups_site_toast').addClass('red')
1743 - .toast({
1744 - class: 'warning',
1745 - position: 'top right',
1746 - displayTime: 5000,
1747 - message: 'There was an issue while deleting your backup.',
1748 - })
1749 - ;
1750 1646
1647 + // Show message.
1648 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
1649 + jQuery('#mainwp-api-backups-message-zone .content .message')
1650 + .html('There was an issue while deleting your backup.')
1651 + ;
1652 +
1751 1653 // Stop button animation. ( Using class so ALL buttons are animated not just the one clicked ).
1752 1654 jQuery('.mainwp_3rd_party_api_cpanel_action_delete_wptk_backup').removeClass('disabled loading');
1753 1655
1754 1656 }
@@ -1755,20 +1657,20 @@
1755 1657 });
1756 1658 };
1757 1659
1758 1660 // Download Backup.
1759 -cpanel_action_download_wptk_backup = function () {
1661 +let cpanel_action_download_wptk_backup = function () {
1760 1662
1761 - var href = jQuery('.mainwp_3rd_party_api_cpanel_action_download_wptk_backup').attr('href');
1663 + let href = jQuery('.mainwp_3rd_party_api_cpanel_action_download_wptk_backup').attr('href');
1762 1664 window.open(href, '_blank');
1763 1665
1764 1666 };
1765 1667
1766 -cpanel_action_create_backup = function (pObj) {
1668 +let cpanel_action_create_backup = function (pObj) {
1767 1669
1768 - var websiteId = jQuery(pObj).attr('website_id');
1670 + let websiteId = jQuery(pObj).attr('website_id');
1769 1671
1770 - var data = mainwp_secure_data({
1672 + let data = mainwp_secure_data({
1771 1673 action: 'cpanel_action_create_manual_backup',
1772 1674 website_id: websiteId,
1773 1675 backup_api: 'cpanel'
1774 1676 });
@@ -1777,32 +1679,28 @@
1777 1679 jQuery(pObj).addClass('disabled loading');
1778 1680
1779 1681 jQuery.post(ajaxurl, data, function (response) {
1780 1682 response = jQuery.trim(response);
1781 - console.log(response);
1683 +
1782 1684 if (response === 'true') {
1783 - jQuery('#backups_site_toast').addClass('green')
1784 - .toast({
1785 - class: 'success',
1786 - position: 'top right',
1787 - displayTime: 9000,
1788 - message: 'A backup has been requested.',
1789 - })
1790 - ;
1791 1685
1686 + // Show message.
1687 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
1688 + jQuery('#mainwp-api-backups-message-zone .content .message')
1689 + .html('A backup has been requested.')
1690 + ;
1691 +
1792 1692 // Stop button animation.
1793 1693 jQuery(pObj).removeClass('disabled loading');
1794 1694
1795 1695 } else {
1796 - jQuery.toast({
1797 - class: 'error',
1798 - position: 'top right',
1799 - showIcon: 'exclamation circle',
1800 - displayTime: 9000,
1801 - message: response,
1802 - })
1803 - ;
1804 1696
1697 + // Show message.
1698 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
1699 + jQuery('#mainwp-api-backups-message-zone .content .message')
1700 + .html( response )
1701 + ;
1702 +
1805 1703 // Stop button animation.
1806 1704 jQuery(pObj).removeClass('disabled loading');
1807 1705
1808 1706 }
@@ -1809,13 +1707,13 @@
1809 1707 });
1810 1708 };
1811 1709
1812 1710 // Refresh Available Backups.
1813 -cpanel_action_refresh_available_backups = function (pObj) {
1711 +let cpanel_action_refresh_available_backups = function (pObj) {
1814 1712
1815 - var websiteId = jQuery(pObj).attr('website_id');
1713 + let websiteId = jQuery(pObj).attr('website_id');
1816 1714
1817 - var data = mainwp_secure_data({
1715 + let data = mainwp_secure_data({
1818 1716 action: 'cpanel_action_refresh_available_backups',
1819 1717 website_id: websiteId,
1820 1718 backup_api: 'cPanel'
1821 1719 });
@@ -1826,17 +1724,15 @@
1826 1724 jQuery.post(ajaxurl, data, function (response) {
1827 1725 response = jQuery.trim(response);
1828 1726
1829 1727 if (response === 'true') {
1830 - jQuery('#backups_site_toast').addClass('green')
1831 - .toast({
1832 - class: 'success',
1833 - position: 'top right',
1834 - displayTime: 5000,
1835 - message: 'Available backups have been refreshed.',
1836 - })
1837 - ;
1838 1728
1729 + // Show message.
1730 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
1731 + jQuery('#mainwp-api-backups-message-zone .content .message')
1732 + .html('Available backups have been refreshed.')
1733 + ;
1734 +
1839 1735 // Stop button animation.
1840 1736 jQuery(pObj).removeClass('disabled loading');
1841 1737
1842 1738 setInterval('location.reload()', 7000); // Using .reload() method.
@@ -1841,17 +1737,15 @@
1841 1737
1842 1738 setInterval('location.reload()', 7000); // Using .reload() method.
1843 1739
1844 1740 } else {
1845 - jQuery('#backups_site_toast').addClass('red')
1846 - .toast({
1847 - class: 'warning',
1848 - position: 'top right',
1849 - displayTime: 5000,
1850 - message: 'There was an issue while refreshing available backups.',
1851 - })
1852 - ;
1853 1741
1742 + // Show message.
1743 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
1744 + jQuery('#mainwp-api-backups-message-zone .content .message')
1745 + .html('There was an issue while refreshing available backups.')
1746 + ;
1747 +
1854 1748 // Stop button animation.
1855 1749 jQuery(pObj).removeClass('disabled loading');
1856 1750
1857 1751 }
@@ -1858,18 +1752,18 @@
1858 1752 });
1859 1753 };
1860 1754
1861 1755 // restore Backup.
1862 -cPanel_action_restore_backup = function (pObj) {
1756 +let cPanel_action_restore_backup = function (pObj) {
1863 1757
1864 1758 // Disable link.
1865 1759 jQuery(pObj).attr('disabled', 'true');
1866 1760
1867 - var websiteId = jQuery('#cpanel_automatic_backup_button').attr('website_id');
1868 - var backupID = jQuery('#cpanel_automatic_backup_button').attr('backup_name');
1869 - var backupPath = jQuery('#cpanel_automatic_backup_button').attr('backup_path');
1761 + let websiteId = jQuery('#cpanel_automatic_backup_button').attr('website_id');
1762 + let backupID = jQuery('#cpanel_automatic_backup_button').attr('backup_name');
1763 + let backupPath = jQuery('#cpanel_automatic_backup_button').attr('backup_path');
1870 1764
1871 - var data = mainwp_secure_data({
1765 + let data = mainwp_secure_data({
1872 1766 action: 'cpanel_action_restore_backup',
1873 1767 website_id: websiteId,
1874 1768 backup_api: 'cpanel',
1875 1769 backup_id: backupID,
@@ -1880,32 +1774,28 @@
1880 1774 jQuery('.mainwp_3rd_party_api_cpanel_action_restore_backup button').addClass('disabled loading');
1881 1775
1882 1776 jQuery.post(ajaxurl, data, function (response) {
1883 1777 response = jQuery.trim(response);
1884 - console.log(response);
1778 +
1885 1779 if (response === 'true') {
1886 - jQuery('#backups_site_toast').addClass('green')
1887 - .toast({
1888 - class: 'success',
1889 - position: 'top right',
1890 - displayTime: 5000,
1891 - message: 'The backup restoration process has finished. Please wait a few moments and then check the site.',
1892 - })
1893 - ;
1894 1780
1781 + // Show message.
1782 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
1783 + jQuery('#mainwp-api-backups-message-zone .content .message')
1784 + .html('The backup restoration process has finished. Please wait a few moments and then check the site.')
1785 + ;
1786 +
1895 1787 // Stop button animation. ( Using class so ALL buttons are animated not just the one clicked ).
1896 1788 jQuery('.mainwp_3rd_party_api_cpanel_action_restore_backup button').removeClass('disabled loading');
1897 1789
1898 1790 } else {
1899 - jQuery('#backups_site_toast').addClass('red')
1900 - .toast({
1901 - class: 'warning',
1902 - position: 'top right',
1903 - displayTime: 5000,
1904 - message: 'There was an issue while restoring your backup.',
1905 - })
1906 - ;
1907 1791
1792 + // Show message.
1793 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
1794 + jQuery('#mainwp-api-backups-message-zone .content .message')
1795 + .html('There was an issue while restoring your backup.')
1796 + ;
1797 +
1908 1798 // Stop button animation. ( Using class so ALL buttons are animated not just the one clicked ).
1909 1799 jQuery('.mainwp_3rd_party_api_cpanel_action_restore_backup button').removeClass('disabled loading');
1910 1800
1911 1801 }
@@ -1912,15 +1802,15 @@
1912 1802 });
1913 1803 };
1914 1804
1915 1805 // restore Backup.
1916 -cpanel_action_restore_database_backup = function (btObj) {
1806 +let cpanel_action_restore_database_backup = function (btObj) {
1917 1807
1918 - var websiteId = jQuery(btObj).attr('website_id');
1919 - var backupID = jQuery(btObj).attr('backup_name');
1920 - var backupPath = jQuery(btObj).attr('backup_path');
1808 + let websiteId = jQuery(btObj).attr('website_id');
1809 + let backupID = jQuery(btObj).attr('backup_name');
1810 + let backupPath = jQuery(btObj).attr('backup_path');
1921 1811
1922 - var data = mainwp_secure_data({
1812 + let data = mainwp_secure_data({
1923 1813 action: 'cpanel_action_restore_database_backup',
1924 1814 website_id: websiteId,
1925 1815 backup_api: 'cpanel',
1926 1816 backup_id: backupID,
@@ -1933,30 +1823,26 @@
1933 1823 jQuery.post(ajaxurl, data, function (response) {
1934 1824 response = jQuery.trim(response);
1935 1825
1936 1826 if (response === 'true') {
1937 - jQuery('#backups_site_toast').addClass('green')
1938 - .toast({
1939 - class: 'success',
1940 - position: 'top right',
1941 - displayTime: 5000,
1942 - message: 'The backup restoration process has finished. Please wait a few moments and then check the site.',
1943 - })
1944 - ;
1945 1827
1828 + // Show message.
1829 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
1830 + jQuery('#mainwp-api-backups-message-zone .content .message')
1831 + .html('The backup restoration process has finished. Please wait a few moments and then check the site.')
1832 + ;
1833 +
1946 1834 // Stop button animation. ( Using class so ALL buttons are animated not just the one clicked ).
1947 1835 jQuery('.mainwp_3rd_party_api_cpanel_action_restore_database_backup button').removeClass('disabled loading');
1948 1836
1949 1837 } else {
1950 - jQuery('#backups_site_toast').addClass('red')
1951 - .toast({
1952 - class: 'warning',
1953 - position: 'top right',
1954 - displayTime: 5000,
1955 - message: 'There was an issue while restoring your backup.',
1956 - })
1957 - ;
1958 1838
1839 + // Show message.
1840 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
1841 + jQuery('#mainwp-api-backups-message-zone .content .message')
1842 + .html('There was an issue while restoring your backup.')
1843 + ;
1844 +
1959 1845 // Stop button animation. ( Using class so ALL buttons are animated not just the one clicked ).
1960 1846 jQuery('.mainwp_3rd_party_api_cpanel_action_restore_database_backup button').removeClass('disabled loading');
1961 1847
1962 1848 }
@@ -1963,15 +1849,15 @@
1963 1849 });
1964 1850 };
1965 1851
1966 1852 // restore Backup.
1967 -cpanel_action_restore_manual_backup = function () {
1853 +let cpanel_action_restore_manual_backup = function () {
1968 1854
1969 - var websiteId = jQuery('#cpanel_automatic_backup_button').attr('website_id');
1970 - var backupID = jQuery('#database_backup_button').attr('backup_name');
1971 - var backupPath = jQuery('#database_backup_button').attr('backup_path');
1855 + let websiteId = jQuery('#cpanel_automatic_backup_button').attr('website_id');
1856 + let backupID = jQuery('#database_backup_button').attr('backup_name');
1857 + let backupPath = jQuery('#database_backup_button').attr('backup_path');
1972 1858
1973 - var data = mainwp_secure_data({
1859 + let data = mainwp_secure_data({
1974 1860 action: 'cpanel_action_restore_manual_backup',
1975 1861 website_id: websiteId,
1976 1862 backup_api: 'cpanel',
1977 1863 backup_id: backupID,
@@ -1984,30 +1870,26 @@
1984 1870 jQuery.post(ajaxurl, data, function (response) {
1985 1871 response = jQuery.trim(response);
1986 1872
1987 1873 if (response === 'true') {
1988 - jQuery('#backups_site_toast').addClass('green')
1989 - .toast({
1990 - class: 'success',
1991 - position: 'top right',
1992 - displayTime: 5000,
1993 - message: 'The backup restoration process has finished. Please wait a few moments and then check the site.',
1994 - })
1995 - ;
1996 1874
1875 + // Show message.
1876 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
1877 + jQuery('#mainwp-api-backups-message-zone .content .message')
1878 + .html('The backup restoration process has finished. Please wait a few moments and then check the site.')
1879 + ;
1880 +
1997 1881 // Stop button animation. ( Using class so ALL buttons are animated not just the one clicked ).
1998 1882 jQuery('.mainwp_3rd_party_api_cpanel_action_restore_manual_backup button').removeClass('disabled loading');
1999 1883
2000 1884 } else {
2001 - jQuery('#backups_site_toast').addClass('red')
2002 - .toast({
2003 - class: 'warning',
2004 - position: 'top right',
2005 - displayTime: 5000,
2006 - message: 'There was an issue while restoring your backup.',
2007 - })
2008 - ;
2009 1885
1886 + // Show message.
1887 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
1888 + jQuery('#mainwp-api-backups-message-zone .content .message')
1889 + .html('There was an issue while restoring your backup.')
1890 + ;
1891 +
2010 1892 // Stop button animation. ( Using class so ALL buttons are animated not just the one clicked ).
2011 1893 jQuery('.mainwp_3rd_party_api_cpanel_action_restore_database_backup button').removeClass('disabled loading');
2012 1894
2013 1895 }
@@ -2013,15 +1895,15 @@
2013 1895 }
2014 1896 });
2015 1897 };
2016 1898
2017 -cpanel_action_create_database_backup = function (pObj) {
1899 +let cpanel_action_create_database_backup = function (pObj) {
2018 1900
2019 1901 // Grab the website ID.
2020 - var websiteId = jQuery(pObj).attr('website_id');
1902 + let websiteId = jQuery(pObj).attr('website_id');
2021 1903
2022 1904 // Build the data object.
2023 - var data = mainwp_secure_data({
1905 + let data = mainwp_secure_data({
2024 1906 action: 'cpanel_action_create_database_backup',
2025 1907 website_id: websiteId,
2026 1908 });
2027 1909
@@ -2033,30 +1915,26 @@
2033 1915 response = jQuery.trim(response);
2034 1916
2035 1917 // Check & return the response.
2036 1918 if (response === 'true') {
2037 - jQuery('#backups_site_toast').addClass('green')
2038 - .toast({
2039 - class: 'success',
2040 - position: 'top right',
2041 - displayTime: 5000,
2042 - message: 'The current database backup has finished. Please wait a few moments and then Refresh Available Backups.',
2043 - })
2044 - ;
2045 1919
1920 + // Show message.
1921 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
1922 + jQuery('#mainwp-api-backups-message-zone .content .message')
1923 + .html('The current database backup has finished. Please wait a few moments and then Refresh Available Backups.')
1924 + ;
1925 +
2046 1926 // Start button animation.
2047 1927 jQuery(pObj).removeClass('disabled loading');
2048 1928
2049 1929 } else {
2050 - jQuery('#backups_site_toast').addClass('red')
2051 - .toast({
2052 - class: 'warning',
2053 - position: 'top right',
2054 - displayTime: 5000,
2055 - message: 'There was an issue while creating your backup.',
2056 - })
2057 - ;
2058 1930
1931 + // Show message.
1932 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
1933 + jQuery('#mainwp-api-backups-message-zone .content .message')
1934 + .html('There was an issue while creating your backup.')
1935 + ;
1936 +
2059 1937 // Start button animation.
2060 1938 jQuery(pObj).removeClass('disabled loading');
2061 1939
2062 1940 }
@@ -2062,21 +1940,22 @@
2062 1940 }
2063 1941 });
2064 1942 }
2065 1943
2066 -cpanel_action_create_full_backup = function (pObj) {
1944 +let cpanel_action_create_full_backup = function (pObj) {
2067 1945
2068 1946 // Grab the website ID.
2069 - var websiteId = jQuery(pObj).attr('website_id');
1947 + let websiteId = jQuery(pObj).attr('website_id');
2070 1948
2071 1949 // Build the data object.
2072 - var data = mainwp_secure_data({
1950 + let data = mainwp_secure_data({
2073 1951 action: 'cpanel_action_create_full_backup',
2074 1952 website_id: websiteId,
2075 - backup_api: 'cpanel'
1953 + backup_api: 'cpanel',
1954 + backup: 'true'
2076 1955 });
2077 - console.log(data);
2078 1956
1957 +
2079 1958 // Start button animation.
2080 1959 jQuery(pObj).addClass('disabled loading');
2081 1960
2082 1961 // Send the data to the server.
@@ -2084,30 +1963,26 @@
2084 1963 response = jQuery.trim(response);
2085 1964
2086 1965 // Check & return the response.
2087 1966 if (response === 'true') {
2088 - jQuery('#backups_site_toast').addClass('green')
2089 - .toast({
2090 - class: 'success',
2091 - position: 'top right',
2092 - displayTime: 5000,
2093 - message: 'The current File & Database backup has finished. Please wait a few moments and then Refresh Available Backups.',
2094 - })
2095 - ;
2096 1967
1968 + // Show message.
1969 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
1970 + jQuery('#mainwp-api-backups-message-zone .content .message')
1971 + .html('The current File & Database backup has finished. Please wait a few moments and then Refresh Available Backups.')
1972 + ;
1973 +
2097 1974 // Start button animation.
2098 1975 jQuery(pObj).removeClass('disabled loading');
2099 1976
2100 1977 } else {
2101 - jQuery('#backups_site_toast').addClass('red')
2102 - .toast({
2103 - class: 'warning',
2104 - position: 'top right',
2105 - displayTime: 5000,
2106 - message: 'There was an issue while creating your backups.',
2107 - })
2108 - ;
2109 1978
1979 + // Show message.
1980 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
1981 + jQuery('#mainwp-api-backups-message-zone .content .message')
1982 + .html('There was an issue while creating your backups.')
1983 + ;
1984 +
2110 1985 // Start button animation.
2111 1986 jQuery(pObj).removeClass('disabled loading');
2112 1987
2113 1988 }
@@ -2118,13 +1993,13 @@
2118 1993 * Plesk Functions.
2119 1994 */
2120 1995
2121 1996 // Refresh Available Backups.
2122 -plesk_action_refresh_available_backups = function (pObj) {
1997 +let plesk_action_refresh_available_backups = function (pObj) {
2123 1998
2124 - var websiteId = jQuery(pObj).attr('website_id');
1999 + let websiteId = jQuery(pObj).attr('website_id');
2125 2000
2126 - var data = mainwp_secure_data({
2001 + let data = mainwp_secure_data({
2127 2002 action: 'plesk_action_refresh_available_backups',
2128 2003 website_id: websiteId,
2129 2004 backup_api: 'Plesk'
2130 2005 });
@@ -2135,17 +2010,15 @@
2135 2010 jQuery.post(ajaxurl, data, function (response) {
2136 2011 response = jQuery.trim(response);
2137 2012
2138 2013 if (response === 'true') {
2139 - jQuery('#backups_site_toast').addClass('green')
2140 - .toast({
2141 - class: 'success',
2142 - position: 'top right',
2143 - displayTime: 5000,
2144 - message: 'Available backups have been refreshed.',
2145 - })
2146 - ;
2147 2014
2015 + // Show message.
2016 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
2017 + jQuery('#mainwp-api-backups-message-zone .content .message')
2018 + .html('Available backups have been refreshed.')
2019 + ;
2020 +
2148 2021 // Stop button animation.
2149 2022 jQuery(pObj).removeClass('disabled loading');
2150 2023
2151 2024 setInterval('location.reload()', 7000);// Using .reload() method.
@@ -2150,17 +2023,15 @@
2150 2023
2151 2024 setInterval('location.reload()', 7000);// Using .reload() method.
2152 2025
2153 2026 } else {
2154 - jQuery('#backups_site_toast').addClass('red')
2155 - .toast({
2156 - class: 'warning',
2157 - position: 'top right',
2158 - displayTime: 5000,
2159 - message: 'There was an issue while refreshing available backups.',
2160 - })
2161 - ;
2162 2027
2028 + // Show message.
2029 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
2030 + jQuery('#mainwp-api-backups-message-zone .content .message')
2031 + .html('There was an issue while refreshing available backups.')
2032 + ;
2033 +
2163 2034 // Stop button animation.
2164 2035 jQuery(pObj).removeClass('disabled loading');
2165 2036
2166 2037 }
@@ -2166,13 +2037,13 @@
2166 2037 }
2167 2038 });
2168 2039 };
2169 2040
2170 -plesk_action_create_backup = function (pObj) {
2041 +let plesk_action_create_backup = function (pObj) {
2171 2042
2172 - var websiteId = jQuery(pObj).attr('website_id');
2043 + let websiteId = jQuery(pObj).attr('website_id');
2173 2044
2174 - var data = mainwp_secure_data({
2045 + let data = mainwp_secure_data({
2175 2046 action: 'plesk_action_create_backup',
2176 2047 website_id: websiteId,
2177 2048 backup_api: 'plesk'
2178 2049 });
@@ -2181,33 +2052,28 @@
2181 2052 jQuery(pObj).addClass('disabled loading');
2182 2053
2183 2054 jQuery.post(ajaxurl, data, function (response) {
2184 2055 response = jQuery.trim(response);
2185 - console.log(response);
2056 +
2186 2057 if (response === 'true') {
2187 - jQuery('#backups_site_toast').addClass('green')
2188 - .toast({
2189 - class: 'success',
2190 - position: 'top right',
2191 - displayTime: 9000,
2192 - message: 'A backup has been requested.',
2193 - })
2194 - ;
2195 2058
2059 + // Show message.
2060 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
2061 + jQuery('#mainwp-api-backups-message-zone .content .message')
2062 + .html('A backup has been requested.')
2063 + ;
2064 +
2196 2065 // Stop button animation.
2197 2066 jQuery(pObj).removeClass('disabled loading');
2198 2067
2199 2068 } else {
2200 - jQuery('#backups_site_toast').addClass('red')
2201 - .toast({
2202 - class: 'error',
2203 - position: 'top right',
2204 - showIcon: 'exclamation circle',
2205 - displayTime: 9000,
2206 - message: response,
2207 - })
2208 - ;
2209 2069
2070 + // Show message.
2071 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
2072 + jQuery('#mainwp-api-backups-message-zone .content .message')
2073 + .html( response )
2074 + ;
2075 +
2210 2076 // Stop button animation.
2211 2077 jQuery(pObj).removeClass('disabled loading');
2212 2078
2213 2079 }
@@ -2214,18 +2080,15 @@
2214 2080 });
2215 2081 };
2216 2082
2217 2083 // Restore backups.
2218 -plesk_action_restore_backup = function () {
2084 +let plesk_action_restore_backup = function () {
2085 + let button = jQuery('.mainwp_3rd_party_api_plesk_action_restore_backup').closest('td');
2086 + let installationId = jQuery('.mainwp_3rd_party_api_plesk_action_restore_backup').attr('installation_id');
2087 + let backupName = jQuery('.mainwp_3rd_party_api_plesk_action_restore_backup').attr('backup_name');
2088 + let websiteId = jQuery('.mainwp_3rd_party_api_plesk_action_restore_backup').attr('website_id');
2219 2089
2220 - //jQuery('.mainwp_3rd_party_api_plesk_action_restore_backup').attr('disabled', 'true');
2221 - var button = jQuery('.mainwp_3rd_party_api_plesk_action_restore_backup').closest('td');
2222 -
2223 - var installationId = jQuery('.mainwp_3rd_party_api_plesk_action_restore_backup').attr('installation_id');
2224 - var backupName = jQuery('.mainwp_3rd_party_api_plesk_action_restore_backup').attr('backup_name');
2225 - var websiteId = jQuery('.mainwp_3rd_party_api_plesk_action_restore_backup').attr('website_id');
2226 -
2227 - var data = mainwp_secure_data({
2090 + let data = mainwp_secure_data({
2228 2091 action: 'plesk_action_restore_backup',
2229 2092 installation_id: installationId,
2230 2093 backup_name: backupName,
2231 2094 website_id: websiteId,
@@ -2238,30 +2101,26 @@
2238 2101 jQuery.post(ajaxurl, data, function (response) {
2239 2102 response = jQuery.trim(response);
2240 2103
2241 2104 if (response === 'true') {
2242 - jQuery('#backups_site_toast').addClass('green')
2243 - .toast({
2244 - class: 'success',
2245 - position: 'top right',
2246 - displayTime: 5000,
2247 - message: 'Your application is in the process of restoring. This will take a few minuets...',
2248 - })
2249 - ;
2250 2105
2106 + // Show message.
2107 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
2108 + jQuery('#mainwp-api-backups-message-zone .content .message')
2109 + .html('Your application is in the process of restoring. This will take a few minuets...')
2110 + ;
2111 +
2251 2112 // Stop button animation.
2252 2113 jQuery(button).removeClass('disabled loading');
2253 2114
2254 2115 } else {
2255 - jQuery('#backups_site_toast').addClass('red')
2256 - .toast({
2257 - class: 'warning',
2258 - position: 'top right',
2259 - displayTime: 5000,
2260 - message: 'There was an issue while attempting to restore your application...',
2261 - })
2262 - ;
2263 2116
2117 + // Show message.
2118 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
2119 + jQuery('#mainwp-api-backups-message-zone .content .message')
2120 + .html('There was an issue while attempting to restore your application...')
2121 + ;
2122 +
2264 2123 // Stop button animation.
2265 2124 jQuery(button).removeClass('disabled loading');
2266 2125 }
2267 2126 });
@@ -2267,17 +2126,17 @@
2267 2126 });
2268 2127 };
2269 2128
2270 2129 // Delete backups.
2271 -plesk_action_delete_backup = function () {
2130 +let plesk_action_delete_backup = function () {
2272 2131 jQuery('.mainwp_3rd_party_api_plesk_action_delete_backup').attr('disabled', 'true');
2273 - var button = jQuery('.mainwp_3rd_party_api_plesk_action_delete_backup').closest('td');
2132 + let button = jQuery('.mainwp_3rd_party_api_plesk_action_delete_backup').closest('td');
2274 2133
2275 - var installationId = jQuery('.mainwp_3rd_party_api_plesk_action_delete_backup').attr('installation_id');
2276 - var backupName = jQuery('.mainwp_3rd_party_api_plesk_action_delete_backup').attr('backup_name');
2277 - var websiteId = jQuery('.mainwp_3rd_party_api_plesk_action_delete_backup').attr('website_id');
2134 + let installationId = jQuery('.mainwp_3rd_party_api_plesk_action_delete_backup').attr('installation_id');
2135 + let backupName = jQuery('.mainwp_3rd_party_api_plesk_action_delete_backup').attr('backup_name');
2136 + let websiteId = jQuery('.mainwp_3rd_party_api_plesk_action_delete_backup').attr('website_id');
2278 2137
2279 - var data = mainwp_secure_data({
2138 + let data = mainwp_secure_data({
2280 2139 action: 'plesk_action_delete_backup',
2281 2140 installation_id: installationId,
2282 2141 backup_name: backupName,
2283 2142 website_id: websiteId,
@@ -2291,36 +2150,199 @@
2291 2150 jQuery.post(ajaxurl, data, function (response) {
2292 2151 response = jQuery.trim(response);
2293 2152
2294 2153 if (response === 'true') {
2295 - jQuery('#backups_site_toast').addClass('green')
2296 - .toast({
2297 - class: 'success',
2298 - position: 'top right',
2299 - displayTime: 5000,
2300 - message: 'The selected backup has been deleted.',
2301 - })
2302 - ;
2303 2154
2304 - // Stop button animation.
2305 - jQuery(button).find('i.loading').css({ 'display': 'none' });
2306 - jQuery(button).find('div').removeClass('hidden');
2155 + // Show message.
2156 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
2157 + jQuery('#mainwp-api-backups-message-zone .content .message')
2158 + .html('The selected backup has been deleted.')
2159 + ;
2307 2160
2161 + setInterval('location.reload()', 5000); // Using .reload() method.
2162 +
2308 2163 } else {
2309 - jQuery('#backups_site_toast').addClass('red')
2310 - .toast({
2311 - class: 'warning',
2312 - position: 'top right',
2313 - displayTime: 5000,
2314 - message: 'There was an issue while deleting your backup.',
2315 - })
2316 - ;
2317 2164
2318 - // Stop button animation.
2319 - jQuery(button).find('i.loading').css({ 'display': 'none' });
2320 - jQuery(button).find('div').removeClass('hidden');
2165 + // Show message.
2166 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
2167 + jQuery('#mainwp-api-backups-message-zone .content .message')
2168 + .html('There was an issue while deleting your backup.')
2169 + ;
2321 2170
2171 + setInterval('location.reload()', 5000); // Using .reload() method.
2172 +
2322 2173 }
2323 2174 });
2324 2175 };
2325 2176
2177 +/********************************************************
2178 + * Kinsta Functions.
2179 + */
2326 2180
2181 +// Refresh Available Backups.
2182 +let kinsta_action_refresh_available_backups = function (pObj) {
2183 +
2184 + let websiteId = jQuery(pObj).attr('website_id');
2185 +
2186 + let data = mainwp_secure_data({
2187 + action: 'kinsta_action_refresh_available_backups',
2188 + website_id: websiteId,
2189 + backup_api: 'Kinsta'
2190 + });
2191 +
2192 + // Start button animation.
2193 + jQuery(pObj).addClass('disabled loading');
2194 +
2195 + jQuery.post(ajaxurl, data, function (response) {
2196 + response = jQuery.trim(response);
2197 +
2198 + if (response === 'true') {
2199 +
2200 + // Show message.
2201 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
2202 + jQuery('#mainwp-api-backups-message-zone .content .message')
2203 + .html('Available backups have been refreshed.')
2204 + ;
2205 +
2206 + // Stop button animation.
2207 + jQuery(pObj).removeClass('disabled loading');
2208 +
2209 + setInterval('location.reload()', 7000);// Using .reload() method.
2210 +
2211 + } else {
2212 +
2213 + // Show message.
2214 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
2215 + jQuery('#mainwp-api-backups-message-zone .content .message')
2216 + .html('There was an issue while refreshing available backups.')
2217 + ;
2218 +
2219 + // Stop button animation.
2220 + jQuery(pObj).removeClass('disabled loading');
2221 +
2222 + }
2223 + });
2224 +};
2225 +
2226 +// Create Manual Backup.
2227 +let kinsta_action_create_backup = function (pObj) {
2228 +
2229 + let websiteId = jQuery(pObj).attr('website_id');
2230 +
2231 + let data = mainwp_secure_data({
2232 + action: 'kinsta_action_create_backup',
2233 + website_id: websiteId,
2234 + backup_api: 'kinsta'
2235 + });
2236 +
2237 + // Start button animation.
2238 + jQuery(pObj).addClass('disabled loading');
2239 +
2240 + jQuery.post(ajaxurl, data, function (response) {
2241 + response = jQuery.trim(response);
2242 +
2243 + if (response === 'true') {
2244 +
2245 + // Show message.
2246 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
2247 + jQuery('#mainwp-api-backups-message-zone .content .message')
2248 + .html('A backup has been requested.')
2249 + ;
2250 +
2251 + // Stop button animation.
2252 + jQuery(pObj).removeClass('disabled loading');
2253 +
2254 + } else {
2255 +
2256 + // Show message.
2257 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
2258 + jQuery('#mainwp-api-backups-message-zone .content .message')
2259 + .html( response )
2260 + ;
2261 +
2262 + // Stop button animation.
2263 + jQuery(pObj).removeClass('disabled loading');
2264 +
2265 + }
2266 + });
2267 +};
2268 +
2269 +// Delete Manual Backup.
2270 +let kinsta_action_delete_backup = function (pObj, backupId) {
2271 + let websiteId = jQuery('.mainwp_3rd_party_api_kinsta_action_delete_backup ').attr('website_id');
2272 + let data = mainwp_secure_data({
2273 + action: 'kinsta_action_delete_backup',
2274 + backup_id: backupId,
2275 + website_id: websiteId,
2276 + backup_api: 'kinsta'
2277 + });
2278 +
2279 + // Start button animation.
2280 + jQuery(pObj).addClass('disabled loading');
2281 +
2282 + jQuery.post(ajaxurl, data, function (response) {
2283 + response = jQuery.trim(response);
2284 + if (response === 'true') {
2285 +
2286 + // Show message.
2287 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
2288 + jQuery('#mainwp-api-backups-message-zone .content .message')
2289 + .html('The selected backup has been deleted.')
2290 + ;
2291 +
2292 + setInterval('location.reload()', 5000); // Using .reload() method.
2293 +
2294 + } else {
2295 +
2296 + // Show message.
2297 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
2298 + jQuery('#mainwp-api-backups-message-zone .content .message')
2299 + .html('There was an issue while deleting your backup.')
2300 + ;
2301 +
2302 + setInterval('location.reload()', 5000); // Using .reload() method.
2303 +
2304 + }
2305 + });
2306 +};
2307 +
2308 +// Delete Manual Backup.
2309 +let kinsta_action_restore_backup = function (pObj, backupId) {
2310 +
2311 + let websiteId = jQuery('.mainwp_3rd_party_api_kinsta_action_restore_backup').attr('website_id');
2312 +
2313 + let data = mainwp_secure_data({
2314 + action: 'kinsta_action_restore_backup',
2315 + backup_id: backupId,
2316 + backup_api: 'kinsta',
2317 + website_id: websiteId
2318 + });
2319 +
2320 + // Start button animation.
2321 + jQuery(pObj).addClass('disabled loading');
2322 +
2323 + jQuery.post(ajaxurl, data, function (response) {
2324 + response = jQuery.trim(response);
2325 + if (response === 'true') {
2326 +
2327 + // Show message.
2328 + jQuery('#mainwp-api-backups-message-zone').addClass('green').show();
2329 + jQuery('#mainwp-api-backups-message-zone .content .message')
2330 + .html('Your application is in the process of restoring. This will take a few minuets...')
2331 + ;
2332 +
2333 + // Stop button animation.
2334 + jQuery(button).removeClass('disabled loading');
2335 +
2336 + } else {
2337 +
2338 + // Show message.
2339 + jQuery('#mainwp-api-backups-message-zone').addClass('red').show();
2340 + jQuery('#mainwp-api-backups-message-zone .content .message')
2341 + .html('There was an issue while attempting to restore your application...')
2342 + ;
2343 +
2344 + // Stop button animation.
2345 + jQuery(button).removeClass('disabled loading');
2346 + }
2347 + });
2348 +};