Total Upkeep – WordPress Backup Plugin plus Restore & Migrate by BoldGrid - Version 1.11.0

Version Description

Release date: August 29th, 2019

  • New feature: Added a transfers page.
  • Bug fix: Fixed "Use of undefined constant STDERR" warning for bgbkup-cli.
  • Update: Updated auto-rollback to use the CLI restoration process.
  • Update: Updated dependencies.
  • Bug fix: Fixed database table exclusion when none are selected.
  • Bug fix: Avoid zip close error by checking files before write/close.
  • Bug fix: Prevent the web server from killing the archive process.
Download this release

Release Info

Developer boldgrid
Plugin Icon 128x128 Total Upkeep – WordPress Backup Plugin plus Restore & Migrate by BoldGrid
Version 1.11.0
Comparing to
See all releases

Code changes from version 1.10.6 to 1.11.0

Files changed (56) hide show
  1. admin/card/class-backups.php +43 -0
  2. admin/card/class-premium.php +70 -0
  3. admin/card/class-updates.php +45 -0
  4. admin/card/feature/class-auto-rollback.php +53 -0
  5. admin/card/feature/class-auto-update-backup.php +56 -0
  6. admin/card/feature/class-central.php +40 -0
  7. admin/card/feature/class-cloud-wordpress.php +34 -0
  8. admin/card/feature/class-more-backup.php +47 -0
  9. admin/card/feature/class-more-boldgrid.php +34 -0
  10. admin/card/feature/class-more-central.php +40 -0
  11. admin/card/feature/class-remote-storage.php +66 -0
  12. admin/card/feature/class-scheduled-backups.php +74 -0
  13. admin/card/feature/class-sign-up.php +36 -0
  14. admin/card/feature/class-speed-coach.php +34 -0
  15. admin/card/feature/class-versions.php +63 -0
  16. admin/class-boldgrid-backup-admin-archive-actions.php +14 -15
  17. admin/class-boldgrid-backup-admin-archive.php +58 -1
  18. admin/class-boldgrid-backup-admin-archives.php +63 -26
  19. admin/class-boldgrid-backup-admin-auto-rollback.php +97 -2
  20. admin/class-boldgrid-backup-admin-core.php +76 -18
  21. admin/class-boldgrid-backup-admin-cron.php +60 -55
  22. admin/class-boldgrid-backup-admin-dashboard-widget.php +74 -0
  23. admin/class-boldgrid-backup-admin-dashboard.php +84 -0
  24. admin/class-boldgrid-backup-admin-db-omit.php +1 -1
  25. admin/class-boldgrid-backup-admin-go-pro.php +57 -20
  26. admin/class-boldgrid-backup-admin-remote.php +39 -0
  27. admin/class-boldgrid-backup-admin-settings.php +76 -2
  28. admin/class-boldgrid-backup-admin-transfers.php +59 -0
  29. admin/class-boldgrid-backup-admin-upload.php +12 -8
  30. admin/class-cron.php +110 -0
  31. admin/compressor/class-boldgrid-backup-admin-compressor-pcl-zip.php +4 -0
  32. admin/compressor/class-boldgrid-backup-admin-compressor-php-zip.php +28 -0
  33. admin/cron/class-crontab.php +59 -0
  34. admin/cron/entry/class-base.php +58 -0
  35. admin/cron/entry/class-crontab.php +161 -0
  36. admin/cron/entry/class-entry.php +29 -0
  37. admin/cron/entry/class-wpcron.php +86 -0
  38. admin/css/boldgrid-backup-admin-dashboard.css +27 -0
  39. admin/css/boldgrid-backup-admin-home.css +1 -1
  40. admin/css/boldgrid-backup-admin.css +0 -4
  41. admin/js/boldgrid-backup-admin-home.js +15 -2
  42. admin/partials/archive-details/remote-storage.php +22 -5
  43. admin/partials/archives/add-new.php +1 -1
  44. admin/partials/boldgrid-backup-admin-archive-details.php +3 -3
  45. admin/partials/boldgrid-backup-admin-dashboard.php +34 -0
  46. admin/partials/boldgrid-backup-admin-home.php +1 -1
  47. admin/partials/boldgrid-backup-admin-nav.php +15 -5
  48. admin/partials/boldgrid-backup-admin-transfers.php +70 -0
  49. admin/partials/tools/local-remote.php +2 -12
  50. admin/partials/transfers/destination.php +40 -0
  51. admin/partials/transfers/overview.php +27 -0
  52. admin/partials/transfers/source.php +36 -0
  53. boldgrid-backup.php +1 -1
  54. cli/class-info.php +4 -0
  55. cli/class-site-restore.php +27 -5
  56. coverage.xml +6619 -4911
