PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backup, Restore, Migration & Clone / 4.9.2
WP STAGING – WordPress Backup, Restore, Migration & Clone v4.9.2
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 / Staging / Renderer / SetupRenderer.php
wp-staging / Staging / Renderer Last commit date
SetupRenderer.php 1 day ago
SetupRenderer.php
171 lines
1 <?php
2
3 namespace WPStaging\Staging\Renderer;
4
5 use WPStaging\Staging\Dto\StagingSiteDto;
6 use WPStaging\Staging\Service\AbstractStagingSetup;
7
8 /**
9 * Renders shared setup modal UI fragments.
10 */
11 class SetupRenderer
12 {
13 /**
14 * @var string
15 */
16 private $selectedEngineName = '';
17
18 public function setSelectedEngineName(string $selectedEngineName = ''): self
19 {
20 $this->selectedEngineName = !empty($selectedEngineName) ? $selectedEngineName : esc_html__('Classic', 'wp-staging');
21
22 return $this;
23 }
24
25 public function getSelectedEngineName(): string
26 {
27 return !empty($this->selectedEngineName) ? $this->selectedEngineName : esc_html__('Classic', 'wp-staging');
28 }
29
30 public function icon(string $name, string $class = 'wpstg-h-5 wpstg-w-5', float $strokeWidth = 1.75)
31 {
32 $this->renderPartial('icon', compact('name', 'class', 'strokeWidth'));
33 }
34
35 public function attributes(array $attributes)
36 {
37 $this->renderPartial('attributes', compact('attributes'));
38 }
39
40 public function closeButton(string $class)
41 {
42 $this->renderPartial('close-button', compact('class'));
43 }
44
45 public function stepBadge(string $label)
46 {
47 $this->renderPartial('step-badge', compact('label'));
48 }
49
50 public function modalHeader(string $title, string $description = '', string $titleId = '', string $stepLabel = '', string $extraClass = '', string $afterDescription = '', string $icon = '')
51 {
52 $this->renderPartial('modal-header', compact('title', 'description', 'titleId', 'stepLabel', 'extraClass', 'afterDescription', 'icon'));
53 }
54
55 public function footerButton(string $label, string $class, string $variant = 'secondary', string $icon = '', string $iconPosition = 'start', array $attributes = [])
56 {
57 $this->renderPartial('footer-button', compact('label', 'class', 'variant', 'icon', 'iconPosition', 'attributes'));
58 }
59
60 public function modalFooter(string $status, callable $buttons, string $extraClass = '', string $statusWarning = '')
61 {
62 $this->renderPartial('modal-footer', compact('status', 'buttons', 'extraClass', 'statusWarning'));
63 }
64
65 public function reviewCard(string $title, array $rows)
66 {
67 $this->renderPartial('review-card', compact('title', 'rows'));
68 }
69
70 public function accordionSection(array $args, callable $content)
71 {
72 $this->renderPartial('accordion-section', compact('args', 'content'));
73 }
74
75 public function setupOptionCard(string $name, string $label, string $description, bool $checked = false, array $checkboxOptions = [], string $tooltip = '', bool $proLocked = false)
76 {
77 $this->renderPartial('setup-option-card', compact('name', 'label', 'description', 'checked', 'checkboxOptions', 'tooltip', 'proLocked'));
78 }
79
80 public function proControlRow(string $name, bool $checked, string $label, string $description, string $statusLabel = '', string $badgeLabel = '', string $context = '')
81 {
82 $this->renderPartial('pro-control-row', compact('name', 'checked', 'label', 'description', 'statusLabel', 'badgeLabel', 'context'));
83 }
84
85 public function setupCopyCard(string $checkboxId, string $checkboxClass, string $title, callable $summary, string $buttonClass, string $buttonLabel, string $buttonIcon, $details = null, array $checkboxOptions = [], $afterContent = null)
86 {
87 $this->renderPartial('setup-copy-card', compact('checkboxId', 'checkboxClass', 'title', 'summary', 'buttonClass', 'buttonLabel', 'buttonIcon', 'details', 'checkboxOptions', 'afterContent'));
88 }
89
90 public function readyCard(
91 string $title = '',
92 string $description = '',
93 string $databaseDescription = '',
94 string $filesDescription = '',
95 bool $showRuntimeBehavior = true,
96 string $runtimeDescription = '',
97 string $cardClass = '',
98 string $runtimeTitle = '',
99 string $engineSuffix = '',
100 string $runtimeIcon = 'shield',
101 array $customizeLinks = [],
102 bool $runtimeLocked = false
103 ) {
104 $this->renderPartial('ready-card', compact(
105 'title',
106 'description',
107 'databaseDescription',
108 'filesDescription',
109 'showRuntimeBehavior',
110 'runtimeDescription',
111 'cardClass',
112 'runtimeTitle',
113 'engineSuffix',
114 'runtimeIcon',
115 'customizeLinks',
116 'runtimeLocked'
117 ));
118 }
119
120 public function engineSection(string $setupMode, string $enginePanelId)
121 {
122 $this->renderPartial('engine-section', compact('setupMode', 'enginePanelId'));
123 }
124
125 public function runtimeSection(bool $isCreate, bool $isUpdate, bool $isProLicenseActive, bool $showWooSchedulerSettings, StagingSiteDto $stagingSiteDto, array $runtimeSummaryTooltips)
126 {
127 $this->renderPartial('runtime-section', compact('isCreate', 'isUpdate', 'isProLicenseActive', 'showWooSchedulerSettings', 'stagingSiteDto', 'runtimeSummaryTooltips'));
128 }
129
130 public function destinationSection(bool $isProLicenseActive, bool $isProBuild, bool $isCreate, AbstractStagingSetup $stagingSetup, string $defaultPathBase, string $defaultSiteName, string $productionSiteUrl)
131 {
132 $this->renderPartial('destination-section', compact('isProLicenseActive', 'isProBuild', 'isCreate', 'stagingSetup', 'defaultPathBase', 'defaultSiteName', 'productionSiteUrl'));
133 }
134
135 public function runtimeSummaryValue(string $key, array $tooltips, bool $isProLicenseActive)
136 {
137 $this->renderPartial('runtime-summary-value', compact('key', 'tooltips', 'isProLicenseActive'));
138 }
139
140 public function hasWooSchedulerSettings(AbstractStagingSetup $stagingSetup): bool
141 {
142 return strpos($this->captureCallable([$stagingSetup, 'renderEnableWooSchedulerSettings']), 'wpstg_woo_scheduler_enabled') !== false;
143 }
144
145 public function configurationBody(array $context)
146 {
147 $this->renderPartial('configuration-body', $context);
148 }
149
150 public function createSetupFooter(string $previewSiteUrl)
151 {
152 $this->renderPartial('create-setup-footer', compact('previewSiteUrl'));
153 }
154
155 private function captureCallable(callable $callback): string
156 {
157 ob_start();
158 $callback();
159
160 return (string)ob_get_clean();
161 }
162
163 private function renderPartial(string $partial, array $data = [])
164 {
165 $renderer = $this;
166 extract($data, EXTR_SKIP);
167
168 require WPSTG_VIEWS_DIR . 'staging/_partials/setup-modal/' . $partial . '.php';
169 }
170 }
171