PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backups, Restore, Migration & Clone / trunk
WP STAGING – WordPress Backups, Restore, Migration & Clone vtrunk
4.11.1 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 / Backup / BeforeUpdateRowStatus.php
wp-staging / Backup Last commit date
Ajax 5 days ago BackgroundProcessing 1 week ago Dto 5 days ago Entity 1 week ago Exceptions 1 week ago FileHeader 1 week ago Interfaces 1 week ago Job 5 days ago Request 1 week ago Service 5 days ago Storage 1 week ago Task 5 days ago Traits 1 week ago Utils 1 week ago AfterRestore.php 1 week ago BackupDeleter.php 1 week ago BackupDownload.php 1 week ago BackupFileIndex.php 1 week ago BackupGlitchReason.php 1 week ago BackupHeader.php 5 days ago BackupNextOffer.php 1 week ago BackupRepairer.php 1 week ago BackupRetentionHandler.php 1 week ago BackupScheduler.php 5 days ago BackupServiceProvider.php 1 week ago BackupValidator.php 5 days ago BeforeUpdateRowStatus.php 1 week ago FileHeader.php 1 week ago FileHeaderAttribute.php 1 week ago UpdateProtectionPausedNotice.php 1 week ago WithBackupIdentifier.php 1 week ago
BeforeUpdateRowStatus.php
119 lines
1 <?php
2
3 namespace WPStaging\Backup;
4
5 use WPStaging\Backup\Service\BeforeUpdateBackupRequest;
6 use WPStaging\Backup\Service\UpdateProtectionSettings;
7 use WPStaging\Framework\Assets\I18n;
8
9
10
11
12
13
14
15
16
17
18
19
20
21 class BeforeUpdateRowStatus
22 {
23
24 const ATTRIBUTE = 'data-wpstg-before-update-status';
25
26
27 private $backupRequest;
28
29
30 private $settings;
31
32
33 private $i18n;
34
35
36
37
38
39
40 public function __construct(BeforeUpdateBackupRequest $backupRequest, UpdateProtectionSettings $settings, I18n $i18n)
41 {
42 $this->backupRequest = $backupRequest;
43 $this->settings = $settings;
44 $this->i18n = $i18n;
45 }
46
47
48
49
50
51 public function registerRowMessages()
52 {
53 if (!$this->settings->isEnabled()) {
54 return;
55 }
56
57 foreach ($this->getPluginsWithUpdates() as $pluginFile) {
58 add_action("in_plugin_update_message-{$pluginFile}", [$this, 'renderAnchor'], 10, 2); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
59 }
60 }
61
62
63
64
65
66
67
68
69
70
71 public function renderAnchor($pluginData = [], $response = null)
72 {
73 $pluginFile = '';
74 if (is_object($response) && isset($response->plugin)) {
75 $pluginFile = (string)$response->plugin;
76 }
77
78 printf(
79 ' <span class="wpstg-before-update-status" %s="%s">%s</span>',
80 esc_attr(self::ATTRIBUTE),
81 esc_attr($pluginFile),
82 $this->getStatusText($pluginFile)
83 );
84 }
85
86
87
88
89
90
91
92
93 private function getStatusText(string $pluginFile): string
94 {
95 $position = array_search($pluginFile, $this->backupRequest->getPendingPluginFiles(), true);
96 if ($pluginFile === '' || $position === false) {
97 return '';
98 }
99
100 $sentences = $this->i18n->getTranslations()['backup_before_update'];
101
102 return $position === 0 ? $sentences['row_backing_up'] : $sentences['row_queued'];
103 }
104
105
106
107
108 private function getPluginsWithUpdates(): array
109 {
110 $updates = get_site_transient('update_plugins');
111
112 if (!is_object($updates) || !isset($updates->response) || !is_array($updates->response)) {
113 return [];
114 }
115
116 return array_keys($updates->response);
117 }
118 }
119