Total Upkeep – WordPress Backup Plugin plus Restore & Migrate by BoldGrid - Version 1.14.0-rc.1

Version Description

Download this release

Release Info

Developer boldgrid
Plugin Icon 128x128 Total Upkeep – WordPress Backup Plugin plus Restore & Migrate by BoldGrid
Version 1.14.0-rc.1
Comparing to
See all releases

Code changes from version 1.13.3 to 1.14.0-rc.1

Files changed (49) hide show
  1. admin/card/class-find-modified-files.php +7 -0
  2. admin/card/class-premium.php +1 -1
  3. admin/card/class-timely-auto-updates.php +50 -0
  4. admin/card/class-updates.php +6 -0
  5. admin/card/feature/class-database-encryption.php +1 -1
  6. admin/card/feature/class-remote-storage.php +1 -1
  7. admin/card/feature/class-scheduled-backups.php +1 -1
  8. admin/card/feature/class-timely-auto-updates.php +57 -0
  9. admin/class-boldgrid-backup-admin-archive-browser.php +7 -5
  10. admin/class-boldgrid-backup-admin-archive-details.php +29 -0
  11. admin/class-boldgrid-backup-admin-auto-rollback.php +16 -18
  12. admin/class-boldgrid-backup-admin-auto-updates.php +215 -0
  13. admin/class-boldgrid-backup-admin-core.php +79 -4
  14. admin/class-boldgrid-backup-admin-dashboard.php +36 -0
  15. admin/class-boldgrid-backup-admin-db-dump.php +15 -1
  16. admin/class-boldgrid-backup-admin-db-import.php +217 -13
  17. admin/class-boldgrid-backup-admin-db-omit.php +1 -1
  18. admin/class-boldgrid-backup-admin-go-pro.php +1 -1
  19. admin/class-boldgrid-backup-admin-notice.php +42 -3
  20. admin/class-boldgrid-backup-admin-premium-features.php +37 -0
  21. admin/class-boldgrid-backup-admin-settings.php +39 -3
  22. admin/class-boldgrid-backup-admin-support.php +35 -1
  23. admin/class-boldgrid-backup-admin-tools.php +35 -2
  24. admin/class-boldgrid-backup-admin-transfers.php +35 -0
  25. admin/class-boldgrid-backup-admin.php +29 -0
  26. admin/css/boldgrid-backup-admin-settings.css +31 -0
  27. admin/css/boldgrid-backup-admin.css +29 -0
  28. admin/image/icon-128x128.png +0 -0
  29. admin/js/boldgrid-backup-admin-backup-now.js +1 -1
  30. admin/js/boldgrid-backup-admin-settings-autoupdate.js +62 -21
  31. admin/js/{boldgrid-backup-admin-table-include.js → boldgrid-backup-admin-table-includes.js} +0 -0
  32. admin/partials/boldgrid-backup-admin-archive-details.php +14 -18
  33. admin/partials/boldgrid-backup-admin-backup-button.php +2 -3
  34. admin/partials/boldgrid-backup-admin-dashboard.php +2 -9
  35. admin/partials/boldgrid-backup-admin-home.php +36 -31
  36. admin/partials/boldgrid-backup-admin-premium.php +3 -11
  37. admin/partials/boldgrid-backup-admin-settings.php +27 -34
  38. admin/partials/boldgrid-backup-admin-support.php +47 -54
  39. admin/partials/boldgrid-backup-admin-test.php +1 -4
  40. admin/partials/boldgrid-backup-admin-tools.php +1 -9
  41. admin/partials/boldgrid-backup-admin-transfers.php +2 -5
  42. admin/partials/settings/auto-backup.php +52 -30
  43. admin/partials/settings/auto-update.php +432 -0
  44. admin/partials/settings/backup-security.php +8 -3
  45. admin/partials/settings/storage.php +1 -1
  46. admin/partials/tools/local-remote.php +8 -12
  47. admin/partials/transfers/destination.php +4 -2
  48. boldgrid-backup.php +1 -1
  49. coverage.xml +7175 -5872
admin/card/class-find-modified-files.php CHANGED
@@ -37,5 +37,12 @@ class Find_Modified_Files extends \Boldgrid\Library\Library\Ui\Card {
37
  'Search for all files modified within a certain time period. You can also look for other versions of that file within your backups.',
38
  'boldgrid-backup' ) .
39
  '</p>';
 
 
 
 
 
 
 
40
  }
41
  }
37
  'Search for all files modified within a certain time period. You can also look for other versions of that file within your backups.',
38
  'boldgrid-backup' ) .
39
  '</p>';
40
+
41
+ $url = esc_url( 'https://www.boldgrid.com/support/total-upkeep/additional-tools/' );
42
+
43
+ $this->links = '
44
+ <a target="_blank" href=" ' . $url . '">' .
45
+ esc_html__( 'Setup Guide' ) . '
46
+ </a>';
47
  }
48
  }
