PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backups, Restore, Migration & Clone / 4.10.0
WP STAGING – WordPress Backups, Restore, Migration & Clone v4.10.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 / clone / index.php
wp-staging / views / clone Last commit date
ajax 1 week ago index.php 4 days ago
index.php
247 lines
1 <?php
2
3 /**
4 * @see \WPStaging\Backend\Administrator::getClonePage()
5 * @see \WPStaging\Backend\Administrator::getBackupPage()
6 * @var bool $isBackupPage
7 * @var bool $isStagingPage
8 */
9
10 use WPStaging\Backup\BackupNextOffer;
11 use WPStaging\Core\WPStaging;
12 use WPStaging\Framework\Notices\BackupPluginsNotice;
13 use WPStaging\Framework\Notices\CliIntegrationNotice;
14 use WPStaging\Framework\Notices\Notices;
15 use WPStaging\Framework\Facades\Escape;
16 use WPStaging\Framework\Language\Language;
17 use WPStaging\Framework\Onboarding\FreeOnboarding;
18 use WPStaging\Framework\Onboarding\NextStepRenderer;
19 use WPStaging\Framework\Onboarding\OnboardingJourney;
20 use WPStaging\Framework\Onboarding\QueuedBackup;
21 use WPStaging\Framework\TemplateEngine\TemplateEngine;
22
23 $backupNotice = WPStaging::make(BackupPluginsNotice::class);
24 $notice = WPStaging::make(Notices::class);
25
26 $onboarding = FreeOnboarding::resolve();
27
28 if ($onboarding !== null) {
29 $onboarding->recordExposure();
30 }
31
32 $journey = $onboarding === null ? null : $onboarding->getJourney();
33 $journeyStep = $onboarding === null ? '' : $onboarding->getJourneyStep();
34 $isPreConsent = $onboarding !== null && $onboarding->isPreConsent();
35 $showBackupNext = $onboarding !== null && $onboarding->shouldOfferBackupNext();
36
37 $showSelector = $journeyStep === OnboardingJourney::STEP_SELECT;
38 $completedCapability = $journey === null ? '' : $journey->getAction(OnboardingJourney::POSITION_FIRST);
39 $nextCapability = $journey === null ? '' : $journey->getNextCapability();
40 $hasFirstSuccess = $journey !== null && $journey->isFirstCapabilityCompleted();
41
42 $secondAction = $journey === null ? '' : $journey->getAction(OnboardingJourney::POSITION_SECOND);
43
44 $nextStepRenderer = $hasFirstSuccess ? NextStepRenderer::resolve() : null;
45 $nextStepMarkup = $nextStepRenderer === null ? '' : $nextStepRenderer->render();
46 $isNextStepVisible = $nextStepMarkup !== '';
47
48 $isFocusMode = $isPreConsent || $journeyStep !== '';
49
50 // The first run offers a backup after staging; outside it the same offer is
51 // made only to a site that has no established backup workflow of its own.
52 $isFirstRunOffer = $showBackupNext && $journey !== null && $journey->getNextCapability() !== OnboardingJourney::CAPABILITY_STAGING;
53 // class_exists rather than a bare call: resolve() can only catch what happens
54 // after the class loads, and a stale autoload map would otherwise take the whole
55 // page down for a detail it can perfectly well render without.
56 $backupNextOffer = (!$isFocusMode && class_exists(BackupNextOffer::class)) ? BackupNextOffer::resolve() : null;
57 $offerBackupNext = $isFirstRunOffer || ($backupNextOffer !== null && $backupNextOffer->isEligible());
58
59 $adminUrl = admin_url('admin.php?page=');
60 $queuedBackupStatus = $offerBackupNext || $showBackupNext ? WPStaging::make(QueuedBackup::class)->getStatus() : '';
61 $runningCapability = $journeyStep === OnboardingJourney::STEP_RUNNING ? $journey->getRunningCapability() : '';
62
63 $activeCapability = $journeyStep === OnboardingJourney::STEP_RUNNING ? $journey->getActiveCapability() : '';
64 $showProgress = $activeCapability !== '' && !$isNextStepVisible;
65
66 // Kept in the DOM so their workflows keep loading behind the first run.
67 $onboardingHiddenClass = ($isPreConsent || $showSelector || $isNextStepVisible || $showProgress) ? ' wpstg-onboarding-hidden' : '';
68 if ($isNextStepVisible && $secondAction === '') {
69 $journey->recordNextOfferShown();
70 }
71
72 $isCalledFromIndex = true;
73 ?>
74
75 <div id="wpstg-clonepage-wrapper" class="<?php echo $isFocusMode ? 'wpstg-onboarding-focus' : ''; ?>">
76 <?php
77 if (!$isFocusMode) {
78 require_once($this->viewsPath . (WPStaging::isPro() ? 'pro/_main/header.php' : '_main/header.php'));
79
80 do_action('wpstg_notifications');
81 }
82
83 if (empty($isStagingPage)) {
84 echo "<script>window.addEventListener('DOMContentLoaded', function() {window.dispatchEvent(new Event('backups-tab'));});</script>";
85 $classStagingPageActive = '';
86 $classBackupPageActive = 'wpstg--tab--active';
87 } else {
88 $classStagingPageActive = 'wpstg--tab--active';
89 $classBackupPageActive = '';
90 }
91
92 ?>
93 <div class="wpstg--tab--wrapper">
94 <?php
95 if (!$isFocusMode) {
96 require_once(WPSTG_VIEWS_DIR . 'navigation/web-template.php');
97 }
98 ?>
99
100 <div class="wpstg-header">
101 <?php
102 if (!$isFocusMode && !WPStaging::isBasic()) {
103 require_once($this->viewsPath . 'pro/notices/update-notification.php');
104 }
105 ?>
106 </div>
107
108 <div class="wpstg-loading-bar-container">
109 <div class="wpstg-loading-bar"></div>
110 </div>
111
112 <div id="wpstg-error-wrapper">
113 <div id="wpstg-error-details"></div>
114 </div>
115
116 <div class="wpstg--tab--contents <?php echo $isStagingPage ? 'min-h-152' : 'min-h-375'; ?>">
117 <?php
118 // Focus mode withholds the header, so without this every state after
119 // the selector is an unbranded card floating in an empty page.
120 if ($isFocusMode) : ?>
121 <div class="wpstg-onboarding__logo">
122 <?php require WPSTG_VIEWS_DIR . 'notices/_partial/wp-staging-logo-svg.php'; ?>
123 </div>
124 <?php endif;
125
126 if ($isPreConsent) {
127 require WPSTG_VIEWS_DIR . 'onboarding/pre-consent.php';
128 } elseif ($showSelector) {
129 require WPSTG_VIEWS_DIR . 'onboarding/first-run.php';
130 }
131
132 if ($showProgress) {
133 require WPSTG_VIEWS_DIR . 'onboarding/progress.php';
134 }
135
136 // Where a job started from this page renders, instead of the modal.
137 // Its presence is what puts the process UI in focus mode at all.
138 if ($isFocusMode) : ?>
139 <div class="wpstg-onboarding-job" data-wpstg-inline-progress hidden></div>
140 <?php endif;
141
142 echo $nextStepMarkup; // phpcs:ignore WPStagingCS.Security.EscapeOutput.OutputNotEscaped -- Markup from NextStepRenderer; every value is escaped in onboarding/next-step.php.
143 ?>
144 <div id="wpstg--tab--staging" class="wpstg--tab--content wpstg-onboarding-pane <?php echo esc_attr($classStagingPageActive) . esc_attr($onboardingHiddenClass); ?>">
145 <?php
146 $notice->maybeShowElementorCloudNotice();
147 if ($this->siteInfo->isHostedOnWordPressCom()) {
148 require $this->viewsPath . 'staging/wordpress-com/index.php';
149 } elseif (!defined('WPSTGPRO_VERSION') && is_multisite()) {
150 require $this->viewsPath . 'staging/free-version.php';
151 } elseif (!$this->siteInfo->isCloneable()) {
152 require $this->viewsPath . 'staging/staging-site/index.php';
153 } elseif (defined('WPSTGPRO_VERSION') && is_multisite()) {
154 do_action(TemplateEngine::ACTION_MULTI_SITE_CLONE_OPTION);
155 } else {
156 require $this->viewsPath . 'staging/index.php';
157 }
158 ?>
159 </div>
160 <div id="wpstg--tab--backup" class="wpstg--tab--content wpstg-onboarding-pane <?php echo esc_attr($classBackupPageActive) . esc_attr($onboardingHiddenClass); ?>">
161 <?php
162 $cliNotice = WPStaging::make(CliIntegrationNotice::class);
163 $cliNotice->maybeShowCliNotice();
164 // When banner is dismissed but dock CTA should be shown, render modal separately
165 $cliNotice->maybeRenderCliModalForDockCta();
166 ?>
167 <div id="wpstg-backup-content">
168 <div class="wpstg-backup-listing-skeleton wpstg-animate-pulse wpstg-py-4">
169 <div class="wpstg-space-y-3">
170 <div class="wpstg-h-4 wpstg-bg-gray-200 wpstg-rounded wpstg-w-1/4 dark:wpstg-bg-gray-700"></div>
171 <div class="wpstg-h-3 wpstg-bg-gray-200 wpstg-rounded wpstg-w-full dark:wpstg-bg-gray-700"></div>
172 <div class="wpstg-h-3 wpstg-bg-gray-200 wpstg-rounded wpstg-w-5/6 dark:wpstg-bg-gray-700"></div>
173 <div class="wpstg-h-3 wpstg-bg-gray-200 wpstg-rounded wpstg-w-4/5 dark:wpstg-bg-gray-700"></div>
174 </div>
175 </div>
176 </div>
177 </div>
178 <div class="wpstg-did-you-know-footer wpstg-onboarding-pane<?php echo esc_attr($onboardingHiddenClass); ?>">
179 <?php echo sprintf(
180 Escape::escapeHtml(__('Need to move this site elsewhere? You can also use backup files for transfers. <a href="%s" target="_blank">Read more</a>', 'wp-staging')),
181 Language::localizeDocsUrl('https://wp-staging.com/docs/how-to-migrate-your-wordpress-site-to-a-new-host/')
182 ); ?>
183 </div>
184 </div>
185 </div>
186 <?php
187 if (!$isFocusMode) {
188 require_once($this->viewsPath . '_main/footer.php');
189 }
190 ?>
191 <script>
192 // Dismiss handler for the compact general "Upgrade to Pro" card. The staging
193 // listing is injected via innerHTML (scripts inside it do not execute), so
194 // this is delegated from the document to work on injected content.
195 (function () {
196 document.addEventListener('click', function (event) {
197 var trigger = event.target.closest('.wpstg-pro-card-dismiss');
198 if (!trigger) {
199 return;
200 }
201
202 event.preventDefault();
203
204 var body = new URLSearchParams();
205 body.append('action', 'wpstg_dismiss_notice');
206 body.append('nonce', wpstg.nonce);
207 body.append('wpstg_notice', 'general_pro_card');
208
209 fetch(ajaxurl, {
210 method: 'POST',
211 credentials: 'same-origin',
212 headers: {'Content-Type': 'application/x-www-form-urlencoded'},
213 body: body.toString()
214 }).then(function (response) {
215 return response.json();
216 }).then(function (success) {
217 // Only hide once the snooze was persisted; otherwise the card would
218 // vanish on a failed request and reappear on the next reload.
219 if (success !== true) {
220 return;
221 }
222
223 var card = document.querySelector('.wpstg-general-pro-card');
224 if (card) {
225 card.style.display = 'none';
226 }
227 }).catch(function () {});
228 });
229 })();
230 </script>
231 <?php
232 // Hidden host for the staging-created success modal's review block. Kept on
233 // the persistent page (not the AJAX-injected listing) so it is available when
234 // the success modal is built. Empty unless Free and review-eligible.
235 ?>
236 <div id="wpstg-staging-review-content" style="display:none;">
237 <?php include WPSTG_VIEWS_DIR . 'notices/review-prompt-modal.php'; ?>
238 </div>
239 <?php require_once(WPSTG_VIEWS_DIR . 'notices/review-prompt-handlers.php'); ?>
240
241 <?php if ($offerBackupNext) : ?>
242 <div id="wpstg-backup-next-content" style="display:none;">
243 <?php include WPSTG_VIEWS_DIR . 'onboarding/backup-next.php'; ?>
244 </div>
245 <?php endif; ?>
246 </div>
247