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

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.3
Comparing to
See all releases

Code changes from version 1.13.6 to 1.14.0-rc.3

Files changed (98) 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 +10 -6
  10. admin/class-boldgrid-backup-admin-archive-details.php +30 -0
  11. admin/class-boldgrid-backup-admin-auto-rollback.php +16 -18
  12. admin/class-boldgrid-backup-admin-auto-updates.php +217 -0
  13. admin/class-boldgrid-backup-admin-core.php +84 -10
  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-in-progress-tmp.php +12 -13
  20. admin/class-boldgrid-backup-admin-log.php +4 -3
  21. admin/class-boldgrid-backup-admin-notice.php +43 -3
  22. admin/class-boldgrid-backup-admin-premium-features.php +38 -0
  23. admin/class-boldgrid-backup-admin-settings.php +49 -3
  24. admin/class-boldgrid-backup-admin-support.php +35 -0
  25. admin/class-boldgrid-backup-admin-tools.php +36 -2
  26. admin/class-boldgrid-backup-admin-transfers.php +35 -0
  27. admin/class-boldgrid-backup-admin-upload.php +23 -0
  28. admin/class-boldgrid-backup-admin.php +29 -0
  29. admin/compressor/class-boldgrid-backup-admin-compressor-system-zip.php +141 -7
  30. admin/css/boldgrid-backup-admin-settings.css +31 -0
  31. admin/css/boldgrid-backup-admin.css +67 -0
  32. admin/image/icon-128x128.png +0 -0
  33. admin/js/boldgrid-backup-admin-backup-now.js +1 -1
  34. admin/js/boldgrid-backup-admin-folder-exclude.js +82 -17
  35. admin/js/boldgrid-backup-admin-home.js +31 -11
  36. admin/js/boldgrid-backup-admin-in-progress.js +9 -3
  37. admin/js/boldgrid-backup-admin-settings-autoupdate.js +64 -21
  38. admin/js/boldgrid-backup-admin-settings.js +18 -0
  39. admin/js/{boldgrid-backup-admin-table-include.js → boldgrid-backup-admin-table-includes.js} +46 -9
  40. admin/partials/archives/add-new.php +17 -6
  41. admin/partials/boldgrid-backup-admin-archive-details.php +24 -19
  42. admin/partials/boldgrid-backup-admin-backup-button.php +2 -3
  43. admin/partials/boldgrid-backup-admin-dashboard.php +3 -8
  44. admin/partials/boldgrid-backup-admin-home.php +36 -31
  45. admin/partials/boldgrid-backup-admin-premium.php +4 -10
  46. admin/partials/boldgrid-backup-admin-settings.php +29 -34
  47. admin/partials/boldgrid-backup-admin-support.php +49 -54
  48. admin/partials/boldgrid-backup-admin-test.php +3 -4
  49. admin/partials/boldgrid-backup-admin-tools.php +3 -7
  50. admin/partials/boldgrid-backup-admin-transfers.php +7 -5
  51. admin/partials/settings/auto-backup.php +52 -30
  52. admin/partials/settings/auto-update.php +435 -0
  53. admin/partials/settings/backup-security.php +8 -3
  54. admin/partials/settings/compressor.php +32 -0
  55. admin/partials/settings/storage.php +1 -1
  56. admin/partials/tools/local-remote.php +8 -12
  57. admin/partials/transfers/destination.php +4 -2
  58. boldgrid-backup.php +1 -1
  59. coverage.xml +6002 -4538
  60. includes/class-boldgrid-backup.php +13 -2
  61. includes/config/config.plugin.php +5 -0
  62. readme.txt +6 -0
  63. vendor/autoload.php +1 -1
  64. vendor/boldgrid/library/.gitignore +1 -1
  65. vendor/boldgrid/library/README.md +2 -1
  66. vendor/boldgrid/library/phpunit.xml +1 -1
  67. vendor/boldgrid/library/src/Library/Configs.php +3 -5
  68. vendor/boldgrid/library/src/Library/Plugin/Checker.php +8 -4
  69. vendor/boldgrid/library/src/Library/Plugin/Factory.php +222 -0
  70. vendor/boldgrid/library/src/Library/Plugin/Notice.php +31 -28
  71. vendor/boldgrid/library/src/Library/Plugin/Notices.php +5 -4
  72. vendor/boldgrid/library/src/Library/Plugin/Page.php +18 -10
  73. vendor/boldgrid/library/src/Library/Plugin/Plugin.php +76 -111
  74. vendor/boldgrid/library/src/Library/Plugin/Plugins.php +48 -5
  75. vendor/boldgrid/library/src/Library/Plugin/UpdateData.php +322 -0
  76. vendor/boldgrid/library/src/Library/Start.php +0 -3
  77. vendor/boldgrid/library/src/Library/Theme/Theme.php +145 -0
  78. vendor/boldgrid/library/src/Library/Theme/Themes.php +85 -0
  79. vendor/boldgrid/library/src/Library/Theme/UpdateData.php +275 -0
  80. vendor/boldgrid/library/src/Library/Ui/Page.php +38 -0
  81. vendor/boldgrid/library/src/Library/Update.php +0 -202
  82. vendor/boldgrid/library/src/assets/css/admin.css +1 -1
  83. vendor/boldgrid/library/src/assets/css/dashboard.css +5 -3
  84. vendor/boldgrid/library/src/assets/css/page.css +60 -0
  85. vendor/boldgrid/library/tests/Library/Library/test-activity.php +0 -25
  86. vendor/boldgrid/library/tests/Library/Library/test-rating-prompt.php +0 -47
  87. vendor/boldgrid/library/tests/Library/Plugin/test-factory.php +82 -0
  88. vendor/boldgrid/library/tests/Library/Plugin/test-notice.php +137 -365
  89. vendor/boldgrid/library/tests/Library/Plugin/test-page.php +60 -163
  90. vendor/boldgrid/library/tests/Library/Plugin/test-plugin.php +182 -191
  91. vendor/boldgrid/library/tests/Library/Plugin/test-plugins.php +100 -0
  92. vendor/boldgrid/library/tests/Library/Theme/test-theme.php +50 -0
  93. vendor/boldgrid/library/tests/Library/Theme/test-themes.php +84 -0
  94. vendor/boldgrid/library/tests/Library/Theme/test-update-data.php +65 -0
  95. vendor/boldgrid/library/tests/bootstrap.php +6 -0
  96. vendor/composer/autoload_real.php +7 -7
  97. vendor/composer/autoload_static.php +4 -4
  98. vendor/composer/installed.json +7 -21
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/' );
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
@@ -57,7 +57,9 @@ class Boldgrid_Backup_Admin_Archive_Browser {
57
  wp_send_json_error( __( 'Permission denied.', 'boldgrid-backup' ) );
58
  }
