PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backups, Restore, Migration & Clone / 4.11.0
WP STAGING – WordPress Backups, Restore, Migration & Clone v4.11.0
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 / Framework / Onboarding / NextStepRenderer.php
wp-staging / Framework / Onboarding Last commit date
BackupPluginsDetector.php 2 days ago FirstInstall.php 2 days ago FreeOnboarding.php 2 days ago NextStepRenderer.php 2 days ago OnboardingAjax.php 2 days ago OnboardingJourney.php 2 days ago QueuedBackup.php 2 days ago
NextStepRenderer.php
129 lines
1 <?php
2
3 namespace WPStaging\Framework\Onboarding;
4
5 use WPStaging\Core\WPStaging;
6 use WPStaging\Framework\Utils\Strings;
7
8
9
10
11
12
13
14
15
16
17
18 class NextStepRenderer
19 {
20
21 private $journey;
22
23
24 private $onboarding;
25
26
27 private $queuedBackup;
28
29
30 private $strings;
31
32 public function __construct(FreeOnboarding $onboarding, OnboardingJourney $journey, QueuedBackup $queuedBackup, Strings $strings)
33 {
34 $this->onboarding = $onboarding;
35 $this->journey = $journey;
36 $this->queuedBackup = $queuedBackup;
37 $this->strings = $strings;
38 }
39
40
41
42
43
44 public function render(): string
45 {
46
47
48 if ($this->journey->getCompletionReason() === OnboardingJourney::REASON_TWO_CAPABILITIES) {
49 return $this->renderCard(OnboardingJourney::CAPABILITY_STAGING, '', true, []);
50 }
51
52 $completedCapability = $this->journey->getAction(OnboardingJourney::POSITION_FIRST);
53
54 if ($completedCapability === '' || !$this->journey->isFirstCapabilityCompleted()) {
55 return '';
56 }
57
58 $secondAction = $this->journey->getAction(OnboardingJourney::POSITION_SECOND);
59
60 return $this->renderCard(
61 $completedCapability,
62 $this->journey->getNextCapability(),
63 $secondAction === '',
64 $this->describeBackup(),
65 $this->queuedBackup->isPending()
66 );
67 }
68
69
70
71
72
73
74
75
76
77
78
79 private function describeBackup(): array
80 {
81 $details = $this->journey->getCompletedBackupDetails();
82
83 if (empty($details['name'])) {
84 return $details;
85 }
86
87 $details['name'] = $this->strings->maskBackupFilename($details['name']);
88
89 return $details;
90 }
91
92
93
94
95
96
97
98
99 private function renderCard(string $completedCapability, string $nextCapability, bool $isNextStepOffered, array $backupDetails, bool $isBackupInBackground = false): string
100 {
101 $stagingSiteUrl = $this->onboarding->getLatestStagingSiteUrl();
102 $adminUrl = admin_url('admin.php?page=');
103
104
105
106 $isNextCapabilityAvailable = !($nextCapability === OnboardingJourney::CAPABILITY_STAGING && $this->onboarding->isHostedOnWordPressCom());
107
108 ob_start();
109 include WPSTG_VIEWS_DIR . 'onboarding/next-step.php';
110
111 return (string)ob_get_clean();
112 }
113
114
115
116
117
118
119
120 public static function resolve()
121 {
122 try {
123 return WPStaging::make(self::class);
124 } catch (\Throwable $e) {
125 return null;
126 }
127 }
128 }
129