Ajax
1 day ago
BackgroundProcessing
1 day ago
Dto
1 day ago
Entity
1 day ago
Exceptions
1 day ago
FileHeader
1 day ago
Interfaces
1 day ago
Job
1 day ago
Request
1 day ago
Service
1 day ago
Storage
1 day ago
Task
1 day ago
Traits
1 day ago
Utils
1 day ago
AfterRestore.php
1 day ago
BackupDeleter.php
1 day ago
BackupDownload.php
1 day ago
BackupFileIndex.php
1 day ago
BackupGlitchReason.php
1 day ago
BackupHeader.php
1 day ago
BackupNextOffer.php
1 day ago
BackupRepairer.php
1 day ago
BackupRetentionHandler.php
1 day ago
BackupScheduler.php
1 day ago
BackupServiceProvider.php
1 day ago
BackupValidator.php
1 day ago
BeforeUpdateRowStatus.php
1 day ago
FileHeader.php
1 day ago
FileHeaderAttribute.php
1 day ago
UpdateProtectionPausedNotice.php
1 day ago
WithBackupIdentifier.php
1 day ago
UpdateProtectionPausedNotice.php
88 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPStaging\Backup; |
| 4 | |
| 5 | use WPStaging\Backup\Service\UpdateProtectionHealth; |
| 6 | use WPStaging\Backup\Service\UpdateProtectionSettings; |
| 7 | use WPStaging\Framework\Security\Capabilities; |
| 8 | use WPStaging\Framework\Traits\PagesTrait; |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | class UpdateProtectionPausedNotice |
| 18 | { |
| 19 | use PagesTrait; |
| 20 | |
| 21 | |
| 22 | private $health; |
| 23 | |
| 24 | |
| 25 | private $settings; |
| 26 | |
| 27 | |
| 28 | private $capabilities; |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | public function __construct(UpdateProtectionHealth $health, UpdateProtectionSettings $settings, Capabilities $capabilities) |
| 36 | { |
| 37 | $this->health = $health; |
| 38 | $this->settings = $settings; |
| 39 | $this->capabilities = $capabilities; |
| 40 | } |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | public function render() |
| 47 | { |
| 48 | if (!$this->isWordPressUpdatePage() || !current_user_can($this->capabilities->manageWPSTG())) { |
| 49 | return; |
| 50 | } |
| 51 | |
| 52 | if (!$this->settings->isEnabled() || !$this->health->isPaused()) { |
| 53 | return; |
| 54 | } |
| 55 | |
| 56 | ?> |
| 57 | <div class="notice notice-warning wpstg-update-protection-paused"> |
| 58 | <p> |
| 59 | <strong><?php esc_html_e('WP STAGING Update Protection is temporarily unavailable', 'wp-staging'); ?></strong><br> |
| 60 | <?php esc_html_e('A recovery backup couldn\'t be created. Plugin updates will continue normally until backup protection is available again.', 'wp-staging'); ?> |
| 61 | <?php echo $this->getReasonSentence(); // phpcs:ignore WPStaging.Security.EscapeOutput -- Both branches return an escaped string. ?> |
| 62 | </p> |
| 63 | <p> |
| 64 | <button type="button" class="button" data-wpstg-resume-update-protection> |
| 65 | <?php esc_html_e('Try protection again', 'wp-staging'); ?> |
| 66 | </button> |
| 67 | </p> |
| 68 | </div> |
| 69 | <?php |
| 70 | } |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | private function getReasonSentence(): string |
| 76 | { |
| 77 | if ($this->health->getReason() === UpdateProtectionHealth::REASON_DISK_SPACE) { |
| 78 | return esc_html__('There was not enough free disk space to create the backup.', 'wp-staging'); |
| 79 | } |
| 80 | |
| 81 | if ($this->health->getReason() === UpdateProtectionHealth::REASON_PERMISSIONS) { |
| 82 | return esc_html__('WP STAGING could not write to the backup directory.', 'wp-staging'); |
| 83 | } |
| 84 | |
| 85 | return ''; |
| 86 | } |
| 87 | } |
| 88 |