59
 
60
- if ( ! check_ajax_referer( 'boldgrid_backup_remote_storage_upload', 'security', false ) ) {
 
 
61
  wp_send_json_error( __( 'Invalid nonce; security check failed.', 'boldgrid-backup' ) );
62
  }
63
  }
@@ -322,17 +324,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
  }
57
  wp_send_json_error( __( 'Permission denied.', 'boldgrid-backup' ) );
58
  }
59
 
60
+ // With Recent UI changes, sometimes this ajax call can be for one of either actions.
61
+ if ( ! check_ajax_referer( 'boldgrid_backup_remote_storage_upload', 'security', false ) &&
62
+ ! check_ajax_referer( 'boldgrid_backup_browse_archive', 'security', false ) ) {
63
  wp_send_json_error( __( 'Invalid nonce; security check failed.', 'boldgrid-backup' ) );
64
  }
65
  }
324
  $importer = new Boldgrid_Backup_Admin_Db_Import( $this->core );
325
  $success = $importer->import_from_archive( $filepath, $file );
326
 
327
+ if ( true === $success ) {
328
  $this->core->notice->add_user_notice(
329
  // translators: 1: Filename 2: File path.
330
+ sprintf( __( 'Success! Database %1$s imported from %2$s.', 'boldgrid-backup' ), $file, $filepath ),
331
+ $this->core->notice->lang['dis_success']
332
  );
333
+ } elseif ( false !== $success ) {
334
+ $this->core->notice->add_user_notice( $success, $this->core->notice->lang['dis_error'] );
335
  } else {
336
  $this->core->notice->add_user_notice(
337
  // translators: 1: Filename 2: File path.
338
+ sprintf( __( 'Error, unable to import database %1$s from %2$s.', 'boldgrid-backup' ), $file, $filepath ),
339
+ $this->core->notice->lang['dis_error']
340
  );
341
  }
342
  }
