PluginProbe
ManageWP Worker / 4.9.29
ManageWP Worker v4.9.29
4.9.38 4.9.37 4.9.36 4.9.35 4.9.34 3.8.7 3.8.8 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.18 3.9.19 3.9.2 3.9.20 3.9.21 3.9.22 3.9.23 3.9.24 All 73 releases
worker / src / MWP / Worker / Brand.php

Brand.php in ManageWP Worker 4.9.29, at src/MWP/Worker/Brand.php

242 lines 5.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * This file is part of the ManageWP Worker plugin.
4 *
5 * (c) ManageWP LLC <contact@managewp.com>
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
9 */
10
11 class MWP_Worker_Brand
12 {
13 const OPTION_NAME = 'mwp_worker_brand';
14
15 private $context;
16
17 /**
18 * @var bool
19 */
20 private $active;
21
22 /**
23 * @var string|null
24 */
25 private $name;
26
27 /**
28 * @var string|null
29 */
30 private $description;
31
32 /**
33 * @var string|null
34 */
35 private $author;
36
37 /**
38 * @var string|null
39 */
40 private $authorUrl;
41
42 /**
43 * Hide the plugin from the plugin list.
44 *
45 * @var bool
46 */
47 private $hide = false;
48
49 /**
50 * Prevent the user from updating/installing plugins and themes within the site. Also disable the plugin and theme code editor.
51 *
52 * @var bool
53 */
54 private $disallowEdit = false;
55
56 /**
57 * Disable code editor only
58 *
59 * @var bool
60 */
61 private $disableCodeEditor = false;
62
63 /**
64 * One of the CONTACT_TYPE_* constants.
65 *
66 * @var int
67 */
68 private $contactType = 0;
69
70 /**
71 * Disable "Contact Support" modal.
72 */
73 const CONTACT_TYPE_NONE = 0;
74
75 /**
76 * Show both text ('textForClient') and the form that submits to the brand owner email address ('adminEmail').
77 */
78 const CONTACT_TYPE_TEXT_PLUS_FORM = 1;
79
80 /**
81 * Show only text ('textForClient').
82 */
83 const CONTACT_TYPE_TEXT = 2;
84
85 /**
86 * Text shown in the "Contact Support" dialog.
87 *
88 * @var string|null
89 */
90 private $textForClient;
91
92 /**
93 * Email address of the brand owner.
94 *
95 * @var string|null
96 */
97 private $adminEmail;
98
99 /**
100 * Whether or not the worker branding was sent from Orion.
101 *
102 * @var bool|null
103 */
104 private $fromOrion;
105
106 public function __construct(MWP_WordPress_Context $context)
107 {
108 $this->context = $context;
109 $brand = $context->optionGet(self::OPTION_NAME);
110
111 if (!is_array($brand)) {
112 return;
113 }
114
115 $this->name = empty($brand['name']) ? null : $brand['name'];
116 $this->description = empty($brand['desc']) ? null : $brand['desc'];
117 $this->author = empty($brand['author']) ? null : $brand['author'];
118 $this->authorUrl = empty($brand['author_url']) ? null : $brand['author_url'];
119 $this->hide = isset($brand['hide']) ? $brand['hide'] : $this->hide;
120 // "Dissalow" [sic] edit .
121 $this->disallowEdit = isset($brand['dissalow_edit']) ? $brand['dissalow_edit'] : $this->disallowEdit;
122 $this->textForClient = empty($brand['text_for_client']) ? null : $brand['text_for_client'];
123 $this->contactType = isset($brand['email_or_link']) ? (int)$brand['email_or_link'] : self::CONTACT_TYPE_NONE;
124 $this->adminEmail = empty($brand['admin_email']) ? null : $brand['admin_email'];
125 $this->fromOrion = empty($brand['from_orion']) ? false : $brand['from_orion'];
126 $this->disableCodeEditor = isset($brand['disable_code_editor']) ? $brand['disable_code_editor'] : $this->disableCodeEditor;
127
128 $this->active = isset($brand['active']) ? $brand['active'] : (bool) ($this->name || $this->description || $this->author || $this->authorUrl || $this->hide || $this->disallowEdit || $this->disableCodeEditor || $this->contactType);
129 }
130
131 public function isActive()
132 {
133 return $this->active;
134 }
135
136 /**
137 * @return null|string
138 */
139 public function getName()
140 {
141 return $this->name;
142 }
143
144 /**
145 * @return null|string
146 */
147 public function getDescription()
148 {
149 return $this->description;
150 }
151
152 /**
153 * @return null|string
154 */
155 public function getAuthor()
156 {
157 return $this->author;
158 }
159
160 /**
161 * @return null|string
162 */
163 public function getAuthorUrl()
164 {
165 return $this->authorUrl;
166 }
167
168 /**
169 * @return boolean
170 */
171 public function isHide()
172 {
173 return $this->hide;
174 }
175
176 /**
177 * @return boolean
178 */
179 public function isDisallowEdit()
180 {
181 return $this->disallowEdit;
182 }
183
184 /**
185 * @return boolean
186 */
187 public function isDisableCodeEditor()
188 {
189 return $this->disableCodeEditor;
190 }
191
192 /**
193 * @return int
194 */
195 public function getContactType()
196 {
197 return $this->contactType;
198 }
199
200 /**
201 * @return null|string
202 */
203 public function getTextForClient()
204 {
205 return $this->textForClient;
206 }
207
208 /**
209 * @return null|string
210 */
211 public function getAdminEmail()
212 {
213 return $this->adminEmail;
214 }
215
216 /**
217 * @return null|bool
218 */
219 public function getFromOrion()
220 {
221 return $this->fromOrion;
222 }
223
224 /**
225 * Active-record-style delete.
226 */
227 public function delete()
228 {
229 $this->context->optionDelete(self::OPTION_NAME);
230 }
231
232 /**
233 * Active-record-style update.
234 *
235 * @param array $brand
236 */
237 public function update(array $brand)
238 {
239 $this->context->optionSet(self::OPTION_NAME, $brand);
240 }
241 }
242