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 / TemplateEngine / TemplateEngine.php
wp-staging / Framework / TemplateEngine Last commit date
TemplateEngine.php 1 day ago TemplateEngineException.php 1 day ago TemplateEngineInterface.php 1 year ago
TemplateEngine.php
96 lines
1 <?php
2
3 namespace WPStaging\Framework\TemplateEngine;
4
5 use DateTime;
6 use WPStaging\Core\WPStaging;
7 use WPStaging\Framework\Adapter\DateTimeAdapter;
8 use WPStaging\Framework\Assets\Assets;
9
10 class TemplateEngine implements TemplateEngineInterface
11 {
12
13
14
15
16 const HOOK_RENDER_PRO_TEMPLATES = 'wpstg.template.render_pro_templates';
17
18
19 const ACTION_AFTER_EXISTING_CLONES = 'wpstg.views.single_overview.after_existing_clones_actions';
20
21
22 const ACTION_MULTI_SITE_CLONE_OPTION = 'wpstg.views.ajax_clone.multi_site_clone_option';
23
24
25 const ACTION_BACKUP_TAB = 'wpstg.views.backup.tab_backup';
26
27
28 protected $views;
29
30
31 private $assets;
32
33 public function __construct()
34 {
35 $this->assets = WPStaging::make(Assets::class);
36 }
37
38
39
40
41
42
43
44 public function render(string $path, array $params = []): string
45 {
46 if (!isset($this->views)) {
47 $this->views = WPSTG_VIEWS_DIR;
48 }
49
50 $fullPath = WPSTG_VIEWS_DIR . $path;
51 if (!file_exists($fullPath)) {
52 throw new TemplateEngineException('Template not found: ' . $fullPath);
53 }
54
55 extract($params, EXTR_SKIP);
56 ob_start();
57
58
59 require $fullPath;
60 $result = ob_get_clean();
61
62 return (string)$result;
63 }
64
65
66
67
68 public function getAssets()
69 {
70 return $this->assets;
71 }
72
73
74
75
76
77 protected function getDateTimeFormat(): string
78 {
79 return (new DateTimeAdapter())->getDateTimeFormat();
80 }
81
82
83
84
85
86
87 protected function transformToWpFormat($dateTime = null): string
88 {
89 if (!$dateTime) {
90 return '';
91 }
92
93 return (new DateTimeAdapter())->transformToWpFormat($dateTime);
94 }
95 }
96