PluginProbe ʕ •ᴥ•ʔ
Backup Migration / 2.1.2
Backup Migration v2.1.2
2.1.6 2.1.5.2 trunk 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.6.1 1.4.7 1.4.8 1.4.9 1.4.9.1 2.0.0 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.5.1
backup-backup / includes / notices / dropbox-issues-notice.php
backup-backup / includes / notices Last commit date
aws-issues.php 3 months ago backupbliss.php 3 months ago dropbox-issues-notice.php 3 months ago google-drive-issues.php 3 months ago wasabi-issues.php 3 months ago
dropbox-issues-notice.php
115 lines
1 <?php
2
3 // Namespace
4 namespace BMI\Plugin\Dashboard;
5
6 use BMI\Plugin\Backup_Migration_Plugin as BMP;
7 use BMI\Plugin\External\BMI_External_Dropbox as Dropbox;
8
9 // Exit on direct access
10 if (!defined('ABSPATH')) exit;
11
12 require_once BMI_INCLUDES . 'external/dropbox.php';
13 $dropbox = new Dropbox();
14
15 $dropboxIssue = get_transient('bmip_dropbox_issue');
16 wp_load_alloptions(true);
17 $expireTime = get_option('_transient_timeout_bmip_dropbox_issue', time() + HOUR_IN_SECONDS);
18 $timeToRetry = human_time_diff($expireTime, time());
19
20 if (!$dropboxIssue) return;
21
22 switch ($dropboxIssue) {
23 case 'auth_error_disconnected':
24 if ($dropbox->verifyConnection()['result'] == 'connected') {
25 delete_transient('bmip_dropbox_issue');
26 return;
27 }
28 $message = sprintf(
29 __('There was an error authenticating your Dropbox account. Please click %shere%s to re-authenticate, or click %shere%s to disable Dropbox as an external storage option.', 'backup-backup'),
30 '<a href="javascript:document.getElementById(\'bmip-dropbox-issues-dismiss\').click();document.getElementById(\'dropbox-connect-btn\').click();">',
31 '</a>',
32 '<a href="javascript:document.getElementById(\'bmip-dropbox-issues-dismiss\').click();document.getElementById(\'bmi-pro-storage-dropbox-toggle\').checked=false;document.querySelector(\'#storage-options .save-btn\').click(); setTimeout(()=>{window.location.reload()}, 500);">',
33 '</a>'
34 );
35 break;
36 case 'not_enough_memory':
37 if (BMP::getAvailableMemoryInBytes() >= 16 * 1024 * 1024) {
38 delete_transient('bmip_dropbox_issue');
39 return;
40 }
41
42 $message = sprintf(
43 __('There is no enough free memory to upload the backup to Dropbox. Dropbox API requires at least 16MB of memory. Please increase the memory limit in your server configuration. Plugin will try again in %s', 'backup-backup'),
44 $timeToRetry
45 );
46 break;
47 case 'rate_limit':
48 $message = sprintf(
49 __('The Dropbox API rate limit has been exceeded, which means the plugin cannot proceed with the current operation at this time. The plugin will automatically attempt to retry the process in %s. Please be patient.', 'backup-backup'),
50 $timeToRetry
51 );
52 break;
53 case 'forbidden': // HAVE NOT TESTED
54 $message = sprintf(
55 __('The plugin does not have permission to access the Dropbox API. Please re-authenticate the plugin with Dropbox to resolve this issue. The plugin will automatically attempt to retry the process in %s.', 'backup-backup'),
56 $timeToRetry
57 );
58 break;
59 case 'insufficient_space':
60 $spaceUsage = $dropbox->getSpaceUsage();
61 if ($spaceUsage === false) {
62 $message = sprintf(
63 __('Your Dropbox account doesn’t have enough space to upload the backup. The plugin will automatically retry in %s.', 'backup-backup'),
64 $timeToRetry
65 );
66 break;
67 }
68 $usagePrecentages = $spaceUsage['used'] / $spaceUsage['allocation']['allocated'] * 100;
69
70 $requiredSpace = get_option('bmip_dropbox_required_space', 0);
71 $requiredSpace = intval($requiredSpace);
72 $availableSpace = $spaceUsage['allocation']['allocated'] - $spaceUsage['used'];
73
74 if ($availableSpace >= $requiredSpace) {
75 delete_transient('bmip_dropbox_issue');
76 return;
77 }
78
79 $message = sprintf(
80 __('Your Dropbox account doesn’t have enough space to upload the backup. You’ve used %s out of %s (%s). The plugin needs %s of free space to complete the upload. It will automatically retry in %s.', 'backup-backup'),
81 BMP::humanSize($spaceUsage['used']),
82 BMP::humanSize($spaceUsage['allocation']['allocated']),
83 number_format($usagePrecentages) . '%',
84 BMP::humanSize($requiredSpace),
85 $timeToRetry
86 );
87 break;
88 default:
89 return;
90 }
91
92 if (!isset($message) || get_option('bmip_dropbox_dismiss_issue', false)) return;
93 ?>
94
95
96 <div class="error-noticer" id="dropbox-issues">
97 <div class="error-header">
98 <div class="cf">
99 <div class="left">
100 <?php esc_html_e('We have some error regarding most recent backup upload process.', 'backup-backup'); ?>
101 </div>
102 <div class="right hoverable">
103 <span class="bmi-error-toggle" data-expand="<?php esc_attr_e('Expand', 'backup-backup'); ?>" data-collapse="<?php esc_attr_e('Collapse', 'backup-backup'); ?>">
104 <?php esc_html_e('Expand', 'backup-backup'); ?>
105 </span> |
106 <span id="bmip-dropbox-issues-dismiss">
107 <?php esc_html_e('Dismiss', 'backup-backup'); ?>
108 </span>
109 </div>
110 </div>
111 </div>
112 <div class="error-body">
113 <?php echo wp_kses_post( $message ); ?>
114 </div>
115 </div>