PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 5.2.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v5.2.1
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 5.2 5.2.1 All 155 releases
mainwp / pages / page-mainwp-manage-backups.php

page-mainwp-manage-backups.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies 5.2.1, at pages/page-mainwp-manage-backups.php

1,190 lines 58.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * MainWP Legacy Backups Page.
4 *
5 * @package MainWP/Dashboard
6 */
7
8 namespace MainWP\Dashboard;
9
10 /**
11 * Class MainWP_Manage_Backups
12 *
13 * @package MainWP\Dashboard
14 */
15 class MainWP_Manage_Backups { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR.
16
17 /**
18 * Get Class Name.
19 *
20 * @return string __CLASS__
21 */
22 public static function get_class_name() {
23 return __CLASS__;
24 }
25
26 /**
27 * Subpages variable.
28 *
29 * @var undefined $subPages Subpages variable.
30 */
31 public static $subPages;
32
33 /**
34 * Whether or not to show the Backups Submenu.
35 *
36 * @var boolean $hideSubmenuBackups true|false,
37 * .
38 */
39 private static $hideSubmenuBackups = false;
40
41 /**
42 * Instance variable.
43 *
44 * @var null Instance variable.
45 */
46 private static $instance = null;
47
48 /**
49 * Create instance.
50 *
51 * @return self $instance.
52 *
53 * @uses \MainWP\Dashboard\MainWP_Manage_Backups
54 */
55 public static function instance() {
56 if ( null === static::$instance ) {
57 static::$instance = new MainWP_Manage_Backups();
58 }
59
60 return static::$instance;
61 }
62
63 /** Instantiate Hooks. */
64 public static function init() {
65 /**
66 * This hook allows you to render the Backups page header via the 'mainwp-pageheader-backups' action.
67 *
68 * @link http://codex.mainwp.com/#mainwp-pageheader-backups
69 *
70 * This hook is normally used in the same context of 'mainwp-getsubpages-backups'
71 * @link http://codex.mainwp.com/#mainwp-getsubpages-backups
72 *
73 * @see \MainWP_Manage_Backups::render_header
74 */
75 add_action( 'mainwp-pageheader-backups', array( static::get_class_name(), 'render_header' ) );
76
77 /**
78 * This hook allows you to render the Backups page footer via the 'mainwp-pagefooter-backups' action.
79 *
80 * @link http://codex.mainwp.com/#mainwp-pagefooter-backups
81 *
82 * This hook is normally used in the same context of 'mainwp-getsubpages-backups'
83 * @link http://codex.mainwp.com/#mainwp-getsubpages-backups
84 *
85 * @see \MainWP_Manage_Backups::render_footer
86 */
87 add_action( 'mainwp-pagefooter-backups', array( static::get_class_name(), 'render_footer' ) );
88 }
89
90 /**
91 * Instantiate Legacy Backups Menu.
92 *
93 * @return void
94 *
95 * @uses \MainWP\Dashboard\MainWP_Menu::add_left_menu()
96 * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item()
97 */
98 public static function init_menu() { //phpcs:ignore -- NOSONAR - complex.
99 $enable_legacy_backup = get_option( 'mainwp_enableLegacyBackupFeature' );
100 $mainwp_primaryBackup = get_option( 'mainwp_primaryBackup' );
101
102 /**
103 * Backups Subpages
104 *
105 * Filters subpages for the Backups page.
106 *
107 * @since Unknown
108 */
109 $customPage = apply_filters_deprecated( 'mainwp-getcustompage-backups', array( false ), '4.0.7.2', 'mainwp_getcustompage_backups' ); // @deprecated Use 'mainwp_getcustompage_backups' instead. NOSONAR - not IP.
110 $customPage = apply_filters( 'mainwp_getcustompage_backups', $customPage );
111
112 if ( is_array( $customPage ) && isset( $customPage['slug'] ) && ! empty( $mainwp_primaryBackup ) ) {
113 static::$hideSubmenuBackups = true;
114 add_submenu_page( 'mainwp_tab', $customPage['title'], '<span id="mainwp-Backups">' . $customPage['title'] . '</span>', 'read', 'ManageBackups' . $customPage['slug'], $customPage['callback'] );
115 MainWP_Menu::add_left_menu(
116 array(
117 'title' => $customPage['title'],
118 'parent_key' => 'mainwp_tab',
119 'slug' => 'ManageBackups' . $customPage['slug'],
120 'href' => 'admin.php?page=ManageBackups' . $customPage['slug'],
121 'icon' => '<i class="hdd outline icon"></i>',
122 ),
123 1
124 );
125
126 } elseif ( $enable_legacy_backup ) {
127 add_submenu_page( 'mainwp_tab', esc_html__( 'Backups', 'mainwp' ), '<span id="mainwp-Backups">' . esc_html__( 'Backups', 'mainwp' ) . '</span>', 'read', 'ManageBackups', array( static::get_class_name(), 'render_manager' ) );
128 if ( mainwp_current_user_have_right( 'dashboard', 'add_backup_tasks' ) ) {
129 if ( ! MainWP_Menu::is_disable_menu_item( 3, 'ManageBackupsAddNew' ) ) {
130 add_submenu_page( 'mainwp_tab', esc_html__( 'Add New Schedule', 'mainwp' ), '<div class="mainwp-hidden">' . esc_html__( 'Add New', 'mainwp' ) . '</div>', 'read', 'ManageBackupsAddNew', array( static::get_class_name(), 'render_new' ) );
131 }
132 }
133 } else {
134 return;
135 }
136
137 /**
138 * This hook allows you to add extra sub pages to the Backups page via the 'mainwp-getsubpages-backups' filter.
139 *
140 * @link http://codex.mainwp.com/#mainwp-getsubpages-backups
141 */
142
143 $sub_pages = array();
144 $sub_pages = apply_filters_deprecated( 'mainwp-getsubpages-backups', array( $sub_pages ), '4.0.7.2', 'mainwp_getsubpages_backups' ); // @deprecated Use 'mainwp_getsubpages_backups' instead. NOSONAR - not IP.
145 static::$subPages = apply_filters( 'mainwp_getsubpages_backups', $sub_pages );
146 if ( isset( static::$subPages ) && is_array( static::$subPages ) ) {
147 foreach ( static::$subPages as $subPage ) {
148 if ( MainWP_Menu::is_disable_menu_item( 3, 'ManageBackups' . $subPage['slug'] ) ) {
149 continue;
150 }
151 add_submenu_page( 'mainwp_tab', $subPage['title'], '<div class="mainwp-hidden">' . $subPage['title'] . '</div>', 'read', 'ManageBackups' . $subPage['slug'], $subPage['callback'] );
152 }
153 }
154 static::init_left_menu( static::$subPages, $enable_legacy_backup );
155 }
156
157 /**
158 * Instantiate legacy backups subpages.
159 *
160 * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item()
161 */
162 public static function init_subpages_menu() { //phpcs:ignore -- NOSONAR - complex.
163 if ( static::$hideSubmenuBackups && ( empty( static::$subPages ) || ! is_array( static::$subPages ) ) ) {
164 return;
165 }
166 ?>
167 <div id="menu-mainwp-Backups" class="mainwp-submenu-wrapper">
168 <div class="wp-submenu sub-open" style="">
169 <div class="mainwp_boxout">
170 <?php
171 if ( ! static::$hideSubmenuBackups ) {
172 ?>
173 <div class="mainwp_boxoutin"></div>
174 <a href="<?php echo esc_url( admin_url( 'admin.php?page=ManageBackups' ) ); ?>" class="mainwp-submenu"><?php esc_html_e( 'Manage Backups', 'mainwp' ); ?></a>
175 <?php if ( mainwp_current_user_have_right( 'dashboard', 'add_backup_tasks' ) ) { ?>
176 <?php if ( ! MainWP_Menu::is_disable_menu_item( 3, 'ManageBackupsAddNew' ) ) { ?>
177 <a href="<?php echo esc_url( admin_url( 'admin.php?page=ManageBackupsAddNew' ) ); ?>" class="mainwp-submenu"><?php esc_html_e( 'Add New', 'mainwp' ); ?></a>
178 <?php } ?>
179 <?php } ?>
180 <?php } ?>
181 <?php
182 if ( isset( static::$subPages ) && is_array( static::$subPages ) ) {
183 foreach ( static::$subPages as $subPage ) {
184 if ( MainWP_Menu::is_disable_menu_item( 3, 'ManageBackups' . $subPage['slug'] ) ) {
185 continue;
186 }
187 ?>
188 <a href="<?php echo esc_url( admin_url( 'admin.php?page=ManageBackups' . $subPage['slug'] ) ); ?>" class="mainwp-submenu"><?php echo esc_html( $subPage['title'] ); ?></a>
189 <?php
190 }
191 }
192 ?>
193 </div>
194 </div>
195 </div>
196 <?php
197 }
198
199 /**
200 * Instantiate Legacy Backups Menu.
201 *
202 * @param array $subPages Legacy Backup Subpages.
203 * @param bool $enableLegacyBackup ture|false, whether or not to enable menu.
204 *
205 * @uses \MainWP\Dashboard\MainWP_Menu::add_left_menu()
206 * @uses \MainWP\Dashboard\MainWP_Menu::init_subpages_left_menu()
207 * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item()
208 */
209 public static function init_left_menu( $subPages = array(), $enableLegacyBackup = true ) {
210 if ( ! static::$hideSubmenuBackups && $enableLegacyBackup ) {
211 MainWP_Menu::add_left_menu(
212 array(
213 'title' => esc_html__( 'Backups', 'mainwp' ),
214 'parent_key' => 'managesites',
215 'slug' => 'ManageBackups',
216 'href' => 'admin.php?page=ManageBackups',
217 'icon' => '<i class="hdd outline icon"></i>',
218 ),
219 1
220 );
221
222 $init_sub_subleftmenu = array(
223 array(
224 'title' => esc_html__( 'Manage Backups', 'mainwp' ),
225 'parent_key' => 'ManageBackups',
226 'href' => 'admin.php?page=ManageBackups',
227 'slug' => 'ManageBackups',
228 'right' => '',
229 ),
230 array(
231 'title' => esc_html__( 'Add New', 'mainwp' ),
232 'parent_key' => 'ManageBackups',
233 'href' => 'admin.php?page=ManageBackupsAddNew',
234 'slug' => 'ManageBackupsAddNew',
235 'right' => 'add_backup_tasks',
236 ),
237 );
238
239 MainWP_Menu::init_subpages_left_menu( $subPages, $init_sub_subleftmenu, 'ManageBackups', 'ManageBackups' );
240
241 foreach ( $init_sub_subleftmenu as $item ) {
242 if ( MainWP_Menu::is_disable_menu_item( 3, $item['slug'] ) ) {
243 continue;
244 }
245 MainWP_Menu::add_left_menu( $item, 2 );
246 }
247 }
248 }
249
250 /**
251 * Render MainWP Legacy Backups Page Header.
252 *
253 * @param string $shownPage The page slug shown at this moment.
254 *
255 * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item()
256 * @uses \MainWP\Dashboard\MainWP_UI::render_top_header()
257 * @uses \MainWP\Dashboard\MainWP_UI::render_page_navigation()
258 */
259 public static function render_header( $shownPage = '' ) { //phpcs:ignore -- NOSONAR - complex.
260
261 $params = array(
262 'title' => esc_html__( 'Backups', 'mainwp' ),
263 );
264
265 MainWP_UI::render_top_header( $params );
266
267 $renderItems = array();
268
269 $renderItems[] = array(
270 'title' => esc_html__( 'Manage Backups', 'mainwp' ),
271 'href' => 'admin.php?page=ManageBackups',
272 'active' => ( '' === $shownPage ) ? true : false,
273 'disabled' => MainWP_Menu::is_disable_menu_item( 3, 'ManageBackups' ) ? true : false,
274 );
275
276 if ( ! MainWP_Menu::is_disable_menu_item( 3, 'ManageBackupsAddNew' ) ) {
277 $renderItems[] = array(
278 'title' => esc_html__( 'Add New', 'mainwp' ),
279 'href' => 'admin.php?page=ManageBackupsAddNew',
280 'access' => mainwp_current_user_have_right( 'dashboard', 'add_backup_tasks' ),
281 'active' => ( 'AddNew' === $shownPage ) ? true : false,
282 'disabled' => MainWP_Menu::is_disable_menu_item( 3, 'ManageBackupsAddNew' ) ? true : false,
283 );
284 }
285
286 if ( ! MainWP_Menu::is_disable_menu_item( 3, 'ManageBackupsEdit' ) ) {
287 if ( 'ManageBackupsEdit' === $shownPage ) {
288 $renderItems[] = array(
289 'title' => esc_html__( 'Edit', 'mainwp' ),
290 'href' => '#',
291 'active' => true,
292 );
293 }
294 }
295
296 if ( isset( static::$subPages ) && is_array( static::$subPages ) ) {
297 foreach ( static::$subPages as $subPage ) {
298 if ( MainWP_Menu::is_disable_menu_item( 3, 'ManageBackups' . $subPage['slug'] ) ) {
299 continue;
300 }
301
302 $item = array();
303 $item['title'] = esc_html( $subPage['title'] );
304 $item['href'] = 'admin.php?page=ManageBackups' . $subPage['slug'];
305 $item['active'] = ( $subPage['slug'] === $shownPage ) ? true : false;
306 $renderItems[] = $item;
307 }
308 }
309
310 MainWP_UI::render_page_navigation( $renderItems );
311 }
312
313 /**
314 * Render MainWP Legacy Backups Footer.
315 */
316 public static function render_footer() {
317 echo '</div>';
318 }
319
320 /**
321 * Render Legacy Backups page.
322 *
323 * @uses \MainWP\Dashboard\MainWP_DB_Backup::get_backup_task_by_id()
324 * @uses \MainWP\Dashboard\MainWP_DB_Backup::get_backup_tasks_for_user()
325 * @uses \MainWP\Dashboard\MainWP_UI::render_modal_edit_notes()
326 * @uses \MainWP\Dashboard\MainWP_Manage_Backups_Handler::can_edit_backuptask()
327 * @uses \MainWP\Dashboard\MainWP_Manage_Backups_Handler::validate_backup_tasks()
328 */
329 public static function render_manager() { //phpcs:ignore -- NOSONAR - complex.
330 $backupTask = null;
331 //phpcs:disable WordPress.Security.NonceVerification.Recommended
332 if ( isset( $_GET['id'] ) ) {
333 if ( ! mainwp_current_user_have_right( 'dashboard', 'edit_backup_tasks' ) ) {
334 mainwp_do_not_have_permissions( esc_html__( 'edit backup tasks', 'mainwp' ) );
335 return;
336 }
337 $backupTaskId = intval( $_GET['id'] );
338
339 $backupTask = MainWP_DB_Backup::instance()->get_backup_task_by_id( $backupTaskId );
340 if ( ! MainWP_Manage_Backups_Handler::can_edit_backuptask( $backupTask ) ) {
341 $backupTask = null;
342 }
343
344 if ( ! empty( $backupTask ) ) {
345 if ( ! MainWP_Manage_Backups_Handler::validate_backup_tasks( array( $backupTask ) ) ) {
346 $backupTask = MainWP_DB_Backup::instance()->get_backup_task_by_id( $backupTaskId );
347 }
348 }
349 }
350
351 $primary_methods = array();
352 $primary_methods = apply_filters_deprecated( 'mainwp-getprimarybackup-methods', array( $primary_methods ), '4.0.7.2', 'mainwp_getprimarybackup_methods' ); // @deprecated Use 'mainwp_getprimarybackup_methods' instead. NOSONAR - not IP.
353 $primaryBackupMethods = apply_filters( 'mainwp_getprimarybackup_methods', $primary_methods );
354
355 if ( ! is_array( $primaryBackupMethods ) ) {
356 $primaryBackupMethods = array();
357 }
358
359 if ( null === $backupTask ) {
360
361 $backup_items = MainWP_DB_Backup::instance()->get_backup_tasks_for_user();
362 if ( ! MainWP_Manage_Backups_Handler::validate_backup_tasks( $backup_items ) ) {
363 $backup_items = MainWP_DB_Backup::instance()->get_backup_tasks_for_user();
364 }
365
366 static::render_header( '' );
367 ?>
368 <?php if ( 0 === count( $primaryBackupMethods ) ) { ?>
369 <div class="mainwp-notice mainwp-notice-blue"><?php printf( esc_html__( 'Did you know that MainWP has extensions for working with popular backup plugins? Visit the %1$sextensions site%2$s for options.', 'mainwp' ), '<a href="https://mainwp.com/extensions/extension-category/backups/" target="_blank" ?>', '</a>' ); // NOSONAR - noopener - open safe. ?></div>
370 <?php } ?>
371 <div class="ui alt segment">
372 <div id="mainwp_managebackups_add_message" class="mainwp-notice mainwp-notice-green" style="display:
373 <?php
374 if ( isset( $_GET['a'] ) && '1' === $_GET['a'] ) {
375 echo 'block';
376 } else {
377 echo 'none';
378 }
379 ?>
380 ">
381 <?php
382 if ( isset( $_GET['a'] ) && '1' === $_GET['a'] ) {
383 echo '<p>' . esc_html__( 'The backup task was added successfully', 'mainwp' ) . '</p>';
384 }
385 ?>
386 </div>
387
388 <form method="post" class="mainwp-table-container">
389 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
390 <?php
391 MainWP_UI::render_modal_edit_notes();
392 static::instance()->display( $backup_items );
393 ?>
394 </form>
395 </div>
396
397 <div class="ui modal" id="managebackups-task-status-box" tabindex="0">
398 <div class="header">Running task</div>
399 <div class="content mainwp-modal-content"></div>
400 <div class="actions mainwp-modal-actions">
401 <input id="managebackups-task-status-close" type="button" name="Close" value="<?php esc_attr_e( 'Cancel', 'mainwp' ); ?>" class="button" />
402 </div>
403 </div>
404 <?php
405 static::render_footer( '' );
406 } else {
407 static::render_edit( $backupTask );
408 }
409 //phpcs:enable
410 }
411
412 /**
413 * Render MainWP Legacy Backups Table.
414 *
415 * @param mixed $backup_items List Item.
416 *
417 * @uses \MainWP\Dashboard\MainWP_DB::get_website_by_group_id()
418 */
419 public function display( $backup_items ) { //phpcs:ignore -- NOSONAR - complex.
420 $can_trigger = true;
421 if ( ! mainwp_current_user_have_right( 'dashboard', 'run_backup_tasks' ) ) {
422 $can_trigger = false;
423 }
424 ?>
425 <table id="mainwp-backups-table" class="ui padded selectable compact single line table">
426 <thead class="full-width">
427 <tr>
428 <th id="mainwp-title"><?php esc_html_e( 'Task name', 'mainwp' ); ?></th>
429 <th id="mainwp-type"><?php esc_html_e( 'Type', 'mainwp' ); ?></th>
430 <th id="mainwp-schedule"><?php esc_html_e( 'Schedule', 'mainwp' ); ?></th>
431 <th id="mainwp-dest" class="no-sort"><?php esc_html_e( 'Destination', 'mainwp' ); ?></th>
432 <th id="mainwp-website"><?php esc_html_e( 'Website', 'mainwp' ); ?></th>
433 <th id="mainwp-details" class="no-sort"><?php esc_html_e( 'Details', 'mainwp' ); ?></th>
434 <?php if ( $can_trigger ) { ?>
435 <th id="mainwp-trigger" class="no-sort"><?php esc_html_e( 'Trigger', 'mainwp' ); ?></th>
436 <?php } ?>
437 <th id="mainwp-actions" class="no-sort"></th>
438 </tr>
439 </thead>
440 <tbody>
441 <?php
442 if ( $backup_items ) {
443 $columns = array(
444 'task_name' => esc_html__( 'Task Name', 'mainwp' ),
445 'type' => esc_html__( 'Type', 'mainwp' ),
446 'schedule' => esc_html__( 'Schedule', 'mainwp' ),
447 'destination' => esc_html__( 'Destination', 'mainwp' ),
448 'websites' => esc_html__( 'Websites', 'mainwp' ),
449 'details' => esc_html__( 'Details', 'mainwp' ),
450 'trigger' => esc_html__( 'Trigger', 'mainwp' ),
451 'actions' => esc_html__( 'Trigger', 'mainwp' ),
452 );
453
454 if ( ! $can_trigger ) {
455 unset( $columns['trigger'] );
456 }
457
458 foreach ( $backup_items as $item ) {
459 $sites = ( empty( $item->sites ) ? array() : explode( ',', $item->sites ) );
460 $groups = ( empty( $item->groups ) ? array() : explode( ',', $item->groups ) );
461 foreach ( $groups as $group ) {
462 $websites = MainWP_DB::instance()->get_websites_by_group_id( $group );
463 if ( empty( $websites ) ) {
464 continue;
465 }
466
467 foreach ( $websites as $website ) {
468 if ( ! in_array( $website->id, $sites ) ) {
469 $sites[] = $website->id;
470 }
471 }
472 }
473
474 $item->the_sites = $sites;
475
476 $this->single_row( $item, $columns );
477 }
478 }
479 ?>
480 </tbody>
481 </table>
482 <script type="text/javascript">
483 jQuery( document ).ready( function () {
484 jQuery( '#mainwp-backups-table' ).DataTable( {
485 "colReorder" : true,
486 "stateSave": true,
487 "pagingType": "full_numbers",
488 "order": [],
489 "columnDefs": [ {
490 "targets": 'no-sort',
491 "orderable": false
492 } ],
493 "drawCallback": function( settings ) {
494 jQuery( '#mainwp-backups-table .ui.dropdown' ).dropdown();
495 },
496 } );
497 } );
498 </script>
499 <?php
500 }
501
502 /**
503 * Single row Content.
504 *
505 * @param mixed $item Item to go in column.
506 * @param mixed $columns Columns Array.
507 */
508 public function single_row( $item, $columns ) {
509 ?>
510 <tr>
511 <?php
512 foreach ( $columns as $column_name => $title ) {
513 if ( method_exists( $this, 'column_' . $column_name ) ) {
514 echo '<td>';
515 echo call_user_func( array( $this, 'column_' . $column_name ), $item ); // phpcs:ignore WordPress.Security.EscapeOutput
516 echo '</td>';
517 } else {
518 echo '<td></td>';
519 }
520 }
521 ?>
522 </tr>
523 <?php
524 }
525
526 /**
527 * Column Actions.
528 *
529 * @param mixed $item Item to go in column.
530 *
531 * @return string Action content.
532 */
533 public function column_actions( $item ) {
534
535 $actions = array(
536 'edit' => sprintf( '<a class="item" href="admin.php?page=ManageBackups&id=%s"><i class="edit outline icon"></i> ' . esc_html__( 'Edit', 'mainwp' ) . '</a>', $item->id ),
537 'delete' => sprintf( '<a class="submitdelete item" href="#" task_id="%s" onClick="return managebackups_remove(this);"><i class="trash alternate outline icon"></i> ' . esc_html__( 'Delete', 'mainwp' ) . '</a>', $item->id ),
538 );
539
540 if ( ! mainwp_current_user_have_right( 'dashboard', 'edit_backup_tasks' ) ) {
541 unset( $actions['edit'] );
542 }
543
544 if ( ! mainwp_current_user_have_right( 'dashboard', 'delete_backup_tasks' ) ) {
545 unset( $actions['delete'] );
546 }
547
548 if ( 1 === (int) $item->paused ) {
549 if ( mainwp_current_user_have_right( 'dashboard', 'pause_resume_backup_tasks' ) ) {
550 $actions['resume'] = sprintf( '<a href="#" class="item" task_id="%s" onClick="return managebackups_resume(this)"><i class="play icon"></i> ' . esc_html__( 'Resume', 'mainwp' ) . '</a>', $item->id );
551 }
552 } elseif ( mainwp_current_user_have_right( 'dashboard', 'pause_resume_backup_tasks' ) ) {
553 $actions['pause'] = sprintf( '<a href="#" class="item" task_id="%s" onClick="return managebackups_pause(this)"><i class="pause icon"></i> ' . esc_html__( 'Pause', 'mainwp' ) . '</a>', $item->id );
554 }
555
556 $out = '<div class="ui left pointing dropdown icon mini basic green button" style="z-index:999">
557 <i class="ellipsis horizontal icon"></i>
558 <div class="menu">
559 <div class="header">' . esc_html_e( 'Backup Actions', 'mainwp' ) . '</div>
560 <div class="divider"></div>';
561 foreach ( $actions as $link ) {
562 $out .= $link;
563 }
564 $out .= '</div>
565 </div>';
566
567 return $out;
568 }
569
570 /**
571 * Column Task Name.
572 *
573 * @param mixed $item Item to go in column.
574 *
575 * @return string Action content.
576 */
577 public function column_task_name( $item ) {
578 return stripslashes( $item->name );
579 }
580
581 /**
582 * Column Type.
583 *
584 * @param mixed $item Item to go in column.
585 *
586 * @return string Action content.
587 */
588 public function column_type( $item ) {
589 return 'db' === $item->type ? esc_html__( 'DATABASE BACKUP', 'mainwp' ) : esc_html__( 'FULL BACKUP', 'mainwp' );
590 }
591
592 /**
593 * Column Schdule.
594 *
595 * @param mixed $item Item to go in column.
596 *
597 * @return string Action content.
598 */
599 public function column_schedule( $item ) {
600 return strtoupper( $item->schedule );
601 }
602
603 /**
604 * Column Destination.
605 *
606 * @param mixed $item Item to go in column.
607 *
608 * @return string Action content.
609 */
610 public function column_destination( $item ) {
611 $extraOutput = apply_filters( 'mainwp_backuptask_column_destination', '', $item->id );
612 if ( '' !== $extraOutput ) {
613 return trim( $extraOutput, '<br />' );
614 }
615
616 return esc_html__( 'SERVER', 'mainwp' );
617 }
618
619 /**
620 * Column Websites.
621 *
622 * @param mixed $item Item to go in column.
623 */
624 public function column_websites( $item ) {
625 if ( 0 === count( $item->the_sites ) ) {
626 echo( '<span style="color: red; font-weight: bold; ">' . count( $item->the_sites ) . '</span>' );
627 } else {
628 echo count( $item->the_sites );
629 }
630 }
631
632 /**
633 * Column Details.
634 *
635 * @param mixed $item Item to go in column.
636 *
637 * @return string Action content.
638 *
639 * @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp()
640 * @uses \MainWP\Dashboard\MainWP_Utility::get_timestamp()
641 */
642 public function column_details( $item ) {
643 $output = '<strong>' . esc_html__( 'LAST RUN MANUALLY: ', 'mainwp' ) . '</strong>' . ( empty( $item->last_run_manually ) ? '-' : MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $item->last_run_manually ) ) ) . '<br />';
644 $output .= '<strong>' . esc_html__( 'LAST RUN: ', 'mainwp' ) . '</strong>' . ( empty( $item->last_run ) ? '-' : MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $item->last_run ) ) ) . '<br />';
645 $output .= '<strong>' . esc_html__( 'LAST COMPLETED: ', 'mainwp' ) . '</strong>' . ( empty( $item->completed ) ? '-' : MainWP_Utility::format_timestamp( MainWP_Utility::get_timestamp( $item->completed ) ) ) . '<br />';
646 $output .= '<strong>' . esc_html__( 'NEXT RUN: ', 'mainwp' ) . '</strong>' . ( empty( $item->last_run ) ? esc_html__( 'Any minute', 'mainwp' ) : MainWP_Utility::format_timestamp( ( 'daily' === $item->schedule ? ( 60 * 60 * 24 ) : ( 'weekly' === $item->schedule ? ( 60 * 60 * 24 * 7 ) : ( 60 * 60 * 24 * 30 ) ) ) + MainWP_Utility::get_timestamp( $item->last_run ) ) );
647 $output .= '<strong>';
648 if ( ! empty( $item->last_run ) && $item->completed < $item->last_run ) {
649 $output .= esc_html__( '<br />CURRENTLY RUNNING: ', 'mainwp' ) . '</strong>';
650 $completed_sites = $item->completed_sites;
651 if ( '' !== $completed_sites ) {
652 $completed_sites = json_decode( $completed_sites, 1 );
653 }
654 if ( ! is_array( $completed_sites ) ) {
655 $completed_sites = array();
656 }
657 $output .= count( $completed_sites ) . '/' . count( $item->the_sites );
658 }
659 return $output;
660 }
661
662 /**
663 * Column Trigger.
664 *
665 * @param mixed $item Item to go in column.
666 *
667 * @return string Action content.
668 */
669 public function column_trigger( $item ) {
670 return '<span class="backup_run_loading"><img src="' . MAINWP_PLUGIN_URL . 'assets/images/loader.gif" /></span>&nbsp;<a href="#" class="backup_run_now" task_id="' . $item->id . '" task_type="' . $item->type . '">' . esc_html__( 'Run now', 'mainwp' ) . '</a>';
671 }
672
673 /**
674 * Render edit.
675 *
676 * @param mixed $task Task to edit.
677 */
678 public static function render_edit( $task ) {
679 static::render_header( 'ManageBackupsEdit' );
680 ?>
681 <div class="ui alt segment">
682 <div class="ui message" id="mainwp-message-zone" style="display:none"></div>
683 <form method="POST" action="" class="ui form">
684 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
685 <input type="hidden" name="mainwp_managebackups_edit_id" id="mainwp_managebackups_edit_id" value="<?php echo esc_attr( $task->id ); ?>"/>
686 <?php
687 static::render_new_edit( $task );
688 ?>
689 </form>
690 </div>
691 <?php
692 static::render_footer( 'ManageBackupsEdit' );
693 }
694
695 /** Render New Task Form. */
696 public static function render_new() {
697 if ( ! mainwp_current_user_have_right( 'dashboard', 'add_backup_tasks' ) ) {
698 mainwp_do_not_have_permissions( esc_html__( 'add backup tasks', 'mainwp' ) );
699 return;
700 }
701 static::render_header( 'AddNew' );
702 ?>
703 <div class="ui alt segment">
704 <div class="ui message" id="mainwp-message-zone" style="display:none"></div>
705 <form method="POST" action="" id="mainwp-backup-task-form" class="ui form">
706 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
707 <?php static::render_new_edit( null ); ?>
708 </form>
709 </div>
710 <?php
711 static::render_footer( 'AddNew' );
712 }
713
714 /**
715 * Render New edit Form.
716 *
717 * @param mixed $task Task to edit.
718 */
719 public static function render_new_edit( $task ) {
720 $selected_websites = array();
721 $selected_groups = array();
722 if ( ! empty( $task ) ) {
723 if ( '' !== $task->sites ) {
724 $selected_websites = explode( ',', $task->sites );
725 }
726 if ( '' !== $task->groups ) {
727 $selected_groups = explode( ',', $task->groups );
728 }
729 }
730 ?>
731
732 <div class="mainwp-main-content">
733 <?php static::render_schedule_backup(); ?>
734 </div>
735 <div class="mainwp-side-content mainwp-no-padding">
736 <div class="mainwp-select-sites">
737 <div class="ui header"><?php esc_html_e( 'Select Sites', 'mainwp' ); ?></div>
738 <?php
739 $sel_params = array(
740 'selected_sites' => $selected_websites,
741 'selected_groups' => $selected_groups,
742 'enable_offline_sites' => true,
743 );
744 MainWP_UI_Select_Sites::select_sites_box( $sel_params );
745 ?>
746 </div>
747 <div class="ui divider"></div>
748 <div class="mainwp-search-submit">
749 <?php if ( ! empty( $task ) ) : ?>
750 <input type="hidden" id="backup_task_id" value="<?php echo esc_attr( $task->id ); ?>"/>
751 <input type="button" name="mainwp_managebackups_update" id="mainwp_managebackups_update" class="ui big green fluid button" value="<?php esc_attr_e( 'Update Schedule Backup', 'mainwp' ); ?>"/>
752 <?php else : ?>
753 <input type="button" name="mainwp_managebackups_add" id="mainwp_managebackups_add" class="ui big green fluid button" value="<?php esc_attr_e( 'Schedule Backup', 'mainwp' ); ?>"/>
754 <?php endif; ?>
755 </div>
756 </div>
757 <div class="ui hidden clearing divider"></div>
758 <?php
759 }
760
761 /**
762 * Render Scheduled Backup.
763 *
764 * @return void
765 * @uses \MainWP\Dashboard\MainWP_DB_Backup::get_backup_task_by_id()
766 * @uses \MainWP\Dashboard\MainWP_Manage_Backups_Handler::can_edit_backuptask()
767 * @uses \MainWP\Dashboard\MainWP_Manage_Backups_Handler::validate_backup_tasks()
768 */
769 public static function render_schedule_backup() { //phpcs:ignore -- NOSONAR - complex.
770 $backupTask = null;
771 $backupTaskId = isset( $_GET['id'] ) ? intval( $_GET['id'] ) : false; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
772
773 if ( ! empty( $backupTaskId ) ) {
774 if ( ! mainwp_current_user_have_right( 'dashboard', 'edit_backup_tasks' ) ) {
775 mainwp_do_not_have_permissions( esc_html__( 'edit backup tasks', 'mainwp' ) );
776 return;
777 }
778
779 $backupTask = MainWP_DB_Backup::instance()->get_backup_task_by_id( $backupTaskId );
780 if ( ! MainWP_Manage_Backups_Handler::can_edit_backuptask( $backupTask ) ) {
781 $backupTask = null;
782 }
783
784 if ( ! empty( $backupTask ) ) {
785 if ( ! MainWP_Manage_Backups_Handler::validate_backup_tasks( array( $backupTask ) ) ) {
786 $backupTask = MainWP_DB_Backup::instance()->get_backup_task_by_id( $backupTaskId );
787 }
788 }
789 }
790 $task = $backupTask;
791
792 $globalArchiveFormat = get_option( 'mainwp_archiveFormat' );
793 if ( false === $globalArchiveFormat ) {
794 $globalArchiveFormat = 'tar.gz';
795 }
796 if ( 'zip' === $globalArchiveFormat ) {
797 $globalArchiveFormatText = 'Zip';
798 } elseif ( 'tar' === $globalArchiveFormat ) {
799 $globalArchiveFormatText = 'Tar';
800 } elseif ( 'tar.gz' === $globalArchiveFormat ) {
801 $globalArchiveFormatText = 'Tar GZip';
802 } elseif ( 'tar.bz2' === $globalArchiveFormat ) {
803 $globalArchiveFormatText = 'Tar BZip2';
804 }
805
806 $archiveFormat = isset( $task ) ? $task->archiveFormat : 'site';
807 $useGlobal = ( 'global' === $archiveFormat );
808 $useSite = ( empty( $archiveFormat ) || 'site' === $archiveFormat );
809
810 static::render_task_details( $task, $globalArchiveFormatText, $archiveFormat, $useGlobal, $useSite );
811 }
812
813 /**
814 * Render Task Details.
815 *
816 * @param mixed $task Task to perform.
817 * @param mixed $globalArchiveFormatText Global Archived Format Text.
818 * @param mixed $archiveFormat Archive Format.
819 * @param mixed $useGlobal Use Global.
820 * @param mixed $useSite Use Site.
821 */
822 public static function render_task_details( $task, $globalArchiveFormatText, $archiveFormat, $useGlobal, $useSite ) { // phpcs:ignore -- NOSONAR - complex.
823 ?>
824
825 <div class="ui divider hidden"></div>
826 <div class="ui message" id="mainwp-message-zone" style="display:none"></div>
827 <h3 class="header"><?php esc_html_e( 'Backup Details', 'mainwp' ); ?></h3>
828 <div class="ui grid field">
829 <label class="six wide column middle aligned"><?php esc_html_e( 'Backup task name', 'mainwp' ); ?></label>
830 <div class="ten wide column">
831 <input type="text" id="mainwp_managebackups_add_name" name="mainwp_managebackups_add_name" value="<?php echo isset( $task ) ? esc_html( stripslashes( $task->name ) ) : ''; ?>"/>
832 </div>
833 </div>
834 <div class="ui grid field">
835 <label class="six wide column middle aligned"><?php esc_html_e( 'Backup file name', 'mainwp' ); ?></label>
836 <div class="ten wide column">
837 <input type="text" id="backup_filename" name="backup_filename" value="<?php echo isset( $task ) ? esc_html( stripslashes( $task->filename ) ) : ''; ?>"/>
838 </div>
839 </div>
840 <div class="ui grid field">
841 <label class="six wide column middle aligned"><?php esc_html_e( 'Backup type', 'mainwp' ); ?></label>
842 <div class="ten wide column">
843 <select name="mainwp-backup-type" id="mainwp-backup-type" class="ui dropdown">
844 <option value="full" <?php echo ! isset( $task ) || 'full' === $task->type ? 'selected' : ''; ?>><?php esc_html_e( 'Full Backup', 'mainwp' ); ?></option>
845 <option value="db" <?php echo isset( $task ) && 'db' === $task->type ? 'selected' : ''; ?>><?php esc_html_e( 'Database Backup', 'mainwp' ); ?></option>
846 </select>
847 </div>
848 </div>
849 <div class="ui grid field">
850 <label class="six wide column middle aligned"><?php esc_html_e( 'Schedule', 'mainwp' ); ?></label>
851 <div class="ten wide column">
852 <select name="mainwp-backup-task-schedule" id="mainwp-backup-task-schedule" class="ui dropdown">
853 <option value="daily" <?php echo( ! isset( $task ) || 'daily' === $task->schedule ? 'selected' : '' ); ?>><?php esc_html_e( 'Daily', 'mainwp' ); ?></option>
854 <option value="weekly" <?php echo( ! isset( $task ) || 'weekly' === $task->schedule ? 'selected' : '' ); ?>><?php esc_html_e( 'Weekly', 'mainwp' ); ?></option>
855 <option value="monthly" <?php echo( ! isset( $task ) || 'monthly' === $task->schedule ? 'selected' : '' ); ?>><?php esc_html_e( 'Monthly', 'mainwp' ); ?></option>
856 </select>
857 </div>
858 </div>
859 <div class="ui grid field">
860 <label class="six wide column middle aligned"><?php esc_html_e( 'Archive type', 'mainwp' ); ?></label>
861 <div class="ten wide column">
862 <select name="mainwp_archiveFormat" id="mainwp_archiveFormat" class="ui dropdown">
863 <option value="site"
864 <?php
865 if ( $useSite ) :
866 ?>
867 selected<?php endif; ?>><?php esc_html_e( 'Site specific setting', 'mainwp' ); ?></option>
868 <option value="global"
869 <?php
870 if ( $useGlobal ) :
871 ?>
872 selected<?php endif; ?>><?php esc_html_e( 'Global setting', 'mainwp' ); ?> (<?php echo esc_html( $globalArchiveFormatText ); ?>)</option>
873 <option value="zip"
874 <?php
875 if ( 'zip' === $archiveFormat ) :
876 ?>
877 selected<?php endif; ?>><?php esc_html_e( 'Zip', 'mainwp' ); ?></option>
878 <option value="tar"
879 <?php
880 if ( 'tar' === $archiveFormat ) :
881 ?>
882 selected<?php endif; ?>><?php esc_html_e( 'Tar', 'mainwp' ); ?></option>
883 <option value="tar.gz"
884 <?php
885 if ( 'tar.gz' === $archiveFormat ) :
886 ?>
887 selected<?php endif; ?>><?php esc_html_e( 'Tar GZip', 'mainwp' ); ?></option>
888 <option value="tar.bz2"
889 <?php
890 if ( 'tar.bz2' === $archiveFormat ) :
891 ?>
892 selected<?php endif; ?>><?php esc_html_e( 'Tar BZip2', 'mainwp' ); ?></option>
893 </select>
894 </div>
895 </div>
896 <?php
897 $style = isset( $task ) && 'db' === $task->type ? 'style="display: none;"' : '';
898 ?>
899 <div class="mainwp-backup-full-exclude" <?php echo $style; //phpcs:ignore -- ok. ?>>
900 <h3 class="header"><?php esc_html_e( 'Backup Excludes', 'mainwp' ); ?></h3>
901 <div class="ui grid field">
902 <label class="six wide column middle aligned"><?php esc_html_e( 'Known backup locations', 'mainwp' ); ?></label>
903 <div class="ten wide column ui toggle checkbox">
904 <input type="checkbox" id="mainwp-known-backup-locations" <?php echo( ! isset( $task ) || 1 === (int) $task->excludebackup ? 'checked' : '' ); ?>>
905 </div>
906 </div>
907 <div class="ui grid field">
908 <label class="six wide column middle aligned"></label>
909 <div class="ten wide column ui toggle checkbox">
910 <textarea id="mainwp-kbl-content" disabled></textarea><br />
911 <em><?php esc_html_e( 'This adds known backup locations of popular WordPress backup plugins to the exclude list. Old backups can take up a lot of space and can cause your current MainWP backup to timeout.', 'mainwp' ); ?></em>
912 </div>
913 </div>
914 <div class="ui grid field">
915 <label class="six wide column middle aligned"><?php esc_html_e( 'Known cache locations', 'mainwp' ); ?></label>
916 <div class="ten wide column ui toggle checkbox">
917 <input type="checkbox" id="mainwp-known-cache-locations" <?php echo( ! isset( $task ) || 1 === (int) $task->excludecache ? 'checked' : '' ); ?>><br />
918 </div>
919 </div>
920 <div class="ui grid field">
921 <label class="six wide column middle aligned"></label>
922 <div class="ten wide column ui toggle checkbox">
923 <textarea id="mainwp-kcl-content" disabled></textarea><br />
924 <em><?php esc_html_e( 'This adds known cache locations of popular WordPress cache plugins to the exclude list. A cache can be massive with thousands of files and can cause your current MainWP backup to timeout. Your cache will be rebuilt by your caching plugin when the backup is restored.', 'mainwp' ); ?></em>
925 </div>
926 </div>
927 <div class="ui grid field">
928 <label class="six wide column middle aligned"><?php esc_html_e( 'Non-WordPress folders', 'mainwp' ); ?></label>
929 <div class="ten wide column ui toggle checkbox">
930 <input type="checkbox" id="mainwp-non-wordpress-folders" <?php echo( ! isset( $task ) || 1 === (int) $task->excludenonwp ? 'checked' : '' ); ?>><br />
931 </div>
932 </div>
933 <div class="ui grid field">
934 <label class="six wide column middle aligned"></label>
935 <div class="ten wide column ui toggle checkbox">
936 <textarea id="mainwp-nwl-content" disabled></textarea><br />
937 <em><?php esc_html_e( 'This adds folders that are not part of the WordPress core (wp-admin, wp-content and wp-include) to the exclude list. Non-WordPress folders can contain a large amount of data or may be a sub-domain or add-on domain that should be backed up individually and not with this backup.', 'mainwp' ); ?></em>
938 </div>
939 </div>
940 <div class="ui grid field">
941 <label class="six wide column middle aligned"><?php esc_html_e( 'ZIP archives', 'mainwp' ); ?></label>
942 <div class="ten wide column ui toggle checkbox">
943 <input type="checkbox" id="mainwp-zip-archives" <?php echo( ! isset( $task ) || 1 === (int) $task->excludezip ? 'checked' : '' ); ?>>
944 </div>
945 </div>
946 <div class="ui grid field">
947 <label class="six wide column middle aligned"><?php esc_html_e( 'Custom excludes', 'mainwp' ); ?></label>
948 <div class="ten wide column ui toggle checkbox">
949 <textarea id="excluded_folders_list">
950 <?php
951 $excluded = ( isset( $task ) ? $task->exclude : '' );
952 if ( '' !== $excluded ) {
953 $excluded = explode( ',', $excluded );
954 $excluded = is_array( $excluded ) ? array_map( 'sanitize_text_field', $excluded ) : array();
955 echo implode( "/\n", $excluded ) . "/\n"; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
956 }
957 ?>
958 </textarea>
959 </div>
960 </div>
961 </div>
962 <?php
963 }
964
965
966 /**
967 * Method render_settings()
968 *
969 * Render backup settings.
970 */
971 public static function render_settings() { //phpcs:ignore -- NOSONAR - complex.
972
973 $backupsOnServer = get_option( 'mainwp_backupsOnServer' );
974 $backupOnExternalSources = get_option( 'mainwp_backupOnExternalSources' );
975 $archiveFormat = get_option( 'mainwp_archiveFormat' );
976 $maximumFileDescriptors = get_option( 'mainwp_maximumFileDescriptors' );
977 $maximumFileDescriptorsAuto = get_option( 'mainwp_maximumFileDescriptorsAuto' );
978 $maximumFileDescriptorsAuto = ( 1 === $maximumFileDescriptorsAuto || false === $maximumFileDescriptorsAuto );
979
980 $notificationOnBackupFail = get_option( 'mainwp_notificationOnBackupFail' );
981 $notificationOnBackupStart = get_option( 'mainwp_notificationOnBackupStart' );
982 $chunkedBackupTasks = get_option( 'mainwp_chunkedBackupTasks' );
983 $enableLegacyBackupFeature = get_option( 'mainwp_enableLegacyBackupFeature' );
984
985 $loadFilesBeforeZip = get_option( 'mainwp_options_loadFilesBeforeZip' );
986 $loadFilesBeforeZip = ( 1 === $loadFilesBeforeZip || false === $loadFilesBeforeZip );
987
988 $primaryBackup = get_option( 'mainwp_primaryBackup' );
989 $primary_methods = array();
990 $primary_methods = apply_filters_deprecated( 'mainwp-getprimarybackup-methods', array( $primary_methods ), '4.0.7.2', 'mainwp_getprimarybackup_methods' ); // @deprecated Use 'mainwp_getprimarybackup_methods' instead. NOSONAR - not IP.
991 $primaryBackupMethods = apply_filters( 'mainwp_getprimarybackup_methods', $primary_methods );
992
993 if ( ! is_array( $primaryBackupMethods ) ) {
994 $primaryBackupMethods = array();
995 }
996
997 /**
998 * MainWP use external primary backup method.
999 *
1000 * @global string
1001 */
1002 global $mainwpUseExternalPrimaryBackupsMethod;
1003
1004 $hidden_elems = false;
1005 if ( ! $enableLegacyBackupFeature || ( ! empty( $primaryBackup ) && $primaryBackup === $mainwpUseExternalPrimaryBackupsMethod ) ) {
1006 $hidden_elems = true;
1007 }
1008 ?>
1009 <h3 class="ui dividing header">
1010 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-backups' ); ?>
1011 <?php esc_html_e( 'Backup Settings', 'mainwp' ); ?>
1012 <div class="sub header"><?php printf( esc_html__( 'MainWP is actively moving away from further development of the native backups feature. The best long-term solution would be one of the %1$sBackup Extensions%2$s.', 'mainwp' ), '<a href="https://mainwp.com/extensions/extension-category/backups/" target="_blank" ?>', '</a>' ); // NOSONAR - noopener - open safe. ?></div>
1013 </h3>
1014 <?php if ( ! empty( $primaryBackupMethods ) ) : ?>
1015 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-wrapper settings-field-indicator-wrapper settings-field-indicator-backups">
1016 <label class="six wide column middle aligned"><?php esc_html_e( 'Select primary backup system', 'mainwp' ); ?></label>
1017 <div class="ten wide column">
1018 <select class="ui dropdown" name="mainwp_primaryBackup" id="mainwp_primaryBackup">
1019 <?php if ( $enableLegacyBackupFeature ) { ?>
1020 <option value="" ><?php esc_html_e( 'Native backups', 'mainwp' ); ?></option>
1021 <?php } ?>
1022 <?php
1023 foreach ( $primaryBackupMethods as $method ) {
1024 echo '<option value="' . esc_attr( $method['value'] ) . '" ' . ( ( $primaryBackup === $method['value'] ) ? 'selected' : '' ) . '>' . esc_html( $method['title'] ) . '</option>';
1025 }
1026 ?>
1027
1028 </select>
1029 </div>
1030 </div>
1031 <?php endif; ?>
1032
1033 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-wrapper settings-field-indicator-wrapper settings-field-indicator-backups">
1034 <label class="six wide column middle aligned">
1035 <?php
1036 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_enableLegacyBackupFeature', (int) $enableLegacyBackupFeature );
1037 esc_html_e( 'Enable legacy backup feature', 'mainwp' );
1038 ?>
1039 </label>
1040 <div class="ten wide column ui toggle checkbox">
1041 <input type="checkbox" class="settings-field-value-change-handler" name="mainwp_options_enableLegacyBackupFeature" id="mainwp_options_enableLegacyBackupFeature" <?php echo 0 === (int) $enableLegacyBackupFeature ? '' : 'checked="true"'; ?>/>
1042 </div>
1043 </div>
1044 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-wrapper settings-field-indicator-wrapper settings-field-indicator-backups" <?php echo $hidden_elems ? 'style="display:none"' : ''; ?> default-indi-value="1">
1045 <label class="six wide column middle aligned">
1046 <?php
1047 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_backupsOnServer', (int) $backupsOnServer );
1048 esc_html_e( 'Backups on server', 'mainwp' );
1049 ?>
1050 </label>
1051 <div class="ten wide column">
1052 <input type="text" class="settings-field-value-change-handler" name="mainwp_options_backupOnServer" value="<?php echo false === $backupsOnServer ? 1 : intval( $backupsOnServer ); ?>"/>
1053 </div>
1054 </div>
1055
1056 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-wrapper settings-field-indicator-wrapper settings-field-indicator-backups" <?php echo $hidden_elems ? 'style="display:none"' : ''; ?> default-indi-value="1">
1057 <label class="six wide column middle aligned">
1058 <?php
1059 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_backupOnExternalSources', (int) $backupOnExternalSources );
1060 esc_html_e( 'Backups on remote storage', 'mainwp' );
1061 ?>
1062 </label>
1063 <div class="ten wide column">
1064 <span data-tooltip="<?php esc_attr_e( 'The number of backups to keep on your external sources. This does not affect backups on the server. 0 sets unlimited.', 'mainwp' ); ?>" data-inverted=""><input type="text" class="settings-field-value-change-handler" name="mainwp_options_backupOnExternalSources" value="<?php echo false === $backupOnExternalSources ? 1 : intval( $backupOnExternalSources ); ?>"/>
1065 </div>
1066 </div>
1067
1068 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-wrapper settings-field-indicator-wrapper settings-field-indicator-backups" <?php echo $hidden_elems ? 'style="display:none"' : ''; ?> default-indi-value="tar.gz">
1069 <label class="six wide column middle aligned">
1070 <?php
1071 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_archiveFormat', $archiveFormat );
1072 esc_html_e( 'Archive format', 'mainwp' );
1073 ?>
1074 </label>
1075 <div class="ten wide column">
1076 <select class="ui dropdown settings-field-value-change-handler" name="mainwp_archiveFormat" id="mainwp_archiveFormat">
1077 <option value="zip"
1078 <?php
1079 if ( 'zip' === $archiveFormat ) :
1080 ?>
1081 selected<?php endif; ?>>Zip</option>
1082 <option value="tar"
1083 <?php
1084 if ( 'tar' === $archiveFormat ) :
1085 ?>
1086 selected<?php endif; ?>>Tar</option>
1087 <option value="tar.gz"
1088 <?php
1089 if ( ( false === $archiveFormat ) || ( 'tar.gz' === $archiveFormat ) ) :
1090 ?>
1091 selected<?php endif; ?>>Tar GZip</option>
1092 <option value="tar.bz2"
1093 <?php
1094 if ( 'tar.bz2' === $archiveFormat ) :
1095 ?>
1096 selected<?php endif; ?>>Tar BZip2</option>
1097 </select>
1098 </div>
1099 </div>
1100
1101 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-wrapper settings-field-indicator-wrapper settings-field-indicator-backups" <?php echo $hidden_elems ? 'style="display:none"' : ''; ?> <?php
1102 if ( empty( $hidden_elems ) && 'zip' !== $archiveFormat ) {
1103 echo 'style="display: none;"';
1104 }
1105 ?>
1106 default-indi-value="1"
1107 >
1108 <label class="six wide column middle aligned">
1109 <?php
1110 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_maximumFileDescriptorsAuto', (int) $maximumFileDescriptorsAuto );
1111 esc_html_e( 'Auto detect maximum file descriptors on child sites', 'mainwp' );
1112 ?>
1113 </label>
1114 <div class="ten wide column ui toggle checkbox">
1115 <input type="checkbox" class="settings-field-value-change-handler" name="mainwp_maximumFileDescriptorsAuto" id="mainwp_maximumFileDescriptorsAuto" value="1" <?php echo $maximumFileDescriptorsAuto ? 'checked="checked"' : ''; ?>/>
1116 </div>
1117 </div>
1118
1119 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-wrapper settings-field-indicator-wrapper settings-field-indicator-backups" <?php echo $hidden_elems ? 'style="display:none"' : ''; ?> <?php
1120 if ( empty( $hidden_elems ) && 'zip' !== $archiveFormat ) {
1121 echo 'style="display: none;"';
1122 }
1123 ?>
1124 default-indi-value="155" >
1125 <label class="six wide column middle aligned">
1126 <?php
1127 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_maximumFileDescriptors', (int) $maximumFileDescriptors );
1128 esc_html_e( 'Maximum file descriptors fallback value', 'mainwp' );
1129 ?>
1130 </label>
1131 <div class="ten wide column">
1132 <input type="text" class="settings-field-value-change-handler" name="mainwp_options_maximumFileDescriptors" id="mainwp_options_maximumFileDescriptors" value="<?php echo false === $maximumFileDescriptors ? 150 : intval( $maximumFileDescriptors ); ?>"/>
1133 </div>
1134 </div>
1135
1136 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-wrapper settings-field-indicator-wrapper settings-field-indicator-backups" default-indi-value="1" <?php echo $hidden_elems ? 'style="display:none"' : ''; ?> <?php
1137 if ( empty( $hidden_elems ) && 'zip' !== $archiveFormat ) {
1138 echo 'style="display: none;"';
1139 }
1140 ?>
1141 >
1142 <label class="six wide column middle aligned">
1143 <?php
1144 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_options_loadFilesBeforeZip', (int) $loadFilesBeforeZip );
1145 esc_html_e( 'Load files in memory before zipping', 'mainwp' );
1146 ?>
1147 </label>
1148 <div class="ten wide column ui toggle checkbox">
1149 <input type="checkbox" class="settings-field-value-change-handler" inverted-value="1" name="mainwp_options_loadFilesBeforeZip" id="mainwp_options_loadFilesBeforeZip" value="1" <?php echo $loadFilesBeforeZip ? 'checked="checked"' : ''; ?>/>
1150 </div>
1151 </div>
1152
1153 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-wrapper settings-field-indicator-wrapper settings-field-indicator-backups" <?php echo $hidden_elems ? 'style="display:none"' : ''; ?> default-indi-value="1">
1154 <label class="six wide column middle aligned">
1155 <?php
1156 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_notificationOnBackupFail', (int) $notificationOnBackupFail );
1157 esc_html_e( 'Send email when backup fails', 'mainwp' );
1158 ?>
1159 </label>
1160 <div class="ten wide column ui toggle checkbox">
1161 <input type="checkbox" class="settings-field-value-change-handler" inverted-value="1" name="mainwp_options_notificationOnBackupFail" id="mainwp_options_notificationOnBackupFail" value="1" <?php echo $notificationOnBackupFail ? 'checked="checked"' : ''; ?>/>
1162 </div>
1163 </div>
1164 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-wrapper settings-field-indicator-wrapper settings-field-indicator-backups" <?php echo $hidden_elems ? 'style="display:none"' : ''; ?> default-indi-value="1">
1165 <label class="six wide column middle aligned">
1166 <?php
1167 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_notificationOnBackupStart', (int) $notificationOnBackupStart );
1168 esc_html_e( 'Send email when backup starts', 'mainwp' );
1169 ?>
1170 </label>
1171 <div class="ten wide column ui toggle checkbox">
1172 <input type="checkbox" class="settings-field-value-change-handler" inverted-value="1" name="mainwp_options_notificationOnBackupStart" id="mainwp_options_notificationOnBackupStart" value="1" <?php echo $notificationOnBackupStart ? 'checked="checked"' : ''; ?>/>
1173 </div>
1174 </div>
1175
1176 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-wrapper settings-field-indicator-wrapper settings-field-indicator-backups" <?php echo $hidden_elems ? 'style="display:none"' : ''; ?> default-indi-value="1">
1177 <label class="six wide column middle aligned">
1178 <?php
1179 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_chunkedBackupTasks', (int) $chunkedBackupTasks );
1180 esc_html_e( 'Execute backup tasks in chunks', 'mainwp' );
1181 ?>
1182 </label>
1183 <div class="ten wide column ui toggle checkbox">
1184 <input type="checkbox" class="settings-field-value-change-handler" inverted-value="1" name="mainwp_options_chunkedBackupTasks" id="mainwp_options_chunkedBackupTasks" value="1" <?php echo $chunkedBackupTasks ? 'checked="checked"' : ''; ?>/>
1185 </div>
1186 </div>
1187 <?php
1188 }
1189 }
1190