index.php
159 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\Core\WPStaging; |
| 11 | use WPStaging\Framework\Notices\BackupPluginsNotice; |
| 12 | use WPStaging\Framework\Notices\CliIntegrationNotice; |
| 13 | use WPStaging\Framework\Notices\Notices; |
| 14 | use WPStaging\Framework\Facades\Escape; |
| 15 | use WPStaging\Framework\Language\Language; |
| 16 | use WPStaging\Framework\TemplateEngine\TemplateEngine; |
| 17 | |
| 18 | $backupNotice = WPStaging::make(BackupPluginsNotice::class); |
| 19 | $notice = WPStaging::make(Notices::class); |
| 20 | |
| 21 | $isCalledFromIndex = true; |
| 22 | ?> |
| 23 | |
| 24 | <div id="wpstg-clonepage-wrapper"> |
| 25 | <?php |
| 26 | if (WPStaging::isPro()) { |
| 27 | require_once($this->viewsPath . 'pro/_main/header.php'); |
| 28 | } else { |
| 29 | require_once($this->viewsPath . '_main/header.php'); |
| 30 | } |
| 31 | |
| 32 | do_action('wpstg_notifications'); |
| 33 | |
| 34 | if (empty($isStagingPage)) { |
| 35 | echo "<script>window.addEventListener('DOMContentLoaded', function() {window.dispatchEvent(new Event('backups-tab'));});</script>"; |
| 36 | $classStagingPageActive = ''; |
| 37 | $classBackupPageActive = 'wpstg--tab--active'; |
| 38 | } else { |
| 39 | $classStagingPageActive = 'wpstg--tab--active'; |
| 40 | $classBackupPageActive = ''; |
| 41 | } |
| 42 | |
| 43 | ?> |
| 44 | <div class="wpstg--tab--wrapper"> |
| 45 | <?php |
| 46 | require_once(WPSTG_VIEWS_DIR . 'navigation/web-template.php'); |
| 47 | ?> |
| 48 | |
| 49 | <div class="wpstg-header"> |
| 50 | <?php |
| 51 | if (!WPStaging::isBasic()) { |
| 52 | require_once($this->viewsPath . 'pro/notices/update-notification.php'); |
| 53 | } |
| 54 | ?> |
| 55 | </div> |
| 56 | |
| 57 | <div class="wpstg-loading-bar-container"> |
| 58 | <div class="wpstg-loading-bar"></div> |
| 59 | </div> |
| 60 | |
| 61 | <div id="wpstg-error-wrapper"> |
| 62 | <div id="wpstg-error-details"></div> |
| 63 | </div> |
| 64 | |
| 65 | <div class="wpstg--tab--contents <?php echo $isStagingPage ? 'min-h-152' : 'min-h-375'; ?>"> |
| 66 | <div id="wpstg--tab--staging" class="wpstg--tab--content <?php echo esc_attr($classStagingPageActive); ?>"> |
| 67 | <?php |
| 68 | $notice->maybeShowElementorCloudNotice(); |
| 69 | if ($this->siteInfo->isHostedOnWordPressCom()) { |
| 70 | require $this->viewsPath . 'staging/wordpress-com/index.php'; |
| 71 | } elseif (!defined('WPSTGPRO_VERSION') && is_multisite()) { |
| 72 | require $this->viewsPath . 'staging/free-version.php'; |
| 73 | } elseif (!$this->siteInfo->isCloneable()) { |
| 74 | require $this->viewsPath . 'staging/staging-site/index.php'; |
| 75 | } elseif (defined('WPSTGPRO_VERSION') && is_multisite()) { |
| 76 | do_action(TemplateEngine::ACTION_MULTI_SITE_CLONE_OPTION); |
| 77 | } else { |
| 78 | require $this->viewsPath . 'staging/index.php'; |
| 79 | } |
| 80 | ?> |
| 81 | </div> |
| 82 | <div id="wpstg--tab--backup" class="wpstg--tab--content <?php echo esc_attr($classBackupPageActive); ?>"> |
| 83 | <?php |
| 84 | $cliNotice = WPStaging::make(CliIntegrationNotice::class); |
| 85 | $cliNotice->maybeShowCliNotice(); |
| 86 | // When banner is dismissed but dock CTA should be shown, render modal separately |
| 87 | $cliNotice->maybeRenderCliModalForDockCta(); |
| 88 | ?> |
| 89 | <div id="wpstg-backup-content"> |
| 90 | <div class="wpstg-backup-listing-skeleton wpstg-animate-pulse wpstg-py-4"> |
| 91 | <div class="wpstg-space-y-3"> |
| 92 | <div class="wpstg-h-4 wpstg-bg-gray-200 wpstg-rounded wpstg-w-1/4 dark:wpstg-bg-gray-700"></div> |
| 93 | <div class="wpstg-h-3 wpstg-bg-gray-200 wpstg-rounded wpstg-w-full dark:wpstg-bg-gray-700"></div> |
| 94 | <div class="wpstg-h-3 wpstg-bg-gray-200 wpstg-rounded wpstg-w-5/6 dark:wpstg-bg-gray-700"></div> |
| 95 | <div class="wpstg-h-3 wpstg-bg-gray-200 wpstg-rounded wpstg-w-4/5 dark:wpstg-bg-gray-700"></div> |
| 96 | </div> |
| 97 | </div> |
| 98 | </div> |
| 99 | </div> |
| 100 | <div class="wpstg-did-you-know-footer"> |
| 101 | <?php echo sprintf( |
| 102 | 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')), |
| 103 | Language::localizeDocsUrl('https://wp-staging.com/docs/how-to-migrate-your-wordpress-site-to-a-new-host/') |
| 104 | ); ?> |
| 105 | </div> |
| 106 | </div> |
| 107 | </div> |
| 108 | <?php require_once($this->viewsPath . '_main/footer.php'); ?> |
| 109 | <script> |
| 110 | // Dismiss handler for the compact general "Upgrade to Pro" card. The staging |
| 111 | // listing is injected via innerHTML (scripts inside it do not execute), so |
| 112 | // this is delegated from the document to work on injected content. |
| 113 | (function () { |
| 114 | document.addEventListener('click', function (event) { |
| 115 | var trigger = event.target.closest('.wpstg-pro-card-dismiss'); |
| 116 | if (!trigger) { |
| 117 | return; |
| 118 | } |
| 119 | |
| 120 | event.preventDefault(); |
| 121 | |
| 122 | var body = new URLSearchParams(); |
| 123 | body.append('action', 'wpstg_dismiss_notice'); |
| 124 | body.append('nonce', wpstg.nonce); |
| 125 | body.append('wpstg_notice', 'general_pro_card'); |
| 126 | |
| 127 | fetch(ajaxurl, { |
| 128 | method: 'POST', |
| 129 | credentials: 'same-origin', |
| 130 | headers: {'Content-Type': 'application/x-www-form-urlencoded'}, |
| 131 | body: body.toString() |
| 132 | }).then(function (response) { |
| 133 | return response.json(); |
| 134 | }).then(function (success) { |
| 135 | // Only hide once the snooze was persisted; otherwise the card would |
| 136 | // vanish on a failed request and reappear on the next reload. |
| 137 | if (success !== true) { |
| 138 | return; |
| 139 | } |
| 140 | |
| 141 | var card = document.querySelector('.wpstg-general-pro-card'); |
| 142 | if (card) { |
| 143 | card.style.display = 'none'; |
| 144 | } |
| 145 | }).catch(function () {}); |
| 146 | }); |
| 147 | })(); |
| 148 | </script> |
| 149 | <?php |
| 150 | // Hidden host for the staging-created success modal's review block. Kept on |
| 151 | // the persistent page (not the AJAX-injected listing) so it is available when |
| 152 | // the success modal is built. Empty unless Free and review-eligible. |
| 153 | ?> |
| 154 | <div id="wpstg-staging-review-content" style="display:none;"> |
| 155 | <?php include WPSTG_VIEWS_DIR . 'notices/review-prompt-modal.php'; ?> |
| 156 | </div> |
| 157 | <?php require_once(WPSTG_VIEWS_DIR . 'notices/review-prompt-handlers.php'); ?> |
| 158 | </div> |
| 159 |