PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backups, Restore, Migration & Clone / 4.11.0
WP STAGING – WordPress Backups, Restore, Migration & Clone v4.11.0
4.11.0 4.10.0 4.9.5 4.9.4 4.9.3 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 1 month ago advanced-exclude-options.php 1 year ago backup-parts.php 1 year ago backup-scheduling-options.php 1 day ago backup-storages.php 1 day ago backup.php 1 day ago confirm-restore.php 1 day ago download-modal.php 1 year ago edit-schedule-modal.php 1 month ago manage-schedules.php 1 month ago remote-upload.php 1 day ago restore.php 1 month ago upload.php 1 day ago
backup.php
291 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
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 <div class="wpstg--wproot-expand-folder">
89 <img class="wpstg--dashicons wpstg-dashicons-14 wpstg--expand-folder-img" src="<?php echo esc_url($urlAssets); ?>svg/folder-expand-chevron.svg" alt="info" />
90 </div>
91 <?php Checkbox::render('wpstgIncludeOtherFilesInWpRoot', 'includeOtherFilesInWpRoot', '', false); ?>
92 <span id="wpstg-wproot-other-files-span" data-id="#wpstg-wproot-scanning-files">
93 <?php esc_html_e('Backup Other WP Root Folders', 'wp-staging'); ?>
94 </span>
95 <span id="wpstgIncludeOtherFilesInWpRootSize"></span> <!-- used to show the size of the files in the root folder -->
96 <div class="wpstg--tooltip wpstg-wproot-tooltip">
97 <img class="wpstg--dashicons wpstg-dashicons-19 wpstg--grey" src="<?php echo esc_url($urlAssets); ?>svg/info-outline.svg" alt="info" />
98 <span class="wpstg--tooltiptext wpstg--tooltiptext-backups">
99 <?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>'); ?>
100 </span>
101 </div>
102
103 <fieldset class="wpstg-wproot-files-selection-section wpstg-wproot-files-selection" id="wpstg-wproot-scanning-files">
104 <?php require(WPSTG_VIEWS_DIR . 'backup/backup-files.php'); ?>
105 </fieldset>
106 </label>
107 </div>
108
109 <label>
110 <?php Checkbox::render('includeDatabaseInBackup', 'backup_database', 'true', true); ?>
111 <?php esc_html_e('Backup Database', 'wp-staging'); ?>
112 <span id="includeDatabaseInBackupSize"></span>
113 <div class="wpstg--tooltip wpstg-backup-modal-tooltip">
114 <img class="wpstg--dashicons wpstg-dashicons-19 wpstg--grey" src="<?php echo esc_url($urlAssets); ?>svg/info-outline.svg" alt="info" />
115 <span class="wpstg--tooltiptext wpstg--tooltiptext-backups">
116 <?php
117 printf(
118 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'),
119 isset($GLOBALS['wpdb']->prefix) ? esc_html($GLOBALS['wpdb']->prefix) : 'wp_'
120 );
121 ?>
122 </span>
123 </div>
124 <div id="backupUploadsWithoutDatabaseWarning" style="display:none;">
125 <?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'); ?>
126 </div>
127 </label>
128 <input type="hidden" name="wpContentDir" value="<?php echo esc_attr($directories['wpContent']); ?>" />
129 <input type="hidden" name="wpStagingDir" value="<?php echo esc_attr($directories['wpStaging']); ?>" />
130 <?php unset($directories['wpContent'], $directories['wpStaging']) ?>
131 <input type="hidden" name="availableDirectories" value="<?php echo esc_attr(implode('|', array_map('strval', (array)$directories))); ?>"/>
132 <?php if (!is_multisite()) { ?>
133 <input type="hidden" name="backupType" value="<?php echo esc_attr(BackupMetadata::BACKUP_TYPE_SINGLE); ?>" />
134 <?php } else { ?>
135 <?php require_once WPSTG_VIEWS_DIR . 'pro/backup/modal/network-options.php'; ?>
136 <?php } ?>
137
138 <!-- Calculate Backup Size -->
139 <div class="wpstg-calculate-backup-container">
140 <div class="wpstg-left-group">
141 <div id="wpstg-calculate-backup-size" class="wpstg-blue-primary wpstg-button">
142 <span class="wpstg-calculator-icon"></span>
143 <?php esc_html_e('Calculate Backup Size', 'wp-staging'); ?>
144 </div>
145 <div class="wpstg-loader-container">
146 <span id="wpstg-calculate-backup-size-loader" class="wpstg-loader"></span>
147 </div>
148 </div>
149 <div id="wpstg-total-backup-size-container" class="wpstg-right-group">
150 <div class="wpstg-estimate-container">
151 <strong><?php esc_html_e('Estimated Size:', 'wp-staging'); ?></strong>
152 <span id="wpstg-total-estimated-backup-size">0.0</span>
153 </div>
154 </div>
155 </div>
156 <?php require_once WPSTG_VIEWS_DIR . 'backup/modal/partials/backup-filters-notice.php'; ?>
157 <!-- End Calculate Backup Size -->
158
159 <!-- Advanced Options -->
160 <div id="wpstg-backup-advance-section-header" data-id="#wpstg-backup-advance-section">
161 <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" />
162 <strong><?php esc_html_e("Advanced Options", 'wp-staging'); ?></strong>
163 <span class="wpstg-badge-pill-container">
164 <span class="wpstg-badge-pill hidden" id="smart-exclusions-badge">Exclusions</span>
165 <span class="wpstg-badge-pill hidden" id="run-in-background-badge">Background Run</span>
166 </span>
167 </div>
168 <div class="wpstg-backup-options-section hidden wpstg-sub-options-details" id="wpstg-backup-advance-section">
169 <div class="wpstg-u-container">
170 <label class="wpstg-backup-option wpstg-with-tooltip" id="wpstg-add-exclusions-label">
171 <div class="wpstg--add-exclusions-expand-folder">
172 <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" />
173 </div>
174 <?php
175 $attributes = [
176 'classes' => $isProVersion ? 'wpstg-is-pro' : 'wpstg-is-basic',
177 'displayDependency' => true,
178 'isDisabled' => !$isProVersion,
179 ];
180 Checkbox::render('wpstgSmartExclusion', 'smartExclusion', '', false, $attributes);
181 ?>
182 <span class="<?php echo esc_attr($disabledClass); ?>" id="wpstg-add-exclusions-span" data-id="#wpstg-advanced-exclude-options">
183 <?php esc_html_e('Add Exclusions', 'wp-staging'); ?>
184 </span>
185 <div class="wpstg--tooltip">
186 <img class="wpstg--dashicons wpstg-dashicons-19 wpstg--grey" src="<?php echo esc_url($urlAssets); ?>svg/info-outline.svg" alt="info" />
187 <span class="wpstg--tooltiptext wpstg--tooltiptext-backups">
188 <?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'); ?>
189 <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>'); ?>
190 </span>
191 </div>
192 <span class="wpstg-badge-pill-container">
193 <span class="wpstgExcludeLogs wpstg-badge-pill hidden">Log files</span>
194 <span class="wpstgExcludeCaches wpstg-badge-pill hidden">Cache files</span>
195 <span class="wpstgExcludePostRevision wpstg-badge-pill hidden">Post revisions</span>
196 <span class="wpstgExcludeSpamComments wpstg-badge-pill hidden">Spam comments</span>
197 <span class="wpstgExcludeUnusedThemes wpstg-badge-pill hidden">Unused themes</span>
198 <span class="wpstgExcludeDeactivatedPlugins wpstg-badge-pill hidden">Deactivated plugins</span>
199 </span>
200 <?php if (!$isProVersion) : ?>
201 <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>
202 <?php endif; ?>
203 </label>
204
205 <?php require_once WPSTG_VIEWS_DIR . 'backup/modal/advanced-exclude-options.php'; ?>
206 </div>
207
208 <div class="wpstg-u-container wpstg-mt-5px">
209 <label class="wpstg-backup-option wpstg-with-tooltip">
210 <?php Checkbox::render('wpstg-run-in-background', 'runInBackground'); ?>
211 <span><?php esc_html_e('Run In Background', 'wp-staging'); ?></span>
212 <div class="wpstg--tooltip">
213 <img class="wpstg--dashicons wpstg-dashicons-19 wpstg--grey" src="<?php echo esc_url($urlAssets); ?>svg/info-outline.svg" alt="info" />
214 <span class="wpstg--tooltiptext wpstg--tooltiptext-backups">
215 <?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'); ?>
216 <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'); ?>
217 </span>
218 </div>
219 </label>
220 </div>
221 </div>
222 <!-- End Advanced Options -->
223
224 <!-- Backup Times -->
225 <div id="wpstg-backup-times-header" data-id="#wpstg-backup-times-section">
226 <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" />
227 <strong><?php esc_html_e("Backup Times", 'wp-staging'); ?></strong>
228 <span class="wpstg-badge-pill-container">
229 <span class="repeatBackupOnSchedule wpstg-badge-pill">One-Time</span>
230 </span>
231 </div>
232 <div class="wpstg-backup-options-section hidden wpstg-sub-options-details" id="wpstg-backup-times-section">
233 <div class="wpstg-backup-scheduling-options wpstg-u-container <?php echo esc_attr($classPropertyHasScheduleAndIsFree); ?>">
234
235 <label>
236 <?php
237 $attributes = [
238 'classes' => $isProVersion ? 'wpstg-is-pro' : 'wpstg-is-basic',
239 'displayDependency' => true,
240 'isDisabled' => ($hasSchedule && !$isProVersion),
241 ];
242 Checkbox::render('repeatBackupOnSchedule', 'repeatBackupOnSchedule', '1', true, $attributes);
243 ?>
244
245 <?php esc_html_e('One-Time Backup', 'wp-staging'); ?>
246 </label>
247
248 <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'; ?>">
249 <?php echo esc_html($cronMessage); ?>
250 <br>
251 <br>
252 <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>
253 </span>
254
255 <?php require_once WPSTG_VIEWS_DIR . 'backup/modal/backup-scheduling-options.php'; ?>
256 </div>
257 </div>
258 <!-- End Backup Times -->
259
260 <!-- Storage Providers -->
261 <div id="wpstg-backup-storages-header" data-id="#wpstg-storages-section">
262 <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" />
263 <strong><?php esc_html_e("Storage Providers", 'wp-staging'); ?></strong>
264 <span class="wpstg-badge-pill-container">
265 <span class="storage-localStorage wpstg-badge-pill">Local Storage</span>
266 <?php foreach ($providers->getStorages(true) as $storageKey => $storage) : ?>
267 <span class="<?php echo esc_attr($storagesPrefix . $storage['id']); ?> wpstg-badge-pill hidden"><?php echo esc_html($storage['name']); ?></span>
268 <?php endforeach; ?>
269 </span>
270 </div>
271 <div id="wpstg-storages-section" class="hidden">
272 <?php require WPSTG_VIEWS_DIR . 'backup/modal/backup-storages.php'; ?>
273 </div>
274 <!-- End Storage Providers -->
275 </div>
276
277 <!-- ADVANCED OPTIONS DROPDOWN -->
278 <div class="wpstg-advanced-options-dropdown-wrapper">
279 <a href="#" class="wpstg--tab--toggle" data-target=".wpstg-advanced-options-dropdown" style="text-decoration: none;">
280 <span style="margin-right: .25em"></span>
281 <?php esc_html_e('Advanced Options', 'wp-staging'); ?>
282 </a>
283
284 <div class="wpstg-advanced-options-dropdown" style="display:none; padding-left: .75em;">
285 <?php esc_html_e('Advanced Options', 'wp-staging'); ?>
286 </div>
287 </div>
288
289 </div>
290 </div>
291