admin/card/class-premium.php CHANGED
@@ -38,7 +38,7 @@ class Premium extends \Boldgrid\Library\Library\Ui\Card {
38
  $features = [];
39
 
40
  if ( empty( $api_key ) ) {
41
- $this->title = esc_html__( 'Build Better Websites With BoldGrid Central', 'boldgrid-backup' );
42
 
43
  $this->subTitle = esc_html__( 'All the tools and services you need to succeed.', 'boldgrid-backup' ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar
44
 
38
  $features = [];
39
 
40
  if ( empty( $api_key ) ) {
41
+ $this->title = esc_html__( 'BoldGrid Central', 'boldgrid-backup' );
42
 
43
  $this->subTitle = esc_html__( 'All the tools and services you need to succeed.', 'boldgrid-backup' ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar
44
 
admin/card/class-timely-auto-updates.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Timely Auto Updates class.
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since 1.14.0
7
+ *
8
+ * @package Boldgrid\Backup
9
+ * @subpackage Boldgrid\Backup\Card
10
+ * @copyright BoldGrid
11
+ * @author BoldGrid <support@boldgrid.com>
12
+ */
13
+
14
+ namespace Boldgrid\Backup\Admin\Card;
15
+
16
+ /**
17
+ * Class: Timely Auto Updates
18
+ *
19
+ * This class is responsible for rendering the "Timely Auto Updates" card on this plugin's Premium Features page.
20
+ *
21
+ * @since 1.14.0
22
+ */
23
+ class Timely_Auto_Updates extends \Boldgrid\Library\Library\Ui\Card {
24
+ /**
25
+ * Init.
26
+ *
27
+ * @since 1.14.0
28
+ */
29
+ public function init() {
30
+ $this->id = 'bgbkup_timely_auto_updates';
31
+
32
+ $this->title = esc_html__( 'Timely Auto Updates', 'boldgrid-backup' );
33
+
34
+ $this->footer = '
35
+ <p>' .
36
+ esc_html__(
37
+ 'Gives you more control over when new updates are installed by WordPress\' Automatic Updates.',
38
+ 'boldgrid-backup' ) .
39
+ '</p>';
40
+
41
+ $url = esc_url( 'https://www.boldgrid.com/support/total-upkeep/timely-auto-updates/?source=timely-auto-updates' );
42
+
43
+ $this->links = '
44
+ <a target="_blank" href="' . $url . '">' .
45
+ esc_html__( 'Setup Guide', 'boldgrid-backup' ) . '
46
+ </a>';
47
+
48
+ $this->icon = '<span class="dashicons dashicons-clock"></span>';
49
+ }
50
+ }
admin/card/class-updates.php CHANGED
@@ -27,6 +27,9 @@ class Updates extends \Boldgrid\Library\Library\Ui\Card {
27
  * @since 1.11.0
28
  */
29
  public function init() {
 
 
 
30
  $this->id = 'bgbkup_updates';
31
 
32
  $this->title = esc_html__( 'Update Management', 'boldgrid-backup' );
@@ -40,5 +43,8 @@ class Updates extends \Boldgrid\Library\Library\Ui\Card {
40
  new Feature\Auto_Rollback(),
41
  new Feature\Auto_Update_Backup(),
42
  ];
 
 
 
43
  }
44
  }
27
  * @since 1.11.0
28
  */
29
  public function init() {
30
+
31
+ $core = apply_filters( 'boldgrid_backup_get_core', null );
32
+
33
  $this->id = 'bgbkup_updates';
34
 
35
  $this->title = esc_html__( 'Update Management', 'boldgrid-backup' );
43
  new Feature\Auto_Rollback(),
44
  new Feature\Auto_Update_Backup(),
45
  ];
46
+ if ( $core->config->get_is_premium() ) {
47
+ $this->features[] = new Feature\Timely_Auto_Updates();
48
+ }
49
  }
50
  }
admin/card/feature/class-database-encryption.php CHANGED
@@ -31,7 +31,7 @@ class Database_Encryption extends \Boldgrid\Library\Library\Ui\Feature {
31
 
32
  $this->title = esc_html__( 'Database Encryption', 'boldgrid-backup' );
33
 
34
- $this->content = '<p>' . esc_html__( 'Secure your sensitive data with database encryption.', 'boldgrid-backup' ) . '</p>';
35
  $this->content .= '<div class="notice notice-warning inline"><p>' . wp_kses(
36
  sprintf(
37
  // translators: 1 An opening anchor tag to the Remote Storage settings, 2 its closing anchor tag.
31
 
32
  $this->title = esc_html__( 'Database Encryption', 'boldgrid-backup' );
33
 
34
+ $this->content = '<p>' . esc_html__( 'Secure your sensitive data with Database Encryption.', 'boldgrid-backup' ) . '</p>';
35
  $this->content .= '<div class="notice notice-warning inline"><p>' . wp_kses(
36
  sprintf(
37
  // translators: 1 An opening anchor tag to the Remote Storage settings, 2 its closing anchor tag.
admin/card/feature/class-remote-storage.php CHANGED
@@ -55,7 +55,7 @@ class Remote_Storage extends \Boldgrid\Library\Library\Ui\Feature {
55
  $this->content .= '<div class="notice notice-error inline"><p>' . wp_kses(
56
  sprintf(
57
  // translators: 1 An opening anchor tag to the Remote Storage settings, 2 its closing anchor tag.
58
- __( 'Remote storage is not configured. %1$sFix this%2$s', 'boldgrid-backup' ),
59
  '<a href="' . esc_url( $core->settings->get_settings_url( 'section_storage' ) ) . '">',
60
  '</a>'
61
  ),
55
  $this->content .= '<div class="notice notice-error inline"><p>' . wp_kses(
56
  sprintf(
57
  // translators: 1 An opening anchor tag to the Remote Storage settings, 2 its closing anchor tag.
58
+ __( 'Remote Storage is not configured. %1$sFix this%2$s', 'boldgrid-backup' ),
59
  '<a href="' . esc_url( $core->settings->get_settings_url( 'section_storage' ) ) . '">',
60
  '</a>'
61
  ),
admin/card/feature/class-scheduled-backups.php CHANGED
@@ -71,7 +71,7 @@ class Scheduled_Backups extends \Boldgrid\Library\Library\Ui\Feature {
71
  $this->content .= '<div class="notice notice-error inline"><p>' . wp_kses(
72
  sprintf(
73
  // translators: 1 An opening anchor tag to the settings page, 2 its closing tag.
74
- __( 'Scheduled backups not configured. %1$sFix this%2$s.', 'boldgrid-backup' ),
75
  '<a href="' . esc_url( $core->settings->get_settings_url() ) . '">',
76
  '</a>'
77
  ),
71
  $this->content .= '<div class="notice notice-error inline"><p>' . wp_kses(
72
  sprintf(
73
  // translators: 1 An opening anchor tag to the settings page, 2 its closing tag.
74
+ __( 'Scheduled Backups not configured. %1$sFix this%2$s.', 'boldgrid-backup' ),
75
  '<a href="' . esc_url( $core->settings->get_settings_url() ) . '">',
76
  '</a>'
77
  ),
admin/card/feature/class-timely-auto-updates.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Timely_Auto_Updates class.
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since 1.14.0
7
+ *
8
+ * @package Boldgrid\Backup
9
+ * @subpackage Boldgrid\Backup\Feature
10
+ * @copyright BoldGrid
11
+ * @author BoldGrid <support@boldgrid.com>
12
+ */
13
+
14
+ namespace Boldgrid\Backup\Admin\Card\Feature;
15
+
16
+ /**
17
+ * Class: Timely_Auto_Updates.
18
+ *
19
+ * This class is responsible for rendering the, "Timely Auto Updates" feature on the BoldGrid.
20
+ * Backup Dashboard.
21
+ *
22
+ * @since 1.14.0
23
+ */
24
+ class Timely_Auto_Updates extends \Boldgrid\Library\Library\Ui\Feature {
25
+ /**
26
+ * Init.
27
+ *
28
+ * @since 1.14.0
29
+ */
30
+ public function init() {
31
+ $core = apply_filters( 'boldgrid_backup_get_core', null );
32
+
33
+ $this->icon = '<span class="dashicons dashicons-clock"></span>';
34
+
35
+ $this->title = __( 'Timely Auto Updates', 'boldgrid-backup' );
36
+
37
+ // Determine whether or not this feature is enabled.
38
+ $auto_update_settings = $core->settings->get_setting( 'auto_update' );
39
+
40
+ $is_enabled = ! empty( $auto_update_settings['timely-updates-enabled'] );
41
+
42
+ if ( $is_enabled ) {
43
+ $this->content = '<p>' . esc_html__( 'Timely Auto Updates are enabled!', 'boldgrid-backup' ) . '</p>';
44
+ } else {
45
+ $this->content = '<p>' . esc_html__( 'By setting up Timely Auto Updates, you can have more control over when new updates are installed by WordPress.', 'boldgrid-backup' ) . '</p>';
46
+ $this->content .= '<div class="notice notice-warning inline"><p>' . wp_kses(
47
+ sprintf(
48
+ // translators: 1 Opening anchor tag to "Auto Updates" settings page, 2 its closing tag.
49
+ __( 'Timely Auto Updates are not enabled. %1$sFix this%2$s.', 'boldgrid-backup' ),
50
+ '<a href="' . esc_url( $core->settings->get_settings_url( 'section_auto_updates' ) ) . '">',
51
+ '</a>'
52
+ ),
53
+ [ 'a' => [ 'href' => [] ] ]
54
+ ) . '</p></div>';
55
+ }
56
+ }
57
+ }
admin/class-boldgrid-backup-admin-archive-browser.php CHANGED
@@ -322,17 +322,19 @@ class Boldgrid_Backup_Admin_Archive_Browser {
322
  $importer = new Boldgrid_Backup_Admin_Db_Import( $this->core );
323
  $success = $importer->import_from_archive( $filepath, $file );
324
 
325
- if ( ! $success ) {
326
  $this->core->notice->add_user_notice(
327
  // translators: 1: Filename 2: File path.
328
- sprintf( __( 'Error, unable to import database %1$s from %2$s.', 'boldgrid-backup' ), $file, $filepath ),
329
- $this->core->notice->lang['dis_error']
330
  );
 
 
331
  } else {
332
  $this->core->notice->add_user_notice(
333
  // translators: 1: Filename 2: File path.
334
- sprintf( __( 'Success! Database %1$s imported from %2$s.', 'boldgrid-backup' ), $file, $filepath ),
335
- $this->core->notice->lang['dis_success']
336
  );
337
  }
338
  }
322
  $importer = new Boldgrid_Backup_Admin_Db_Import( $this->core );
323
  $success = $importer->import_from_archive( $filepath, $file );
324
 
325
+ if ( true === $success ) {
326
  $this->core->notice->add_user_notice(
327
  // translators: 1: Filename 2: File path.
328
+ sprintf( __( 'Success! Database %1$s imported from %2$s.', 'boldgrid-backup' ), $file, $filepath ),
329
+ $this->core->notice->lang['dis_success']
330
  );
331
+ } elseif ( false !== $success ) {
332
+ $this->core->notice->add_user_notice( $success, $this->core->notice->lang['dis_error'] );
333
  } else {
334
  $this->core->notice->add_user_notice(
335
  // translators: 1: Filename 2: File path.
336
+ sprintf( __( 'Error, unable to import database %1$s from %2$s.', 'boldgrid-backup' ), $file, $filepath ),
337
+ $this->core->notice->lang['dis_error']
338
  );
339
  }
340
  }
admin/class-boldgrid-backup-admin-archive-details.php CHANGED
@@ -161,7 +161,36 @@ class Boldgrid_Backup_Admin_Archive_Details {
161
  $title = $this->core->archive->get_attribute( 'title' );
162
  $description = $this->core->archive->get_attribute( 'description' );
163
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-archive-details.php';
 
 
 
 
165
  }
166
 
167
  /**
161
  $title = $this->core->archive->get_attribute( 'title' );
162
  $description = $this->core->archive->get_attribute( 'description' );
163
 
164
+ $settings = $this->core->settings->get_settings();
165
+ wp_enqueue_style( 'boldgrid-backup-admin-new-thickbox-style' );
166
+ wp_enqueue_style( 'bglib-ui-css' );
167
+
168
+ $in_modal = true;
169
+ $modal = include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-backup-modal.php';
170
+ $in_modal = false;
171
+
172
+ echo '
173
+ <div class="wrap">
174
+ <div id="bglib-page-container" class="bgbkup-page-container">
175
+ <div id="bglib-page-top">
176
+ <div id="bglib-page-header" class="bglib-has-logo">
177
+ <h1>' . esc_html__( 'Total Upkeep Preflight Check', 'boldgrid-backup' ) . '</h1>
178
+ <div class="page-title-actions">
179
+ <a href="#TB_inline?width=800&amp;height=600&amp;inlineId=backup_now_content" class="thickbox page-title-action page-title-action-primary">' .
180
+ esc_html__( 'Backup Site Now', 'boldgrid-backup' ) . '
181
+ </a>
182
+ <a class="page-title-action add-new">' . esc_html__( 'Upload Backup', 'boldgrid-backup' ) . '</a>
183
+ </div>
184
+ </div>
185
+ </div>
186
+ <div id="bglib-page-content">
187
+ <div class="wp-header-end"></div>';
188
+ echo $modal; //phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
189
  include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-archive-details.php';
190
+ echo '
191
+ </div>
192
+ </div>
193
+ </div>';
194
  }
195
 
196
  /**
admin/class-boldgrid-backup-admin-auto-rollback.php CHANGED
@@ -358,27 +358,25 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
358
  * @since 1.6.0
359
  */
360
  public function enqueue_update_selectors() {
361
- if ( $this->on_update_page || $this->core->utility->is_admin_page( 'boldgrid-backup' ) ) {
362
- $handle = 'boldgrid-backup-admin-update-selectors';
363
-
364
- wp_register_script(
365
- $handle,
366
- plugin_dir_url( __FILE__ ) . 'js/boldgrid-backup-admin-update-selectors.js',
367
- array( 'jquery' ),
368
- BOLDGRID_BACKUP_VERSION,
369
- false
370
- );
371
 
372
- $localize_script_data = array(
373
- // Generally used as the title attr of a disable update button.
374
- 'backupInProgress' => __( 'Your website is currently being backed up. You can perform updates when the backup is complete.', 'boldgrid-backup' ),
375
- 'waitClass' => 'bgbu-wait',
376
- );
 
 
 
 
 
 
 
 
377
 
378
- wp_localize_script( $handle, 'boldgrid_backup_admin_update_selectors', $localize_script_data );
379
 
380
- wp_enqueue_script( $handle );
381
- }
382
  }
383
 
384
  /**
358
  * @since 1.6.0
359
  */
360
  public function enqueue_update_selectors() {
361
+ $handle = 'boldgrid-backup-admin-update-selectors';
 
 
 
 
 
 
 
 
 
362
 
363
+ wp_register_script(
364
+ $handle,
365
+ plugin_dir_url( __FILE__ ) . 'js/boldgrid-backup-admin-update-selectors.js',
366
+ array( 'jquery' ),
367
+ BOLDGRID_BACKUP_VERSION,
368
+ false
369
+ );
370
+
371
+ $localize_script_data = array(
372
+ // Generally used as the title attr of a disable update button.
373
+ 'backupInProgress' => __( 'Your website is currently being backed up. You can perform updates when the backup is complete.', 'boldgrid-backup' ),
374
+ 'waitClass' => 'bgbu-wait',
375
+ );
376
 
377
+ wp_localize_script( $handle, 'boldgrid_backup_admin_update_selectors', $localize_script_data );
378
 
379
+ wp_enqueue_script( $handle );
 
380
  }
381
 
382
  /**
admin/class-boldgrid-backup-admin-auto-updates.php ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * File: class-boldgrid-backup-admin-auto-updates.php
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since 1.14.0
7
+ *
8
+ * @package Boldgrid_Backup
9
+ * @subpackage Boldgrid_Backup/admin
10
+ * @copyright BoldGrid
11
+ * @version 1.14.0
12
+ * @author BoldGrid <support@boldgrid.com>
13
+ */
14
+
15
+ use Boldgrid\Library\Library\Plugin\Plugins;
16
+
17
+ /**
18
+ * Class: Boldgrid_Backup_Admin_Auto_Updates.
19
+ *
20
+ * @since 1.14.0
21
+ */
22
+ class Boldgrid_Backup_Admin_Auto_Updates {
23
+ /**
24
+ * Settings.
25
+ *
26
+ * @since 1.14.0
27
+ * @var array
28
+ */
29
+ public $settings;
30
+
31
+ /**
32
+ * Active Plugins.
33
+ *
34
+ * @since 1.14.0
35
+ * @var array
36
+ */
37
+ public $plugins = array();
38
+
39
+ /**
40
+ * Themes.
41
+ *
42
+ * @since 1.14.0
43
+ * @var array
44
+ */
45
+ public $themes = array();
46
+
47
+ /**
48
+ * Active Plugins.
49
+ *
50
+ * @since 1.14.0
51
+ * @var Boldgrid_Backup_Admin_Core
52
+ */
53
+ public $core;
54
+
55
+ /**
56
+ * Constructor.
57
+ *
58
+ * @since 1.14.0
59
+ */
60
+ public function __construct() {
61
+
62
+ $this->set_settings();
63
+ $plugins = new \Boldgrid\Library\Library\Plugin\Plugins();
64
+ $this->plugins = $plugins->getAllPlugins();
65
+ $this->themes = new \Boldgrid\Library\Library\Theme\Themes();
66
+ add_filter( 'automatic_updater_disabled', '__return_false' );
67
+ }
68
+
69
+ /**
70
+ * Set Settings.
71
+ *
72
+ * @since 1.14.0
73
+ */
74
+ public function set_settings() {
75
+ $boldgrid_backup_settings = get_site_option( 'boldgrid_backup_settings', array() );
76
+ if ( isset( $boldgrid_backup_settings['auto_update'] ) ) {
77
+ $this->settings = $boldgrid_backup_settings['auto_update'];
78
+ } else {
79
+ $this->settings = array(
80
+ 'days' => 0,
81
+ );
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Maybe Update Plugin.
87
+ *
88
+ * @since 1.14.0
89
+ *
90
+ * @param string $slug Plugin Slug.
91
+ * @return bool
92
+ */
93
+ public function maybe_update_plugin( $slug ) {
94
+ $days_to_wait = $this->settings['days'];
95
+ $plugin = \Boldgrid\Library\Library\Plugin\Plugins::getBySlug( $this->plugins, $slug );
96
+ $days_since_release = $plugin->updateData->days; //phpcs:ignore WordPress.NamingConventions.ValidVariableName
97
+ $plugin_update_enabled = array_key_exists( $plugin->getFile(), $this->settings['plugins'] ) ? (bool) $this->settings['plugins'][ $plugin->getFile() ] : (bool) $this->settings['plugins']['default'];
98
+ $is_update_time = ( $days_since_release >= $days_to_wait );
99
+ if ( $is_update_time && true === $plugin_update_enabled ) {
100
+ return true;
101
+ } else {
102
+ return false;
103
+ }
104
+ }
105
+
106
+ /**
107
+ * Maybe Update Theme.
108
+ *
109
+ * @since 1.14.0
110
+ *
111
+ * @param string $stylesheet Theme's Stylesheet.
112
+ * @return bool
113
+ */
114
+ public function maybe_update_theme( $stylesheet ) {
115
+ $days_to_wait = $this->settings['days'];
116
+ $theme = $this->themes->getFromStylesheet( $stylesheet );
117
+ $days_since_release = $theme->updateData->days; //phpcs:ignore WordPress.NamingConventions.ValidVariableName
118
+ $theme_update_enabled = isset( $this->settings['themes'][ $stylesheet ] ) ? (bool) $this->settings['themes'][ $stylesheet ] : (bool) $this->settings['plugins']['default'];
119
+ $is_update_time = ( $days_since_release >= $days_to_wait );
120
+
121
+ if ( $is_update_time && true === $theme_update_enabled ) {
122
+ return true;
123
+ } else {
124
+ return false;
125
+ }
126
+ }
127
+
128
+ /**
129
+ * Auto Update Plugins.
130
+ *
131
+ * This method is the callback for the 'auto_update_plugin' action hook.
132
+ *
133
+ * @since 1.14.0
134
+ *
135
+ * @param bool $update Whether or not to update.
136
+ * @param stdClass $item The item class passed to callback.
137
+ * @return bool
138
+ */
139
+ public function auto_update_plugins( $update, stdClass $item ) {
140
+ // Array of plugin slugs to always auto-update.
141
+ $plugins = array();
142
+ foreach ( $this->plugins as $plugin ) {
143
+ if ( $this->maybe_update_plugin( $plugin->getSlug() ) ) {
144
+ $plugins[] = $plugin->getSlug();
145
+ }
146
+ }
147
+ if ( in_array( $item->slug, $plugins, true ) ) {
148
+ // Always update plugins in this array.
149
+ return true;
150
+ } else {
151
+ // Else, Do Not Update Plugin.
152
+ return false;
153
+ }
154
+ }
155
+
156
+ /**
157
+ * Auto Update Themes.
158
+ *
159
+ * This method is the callback for the 'auto_update_theme' action hook.
160
+ *
161
+ * @since 1.14.0
162
+ *
163
+ * @param bool $update Whether or not to update.
164
+ * @param stdClass $item The item class passed to callback.
165
+ * @return bool
166
+ */
167
+ public function auto_update_themes( $update, stdClass $item ) {
168
+ // Array of theme stylesheets to always auto-update.
169
+ $themes = array();
170
+ foreach ( $this->themes->get() as $theme ) {
171
+ if ( $this->maybe_update_theme( $theme->stylesheet ) ) {
172
+ $themes[] = $theme->stylesheet;
173
+ }
174
+ }
175
+ if ( in_array( $item->theme, $themes, true ) ) {
176
+ // Always update themes in this array.
177
+ return true;
178
+ } else {
179
+ // Else, Do Not Update theme.
180
+ return false;
181
+ }
182
+ }
183
+
184
+ /**
185
+ * Auto Update Core.
186
+ *
187
+ * Sets the type of updates to perform for wpcore.
188
+ *
189
+ * @since 1.14.0
190
+ */
191
+ public function auto_update_core() {
192
+ $wpcs_default = array(
193
+ 'all' => false,
194
+ 'minor' => true,
195
+ 'major' => false,
196
+ 'translation' => false,
197
+ 'dev' => false,
198
+ );
199
+
200
+ $wpcs = isset( $this->settings['wpcore'] ) ? $this->settings['wpcore'] : $wpcs_default;
201
+ if ( $wpcs['all'] ) {
202
+ add_filter( 'auto_update_core', '__return_true' );
203
+ }
204
+
205
+ $dev = ( $wpcs['dev'] ) ? 'true' : 'false';
206
+ $major = ( $wpcs['major'] ) ? 'true' : 'false';
207
+ $minor = ( $wpcs['minor'] ) ? 'true' : 'false';
208
+ $translation = ( $wpcs['translation'] ) ? 'true' : 'false';
209
+
210
+ add_filter( 'allow_major_auto_core_updates', '__return_' . $major );
211
+ add_filter( 'allow_minor_auto_core_updates', '__return_' . $minor );
212
+ add_filter( 'auto_update_translation', '__return_' . $translation );
213
+ add_filter( 'allow_dev_auto_core_updates', '__return_' . $dev );
214
+ }
215
+ }
admin/class-boldgrid-backup-admin-core.php CHANGED
@@ -374,6 +374,14 @@ class Boldgrid_Backup_Admin_Core {
374
  */
375
  public $db_omit;
376
 
 
 
 
 
 
 
 
 
377
  /**
378
  * An instance of Boldgrid_Backup_Admin_Filelist.
379
  *
@@ -554,6 +562,14 @@ class Boldgrid_Backup_Admin_Core {
554
  */
555
  public $activity;
556
 
 
 
 
 
 
 
 
 
557
  /**
558
  * Constructor.
559
  *
@@ -682,9 +698,12 @@ class Boldgrid_Backup_Admin_Core {
682
  $this->dashboard = new Boldgrid_Backup_Admin_Dashboard( $this );
683
 
684
  // Instantiate Boldgrid\Library\Library\Plugin\Plugin.
685
- $this->plugin = new \Boldgrid\Library\Library\Plugin\Plugin( 'boldgrid-backup', $this->configs );
686
  $this->premium_page = new Boldgrid_Backup_Admin_Premium_Features( $this );
687
 
 
 
 
688
  // Ensure there is a backup identifier.
689
  $this->get_backup_identifier();
690
 
@@ -1242,6 +1261,7 @@ class Boldgrid_Backup_Admin_Core {
1242
  $status = $importer->import( $db_dump_filepath );
1243
 
1244
  if ( ! empty( $status['error'] ) ) {
 
1245
  do_action( 'boldgrid_backup_notice', $status['error'], 'notice notice-error is-dismissible' );
1246
  return false;
1247
  }
@@ -2361,7 +2381,12 @@ class Boldgrid_Backup_Admin_Core {
2361
  $this->wp_filesystem->delete( $db_dump_filepath, false, 'f' );
2362
 
2363
  // Display notice of deletion status.
2364
- if ( ! $restore_ok ) {
 
 
 
 
 
2365
  return [
2366
  'error' => esc_html__( 'Could not restore database.', 'boldgrid-backup' ),
2367
  ];
@@ -2408,7 +2433,6 @@ class Boldgrid_Backup_Admin_Core {
2408
  global $pagenow;
2409
 
2410
  // Thickbox used for Backup Site Now modal.
2411
- add_thickbox();
2412
  wp_enqueue_style( 'boldgrid-backup-admin-new-thickbox-style' );
2413
 
2414
  wp_enqueue_style( 'bglib-ui-css' );
@@ -2505,6 +2529,11 @@ class Boldgrid_Backup_Admin_Core {
2505
  // If there were any errors encountered during the backup, save them to the In Progress data.
2506
  if ( ! empty( $archive_info['error'] ) ) {
2507
  Boldgrid_Backup_Admin_In_Progress_Data::set_arg( 'error', $archive_info['error'] );
 
 
 
 
 
2508
  }
2509
 
2510
  if ( $this->is_archiving_update_protection ) {
@@ -2674,8 +2703,43 @@ class Boldgrid_Backup_Admin_Core {
2674
  BOLDGRID_BACKUP_VERSION, 'all'
2675
  );
2676
 
2677
- // Load template view.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2678
  include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-test.php';
 
 
 
 
2679
  }
2680
 
2681
  /**
@@ -2929,4 +2993,15 @@ class Boldgrid_Backup_Admin_Core {
2929
  $counter --;
2930
  }
2931
  }
 
 
 
 
 
 
 
 
 
 
 
2932
  }
374
  */
375
  public $db_omit;
376
 
377
+ /**
378
+ * Database Restoration errro
379
+ *
380
+ * @since 1.14.0
381
+ * @var string
382
+ */
383
+ public $db_restore_error;
384
+
385
  /**
386
  * An instance of Boldgrid_Backup_Admin_Filelist.
387
  *
562
  */
563
  public $activity;
564
 
565
+ /**
566
+ * An instance of the Auto Updates class
567
+ *
568
+ * @since 1.14.0
569
+ * @var Boldgrid_Backup_Admin_Auto_Updates
570
+ */
571
+ public $auto_updates;
572
+
573
  /**
574
  * Constructor.
575
  *
698
  $this->dashboard = new Boldgrid_Backup_Admin_Dashboard( $this );
699
 
700
  // Instantiate Boldgrid\Library\Library\Plugin\Plugin.
701
+ $this->plugin = \Boldgrid\Library\Library\Plugin\Factory::create( 'boldgrid-backup', $this->configs );
702
  $this->premium_page = new Boldgrid_Backup_Admin_Premium_Features( $this );
703
 
704
+ // Instantiate Boldgrid_Backup_Admin_Auto_Updates.
705
+ $this->auto_updates = new Boldgrid_Backup_Admin_Auto_Updates();
706
+
707
  // Ensure there is a backup identifier.
708
  $this->get_backup_identifier();
709
 
1261
  $status = $importer->import( $db_dump_filepath );
1262
 
1263
  if ( ! empty( $status['error'] ) ) {
1264
+ $this->db_restore_error = $status['error'];
1265
  do_action( 'boldgrid_backup_notice', $status['error'], 'notice notice-error is-dismissible' );
1266
  return false;
1267
  }
2381
  $this->wp_filesystem->delete( $db_dump_filepath, false, 'f' );
2382
 
2383
  // Display notice of deletion status.
2384
+ if ( ! $restore_ok && $this->db_restore_error ) {
2385
+ return [
2386
+ 'error' => $this->db_restore_error,
2387
+ ];
2388
+ }
2389
+ if ( ! $restore_ok && ! $this->db_restore_error ) {
2390
  return [
2391
  'error' => esc_html__( 'Could not restore database.', 'boldgrid-backup' ),
2392
  ];
2433
  global $pagenow;
2434
 
2435
  // Thickbox used for Backup Site Now modal.
 
2436
  wp_enqueue_style( 'boldgrid-backup-admin-new-thickbox-style' );
2437
 
2438
  wp_enqueue_style( 'bglib-ui-css' );
2529
  // If there were any errors encountered during the backup, save them to the In Progress data.
2530
  if ( ! empty( $archive_info['error'] ) ) {
2531
  Boldgrid_Backup_Admin_In_Progress_Data::set_arg( 'error', $archive_info['error'] );
2532
+ $this->notice->add_user_notice(
2533
+ '<p>' . $archive_info['error'] . '</p>',
2534
+ 'notice notice-error is-dismissible',
2535
+ 'Backup Failed'
2536
+ );
2537
  }
2538
 
2539
  if ( $this->is_archiving_update_protection ) {
2703
  BOLDGRID_BACKUP_VERSION, 'all'
2704
  );
2705
 
2706
+ $settings = $this->settings->get_settings();
2707
+ wp_enqueue_style( 'boldgrid-backup-admin-new-thickbox-style' );
2708
+ wp_enqueue_style( 'bglib-ui-css' );
2709
+
2710
+ $this->auto_rollback->enqueue_home_scripts();
2711
+ $this->auto_rollback->enqueue_backup_scripts();
2712
+ $this->archive_actions->enqueue_scripts();
2713
+
2714
+ $this->folder_exclusion->enqueue_scripts();
2715
+ $this->db_omit->enqueue_scripts();
2716
+
2717
+ $in_modal = true;
2718
+ $modal = include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-backup-modal.php';
2719
+ $in_modal = false;
2720
+
2721
+ echo '
2722
+ <div class="wrap">
2723
+ <div id="bglib-page-container" class="bgbkup-page-container">
2724
+ <div id="bglib-page-top">
2725
+ <div id="bglib-page-header" class="bglib-has-logo">
2726
+ <h1>' . esc_html__( 'Total Upkeep Preflight Check', 'boldgrid-backup' ) . '</h1>
2727
+ <div class="page-title-actions">
2728
+ <a href="#TB_inline?width=800&amp;height=600&amp;inlineId=backup_now_content" class="thickbox page-title-action page-title-action-primary">' .
2729
+ esc_html__( 'Backup Site Now', 'boldgrid-backup' ) . '
2730
+ </a>
2731
+ <a class="page-title-action add-new">' . esc_html__( 'Upload Backup', 'boldgrid-backup' ) . '</a>
2732
+ </div>
2733
+ </div>
2734
+ </div>
2735
+ <div id="bglib-page-content">
2736
+ <div class="wp-header-end"></div>';
2737
+ echo $modal; //phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
2738
  include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-test.php';
2739
+ echo '
2740
+ </div>
2741
+ </div>
2742
+ </div>';
2743
  }
2744
 
2745
  /**
2993
  $counter --;
2994
  }
2995
  }
2996
+
2997
+ /**
2998
+ * Add thickbox to bolgrid_backup admin pages.
2999
+ *
3000
+ * @since 1.14.0
3001
+ */
3002
+ public function add_thickbox( $hook_suffix ) {
3003
+ if ( false !== strpos( $hook_suffix, 'boldgrid-backup' ) ) {
3004
+ add_thickbox();
3005
+ }
3006
+ }
3007
  }
admin/class-boldgrid-backup-admin-dashboard.php CHANGED
@@ -79,6 +79,42 @@ class Boldgrid_Backup_Admin_Dashboard {
79
  * @since 1.11.0
80
  */
81
  public function page() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-dashboard.php';
 
 
 
 
83
  }
84
  }
79
  * @since 1.11.0
80
  */
81
  public function page() {
82
+ $settings = $this->core->settings->get_settings();
83
+ wp_enqueue_style( 'boldgrid-backup-admin-new-thickbox-style' );
84
+ wp_enqueue_style( 'bglib-ui-css' );
85
+
86
+ $this->core->auto_rollback->enqueue_home_scripts();
87
+ $this->core->auto_rollback->enqueue_backup_scripts();
88
+ $this->core->archive_actions->enqueue_scripts();
89
+
90
+ $this->core->folder_exclusion->enqueue_scripts();
91
+ $this->core->db_omit->enqueue_scripts();
92
+
93
+ $in_modal = true;
94
+ $modal = include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-backup-modal.php';
95
+ $in_modal = false;
96
+
97
+ echo '
98
+ <div class="wrap">
99
+ <div id="bglib-page-container" class="bgbkup-page-container">
100
+ <div id="bglib-page-top">
101
+ <div id="bglib-page-header" class="bglib-has-logo">
102
+ <h1>' . esc_html( BOLDGRID_BACKUP_TITLE . ' ' . __( 'Dashboard', 'boldgrid-backup' ) ) . '</h1>
103
+ <div class="page-title-actions">
104
+ <a href="#TB_inline?width=800&amp;height=600&amp;inlineId=backup_now_content" class="thickbox page-title-action page-title-action-primary">' .
105
+ esc_html__( 'Backup Site Now', 'boldgrid-backup' ) . '
106
+ </a>
107
+ <a class="page-title-action add-new">' . esc_html__( 'Upload Backup', 'boldgrid-backup' ) . '</a>
108
+ </div>
109
+ </div>
110
+ </div>
111
+ <div id="bglib-page-content">
112
+ <div class="wp-header-end"></div>';
113
+ echo $modal; //phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
114
  include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-dashboard.php';
115
+ echo '
116
+ </div>
117
+ </div>
118
+ </div>';
119
  }
120
  }
admin/class-boldgrid-backup-admin-db-dump.php CHANGED
@@ -63,7 +63,8 @@ class Boldgrid_Backup_Admin_Db_Dump {
63
  *
64
  * In the list below, it is important that $include_tables is processed last.
65
  */
66
- $include_views = $this->core->db_get->filter_by_type( $include_tables, 'VIEW' );
 
67
  $include_tables = $this->core->db_get->filter_by_type( $include_tables, 'BASE TABLE' );
68
 
69
  Boldgrid_Backup_Admin_In_Progress_Data::set_args(
@@ -81,6 +82,19 @@ class Boldgrid_Backup_Admin_Db_Dump {
81
  */
82
  do_action( 'boldgrid_backup_pre_dump', $file );
83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  try {
85
  $dump = new IMysqldump\Mysqldump(
86
  $this->get_connection_string(),
63
  *
64
  * In the list below, it is important that $include_tables is processed last.
65
  */
66
+ $include_views = $this->core->db_get->filter_by_type( $include_tables, 'VIEW' );
67
+
68
  $include_tables = $this->core->db_get->filter_by_type( $include_tables, 'BASE TABLE' );
69
 
70
  Boldgrid_Backup_Admin_In_Progress_Data::set_args(
82
  */
83
  do_action( 'boldgrid_backup_pre_dump', $file );
84
 
85
+ if ( ! empty( $include_views ) ) {
86
+ $db_import = new Boldgrid_Backup_Admin_Db_Import();
87
+ $user_has_privileges = $db_import->has_db_privileges( array( 'SHOW VIEW' ) );
88
+ if ( false === $user_has_privileges ) {
89
+ return array(
90
+ 'error' => esc_html__(
91
+ 'The database contains VIEWS, but the database user does not have the permissions needed to create a backup.',
92
+ 'boldgrid-backup'
93
+ ),
94
+ );
95
+ }
96
+ }
97
+
98
  try {
99
  $dump = new IMysqldump\Mysqldump(
100
  $this->get_connection_string(),
admin/class-boldgrid-backup-admin-db-import.php CHANGED
@@ -13,7 +13,7 @@
13
  */
14
 
15
  /**
16
- * Class: Boldgrid_Backup_Admin_Db_Import
17
  *
18
  * @since 1.5.1
19
  */
@@ -22,8 +22,8 @@ class Boldgrid_Backup_Admin_Db_Import {
22
  * The core class object.
23
  *
24
  * @since 1.6.0
25
- * @access private
26
  * @var Boldgrid_Backup_Admin_Core
 
27
  */
28
  private $core;
29
 
@@ -49,6 +49,23 @@ class Boldgrid_Backup_Admin_Db_Import {
49
  }
50
  }
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  /**
53
  * Import a mysqldump.
54
  *
@@ -58,7 +75,7 @@ class Boldgrid_Backup_Admin_Db_Import {
58
  * @return bool TRUE on success.
59
  */
60
  public function import( $file ) {
61
- $lines = file( $file );
62
 
63
  if ( false === $lines ) {
64
  return array(
@@ -70,6 +87,18 @@ class Boldgrid_Backup_Admin_Db_Import {
70
  );
71
  }
72
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  $success = $this->import_lines( $lines );
74
 
75
  return $success;
@@ -78,8 +107,7 @@ class Boldgrid_Backup_Admin_Db_Import {
78
  /**
79
  * Import a database dump from an archive.
80
  *
81
- * Pass in "file.zip" and "backup.sql" and we'll find "backup.sql" in the
82
- * "file.zip" file and restore it.
83
  *
84
  * @since 1.6.0
85
  *
@@ -90,8 +118,7 @@ class Boldgrid_Backup_Admin_Db_Import {
90
  public function import_from_archive( $archive_filepath, $file ) {
91
  $this->core->archive->init( $archive_filepath );
92
  $file_contents = $this->core->archive->get_dump_file( $file );
93
-
94
- $sql = ! empty( $file_contents[0]['content'] ) ? $file_contents[0]['content'] : null;
95
  if ( empty( $sql ) ) {
96
  $this->errors[] = __( 'Unable to get contents of file.', 'boldgrid-backup' );
97
  return false;
@@ -105,8 +132,7 @@ class Boldgrid_Backup_Admin_Db_Import {
105
  /**
106
  * Import lines (queries).
107
  *
108
- * This method accepts an array of $lines, and loops through each $line and
109
- * imports it.
110
  *
111
  * These lines usually come from either a .sql file, or a string is parsed
112
  * into separate lines.
@@ -139,7 +165,7 @@ class Boldgrid_Backup_Admin_Db_Import {
139
 
140
  // Check if this is the end of the query.
141
  if ( substr( trim( $line ), -1, 1 ) === ';' ) {
142
- $affected_rows = $db->exec( $templine );
143
  if ( false === $affected_rows ) {
144
  return false;
145
  }
@@ -154,9 +180,8 @@ class Boldgrid_Backup_Admin_Db_Import {
154
  /**
155
  * Import a string into a database.
156
  *
157
- * Generally this method is used when we grab a .sql file from within a .zip
158
- * file and import it. Instead of saving the .sql file then importing, it
159
- * comes straight from the .zip file as a string to here.
160
  *
161
  * @since 1.6.0
162
  *
@@ -166,8 +191,187 @@ class Boldgrid_Backup_Admin_Db_Import {
166
  public function import_string( $string ) {
167
  $lines = preg_split( "/\\r\\n|\\r|\\n/", $string );
168
 
 
 
 
 
 
 
169
  $success = $this->import_lines( $lines );
170
 
171
  return $success;
172
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
  }
13
  */
14
 
15
  /**
16
+ * Class: Boldgrid_Backup_Admin_Db_Import.
17
  *
18
  * @since 1.5.1
19
  */
22
  * The core class object.
23
  *
24
  * @since 1.6.0
 
25
  * @var Boldgrid_Backup_Admin_Core
26
+ * @access private
27
  */
28
  private $core;
29
 
49
  }
50
  }
51
 
52
+ /**
53
+ * Get Lines from file.
54
+ *
55
+ * Gets an array of lines from a file.
56
+ *
57
+ * @since 1.14.0
58
+ *
59
+ * @param string $file String ocntaining the path of the file.
60
+ *
61
+ * @return array An array of lines.
62
+ */
63
+ public function get_lines( $file ) {
64
+ if ( false === file_exists( $file ) ) {
65
+ return false;
66
+ }
67
+ return file( $file );
68
+ }
69
  /**
70
  * Import a mysqldump.
71
  *
75
  * @return bool TRUE on success.
76
  */
77
  public function import( $file ) {
78
+ $lines = $this->get_lines( $file );
79
 
80
  if ( false === $lines ) {
81
  return array(
87
  );
88
  }
89
 
90
+ $lines = $this->fix_view_statements( $lines );
91
+
92
+ if ( true === empty( $lines ) ) {
93
+ return array(
94
+ 'error' => sprintf(
95
+ /* translators: 1: Database File Name */
96
+ __( 'MySQL Database User does not have necessary priviliges to restore mysqldump, %1$s.', 'boldgrid-backup' ),
97
+ $file
98
+ ),
99
+ );
100
+ }
101
+
102
  $success = $this->import_lines( $lines );
103
 
104
  return $success;
107
  /**
108
  * Import a database dump from an archive.
109
  *
110
+ * Pass in "file.zip" and "backup.sql" and we'll find "backup.sql" in the file.zip file and restore it.
 
111
  *
112
  * @since 1.6.0
113
  *
118
  public function import_from_archive( $archive_filepath, $file ) {
119
  $this->core->archive->init( $archive_filepath );
120
  $file_contents = $this->core->archive->get_dump_file( $file );
121
+ $sql = ! empty( $file_contents[0]['content'] ) ? $file_contents[0]['content'] : null;
 
122
  if ( empty( $sql ) ) {
123
  $this->errors[] = __( 'Unable to get contents of file.', 'boldgrid-backup' );
124
  return false;
132
  /**
133
  * Import lines (queries).
134
  *
135
+ * This method accepts an array of $lines, and loops through each $line and imports it.
 
136
  *
137
  * These lines usually come from either a .sql file, or a string is parsed
138
  * into separate lines.
165
 
166
  // Check if this is the end of the query.
167
  if ( substr( trim( $line ), -1, 1 ) === ';' ) {
168
+ $affected_rows = $this->exec_import( $db, $templine );
169
  if ( false === $affected_rows ) {
170
  return false;
171
  }
180
  /**
181
  * Import a string into a database.
182
  *
183
+ * Generally this method is used when we grab a .sql file from within a .zip file and import it.
184
+ * Instead of saving the .sql file then importing, it comes straight from the .zip file as a string to here.
 
185
  *
186
  * @since 1.6.0
187
  *
191
  public function import_string( $string ) {
192
  $lines = preg_split( "/\\r\\n|\\r|\\n/", $string );
193
 
194
+ $lines = $this->fix_view_statements( $lines );
195
+
196
+ if ( true === empty( $lines ) ) {
197
+ return __( 'The Database User does not have the necessary priviliges to restore this database.', 'boldgrid-backup' );
198
+ }
199
+
200
  $success = $this->import_lines( $lines );
201
 
202
  return $success;
203
  }
204
+
205
+ /**
206
+ * Fix View Statements.
207
+ *
208
+ * Fixes view statements to ensure the definer matches the current db user.
209
+ *
210
+ * @since 1.14.0
211
+ *
212
+ * @param array $lines An array of lines from db file.
213
+ * @return array
214
+ */
215
+ public function fix_view_statements( array $lines ) {
216
+
217
+ $has_drop_view_if_exists = false;
218
+
219
+ foreach ( $lines as $line ) {
220
+ if ( strpos( $line, 'DROP VIEW IF EXISTS' ) ) {
221
+ $has_drop_view_if_exists = true;
222
+ }
223
+ }
224
+
225
+ if ( false === $has_drop_view_if_exists ) {
226
+ return $lines;
227
+ }
228
+
229
+ $user_has_privileges = $this->has_db_privileges( array( 'SHOW VIEW', 'CREATE VIEW' ) );
230
+
231
+ if ( false === $user_has_privileges ) {
232
+ return array();
233
+ }
234
+
235
+ $fixed_lines = array();
236
+
237
+ foreach ( $lines as $line ) {
238
+ if ( strpos( $line, 'DEFINER=' ) === 9 ) {
239
+ $fixed_lines[] = $this->fix_definer( $line );
240
+ } else {
241
+ $fixed_lines[] = $line;
242
+ }
243
+ }
244
+
245
+ return $fixed_lines;
246
+ }
247
+
248
+ /**
249
+ * Fix Definer.
250
+ *
251
+ * Fixes the actual definer line.
252
+ *
253
+ * @since 1.14.0
254
+ *
255
+ * @param string $line The line from db dump file to fix.
256
+ * @return string The line with the DEFINER option removed.
257
+ */
258
+ public function fix_definer( $line ) {
259
+ $line_fixed_definer = '';
260
+ $sql_security_offset = strpos( $line, 'SQL SECURITY' );
261
+ $line_fixed_definer = substr( $line, 0, 9 );
262
+ if ( strpos( $line, '@`%`' ) ) {
263
+ $line_fixed_definer .= 'DEFINER=`' . DB_USER . '`@`%` ';
264
+ } else {
265
+ $line_fixed_definer .= 'DEFINER=`' . DB_USER . '`@`' . DB_HOST . '` ';
266
+ }
267
+
268
+ if ( strpos( $line, 'SQL SECURITY' ) ) {
269
+ $line_fixed_definer .= subStr( $line, $sql_security_offset );
270
+ } else {
271
+ $line_fixed_definer .= '*/';
272
+ }
273
+
274
+ return $line_fixed_definer;
275
+ }
276
+
277
+ /**
278
+ * Tests if database user has specific privileges.
279
+ *
280
+ * @since 1.14.0
281
+ *
282
+ * @param array $privileges An array of permissions to check against.
283
+ * @return bool True if user has specified privileges.
284
+ */
285
+ public function has_db_privileges( array $privileges ) {
286
+ $user_grants = $this->get_db_privileges();
287
+ if ( in_array( 'ALL', $user_grants, true ) ) {
288
+ return true;
289
+ }
290
+ if ( count( $privileges ) === count( array_intersect( $privileges, $user_grants ) ) ) {
291
+ return true;
292
+ }
293
+ return false;
294
+ }
295
+
296
+ /**
297
+ * Get database user privileges.
298
+ *
299
+ * @since 1.14.0
300
+ *
301
+ * @global wpdb $wpdb The WordPress database class object.
302
+ *
303
+ * @return array An array of database user privileges.
304
+ */
305
+ public function get_db_privileges() {
306
+ $results = $this->show_grants_query();
307
+
308
+ foreach ( $results as $result ) {
309
+ $result[0] = str_replace( '\\', '', $result[0] );
310
+ $is_string_db_grant = ( false !== strpos( $result[0], 'ON `' . DB_NAME . '`' ) );
311
+ $is_string_all_grant = ( false !== strpos( $result[0], 'ON *.*' ) );
312
+ $is_grant_all_privileges = ( false !== strpos( $result[0], 'GRANT ALL PRIVILEGES' ) );
313
+
314
+ if ( ( $is_string_db_grant || $is_string_all_grant ) && $is_grant_all_privileges ) {
315
+ return array( 'ALL' );
316
+ }
317
+ if ( ( $is_string_db_grant ) && false === $is_grant_all_privileges ) {
318
+ return $this->get_grants_array( $result[0] );
319
+ }
320
+ }
321
+ return array();
322
+ }
323
+
324
+ /**
325
+ * Show Grants Query.
326
+ *
327
+ * Queries the database for 'SHOW GRANTS'.
328
+ *
329
+ * @since 1.14.0
330
+ *
331
+ * @return array an array of results from the database query
332
+ */
333
+ public function show_grants_query() {
334
+ $db = new PDO( sprintf( 'mysql:host=%1$s;dbname=%2$s;', DB_HOST, DB_NAME ), DB_USER, DB_PASSWORD );
335
+ $db_statement = $db->query( 'SHOW GRANTS' );
336
+ return $db_statement->fetchAll();
337
+ }
338
+
339
+ /**
340
+ * Execute Import.
341
+ *
342
+ * Executes Import MySql Query.
343
+ *
344
+ * @since 1.14.0
345
+ *
346
+ * @param PDO $db The PDO Object.
347
+ * @param string $sql_line The line of sql to execute.
348
+ *
349
+ * @return int Number of affected rows
350
+ */
351
+ public function exec_import( PDO $db, $sql_line ) {
352
+ return $db->exec( $sql_line );
353
+ }
354
+
355
+ /**
356
+ * Get a user's grants in the form of an array.
357
+ *
358
+ * @since 1.14.0
359
+ *
360
+ * @param string $grants_string A string containing the user's grants.
361
+ * @return array
362
+ */
363
+ public function get_grants_array( $grants_string ) {
364
+ $expected_grants_string_start = 6;
365
+
366
+ if ( strpos( $grants_string, 'GRANT' ) === 0 ) {
367
+ $grants_string = substr( $grants_string, $expected_grants_string_start );
368
+ }
369
+
370
+ $on_strpos = strpos( $grants_string, ' ON ' );
371
+ if ( $on_strpos ) {
372
+ $grants_string = substr( $grants_string, 0, $on_strpos );
373
+ }
374
+
375
+ return explode( ', ', $grants_string );
376
+ }
377
  }
admin/class-boldgrid-backup-admin-db-omit.php CHANGED
@@ -101,7 +101,7 @@ class Boldgrid_Backup_Admin_Db_Omit {
101
  $handle = 'boldgrid-backup-admin-table-include';
102
  wp_register_script(
103
  $handle,
104
- plugin_dir_url( __FILE__ ) . 'js/boldgrid-backup-admin-table-include.js',
105
  array( 'jquery' ),
106
  BOLDGRID_BACKUP_VERSION,
107
  false
101
  $handle = 'boldgrid-backup-admin-table-include';
102
  wp_register_script(
103
  $handle,
104
+ plugin_dir_url( __FILE__ ) . 'js/boldgrid-backup-admin-table-includes.js',
105
  array( 'jquery' ),
106
  BOLDGRID_BACKUP_VERSION,
107
  false
admin/class-boldgrid-backup-admin-go-pro.php CHANGED
@@ -90,7 +90,7 @@ class Boldgrid_Backup_Admin_Go_Pro {
90
 
91
  $is_premium = $this->core->config->get_is_premium();
92
 
93
- $premium_plugin = new \Boldgrid\Library\Library\Plugin\Plugin( 'boldgrid-backup-premium' );
94
 
95
  $notices = [
96
  [
90
 
91
  $is_premium = $this->core->config->get_is_premium();
92
 
93
+ $premium_plugin = \Boldgrid\Library\Library\Plugin\Factory::create( 'boldgrid-backup-premium' );
94
 
95
  $notices = [
96
  [
admin/class-boldgrid-backup-admin-notice.php CHANGED
@@ -236,15 +236,54 @@ class Boldgrid_Backup_Admin_Notice {
236
  * @since 1.7.0
237
  */
238
  public function display_autoupdate_notice() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
  $message = sprintf(
240
  // translators: 1: HTML anchor opening tag, 2: HTML anchor closing tag, 3: Plugin title.
241
  esc_html__(
242
- 'Auto Updates can be configured in the %1$s%3$s Settings%2$s.',
243
  'boldgrid-backup'
244
  ),
245
  '<a href="' . admin_url( 'admin.php?page=boldgrid-backup-settings&section=section_auto_updates' ) . '">',
246
  '</a>',
247
- BOLDGRID_BACKUP_TITLE
 
248
  );
249
 
250
  do_action( 'boldgrid_backup_notice', $message, 'notice notice-info is-dismissible' );
@@ -261,7 +300,7 @@ class Boldgrid_Backup_Admin_Notice {
261
  * @see \Boldgrid\Library\Library\Notice::show()
262
  */
263
  public function plugin_renamed_notice() {
264
- $plugin = new \Boldgrid\Library\Library\Plugin\Plugin( 'boldgrid-backup' );
265
 
266
  /*
267
  * Only show to existing users.
236
  * @since 1.7.0
237
  */
238
  public function display_autoupdate_notice() {
239
+ $auto_update_array = [
240
+ ( apply_filters( 'allow_major_auto_core_updates', false ) ) ? 'Major' : false,
241
+ ( apply_filters( 'allow_minor_auto_core_updates', false ) ) ? 'Minor' : false,
242
+ ( apply_filters( 'allow_dev_auto_core_updates', false ) ) ? 'Development' : false,
243
+ ( apply_filters( 'auto_update_translation', false ) ) ? 'Translation' : false,
244
+ ];
245
+ $auto_update_array = array_filter( $auto_update_array );
246
+ $update_msg = '';
247
+ switch ( count( $auto_update_array ) ) {
248
+ case 0:
249
+ $update_msg = esc_html__( 'disabled for all', 'boldgrid-backup' );
250
+ break;
251
+ case 1:
252
+ $update_msg = sprintf(
253
+ // translators: 1: Auto Update Type.
254
+ esc_html__( 'enabled for %s', 'boldgrid-backup' ),
255
+ $auto_update_array[0]
256
+ );
257
+ break;
258
+ case 4:
259
+ $update_msg = esc_html__( 'enabled for all', 'boldgrid-backup' );
260
+ break;
261
+ default:
262
+ $x = array_slice( $auto_update_array, 0, -1 );
263
+
264
+ $auto_update_string = implode( ', ', $x );
265
+ $update_msg = sprintf(
266
+ // translators: 1: Auto Update Types, 2: Auto Update Type.
267
+ esc_html__(
268
+ 'enabled for %1$s and %2$s',
269
+ 'boldgrid-backup'
270
+ ),
271
+ $auto_update_string,
272
+ end( $auto_update_array )
273
+ );
274
+ break;
275
+ }
276
+
277
  $message = sprintf(
278
  // translators: 1: HTML anchor opening tag, 2: HTML anchor closing tag, 3: Plugin title.
279
  esc_html__(
280
+ 'Auto Updates are %4$s WordPress Core Updates. This can be configured in the %1$s%3$s Settings%2$s.',
281
  'boldgrid-backup'
282
  ),
283
  '<a href="' . admin_url( 'admin.php?page=boldgrid-backup-settings&section=section_auto_updates' ) . '">',
284
  '</a>',
285
+ BOLDGRID_BACKUP_TITLE,
286
+ $update_msg
287
  );
288
 
289
  do_action( 'boldgrid_backup_notice', $message, 'notice notice-info is-dismissible' );
300
  * @see \Boldgrid\Library\Library\Notice::show()
301
  */
302
  public function plugin_renamed_notice() {
303
+ $plugin = \Boldgrid\Library\Library\Plugin\Factory::create( 'boldgrid-backup' );
304
 
305
  /*
306
  * Only show to existing users.
admin/class-boldgrid-backup-admin-premium-features.php CHANGED
@@ -78,6 +78,7 @@ class Boldgrid_Backup_Admin_Premium_Features {
78
 
79
  $this->page = $plugin->getPageBySlug( 'boldgrid-backup-premium-features' );
80
  $cards = [
 
81
  new Card\Database_Encryption( $this->page ),
82
  new Card\Google_Drive( $this->page ),
83
  new Card\Amazon_S3( $this->page ),
@@ -101,9 +102,45 @@ class Boldgrid_Backup_Admin_Premium_Features {
101
  */
102
  public function page() {
103
  wp_enqueue_style( 'bglib-ui-css' );
 
 
 
 
 
 
 
 
 
 
 
 
 
104
 
105
  $this->admin_enqueue_scripts( 'boldgrid-backup-admin-premium-features' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-premium.php';
 
 
 
 
 
107
  $this->page->setAllNoticesRead();
108
  return array(
109
  'nav' => $nav,
78
 
79
  $this->page = $plugin->getPageBySlug( 'boldgrid-backup-premium-features' );
80
  $cards = [
81
+ new Card\Timely_Auto_Updates( $this->page ),
82
  new Card\Database_Encryption( $this->page ),
83
  new Card\Google_Drive( $this->page ),
84
  new Card\Amazon_S3( $this->page ),
102
  */
103
  public function page() {
104
  wp_enqueue_style( 'bglib-ui-css' );
105
+ $settings = $this->core->settings->get_settings();
106
+ wp_enqueue_style( 'boldgrid-backup-admin-new-thickbox-style' );
107
+
108
+ $this->core->auto_rollback->enqueue_home_scripts();
109
+ $this->core->auto_rollback->enqueue_backup_scripts();
110
+ $this->core->archive_actions->enqueue_scripts();
111
+
112
+ $this->core->folder_exclusion->enqueue_scripts();
113
+ $this->core->db_omit->enqueue_scripts();
114
+
115
+ $in_modal = true;
116
+ $modal = include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-backup-modal.php';
117
+ $in_modal = false;
118
 
119
  $this->admin_enqueue_scripts( 'boldgrid-backup-admin-premium-features' );
120
+
121
+ echo '
122
+ <div class="wrap">
123
+ <div id="bglib-page-container" class="bgbkup-page-container">
124
+ <div id="bglib-page-top">
125
+ <div id="bglib-page-header" class="bglib-has-logo">
126
+ <h1>' . esc_html__( 'Total Upkeep Premium Features', 'boldgrid-backup' ) . '</h1>
127
+ <div class="page-title-actions">
128
+ <a href="#TB_inline?width=800&amp;height=600&amp;inlineId=backup_now_content" class="thickbox page-title-action page-title-action-primary">' .
129
+ esc_html__( 'Backup Site Now', 'boldgrid-backup' ) . '
130
+ </a>
131
+ <a class="page-title-action add-new">' . esc_html__( 'Upload Backup', 'boldgrid-backup' ) . '</a>
132
+ </div>
133
+ </div>
134
+ </div>
135
+ <div id="bglib-page-content">
136
+ <div class="wp-header-end"></div>';
137
+ echo $modal; //phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
138
  include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-premium.php';
139
+ echo '
140
+ </div>
141
+ </div>
142
+ </div>';
143
+
144
  $this->page->setAllNoticesRead();
145
  return array(
146
  'nav' => $nav,
admin/class-boldgrid-backup-admin-settings.php CHANGED
@@ -402,7 +402,7 @@ class Boldgrid_Backup_Admin_Settings {
402
  * @param string $new_dir Destination directory.
403
  * @return bool TRUE on success / no backups needed to be moved.
404
  */
405
- private function move_backups( $old_dir, $new_dir ) {
406
  $fail_count = 0;
407
 
408
  $old_dir = Boldgrid_Backup_Admin_Utility::trailingslashit( $old_dir );
@@ -700,6 +700,15 @@ class Boldgrid_Backup_Admin_Settings {
700
  $settings['folder_exclusion_exclude'] = $this->core->folder_exclusion->from_post( 'exclude' );
701
  $settings['folder_exclusion_type'] = $this->core->folder_exclusion->from_post( 'type' );
702
 
 
 
 
 
 
 
 
 
 
703
  // Read BoldGrid settings form POST request, sanitize, and merge settings with saved.
704
  $boldgrid_settings = array_merge(
705
  get_option( 'boldgrid_settings' ),
@@ -785,13 +794,16 @@ class Boldgrid_Backup_Admin_Settings {
785
  $is_premium_installed = $this->core->config->is_premium_installed;
786
  $is_premium_active = $this->core->config->is_premium_active;
787
 
788
- add_thickbox();
789
  wp_enqueue_style( 'boldgrid-backup-admin-new-thickbox-style' );
790
  wp_enqueue_style( 'bglib-ui-css' );
791
  wp_enqueue_script( 'bglib-ui-js' );
792
  wp_enqueue_script( 'bglib-sticky' );
793
  wp_enqueue_script( 'bglib-license' );
794
 
 
 
 
 
795
  if ( ! $this->is_saving_settings ) {
796
  $is_functional = $this->core->test->run_functionality_tests();
797
  }
@@ -918,8 +930,32 @@ class Boldgrid_Backup_Admin_Settings {
918
  $settings['encrypt_db'] = false;
919
  }
920
 
921
- // Include the page template.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
922
  include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-settings.php';
 
 
 
 
923
  }
924
 
925
  /**
402
  * @param string $new_dir Destination directory.
403
  * @return bool TRUE on success / no backups needed to be moved.
404
  */
405
+ public function move_backups( $old_dir, $new_dir ) {
406
  $fail_count = 0;
407
 
408
  $old_dir = Boldgrid_Backup_Admin_Utility::trailingslashit( $old_dir );
700
  $settings['folder_exclusion_exclude'] = $this->core->folder_exclusion->from_post( 'exclude' );
701
  $settings['folder_exclusion_type'] = $this->core->folder_exclusion->from_post( 'type' );
702
 
703
+ /*
704
+ * Save Auto Backup options
705
+ *
706
+ * @since 1.14.0
707
+ */
708
+ if ( ! empty( $_POST['auto_update'] ) ) {
709
+ $settings['auto_update'] = $_POST['auto_update'];
710
+ }
711
+
712
  // Read BoldGrid settings form POST request, sanitize, and merge settings with saved.
713
  $boldgrid_settings = array_merge(
714
  get_option( 'boldgrid_settings' ),
794
  $is_premium_installed = $this->core->config->is_premium_installed;
795
  $is_premium_active = $this->core->config->is_premium_active;
796
 
 
797
  wp_enqueue_style( 'boldgrid-backup-admin-new-thickbox-style' );
798
  wp_enqueue_style( 'bglib-ui-css' );
799
  wp_enqueue_script( 'bglib-ui-js' );
800
  wp_enqueue_script( 'bglib-sticky' );
801
  wp_enqueue_script( 'bglib-license' );
802
 
803
+ $this->core->auto_rollback->enqueue_home_scripts();
804
+ $this->core->auto_rollback->enqueue_backup_scripts();
805
+ $this->core->archive_actions->enqueue_scripts();
806
+
807
  if ( ! $this->is_saving_settings ) {
808
  $is_functional = $this->core->test->run_functionality_tests();
809
  }
930
  $settings['encrypt_db'] = false;
931
  }
932
 
933
+ $in_modal = true;
934
+ $modal = include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-backup-modal.php';
935
+ $in_modal = false;
936
+
937
+ echo '
938
+ <div class="wrap">
939
+ <div id="bglib-page-container" class="bgbkup-page-container">
940
+ <div id="bglib-page-top">
941
+ <div id="bglib-page-header" class="bglib-has-logo">
942
+ <h1>' . esc_html__( 'Total Upkeep Backup and Restore Settings', 'boldgrid-backup' ) . '</h1>
943
+ <div class="page-title-actions">
944
+ <a href="#TB_inline?width=800&amp;height=600&amp;inlineId=backup_now_content" class="thickbox page-title-action page-title-action-primary">' .
945
+ esc_html__( 'Backup Site Now', 'boldgrid-backup' ) . '
946
+ </a>
947
+ <a class="page-title-action add-new">' . esc_html__( 'Upload Backup', 'boldgrid-backup' ) . '</a>
948
+ </div>
949
+ </div>
950
+ </div>
951
+ <div id="bglib-page-content">
952
+ <div class="wp-header-end"></div>';
953
+ echo $modal; //phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
954
  include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-settings.php';
955
+ echo '
956
+ </div>
957
+ </div>
958
+ </div>';
959
  }
960
 
961
  /**
admin/class-boldgrid-backup-admin-support.php CHANGED
@@ -175,7 +175,41 @@ class Boldgrid_Backup_Admin_Support {
175
  */
176
  public function page() {
177
  wp_enqueue_style( 'bglib-ui-css' );
178
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-support.php';
 
 
 
 
180
  }
181
  }
175
  */
176
  public function page() {
177
  wp_enqueue_style( 'bglib-ui-css' );
178
+ $settings = $this->core->settings->get_settings();
179
+ wp_enqueue_style( 'boldgrid-backup-admin-new-thickbox-style' );
180
+
181
+ $this->core->auto_rollback->enqueue_home_scripts();
182
+ $this->core->auto_rollback->enqueue_backup_scripts();
183
+ $this->core->archive_actions->enqueue_scripts();
184
+
185
+ $this->core->folder_exclusion->enqueue_scripts();
186
+ $this->core->db_omit->enqueue_scripts();
187
+
188
+ $in_modal = true;
189
+ $modal = include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-backup-modal.php';
190
+ $in_modal = false;
191
+
192
+ echo '
193
+ <div class="wrap">
194
+ <div id="bglib-page-container" class="bgbkup-page-container">
195
+ <div id="bglib-page-top">
196
+ <div id="bglib-page-header" class="bglib-has-logo">
197
+ <h1>' . esc_html__( 'Total Upkeep Support', 'boldgrid-backup' ) . '</h1>
198
+ <div class="page-title-actions">
199
+ <a href="#TB_inline?width=800&amp;height=600&amp;inlineId=backup_now_content" class="thickbox page-title-action page-title-action-primary">' .
200
+ esc_html__( 'Backup Site Now', 'boldgrid-backup' ) . '
201
+ </a>
202
+ <a class="page-title-action add-new">' . esc_html__( 'Upload Backup', 'boldgrid-backup' ) . '</a>
203
+ </div>
204
+ </div>
205
+ </div>
206
+ <div id="bglib-page-content">
207
+ <div class="wp-header-end"></div>';
208
+ echo $modal; //phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped, WordPress.Security.EscapeOutput
209
  include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-support.php';
210
+ echo '
211
+ </div>
212
+ </div>
213
+ </div>';
214
  }
215
  }
admin/class-boldgrid-backup-admin-tools.php CHANGED
@@ -51,8 +51,6 @@ class Boldgrid_Backup_Admin_Tools {
51
  wp_enqueue_script( 'bglib-ui-js' );
52
  wp_enqueue_script( 'bglib-sticky' );
53
 
54
- // Add thickbox functionality. Initially added to support viewing log files.
55
- add_thickbox();
56
  }
57
 
58
  /**
@@ -61,6 +59,41 @@ class Boldgrid_Backup_Admin_Tools {
61
  * @since 1.6.0
62
  */
63
  public function page() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-tools.php';
 
 
 
 
65
  }
66
  }
51
  wp_enqueue_script( 'bglib-ui-js' );
52
  wp_enqueue_script( 'bglib-sticky' );
53
 
 
 
54
  }
55
 
56
  /**
59
  * @since 1.6.0
60
  */
61
  public function page() {
62
+ $settings = $this->core->settings->get_settings();
63
+ wp_enqueue_style( 'boldgrid-backup-admin-new-thickbox-style' );
64
+
65
+ $this->core->auto_rollback->enqueue_home_scripts();
66
+ $this->core->auto_rollback->enqueue_backup_scripts();
67
+ $this->core->archive_actions->enqueue_scripts();
68
+
69
+ $this->core->folder_exclusion->enqueue_scripts();
70
+ $this->core->db_omit->enqueue_scripts();
71
+
72
+ $in_modal = true;
73
+ $modal = include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-backup-modal.php';
74
+ $in_modal = false;
75
+
76
+ echo '
77
+ <div class="wrap">
78
+ <div id="bglib-page-container" class="bgbkup-page-container">
79
+ <div id="bglib-page-top">
80
+ <div id="bglib-page-header" class="bglib-has-logo">
81
+ <h1>' . esc_html( BOLDGRID_BACKUP_TITLE . ' ' . __( 'Total Upkeep Tools', 'boldgrid-backup' ) ) . '</h1>
82
+ <div class="page-title-actions">
83
+ <a href="#TB_inline?width=800&amp;height=600&amp;inlineId=backup_now_content" class="thickbox page-title-action page-title-action-primary">' .
84
+ esc_html__( 'Backup Site Now', 'boldgrid-backup' ) . '
85
+ </a>
86
+ <a class="page-title-action add-new">' . esc_html__( 'Upload Backup', 'boldgrid-backup' ) . '</a>
87
+ </div>
88
+ </div>
89
+ </div>
90
+ <div id="bglib-page-content">
91
+ <div class="wp-header-end"></div>';
92
+ echo $modal; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.XSS.EscapeOutput.OutputNotEscaped
93
  include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-tools.php';
94
+ echo '
95
+ </div>
96
+ </div>
97
+ </div>';
98
  }
99
  }
admin/class-boldgrid-backup-admin-transfers.php CHANGED
@@ -47,6 +47,20 @@ class Boldgrid_Backup_Admin_Transfers {
47
  wp_enqueue_script( 'bglib-ui-js' );
48
  wp_enqueue_script( 'bglib-sticky' );
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  wp_enqueue_style(
51
  'boldgrid-backup-admin-transfers',
52
  plugin_dir_url( __FILE__ ) . 'css/boldgrid-backup-admin-home.css',
@@ -54,6 +68,27 @@ class Boldgrid_Backup_Admin_Transfers {
54
  BOLDGRID_BACKUP_VERSION
55
  );
56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-transfers.php';
 
 
 
 
58
  }
59
  }
47
  wp_enqueue_script( 'bglib-ui-js' );
48
  wp_enqueue_script( 'bglib-sticky' );
49
 
50
+ $settings = $this->core->settings->get_settings();
51
+ wp_enqueue_style( 'boldgrid-backup-admin-new-thickbox-style' );
52
+
53
+ $this->core->auto_rollback->enqueue_home_scripts();
54
+ $this->core->auto_rollback->enqueue_backup_scripts();
55
+ $this->core->archive_actions->enqueue_scripts();
56
+
57
+ $this->core->folder_exclusion->enqueue_scripts();
58
+ $this->core->db_omit->enqueue_scripts();
59
+
60
+ $in_modal = true;
61
+ $modal = include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-backup-modal.php';
62
+ $in_modal = false;
63
+
64
  wp_enqueue_style(
65
  'boldgrid-backup-admin-transfers',
66
  plugin_dir_url( __FILE__ ) . 'css/boldgrid-backup-admin-home.css',
68
  BOLDGRID_BACKUP_VERSION
69
  );
70
 
71
+ echo '
72
+ <div class="wrap">
73
+ <div id="bglib-page-container" class="bgbkup-page-container">
74
+ <div id="bglib-page-top">
75
+ <div id="bglib-page-header" class="bglib-has-logo">
76
+ <h1>' . esc_html( BOLDGRID_BACKUP_TITLE . ' ' . __( 'Total Upkeep Transfers', 'boldgrid-backup' ) ) . '</h1>
77
+ <div class="page-title-actions">
78
+ <a href="#TB_inline?width=800&amp;height=600&amp;inlineId=backup_now_content" class="thickbox page-title-action page-title-action-primary">' .
79
+ esc_html__( 'Backup Site Now', 'boldgrid-backup' ) . '
80
+ </a>
81
+ <a class="page-title-action add-new">' . esc_html__( 'Upload Backup', 'boldgrid-backup' ) . '</a>
82
+ </div>
83
+ </div>
84
+ </div>
85
+ <div id="bglib-page-content">
86
+ <div class="wp-header-end"></div>';
87
+ echo $modal; //phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
88
  include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-transfers.php';
89
+ echo '
90
+ </div>
91
+ </div>
92
+ </div>';
93
  }
94
  }
admin/class-boldgrid-backup-admin.php CHANGED
<
@@ -92,6 +92,10 @@ class Boldgrid_Backup_Admin {
92
  * @since 1.0
93
  */