admin/class-boldgrid-backup-admin-archive-details.php CHANGED
@@ -133,6 +133,7 @@ class Boldgrid_Backup_Admin_Archive_Details {
133
 
134
  $this->enqueue_scripts();
135
  $this->core->archive_actions->enqueue_scripts();
 
136
 
137
  $archive_found = false;
138
 
@@ -161,7 +162,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
  /**
133
 
134
  $this->enqueue_scripts();
135
  $this->core->archive_actions->enqueue_scripts();
136
+ $this->core->auto_rollback->enqueue_home_scripts();
137
 
138
  $archive_found = false;
139
 
162
  $title = $this->core->archive->get_attribute( 'title' );
163
  $description = $this->core->archive->get_attribute( 'description' );
164
 
165
+ $settings = $this->core->settings->get_settings();
166
+ wp_enqueue_style( 'boldgrid-backup-admin-new-thickbox-style' );
167
+ wp_enqueue_style( 'bglib-ui-css' );
168
+
169
+ $in_modal = true;
170
+ $modal = include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-backup-modal.php';
171
+ $in_modal = false;
172
+
173
+ echo '
174
+ <div class="wrap">
175
+ <div id="bglib-page-container" class="bgbkup-page-container">
176
+ <div id="bglib-page-top">
177
+ <div id="bglib-page-header" class="bglib-has-logo">
178
+ <h1>' . esc_html__( 'Total Upkeep Preflight Check', 'boldgrid-backup' ) . '</h1>
179
+ <div class="page-title-actions">
180
+ <a href="#TB_inline?width=800&amp;height=600&amp;inlineId=backup_now_content" class="thickbox page-title-action page-title-action-primary">' .
181
+ esc_html__( 'Backup Site Now', 'boldgrid-backup' ) . '
182
+ </a>
183
+ <a class="page-title-action add-new">' . esc_html__( 'Upload Backup', 'boldgrid-backup' ) . '</a>
184
+ </div>
185
+ </div>
186
+ </div>
187
+ <div id="bglib-page-content">
188
+ <div class="wp-header-end"></div>';
189
+ echo $modal; //phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
190
  include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-archive-details.php';
191
+ echo '
192
+ </div>
193
+ </div>
194
+ </div>';
195
  }
196
 
197
  /**
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,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ $plugin->setUpdateData();
97
+
98
+ $days_since_release = $plugin->updateData->days; //phpcs:ignore WordPress.NamingConventions.ValidVariableName
99
+ $plugin_update_enabled = array_key_exists( $plugin->getFile(), $this->settings['plugins'] ) ? (bool) $this->settings['plugins'][ $plugin->getFile() ] : (bool) $this->settings['plugins']['default'];
100
+ $is_update_time = ( $days_since_release >= $days_to_wait );
101
+ if ( $is_update_time && true === $plugin_update_enabled ) {
102
+ return true;
103
+ } else {
104
+ return false;
105
+ }
106
+ }
107
+
108
+ /**
109
+ * Maybe Update Theme.
110
+ *
111
+ * @since 1.14.0
112
+ *
113
+ * @param string $stylesheet Theme's Stylesheet.
114
+ * @return bool
115
+ */
116
+ public function maybe_update_theme( $stylesheet ) {
117
+ $days_to_wait = $this->settings['days'];
118
+ $theme = $this->themes->getFromStylesheet( $stylesheet );
119
+ $days_since_release = $theme->updateData->days; //phpcs:ignore WordPress.NamingConventions.ValidVariableName
120
+ $theme_update_enabled = isset( $this->settings['themes'][ $stylesheet ] ) ? (bool) $this->settings['themes'][ $stylesheet ] : (bool) $this->settings['plugins']['default'];
121
+ $is_update_time = ( $days_since_release >= $days_to_wait );
122
+
123
+ if ( $is_update_time && true === $theme_update_enabled ) {
124
+ return true;
125
+ } else {
126
+ return false;
127
+ }
128
+ }
129
+
130
+ /**
131
+ * Auto Update Plugins.
132
+ *
133
+ * This method is the callback for the 'auto_update_plugin' action hook.
134
+ *
135
+ * @since 1.14.0
136
+ *
137
+ * @param bool $update Whether or not to update.
138
+ * @param stdClass $item The item class passed to callback.
139
+ * @return bool
140
+ */
141
+ public function auto_update_plugins( $update, stdClass $item ) {
142
+ // Array of plugin slugs to always auto-update.
143
+ $plugins = array();
144
+ foreach ( $this->plugins as $plugin ) {
145
+ if ( $this->maybe_update_plugin( $plugin->getSlug() ) ) {
146
+ $plugins[] = $plugin->getSlug();
147
+ }
148
+ }
149
+ if ( in_array( $item->slug, $plugins, true ) ) {
150
+ // Always update plugins in this array.
151
+ return true;
152
+ } else {
153
+ // Else, Do Not Update Plugin.
154
+ return false;
155
+ }
156
+ }
157
+
158
+ /**
159
+ * Auto Update Themes.
160
+ *
161
+ * This method is the callback for the 'auto_update_theme' action hook.
162
+ *
163
+ * @since 1.14.0
164
+ *
165
+ * @param bool $update Whether or not to update.
166
+ * @param stdClass $item The item class passed to callback.
167
+ * @return bool
168
+ */
169
+ public function auto_update_themes( $update, stdClass $item ) {
170
+ // Array of theme stylesheets to always auto-update.
171
+ $themes = array();
172
+ foreach ( $this->themes->get() as $theme ) {
173
+ if ( $this->maybe_update_theme( $theme->stylesheet ) ) {
174
+ $themes[] = $theme->stylesheet;
175
+ }
176
+ }
177
+ if ( in_array( $item->theme, $themes, true ) ) {
178
+ // Always update themes in this array.
179
+ return true;
180
+ } else {
181
+ // Else, Do Not Update theme.
182
+ return false;
183
+ }
184
+ }
185
+
186
+ /**
187
+ * Auto Update Core.
188
+ *
189
+ * Sets the type of updates to perform for wpcore.
190
+ *
191
+ * @since 1.14.0
192
+ */
193
+ public function auto_update_core() {
194
+ $wpcs_default = array(
195
+ 'all' => false,
196
+ 'minor' => true,
197
+ 'major' => false,
198
+ 'translation' => false,
199
+ 'dev' => false,
200
+ );
201
+
202
+ $wpcs = isset( $this->settings['wpcore'] ) ? $this->settings['wpcore'] : $wpcs_default;
203
+ if ( $wpcs['all'] ) {
204
+ add_filter( 'auto_update_core', '__return_true' );
205
+ }
206
+
207
+ $dev = ( $wpcs['dev'] ) ? 'true' : 'false';
208
+ $major = ( $wpcs['major'] ) ? 'true' : 'false';
209
+ $minor = ( $wpcs['minor'] ) ? 'true' : 'false';
210
+ $translation = ( $wpcs['translation'] ) ? 'true' : 'false';
211
+
212
+ add_filter( 'allow_major_auto_core_updates', '__return_' . $major );
213
+ add_filter( 'allow_minor_auto_core_updates', '__return_' . $minor );
214
+ add_filter( 'auto_update_translation', '__return_' . $translation );
215
+ add_filter( 'allow_dev_auto_core_updates', '__return_' . $dev );
216
+ }
217
+ }
admin/class-boldgrid-backup-admin-core.php CHANGED
@@ -384,6 +384,14 @@ class Boldgrid_Backup_Admin_Core {
384
  */
385
  public $db_omit;
386
 
 
 
 
 
 
 
 
 
387
  /**
388
  * An instance of Boldgrid_Backup_Admin_Filelist.
389
  *
@@ -574,6 +582,14 @@ class Boldgrid_Backup_Admin_Core {
574
  */
575
  public $activity;
576
 
 
 
 
 
 
 
 
 
577
  /**
578
  * Constructor.
579
  *
@@ -701,10 +717,20 @@ class Boldgrid_Backup_Admin_Core {
701
 
702
  $this->dashboard = new Boldgrid_Backup_Admin_Dashboard( $this );
703
 
704
- // Instantiate Boldgrid\Library\Library\Plugin\Plugin.
705
- $this->plugin = new \Boldgrid\Library\Library\Plugin\Plugin( 'boldgrid-backup', $this->configs );
 
 
 
 
706
  $this->premium_page = new Boldgrid_Backup_Admin_Premium_Features( $this );
707
 
 
 
 
 
 
 
708
  // Ensure there is a backup identifier.
709
  $this->get_backup_identifier();
710
 
@@ -1262,6 +1288,7 @@ class Boldgrid_Backup_Admin_Core {
1262
  $status = $importer->import( $db_dump_filepath );
1263
 
1264
  if ( ! empty( $status['error'] ) ) {
 
1265
  do_action( 'boldgrid_backup_notice', $status['error'], 'notice notice-error is-dismissible' );
1266
  return false;
1267
  }
@@ -1540,6 +1567,8 @@ class Boldgrid_Backup_Admin_Core {
1540
  $this->logger->init( 'archive-' . time() . '.log' );
1541
  $this->logger->add( 'Backup process initialized.' );
1542
 
 
 
1543
  $this->pre_auto_update = 'pre_auto_update' === current_filter();
1544
 
1545
  /*
@@ -2422,7 +2451,7 @@ class Boldgrid_Backup_Admin_Core {
2422
 
2423
  // Display notice of deletion status.
2424
  if ( ! $restore_ok ) {
2425
- $error_message = esc_html__( 'Could not restore database.', 'boldgrid-backup' );
2426
  $this->logger->add( $error_message );
2427
  return [ 'error' => $error_message ];
2428
  }
@@ -2478,7 +2507,6 @@ class Boldgrid_Backup_Admin_Core {
2478
  global $pagenow;
2479
 
2480
  // Thickbox used for Backup Site Now modal.
2481
- add_thickbox();
2482
  wp_enqueue_style( 'boldgrid-backup-admin-new-thickbox-style' );
2483
 
2484
  wp_enqueue_style( 'bglib-ui-css' );
@@ -2500,11 +2528,6 @@ class Boldgrid_Backup_Admin_Core {
2500
  $this->folder_exclusion->enqueue_scripts();
2501
  $this->db_omit->enqueue_scripts();
2502
 
2503
- // If uploading an archive file.
2504
- if ( ! empty( $_FILES['file'] ) ) {
2505
- $this->upload->upload_archive_file();
2506
- }
2507
-
2508
  // Get archive list.
2509
  $archives = $this->get_archive_list();
2510
 
@@ -2575,6 +2598,11 @@ class Boldgrid_Backup_Admin_Core {
2575
  // If there were any errors encountered during the backup, save them to the In Progress data.
2576
  if ( ! empty( $archive_info['error'] ) ) {
2577
  Boldgrid_Backup_Admin_In_Progress_Data::set_arg( 'error', $archive_info['error'] );
 
 
 
 
 
2578
  }
2579
 
2580
  if ( $this->is_archiving_update_protection ) {
@@ -2744,8 +2772,43 @@ class Boldgrid_Backup_Admin_Core {
2744
  BOLDGRID_BACKUP_VERSION, 'all'
2745
  );
2746
 
2747
- // Load template view.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2748
  include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-test.php';
 
 
 
 
2749
  }
2750
 
2751
  /**
@@ -2999,4 +3062,15 @@ class Boldgrid_Backup_Admin_Core {
2999
  $counter --;
3000
  }
3001
  }
 
 
 
 
 
 
 
 
 
 
 
3002
  }
384
  */
385
  public $db_omit;
386
 
387
+ /**
388
+ * Database Restoration errro
389
+ *
390
+ * @since 1.14.0
391
+ * @var string
392
+ */
393
+ public $db_restore_error;
394
+
395
  /**
396
  * An instance of Boldgrid_Backup_Admin_Filelist.
397
  *
582
  */
583
  public $activity;
584
 
585
+ /**
586
+ * An instance of the Auto Updates class
587
+ *
588
+ * @since 1.14.0
589
+ * @var Boldgrid_Backup_Admin_Auto_Updates
590
+ */
591
+ public $auto_updates;
592
+
593
  /**
594
  * Constructor.
595
  *
717
 
718
  $this->dashboard = new Boldgrid_Backup_Admin_Dashboard( $this );
719
 
720
+ /**
721
+ * For backwards compatibility with plugins using previous versions of the Library, this will
722
+ * allow the plugins to be instantiated without using the new Factory methods.
723
+ */
724
+ $this->plugin = new \Boldgrid\Library\Library\Plugin\Plugin( 'boldgrid-backup', $this->configs );
725
+
726
  $this->premium_page = new Boldgrid_Backup_Admin_Premium_Features( $this );
727
 
728
+ // Instantiate Boldgrid_Backup_Admin_Auto_Updates.
729
+
730
+ if ( Boldgrid_Backup_Admin_Utility::is_active() ) {
731
+ $this->auto_updates = new Boldgrid_Backup_Admin_Auto_Updates();
732
+ }
733
+
734
  // Ensure there is a backup identifier.
735
  $this->get_backup_identifier();
736
 
1288
  $status = $importer->import( $db_dump_filepath );
1289
 
1290
  if ( ! empty( $status['error'] ) ) {
1291
+ $this->db_restore_error = $status['error'];
1292
  do_action( 'boldgrid_backup_notice', $status['error'], 'notice notice-error is-dismissible' );
1293
  return false;
1294
  }
1567
  $this->logger->init( 'archive-' . time() . '.log' );
1568
  $this->logger->add( 'Backup process initialized.' );
1569
 
1570
+ $this->utility->bump_memory_limit( '1G' );
1571
+
1572
  $this->pre_auto_update = 'pre_auto_update' === current_filter();
1573
 
1574
  /*
2451
 
2452
  // Display notice of deletion status.
2453
  if ( ! $restore_ok ) {
2454
+ $error_message = $this->db_restore_error ? $this->db_restore_error : esc_html__( 'Could not restore database.', 'boldgrid-backup' );
2455
  $this->logger->add( $error_message );
2456
  return [ 'error' => $error_message ];
2457
  }
2507
  global $pagenow;
2508
 
2509
  // Thickbox used for Backup Site Now modal.
 
2510
  wp_enqueue_style( 'boldgrid-backup-admin-new-thickbox-style' );
2511
 
2512
  wp_enqueue_style( 'bglib-ui-css' );
2528
  $this->folder_exclusion->enqueue_scripts();
2529
  $this->db_omit->enqueue_scripts();
2530
 
 
 
 
 
 
2531
  // Get archive list.
2532
  $archives = $this->get_archive_list();
2533
 
2598
  // If there were any errors encountered during the backup, save them to the In Progress data.
2599
  if ( ! empty( $archive_info['error'] ) ) {
2600
  Boldgrid_Backup_Admin_In_Progress_Data::set_arg( 'error', $archive_info['error'] );
2601
+ $this->notice->add_user_notice(
2602
+ '<p>' . $archive_info['error'] . '</p>',
2603
+ 'notice notice-error is-dismissible',
2604
+ 'Backup Failed'
2605
+ );
2606
  }
2607
 
2608
  if ( $this->is_archiving_update_protection ) {
2772
  BOLDGRID_BACKUP_VERSION, 'all'
2773
  );
2774
 
2775
+ $settings = $this->settings->get_settings();
2776
+ wp_enqueue_style( 'boldgrid-backup-admin-new-thickbox-style' );
2777
+ wp_enqueue_style( 'bglib-ui-css' );
2778
+
2779
+ $this->auto_rollback->enqueue_home_scripts();
2780
+ $this->auto_rollback->enqueue_backup_scripts();
2781
+ $this->archive_actions->enqueue_scripts();
2782
+
2783
+ $this->folder_exclusion->enqueue_scripts();
2784
+ $this->db_omit->enqueue_scripts();
2785
+
2786
+ $in_modal = true;
2787
+ $modal = include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-backup-modal.php';
2788
+ $in_modal = false;
2789
+
2790
+ echo '
2791
+ <div class="wrap">
2792
+ <div id="bglib-page-container" class="bgbkup-page-container">
2793
+ <div id="bglib-page-top">
2794
+ <div id="bglib-page-header" class="bglib-has-logo">
2795
+ <h1>' . esc_html__( 'Total Upkeep Preflight Check', 'boldgrid-backup' ) . '</h1>
2796
+ <div class="page-title-actions">
2797
+ <a href="#TB_inline?width=800&amp;height=600&amp;inlineId=backup_now_content" class="thickbox page-title-action page-title-action-primary">' .
2798
+ esc_html__( 'Backup Site Now', 'boldgrid-backup' ) . '
2799
+ </a>
2800
+ <a class="page-title-action add-new">' . esc_html__( 'Upload Backup', 'boldgrid-backup' ) . '</a>
2801
+ </div>
2802
+ </div>
2803
+ </div>
2804
+ <div id="bglib-page-content">
2805
+ <div class="wp-header-end"></div>';
2806
+ echo $modal; //phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
2807
  include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-test.php';
2808
+ echo '
2809
+ </div>
2810
+ </div>
2811
+ </div>';
2812
  }
2813
 
2814
  /**
3062
  $counter --;
3063
  }
3064
  }
3065
+
3066
+ /**
3067
+ * Add thickbox to bolgrid_backup admin pages.
3068
+ *
3069
+ * @since 1.14.0
3070
+ */
3071
+ public function add_thickbox( $hook_suffix ) {
3072
+ if ( false !== strpos( $hook_suffix, 'boldgrid-backup' ) ) {
3073
+ add_thickbox();
3074
+ }
3075
+ }
3076
  }
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
@@ -67,7 +67,8 @@ class Boldgrid_Backup_Admin_Db_Dump {
67
  *
68
  * In the list below, it is important that $include_tables is processed last.
69
  */
70
- $include_views = $this->core->db_get->filter_by_type( $include_tables, 'VIEW' );
 
71
  $include_tables = $this->core->db_get->filter_by_type( $include_tables, 'BASE TABLE' );
72
 
73
  Boldgrid_Backup_Admin_In_Progress_Data::set_args(
@@ -106,6 +107,19 @@ class Boldgrid_Backup_Admin_Db_Dump {
106
  $settings['default-character-set'] = $wpdb->charset;
107
  }
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  try {
110
  $dump = new IMysqldump\Mysqldump(
111
  $this->get_connection_string(),
67
  *
68
  * In the list below, it is important that $include_tables is processed last.
69
  */
70
+ $include_views = $this->core->db_get->filter_by_type( $include_tables, 'VIEW' );
71
+
72
  $include_tables = $this->core->db_get->filter_by_type( $include_tables, 'BASE TABLE' );
73
 
74
  Boldgrid_Backup_Admin_In_Progress_Data::set_args(
107
  $settings['default-character-set'] = $wpdb->charset;
108
  }
109
 
110
+ if ( ! empty( $include_views ) ) {
111
+ $db_import = new Boldgrid_Backup_Admin_Db_Import();
112
+ $user_has_privileges = $db_import->has_db_privileges( array( 'SHOW VIEW' ) );
113
+ if ( false === $user_has_privileges ) {
114
+ return array(
115
+ 'error' => esc_html__(
116
+ 'The database contains VIEWS, but the database user does not have the permissions needed to create a backup.',
117
+ 'boldgrid-backup'
118
+ ),
119
+ );
120
+ }
121
+ }
122
+
123
  try {
124
  $dump = new IMysqldump\Mysqldump(
125
  $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-in-progress-tmp.php CHANGED
@@ -84,23 +84,22 @@ class Boldgrid_Backup_Admin_In_Progress_Tmp {
84
  * @return array
85
  */
86
  private function get_system_zip() {
87
- $dir = Boldgrid_Backup_Admin_Compressor_System_Zip_Temp_Folder::get_path();
88
- $dirlist = $this->core->wp_filesystem->dirlist( $dir );
89
- $dirlist = is_array( $dirlist ) ? $dirlist : [];
90
- $size = 0;
91
- $lastmodunix = 0;
92
 
93
- foreach ( $dirlist as $file ) {
94
- $size += ! empty( $file['size'] ) ? $file['size'] : 0;
95
 
96
- $lastmodunix = ! empty( $file['lastmodunix'] ) ? $file['lastmodunix'] : $lastmodunix;
 
 
 
 
 
97
  }
98
 
99
- return [
100
- 'size' => $size,
101
- 'lastmodunix' => $lastmodunix,
102
- 'size_format' => size_format( $size, 2 ),
103
- ];
104
  }
105
 
106
  /**
84
  * @return array
85
  */
86
  private function get_system_zip() {
87
+ $data = [];
88
+
89
+ $filepath = Boldgrid_Backup_Admin_In_Progress_Data::get_arg( 'filepath' );
90
+ $filename = basename( $filepath );
 
91
 
92
+ $dirlist = $this->core->backup_dir->dirlist_containing( $filename );
 
93
 
94
+ if ( ! empty( $dirlist[ $filename ] ) ) {
95
+ $data = [
96
+ 'size' => $dirlist[ $filename ]['size'],
97
+ 'lastmodunix' => $dirlist[ $filename ]['lastmodunix'],
98
+ 'size_format' => size_format( $dirlist[ $filename ]['size'], 2 ),
99
+ ];
100
  }
101
 
102
+ return $data;
 
 
 
 
103
  }
104
 
105
  /**
admin/class-boldgrid-backup-admin-log.php CHANGED
@@ -278,10 +278,11 @@ class Boldgrid_Backup_Admin_Log {
278
  *
279
  * @since 1.12.6
280
  *
281
- * @param int The signal being handled.
 
282
  */
283
- public function signal_handler( $signo ) {
284
- $this->add( 'Signal received: ' . $signo );
285
 
286
  exit;
287
  }
278
  *
279
  * @since 1.12.6
280
  *
281
+ * @param int $signo The signal being handled.
282
+ * @param array $signinfo Additional information about signal.
283
  */
284
+ public function signal_handler( $signo, $signinfo ) {
285
+ $this->add( 'Signal received: ' . $signo . ' ' . wp_json_encode( $signinfo ) );
286
 
287
  exit;
288
  }
admin/class-boldgrid-backup-admin-notice.php CHANGED
@@ -236,15 +236,55 @@ 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 +301,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
+ $auto_update_array = array_values( $auto_update_array );
253
+ $update_msg = sprintf(
254
+ // translators: 1: Auto Update Type.
255
+ esc_html__( 'enabled for %s', 'boldgrid-backup' ),
256
+ $auto_update_array[0]
257
+ );
258
+ break;
259
+ case 4:
260
+ $update_msg = esc_html__( 'enabled for all', 'boldgrid-backup' );
261
+ break;
262
+ default:
263
+ $x = array_slice( $auto_update_array, 0, -1 );
264
+
265
+ $auto_update_string = implode( ', ', $x );
266
+ $update_msg = sprintf(
267
+ // translators: 1: Auto Update Types, 2: Auto Update Type.
268
+ esc_html__(
269
+ 'enabled for %1$s and %2$s',
270
+ 'boldgrid-backup'
271
+ ),
272
+ $auto_update_string,
273
+ end( $auto_update_array )
274
+ );
275
+ break;
276
+ }
277
+
278
  $message = sprintf(
279
  // translators: 1: HTML anchor opening tag, 2: HTML anchor closing tag, 3: Plugin title.
280
  esc_html__(
281
+ 'Auto Updates are %4$s WordPress Core Updates. This can be configured in the %1$s%3$s Settings%2$s.',
282
  'boldgrid-backup'
283
  ),
284
  '<a href="' . admin_url( 'admin.php?page=boldgrid-backup-settings&section=section_auto_updates' ) . '">',
285
  '</a>',
286
+ BOLDGRID_BACKUP_TITLE,
287
+ $update_msg
288
  );
289
 
290
  do_action( 'boldgrid_backup_notice', $message, 'notice notice-info is-dismissible' );
301
  * @see \Boldgrid\Library\Library\Notice::show()
302
  */
303
  public function plugin_renamed_notice() {
304
+ $plugin = \Boldgrid\Library\Library\Plugin\Factory::create( 'boldgrid-backup' );
305
 
306
  /*
307
  * 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 ),
@@ -100,10 +101,47 @@ class Boldgrid_Backup_Admin_Premium_Features {
100
  * @return array returns an array of the $nav, $dashboard, and $premium_box for validation.
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 ),
101
  * @return array returns an array of the $nav, $dashboard, and $premium_box for validation.
102
  */
103
  public function page() {
104
+
105
  wp_enqueue_style( 'bglib-ui-css' );
106
+ $settings = $this->core->settings->get_settings();
107
+ wp_enqueue_style( 'boldgrid-backup-admin-new-thickbox-style' );
108
+
109
+ $this->core->auto_rollback->enqueue_home_scripts();
110
+ $this->core->auto_rollback->enqueue_backup_scripts();
111
+ $this->core->archive_actions->enqueue_scripts();
112
+
113
+ $this->core->folder_exclusion->enqueue_scripts();
114
+ $this->core->db_omit->enqueue_scripts();
115
+
116
+ $in_modal = true;
117
+ $modal = include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-backup-modal.php';
118
+ $in_modal = false;
119
 
120
  $this->admin_enqueue_scripts( 'boldgrid-backup-admin-premium-features' );
121
+
122
+ echo '
123
+ <div class="wrap">
124
+ <div id="bglib-page-container" class="bgbkup-page-container">
125
+ <div id="bglib-page-top">
126
+ <div id="bglib-page-header" class="bglib-has-logo">
127
+ <h1>' . esc_html__( 'Total Upkeep Premium Features', 'boldgrid-backup' ) . '</h1>
128
+ <div class="page-title-actions">
129
+ <a href="#TB_inline?width=800&amp;height=600&amp;inlineId=backup_now_content" class="thickbox page-title-action page-title-action-primary">' .
130
+ esc_html__( 'Backup Site Now', 'boldgrid-backup' ) . '
131
+ </a>
132
+ <a class="page-title-action add-new">' . esc_html__( 'Upload Backup', 'boldgrid-backup' ) . '</a>
133
+ </div>
134
+ </div>
135
+ </div>
136
+ <div id="bglib-page-content">
137
+ <div class="wp-header-end"></div>';
138
+ echo $modal; //phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
139
  include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-premium.php';
140
+ echo '
141
+ </div>
142
+ </div>
143
+ </div>';
144
+
145
  $this->page->setAllNoticesRead();
146
  return array(
147
  '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 );
@@ -609,6 +609,15 @@ class Boldgrid_Backup_Admin_Settings {
609
  }
610
  }
611
 
 
 
 
 
 
 
 
 
 
612
  /*
613
  * Save extractor settings.
614
  *
@@ -700,6 +709,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' ),
@@ -781,17 +799,21 @@ class Boldgrid_Backup_Admin_Settings {
781
  * @see Boldgrid_Backup_Admin_Config::is_premium_active
782
  */
783
  public function page_backup_settings() {
 
784
  $is_premium = $this->core->config->get_is_premium();
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 +940,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 );
609
  }
610
  }
611
 
612
+ /*
613
+ * Save Compression Level Settings.
614
+ *
615
+ * @since 1.14.0
616
+ */
617
+ if ( isset( $_POST['compression_level'] ) ) {
618
+ $settings['compression_level'] = $_POST['compression_level'];
619
+ }
620
+
621
  /*
622
  * Save extractor settings.
623
  *
709
  $settings['folder_exclusion_exclude'] = $this->core->folder_exclusion->from_post( 'exclude' );
710
  $settings['folder_exclusion_type'] = $this->core->folder_exclusion->from_post( 'type' );
711
 
712
+ /*
713
+ * Save Auto Backup options
714
+ *
715
+ * @since 1.14.0
716
+ */
717
+ if ( ! empty( $_POST['auto_update'] ) ) {
718
+ $settings['auto_update'] = $_POST['auto_update'];
719
+ }
720
+
721
  // Read BoldGrid settings form POST request, sanitize, and merge settings with saved.
722
  $boldgrid_settings = array_merge(
723
  get_option( 'boldgrid_settings' ),
799
  * @see Boldgrid_Backup_Admin_Config::is_premium_active
800
  */
801
  public function page_backup_settings() {
802
+
803
  $is_premium = $this->core->config->get_is_premium();
804
  $is_premium_installed = $this->core->config->is_premium_installed;
805
  $is_premium_active = $this->core->config->is_premium_active;
806
 
 
807
  wp_enqueue_style( 'boldgrid-backup-admin-new-thickbox-style' );
808
  wp_enqueue_style( 'bglib-ui-css' );
809
  wp_enqueue_script( 'bglib-ui-js' );
810
  wp_enqueue_script( 'bglib-sticky' );
811
  wp_enqueue_script( 'bglib-license' );
812
 
813
+ $this->core->auto_rollback->enqueue_home_scripts();
814
+ $this->core->auto_rollback->enqueue_backup_scripts();
815
+ $this->core->archive_actions->enqueue_scripts();
816
+
817
  if ( ! $this->is_saving_settings ) {
818
  $is_functional = $this->core->test->run_functionality_tests();
819
  }
940
  $settings['encrypt_db'] = false;
941
  }
942
 
943
+ $in_modal = true;
944
+ $modal = include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-backup-modal.php';
945
+ $in_modal = false;
946
+
947
+ echo '
948
+ <div class="wrap">
949
+ <div id="bglib-page-container" class="bgbkup-page-container">
950
+ <div id="bglib-page-top">
951
+ <div id="bglib-page-header" class="bglib-has-logo">
952
+ <h1>' . esc_html__( 'Total Upkeep Backup and Restore Settings', 'boldgrid-backup' ) . '</h1>
953
+ <div class="page-title-actions">
954
+ <a href="#TB_inline?width=800&amp;height=600&amp;inlineId=backup_now_content" class="thickbox page-title-action page-title-action-primary">' .
955
+ esc_html__( 'Backup Site Now', 'boldgrid-backup' ) . '
956
+ </a>
957
+ <a class="page-title-action add-new">' . esc_html__( 'Upload Backup', 'boldgrid-backup' ) . '</a>
958
+ </div>
959
+ </div>
960
+ </div>
961
+ <div id="bglib-page-content">