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

Version Description

Download this release

Release Info

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

Code changes from version 1.12.6 to 1.13.0-rc.1

Files changed (44) hide show
  1. admin/card/class-amazon-s3.php +50 -0
  2. admin/card/class-backups.php +3 -0
  3. admin/card/class-database-encryption.php +50 -0
  4. admin/card/class-dream-objects.php +51 -0
  5. admin/card/class-google-drive.php +51 -0
  6. admin/card/class-historical-versions.php +51 -0
  7. admin/card/class-history.php +51 -0
  8. admin/card/class-one-click-restoration.php +51 -0
  9. admin/card/class-plugin-editor-tools.php +51 -0
  10. admin/card/feature/class-database-encryption.php +45 -0
  11. admin/class-boldgrid-backup-admin-compressor.php +50 -0
  12. admin/class-boldgrid-backup-admin-compressors.php +35 -3
  13. admin/class-boldgrid-backup-admin-config.php +3 -2
  14. admin/class-boldgrid-backup-admin-core.php +53 -7
  15. admin/class-boldgrid-backup-admin-in-progress-tmp.php +163 -0
  16. admin/class-boldgrid-backup-admin-in-progress.php +12 -42
  17. admin/class-boldgrid-backup-admin-premium-features.php +113 -0
  18. admin/class-boldgrid-backup-admin-settings.php +2 -0
  19. admin/class-boldgrid-backup-admin-test.php +16 -1
  20. admin/compressor/class-boldgrid-backup-admin-compressor-pcl-zip.php +20 -5
  21. admin/compressor/class-boldgrid-backup-admin-compressor-php-zip.php +10 -3
  22. admin/compressor/class-boldgrid-backup-admin-compressor-system-zip-temp-folder.php +82 -0
  23. admin/compressor/class-boldgrid-backup-admin-compressor-system-zip-test.php +303 -0
  24. admin/compressor/class-boldgrid-backup-admin-compressor-system-zip.php +227 -0
  25. admin/css/boldgrid-backup-admin-premium.css +110 -0
  26. admin/css/boldgrid-backup-admin.css +1 -1
  27. admin/image/db-lock-64.png +0 -0
  28. admin/image/remote/dreamhost-logo.png +0 -0
  29. admin/image/remote/google-drive.png +0 -0
  30. admin/partials/boldgrid-backup-admin-nav.php +19 -4
  31. admin/partials/boldgrid-backup-admin-premium.php +57 -0
  32. admin/partials/boldgrid-backup-admin-settings.php +6 -0
  33. admin/partials/boldgrid-backup-admin-test.php +6 -2
  34. admin/partials/settings/compressor.php +35 -35
  35. boldgrid-backup.php +1 -1
  36. coverage.xml +4921 -5528
  37. includes/class-boldgrid-backup.php +19 -5
  38. includes/config/config.plugin.php +16 -0
  39. readme.txt +8 -0
  40. vendor/autoload.php +1 -1
  41. vendor/boldgrid/library/.gitignore +1 -0
  42. vendor/boldgrid/library/README.md +6 -0
  43. vendor/boldgrid/library/bin/install-wp-tests.sh +2 -2
  44. vendor/boldgrid/library/src/Library/Plugin/Notice.php +159 -0
admin/card/class-amazon-s3.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Amazon_S3 class.
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since 1.13.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: Amazon_S3
18
+ *
19
+ * This class is responsible for rendering the "Amazon S3" card on this plugin's Premium Features page.
20
+ *
21
+ * @since 1.13.0
22
+ */
23
+ class Amazon_S3 extends \Boldgrid\Library\Library\Ui\Card {
24
+ /**
25
+ * Init.
26
+ *
27
+ * @since 1.13.0
28
+ */
29
+ public function init() {
30
+ $this->id = 'bgbkup_amazon_s3';
31
+
32
+ $this->title = esc_html__( 'Amazon S3', 'boldgrid-backup' );
33
+
34
+ $this->footer = '
35
+ <p>' .
36
+ esc_html__(
37
+ 'Safely store backups in the cloud via Amazon S3. Compatible with automated remote backups feature.',
38
+ 'boldgrid-backup' ) .
39
+ '</p>';
40
+
41
+ $url = esc_url( 'https://www.boldgrid.com/support/total-upkeep/backup-wordpress-to-amazon-s3/' );
42
+
43
+ $this->links = '
44
+ <a target="_blank" href="' . $url . '">' .
45
+ esc_html__( 'Setup Guide' ) . '
46
+ </a>';
47
+
48
+ $this->icon = '<img src="' . plugin_dir_url( __FILE__ ) . '../image/remote/amazon-s3-logo.png"></img>';
49
+ }
50
+ }
admin/card/class-backups.php CHANGED
@@ -39,5 +39,8 @@ class Backups extends \Boldgrid\Library\Library\Ui\Card {
39
  new Feature\Scheduled_Backups(),
40
  new Feature\Remote_Storage(),
41
  ];
 
 
 
42
  }
43
  }
39
  new Feature\Scheduled_Backups(),
40
  new Feature\Remote_Storage(),
41
  ];
42
+ if ( ! get_option( 'boldgrid_backup_settings' )['encrypt_db'] ) {
43
+ $this->features[] = new Feature\Database_Encryption();
44
+ }
45
  }
46
  }