admin/card/class-backups.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Backups class.
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since 1.11.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: Backups
18
+ *
19
+ * This class is responsible for rendering the "Backups" card on the BoldGrid Backup dashboard.
20
+ *
21
+ * @since 1.11.0
22
+ */
23
+ class Backups extends \Boldgrid\Library\Library\Ui\Card {
24
+ /**
25
+ * Init.
26
+ *
27
+ * @since 1.11.0
28
+ */
29
+ public function init() {
30
+ $this->id = 'bgbkup_backups';
31
+
32
+ $this->title = esc_html__( 'Backups', 'boldgrid-backup' );
33
+
34
+ $this->subTitle = esc_html__( 'It\'s website insurance. Make sure you have a backup.', 'boldgrid-backup' ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar
35
+
36
+ $this->icon = '<span class="dashicons dashicons-vault"></span>';
37
+
38
+ $this->features = [
39
+ new Feature\Scheduled_Backups(),
40
+ new Feature\Remote_Storage(),
41
+ ];
42
+ }
43
+ }
admin/card/class-premium.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Premium class.
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since 1.11.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: Premium
18
+ *
19
+ * This class is responsible for rendering the "Premium" card on the BoldGrid Backup dashboard.
20
+ *
21
+ * @since 1.11.0
22
+ */
23
+ class Premium extends \Boldgrid\Library\Library\Ui\Card {
24
+ /**
25
+ * Init.
26
+ *
27
+ * @since 1.11.0
28
+ */
29
+ public function init() {
30
+ $core = apply_filters( 'boldgrid_backup_get_core', null );
31
+
32
+ $api_key = apply_filters( 'Boldgrid\Library\License\getApiKey', '' ); // phpcs:ignore
33
+
34
+ $this->id = 'bgbkup_get_premium';
35
+
36
+ $this->icon = '<span class="dashicons dashicons-admin-network"></span>';
37
+
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
+
45
+ $this->features = [
46
+ new Feature\Cloud_Wordpress(),
47
+ new Feature\Speed_Coach(),
48
+ new Feature\Sign_Up(),
49
+ ];
50
+ } elseif ( ! $core->config->get_is_premium() ) {
51
+ $this->title = esc_html__( 'Enjoying your free account?', 'boldgrid-backup' );
52
+
53
+ $this->subTitle = esc_html__( 'We hope so. There\'s more available by upgrading now!', 'boldgrid-backup' ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar
54
+
55
+ $this->features = [
56
+ new Feature\More_Backup(),
57
+ new Feature\More_Boldgrid(),
58
+ new Feature\More_Central(),
59
+ ];
60
+ } else {
61
+ $this->title = esc_html__( 'BoldGrid Premium', 'boldgrid-backup' );
62
+
63
+ $this->subTitle = esc_html__( 'Thank you for running BoldGrid Premium!', 'boldgrid-backup' ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar
64
+
65
+ $this->features = [
66
+ new Feature\Central(),
67
+ ];
68
+ }
69
+ }
70
+ }
admin/card/class-updates.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Updates class.
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since 1.11.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: Updates
18
+ *
19
+ * This class is responsible for rendering the "Update Management" card on the BoldGrid Backup
20
+ * dashboard.
21
+ *
22
+ * @since 1.11.0
23
+ */
24
+ class Updates extends \Boldgrid\Library\Library\Ui\Card {
25
+ /**
26
+ * Init.
27
+ *
28
+ * @since 1.11.0
29
+ */
30
+ public function init() {
31
+ $this->id = 'bgbkup_updates';
32
+
33
+ $this->title = esc_html__( 'Update Management', 'boldgrid-backup' );
34
+
35
+ $this->subTitle = esc_html__( 'Keep everything tidy and up to date.', 'boldgrid-backup' ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar
36
+
37
+ $this->icon = '<span class="dashicons dashicons-plugins-checked"></span>';
38
+
39
+ $this->features = [
40
+ new Feature\Versions(),
41
+ new Feature\Auto_Rollback(),
42
+ new Feature\Auto_Update_Backup(),
43
+ ];
44
+ }
45
+ }
admin/card/feature/class-auto-rollback.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Auto_Rollback class.
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since 1.11.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\Feature;
15
+
16
+ /**
17
+ * Class: Auto_Rollback
18
+ *
19
+ * This class is responsible for rendering the "Auto Rollback" feature on the BoldGrid Backup
20
+ * dashboard.
21
+ *
22
+ * @since 1.11.0
23
+ */
24
+ class Auto_Rollback extends \Boldgrid\Library\Library\Ui\Feature {
25
+ /**
26
+ * Init.
27
+ *
28
+ * @since 1.11.0
29
+ */
30
+ public function init() {
31
+ $core = apply_filters( 'boldgrid_backup_get_core', null );
32
+
33
+ $this->icon = '<span class="dashicons dashicons-controls-back"></span>';
34
+
35
+ $this->title = __( 'Auto Rollback', 'boldgrid-backup' );
36
+
37
+ if ( $core->auto_rollback->is_enabled() ) {
38
+ $this->content = '<p>' . esc_html__( 'Auto Rollback is enabled!', 'boldgrid-backup' ) . '</p>';
39
+ } else {
40
+ $this->content = '<p>' . esc_html__( 'With Auto Rollback, we can help fix your site if anything goes wrong while performing updates.', 'boldgrid-backup' ) . '</p>';
41
+ $this->content .= '<div class="notice notice-error inline"><p>' .
42
+ wp_kses(
43
+ sprintf(
44
+ // translators: 1 An opening anchor tag to the "Auto Updates" settings page, 2 its closing tag.
45
+ __( 'Auto Rollback is not enabled. %1$sFix this%2$s.', 'boldgrid-backup' ),
46
+ '<a href="' . esc_url( $core->settings->get_settings_url( 'section_auto_updates' ) ) . '">',
47
+ '</a>'
48
+ ),
49
+ [ 'a' => [ 'href' => [] ] ]
50
+ ) . '</p></div>';
51
+ }
52
+ }
53
+ }
admin/card/feature/class-auto-update-backup.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Auto_Update_Backup class.
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since 1.11.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: Auto_Update_Backup
18
+ *
19
+ * This class is responsible for rendering the, "Auto Backup Before Updates" feature on the BoldGrid
20
+ * Backup Dashboard.
21
+ *
22
+ * @since 1.11.0
23
+ */
24
+ class Auto_Update_Backup extends \Boldgrid\Library\Library\Ui\Feature {
25
+ /**
26
+ * Init.
27
+ *
28
+ * @since 1.11.0
29
+ */
30
+ public function init() {
31
+ $core = apply_filters( 'boldgrid_backup_get_core', null );
32
+
33
+ $this->icon = '<span class="dashicons dashicons-update-alt"></span>';
34
+
35
+ $this->title = __( 'Auto Backup Before Updates', 'boldgrid-backup' );
36
+
37
+ // Determine whether or not this feature is enabled.
38
+ $setting_value = $core->settings->get_setting( 'auto_backup' );
39
+ $is_enabled = ! empty( $setting_value );
40
+
41
+ if ( $is_enabled ) {
42
+ $this->content = '<p>' . esc_html__( 'Auto Backup Before Updates is enabled!', 'boldgrid-backup' ) . '</p>';
43
+ } else {
44
+ $this->content = '<p>' . esc_html__( 'When Auto Backup is enabled, we will backup your site before any auto-updates occur.', 'boldgrid-backup' ) . '</p>';
45
+ $this->content .= '<div class="notice notice-error inline"><p>' . wp_kses(
46
+ sprintf(
47
+ // translators: 1 Opening anchor tag to "Auto Updates" settings page, 2 its closing tag.
48
+ __( 'Auto Backup Before Updates is not enabled. %1$sFix this%2$s.', 'boldgrid-backup' ),
49
+ '<a href="' . esc_url( $core->settings->get_settings_url( 'section_auto_updates' ) ) . '">',
50
+ '</a>'
51
+ ),
52
+ [ 'a' => [ 'href' => [] ] ]
53
+ ) . '</p></div>';
54
+ }
55
+ }
56
+ }
admin/card/feature/class-central.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Central class.
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since 1.11.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\Feature;
15
+
16
+ /**
17
+ * Class: Central
18
+ *
19
+ * This class is responsible for initializing a BoldGrid Central "feature" for use within a card.
20
+ *
21
+ * @since 1.11.0
22
+ */
23
+ class Central extends \Boldgrid\Library\Library\Ui\Feature {
24
+ /**
25
+ * Init.
26
+ *
27
+ * @since 1.11.0
28
+ */
29
+ public function init() {
30
+ $reseller = new \Boldgrid\Library\Library\Reseller();
31
+
32
+ $this->icon = '<span class="dashicons boldgrid-icon"></span>';
33
+
34
+ $this->title = esc_html__( 'BoldGrid Central', 'boldgrid-backup' );
35
+
36
+ $this->content = '<p>' . esc_html__( 'Manage your account, Run Automated Website Speed Tests, and more within BoldGrid Central.', 'boldgrid-backup' ) . '</p>';
37
+
38
+ $this->content .= '<p style="text-align:right;"><a href="' . esc_url( $reseller->centralUrl ) . '">' . esc_html__( 'BoldGrid Central Login', 'boldgrid-backup' ) . '</a></p>'; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar
39
+ }
40
+ }
admin/card/feature/class-cloud-wordpress.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cloud_WordPress class.
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since 1.11.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\Feature;
15
+
16
+ /**
17
+ * Class: Cloud_WordPress
18
+ *
19
+ * @since 1.11.0
20
+ */
21
+ class Cloud_Wordpress extends \Boldgrid\Library\Library\Ui\Feature { //phpcs:ignore
22
+ /**
23
+ * Init.
24
+ *
25
+ * @since 1.11.0
26
+ */
27
+ public function init() {
28
+ $this->icon = '<span class="dashicons dashicons-cloud"></span>';
29
+
30
+ $this->title = __( 'Cloud WordPress', 'boldgrid-backup' );
31
+
32
+ $this->content = '<p>' . __( 'Create a fully functional free WordPress demo in just a few clicks. Easily design, build, test and share your WordPress website with clients or teams.', 'boldgrid-backup' ) . '</p>';
33
+ }
34
+ }
admin/card/feature/class-more-backup.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * More_Backup class.
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since 1.11.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\Feature;
15
+
16
+ /**
17
+ * Class: More_Backup
18
+ *
19
+ * @since 1.11.0
20
+ */
21
+ class More_Backup extends \Boldgrid\Library\Library\Ui\Feature {
22
+ /**
23
+ * Init.
24
+ *
25
+ * @since 1.11.0
26
+ */
27
+ public function init() {
28
+ $this->icon = '<span class="dashicons dashicons-vault"></span>';
29
+
30
+ $this->title = esc_html__( 'More BoldGrid Backup Features', 'boldgrid-backup' );
31
+
32
+ $this->content = '<p>' . wp_kses(
33
+ sprintf(
34
+ // translators: 1 A span displaying the Google Drive logo, 2 a span displaying the Amazon S3 logo.
35
+ __( 'BoldGrid Backup Premium can store backups on %1$s and %2$s, restore individual files with just a click, and more!', 'boldgrid-backup' ),
36
+ '<span class="bgbkup-remote-logo bgbkup-gdrive-logo" title="Google Drive"></span>',
37
+ '<span class="bgbkup-remote-logo amazon-s3-logo" title="Amazon S3"></span>'
38
+ ),
39
+ [
40
+ 'span' => [
41
+ 'class' => [],
42
+ 'title' => [],
43
+ ],
44
+ ]
45
+ ) . '</p>';
46
+ }
47
+ }
admin/card/feature/class-more-boldgrid.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * More_Boldgrid class.
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since 1.11.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\Feature;
15
+
16
+ /**
17
+ * Class: More_Boldgrid
18
+ *
19
+ * @since 1.11.0
20
+ */
21
+ class More_Boldgrid extends \Boldgrid\Library\Library\Ui\Feature {
22
+ /**
23
+ * Init.
24
+ *
25
+ * @since 1.11.0
26
+ */
27
+ public function init() {
28
+ $this->icon = '<span class="dashicons dashicons-admin-plugins"></span>';
29
+
30
+ $this->title = esc_html__( 'More Premium BoldGrid Plugins', 'boldgrid-backup' );
31
+
32
+ $this->content = '<p>' . esc_html__( 'Gain access to all BoldGrid premium plugins and services. This includes Post and Page Builder Premium, which offers premium Blocks and native sliders.', 'boldgrid-backup' ) . '</p>';
33
+ }
34
+ }
admin/card/feature/class-more-central.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * More_Central class.
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since 1.11.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\Feature;
15
+
16
+ /**
17
+ * Class: More_Central
18
+ *
19
+ * @since 1.11.0
20
+ */
21
+ class More_Central extends \Boldgrid\Library\Library\Ui\Feature {
22
+ /**
23
+ * Init.
24
+ *
25
+ * @since 1.11.0
26
+ */
27
+ public function init() {
28
+ $core = apply_filters( 'boldgrid_backup_get_core', null );
29
+
30
+ $get_premium_url = $core->go_pro->get_premium_url( 'bgbkup-dashboard' );
31
+
32
+ $this->icon = '<span class="dashicons boldgrid-icon"></span>';
33
+
34
+ $this->title = esc_html__( 'More BoldGrid Central Features', 'boldgrid-backup' );
35
+
36
+ $this->content = '<p>' . esc_html__( 'Unlock more features within BoldGrid Central, including Cloud WordPress Advanced Controls and Automated Website Speed Tests.', 'boldgrid-backup' ) . '</p>';
37
+
38
+ $this->content .= '<p style="text-align:right;"><a href="' . esc_url( $get_premium_url ) . '" class="button button-primary boldgrid-orange">' . __( 'Get Premium', 'boldgrid-backup' ) . '</a></p>';
39
+ }
40
+ }
admin/card/feature/class-remote-storage.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Remote_Storage class.
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since 1.11.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\Feature;
15
+
16
+ /**
17
+ * Class: Remote_Storage
18
+ *
19
+ * @since 1.11.0
20
+ */
21
+ class Remote_Storage extends \Boldgrid\Library\Library\Ui\Feature {
22
+ /**
23
+ * Init.
24
+ *
25
+ * @since 1.11.0
26
+ */
27
+ public function init() {
28
+ $core = apply_filters( 'boldgrid_backup_get_core', null );
29
+
30
+ $this->icon = '<span class="dashicons dashicons-networking"></span>';
31
+
32
+ $this->title = esc_html__( 'Remote Storage', 'boldgrid-backup' );
33
+
34
+ if ( $core->settings->has_remote_configured() ) {
35
+ $storage_locations = $core->remote->get_enabled( 'title' );
36
+
37
+ $this->content = '<p>' .
38
+ wp_kses(
39
+ sprintf(
40
+ // translators: 1 An opening span tag, A list of remote backup storage locations (csv), its closing span tag.
41
+ __( 'Backups saved to: %1$s%2$s%3$s', 'boldgrid-bakcup' ),
42
+ '<span class="bglib-feature-value">',
43
+ esc_html( implode( ', ', $storage_locations ) ),
44
+ '</span>'
45
+ ),
46
+ [
47
+ 'span' => [
48
+ 'class' => [],
49
+ ],
50
+ ]
51
+ ) .
52
+ '</p>';
53
+ } else {
54
+ $this->content = '<p>' . esc_html__( 'Don\'t put all of your eggs in one basket! Store your backups remotely.', 'boldgrid-backup' ) . '</p>';
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
+ ),
62
+ [ 'a' => [ 'href' => [] ] ]
63
+ ) . '</p></div>';
64
+ }
65
+ }
66
+ }
admin/card/feature/class-scheduled-backups.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Scheduled_Backups class.
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since 1.11.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\Feature;
15
+
16
+ /**
17
+ * Class: Scheduled_Backups
18
+ *
19
+ * This class is responsible for displaying the scheduled backups feature on the BoldGrid Backup
20
+ * dashboard.
21
+ *
22
+ * @since 1.11.0
23
+ */
24
+ class Scheduled_Backups extends \Boldgrid\Library\Library\Ui\Feature {
25
+ /**
26
+ * Init.
27
+ *
28
+ * @since 1.11.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 = esc_html__( 'Scheduled Backups', 'boldgrid-backup' );
36
+
37
+ if ( $core->settings->has_scheduled_backups() ) {
38
+ $cron = new \Boldgrid\Backup\Admin\Cron();
39
+ $backup_entry = $cron->get_entry( 'backup' );
40
+ $next_runtime = $backup_entry->get_next_runtime();
41
+
42
+ $this->content = '<p>' . wp_kses(
43
+ sprintf(
44
+ // Translators: 1 An opening span tag, 2 the date of the next backup, 3 its closing span tag.
45
+ __( 'Next backup in: %1$s%2$s%3$s', 'boldgrid-backup' ),
46
+ '<span class="bglib-feature-value" title="' . esc_attr( date( 'M j, Y h:i a', $next_runtime ) ) . '">',
47
+ human_time_diff( time(), $next_runtime ),
48
+ '</span>'
49
+ ),
50
+ [
51
+ 'span' => [
52
+ 'class' => [],
53
+ 'title' => [],
54
+ ],
55
+ ]
56
+ ) . '</p>';
57
+ } else {
58
+ $this->content = '<p>' . esc_html__( 'It\'s easy to forget to make a backup. Schedule automatic backups so they\'re made for you.', 'boldgrid-backup' ) . '</p>';
59
+ $this->content .= '<div class="notice notice-error inline"><p>' . wp_kses(
60
+ sprintf(
61
+ // translators: 1 An opening anchor tag to the settings page, 2 its closing tag.
62
+ __( 'Scheduled backups not configured. %1$sFix this%2$s.', 'boldgrid-backup' ),
63
+ '<a href="' . esc_url( $core->settings->get_settings_url() ) . '">',
64
+ '</a>'
65
+ ),
66
+ [
67
+ 'a' => [
68
+ 'href' => [],
69
+ ],
70
+ ]
71
+ ) . '</p></div>';
72
+ }
73
+ }
74
+ }
admin/card/feature/class-sign-up.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sign_Up class.
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since 1.11.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\Feature;
15
+
16
+ /**
17
+ * Class: Sign_Up
18
+ *
19
+ * @since 1.11.0
20
+ */
21
+ class Sign_Up extends \Boldgrid\Library\Library\Ui\Feature {
22
+ /**
23
+ * Init.
24
+ *
25
+ * @since 1.11.0
26
+ */
27
+ public function init() {
28
+ $new_key_url = \Boldgrid\Library\Library\Key\PostNewKey::getCentralUrl( admin_url( 'admin.php?page=boldgrid-backup-dashboard' ) );
29
+
30
+ $this->icon = '<span class="dashicons dashicons-clipboard"></span>';
31
+
32
+ $this->content = '<p>' . esc_html__( 'There’s more waiting for you in BoldGrid Central. Download the full-featured community versions of ALL our plugins for FREE. It’s just a click away.', 'boldgrid-backup' ) . '</p>';
33
+
34
+ $this->content .= '<p style="text-align:right;"><a href="' . esc_url( $new_key_url ) . '" class="button button-primary boldgrid-orange">' . __( 'Sign Up for Free!', 'boldgrid-backup' ) . '</a></p>';
35
+ }
36
+ }
admin/card/feature/class-speed-coach.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Speed_Coach class.
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since 1.11.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\Feature;
15
+
16
+ /**
17
+ * Class: Speed_Coach
18
+ *
19
+ * @since 1.11.0
20
+ */
21
+ class Speed_Coach extends \Boldgrid\Library\Library\Ui\Feature {
22
+ /**
23
+ * Init.
24
+ *
25
+ * @since 1.11.0
26
+ */
27
+ public function init() {
28
+ $this->icon = '<span class="dashicons dashicons-chart-line"></span>';
29
+
30
+ $this->title = esc_html__( 'Speed Coach', 'boldgrid-backup' );
31
+
32
+ $this->content = '<p>' . esc_html__( 'A faster website means happier visitors and higher rankings on the search engines. Simply type in your website’s URL and receive detailed advice on making your site lightning fast.', 'boldgrid-backup' ) . '</p>';
33
+ }
34
+ }
admin/card/feature/class-versions.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * My Backups class.
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since 1.11.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\Feature;
15
+
16
+ /**
17
+ * Class: Versions
18
+ *
19
+ * @since 1.11.0
20
+ */
21
+ class Versions extends \Boldgrid\Library\Library\Ui\Feature {
22
+ /**
23
+ *
24
+ */
25
+ public function init() {
26
+ $data = wp_get_update_data();
27
+
28
+ $has_updates = ! empty( $data['counts']['plugins'] ) || ! empty( $data['counts']['themes'] ) || ! empty( $data['counts']['wordpress'] );
29
+
30
+ $this->icon = '<span class="dashicons dashicons-wordpress"></span>';
31
+
32
+ $this->title = esc_html__( 'WordPress, Plugins, & Theme Version', 'boldgrid-backup' );
33
+
34
+ if ( $has_updates ) {
35
+ $this->content = '<p>' . wp_kses(
36
+ sprintf(
37
+ // translators: 1 A description of what updates are available (such as plugins, themes, or core).
38
+ __( 'The following updates are available: %1$s', 'boldgrid-backup' ),
39
+ $data['title']
40
+ ),
41
+ []
42
+ ) . '</p>';
43
+
44
+ $this->content .= '<div class="notice notice-error inline"><p>' .
45
+ wp_kses(
46
+ sprintf(
47
+ // translators: 1 An opening anchor tag to the update-core.php page, 2 its closing tag.
48
+ __( 'Not everything is up to date. %1$sFix this%2$s.', 'boldgrid-backup' ),
49
+ '<a href="' . esc_url( admin_url( 'update-core.php' ) ) . '">',
50
+ '</a>'
51
+ ),
52
+ [
53
+ 'a' => [
54
+ 'href' => [],
55
+ ],
56
+ ]
57
+ ) .
58
+ '</p></div>';
59
+ } else {
60
+ $this->content = '<p>' . esc_html__( 'Everything is up to date!', 'boldgrid-backup' ) . '</p>';
61
+ }
62
+ }
63
+ }
admin/class-boldgrid-backup-admin-archive-actions.php CHANGED
@@ -184,10 +184,10 @@ class Boldgrid_Backup_Admin_Archive_Actions {
184
  * @param array $args Arguments for the link/button.
185
  * @return string
186
  */
187
- public function get_restore_button( $filename, $args = array() ) {
188
- $defaults = array(
189
- 'button_text' => __( 'Restore' ),
190
- );
191
 
192
  $args = wp_parse_args( $args, $defaults );
193
 
@@ -200,20 +200,19 @@ class Boldgrid_Backup_Admin_Archive_Actions {
200
  '
201
  <a
202
  data-restore-now="1"
203
- data-archive-key="%2$s"
204
- data-archive-filename="%3$s"
205
- data-nonce="%4$s"
206
  class="button restore-now"
207
  href="">
208
- %5$s
209
  </a>
210
- %6$s',
211
- /* 1 */ get_admin_url( null, 'admin.php?page=boldgrid-backup' ),
212
- /* 2 */ $archive['key'],
213
- /* 3 */ $filename,
214
- /* 4 */ wp_create_nonce( 'boldgrid_backup_restore_archive' ),
215
- /* 5 */ $args['button_text'],
216
- /* 6 */ $this->core->lang['spinner']
217
  );
218
  }
219
 
184
  * @param array $args Arguments for the link/button.
185
  * @return string
186
  */
187
+ public function get_restore_button( $filename, $args = [] ) {
188
+ $defaults = [
189
+ 'button_text' => __( 'Restore', 'boldgrid-backup' ),
190
+ ];
191
 
192
  $args = wp_parse_args( $args, $defaults );
193
 
200
  '
201
  <a
202
  data-restore-now="1"
203
+ data-archive-key="%1$s"
204
+ data-archive-filename="%2$s"
205
+ data-nonce="%3$s"
206
  class="button restore-now"
207
  href="">
208
+ %4$s
209
  </a>
210
+ %5$s',
211
+ /* 1 */ $archive['key'],
212
+ /* 2 */ $filename,
213
+ /* 3 */ wp_create_nonce( 'boldgrid_backup_restore_archive' ),
214
+ /* 4 */ esc_html( $args['button_text'] ),
215
+ /* 5 */ $this->core->lang['spinner']
 
216
  );
217
  }
218
 
admin/class-boldgrid-backup-admin-archive.php CHANGED
@@ -86,7 +86,9 @@ class Boldgrid_Backup_Admin_Archive {
86
  /**
87
  * The unix timestamp of the backup file.
88
  *
89
- * Not the date the backup was created (though it should be), just the date created timestamp.
 
 
90
  *
91
  * @since 1.7.3
92
  * @var string
@@ -204,6 +206,17 @@ class Boldgrid_Backup_Admin_Archive {
204
  return $file_contents;
205
  }
206
 
 
 
 
 
 
 
 
 
 
 
 
207
  /**
208
  * Init.
209
  *
@@ -265,6 +278,50 @@ class Boldgrid_Backup_Admin_Archive {
265
  $this->init( $filepath );
266
  }
267
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
268
  /**
269
  * Determine if a zip file is in our archive.
270
  *
86
  /**
87
  * The unix timestamp of the backup file.
88
  *
89
+ * The timestamp of when the backup was created. This value is set in the self::init() method by
90
+ * reading the 'lastmodunix' value from the logs. The 'lastmodunix' value was saved to the archive's
91
+ * log when the archive was made in Boldgrid_Backup_Admin_Core::archive_files().
92
  *
93
  * @since 1.7.3
94
  * @var string
206
  return $file_contents;
207
  }
208
 
209
+ /**
210
+ * Get the filesize of the backup file itself.
211
+ *
212
+ * IE the size of the zip file, not the size of everything before compression.
213
+ *
214
+ * @since 1.11.0
215
+ */
216
+ public function get_filesize() {
217
+ return $this->core->wp_filesystem->size( $this->filepath );
218
+ }
219
+
220
  /**
221
  * Init.
222
  *
278
  $this->init( $filepath );
279
  }
280
 
281
+ /**
282
+ * Init this class based upon an archive key.
283
+ *
284
+ * @since 1.11.0
285
+ *
286
+ * @param int $key The archive key.
287
+ * @return bool Whether or not this archive was initialized successfully.
288
+ */
289
+ public function init_by_key( $key ) {
290
+ $this->reset();
291
+
292
+ $archives = $this->core->get_archive_list();
293
+
294
+ if ( empty( $archives[ $key ] ) ) {
295
+ return false;
296
+ }
297
+
298
+ $archive = $archives[ $key ];
299
+
300
+ if ( ! empty( $archive['filename'] ) ) {
301
+ $this->init_by_filename( $archive['filename'] );
302
+ }
303
+
304
+ /*
305
+ * Return whether or not this init method was successful. If we don't have a filename, then
306
+ * it was not succesful.
307
+ */
308
+ return ! empty( $this->filename );
309
+ }
310
+
311
+ /**
312
+ * Init this class using the last backup created.
313
+ *
314
+ * The last backup created is that defined by the boldgrid_backup_latest_backup option. This option
315
+ * is set at the end of Boldgrid_Backup_Admin_Core::archive_files.
316
+ */
317
+ public function init_by_latest() {
318
+ $option = get_option( 'boldgrid_backup_latest_backup' );
319
+
320
+ if ( ! empty( $option['filepath'] ) ) {
321
+ $this->init( $option['filepath'] );
322
+ }
323
+ }
324
+
325
  /**
326
  * Determine if a zip file is in our archive.
327
  *
admin/class-boldgrid-backup-admin-archives.php CHANGED
@@ -184,14 +184,26 @@ class Boldgrid_Backup_Admin_Archives {
184
  *
185
  * @since 1.6.0
186
  *
 
 
 
 
 
 
187
  * @return string
188
  */
189
- public function get_table() {
190
  $this->core->archives_all->init();
191
  $backup = __( 'Backup', 'boldgrid-backup' );
192
  $view_details = __( 'View details', 'boldgrid-backup' );
193
 
194
- $table = $this->get_mine_count();
 
 
 
 
 
 
195
 
196
  $table .= sprintf(
197
  '
@@ -199,7 +211,8 @@ class Boldgrid_Backup_Admin_Archives {
199
  <thead>
200
  <td>%1$s</td>
201
  <td>%2$s</td>
202
- <td></td>
 
203
  <tbody id="backup-archive-list-body">',
204
  __( 'Date', 'boldgrid-backup' ),
205
  __( 'Size', 'boldgrid-backup' )
@@ -232,8 +245,11 @@ class Boldgrid_Backup_Admin_Archives {
232
  href="admin.php?page=boldgrid-backup-archive-details&filename=%4$s"
233
  >%5$s</a>
234
  </td>
235
- </tr>
236
- ',
 
 
 
237
  /* 1 */ $backup,
238
  /* 2 */ empty( $title ) ? '' : '<strong>' . esc_html( $title ) . '</strong><br />',
239
  /* 3 */ Boldgrid_Backup_Admin_Utility::bytes_to_human( $archive['size'] ),
@@ -243,6 +259,7 @@ class Boldgrid_Backup_Admin_Archives {
243
  /* 7 */ $this->core->time->get_span()
244
  );
245
  }
 
246
  $table .= '</tbody>
247
  </table>
248
  ';
@@ -254,7 +271,7 @@ class Boldgrid_Backup_Admin_Archives {
254
  * the user (1) how they can create their first backup and (2) how they can schedule backups.
255
  */
256
  if ( empty( $this->core->archives_all->all ) ) {
257
- $table = '
258
  <div class="notice notice-warning inline" style="margin:15px 0">
259
  <p>
260
  <strong>
@@ -263,26 +280,46 @@ class Boldgrid_Backup_Admin_Archives {
263
  </p>
264
  <ol>
265
  <li>';
266
- $table .= wp_kses(
267
- sprintf(
268
- // translators: 1 an opening strong tag, 2 its closing strong tag.
269
- __( 'Create a backup of your site right now by clicking the %1$sBackup Site Now%2$s button at the top of the page.', 'boldgrid-backup' ),
270
- '<strong>',
271
- '</strong>'
272
- ),
273
- array( 'strong' => array() )
274
- );
275
- $table .= '</li><li>';
276
- $table .= wp_kses(
277
- sprintf(
278
- // translators: 1 the opening anchor tag linking to the settings page, 2 its closing anchor tag.
279
- __( 'After the backup is created, go to your %1$ssettings%2$s page and setup backups so they\'re create automatically on a set schedule.', 'boldgrid-backup' ),
280
- '<a href="' . $this->core->settings->get_settings_url() . '">',
281
- '</a>'
282
- ),
283
- array( 'a' => array( 'href' => array() ) )
284
- );
285
- $table .= '</li>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
286
  </ol>
287
  </div>';
288
  }
184
  *
185
  * @since 1.6.0
186
  *
187
+ * @param array $options {
188
+ * Display options.
189
+ *
190
+ * @type bool $show_link_button Display the "Get Download Link" button. Optional.
191
+ * @type bool $transfers_mode Alters messages for the transfers pages. Optional.
192
+ * }
193
  * @return string
194
  */
195
+ public function get_table( array $options = [] ) {
196
  $this->core->archives_all->init();
197
  $backup = __( 'Backup', 'boldgrid-backup' );
198
  $view_details = __( 'View details', 'boldgrid-backup' );
199
 
200
+ // If showing a "Get Download Link" button, we need a container to show the results.
201
+ $table = (
202
+ ! empty( $options['show_link_button'] ) ?
203
+ '<div id="download-link-copy" class="notice notice-info inline"></div>' : ''
204
+ );
205
+
206
+ $table .= $this->get_mine_count();
207
 
208
  $table .= sprintf(
209
  '
211
  <thead>
212
  <td>%1$s</td>
213
  <td>%2$s</td>
214
+ <td></td>' .
215
+ ( ! empty( $options['show_link_button'] ) ? '<td></td>' : '' ) . '
216
  <tbody id="backup-archive-list-body">',
217
  __( 'Date', 'boldgrid-backup' ),
218
  __( 'Size', 'boldgrid-backup' )
245
  href="admin.php?page=boldgrid-backup-archive-details&filename=%4$s"
246
  >%5$s</a>
247
  </td>
248
+ ' . (
249
+ // Show a "Get Download Link" button.
250
+ ! empty( $options['show_link_button'] ) ?
251
+ '<td>' . $this->core->archive_actions->get_download_link_button( $archive['filename'] ) . '</td>' : ''
252
+ ) . '</tr>',
253
  /* 1 */ $backup,
254
  /* 2 */ empty( $title ) ? '' : '<strong>' . esc_html( $title ) . '</strong><br />',
255
  /* 3 */ Boldgrid_Backup_Admin_Utility::bytes_to_human( $archive['size'] ),
259
  /* 7 */ $this->core->time->get_span()
260
  );
261
  }
262
+
263
  $table .= '</tbody>
264
  </table>
265
  ';
271
  * the user (1) how they can create their first backup and (2) how they can schedule backups.
272
  */
273
  if ( empty( $this->core->archives_all->all ) ) {
274
+ $table = '
275
  <div class="notice notice-warning inline" style="margin:15px 0">
276
  <p>
277
  <strong>
280
  </p>
281
  <ol>
282
  <li>';
283
+
284
+ if ( ! empty( $options['transfers_mode'] ) ) {
285
+ $table .= wp_kses(
286
+ sprintf(
287
+ // translators: 1 an opening strong tag, 2 its closing strong tag.
288
+ __( 'Go to the %1$sBackups%2$s page to create a backup of your site, and then come back here for further instruction.', 'boldgrid-backup' ),
289
+ '<em>',
290
+ '</em>'
291
+ ),
292
+ [ 'em' => [] ]
293
+ );
294
+ } else {
295
+ $table .= wp_kses(
296
+ sprintf(
297
+ // translators: 1 an opening strong tag, 2 its closing strong tag.
298
+ __( 'Create a backup of your site right now by clicking the %1$sBackup Site Now%2$s button at the top of the page.', 'boldgrid-backup' ),
299
+ '<strong>',
300
+ '</strong>'
301
+ ),
302
+ array( 'strong' => array() )
303
+ );
304
+ }
305
+
306
+ $table .= '</li>';
307
+
308
+ if ( empty( $options['transfers_mode'] ) ) {
309
+ $table .= '<li>';
310
+ $table .= wp_kses(
311
+ sprintf(
312
+ // translators: 1 the opening anchor tag linking to the settings page, 2 its closing anchor tag.
313
+ __( 'After the backup is created, go to your %1$ssettings%2$s page and setup backups so they\'re create automatically on a set schedule.', 'boldgrid-backup' ),
314
+ '<a href="' . $this->core->settings->get_settings_url() . '">',
315
+ '</a>'
316
+ ),
317
+ array( 'a' => array( 'href' => array() ) )
318
+ );
319
+ $table .= '</li>';
320
+ }
321
+
322
+ $table .= '
323
  </ol>
324
  </div>';
325
  }
admin/class-boldgrid-backup-admin-auto-rollback.php CHANGED
@@ -58,6 +58,23 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
58
  */
59
  private $core;
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  /**
62
  * Whether or not we are on an update page.
63
  *
@@ -295,6 +312,7 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
295
  'unknownError' => __( 'Unknown error.', 'boldgrid-backup' ),
296
  'ajaxError' => __( 'Could not reach the URL address. HTTP error: ', 'boldgrid-backup' ),
297
  'urlRegex' => $this->core->configs['url_regex'],
 
298
  );
299
 
300
  wp_localize_script( $handle, 'BoldGridBackupAdminHome', $translation );
@@ -599,6 +617,63 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
599
  }
600
  }
601
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
602
  /**
603
  * Return a bool indicating whether or not auto_rollback is enabled.
604
  *
@@ -1079,8 +1154,8 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
1079
  *
1080
  * @since 1.7.0
1081
  *
1082
- * @param array|false WordPress option value for "boldgrid_backup_pending_rollback".
1083
- * @param string Option name.
1084
  * @return array|false
1085
  */
1086
  public function validate_rollback_option( $value, $option ) {
@@ -1095,4 +1170,24 @@ class Boldgrid_Backup_Admin_Auto_Rollback {
1095
 
1096
  return $value;
1097
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1098
  }
58
  */
59
  private $core;
60
 
61
+ /**
62
+ * Time data.
63
+ *
64
+ * An array of time about when our auto rollback needs to occur.
65
+ *
66
+ * When we are setting our auto rollback cron, we need to get the time for 15 minutes from now
67
+ * (or whatever time limit is set in the config). When we parse that time, we split out the minute,
68
+ * hour, etc, to help build the cron command.
69
+ *
70
+ * After parsing the time, we save it in this class property.
71
+ *
72
+ * @since 1.11.0
73
+ * @access private
74
+ * @var array
75
+ */
76
+ private $time_data = [];
77
+
78
  /**
79
  * Whether or not we are on an update page.
80
  *
312
  'unknownError' => __( 'Unknown error.', 'boldgrid-backup' ),
313
  'ajaxError' => __( 'Could not reach the URL address. HTTP error: ', 'boldgrid-backup' ),
314
  'urlRegex' => $this->core->configs['url_regex'],
315
+ 'restore' => __( 'Restore', 'boldgrid-backup' ),
316
  );
317
 
318
  wp_localize_script( $handle, 'BoldGridBackupAdminHome', $translation );
617
  }
618
  }
619
 
620
+ /**
621
+ * Get our auto rollback time data.
622
+ *
623
+ * This code was originally contained within Boldgrid_Backup_Admin_Cron::add_restore_cron, but
624
+ * has since been separated out for reusability.
625
+ *
626
+ * @since 1.11.0
627
+ *
628
+ * @return array
629
+ */
630
+ public function get_time_data() {
631
+ if ( ! empty( $this->time_data ) ) {
632
+ return $this->time_data;
633
+ }
634
+
635
+ $time = [];
636
+
637
+ // Get the unix time for 5 minutes from now.
638
+ $time_5_minutes_later = strtotime( $this->testing_time );
639
+
640
+ // Get the system's localized current time (HH:MM:SS), 5 minutes in the future.
641
+ $system_time = $this->core->execute_command(
642
+ 'date "+%H|%M|%S|%a %d %b %Y %I:%M:00 %p %Z" -d "' . $this->testing_time . '"'
643
+ );
644
+
645
+ // Split the time into hour, minute, and second.
646
+ if ( ! empty( $system_time ) ) {
647
+ list(
648
+ $time['hour'],
649
+ $time['minute'],
650
+ $time['second'],
651
+ $time['system_time_iso']
652
+ ) = explode( '|', $system_time );
653
+ }
654
+
655
+ // Validate hour; use system hour, or the date code for hour ("G").
656
+ if ( ! isset( $time['hour'] ) ) {
657
+ $time['hour'] = 'G';
658
+ }
659
+
660
+ // Validate hour; use system hour, or the date code for minute ("i").
661
+ if ( ! isset( $time['minute'] ) ) {
662
+ $time['minute'] = 'i';
663
+ }
664
+
665
+ // Mark the deadline.
666
+ if ( ! empty( $time['system_time_iso'] ) ) {
667
+ $time['deadline'] = strtotime( $time['system_time_iso'] );
668
+ } else {
669
+ $time['deadline'] = $time_5_minutes_later;
670
+ }
671
+
672
+ $this->time_data = $time;
673
+
674
+ return $this->time_data;
675
+ }
676
+
677
  /**
678
  * Return a bool indicating whether or not auto_rollback is enabled.
679
  *
1154
  *
1155
  * @since 1.7.0
1156
  *
1157
+ * @param array|false $value WordPress option value for "boldgrid_backup_pending_rollback".
1158
+ * @param string $option Option name.
1159
  * @return array|false
1160
  */
1161
  public function validate_rollback_option( $value, $option ) {
1170
 
1171
  return $value;
1172
  }
1173
+
1174
+ /**
1175
+ * Callback function for canceling a pending rollback from the cli process.
1176
+ *
1177
+ * This admin-ajax call is unprovileged, so that the CLI script can make the call.
1178
+ * The only validation that we use is the backup identifier.
1179
+ * Nobody will be trying to cancel rollbacks (with a 15-minute window) anyways.
1180
+ *
1181
+ * @since 1.10.7
1182
+ */
1183
+ public function wp_ajax_cli_cancel() {
1184
+ $backup_id_match = ! empty( $_GET['backup_id'] ) && $this->core->get_backup_identifier() === sanitize_key( $_GET['backup_id'] ); // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification
1185
+
1186
+ if ( $backup_id_match ) {
1187
+ $this->cancel();
1188
+ wp_send_json_success( __( 'Rollback canceled', 'boldgrid-backup' ) );
1189
+ } else {
1190
+ wp_send_json_error( __( 'Invalid arguments', 'boldgrid-backup' ), 400 );
1191
+ }
1192
+ }
1193
  }
admin/class-boldgrid-backup-admin-core.php CHANGED
@@ -36,6 +36,22 @@ class Boldgrid_Backup_Admin_Core {
36
  */
37
  public $auto_rollback;
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  /**
40
  * The settings class object.
41
  *
@@ -148,6 +164,14 @@ class Boldgrid_Backup_Admin_Core {
148
  */
149
  public $tools;
150
 
 
 
 
 
 
 
 
 
151
  /**
152
  * An instance of Boldgrid_Backup_Admin_Support.
153
  *
@@ -606,6 +630,8 @@ class Boldgrid_Backup_Admin_Core {
606
 
607
  $this->tools = new Boldgrid_Backup_Admin_Tools( $this );
608
 
 
 
609
  $this->support = new Boldgrid_Backup_Admin_Support( $this );
610
 
611
  $this->time = new Boldgrid_Backup_Admin_Time( $this );
@@ -616,6 +642,10 @@ class Boldgrid_Backup_Admin_Core {
616
 
617
  $this->download = new Boldgrid_Backup_Download( $this );
618
 
 
 
 
 
619
  // Ensure there is a backup identifier.
620
  $this->get_backup_identifier();
621
 
@@ -771,27 +801,42 @@ class Boldgrid_Backup_Admin_Core {
771
  'preflight_check' => __( 'Preflight Check', 'boldgrid-backup' ),
772
  'settings' => __( 'Settings', 'boldgrid-backup' ),
773
  'tools' => __( 'Tools', 'boldgrid-backup' ),
 
774
  'support' => __( 'Support', 'boldgrid-backup' ),
775
  ];
776
 
777
  // The main slug all sub menu items are children of.
778
- $main_slug = 'boldgrid-backup';
779
 
780
  // The capability required for these menu items to be displayed to the user.
781
  $capability = 'administrator';
782
 
 
783
  add_menu_page(
784
  $lang['boldgrid_backup'],
785
  $lang['boldgrid_backup'],
786
  $capability,
787
  $main_slug,
788
  [
789
- $this,
790
- 'page_archives',
791
  ],
792
  'none'
793
  );
794
 
 
 
 
 
 
 
 
 
 
 
 
 
 
795
  // Add "Backup Archive", formally known as "BoldGrid Backup".
796
  add_submenu_page(
797
  $main_slug,
@@ -805,6 +850,32 @@ class Boldgrid_Backup_Admin_Core {
805
  ]
806
  );
807
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
808
  /*
809
  * Add "Settings", formally known as "Backup Settings".
810
  *
@@ -848,19 +919,6 @@ class Boldgrid_Backup_Admin_Core {
848
  ]
849
  );
850
 
851
- // Add "Tools" page.
852
- add_submenu_page(
853
- $main_slug,
854
- $lang['boldgrid_backup'] . ' ' . $lang['tools'],
855
- $lang['tools'],
856
- $capability,
857
- 'boldgrid-backup-tools',
858
- [
859
- $this->tools,
860
- 'page',
861
- ]
862
- );
863
-
864
  // Add "Support" page.
865
  add_submenu_page(
866
  $main_slug,
@@ -1416,7 +1474,7 @@ class Boldgrid_Backup_Admin_Core {
1416
  'ABSPATH' => ABSPATH,
1417
  'backup_id' => $this->get_backup_identifier(),
1418
  'siteurl' => site_url(),
1419
- 'timestamp' => time(),
1420
  // Environment information.
1421
  'gateway_interface' => getenv( 'GATEWAY_INTERFACE' ),
1422
  'http_host' => getenv( 'HTTP_HOST' ),
@@ -2510,7 +2568,7 @@ class Boldgrid_Backup_Admin_Core {
2510
  */
2511
  'want_to' => sprintf(
2512
  // translators: 1 Markup showing a "Google Drive" logo, 2 Markup showing an "Amazon S3" logo.
2513
- __( 'Want to store your backups on %1$s and %2$s, restore individual files with just a click, and have access to more tools? Get <strong>BoldGrid Backup Premium</strong>!', 'boldgrid-backup' ),
2514
  '<span class="bgbkup-remote-logo bgbkup-gdrive-logo" title="Google Drive"></span>',
2515
  '<span class="bgbkup-remote-logo amazon-s3-logo" title="Amazon S3"></span>'
2516
  ),
36
  */
37
  public $auto_rollback;
38
 
39
+ /**
40
+ * An instance of Boldgrid_Backup_Admin_Dashboard
41
+ *
42
+ * @since 1.11.0
43
+ * @var Boldgrid_Backup_Admin_Dashboard
44
+ */
45
+ public $dashboard;
46
+
47
+ /**
48
+ * Dashboard widget.
49
+ *
50
+ * @since 1.10.0
51
+ * @var Boldgrid_Backup_Admin_Dashboard_Widget
52
+ */
53
+ public $dashboard_widget;
54
+
55
  /**
56
  * The settings class object.
57
  *
164
  */
165
  public $tools;
166
 
167
+ /**
168
+ * An instance of Boldgrid_Backup_Admin_Transfers.
169
+ *
170
+ * @since 1.11.0
171
+ * @var Boldgrid_Backup_Admin_Transfers
172
+ */
173
+ public $transfers;
174
+
175
  /**
176
  * An instance of Boldgrid_Backup_Admin_Support.
177
  *
630
 
631
  $this->tools = new Boldgrid_Backup_Admin_Tools( $this );
632
 
633
+ $this->transfers = new Boldgrid_Backup_Admin_Transfers( $this );
634
+
635
  $this->support = new Boldgrid_Backup_Admin_Support( $this );
636
 
637
  $this->time = new Boldgrid_Backup_Admin_Time( $this );
642
 
643
  $this->download = new Boldgrid_Backup_Download( $this );
644
 
645
+ $this->dashboard_widget = new Boldgrid_Backup_Admin_Dashboard_Widget( $this );
646
+
647
+ $this->dashboard = new Boldgrid_Backup_Admin_Dashboard( $this );
648
+
649
  // Ensure there is a backup identifier.
650
  $this->get_backup_identifier();
651
 
801
  'preflight_check' => __( 'Preflight Check', 'boldgrid-backup' ),
802
  'settings' => __( 'Settings', 'boldgrid-backup' ),
803
  'tools' => __( 'Tools', 'boldgrid-backup' ),
804
+ 'transfers' => __( 'Transfers', 'boldgrid-backup' ),
805
  'support' => __( 'Support', 'boldgrid-backup' ),
806
  ];
807
 
808
  // The main slug all sub menu items are children of.
809
+ $main_slug = 'boldgrid-backup-dashboard';
810
 
811
  // The capability required for these menu items to be displayed to the user.
812
  $capability = 'administrator';
813
 
814
+ // Add the main menu item.
815
  add_menu_page(
816
  $lang['boldgrid_backup'],
817
  $lang['boldgrid_backup'],
818
  $capability,
819
  $main_slug,
820
  [
821
+ $this->dashboard,
822
+ 'page',
823
  ],
824
  'none'
825
  );
826
 
827
+ // Add our "Dashboard" page.
828
+ add_submenu_page(
829
+ $main_slug,
830
+ __( 'Dashboard', 'boldgrid-backup' ),
831
+ __( 'Dashboard', 'boldgrid-backup' ),
832
+ $capability,
833
+ 'boldgrid-backup-dashboard',
834
+ [
835
+ $this->dashboard,
836
+ 'page',
837
+ ]
838
+ );
839
+
840
  // Add "Backup Archive", formally known as "BoldGrid Backup".
841
  add_submenu_page(
842
  $main_slug,
850
  ]
851
  );
852
 
853
+ // Add "Transfers" page.
854
+ add_submenu_page(
855
+ $main_slug,
856
+ $lang['boldgrid_backup'] . ' ' . $lang['transfers'],
857
+ $lang['transfers'],
858
+ $capability,
859
+ 'boldgrid-backup-transfers',
860
+ [
861
+ $this->transfers,
862
+ 'page',
863
+ ]
864
+ );
865
+
866
+ // Add "Tools" page.
867
+ add_submenu_page(
868
+ $main_slug,
869
+ $lang['boldgrid_backup'] . ' ' . $lang['tools'],
870
+ $lang['tools'],
871
+ $capability,
872
+ 'boldgrid-backup-tools',
873
+ [
874
+ $this->tools,
875
+ 'page',
876
+ ]
877
+ );
878
+
879
  /*
880
  * Add "Settings", formally known as "Backup Settings".
881
  *
919
  ]
920
  );
921
 
 
 
 
 
 
 
 
 
 
 
 
 
 
922
  // Add "Support" page.
923
  add_submenu_page(
924
  $main_slug,
1474
  'ABSPATH' => ABSPATH,
1475
  'backup_id' => $this->get_backup_identifier(),
1476
  'siteurl' => site_url(),
1477
+ 'timestamp' => time(), // @todo Is this a duplicate value? $info['lastmodunix'] is added below.
1478
  // Environment information.
1479
  'gateway_interface' => getenv( 'GATEWAY_INTERFACE' ),
1480
  'http_host' => getenv( 'HTTP_HOST' ),
2568
  */
2569
  'want_to' => sprintf(
2570
  // translators: 1 Markup showing a "Google Drive" logo, 2 Markup showing an "Amazon S3" logo.
2571
+ __( 'Catastrophic data loss can happen at any time. Storing your archives in multiple secure locations will keep your website data safe and put your mind at ease. Upgrade to BoldGrid Premium to enable automated remote backups to %1$s and %2$s', 'boldgrid-backup' ),
2572
  '<span class="bgbkup-remote-logo bgbkup-gdrive-logo" title="Google Drive"></span>',
2573
  '<span class="bgbkup-remote-logo amazon-s3-logo" title="Amazon S3"></span>'
2574
  ),
admin/class-boldgrid-backup-admin-cron.php CHANGED
@@ -235,67 +235,18 @@ class Boldgrid_Backup_Admin_Cron {
235
  * @see BoldGrid_Backup_Admin_Cron::get_cron_secret()
236
  */
237
  public function add_restore_cron() {
238
- $pending_rollback = get_site_option( 'boldgrid_backup_pending_rollback' );
239
- $archives = $this->core->get_archive_list();
240
-
241
- // Use the first key to get info on the most recent archive.
242
- $archive_key = 0;
243
-
244
- $archive = $archives[ $archive_key ];
245
-
246
- $archive_filename = $archive['filename'];
247
-
248
  // Remove existing restore cron jobs.
249
  $this->delete_cron_entries( 'restore' );
250
 
251
- // Get the unix time for 5 minutes from now.
252
- $time_5_minutes_later = strtotime( $this->core->auto_rollback->testing_time );
253
-
254
- // Get the system's localized current time (HH:MM:SS), 5 minutes in the future.
255
- $system_time = $this->core->execute_command(
256
- 'date "+%H|%M|%S|%a %d %b %Y %I:%M:00 %p %Z" -d "' . $this->core->auto_rollback->testing_time . '"'
257
- );
258
-
259
- // Split the time into hour, minute, and second.
260
- if ( ! empty( $system_time ) ) {
261
- list( $hour, $minute, $second, $system_time_iso ) = explode( '|', $system_time );
262
- }
263
-
264
- // Validate hour; use system hour, or the date code for hour ("G").
265
- if ( ! isset( $hour ) ) {
266
- $hour = 'G';
267
- }
268
-
269
- // Validate hour; use system hour, or the date code for minute ("i").
270
- if ( ! isset( $minute ) ) {
271
- $minute = 'i';
272
- }
273
-
274
- // Mark the deadline.
275
- if ( ! empty( $system_time_iso ) ) {
276
- $deadline = strtotime( $system_time_iso );
277
- } else {
278
- $deadline = $time_5_minutes_later;
279
- }
280
-
281
- // Build cron job line in crontab format.
282
- $entry = date( $minute . ' ' . $hour, $deadline ) . ' * * ' . date( 'w' ) . ' ' . $this->cron_command . ' "' .
283
- dirname( dirname( __FILE__ ) ) . '/boldgrid-backup-cron.php" mode=restore siteurl=' .
284
- get_site_url() . ' id=' . $this->core->get_backup_identifier() . ' secret=' .
285
- $this->get_cron_secret() . ' archive_key=' . $archive_key .
286
- ' archive_filename=' . $archive_filename;
287
-
288
- // If not Windows, then also silence the cron job.
289
- if ( ! $this->core->test->is_windows() ) {
290
- $entry .= ' > /dev/null 2>&1';
291
- }
292
-
293
- // Update cron.
294
  $status = $this->update_cron( $entry );
 
295
 
296
  // If cron job was added, then update the boldgrid_backup_pending_rollback option with time.
297
  if ( $status ) {
298
- $pending_rollback['deadline'] = $deadline;
 
 
299
 
300
  update_site_option( 'boldgrid_backup_pending_rollback', $pending_rollback );
301
  }
@@ -553,7 +504,7 @@ class Boldgrid_Backup_Admin_Cron {
553
  if ( '' === $mode ) {
554
  $pattern .= 'boldgrid-backup-cron.php" mode=';
555
  } elseif ( 'restore' === $mode ) {
556
- $pattern .= 'boldgrid-backup-cron.php" mode=restore';
557
  } elseif ( true !== $mode ) {
558
  $pattern .= $mode;
559
  }
@@ -793,6 +744,60 @@ class Boldgrid_Backup_Admin_Cron {
793
  return $our;
794
  }
795
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
796
  /**
797
  * Read a line from the cron and return the schedule.
798
  *
235
  * @see BoldGrid_Backup_Admin_Cron::get_cron_secret()