PluginProbe ʕ •ᴥ•ʔ
Hostinger Reach – AI-Powered Email Marketing for WordPress / 1.6.0
Hostinger Reach – AI-Powered Email Marketing for WordPress v1.6.0
1.6.0 1.5.9 1.5.8 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 1.5.2 1.5.1 1.5.0 1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 trunk 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6
hostinger-reach / src / Dto / PluginData.php
hostinger-reach / src / Dto Last commit date
Cart.php 8 months ago CartItem.php 8 months ago PluginData.php 7 months ago ReachContact.php 7 months ago Totals.php 8 months ago
PluginData.php
221 lines
1 <?php
2
3 namespace Hostinger\Reach\Dto;
4
5 use Hostinger\Reach\Functions;
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 die;
9 }
10
11 class PluginData {
12
13 /**
14 * Unique integration/plugin identifier (slug).
15 *
16 * @var string
17 */
18 private string $id;
19
20 /**
21 * Integration type (forms or ecommerce).
22 * Default forms
23 *
24 * @var string
25 */
26 private string $type;
27
28
29 /**
30 * Plugin folder name.
31 *
32 * @var string
33 */
34 private string $folder;
35
36 /**
37 * Main plugin file name.
38 *
39 * @var string
40 */
41 private string $file;
42
43 /**
44 * Admin URL to the plugin settings or dashboard.
45 *
46 * @var string
47 */
48 private string $admin_url;
49
50 /**
51 * URL to add or create a new form within the plugin.
52 *
53 * @var string
54 */
55 private string $add_form_url;
56
57 /**
58 * URL to edit an existing form within the plugin.
59 *
60 * @var string
61 */
62 private string $edit_url;
63
64 /**
65 * General plugin page URL.
66 *
67 * @var string
68 */
69 private string $url;
70
71 /**
72 * URL to download or install the plugin.
73 *
74 * @var string
75 */
76 private string $download_url;
77
78 /**
79 * Human-readable plugin title.
80 *
81 * @var string
82 */
83 private string $title;
84
85 /**
86 * Absolute URL to the plugin icon.
87 *
88 * @var string
89 */
90 private string $icon;
91
92 /**
93 * Whether the "view form" action should be hidden.
94 *
95 * @var bool
96 */
97 private bool $is_view_form_hidden;
98
99 /**
100 * Whether the "edit form" action should be hidden.
101 *
102 * @var bool
103 */
104 private bool $is_edit_form_hidden;
105
106 /**
107 * Whether the UI can toggle between forms.
108 *
109 * @var bool
110 */
111 private bool $can_toggle_forms;
112
113 /**
114 * Whether the integration is active.
115 * @var bool
116 */
117 private bool $is_active;
118
119 /**
120 * Whether the Import feature is enabled.
121 * @var bool
122 */
123 private bool $import_enabled;
124
125 public function __construct(
126 string $id,
127 string $title,
128 string $folder = null,
129 string $file = null,
130 string $admin_url = '',
131 string $add_form_url = '',
132 string $edit_url = '',
133 string $url = '',
134 string $download_url = '',
135 string $icon = null,
136 bool $is_view_form_hidden = true,
137 bool $is_edit_form_hidden = false,
138 bool $can_toggle_forms = true,
139 string $type = 'forms',
140 bool $is_active = false,
141 bool $import_enabled = false,
142 ) {
143 $this->id = $id;
144 $this->type = $type;
145 $this->title = $title;
146 $this->folder = $folder ?? $this->id;
147 $this->file = $file ?? $this->id . '.php';
148 $this->admin_url = $admin_url;
149 $this->add_form_url = $add_form_url;
150 $this->edit_url = $edit_url;
151 $this->url = $url;
152 $this->download_url = $download_url;
153 $this->icon = $icon ?? Functions::get_frontend_url() . 'icons/' . $this->id . '.svg';
154 $this->is_view_form_hidden = $is_view_form_hidden;
155 $this->is_edit_form_hidden = $is_edit_form_hidden;
156 $this->can_toggle_forms = $can_toggle_forms;
157 $this->is_active = $is_active;
158 $this->import_enabled = $import_enabled;
159 }
160
161 public static function from_array( array $data = array() ): PluginData {
162 $id = $data['id'] ?? '';
163 $type = $data['type'] ?? 'forms';
164 $title = $data['title'] ?? '';
165 $folder = $data['folder'] ?? $id;
166 $file = $data['file'] ?? $id . '.php';
167 $admin_url = $data['admin_url'] ?? '';
168 $add_form_url = $data['add_form_url'] ?? '';
169 $edit_url = $data['edit_url'] ?? '';
170 $url = $data['url'] ?? '';
171 $download_url = $data['download_url'] ?? '';
172 $icon = $data['icon'] ?? Functions::get_frontend_url() . 'icons/' . $id . '.svg';
173 $is_view_form_hidden = $data['is_view_form_hidden'] ?? true;
174 $is_edit_form_hidden = $data['is_edit_form_hidden'] ?? false;
175 $can_toggle_forms = $data['can_toggle_forms'] ?? true;
176 $is_active = $data['is_active'] ?? false;
177 $import_enabled = $data['import_enabled'] ?? false;
178
179 return new self(
180 $id,
181 $title,
182 $folder,
183 $file,
184 $admin_url,
185 $add_form_url,
186 $edit_url,
187 $url,
188 $download_url,
189 $icon,
190 $is_view_form_hidden,
191 $is_edit_form_hidden,
192 $can_toggle_forms,
193 $type,
194 $is_active,
195 $import_enabled
196 );
197 }
198
199
200 public function to_array(): array {
201 return array(
202 'id' => $this->id,
203 'type' => $this->type,
204 'folder' => $this->folder,
205 'file' => $this->file,
206 'admin_url' => $this->admin_url,
207 'add_form_url' => $this->add_form_url,
208 'edit_url' => $this->edit_url,
209 'url' => $this->url,
210 'download_url' => $this->download_url,
211 'title' => $this->title,
212 'icon' => $this->icon,
213 'is_view_form_hidden' => $this->is_view_form_hidden,
214 'is_edit_form_hidden' => $this->is_edit_form_hidden,
215 'can_toggle_forms' => $this->can_toggle_forms,
216 'is_active' => $this->is_active,
217 'import_enabled' => $this->import_enabled,
218 );
219 }
220 }
221