admin/card/class-database-encryption.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Database Encryption class.
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since 1.13.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: Encryption
18
+ *
19
+ * This class is responsible for rendering the "Encryption" card on this plugin's Premium Features page.
20
+ *
21
+ * @since 1.13.0
22
+ */
23
+ class Database_Encryption extends \Boldgrid\Library\Library\Ui\Card {
24
+ /**
25
+ * Init.
26
+ *
27
+ * @since 1.13.0
28
+ */
29
+ public function init() {
30
+ $this->id = 'bgbkup_database_encryption';
31
+
32
+ $this->title = esc_html__( 'Database Encryption', 'boldgrid-backup' );
33
+
34
+ $this->footer = '
35
+ <p>' .
36
+ esc_html__(
37
+ 'Provides another level of protection by preventing unauthorized access to your database backup archives.',
38
+ 'boldgrid-backup' ) .
39
+ '</p>';
40
+
41
+ $url = esc_url( 'https://www.boldgrid.com/support/total-upkeep/encrypt-database-backups/' );
42
+
43
+ $this->links = '
44
+ <a target="_blank" href="' . $url . '">' .
45
+ esc_html__( 'Setup Guide' ) . '
46
+ </a>';
47
+
48
+ $this->icon = '<img src="' . plugin_dir_url( __FILE__ ) . '../image/db-lock-64.png" />';
49
+ }
50
+ }
admin/card/class-dream-objects.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Dream_Objects class.
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since 1.13.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: Dream_Objects
18
+ *
19
+ * This class is responsible for rendering the "Dream Objects" card
20
+ * on this plugin's Premium Features Page.
21
+ *
22
+ * @since 1.13.0
23
+ */
24
+ class Dream_Objects extends \Boldgrid\Library\Library\Ui\Card {
25
+ /**
26
+ * Init.
27
+ *
28
+ * @since 1.13.0
29
+ */
30
+ public function init() {
31
+ $this->id = 'bgbkup_dream_objects';
32
+
33
+ $this->title = esc_html__( 'DreamObjects', 'boldgrid-backup' );
34
+
35
+ $this->footer = '
36
+ <p>' .
37
+ esc_html__(
38
+ 'Safely store backups in the cloud via DreamObjects by DreamHost. Compatible with automated backups feature.',
39
+ 'boldgrid-backup' ) .
40
+ '</p>';
41
+
42
+ $url = esc_url( 'https://www.boldgrid.com/support/total-upkeep/dreamobjects-storage/' );
43
+
44
+ $this->links = '
45
+ <a target="_blank" href="' . $url . '">' .
46
+ esc_html__( 'Setup Guide' ) . '
47
+ </a>';
48
+
49
+ $this->icon = '<img src="' . plugin_dir_url( __FILE__ ) . '../image/remote/dreamhost-logo.png"></img>';
50
+ }
51
+ }
admin/card/class-google-drive.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Google Drive class.
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since 1.13.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: Google Drive
18
+ *
19
+ * This class is responsible for rendering the "Google drive" card on this
20
+ * plugin's Premium Features Page.
21
+ *
22
+ * @since 1.13.0
23
+ */
24
+ class Google_Drive extends \Boldgrid\Library\Library\Ui\Card {
25
+ /**
26
+ * Init.
27
+ *
28
+ * @since 1.13.0
29
+ */
30
+ public function init() {
31
+ $this->id = 'bgbkup_google_drive';
32
+
33
+ $this->title = esc_html__( 'Google Drive', 'boldgrid-backup' );
34
+
35
+ $this->icon = '<img src="' . plugin_dir_url( __FILE__ ) . '../image/remote/google-drive.png"></img>';
36
+
37
+ $this->footer = '
38
+ <p>' .
39
+ esc_html__(
40
+ 'Keep your backup archives safe and secure with remote, automated backups to Google Drive.',
41
+ 'boldgrid-backup' ) .
42
+ '</p>';
43
+
44
+ $url = esc_url( 'https://www.boldgrid.com/support/total-upkeep/auto-backup-to-google-drive/' );
45
+
46
+ $this->links = '
47
+ <a target="_blank" href=" ' . $url . '">' .
48
+ esc_html__( 'Setup Guide' ) . '
49
+ </a>';
50
+ }
51
+ }
admin/card/class-historical-versions.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * HistoricalVersions class.
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since 1.13.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: Historical_Versions
18
+ *
19
+ * This class is responsible for rendering the "Historical Versions" card on this
20
+ * plugin's Premium Features Page.
21
+ *
22
+ * @since 1.13.0
23
+ */
24
+ class Historical_Versions extends \Boldgrid\Library\Library\Ui\Card {
25
+ /**
26
+ * Init.
27
+ *
28
+ * @since 1.13.0
29
+ */
30
+ public function init() {
31
+ $this->id = 'bgbkup_historical_versions';
32
+
33
+ $this->title = esc_html__( 'Historical Versions', 'boldgrid-backup' );
34
+
35
+ $this->icon = '<span class="dashicons dashicons-images-alt2"></span>';
36
+
37
+ $this->footer = '
38
+ <p>' .
39
+ esc_html__(
40
+ 'Search through all backup archives for a particular, individual file and restore it.',
41
+ 'boldgrid-backup' ) .
42
+ '</p>';
43
+
44
+ $url = esc_url( 'https://www.boldgrid.com/support/total-upkeep/restore-historical-files/' );
45
+
46
+ $this->links = '
47
+ <a target="_blank" href="' . $url . '">' .
48
+ esc_html__( 'Setup Guide' ) . '
49
+ </a>';
50
+ }
51
+ }
admin/card/class-history.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * History class.
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since 1.13.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: History
18
+ *
19
+ * This class is responsible for rendering the "History" card on this plugin's
20
+ * Premium Features Page.
21
+ *
22
+ * @since 1.13.0
23
+ */
24
+ class History extends \Boldgrid\Library\Library\Ui\Card {
25
+ /**
26
+ * Init.
27
+ *
28
+ * @since 1.13.0
29
+ */
30
+ public function init() {
31
+ $this->id = 'bgbkup_history';
32
+
33
+ $this->title = esc_html__( 'Update History', 'boldgrid-backup' );
34
+
35
+ $this->icon = '<span class="dashicons dashicons-media-text"></span>';
36
+
37
+ $this->footer = '
38
+ <p>' .
39
+ esc_html__(
40
+ 'Search for all files modified within a certain time period. You can also look for other versions of that file within your backups.',
41
+ 'boldgrid-backup' ) .
42
+ '</p>';
43
+
44
+ $url = esc_url( 'https://www.boldgrid.com/support/total-upkeep/backup-changed-files-history/' );
45
+
46
+ $this->links = '
47
+ <a target="_blank" href="' . $url . '">' .
48
+ esc_html__( 'Setup Guide' ) . '
49
+ </a>';
50
+ }
51
+ }
admin/card/class-one-click-restoration.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * One_Click_Restoration class.
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since 1.13.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: One_Click_Restoration
18
+ *
19
+ * This class is responsible for rendering the "One Click Restoration" card
20
+ * on this plugin's Premium Features Page.
21
+ *
22
+ * @since 1.13.0
23
+ */
24
+ class One_Click_Restoration extends \Boldgrid\Library\Library\Ui\Card {
25
+ /**
26
+ * Init.
27
+ *
28
+ * @since 1.13.0
29
+ */
30
+ public function init() {
31
+ $this->id = 'bgbkup_one_click_restoration';
32
+
33
+ $this->title = esc_html__( 'One Click File Restorations', 'boldgrid-backup' );
34
+
35
+ $this->icon = '<span class="dashicons dashicons-undo"></span>';
36
+
37
+ $this->footer = '
38
+ <p>' .
39
+ esc_html__(
40
+ 'Restore a single file within the backup browser. Helpful when modifying individual files.',
41
+ 'boldgrid-backup' ) .
42
+ '</p>';
43
+
44
+ $url = esc_url( 'https://www.boldgrid.com/support/total-upkeep/individual-file-restorations/' );
45
+
46
+ $this->links = '
47
+ <a target="_blank" href="' . $url . '">' .
48
+ esc_html__( 'Setup Guide' ) . '
49
+ </a>';
50
+ }
51
+ }
admin/card/class-plugin-editor-tools.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PluginEditorTools class.
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since 1.13.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: Plugin_Editor_Tools
18
+ *
19
+ * This class is responsible for rendering the "Plugin Editor Tools"
20
+ * card on this plugin's Premium Features Page.
21
+ *
22
+ * @since 1.13.0
23
+ */
24
+ class Plugin_Editor_Tools extends \Boldgrid\Library\Library\Ui\Card {
25
+ /**
26
+ * Init.
27
+ *
28
+ * @since 1.13.0
29
+ */
30
+ public function init() {
31
+ $this->id = 'bgbkup_plugin_editor_tools';
32
+
33
+ $this->title = esc_html__( 'Plugin Editor Tools', 'boldgrid-backup' );
34
+
35
+ $this->icon = '<span class="dashicons dashicons-media-code"></span>';
36
+
37
+ $this->footer = '
38
+ <p>' .
39
+ esc_html__(
40
+ 'When using the WordPress Plugin Editor, Total Upkeep Premium will save a copy of the file in case you need to undo any changes.',
41
+ 'boldgrid-backup' ) .
42
+ '</p>';
43
+
44
+ $url = esc_url( 'https://www.boldgrid.com/support/total-upkeep/plugin-editor-backup/' );
45
+
46
+ $this->links = '
47
+ <a target="_blank" href="' . $url . '">' .
48
+ esc_html__( 'Setup Guide' ) . '
49
+ </a>';
50
+ }
51
+ }
admin/card/feature/class-database-encryption.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Database_Encryption class.
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since 1.13.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: Database_Encryption
18
+ *
19
+ * @since 1.13.0
20
+ */
21
+ class Database_Encryption extends \Boldgrid\Library\Library\Ui\Feature {
22
+ /**
23
+ * Init.
24
+ *
25
+ * @since 1.13.0
26
+ */
27
+ public function init() {
28
+ $core = apply_filters( 'boldgrid_backup_get_core', null );
29
+
30
+ $this->icon = '<img class="feature-icon" src="' . plugin_dir_url( BOLDGRID_BACKUP_PATH ) . 'boldgrid-backup/admin/image/db-lock-64.png" />';
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.
38
+ __( 'Database Encryption is not configured. %1$sFix this%2$s', 'boldgrid-backup' ),
39
+ '<a href="' . esc_url( $core->settings->get_settings_url( 'section_security' ) ) . '">',
40
+ '</a>'
41
+ ),
42
+ [ 'a' => [ 'href' => [] ] ]
43
+ ) . '</p></div>';
44
+ }
45
+ }
admin/class-boldgrid-backup-admin-compressor.php CHANGED
@@ -74,4 +74,54 @@ class Boldgrid_Backup_Admin_Compressor {
74
  public function archive_files( $filelist, &$info ) {
75
  return false;
76
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  }
74
  public function archive_files( $filelist, &$info ) {
75
  return false;
76
  }
77
+
78
+ /**
79
+ * Determine whether or not this compressor is available.
80
+ *
81
+ * @since SINCEVERSION
82
+ *
83
+ * @param string $compressor A compressor.
84
+ * @return bool True if is available.
85
+ */
86
+ public function is_available() {
87
+ return in_array( $this->key, $this->core->compressors->get_available(), true );
88
+ }
89
+
90
+ /**
91
+ * Determine whether or not the given compressor is the default.
92
+ *
93
+ * @since SINCEVERSION
94
+ *
95
+ * @param string $compressor A compressor.
96
+ * @return bool True if is default compressor.
97
+ */
98
+ public function is_default() {
99
+ return $this->key === $this->core->compressors->get_default();
100
+ }
101
+
102
+ /**
103
+ * Determine whether or not the given compressor is the one saved in the settings.
104
+ *
105
+ * @since SINCEVERSION
106
+ *
107
+ * @param string $compressor A compressor.
108
+ * @return bool True if compressor is saved in settings.
109
+ */
110
+ public function is_saved_compressor() {
111
+ return $this->key === $this->core->settings->get_setting( 'compressor' );
112
+ }
113
+
114
+ /**
115
+ * Whether or not this compressor should be selected if it is in an array of available compressors.
116
+ *
117
+ * Used in a <select> element.
118
+ *
119
+ * @return bool
120
+ */
121
+ public function maybe_selected_compressor() {
122
+ $setting = $this->core->settings->get_setting( 'compressor' );
123
+
124
+ return $this->is_saved_compressor() ||
125
+ ( empty( $setting ) && $this->is_default() );
126
+ }
127
  }
