_partial
1 week ago
aios-salt-postfix-enabled.php
1 year ago
analytics-consent-failed.php
1 year ago
analytics-consent-refused.php
1 year ago
analytics-modal.php
1 month ago
backup-plugins-notice.php
7 months ago
beta.php
1 year ago
cache-directory-permission-problem.php
1 year ago
cli-integration-notice.php
4 days ago
cron-warning-notice.php
2 months ago
directory-listing-could-not-be-prevented.php
7 months ago
disabled-items-notice.php
1 year ago
disabled-optimizer-notice.php
1 year ago
elementor-cloud-notice.php
4 months ago
logs-directory-permission-problem.php
1 year ago
low-memory-limit.php
1 year ago
mu-plugin-directory-permission-problem.php
1 year ago
next-gen-engine-notice.php
4 days ago
no-db-prefix-notice.php
1 year ago
object-cache-skipped.php
11 months ago
outdated-wp-staging-hooks.php
1 year ago
outdated-wp-staging-version.php
1 year ago
pro-crons-notice.php
1 year ago
review-prompt-handlers.php
2 weeks ago
review-prompt-modal.php
2 weeks ago
settings_option_corrupt.php
1 year ago
staging-directory-permission-problem.php
1 year ago
staging-symlink-enabled-notice.php
10 months ago
table-tmp-prefix-conflict-notice.php
1 year ago
transient.php
1 year ago
uploads-outside-wp-root.php
1 year ago
vars-directory-permission-problem.php
1 year ago
wordfence-userini-renamed.php
5 months ago
wp-options-missing-pk.php
5 months ago
wp-version-compat-notice.php
4 months ago
wpe-permalink-issue-notice.php
1 year ago
wrong-scheme.php
1 year ago
cron-warning-notice.php
148 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Cron Warning Notice - Compact banner for WP-Cron status warnings |
| 5 | * |
| 6 | * Uses UI primitives for buttons and badges, with minimal custom layout styles. |
| 7 | * |
| 8 | * @var BackupScheduler $backupScheduler |
| 9 | * @var bool $cronStatus |
| 10 | * @var string $cronMessage |
| 11 | */ |
| 12 | |
| 13 | use WPStaging\Backup\BackupScheduler; |
| 14 | use WPStaging\Core\WPStaging; |
| 15 | use WPStaging\Framework\Utils\ServerVars; |
| 16 | |
| 17 | // Don't show if no cron issues |
| 18 | if ($cronMessage === '' && $backupScheduler->getWarningType() === '') { |
| 19 | return; |
| 20 | } |
| 21 | |
| 22 | $overdueCount = $backupScheduler->getOverdueCronJobsCount(); |
| 23 | $hasOverdue = $backupScheduler->hasOverdueCronJobs(); |
| 24 | $isWpCronDisabled = $backupScheduler->isWpCronDisabled(); |
| 25 | $isLitespeed = WPStaging::make(ServerVars::class)->isLitespeed(); |
| 26 | $isPro = WPStaging::isPro(); |
| 27 | $warningType = $backupScheduler->getWarningType(); |
| 28 | $failureMessage = $backupScheduler->getLastBackupFailureMessage(); |
| 29 | |
| 30 | // Help article URL |
| 31 | $helpUrl = $isPro |
| 32 | ? 'https://wp-staging.com/docs/wp-cron-is-not-working-correctly/' |
| 33 | : 'https://wordpress.org/support/plugin/wp-staging/'; |
| 34 | ?> |
| 35 | |
| 36 | <div class="wpstg-cron-banner" id="wpstg-cron-warning-notice"> |
| 37 | <!-- Collapsed row: icon + message + badge + buttons --> |
| 38 | <div class="wpstg-cron-banner-row"> |
| 39 | <!-- Icon Box - uses UI primitive --> |
| 40 | <div class="wpstg-icon-box wpstg-icon-box-amber wpstg-cron-banner-icon"> |
| 41 | <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> |
| 42 | <circle cx="12" cy="12" r="10"></circle> |
| 43 | <line x1="12" y1="8" x2="12" y2="12"></line> |
| 44 | <line x1="12" y1="16" x2="12.01" y2="16"></line> |
| 45 | </svg> |
| 46 | </div> |
| 47 | |
| 48 | <!-- Message + Badge --> |
| 49 | <div class="wpstg-cron-banner-message"> |
| 50 | <span class="wpstg-cron-banner-text"> |
| 51 | <?php if ($warningType === BackupScheduler::CRON_WARNING_TYPE_FAILURE) : ?> |
| 52 | <?php esc_html_e('Last scheduled backup failed.', 'wp-staging'); ?> |
| 53 | <?php elseif ($warningType === BackupScheduler::CRON_WARNING_TYPE_OVERDUE) : ?> |
| 54 | <?php esc_html_e('Scheduled backup is overdue.', 'wp-staging'); ?> |
| 55 | <?php else : ?> |
| 56 | <?php esc_html_e('Scheduled backups may not run.', 'wp-staging'); ?> |
| 57 | <?php endif; ?> |
| 58 | </span> |
| 59 | <?php if ($hasOverdue) : ?> |
| 60 | <span class="wpstg-badge wpstg-cron-banner-badge"><?php echo esc_html((string)$overdueCount); ?> <?php esc_html_e('overdue', 'wp-staging'); ?></span> |
| 61 | <?php endif; ?> |
| 62 | </div> |
| 63 | |
| 64 | <!-- Actions - uses UI primitive buttons --> |
| 65 | <div class="wpstg-cron-banner-actions"> |
| 66 | <a href="<?php echo esc_url($helpUrl); ?>" target="_blank" rel="noopener" class="wpstg-btn wpstg-btn-sm wpstg-btn-warning"> |
| 67 | <?php if ($warningType === BackupScheduler::CRON_WARNING_TYPE_FAILURE || $warningType === BackupScheduler::CRON_WARNING_TYPE_OVERDUE) : ?> |
| 68 | <?php esc_html_e('Get Help', 'wp-staging'); ?> |
| 69 | <?php else : ?> |
| 70 | <?php esc_html_e('Fix WP-Cron', 'wp-staging'); ?> |
| 71 | <?php endif; ?> |
| 72 | <svg class="wpstg-btn-icon-sm" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> |
| 73 | <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path> |
| 74 | <polyline points="15 3 21 3 21 9"></polyline> |
| 75 | <line x1="10" y1="14" x2="21" y2="3"></line> |
| 76 | </svg> |
| 77 | </a> |
| 78 | <button |
| 79 | type="button" |
| 80 | class="wpstg-btn wpstg-btn-sm wpstg-btn-warning-outline wpstg-cron-banner-toggle" |
| 81 | aria-expanded="false" |
| 82 | aria-controls="wpstg-cron-banner-details" |
| 83 | > |
| 84 | <?php esc_html_e('Details', 'wp-staging'); ?> |
| 85 | <svg class="wpstg-cron-banner-caret wpstg-btn-icon-sm" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> |
| 86 | <polyline points="6 9 12 15 18 9"></polyline> |
| 87 | </svg> |
| 88 | </button> |
| 89 | </div> |
| 90 | </div> |
| 91 | |
| 92 | <!-- Expandable details panel --> |
| 93 | <div id="wpstg-cron-banner-details" class="wpstg-cron-banner-details" hidden> |
| 94 | <div class="wpstg-cron-banner-details-content"> |
| 95 | <?php if ($warningType === BackupScheduler::CRON_WARNING_TYPE_FAILURE && $failureMessage !== '') : ?> |
| 96 | <p class="wpstg-cron-banner-cause"> |
| 97 | <?php esc_html_e('Error:', 'wp-staging'); ?> |
| 98 | <code class="wpstg-code-chip"><?php echo esc_html($failureMessage); ?></code> |
| 99 | </p> |
| 100 | <?php endif; ?> |
| 101 | <?php if ($isWpCronDisabled) : ?> |
| 102 | <p class="wpstg-cron-banner-cause"> |
| 103 | <?php esc_html_e('Detected', 'wp-staging'); ?> |
| 104 | <code class="wpstg-code-chip">DISABLE_WP_CRON=true</code> |
| 105 | <?php esc_html_e('in wp-config.php.', 'wp-staging'); ?> |
| 106 | </p> |
| 107 | <?php endif; ?> |
| 108 | <p class="wpstg-cron-banner-guidance"> |
| 109 | <?php esc_html_e('Enable WP-Cron or configure a server cron job.', 'wp-staging'); ?> |
| 110 | <?php if ($hasOverdue) : ?> |
| 111 | <?php esc_html_e('This could also indicate a development site with no visitors.', 'wp-staging'); ?> |
| 112 | <?php endif; ?> |
| 113 | </p> |
| 114 | <?php if ($isLitespeed) : ?> |
| 115 | <p class="wpstg-cron-banner-litespeed"> |
| 116 | <?php esc_html_e('LiteSpeed server detected.', 'wp-staging'); ?> |
| 117 | <a href="https://wp-staging.com/docs/scheduled-backups-do-not-work-hosting-company-uses-the-litespeed-webserver-fix-wp-cron/" target="_blank" rel="noopener"> |
| 118 | <?php esc_html_e('Learn more', 'wp-staging'); ?> |
| 119 | <svg class="wpstg-btn-icon-sm wpstg-inline" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> |
| 120 | <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path> |
| 121 | <polyline points="15 3 21 3 21 9"></polyline> |
| 122 | <line x1="10" y1="14" x2="21" y2="3"></line> |
| 123 | </svg> |
| 124 | </a> |
| 125 | </p> |
| 126 | <?php endif; ?> |
| 127 | </div> |
| 128 | </div> |
| 129 | </div> |
| 130 | |
| 131 | <script> |
| 132 | (function() { |
| 133 | 'use strict'; |
| 134 | |
| 135 | var toggle = document.querySelector('.wpstg-cron-banner-toggle'); |
| 136 | if (!toggle) return; |
| 137 | |
| 138 | toggle.onclick = function() { |
| 139 | var details = document.getElementById('wpstg-cron-banner-details'); |
| 140 | var isExpanded = this.getAttribute('aria-expanded') === 'true'; |
| 141 | |
| 142 | this.setAttribute('aria-expanded', !isExpanded); |
| 143 | details.hidden = isExpanded; |
| 144 | this.classList.toggle('wpstg-expanded', !isExpanded); |
| 145 | }; |
| 146 | })(); |
| 147 | </script> |
| 148 |