1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace EventEspresso\admin_pages\general_settings; |
4
|
|
|
|
5
|
|
|
use DomainException; |
6
|
|
|
use EE_Admin_File_Uploader_Input; |
7
|
|
|
use EE_Admin_Two_Column_Layout; |
8
|
|
|
use EE_Checkbox_Multi_Input; |
9
|
|
|
use EE_Core_Config; |
10
|
|
|
use EE_Country_Select_Input; |
11
|
|
|
use EE_Currency_Config; |
12
|
|
|
use EE_Error; |
13
|
|
|
use EE_Form_Section_HTML; |
14
|
|
|
use EE_Form_Section_Proper; |
15
|
|
|
use EE_License_Key_Display_Strategy; |
16
|
|
|
use EE_Network_Core_Config; |
17
|
|
|
use EE_Organization_Config; |
18
|
|
|
use EE_Registry; |
19
|
|
|
use EE_State_Select_Input; |
20
|
|
|
use EE_Text_Input; |
21
|
|
|
use EEH_HTML; |
22
|
|
|
use EEH_Template; |
23
|
|
|
use EventEspresso\core\domain\services\pue\Stats; |
24
|
|
|
use EventEspresso\core\exceptions\InvalidDataTypeException; |
25
|
|
|
use EventEspresso\core\exceptions\InvalidFormSubmissionException; |
26
|
|
|
use EventEspresso\core\exceptions\InvalidInterfaceException; |
27
|
|
|
use EventEspresso\core\libraries\form_sections\form_handlers\FormHandler; |
28
|
|
|
use EventEspresso\core\libraries\form_sections\strategies\filter\VsprintfFilter; |
29
|
|
|
use InvalidArgumentException; |
30
|
|
|
use LogicException; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* OrganizationSettings |
34
|
|
|
* A form handler for Organization Settings |
35
|
|
|
* |
36
|
|
|
* @package EventEspresso\admin_pages\general_settings |
37
|
|
|
* @author Darren Ethier |
38
|
|
|
* @since $VID:$ |
39
|
|
|
*/ |
40
|
|
|
class OrganizationSettings extends FormHandler |
41
|
|
|
{ |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var EE_Organization_Config |
45
|
|
|
*/ |
46
|
|
|
protected $organization_config; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @var EE_Core_Config |
50
|
|
|
*/ |
51
|
|
|
protected $core_config; |
52
|
|
|
|
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @var EE_Network_Core_Config |
56
|
|
|
*/ |
57
|
|
|
protected $network_core_config; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Form constructor. |
61
|
|
|
* |
62
|
|
|
* @param EE_Registry $registry |
63
|
|
|
* @param EE_Organization_Config $organization_config |
64
|
|
|
* @param EE_Core_Config $core_config |
65
|
|
|
* @param EE_Network_Core_Config $network_core_config |
66
|
|
|
* @throws InvalidArgumentException |
67
|
|
|
* @throws InvalidDataTypeException |
68
|
|
|
* @throws DomainException |
69
|
|
|
*/ |
70
|
|
|
public function __construct( |
71
|
|
|
EE_Registry $registry, |
72
|
|
|
EE_Organization_Config $organization_config, |
73
|
|
|
EE_Core_Config $core_config, |
74
|
|
|
EE_Network_Core_Config $network_core_config |
75
|
|
|
) { |
76
|
|
|
$this->organization_config = $organization_config; |
77
|
|
|
$this->core_config = $core_config; |
78
|
|
|
$this->network_core_config = $network_core_config; |
79
|
|
|
parent::__construct( |
80
|
|
|
esc_html__('Your Organization Settings', 'event_espresso'), |
81
|
|
|
esc_html__('Your Organization Settings', 'event_espresso'), |
82
|
|
|
'organization_settings', |
83
|
|
|
'', |
84
|
|
|
FormHandler::DO_NOT_SETUP_FORM, |
85
|
|
|
$registry |
86
|
|
|
); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
|
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* creates and returns the actual form |
93
|
|
|
* |
94
|
|
|
* @return EE_Form_Section_Proper |
95
|
|
|
* @throws EE_Error |
96
|
|
|
*/ |
97
|
|
|
public function generate() |
98
|
|
|
{ |
99
|
|
|
$form = new EE_Form_Section_Proper( |
100
|
|
|
array( |
101
|
|
|
'name' => 'organization_settings', |
102
|
|
|
'html_id' => 'organization_settings', |
103
|
|
|
'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
104
|
|
|
'subsections' => array( |
105
|
|
|
'site_license_key_hdr' => new EE_Form_Section_HTML( |
106
|
|
|
EEH_HTML::h2( |
107
|
|
|
esc_html__('Your Event Espresso License Key', 'event_espresso') |
108
|
|
|
. ' ' |
109
|
|
|
. EEH_HTML::span( |
110
|
|
|
EEH_Template::get_help_tab_link('site_license_key_info'), |
111
|
|
|
'help_tour_activation' |
112
|
|
|
), |
113
|
|
|
'', |
114
|
|
|
'site-license-key-hdr' |
115
|
|
|
) |
116
|
|
|
), |
117
|
|
|
'site_license_key' => $this->getSiteLicenseKeyField(), |
118
|
|
|
'contact_information_hdr' => new EE_Form_Section_HTML( |
119
|
|
|
EEH_HTML::h2( |
120
|
|
|
esc_html__('Contact Information', 'event_espresso') |
121
|
|
|
. ' ' |
122
|
|
|
. EEH_HTML::span(EEH_Template::get_help_tab_link('contact_info_info')), |
123
|
|
|
'', |
124
|
|
|
'contact-information-hdr' |
125
|
|
|
) |
126
|
|
|
), |
127
|
|
|
'organization_name' => new EE_Text_Input( |
128
|
|
|
array( |
129
|
|
|
'html_name' => 'organization_name', |
130
|
|
|
'html_label_text' => esc_html__('Organization Name', 'event_espresso'), |
131
|
|
|
'html_help_text' => esc_html__( |
132
|
|
|
'Displayed on all emails and invoices.', |
133
|
|
|
'event_espresso' |
134
|
|
|
), |
135
|
|
|
'default' => $this->organization_config->get_pretty('name'), |
136
|
|
|
'required' => false, |
137
|
|
|
) |
138
|
|
|
), |
139
|
|
|
'organization_address_1' => new EE_Text_Input( |
140
|
|
|
array( |
141
|
|
|
'html_name' => 'organization_address_1', |
142
|
|
|
'html_label_text' => esc_html__('Street Address', 'event_espresso'), |
143
|
|
|
'default' => $this->organization_config->get_pretty('address_1'), |
144
|
|
|
'required' => false, |
145
|
|
|
) |
146
|
|
|
), |
147
|
|
|
'organization_address_2' => new EE_Text_Input( |
148
|
|
|
array( |
149
|
|
|
'html_name' => 'organization_address_2', |
150
|
|
|
'html_label_text' => esc_html__('Street Address 2', 'event_espresso'), |
151
|
|
|
'default' => $this->organization_config->get_pretty('address_2'), |
152
|
|
|
'required' => false, |
153
|
|
|
) |
154
|
|
|
), |
155
|
|
|
'organization_city' => new EE_Text_Input( |
156
|
|
|
array( |
157
|
|
|
'html_name' => 'organization_city', |
158
|
|
|
'html_label_text' => esc_html__('City', 'event_espresso'), |
159
|
|
|
'default' => $this->organization_config->get_pretty('city'), |
160
|
|
|
'required' => false, |
161
|
|
|
) |
162
|
|
|
), |
163
|
|
|
'organization_state' => new EE_State_Select_Input( |
164
|
|
|
null, |
165
|
|
|
array( |
166
|
|
|
'html_name' => 'organization_state', |
167
|
|
|
'html_label_text' => esc_html__('State/Province', 'event_espresso'), |
168
|
|
|
'default' => $this->organization_config->STA_ID, |
169
|
|
|
'required' => false, |
170
|
|
|
) |
171
|
|
|
), |
172
|
|
|
'organization_country' => new EE_Country_Select_Input( |
173
|
|
|
null, |
174
|
|
|
array( |
175
|
|
|
'html_name' => 'organization_country', |
176
|
|
|
'html_label_text' => esc_html__('Country', 'event_espresso'), |
177
|
|
|
'default' => $this->organization_config->CNT_ISO, |
178
|
|
|
'required' => false, |
179
|
|
|
) |
180
|
|
|
), |
181
|
|
|
'organization_zip' => new EE_Text_Input( |
182
|
|
|
array( |
183
|
|
|
'html_name' => 'organization_zip', |
184
|
|
|
'html_label_text' => esc_html__('Zip/Postal Code', 'event_espresso'), |
185
|
|
|
'default' => $this->organization_config->get_pretty('zip'), |
186
|
|
|
'required' => false, |
187
|
|
|
) |
188
|
|
|
), |
189
|
|
|
'organization_email' => new EE_Text_Input( |
190
|
|
|
array( |
191
|
|
|
'html_name' => 'organization_email', |
192
|
|
|
'html_label_text' => esc_html__('Primary Contact Email', 'event_espresso'), |
193
|
|
|
'html_help_text' => sprintf( |
194
|
|
|
esc_html__( |
195
|
|
|
'This is where notifications go to when you use the %1$s and %2$s shortcodes in the message templates.', |
196
|
|
|
'event_espresso' |
197
|
|
|
), |
198
|
|
|
'<code>[CO_FORMATTED_EMAIL]</code>', |
199
|
|
|
'<code>[CO_EMAIL]</code>' |
200
|
|
|
), |
201
|
|
|
'default' => $this->organization_config->get_pretty('email'), |
202
|
|
|
'required' => false, |
203
|
|
|
) |
204
|
|
|
), |
205
|
|
|
'organization_phone' => new EE_Text_Input( |
206
|
|
|
array( |
207
|
|
|
'html_name' => 'organization_phone', |
208
|
|
|
'html_label_text' => esc_html__('Phone Number', 'event_espresso'), |
209
|
|
|
'html_help_text' => esc_html__( |
210
|
|
|
'The phone number for your organization.', |
211
|
|
|
'event_espresso' |
212
|
|
|
), |
213
|
|
|
'default' => $this->organization_config->get_pretty('phone'), |
214
|
|
|
'required' => false, |
215
|
|
|
) |
216
|
|
|
), |
217
|
|
|
'organization_vat' => new EE_Text_Input( |
218
|
|
|
array( |
219
|
|
|
'html_name' => 'organization_vat', |
220
|
|
|
'html_label_text' => esc_html__('VAT/Tax Number', 'event_espresso'), |
221
|
|
|
'html_help_text' => esc_html__( |
222
|
|
|
'The VAT/Tax Number may be displayed on invoices and receipts.', |
223
|
|
|
'event_espresso' |
224
|
|
|
), |
225
|
|
|
'default' => $this->organization_config->get_pretty('vat'), |
226
|
|
|
'required' => false, |
227
|
|
|
) |
228
|
|
|
), |
229
|
|
|
'company_logo_hdr' => new EE_Form_Section_HTML( |
230
|
|
|
EEH_HTML::h2( |
231
|
|
|
esc_html__('Company Logo', 'event_espresso') |
232
|
|
|
. ' ' |
233
|
|
|
. EEH_HTML::span(EEH_Template::get_help_tab_link('organization_logo_info')), |
234
|
|
|
'', |
235
|
|
|
'company-logo-hdr' |
236
|
|
|
) |
237
|
|
|
), |
238
|
|
|
'organization_logo_url' => new EE_Admin_File_Uploader_Input( |
239
|
|
|
array( |
240
|
|
|
'html_name' => 'organization_logo_url', |
241
|
|
|
'html_label_text' => esc_html__('Upload New Logo', 'event_espresso'), |
242
|
|
|
'html_help_text' => esc_html__( |
243
|
|
|
'Your logo will be used on custom invoices, tickets, certificates, and payment templates.', |
244
|
|
|
'event_espresso' |
245
|
|
|
), |
246
|
|
|
'default' => $this->organization_config->get_pretty('logo_url'), |
247
|
|
|
'required' => false, |
248
|
|
|
) |
249
|
|
|
), |
250
|
|
|
'social_links_hdr' => new EE_Form_Section_HTML( |
251
|
|
|
EEH_HTML::h2( |
252
|
|
|
esc_html__('Social Links', 'event_espresso') |
253
|
|
|
. ' ' |
254
|
|
|
. EEH_HTML::span(EEH_Template::get_help_tab_link('social_links_info')) |
255
|
|
|
. EEH_HTML::br() |
256
|
|
|
. EEH_HTML::p( |
257
|
|
|
esc_html__( |
258
|
|
|
'Enter any links to social accounts for your organization here', |
259
|
|
|
'event_espresso' |
260
|
|
|
), |
261
|
|
|
'', |
262
|
|
|
'description' |
263
|
|
|
), |
264
|
|
|
'', |
265
|
|
|
'social-links-hdr' |
266
|
|
|
) |
267
|
|
|
), |
268
|
|
|
'organization_facebook' => new EE_Text_Input( |
269
|
|
|
array( |
270
|
|
|
'html_name' => 'organization_facebook', |
271
|
|
|
'html_label_text' => esc_html__('Facebook', 'event_espresso'), |
272
|
|
|
'other_html_attributes' => ' placeholder="facebook.com/profile.name"', |
273
|
|
|
'default' => $this->organization_config->get_pretty('facebook'), |
274
|
|
|
'required' => false, |
275
|
|
|
) |
276
|
|
|
), |
277
|
|
|
'organization_twitter' => new EE_Text_Input( |
278
|
|
|
array( |
279
|
|
|
'html_name' => 'organization_twitter', |
280
|
|
|
'html_label_text' => esc_html__('Twitter', 'event_espresso'), |
281
|
|
|
'other_html_attributes' => ' placeholder="twitter.com/twitterhandle"', |
282
|
|
|
'default' => $this->organization_config->get_pretty('twitter'), |
283
|
|
|
'required' => false, |
284
|
|
|
) |
285
|
|
|
), |
286
|
|
|
'organization_linkedin' => new EE_Text_Input( |
287
|
|
|
array( |
288
|
|
|
'html_name' => 'organization_linkedin', |
289
|
|
|
'html_label_text' => esc_html__('LinkedIn', 'event_espresso'), |
290
|
|
|
'other_html_attributes' => ' placeholder="linkedin.com/in/profilename"', |
291
|
|
|
'default' => $this->organization_config->get_pretty('linkedin'), |
292
|
|
|
'required' => false, |
293
|
|
|
) |
294
|
|
|
), |
295
|
|
|
'organization_pinterest' => new EE_Text_Input( |
296
|
|
|
array( |
297
|
|
|
'html_name' => 'organization_pinterest', |
298
|
|
|
'html_label_text' => esc_html__('Pinterest', 'event_espresso'), |
299
|
|
|
'other_html_attributes' => ' placeholder="pinterest.com/profilename"', |
300
|
|
|
'default' => $this->organization_config->get_pretty('pinterest'), |
301
|
|
|
'required' => false, |
302
|
|
|
) |
303
|
|
|
), |
304
|
|
|
'organization_google' => new EE_Text_Input( |
305
|
|
|
array( |
306
|
|
|
'html_name' => 'organization_google', |
307
|
|
|
'html_label_text' => esc_html__('Google+', 'event_espresso'), |
308
|
|
|
'other_html_attributes' => ' placeholder="google.com/+profilename"', |
309
|
|
|
'default' => $this->organization_config->get_pretty('google'), |
310
|
|
|
'required' => false, |
311
|
|
|
) |
312
|
|
|
), |
313
|
|
|
'organization_instagram' => new EE_Text_Input( |
314
|
|
|
array( |
315
|
|
|
'html_name' => 'organization_instagram', |
316
|
|
|
'html_label_text' => esc_html__('Instagram', 'event_espresso'), |
317
|
|
|
'other_html_attributes' => ' placeholder="instagram.com/handle"', |
318
|
|
|
'default' => $this->organization_config->get_pretty('instagram'), |
319
|
|
|
'required' => false, |
320
|
|
|
) |
321
|
|
|
), |
322
|
|
|
), |
323
|
|
|
) |
324
|
|
|
); |
325
|
|
|
if (is_main_site()) { |
326
|
|
|
$form->add_subsections( |
327
|
|
|
array( |
328
|
|
|
'uxip_optin_hdr' => new EE_Form_Section_HTML( |
329
|
|
|
$this->uxipOptinText() |
330
|
|
|
), |
331
|
|
|
'ueip_optin' => new EE_Checkbox_Multi_Input( |
332
|
|
|
array( |
333
|
|
|
true => __('Yes! I want to help improve Event Espresso!', 'event_espresso') |
334
|
|
|
), |
335
|
|
|
array( |
336
|
|
|
'html_name' => EE_Core_Config::OPTION_NAME_UXIP, |
337
|
|
|
'html_label_text' => esc_html__( |
338
|
|
|
'UXIP Opt In?', |
339
|
|
|
'event_espresso' |
340
|
|
|
), |
341
|
|
|
'default' => isset($this->core_config->ee_ueip_optin) |
342
|
|
|
? filter_var($this->core_config->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN) |
343
|
|
|
: false, |
344
|
|
|
'required' => false, |
345
|
|
|
) |
346
|
|
|
), |
347
|
|
|
), |
348
|
|
|
'organization_instagram', |
349
|
|
|
false |
350
|
|
|
); |
351
|
|
|
} |
352
|
|
|
return $form; |
353
|
|
|
} |
354
|
|
|
|
355
|
|
|
|
356
|
|
|
/** |
357
|
|
|
* takes the generated form and displays it along with ony other non-form HTML that may be required |
358
|
|
|
* returns a string of HTML that can be directly echoed in a template |
359
|
|
|
* |
360
|
|
|
* @return string |
361
|
|
|
* @throws EE_Error |
362
|
|
|
* @throws InvalidArgumentException |
363
|
|
|
* @throws InvalidDataTypeException |
364
|
|
|
* @throws InvalidInterfaceException |
365
|
|
|
* @throws LogicException |
366
|
|
|
*/ |
367
|
|
|
public function display() |
368
|
|
|
{ |
369
|
|
|
$this->form()->enqueue_js(); |
370
|
|
|
return parent::display(); |
371
|
|
|
} |
372
|
|
|
|
373
|
|
|
|
374
|
|
|
/** |
375
|
|
|
* handles processing the form submission |
376
|
|
|
* returns true or false depending on whether the form was processed successfully or not |
377
|
|
|
* |
378
|
|
|
* @param array $form_data |
379
|
|
|
* @return bool |
380
|
|
|
* @throws InvalidFormSubmissionException |
381
|
|
|
* @throws EE_Error |
382
|
|
|
* @throws LogicException |
383
|
|
|
* @throws InvalidArgumentException |
384
|
|
|
* @throws InvalidDataTypeException |
385
|
|
|
*/ |
386
|
|
|
public function process($form_data = array()) |
387
|
|
|
{ |
388
|
|
|
// process form |
389
|
|
|
$valid_data = (array) parent::process($form_data); |
390
|
|
|
if (empty($valid_data)) { |
391
|
|
|
return false; |
392
|
|
|
} |
393
|
|
|
|
394
|
|
|
if (is_main_site()) { |
395
|
|
|
$this->network_core_config->site_license_key = isset($form_data['site_license_key']) |
396
|
|
|
? sanitize_text_field($form_data['site_license_key']) |
397
|
|
|
: $this->network_core_config->site_license_key; |
398
|
|
|
} |
399
|
|
|
$this->organization_config->name = isset($form_data['organization_name']) |
400
|
|
|
? sanitize_text_field($form_data['organization_name']) |
401
|
|
|
: $this->organization_config->name; |
402
|
|
|
$this->organization_config->address_1 = isset($form_data['organization_address_1']) |
403
|
|
|
? sanitize_text_field($form_data['organization_address_1']) |
404
|
|
|
: $this->organization_config->address_1; |
405
|
|
|
$this->organization_config->address_2 = isset($form_data['organization_address_2']) |
406
|
|
|
? sanitize_text_field($form_data['organization_address_2']) |
407
|
|
|
: $this->organization_config->address_2; |
408
|
|
|
$this->organization_config->city = isset($form_data['organization_city']) |
409
|
|
|
? sanitize_text_field($form_data['organization_city']) |
410
|
|
|
: $this->organization_config->city; |
411
|
|
|
$this->organization_config->STA_ID = isset($form_data['organization_state']) |
412
|
|
|
? absint($form_data['organization_state']) |
413
|
|
|
: $this->organization_config->STA_ID; |
414
|
|
|
$this->organization_config->CNT_ISO = isset($form_data['organization_country']) |
415
|
|
|
? sanitize_text_field($form_data['organization_country']) |
416
|
|
|
: $this->organization_config->CNT_ISO; |
417
|
|
|
$this->organization_config->zip = isset($form_data['organization_zip']) |
418
|
|
|
? sanitize_text_field($form_data['organization_zip']) |
419
|
|
|
: $this->organization_config->zip; |
420
|
|
|
$this->organization_config->email = isset($form_data['organization_email']) |
421
|
|
|
? sanitize_email($form_data['organization_email']) |
422
|
|
|
: $this->organization_config->email; |
423
|
|
|
$this->organization_config->vat = isset($form_data['organization_vat']) |
424
|
|
|
? sanitize_text_field($form_data['organization_vat']) |
425
|
|
|
: $this->organization_config->vat; |
426
|
|
|
$this->organization_config->phone = isset($form_data['organization_phone']) |
427
|
|
|
? sanitize_text_field($form_data['organization_phone']) |
428
|
|
|
: $this->organization_config->phone; |
429
|
|
|
$this->organization_config->logo_url = isset($form_data['organization_logo_url']) |
430
|
|
|
? esc_url_raw($form_data['organization_logo_url']) |
431
|
|
|
: $this->organization_config->logo_url; |
432
|
|
|
$this->organization_config->facebook = isset($form_data['organization_facebook']) |
433
|
|
|
? esc_url_raw($form_data['organization_facebook']) |
434
|
|
|
: $this->organization_config->facebook; |
435
|
|
|
$this->organization_config->twitter = isset($form_data['organization_twitter']) |
436
|
|
|
? esc_url_raw($form_data['organization_twitter']) |
437
|
|
|
: $this->organization_config->twitter; |
438
|
|
|
$this->organization_config->linkedin = isset($form_data['organization_linkedin']) |
439
|
|
|
? esc_url_raw($form_data['organization_linkedin']) |
440
|
|
|
: $this->organization_config->linkedin; |
441
|
|
|
$this->organization_config->pinterest = isset($form_data['organization_pinterest']) |
442
|
|
|
? esc_url_raw($form_data['organization_pinterest']) |
443
|
|
|
: $this->organization_config->pinterest; |
444
|
|
|
$this->organization_config->google = isset($form_data['organization_google']) |
445
|
|
|
? esc_url_raw($form_data['organization_google']) |
446
|
|
|
: $this->organization_config->google; |
447
|
|
|
$this->organization_config->instagram = isset($form_data['organization_instagram']) |
448
|
|
|
? esc_url_raw($form_data['organization_instagram']) |
449
|
|
|
: $this->organization_config->instagram; |
450
|
|
|
$this->core_config->ee_ueip_optin = isset($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0]) |
451
|
|
|
? filter_var($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0], FILTER_VALIDATE_BOOLEAN) |
452
|
|
|
: false; |
453
|
|
|
$this->core_config->ee_ueip_has_notified = true; |
454
|
|
|
|
455
|
|
|
$this->registry->CFG->currency = new EE_Currency_Config( |
456
|
|
|
$this->organization_config->CNT_ISO |
457
|
|
|
); |
458
|
|
|
return true; |
459
|
|
|
} |
460
|
|
|
|
461
|
|
|
|
462
|
|
|
/** |
463
|
|
|
* @return string |
464
|
|
|
*/ |
465
|
|
|
private function uxipOptinText() |
466
|
|
|
{ |
467
|
|
|
ob_start(); |
468
|
|
|
Stats::optinText(false); |
469
|
|
|
return ob_get_clean(); |
470
|
|
|
} |
471
|
|
|
|
472
|
|
|
|
473
|
|
|
/** |
474
|
|
|
* Return whether the site license key has been verified or not. |
475
|
|
|
* @return bool |
476
|
|
|
*/ |
477
|
|
|
private function licenseKeyVerified() |
478
|
|
|
{ |
479
|
|
|
if (empty($this->network_core_config->site_license_key)) { |
480
|
|
|
return false; |
481
|
|
|
} |
482
|
|
|
$ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME); |
483
|
|
|
$verify_fail = get_option($ver_option_key, false); |
484
|
|
|
return $verify_fail === false |
485
|
|
|
|| (! empty($this->network_core_config->site_license_key) |
486
|
|
|
&& $verify_fail === false |
487
|
|
|
); |
488
|
|
|
} |
489
|
|
|
|
490
|
|
|
|
491
|
|
|
/** |
492
|
|
|
* @return EE_Text_Input |
493
|
|
|
*/ |
494
|
|
|
private function getSiteLicenseKeyField() |
495
|
|
|
{ |
496
|
|
|
$text_input = new EE_Text_Input( |
497
|
|
|
array( |
498
|
|
|
'html_name' => 'site_license_key', |
499
|
|
|
'html_id' => 'site_license_key', |
500
|
|
|
'html_label_text' => esc_html__('Support License Key', 'event_espresso'), |
501
|
|
|
/** phpcs:disable WordPress.WP.I18n.UnorderedPlaceholdersText */ |
502
|
|
|
'html_help_text' => sprintf( |
503
|
|
|
esc_html__( |
504
|
|
|
'Adding a valid Support License Key will enable automatic update notifications and backend updates for Event Espresso Core and any installed add-ons. If this is a Development or Test site, %sDO NOT%s enter your Support License Key.', |
505
|
|
|
'event_espresso' |
506
|
|
|
), |
507
|
|
|
'<strong>', |
508
|
|
|
'</strong>' |
509
|
|
|
), |
510
|
|
|
/** phpcs:enable */ |
511
|
|
|
'default' => isset($this->network_core_config->site_license_key) |
512
|
|
|
? $this->network_core_config->site_license_key |
513
|
|
|
: '', |
514
|
|
|
'required' => false, |
515
|
|
|
'form_html_filter' => new VsprintfFilter( |
516
|
|
|
'%2$s %1$s', |
517
|
|
|
array($this->getValidationIndicator()) |
518
|
|
|
) |
519
|
|
|
) |
520
|
|
|
); |
521
|
|
|
return $text_input; |
522
|
|
|
} |
523
|
|
|
|
524
|
|
|
|
525
|
|
|
/** |
526
|
|
|
* @return string |
527
|
|
|
*/ |
528
|
|
|
private function getValidationIndicator() |
529
|
|
|
{ |
530
|
|
|
$verified_class = $this->licenseKeyVerified() ? 'ee-icon-color-ee-green' : 'ee-icon-color-ee-red'; |
531
|
|
|
return '<span class="dashicons dashicons-admin-network ' . $verified_class . ' ee-icon-size-20"></span>'; |
532
|
|
|
} |
533
|
|
|
} |
534
|
|
|
|