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