|
1
|
|
|
<?php |
|
2
|
|
|
namespace EventEspresso\core\domain\services\pue; |
|
3
|
|
|
|
|
4
|
|
|
use EE_Config; |
|
5
|
|
|
use EE_Core_Config; |
|
6
|
|
|
use EE_Network_Config; |
|
7
|
|
|
use const FILTER_VALIDATE_BOOLEAN; |
|
8
|
|
|
use const FILTER_VALIDATE_EMAIL; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Config |
|
12
|
|
|
* This contains the various configuration properties for PUE implementation. |
|
13
|
|
|
* |
|
14
|
|
|
* @package EventEspresso\core\domain\services\pue |
|
15
|
|
|
* @author Darren Ethier |
|
16
|
|
|
* @since $VID:$ |
|
17
|
|
|
*/ |
|
18
|
|
|
class Config |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* @var EE_Network_Config |
|
22
|
|
|
*/ |
|
23
|
|
|
private $network_config; |
|
24
|
|
|
|
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var EE_Config |
|
28
|
|
|
*/ |
|
29
|
|
|
private $ee_config; |
|
30
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
public function __construct(EE_Network_Config $network_config, EE_Config $ee_config) |
|
34
|
|
|
{ |
|
35
|
|
|
$this->network_config = $network_config; |
|
36
|
|
|
$this->ee_config = $ee_config; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Get the site license key for the site. |
|
42
|
|
|
*/ |
|
43
|
|
|
public function siteLicenseKey() |
|
44
|
|
|
{ |
|
45
|
|
|
return $this->network_config->core->site_license_key; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
|
|
49
|
|
|
|
|
50
|
|
|
public function i18nDomain() |
|
51
|
|
|
{ |
|
52
|
|
|
return 'event_espresso'; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
public function checkPeriod() |
|
58
|
|
|
{ |
|
59
|
|
|
return 24; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
|
|
63
|
|
|
|
|
64
|
|
|
public function optionKey() |
|
65
|
|
|
{ |
|
66
|
|
|
return 'site_license_key'; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
|
|
70
|
|
|
|
|
71
|
|
|
public function optionsPageSlug() |
|
72
|
|
|
{ |
|
73
|
|
|
return 'espresso_general_settings'; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
|
|
77
|
|
|
public function hostServerUrl() |
|
78
|
|
|
{ |
|
79
|
|
|
return defined('PUE_UPDATES_ENDPOINT') |
|
80
|
|
|
? PUE_UPDATES_ENDPOINT |
|
81
|
|
|
: 'https://eventespresso.com'; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
|
|
85
|
|
|
public function pluginSlug() |
|
86
|
|
|
{ |
|
87
|
|
|
//Note: PUE uses a simple preg_match to determine what type is currently installed based on version number. |
|
88
|
|
|
// So it's important that you use a key for the version type that is unique and not found in another key. |
|
89
|
|
|
//For example: |
|
90
|
|
|
//$plugin_slug['premium']['p'] = 'some-premium-slug'; |
|
91
|
|
|
//$plugin_slug['prerelease']['pr'] = 'some-pre-release-slug'; |
|
92
|
|
|
//The above would not work because "p" is found in both keys for the version type. ( i.e 1.0.p vs 1.0.pr ) |
|
93
|
|
|
// so doing something like: |
|
94
|
|
|
//$plugin_slug['premium']['p'] = 'some-premium-slug'; |
|
95
|
|
|
//$plugin_slug['prerelease']['b'] = 'some-pre-release-slug'; |
|
96
|
|
|
//..WOULD work! |
|
97
|
|
|
return array( |
|
98
|
|
|
'free' => array('decaf' => 'event-espresso-core-decaf'), |
|
99
|
|
|
'premium' => array('p' => 'event-espresso-core-reg'), |
|
100
|
|
|
'prerelease' => array('beta' => 'event-espresso-core-pr'), |
|
101
|
|
|
); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* Return whether the site is opted in for UXIP or not. |
|
107
|
|
|
* @return bool |
|
108
|
|
|
*/ |
|
109
|
|
|
public function isOptedInForUxip() |
|
110
|
|
|
{ |
|
111
|
|
|
return filter_var($this->ee_config->core->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* Return whether the site has been notified about UXIP or not. |
|
117
|
|
|
* @return bool |
|
118
|
|
|
*/ |
|
119
|
|
|
public function hasNotifiedForUxip() |
|
120
|
|
|
{ |
|
121
|
|
|
return filter_var($this->ee_config->core->ee_ueip_has_notified, FILTER_VALIDATE_BOOLEAN); |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* Set the site opted in for UXIP. |
|
127
|
|
|
*/ |
|
128
|
|
|
public function setHasOptedInForUxip() |
|
129
|
|
|
{ |
|
130
|
|
|
$this->ee_config->core->ee_ueip_optin = true; |
|
131
|
|
|
$this->ee_config->update_espresso_config(false, false); |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
|
|
135
|
|
|
/** |
|
136
|
|
|
* Set the site opted out for UXIP |
|
137
|
|
|
*/ |
|
138
|
|
|
public function setHasOptedOutForUxip() |
|
139
|
|
|
{ |
|
140
|
|
|
$this->ee_config->core->ee_ueip_optin = false; |
|
141
|
|
|
$this->ee_config->update_espresso_config(false, false); |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
|
|
145
|
|
|
|
|
146
|
|
|
public function setHasNotifiedAboutUxip() |
|
147
|
|
|
{ |
|
148
|
|
|
$this->ee_config->core->ee_ueip_has_notified = true; |
|
149
|
|
|
$this->ee_config->update_espresso_config(false, false); |
|
150
|
|
|
} |
|
151
|
|
|
} |
|
152
|
|
|
|