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 / Staging / Dto / StagingSiteDto.php
wp-staging / Staging / Dto Last commit date
Job 1 day ago Service 1 day ago Task 1 day ago DirectoryNodeDto.php 1 day ago ListableStagingSite.php 1 day ago StagingSiteDto.php 1 day ago
StagingSiteDto.php
739 lines
1 <?php
2
3 namespace WPStaging\Staging\Dto;
4
5 use WPStaging\Framework\Traits\ArrayableTrait;
6 use WPStaging\Framework\Traits\HydrateTrait;
7
8
9
10
11
12
13
14
15 class StagingSiteDto implements \JsonSerializable
16 {
17 use HydrateTrait;
18 use ArrayableTrait;
19
20
21
22
23 const STATUS_FINISHED = 'finished';
24
25 const STATUS_UNFINISHED_BROKEN = 'unfinished or broken (?)';
26
27
28 protected $cloneId = '';
29
30
31 protected $cloneName = '';
32
33
34 protected $directoryName = '';
35
36
37 protected $path = '';
38
39
40 protected $url = '';
41
42
43 protected $number = 0;
44
45
46 protected $version = '';
47
48
49 protected $status = '';
50
51
52 protected $prefix = '';
53
54
55 protected $datetime = 0;
56
57
58 protected $databaseUser = '';
59
60
61 protected $databasePassword = '';
62
63
64 protected $databaseDatabase = '';
65
66
67 protected $databaseServer = '';
68
69
70 protected $databasePrefix = '';
71
72
73 protected $databaseSsl = false;
74
75
76 protected $isEmailsAllowed = true;
77
78
79 protected $uploadsSymlinked = false;
80
81
82 protected $includedTables = [];
83
84
85 protected $excludeSizeRules = [];
86
87
88 protected $excludeGlobRules = [];
89
90
91 protected $excludedDirectories = [];
92
93
94 protected $extraDirectories = [];
95
96
97 protected $networkClone = false;
98
99
100
101
102
103
104 protected $sourceBlogId = 0;
105
106
107 protected $isCronEnabled = true;
108
109
110 protected $isWooSchedulerEnabled = true;
111
112
113 protected $isEmailsReminderEnabled = false;
114
115
116 protected $ownerId = 0;
117
118
119 protected $useNewAdminAccount = false;
120
121
122 protected $adminEmail = '';
123
124
125 protected $adminPassword = '';
126
127
128 protected $excludedDirs = [];
129
130
131 protected $tablePushSelection = false;
132
133
134 protected $isAutoUpdatePlugins = false;
135
136 public function jsonSerialize(): mixed
137 {
138 return $this->toArray();
139 }
140
141 public function toListableItem(): ListableStagingSite
142 {
143 $listable = new ListableStagingSite();
144 $listable->cloneId = $this->cloneId;
145 $listable->cloneName = $this->cloneName;
146 $listable->siteName = $this->getSiteName();
147 $listable->path = $this->path;
148 $listable->url = $this->url;
149 $listable->isNetworkClone = $this->networkClone;
150 $listable->directoryName = $this->directoryName;
151 $listable->status = $this->status;
152 $listable->databaseName = $this->getDatabaseName();
153 $listable->databasePrefix = $this->getUsedPrefix();
154 $listable->modifiedAt = empty($this->datetime) ? 0 : get_date_from_gmt(date("Y-m-d H:i:s", $this->datetime), "D, d M Y H:i:s T");
155 $listable->createdBy = $this->getOwnerName();
156
157 return $listable;
158 }
159
160 public function getCloneId(): string
161 {
162 return $this->cloneId;
163 }
164
165
166
167
168
169 public function setCloneId($cloneId)
170 {
171 $this->cloneId = (string)$cloneId;
172 }
173
174 public function getCloneName(): string
175 {
176 return $this->cloneName;
177 }
178
179
180
181
182
183 public function setCloneName(string $cloneName)
184 {
185 $this->cloneName = $cloneName;
186 }
187
188 public function getDirectoryName(): string
189 {
190 return $this->directoryName;
191 }
192
193
194
195
196
197 public function setDirectoryName(string $directoryName)
198 {
199 $this->directoryName = $directoryName;
200 }
201
202 public function getPath(): string
203 {
204 return $this->path;
205 }
206
207
208
209
210
211 public function setPath(string $path)
212 {
213 $this->path = $path;
214 }
215
216 public function getUrl(): string
217 {
218 return $this->url;
219 }
220
221
222
223
224
225 public function setUrl(string $url)
226 {
227 $this->url = $url;
228 }
229
230 public function getNumber(): int
231 {
232 return $this->number;
233 }
234
235
236
237
238
239 public function setNumber(int $number)
240 {
241 $this->number = $number;
242 }
243
244 public function getVersion(): string
245 {
246 return $this->version;
247 }
248
249
250
251
252
253 public function setVersion(string $version)
254 {
255 $this->version = $version;
256 }
257
258 public function getStatus(): string
259 {
260 return $this->status;
261 }
262
263
264
265
266
267 public function setStatus(string $status)
268 {
269 $this->status = $status;
270 }
271
272 public function getPrefix(): string
273 {
274 return $this->prefix;
275 }
276
277
278
279
280
281 public function setPrefix(string $prefix)
282 {
283 $this->prefix = $prefix;
284 }
285
286 public function getDatetime(): int
287 {
288 return $this->datetime;
289 }
290
291
292
293
294
295 public function setDatetime(int $datetime)
296 {
297 $this->datetime = $datetime;
298 }
299
300 public function getDatabaseUser(): string
301 {
302 return $this->databaseUser;
303 }
304
305
306
307
308
309 public function setDatabaseUser(string $databaseUser)
310 {
311 $this->databaseUser = $databaseUser;
312 }
313
314 public function getDatabasePassword(): string
315 {
316 return $this->databasePassword;
317 }
318
319
320
321
322
323 public function setDatabasePassword(string $databasePassword)
324 {
325 $this->databasePassword = $databasePassword;
326 }
327
328 public function getDatabaseDatabase(): string
329 {
330 return $this->databaseDatabase;
331 }
332
333
334
335
336
337 public function setDatabaseDatabase(string $databaseDatabase)
338 {
339 $this->databaseDatabase = $databaseDatabase;
340 }
341
342 public function getDatabaseServer(): string
343 {
344 return $this->databaseServer;
345 }
346
347
348
349
350
351 public function setDatabaseServer(string $databaseServer)
352 {
353 $this->databaseServer = $databaseServer;
354 }
355
356 public function getDatabasePrefix(): string
357 {
358 if (empty($this->databasePrefix)) {
359 return $this->prefix;
360 }
361
362 return $this->databasePrefix;
363 }
364
365
366
367
368
369 public function setDatabasePrefix(string $databasePrefix)
370 {
371 $this->databasePrefix = $databasePrefix;
372 }
373
374 public function getDatabaseSsl(): bool
375 {
376 return $this->databaseSsl;
377 }
378
379
380
381
382
383 public function setDatabaseSsl(bool $databaseSsl)
384 {
385 $this->databaseSsl = $databaseSsl;
386 }
387
388 public function getIsEmailsAllowed(): bool
389 {
390 return $this->isEmailsAllowed;
391 }
392
393
394
395
396
397 public function setIsEmailsAllowed(bool $isEmailsAllowed)
398 {
399 $this->isEmailsAllowed = $isEmailsAllowed;
400 }
401
402 public function getUploadsSymlinked(): bool
403 {
404 return $this->uploadsSymlinked;
405 }
406
407
408
409
410
411 public function setUploadsSymlinked(bool $uploadsSymlinked)
412 {
413 $this->uploadsSymlinked = $uploadsSymlinked;
414 }
415
416 public function getIncludedTables(): array
417 {
418 return $this->includedTables;
419 }
420
421
422
423
424
425 public function setIncludedTables(array $includedTables)
426 {
427 $this->includedTables = $includedTables;
428 }
429
430 public function getExcludeSizeRules(): array
431 {
432 return $this->excludeSizeRules;
433 }
434
435
436
437
438
439 public function setExcludeSizeRules(array $excludeSizeRules)
440 {
441 $this->excludeSizeRules = $excludeSizeRules;
442 }
443
444 public function getExcludeGlobRules(): array
445 {
446 return $this->excludeGlobRules;
447 }
448
449
450
451
452
453 public function setExcludeGlobRules(array $excludeGlobRules)
454 {
455 $this->excludeGlobRules = $excludeGlobRules;
456 }
457
458 public function getExcludedDirectories(): array
459 {
460 return $this->excludedDirectories;
461 }
462
463
464
465
466
467 public function setExcludedDirectories(array $excludedDirectories)
468 {
469 $this->excludedDirectories = $excludedDirectories;
470 }
471
472 public function getExtraDirectories(): array
473 {
474 return $this->extraDirectories;
475 }
476
477
478
479
480
481 public function setExtraDirectories(array $extraDirectories)
482 {
483 $this->extraDirectories = $extraDirectories;
484 }
485
486 public function getNetworkClone(): bool
487 {
488 return $this->networkClone;
489 }
490
491
492
493
494
495 public function setNetworkClone(bool $networkClone)
496 {
497 $this->networkClone = $networkClone;
498 }
499
500 public function getSourceBlogId(): int
501 {
502 return $this->sourceBlogId;
503 }
504
505
506
507
508
509 public function setSourceBlogId(int $sourceBlogId)
510 {
511 $this->sourceBlogId = $sourceBlogId;
512 }
513
514 public function getIsCronEnabled(): bool
515 {
516 return $this->isCronEnabled;
517 }
518
519
520
521
522
523 public function setIsCronEnabled(bool $isCronEnabled)
524 {
525 $this->isCronEnabled = $isCronEnabled;
526 }
527
528 public function getIsWooSchedulerEnabled(): bool
529 {
530 return $this->isWooSchedulerEnabled;
531 }
532
533
534
535
536
537 public function setIsWooSchedulerEnabled(bool $isWooSchedulerEnabled)
538 {
539 $this->isWooSchedulerEnabled = $isWooSchedulerEnabled;
540 }
541
542 public function getIsEmailsReminderEnabled(): bool
543 {
544 return $this->isEmailsReminderEnabled;
545 }
546
547
548
549
550
551 public function setIsEmailsReminderEnabled(bool $isEmailsReminderEnabled)
552 {
553 $this->isEmailsReminderEnabled = $isEmailsReminderEnabled;
554 }
555
556 public function getOwnerId(): int
557 {
558 return $this->ownerId;
559 }
560
561
562
563
564
565 public function setOwnerId(int $ownerId)
566 {
567 $this->ownerId = $ownerId;
568 }
569
570 public function getUseNewAdminAccount(): bool
571 {
572 return $this->useNewAdminAccount;
573 }
574
575
576
577
578
579 public function setUseNewAdminAccount(bool $useNewAdminAccount)
580 {
581 $this->useNewAdminAccount = $useNewAdminAccount;
582 }
583
584 public function getAdminEmail(): string
585 {
586 return $this->adminEmail;
587 }
588
589
590
591
592
593 public function setAdminEmail(string $adminEmail)
594 {
595 $this->adminEmail = $adminEmail;
596 }
597
598 public function getAdminPassword(): string
599 {
600 return $this->adminPassword;
601 }
602
603
604
605
606
607 public function setAdminPassword(string $adminPassword)
608 {
609 $this->adminPassword = $adminPassword;
610 }
611
612 public function getExcludedDirs(): array
613 {
614 return $this->excludedDirs;
615 }
616
617
618
619
620
621 public function setExcludedDirs(array $excludedDirs)
622 {
623 $this->excludedDirs = $excludedDirs;
624 }
625
626
627
628
629 public function getTablePushSelection()
630 {
631 return $this->tablePushSelection;
632 }
633
634
635
636
637
638 public function setTablePushSelection($tablePushSelection)
639 {
640 $this->tablePushSelection = $tablePushSelection;
641 }
642
643 public function getSiteName(): string
644 {
645 return empty($this->cloneName) ? $this->directoryName : $this->cloneName;
646 }
647
648 public function getIsCustomDatabaseConnection(): bool
649 {
650 return !empty($this->databaseDatabase) && !empty($this->databaseUser);
651 }
652
653 public function getIsExternalDatabase(): bool
654 {
655 return $this->getIsCustomDatabaseConnection()
656 && ($this->getDatabaseName() !== DB_NAME
657 || $this->getDatabaseServer() !== DB_HOST);
658 }
659
660 public function getOwnerName(): string
661 {
662 if (empty($this->ownerId)) {
663 return 'N/A';
664 }
665
666 $owner = get_userdata($this->ownerId);
667 if (empty($owner)) {
668 return 'N/A';
669 }
670
671 return isset($owner->user_login) ? $owner->user_login : 'N/A';
672 }
673
674
675
676
677
678
679
680 public function getDatabaseName(): string
681 {
682 return empty($this->databaseDatabase) ? DB_NAME : $this->databaseDatabase;
683 }
684
685
686
687
688
689
690
691 public function getUsedPrefix(): string
692 {
693 return $this->getIsExternalDatabase() ? $this->getDatabasePrefix() : $this->getPrefix();
694 }
695
696
697
698
699
700 public function setIsAutoUpdatePlugins(bool $isAutoUpdatePlugins)
701 {
702 $this->isAutoUpdatePlugins = $isAutoUpdatePlugins;
703 }
704
705
706
707
708 public function getIsAutoUpdatePlugins(): bool
709 {
710 return $this->isAutoUpdatePlugins;
711 }
712
713 public function getIsUploadsSymlink(): bool
714 {
715 $uploadsDirectory = $this->getPath() . '/wp-content/uploads';
716
717 return is_link($uploadsDirectory);
718 }
719
720
721
722
723
724
725 public function setIsUploadsSymlink(bool $isUploadsSymlink)
726 {
727 $this->uploadsSymlinked = $isUploadsSymlink;
728 }
729
730
731
732
733
734 public function isFromSubsite(): bool
735 {
736 return $this->sourceBlogId > 1;
737 }
738 }
739