admin/class-boldgrid-backup-admin-compressors.php CHANGED
@@ -28,10 +28,12 @@ class Boldgrid_Backup_Admin_Compressors {
28
  private $core;
29
 
30
  /**
31
- * The default compressors.
32
  *
33
  * WordPress ships out of the box with pcl_zip.
34
  *
 
 
35
  * @since 1.5.1
36
  * @access public
37
  * @var string
@@ -52,7 +54,7 @@ class Boldgrid_Backup_Admin_Compressors {
52
  * If ZipArchive is available, make it the default. Tests show it is
53
  * superior to PclZip.
54
  */
55
- if ( class_exists( 'Boldgrid_Backup_Admin_Compressor_Php_Zip' ) && Boldgrid_Backup_Admin_Compressor_Php_Zip::is_available() ) {
56
  $this->default = 'php_zip';
57
  }
58
  }
@@ -91,6 +93,36 @@ class Boldgrid_Backup_Admin_Compressors {
91
  return $this->core->config->get_available_compressors();
92
  }
93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  /**
95
  * Set php_zip (ZipArchive) as our compressor/extractor.
96
  *
@@ -99,7 +131,7 @@ class Boldgrid_Backup_Admin_Compressors {
99
  * @return bool True on success.
100
  */
101
  public function set_php_zip() {
102
- if ( Boldgrid_Backup_Admin_Compressor_Php_Zip::is_available() ) {
103
  $settings = $this->core->settings->get_settings();
104
  $settings['compressor'] = 'php_zip';
105
  $settings['extractor'] = 'php_zip';
28
  private $core;
29
 
30
  /**
31
+ * The default compressor.
32
  *
33
  * WordPress ships out of the box with pcl_zip.
34
  *
35
+ * In the contructor, if php_zip is available, it will be set as the default.
36
+ *
37
  * @since 1.5.1
38
  * @access public
39
  * @var string
54
  * If ZipArchive is available, make it the default. Tests show it is
55
  * superior to PclZip.
56
  */
57
+ if ( class_exists( 'Boldgrid_Backup_Admin_Compressor_Php_Zip' ) && Boldgrid_Backup_Admin_Compressor_Php_Zip::is_extension_available() ) {
58
  $this->default = 'php_zip';
59
  }
60
  }
93
  return $this->core->config->get_available_compressors();
94
  }
95
 
