PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backup, Restore, Migration & Clone / 4.9.2
WP STAGING – WordPress Backup, Restore, Migration & Clone v4.9.2
4.9.2 4.9.1 4.9.0 4.8.1 trunk 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.10.0 3.2.0 3.3.1 3.3.2 3.3.3 3.4.1 3.4.3 3.5.0 3.6.0 3.7.1 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 4.0.0 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.8.0
wp-staging / views / backup / modal / backup.php
wp-staging / views / backup / modal Last commit date
partials 2 weeks ago advanced-exclude-options.php 11 months ago backup-parts.php 10 months ago backup-scheduling-options.php 1 day ago backup-storages.php 1 day ago backup.php 1 day ago confirm-restore.php 2 weeks ago download-modal.php 10 months ago edit-schedule-modal.php 2 weeks ago manage-schedules.php 2 weeks ago remote-upload.php 3 months ago restore.php 2 weeks ago upload.php 2 weeks ago
backup.php
308 lines
1 <?php
2
3 /**
4 * @var \WPStaging\Framework\Adapter\Directory $directories
5 * @var string $urlAssets
6 * @var bool $isProVersion
7 * @var bool $hasSchedule
8 * @var bool $isPersonalLicense
9 * @var string $licenseType
10 */
11
12 use WPStaging\Backup\BackupScheduler;
13 use WPStaging\Backup\Entity\BackupMetadata;
14 use WPStaging\Core\WPStaging;
15 use WPStaging\Framework\Language\Language;
16 use WPStaging\Framework\Facades\UI\Checkbox;
17 use WPStaging\Framework\Utils\Times;
18 use WPStaging\Basic\Ajax\ProCronsCleaner;
19 use WPStaging\Framework\Facades\Hooks;
20 use WPStaging\Backup\Storage\Providers;
21
22 $timeFormatOption = get_option('time_format');
23
24 /** @var Times */
25 $time = WPStaging::make(Times::class);
26 $providers = WPStaging::make(Providers::class);
27
28 $recurInterval = (defined('WPSTG_IS_DEV') && WPSTG_IS_DEV) ? 'PT1M' : 'PT15M';
29 $recurInterval = Hooks::applyFilters(BackupScheduler::FILTER_SCHEDULES_BACKUP_INTERVAL, $recurInterval);
30 $recurrenceTimes = $time->range('midnight', 'tomorrow - 1 minutes', $recurInterval);
31
32 $disabledProAttribute = $isProVersion ? '' : ' disabled';
33
34 $disabledClass = !$isProVersion ? 'wpstg-storage-settings-disabled' : '';
35
36 $classPropertyHasScheduleAndIsFree = ($hasSchedule && !$isProVersion) ? 'wpstg-free-has-schedule-message ' : '';
37
38 $haveProCrons = WPStaging::make(ProCronsCleaner::class)->haveProCrons();
39
40 $cronMessage = $haveProCrons ? __('There are backup plans created with WP Staging Pro. Delete them first to create a backup plan with the free version of WP Staging. ', 'wp-staging') :
41 __('A backup is created every day at 12:00 noon!', 'wp-staging');
42
43 $storagesPrefix = 'storage-';
44 ?>
45 <div id="wpstg--modal--backup--new" data-confirmButtonText="<?php esc_attr_e('Start Backup', 'wp-staging'); ?>" style="display: none">
46 <h3 class="wpstg--swal2-title wpstg-modal-title wpstg-w-100" for="wpstg-backup-name-input"><?php esc_html_e('Create Site Backup', 'wp-staging'); ?></h3>
47 <input id="wpstg-backup-name-input" name="backup_name" class="wpstg-input wpstg-input-md wpstg-my-4" style="max-width: 400px;" placeholder="<?php esc_attr_e('Backup Name (Optional)', 'wp-staging'); ?>">
48
49 <div class="wpstg-advanced-options" style="text-align: left;">
50
51 <!-- BACKUP CHECKBOXES -->
52 <div class="wpstg-advanced-options-site">
53 <label>
54 <?php Checkbox::render('includeMediaLibraryInBackup', 'includedDirectories[]', $directories['uploads'], true); ?>
55 <?php esc_html_e('Backup Media Library', 'wp-staging'); ?>
56 <span id="includeMediaLibraryInBackupSize"></span>
57 </label>
58 <label>
59 <?php Checkbox::render('includeThemesInBackup', 'includedDirectories[]', $directories['themes'], true); ?>
60 <?php esc_html_e('Backup Themes', 'wp-staging'); ?>
61 <span id="includeThemesInBackupSize"></span>
62 </label>
63 <label>
64 <?php Checkbox::render('includeMuPluginsInBackup', 'includedDirectories[]', $directories['muPlugins'], true); ?>
65 <?php esc_html_e('Backup Must-Use Plugins', 'wp-staging'); ?>
66 <span id="includeMuPluginsInBackupSize"></span>
67 </label>
68 <label>
69 <?php Checkbox::render('includePluginsInBackup', 'includedDirectories[]', $directories['plugins'], true); ?>
70 <?php esc_html_e('Backup Plugins', 'wp-staging'); ?>
71 <span id="includePluginsInBackupSize"></span>
72 </label>
73 <div>
74 <label>
75 <?php Checkbox::render('includeOtherFilesInWpContent', 'includeOtherFilesInWpContent', 'true', true); ?>
76 <?php esc_html_e('Backup Other Files In wp-content', 'wp-staging'); ?>
77 <span id="includeOtherFilesInWpContentSize"></span>
78 <div class="wpstg--tooltip wpstg-backup-modal-tooltip">
79 <img class="wpstg--dashicons wpstg-dashicons-19 wpstg--grey" src="<?php echo esc_url($urlAssets); ?>svg/info-outline.svg" alt="info" />
80 <span class="wpstg--tooltiptext wpstg--tooltiptext-backups">
81 <?php esc_html_e('All files in folder wp-content that are not plugins, themes, mu-plugins and uploads. Recommended for full-site backups.', 'wp-staging'); ?>
82 </span>
83 </div>
84 </label>
85 </div>
86 <div>
87 <label>
88 <?php if ($isProVersion) : ?>
89 <div class="wpstg--wproot-expand-folder">
90 <img class="wpstg--dashicons wpstg-dashicons-14 wpstg--expand-folder-img" src="<?php echo esc_url($urlAssets); ?>svg/folder-expand-chevron.svg" alt="info" />
91 </div>
92 <?php endif; ?>
93 <?php
94 Checkbox::render(
95 'wpstgIncludeOtherFilesInWpRoot',
96 'includeOtherFilesInWpRoot',
97 '',
98 false,
99 [
100 'classes' => $isProVersion ? 'wpstg-is-pro' : 'wpstg-is-basic',
101 'isDisabled' => !$isProVersion,
102 ]
103 );
104 ?>
105 <span class="<?php echo esc_attr($disabledClass); ?>" id="wpstg-wproot-other-files-span" data-id="#wpstg-wproot-scanning-files">
106 <?php esc_html_e('Backup Other WP Root Folders', 'wp-staging'); ?>
107 </span>
108 <span id="wpstgIncludeOtherFilesInWpRootSize"></span> <!-- used to show the size of the files in the root folder -->
109 <div class="wpstg--tooltip wpstg-wproot-tooltip">
110 <img class="wpstg--dashicons wpstg-dashicons-19 wpstg--grey" src="<?php echo esc_url($urlAssets); ?>svg/info-outline.svg" alt="info" />
111 <span class="wpstg--tooltiptext wpstg--tooltiptext-backups">
112 <?php echo sprintf(esc_html__('Only folders are backed up; files like %s are excluded and must be saved manually if needed. The following folders are also not included in the backup: %s, %s, and those containing WP Staging sites. To back up a staging site, open WP Staging on that site and create a backup directly from there.', 'wp-staging'), '<code>wp-config.php</code>', '<code>wp-admin</code>', '<code>wp-includes</code>'); ?>
113 </span>
114 </div>
115
116 <?php if (!$isProVersion) : ?>
117 <a href="<?php echo esc_url(Language::getUpgradeUrl('backup_root_files')); ?>" target="_blank" class="wpstg-pro-feature-link"><span class="wpstg-pro-feature wpstg-u-ml-8"><?php esc_html_e('Upgrade', 'wp-staging'); ?></span></a>
118 <?php else : ?>
119 <fieldset class="wpstg-wproot-files-selection-section wpstg-wproot-files-selection" id="wpstg-wproot-scanning-files">
120 <?php require(WPSTG_VIEWS_DIR . 'pro/backup/backup-files.php'); ?>
121 </fieldset>
122 <?php endif; ?>
123 </label>
124 </div>
125
126 <label>
127 <?php Checkbox::render('includeDatabaseInBackup', 'backup_database', 'true', true); ?>
128 <?php esc_html_e('Backup Database', 'wp-staging'); ?>
129 <span id="includeDatabaseInBackupSize"></span>
130 <div class="wpstg--tooltip wpstg-backup-modal-tooltip">
131 <img class="wpstg--dashicons wpstg-dashicons-19 wpstg--grey" src="<?php echo esc_url($urlAssets); ?>svg/info-outline.svg" alt="info" />
132 <span class="wpstg--tooltiptext wpstg--tooltiptext-backups">
133 <?php
134 printf(
135 esc_html__('This will backup all database tables starting with the prefix "%s". To backup a staging site, run the backup function again on the staging site', 'wp-staging'),
136 isset($GLOBALS['wpdb']->prefix) ? esc_html($GLOBALS['wpdb']->prefix) : 'wp_'
137 );
138 ?>
139 </span>
140 </div>
141 <div id="backupUploadsWithoutDatabaseWarning" style="display:none;">
142 <?php esc_html_e('When backing up the Media Library without the Database, the attachments will be migrated but won\'t show up in the media library after restore.', 'wp-staging'); ?>
143 </div>
144 </label>
145 <input type="hidden" name="wpContentDir" value="<?php echo esc_attr($directories['wpContent']); ?>" />
146 <input type="hidden" name="wpStagingDir" value="<?php echo esc_attr($directories['wpStaging']); ?>" />
147 <?php unset($directories['wpContent'], $directories['wpStaging']) ?>
148 <input type="hidden" name="availableDirectories" value="<?php echo esc_attr(implode('|', array_map('strval', (array)$directories))); ?>"/>
149 <?php if (!is_multisite()) { ?>
150 <input type="hidden" name="backupType" value="<?php echo esc_attr(BackupMetadata::BACKUP_TYPE_SINGLE); ?>" />
151 <?php } else { ?>
152 <?php require_once WPSTG_VIEWS_DIR . 'pro/backup/modal/network-options.php'; ?>
153 <?php } ?>
154
155 <!-- Calculate Backup Size -->
156 <div class="wpstg-calculate-backup-container">
157 <div class="wpstg-left-group">
158 <div id="wpstg-calculate-backup-size" class="wpstg-blue-primary wpstg-button">
159 <span class="wpstg-calculator-icon"></span>
160 <?php esc_html_e('Calculate Backup Size', 'wp-staging'); ?>
161 </div>
162 <div class="wpstg-loader-container">
163 <span id="wpstg-calculate-backup-size-loader" class="wpstg-loader"></span>
164 </div>
165 </div>
166 <div id="wpstg-total-backup-size-container" class="wpstg-right-group">
167 <div class="wpstg-estimate-container">
168 <strong><?php esc_html_e('Estimated Size:', 'wp-staging'); ?></strong>
169 <span id="wpstg-total-estimated-backup-size">0.0</span>
170 </div>
171 </div>
172 </div>
173 <?php require_once WPSTG_VIEWS_DIR . 'backup/modal/partials/backup-filters-notice.php'; ?>
174 <!-- End Calculate Backup Size -->
175
176 <!-- Advanced Options -->
177 <div id="wpstg-backup-advance-section-header" data-id="#wpstg-backup-advance-section">
178 <img class="wpstg--dashicons wpstg-dashicons-14 wpstg--expand-folder-img" src="<?php echo esc_url($urlAssets); ?>svg/folder-expand-chevron.svg" alt="Advanced Options" />
179 <strong><?php esc_html_e("Advanced Options", 'wp-staging'); ?></strong>
180 <span class="wpstg-badge-pill-container">
181 <span class="wpstg-badge-pill hidden" id="smart-exclusions-badge">Exclusions</span>
182 <span class="wpstg-badge-pill hidden" id="run-in-background-badge">Background Run</span>
183 </span>
184 </div>
185 <div class="wpstg-backup-options-section hidden wpstg-sub-options-details" id="wpstg-backup-advance-section">
186 <div class="wpstg-u-container">
187 <label class="wpstg-backup-option wpstg-with-tooltip" id="wpstg-add-exclusions-label">
188 <div class="wpstg--add-exclusions-expand-folder">
189 <img class="wpstg--dashicons wpstg-dashicons-14 wpstg--add-exclusions-expand-folder-img" src="<?php echo esc_url($urlAssets); ?>svg/folder-expand-chevron.svg" alt="info" />
190 </div>
191 <?php
192 $attributes = [
193 'classes' => $isProVersion ? 'wpstg-is-pro' : 'wpstg-is-basic',
194 'displayDependency' => true,
195 'isDisabled' => !$isProVersion,
196 ];
197 Checkbox::render('wpstgSmartExclusion', 'smartExclusion', '', false, $attributes);
198 ?>
199 <span class="<?php echo esc_attr($disabledClass); ?>" id="wpstg-add-exclusions-span" data-id="#wpstg-advanced-exclude-options">
200 <?php esc_html_e('Add Exclusions', 'wp-staging'); ?>
201 </span>
202 <div class="wpstg--tooltip">
203 <img class="wpstg--dashicons wpstg-dashicons-19 wpstg--grey" src="<?php echo esc_url($urlAssets); ?>svg/info-outline.svg" alt="info" />
204 <span class="wpstg--tooltiptext wpstg--tooltiptext-backups">
205 <?php esc_html_e('To keep backups fast and efficient, we automatically exclude files over 200MB and system files like .wpstg, .gz, and .tmp', 'wp-staging'); ?>
206 <br /><?php printf(esc_html__('Want to change this? %s', 'wp-staging'), '<a href="https://wp-staging.com/docs/actions-and-filters/#Exclude_a_file_extension_from_backup" target="_blank" rel="noopener noreferrer">' . esc_html__('Learn how to customize exclusions.', 'wp-staging') . '</a>'); ?>
207 </span>
208 </div>
209 <span class="wpstg-badge-pill-container">
210 <span class="wpstgExcludeLogs wpstg-badge-pill hidden">Log files</span>
211 <span class="wpstgExcludeCaches wpstg-badge-pill hidden">Cache files</span>
212 <span class="wpstgExcludePostRevision wpstg-badge-pill hidden">Post revisions</span>
213 <span class="wpstgExcludeSpamComments wpstg-badge-pill hidden">Spam comments</span>
214 <span class="wpstgExcludeUnusedThemes wpstg-badge-pill hidden">Unused themes</span>
215 <span class="wpstgExcludeDeactivatedPlugins wpstg-badge-pill hidden">Deactivated plugins</span>
216 </span>
217 <?php if (!$isProVersion) : ?>
218 <a href="<?php echo esc_url(Language::getUpgradeUrl('backup_exclude')); ?>" target="_blank" class="wpstg-pro-feature-link"><span class="wpstg-pro-feature wpstg-u-ml-8"><?php esc_html_e('Upgrade', 'wp-staging'); ?></span></a>
219 <?php endif; ?>
220 </label>
221
222 <?php require_once WPSTG_VIEWS_DIR . 'backup/modal/advanced-exclude-options.php'; ?>
223 </div>
224
225 <div class="wpstg-u-container wpstg-mt-5px">
226 <label class="wpstg-backup-option wpstg-with-tooltip">
227 <?php Checkbox::render('wpstg-run-in-background', 'runInBackground'); ?>
228 <span><?php esc_html_e('Run In Background', 'wp-staging'); ?></span>
229 <div class="wpstg--tooltip">
230 <img class="wpstg--dashicons wpstg-dashicons-19 wpstg--grey" src="<?php echo esc_url($urlAssets); ?>svg/info-outline.svg" alt="info" />
231 <span class="wpstg--tooltiptext wpstg--tooltiptext-backups">
232 <?php esc_html_e('This runs the backup in the background and means you can close the window or open another WordPress page and the backup process will not stop.', 'wp-staging'); ?>
233 <br /><?php esc_html_e('You will be notified by e-mail or slack if the backup fails. (If activated in WP Staging settings)', 'wp-staging'); ?>
234 </span>
235 </div>
236 </label>
237 </div>
238 </div>
239 <!-- End Advanced Options -->
240
241 <!-- Backup Times -->
242 <div id="wpstg-backup-times-header" data-id="#wpstg-backup-times-section">
243 <img class="wpstg--dashicons wpstg-dashicons-14 wpstg--expand-folder-img" src="<?php echo esc_url($urlAssets); ?>svg/folder-expand-chevron.svg" alt="Backup Times" />
244 <strong><?php esc_html_e("Backup Times", 'wp-staging'); ?></strong>
245 <span class="wpstg-badge-pill-container">
246 <span class="repeatBackupOnSchedule wpstg-badge-pill">One-Time</span>
247 </span>
248 </div>
249 <div class="wpstg-backup-options-section hidden wpstg-sub-options-details" id="wpstg-backup-times-section">
250 <div class="wpstg-backup-scheduling-options wpstg-u-container <?php echo esc_attr($classPropertyHasScheduleAndIsFree); ?>">
251
252 <label>
253 <?php
254 $attributes = [
255 'classes' => $isProVersion ? 'wpstg-is-pro' : 'wpstg-is-basic',
256 'displayDependency' => true,
257 'isDisabled' => ($hasSchedule && !$isProVersion),
258 ];
259 Checkbox::render('repeatBackupOnSchedule', 'repeatBackupOnSchedule', '1', true, $attributes);
260 ?>
261
262 <?php esc_html_e('One-Time Backup', 'wp-staging'); ?>
263 </label>
264
265 <span class="wpstg--text--danger wpstg-basic-schedule-notice <?php echo $isProVersion ? 'wpstg-is-pro' : 'wpstg-is-basic'; ?>" style="display: <?php echo ($hasSchedule && !$isProVersion) ? 'block' : 'none'; ?>">
266 <?php echo esc_html($cronMessage); ?>
267 <br>
268 <br>
269 <a href="<?php echo esc_url(Language::getUpgradeUrl('backup_schedule')); ?>" target="_blank" class="wpstg-pro-feature-link"><?php echo sprintf(esc_html__('%sUpgrade to Pro%s to create unlimited backup plans, change the start time or upload backups to cloud storage.', 'wp-staging'), '<strong><u>', '</u></strong>'); ?></a>
270 </span>
271
272 <?php require_once WPSTG_VIEWS_DIR . 'backup/modal/backup-scheduling-options.php'; ?>
273 </div>
274 </div>
275 <!-- End Backup Times -->
276
277 <!-- Storage Providers -->
278 <div id="wpstg-backup-storages-header" data-id="#wpstg-storages-section">
279 <img class="wpstg--dashicons wpstg-dashicons-14 wpstg--expand-folder-img" src="<?php echo esc_url($urlAssets); ?>svg/folder-expand-chevron.svg" alt="Storage Providers" />
280 <strong><?php esc_html_e("Storage Providers", 'wp-staging'); ?></strong>
281 <span class="wpstg-badge-pill-container">
282 <span class="storage-localStorage wpstg-badge-pill">Local Storage</span>
283 <?php foreach ($providers->getStorages(true) as $storageKey => $storage) : ?>
284 <span class="<?php echo esc_attr($storagesPrefix . $storage['id']); ?> wpstg-badge-pill hidden"><?php echo esc_html($storage['name']); ?></span>
285 <?php endforeach; ?>
286 </span>
287 </div>
288 <div id="wpstg-storages-section" class="hidden">
289 <?php require WPSTG_VIEWS_DIR . 'backup/modal/backup-storages.php'; ?>
290 </div>
291 <!-- End Storage Providers -->
292 </div>
293
294 <!-- ADVANCED OPTIONS DROPDOWN -->
295 <div class="wpstg-advanced-options-dropdown-wrapper">
296 <a href="#" class="wpstg--tab--toggle" data-target=".wpstg-advanced-options-dropdown" style="text-decoration: none;">
297 <span style="margin-right: .25em"></span>
298 <?php esc_html_e('Advanced Options', 'wp-staging'); ?>
299 </a>
300
301 <div class="wpstg-advanced-options-dropdown" style="display:none; padding-left: .75em;">
302 <?php esc_html_e('Advanced Options', 'wp-staging'); ?>
303 </div>
304 </div>
305
306 </div>
307 </div>
308