96
+ /**
97
+ * Get the default compressor.
98
+ *
99
+ * @since SINCEVERSION
100
+ *
101
+ * @return string
102
+ */
103
+ public function get_default() {
104
+ return $this->default;
105
+ }
106
+
107
+ /**
108
+ * Get our compressor object.
109
+ *
110
+ * @since SINCEVERSION
111
+ *
112
+ * @param string $compressor The id of a compressor to get.
113
+ * @return mixed
114
+ */
115
+ public function get_object( $compressor ) {
116
+ switch ( $compressor ) {
117
+ case 'pcl_zip':
118
+ return new Boldgrid_Backup_Admin_Compressor_Pcl_Zip( $this->core );
119
+ case 'php_zip':
120
+ return new Boldgrid_Backup_Admin_Compressor_Php_Zip( $this->core );
121
+ case 'system_zip':
122
+ return new Boldgrid_Backup_Admin_Compressor_System_Zip( $this->core );
123
+ }
124
+ }
125
+
126
  /**
127
  * Set php_zip (ZipArchive) as our compressor/extractor.
128
  *
131
  * @return bool True on success.
132
  */
133
  public function set_php_zip() {
134
+ if ( Boldgrid_Backup_Admin_Compressor_Php_Zip::is_extension_available() ) {
135
  $settings = $this->core->settings->get_settings();
136
  $settings['compressor'] = 'php_zip';
137
  $settings['extractor'] = 'php_zip';
admin/class-boldgrid-backup-admin-config.php CHANGED
@@ -431,7 +431,7 @@ class Boldgrid_Backup_Admin_Config {
431
  $this->available_compressors = array();
432
 
433
  // PHP zip (ZipArchive).
434
- if ( Boldgrid_Backup_Admin_Compressor_Php_Zip::is_available() ) {
435
  $this->add_compressor( 'php_zip' );
436
  }
437
 
@@ -465,7 +465,8 @@ class Boldgrid_Backup_Admin_Config {
465
  }
466
 
467
  // System zip.
468
- if ( $this->core->execute_command( '/usr/bin/zip -v ' ) ) {
 
469
  $this->add_compressor( 'system_zip' );
470
  }
471
 
431
  $this->available_compressors = array();
432
 
433
  // PHP zip (ZipArchive).
434
+ if ( Boldgrid_Backup_Admin_Compressor_Php_Zip::is_extension_available() ) {
435
  $this->add_compressor( 'php_zip' );
436
  }
437
 
465
  }
466
 
467
  // System zip.
468
+ $system_zip_test = new Boldgrid_Backup_Admin_Compressor_System_Zip_Test( $this->core );
469
+ if ( $system_zip_test->run() ) {
470
  $this->add_compressor( 'system_zip' );
471
  }
472
 
admin/class-boldgrid-backup-admin-core.php CHANGED
@@ -76,6 +76,14 @@ class Boldgrid_Backup_Admin_Core {
76
  */
77
  public $configs;
78
 
 
 
 
 
 
 
 
 
79
  /**
80
  * Core Files class.
81
  *
@@ -180,6 +188,14 @@ class Boldgrid_Backup_Admin_Core {
180
  */
181
  public $support;
182
 
 
 
 
 
 
 
 
 
183
  /**
184
  * An instance of Boldgrid_Backup_Admin_Utility.
185
  *
@@ -560,6 +576,9 @@ class Boldgrid_Backup_Admin_Core {
560
 
561
  $this->pagenow = $pagenow;
562
 
 
 
 
563
  // Instantiate Boldgrid_Backup_Admin_Settings.
564
  $this->settings = new Boldgrid_Backup_Admin_Settings( $this );
565
 
@@ -662,11 +681,13 @@ class Boldgrid_Backup_Admin_Core {
662
 
663
  $this->dashboard = new Boldgrid_Backup_Admin_Dashboard( $this );
664
 
 
 
 
 
665
  // Ensure there is a backup identifier.
666
  $this->get_backup_identifier();
667
 
668
- $this->configs = Boldgrid_Backup_Admin::get_configs();
669
-
670
  $this->set_lang();
671
 
672
  // Log system.
@@ -871,6 +892,7 @@ class Boldgrid_Backup_Admin_Core {
871
  'tools' => esc_html__( 'Tools', 'boldgrid-backup' ),
872
  'transfers' => esc_html__( 'Transfers', 'boldgrid-backup' ),
873
  'support' => esc_html__( 'Support', 'boldgrid-backup' ),
 
874
  ];
875
 
876
  // The main slug all sub menu items are children of.
@@ -882,7 +904,8 @@ class Boldgrid_Backup_Admin_Core {
882
  // Add the main menu item.
883
  add_menu_page(
884
  $lang['boldgrid_backup'],
885
- $lang['boldgrid_backup'],
 
886
  $capability,
887
  $main_slug,
888
  [
@@ -1000,6 +1023,20 @@ class Boldgrid_Backup_Admin_Core {
1000
  ]
1001
  );
1002
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1003
  /*
1004
  * Add our "Get Premium" link to the navigation.
1005
  *
@@ -1682,11 +1719,20 @@ class Boldgrid_Backup_Admin_Core {
1682
  */
1683
  $info = apply_filters( 'boldgrid_backup_pre_archive_info', $info );
1684
 
1685
- Boldgrid_Backup_Admin_In_Progress_Data::set_args( [ 'total_files_todo' => count( $filelist ) ] );
1686
-
1687
  $this->logger->add( 'Starting archiving of files. Chosen compressor: ' . $info['compressor'] );
1688
  $this->logger->add_memory();
1689
 
 
 
 
 
 
 
 
 
 
 
 
1690
  /*
1691
  * Use the chosen compressor to build an archive.
1692
  * If the is no available compressor, then return an error.
@@ -1717,8 +1763,8 @@ class Boldgrid_Backup_Admin_Core {
1717
  $info['filepath'] = $this->generate_archive_path( 'tar.gz' );
1718
  break;
1719
  case 'system_zip':
1720
- // Generate a new archive file path.
1721
- $info['filepath'] = $this->generate_archive_path( 'zip' );
1722
  break;
1723
  default:
1724
  $status = [ 'error' => 'No available compressor' ];
76
  */
77
  public $configs;
78
 
79
+ /**
80
+ * Plugin class.
81
+ *
82
+ * @since 1.13.0
83
+ * @var Boldgrid\Library\Library\Plugin\Plugin
84
+ */
85
+ public $plugin;
86
+
87
  /**
88
  * Core Files class.
89
  *
188
  */
189
  public $support;
190
 
191
+ /**
192
+ * An instance of Boldgrid_Backup_Admin_Premium.
193
+ *
194
+ * @since 1.12.4
195
+ * @var Boldgrid_Backup_Admin_Premium_Features
196
+ */
197
+ public $premium_page;
198
+
199
  /**
200
  * An instance of Boldgrid_Backup_Admin_Utility.
201
  *
576
 
577
  $this->pagenow = $pagenow;
578
 
579
+ // Instantiate Configs Array
580
+ $this->configs = Boldgrid_Backup_Admin::get_configs();
581
+
582
  // Instantiate Boldgrid_Backup_Admin_Settings.
583
  $this->settings = new Boldgrid_Backup_Admin_Settings( $this );
584
 
681
 
682
  $this->dashboard = new Boldgrid_Backup_Admin_Dashboard( $this );
683
 
684
+ // Instantiate Boldgrid\Library\Library\Plugin\Plugin.
685
+ $this->plugin = new \Boldgrid\Library\Library\Plugin\Plugin( 'boldgrid-backup', $this->configs );
686
+ $this->premium_page = new Boldgrid_Backup_Admin_Premium_Features( $this );
687
+
688
  // Ensure there is a backup identifier.
689
  $this->get_backup_identifier();
690
 
 
 
691
  $this->set_lang();
692
 
693
  // Log system.
892
  'tools' => esc_html__( 'Tools', 'boldgrid-backup' ),
893
  'transfers' => esc_html__( 'Transfers', 'boldgrid-backup' ),
894
  'support' => esc_html__( 'Support', 'boldgrid-backup' ),
895
+ 'premium' => esc_html__( 'Premium Features', 'boldgrid-backup' ),
896
  ];
897
 
898
  // The main slug all sub menu items are children of.
904
  // Add the main menu item.
905
  add_menu_page(
906
  $lang['boldgrid_backup'],
907
+ // This value is escaped already by Library\Plugin\Page::getUnreadMarkup
908
+ $lang['boldgrid_backup'] . $this->plugin->getUnreadMarkup(),
909
  $capability,
910
  $main_slug,
911
  [
1023
  ]
1024
  );
1025
 
1026
+ // Add "Premium" page.
1027
+ add_submenu_page(
1028
+ $main_slug,
1029
+ $lang['boldgrid_backup'] . ' ' . $lang['premium'],
1030
+ // Count value is escaped already by Library\Plugin\Page::getUnreadMarkup
1031
+ $lang['premium'] . $this->plugin->getPageBySlug( 'boldgrid-backup-premium-features' )->getUnreadMarkup(),
1032
+ $capability,
1033
+ 'boldgrid-backup-premium-features',
1034
+ [
1035
+ $this->premium_page,
1036
+ 'page',
1037
+ ]
1038
+ );
1039
+
1040
  /*
1041
  * Add our "Get Premium" link to the navigation.
1042
  *
1719
  */
1720
  $info = apply_filters( 'boldgrid_backup_pre_archive_info', $info );
1721
 
 
 
1722
  $this->logger->add( 'Starting archiving of files. Chosen compressor: ' . $info['compressor'] );
1723
  $this->logger->add_memory();
1724
 
1725
+ // Determine the path to our zip file.
1726
+ $info['filepath'] = $this->generate_archive_path( 'zip' );
1727
+
1728
+ Boldgrid_Backup_Admin_In_Progress_Data::set_args(
1729
+ [
1730
+ 'total_files_todo' => count( $filelist ),
1731
+ 'filepath' => $info['filepath'],
1732
+ 'compressor' => $info['compressor'],
1733
+ ]
1734
+ );
1735
+
1736
  /*
1737
  * Use the chosen compressor to build an archive.
1738
  * If the is no available compressor, then return an error.
1763
  $info['filepath'] = $this->generate_archive_path( 'tar.gz' );
1764
  break;
1765
  case 'system_zip':
1766
+ $compressor = new Boldgrid_Backup_Admin_Compressor_System_Zip( $this );
1767
+ $status = $compressor->archive_files( $filelist, $info );
1768
  break;
1769
  default:
1770
  $status = [ 'error' => 'No available compressor' ];
admin/class-boldgrid-backup-admin-in-progress-tmp.php ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * File: class-boldgrid-backup-admin-in-progress-tmp.php
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since SINCEVERSION
7
+ *
8
+ * @package Boldgrid_Backup
9
+ * @subpackage Boldgrid_Backup/admin
10
+ * @copyright BoldGrid
11
+ * @author BoldGrid <support@boldgrid.com>
12
+ */
13
+
14
+ /**
15
+ * Class: Boldgrid_Backup_Admin_In_Progress_Tmp
16
+ *
17
+ * When an archive is being created, it is first created in a temporary file, then finally moved to
18
+ * the ending .zip file.
19
+ *
20
+ * This is a utility class used for getting information about these temporary files. They differ based
21
+ * on the compressor that is being used.
22
+ *
23
+ * Examples of the different compressors' tmp files:
24
+ * pcl_zip: /backup_dir/backup.zip Does not create a temporary file.
25
+ * php_zip: /backup_dir/backup.zip.Evubai
26
+ * system_zip: /backup_dir/system_zip_temp/zigWlkvV The "system_zip_temp" folder is optional and
27
+ * created by us.
28
+ *
29
+ * @since SINCEVERSION
30
+ */
31
+ class Boldgrid_Backup_Admin_In_Progress_Tmp {
32
+ /**
33
+ * An instance of core.
34
+ *
35
+ * @since SINCEVERSION
36
+ * @access private
37
+ * @var Boldgrid_Backup_Admin_Core
38
+ */
39
+ private $core;
40
+
41
+ /**
42
+ * Constructor.
43
+ *
44
+ * @since SINCEVERSION
45
+ *
46
+ * @param Boldgrid_Backup_Admin_Core $core
47
+ */
48
+ public function __construct( $core = null ) {
49
+ $this->core = ! empty( $core ) ? $core : apply_filters( 'boldgrid_backup_get_core', null );
50
+ }
51
+
52
+ /**
53
+ * Get an array of data for the temporary .zip file.
54
+ *
55
+ * @since SINCEVERSION
56
+ *
57
+ * @return array
58
+ */
59
+ public function get() {
60
+ $data = [];
61
+
62
+ $compressor = Boldgrid_Backup_Admin_In_Progress_Data::get_arg( 'compressor' );
63
+
64
+ switch ( $compressor ) {
65
+ case 'system_zip':
66
+ $data = $this->get_system_zip();
67
+ break;
68
+ case 'php_zip':
69
+ $data = $this->get_php_zip();
70
+ break;
71
+ case 'pcl_zip':
72
+ $data = $this->get_pcl_zip();
73
+ break;
74
+ }
75
+
76
+ return $data;
77
+ }
78
+
79
+ /**
80
+ * Get temporary .zip file info for system_zip compressor.
81
+ *
82
+ * @since SINCEVERSION
83
+ *
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
+ $size = 0;
90
+ $lastmodunix = 0;
91
+
92
+ foreach ( $dirlist as $file ) {
93
+ $size += ! empty( $file['size'] ) ? $file['size'] : 0;
94
+
95
+ $lastmodunix = ! empty( $file['lastmodunix'] ) ? $file['lastmodunix'] : $lastmodunix;
96
+ }
97
+
98
+ return [
99
+ 'size' => $size,
100
+ 'lastmodunix' => $lastmodunix,
101
+ 'size_format' => size_format( $size, 2 ),
102
+ ];
103
+ }
104
+
105
+ /**
106
+ * Get data for pcl_zip.
107
+ *
108
+ * @since SINCEVERSION
109
+ *
110
+ * @return array
111
+ */
112
+ private function get_pcl_zip() {
113
+ $data = [];
114
+
115
+ $filepath = Boldgrid_Backup_Admin_In_Progress_Data::get_arg( 'filepath' );
116
+ $filename = basename( $filepath );
117
+
118
+ $dirlist = $this->core->backup_dir->dirlist_containing( $filename );
119
+
120
+ if ( ! empty( $dirlist[ $filename ] ) ) {
121
+ $data = [
122
+ 'size' => $dirlist[ $filename ]['size'],
123
+ 'lastmodunix' => $dirlist[ $filename ]['lastmodunix'],
124
+ 'size_format' => size_format( $dirlist[ $filename ]['size'], 2 ),
125
+ ];
126
+ }
127
+
128
+ return $data;
129
+ }
130
+
131
+ /**
132
+ * Get temporary .zip file info for system_zip compressor.
133
+ *
134
+ * This method originally lived in the Boldgrid_Backup_Admin_In_Progress class and handled getting
135
+ * data for the php_zip compressor. It was moved to this new class in order to more effecitvely
136
+ * account for system_zip and other compressors (in the future).
137
+ *
138
+ * @since 1.7.0
139
+ *
140
+ * @return array
141
+ */
142
+ private function get_php_zip() {
143
+ $data = [];
144
+
145
+ $filepath = Boldgrid_Backup_Admin_In_Progress_Data::get_arg( 'filepath' );
146
+ $filename = basename( $filepath );
147
+
148
+ $dirlist = $this->core->backup_dir->dirlist_containing( $filename . '.' );
149
+
150
+ // We're looping, but there should only be one item in the array.
151
+ foreach ( $dirlist as $info ) {
152
+ $data = [
153
+ 'size' => $info['size'],
154
+ 'lastmodunix' => $info['lastmodunix'],
155
+ 'size_format' => size_format( $info['size'], 2 ),
156
+ ];
157
+
158
+ break;
159
+ }
160
+
161
+ return $data;
162
+ }
163
+ }
admin/class-boldgrid-backup-admin-in-progress.php CHANGED
@@ -26,6 +26,15 @@ class Boldgrid_Backup_Admin_In_Progress {
26
  */
27
  private $core;
28
 
 
 
 
 
 
 
 
 
 
29
  /**
30
  * A unix timestamp indicating when a backup was started.
31
  *
@@ -47,6 +56,8 @@ class Boldgrid_Backup_Admin_In_Progress {
47
  */
48
  public function __construct( $core ) {
49
  $this->core = $core;
 
 
50
  }
51
 
52
  /**
@@ -215,47 +226,6 @@ class Boldgrid_Backup_Admin_In_Progress {
215
  return $markup;
216
  }
217
 
218
- /**
219
- * Get details on our temporary zip file.
220
- *
221
- * For example, if we're in the middle of saving / closing our backup file, there should be a
222
- * file.zip.temp file in our backup directory. We are getting the details of that file.
223
- *
224
- * @since 1.7.0
225
- *
226
- * @return array
227
- */
228
- public function get_tmp() {
229
- $data = array();
230
-
231
- $dirlist = $this->core->backup_dir->dirlist_containing( '.zip.' );
232
-
233
- /*
234
- * We should only have one temp zip file. If we have multiple though, something may have
235
- * gone recently. Sort by timestamp and use the newest file.
236
- */
237
- if ( 1 < count( $dirlist ) ) {
238
- uasort(
239
- $dirlist, function( $item1, $item2 ) {
240
- return $item1['lastmodunix'] < $item2['lastmodunix'] ? 1 : -1;
241
- }
242
- );
243
- }
244
-
245
- if ( 1 <= count( $dirlist ) ) {
246
- reset( $dirlist );
247
- $tmp_filename = key( $dirlist );
248
-
249
- $data = array(
250
- 'size' => $dirlist[ $tmp_filename ]['size'],
251
- 'lastmodunix' => $dirlist[ $tmp_filename ]['lastmodunix'],
252
- 'size_format' => size_format( $dirlist[ $tmp_filename ]['size'], 2 ),
253
- );
254
- }
255
-
256
- return $data;
257
- }
258
-
259
  /**
260
  * Take action when the heartbeat is received.
261
  *
@@ -291,7 +261,7 @@ class Boldgrid_Backup_Admin_In_Progress {
291
 
292
  // Steps to take if we're on the last step, step 3, closing the archive.
293
  if ( 3 === Boldgrid_Backup_Admin_In_Progress_Data::get_arg( 'step' ) ) {
294
- $tmp = $this->get_tmp();
295
  if ( ! empty( $tmp ) ) {
296
  $response['in_progress_data']['tmp'] = $tmp;
297
  }
26
  */
27
  private $core;
28
 
29
+ /**
30
+ * Our tmp class.
31
+ *
32
+ * @since SINCEVERSION
33
+ * @access private
34
+ * @var Boldgrid_Backup_Admin_In_Progress_Tmp
35
+ */
36
+ private $tmp;
37
+
38
  /**
39
  * A unix timestamp indicating when a backup was started.
40
  *
56
  */
57
  public function __construct( $core ) {
58
  $this->core = $core;
59
+
60
+ $this->tmp = new Boldgrid_Backup_Admin_In_Progress_Tmp( $this->core );
61
  }
62
 
63
  /**
226
  return $markup;
227
  }
228
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
  /**
230
  * Take action when the heartbeat is received.
231
  *
261
 
262
  // Steps to take if we're on the last step, step 3, closing the archive.
263
  if ( 3 === Boldgrid_Backup_Admin_In_Progress_Data::get_arg( 'step' ) ) {
264
+ $tmp = $this->tmp->get();
265
  if ( ! empty( $tmp ) ) {
266
  $response['in_progress_data']['tmp'] = $tmp;
267
  }
admin/class-boldgrid-backup-admin-premium-features.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * File: class-boldgrid-backup-admin-premium-features.php
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since 1.13.0
7
+ *
8
+ * @package Boldgrid_Backup
9
+ * @subpackage Boldgrid_Backup/admin
10
+ * @copyright BoldGrid
11
+ * @version $Id$
12
+ * @author BoldGrid <support@boldgrid.com>
13
+ */
14
+
15
+ use Boldgrid\Backup\Admin\Card;
16
+
17
+ /**
18
+ * Class: Boldgrid_Backup_Admin_Premium_Features
19
+ *
20
+ * @since 1.13.0
21
+ */
22
+ class Boldgrid_Backup_Admin_Premium_Features {
23
+
24
+ /**
25
+ * The core class object.
26
+ *
27
+ * @since 1.13.0
28
+ * @var Boldgrid_Backup_Admin_Core
29
+ */
30
+ public $core;
31
+
32
+ /**
33
+ * The page's Boldgrid\Library\Library\Plugin\Page Object.
34
+ *
35
+ * @since 1.13.0
36
+ * @access private
37
+ * @var Boldgrid\Library\Library\Plugin\Page
38
+ */
39
+ private $page;
40
+
41
+ /**
42
+ * Constructor.
43
+ *
44
+ * @since 1.13.0
45
+ *
46
+ * @param Boldgrid_Backup_Admin_Core $core Core class object.
47
+ */
48
+ public function __construct( Boldgrid_Backup_Admin_Core $core ) {
49
+ $this->core = $core;
50
+ }
51
+
52
+ /**
53
+ * Enqueue scripts.
54
+ *
55
+ * @since 1.13.0
56
+ *
57
+ * @param string $hook Hook name.
58
+ */
59
+ public function admin_enqueue_scripts( $hook ) {
60
+ if ( isset( $_REQUEST['page'] ) && 'boldgrid-backup-premium-features' === $_REQUEST['page'] ) { // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification
61
+ wp_enqueue_style(
62
+ 'boldgrid-backup-admin-premium-features',
63
+ plugin_dir_url( __FILE__ ) . 'css/boldgrid-backup-admin-premium.css', array(),
64
+ BOLDGRID_BACKUP_VERSION
65
+ );
66
+ }
67
+ }
68
+
69
+ /**
70
+ * Get cards needed for the dashboard.
71
+ *
72
+ * @since 1.13.0
73
+ *
74
+ * @return array
75
+ */
76
+ public function get_cards() {
77
+ $plugin = $this->core->plugin;
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 ),
84
+ new Card\Dream_Objects( $this->page ),
85
+ new Card\One_Click_Restoration( $this->page ),
86
+ new Card\History( $this->page ),
87
+ new Card\Historical_Versions( $this->page ),
88
+ new Card\Plugin_Editor_Tools( $this->page ),
89
+ ];
90
+
91
+ return $cards;
92
+ }
93
+
94
+ /**
95
+ * Render the dashboard page.
96
+ *
97
+ * @since 1.13.0
98
+ *
99
+ * @return array returns an array of the $nav, $dashboard, and $premium_box for validation.
100
+ */
101
+ public function page() {
102
+ wp_enqueue_style( 'bglib-ui-css' );
103
+
104
+ $this->admin_enqueue_scripts( 'boldgrid-backup-admin-premium-features' );
105
+ include BOLDGRID_BACKUP_PATH . '/admin/partials/boldgrid-backup-admin-premium.php';
106
+ $this->page->setAllNoticesRead();
107
+ return array(
108
+ 'nav' => $nav,
109
+ 'dashboard' => $dashboard,
110
+ 'premium_box' => $premium_box,
111
+ );
112
+ }
113
+ }
admin/class-boldgrid-backup-admin-settings.php CHANGED
@@ -612,6 +612,8 @@ class Boldgrid_Backup_Admin_Settings {
612
  /*
613
  * Save extractor settings.
614
  *
 
 
615
  * @since 1.5.1
616
  */
617
  if ( ! empty( $_POST['extractor'] ) ) {
612
  /*
613
  * Save extractor settings.
614
  *
615
+ * At this time, the extractor cannot be selected within the settings.
616
+ *
617
  * @since 1.5.1
618
  */
619
  if ( ! empty( $_POST['extractor'] ) ) {
admin/class-boldgrid-backup-admin-test.php CHANGED
@@ -286,7 +286,7 @@ class Boldgrid_Backup_Admin_Test {
286
  $filename = $file['name'];
287
 
288
  if ( 0 === strpos( $filename, $this->test_prefix ) ) {
289
- $this->core->wp_filesystem->delete( $dir . $filename );
290
  }
291
  }
292
 
@@ -511,6 +511,19 @@ class Boldgrid_Backup_Admin_Test {
511
  return false;
512
  }
513
 
 
 
 
 
 
 
 
 
 
 
 
 
 
514
  /**
515
  * Perform functionality tests.
516
  *
@@ -538,6 +551,8 @@ class Boldgrid_Backup_Admin_Test {
538
  $this->is_functional = false;
539
  } elseif ( 'pcl_zip' === $compressor && ! $this->is_pcl_zip_supported() ) {
540
  $this->is_functional = false;
 
 
541
  } elseif ( $this->is_php_safemode() ) {
542
  $this->is_functional = false;
543
  } else {
286
  $filename = $file['name'];
287
 
288
  if ( 0 === strpos( $filename, $this->test_prefix ) ) {
289
+ $this->core->wp_filesystem->delete( $dir . $filename, true );
290
  }
291
  }
292
 
511
  return false;
512
  }
513
 
514
+ /**
515
+ * Determine whether or not system_zip is suppored.
516
+ *
517
+ * @since SINCEVERSION
518
+ *
519
+ * @return bool
520
+ */
521
+ public function is_system_zip_supported() {
522
+ $system_zip_test = new Boldgrid_Backup_Admin_Compressor_System_Zip_Test( $this->core );
523
+
524
+ return $system_zip_test->run();
525
+ }
526
+
527
  /**
528
  * Perform functionality tests.
529
  *
551
  $this->is_functional = false;
552
  } elseif ( 'pcl_zip' === $compressor && ! $this->is_pcl_zip_supported() ) {
553
  $this->is_functional = false;
554
+ } elseif ( 'system_zip' === $compressor && ! $this->is_system_zip_supported() ) {
555
+ $this->is_functional = false;
556
  } elseif ( $this->is_php_safemode() ) {
557
  $this->is_functional = false;
558
  } else {
admin/compressor/class-boldgrid-backup-admin-compressor-pcl-zip.php CHANGED
@@ -47,6 +47,15 @@ class Boldgrid_Backup_Admin_Compressor_Pcl_Zip extends Boldgrid_Backup_Admin_Com
47
  */
48
  public $test_errors = array();
49
 
 
 
 
 
 
 
 
 
 
50
  /**
51
  * Constructor.
52
  *
@@ -159,8 +168,6 @@ class Boldgrid_Backup_Admin_Compressor_Pcl_Zip extends Boldgrid_Backup_Admin_Com
159
  * }
160
  */
161
  public function archive_files( $filelist, &$info ) {
162
- $info['filepath'] = $this->core->generate_archive_path( 'zip' );
163
-
164
  if ( $info['dryrun'] ) {
165
  return true;
166
  }
@@ -185,17 +192,23 @@ class Boldgrid_Backup_Admin_Compressor_Pcl_Zip extends Boldgrid_Backup_Admin_Com
185
  * is an array of arrays, so we need to convert to simply an array of
186
  * strings (filenames to archive).
187
  */
188
- $new_filelist = array();
189
- foreach ( $filelist as $key => $file ) {
190
-
191
  // Don't add the database dump at this time, it will be added later.
192
  if ( ! empty( $this->core->db_dump_filepath ) && $file[0] === $this->core->db_dump_filepath ) {
193
  continue;
194
  }
195
 
 
 
196
  $new_filelist[] = $file[0];
197
  }
198
 
 
 
 
 
199
  $status = $archive->add(
200
  $new_filelist,
201
  PCLZIP_OPT_REMOVE_PATH, ABSPATH
@@ -232,6 +245,8 @@ class Boldgrid_Backup_Admin_Compressor_Pcl_Zip extends Boldgrid_Backup_Admin_Com
232
  }
233
  }
234
 
 
 
235
  $this->wp_filesystem->chdir( $cwd );
236
 
237
  return true;
47
  */
48
  public $test_errors = array();
49
 
50
+ /**
51
+ * Key.
52
+ *
53
+ * @since SINCEVERSION
54
+ * @access proteced
55
+ * @var string
56
+ */
57
+ protected $key = 'pcl_zip';
58
+
59
  /**
60
  * Constructor.
61
  *
168
  * }
169
  */
170
  public function archive_files( $filelist, &$info ) {
 
 
171
  if ( $info['dryrun'] ) {
172
  return true;
173
  }
192
  * is an array of arrays, so we need to convert to simply an array of
193
  * strings (filenames to archive).
194
  */
195
+ $total_size_archived = 0;
196
+ $new_filelist = [];
197
+ foreach ( $filelist as $file ) {
198
  // Don't add the database dump at this time, it will be added later.
199
  if ( ! empty( $this->core->db_dump_filepath ) && $file[0] === $this->core->db_dump_filepath ) {
200
  continue;
201
  }
202
 
203
+ $total_size_archived += empty( $file[2] ) ? 0 : $file[2];
204
+
205
  $new_filelist[] = $file[0];
206
  }
207
 
208
+ Boldgrid_Backup_Admin_In_Progress_Data::set_arg( 'step', 3 );
209
+ Boldgrid_Backup_Admin_In_Progress_Data::set_arg( 'total_size_archived', $total_size_archived );
210
+ Boldgrid_Backup_Admin_In_Progress_Data::set_arg( 'total_size_archived_size_format', size_format( $total_size_archived, 2 ) );
211
+
212
  $status = $archive->add(
213
  $new_filelist,
214
  PCLZIP_OPT_REMOVE_PATH, ABSPATH
245
  }
246
  }
247
 
248
+ Boldgrid_Backup_Admin_In_Progress_Data::delete_arg( 'step' );
249
+
250
  $this->wp_filesystem->chdir( $cwd );
251
 
252
  return true;
admin/compressor/class-boldgrid-backup-admin-compressor-php-zip.php CHANGED
@@ -55,6 +55,15 @@ class Boldgrid_Backup_Admin_Compressor_Php_Zip extends Boldgrid_Backup_Admin_Com
55
  */
56
  public $zip;
57
 
 
 
 
 
 
 
 
 
 
58
  /**
59
  * Add a file's directories to the zip.
60
  *
@@ -111,8 +120,6 @@ class Boldgrid_Backup_Admin_Compressor_Php_Zip extends Boldgrid_Backup_Admin_Com
111
  * }
112
  */
113
  public function archive_files( $filelist, &$info ) {
114
- $info['filepath'] = $this->core->generate_archive_path( 'zip' );
115
-
116
  // Init vars used for our "in progress" bar.
117
  $number_files_archived = 0;
118
  $total_size_archived = 0;
@@ -277,7 +284,7 @@ class Boldgrid_Backup_Admin_Compressor_Php_Zip extends Boldgrid_Backup_Admin_Com
277
  *
278
  * @since 1.5.2
279
  */
280
- public static function is_available() {
281
  return extension_loaded( 'zip' ) && class_exists( 'ZipArchive' );
282
  }
283
 
55
  */
56
  public $zip;
57
 
58
+ /**
59
+ * Key.
60
+ *
61
+ * @since SINCEVERSION
62
+ * @access protected
63
+ * @var string
64
+ */
65
+ protected $key = 'php_zip';
66
+
67
  /**
68
  * Add a file's directories to the zip.
69
  *
120
  * }
121
  */
122
  public function archive_files( $filelist, &$info ) {
 
 
123
  // Init vars used for our "in progress" bar.
124
  $number_files_archived = 0;
125
  $total_size_archived = 0;
284
  *
285
  * @since 1.5.2
286
  */
287
+ public static function is_extension_available() {
288
  return extension_loaded( 'zip' ) && class_exists( 'ZipArchive' );
289
  }
290
 
admin/compressor/class-boldgrid-backup-admin-compressor-system-zip-temp-folder.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * File: class-boldgrid-backup-admin-compressor-system-zip-temp-folder.php
4
+ *
5
+ * @link https://www.boldgrid.com
6
+ * @since SINCEVERSION
7
+ *
8
+ * @package Boldgrid_Backup
9
+ * @subpackage Boldgrid_Backup/admin/compressor
10
+ * @copyright BoldGrid
11
+ * @version $Id$
12
+ * @author BoldGrid <support@boldgrid.com>
13
+ */
14
+
15
+ /**
16
+ * Class: Boldgrid_Backup_Admin_Compressor_System_Zip_Temp_Folder
17
+ *
18
+ * @since SINCEVERSION
19
+ */
20
+ class Boldgrid_Backup_Admin_Compressor_System_Zip_Temp_Folder {
21
+ /**
22
+ * An instance of core.
23
+ *
24
+ * @since SINCEVERSION
25
+ * @access private
26
+ * @var Boldgrid_Backup_Admin_Core
27
+ */
28
+ private $core;
29
+
30
+ /**
31
+ * The name of the temporary folder where the compression will take place.
32
+ *
33
+ * @since SINCEVERSION
34
+ * @access private
35
+ * @var string
36
+ */
37
+ private static $name = 'system-zip-temp';
38
+
39
+ /**
40
+ * Constructor.
41
+ *
42
+ * @since SINCEVERSION
43
+ */
44
+ public function __construct() {
45
+ $this->core = apply_filters( 'boldgrid_backup_get_core', null );
46
+ }
47
+
48
+ /**
49
+ * Create the temp folder.
50
+ *
51
+ * @since SINCEVERSION
52
+ *
53
+ * @return bool True on success.
54
+ */
55
+ public function create() {
56
+ return $this->core->wp_filesystem->mkdir( self::get_path() );
57
+ }
58
+
59
+ /**
60
+ * Delete the temp folder.
61
+ *
62
+ * @since SINCEVERSION
63
+ *
64
+ * @return bool True on success.
65
+ */
66
+ public function delete() {
67
+ return $this->core->wp_filesystem->rmdir( self::get_path() );
68
+ }
69
+
70
+ /**
71
+ * Get the path to our temp folder.
72
+ *
73
+ * @since SINCEVERSION
74
+ *
75
+ * @return string
76
+ */
77
+ public static function get_path() {
78
+ $core = apply_filters( 'boldgrid_backup_get_core', null );
79
+
80
+ return $core->backup_dir->get_path_to( self::$name );
81
+ }
82
+ }
admin/compressor/class-boldgrid-backup-admin-compressor-system-zip-test.php ADDED
@@ -0,0 +1,303 @@