@@ -16,131 +16,131 @@ |
||
16 | 16 | */ |
17 | 17 | class Config |
18 | 18 | { |
19 | - /** |
|
20 | - * @var EE_Network_Config |
|
21 | - */ |
|
22 | - private $network_config; |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * @var EE_Config |
|
27 | - */ |
|
28 | - private $ee_config; |
|
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 | - public function i18nDomain() |
|
48 | - { |
|
49 | - return 'event_espresso'; |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - public function checkPeriod() |
|
54 | - { |
|
55 | - return 24; |
|
56 | - } |
|
57 | - |
|
58 | - |
|
59 | - public function optionKey() |
|
60 | - { |
|
61 | - return 'ee_site_license_key'; |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - public function optionsPageSlug() |
|
66 | - { |
|
67 | - return 'espresso_general_settings'; |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - public function hostServerUrl() |
|
72 | - { |
|
73 | - return defined('PUE_UPDATES_ENDPOINT') |
|
74 | - ? PUE_UPDATES_ENDPOINT |
|
75 | - : 'https://eventespresso.com'; |
|
76 | - } |
|
77 | - |
|
78 | - |
|
79 | - public function pluginSlug() |
|
80 | - { |
|
81 | - // Note: PUE uses a simple preg_match to determine what type is currently installed based on version number. |
|
82 | - // So it's important that you use a key for the version type that is unique and not found in another key. |
|
83 | - // For example: |
|
84 | - // $plugin_slug['premium']['p'] = 'some-premium-slug'; |
|
85 | - // $plugin_slug['prerelease']['pr'] = 'some-pre-release-slug'; |
|
86 | - // 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 ) |
|
87 | - // so doing something like: |
|
88 | - // $plugin_slug['premium']['p'] = 'some-premium-slug'; |
|
89 | - // $plugin_slug['prerelease']['b'] = 'some-pre-release-slug'; |
|
90 | - // ..WOULD work! |
|
91 | - return array( |
|
92 | - 'free' => array('decaf' => 'event-espresso-core-decaf'), |
|
93 | - 'premium' => array('p' => 'event-espresso-core-reg'), |
|
94 | - 'prerelease' => array('beta' => 'event-espresso-core-pr'), |
|
95 | - ); |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * Return whether the site is opted in for UXIP or not. |
|
101 | - * |
|
102 | - * @return bool |
|
103 | - */ |
|
104 | - public function isOptedInForUxip() |
|
105 | - { |
|
106 | - return filter_var($this->ee_config->core->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN); |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * Return whether the site has been notified about UXIP or not. |
|
112 | - * |
|
113 | - * @return bool |
|
114 | - */ |
|
115 | - public function hasNotifiedForUxip() |
|
116 | - { |
|
117 | - return filter_var($this->ee_config->core->ee_ueip_has_notified, FILTER_VALIDATE_BOOLEAN); |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - /** |
|
122 | - * Set the site opted in for UXIP. |
|
123 | - */ |
|
124 | - public function setHasOptedInForUxip() |
|
125 | - { |
|
126 | - $this->ee_config->core->ee_ueip_optin = true; |
|
127 | - $this->ee_config->update_espresso_config(false, false); |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * Set the site opted out for UXIP |
|
133 | - */ |
|
134 | - public function setHasOptedOutForUxip() |
|
135 | - { |
|
136 | - $this->ee_config->core->ee_ueip_optin = false; |
|
137 | - $this->ee_config->update_espresso_config(false, false); |
|
138 | - } |
|
139 | - |
|
140 | - |
|
141 | - public function setHasNotifiedAboutUxip() |
|
142 | - { |
|
143 | - $this->ee_config->core->ee_ueip_has_notified = true; |
|
144 | - $this->ee_config->update_espresso_config(false, false); |
|
145 | - } |
|
19 | + /** |
|
20 | + * @var EE_Network_Config |
|
21 | + */ |
|
22 | + private $network_config; |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * @var EE_Config |
|
27 | + */ |
|
28 | + private $ee_config; |
|
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 | + public function i18nDomain() |
|
48 | + { |
|
49 | + return 'event_espresso'; |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + public function checkPeriod() |
|
54 | + { |
|
55 | + return 24; |
|
56 | + } |
|
57 | + |
|
58 | + |
|
59 | + public function optionKey() |
|
60 | + { |
|
61 | + return 'ee_site_license_key'; |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + public function optionsPageSlug() |
|
66 | + { |
|
67 | + return 'espresso_general_settings'; |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + public function hostServerUrl() |
|
72 | + { |
|
73 | + return defined('PUE_UPDATES_ENDPOINT') |
|
74 | + ? PUE_UPDATES_ENDPOINT |
|
75 | + : 'https://eventespresso.com'; |
|
76 | + } |
|
77 | + |
|
78 | + |
|
79 | + public function pluginSlug() |
|
80 | + { |
|
81 | + // Note: PUE uses a simple preg_match to determine what type is currently installed based on version number. |
|
82 | + // So it's important that you use a key for the version type that is unique and not found in another key. |
|
83 | + // For example: |
|
84 | + // $plugin_slug['premium']['p'] = 'some-premium-slug'; |
|
85 | + // $plugin_slug['prerelease']['pr'] = 'some-pre-release-slug'; |
|
86 | + // 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 ) |
|
87 | + // so doing something like: |
|
88 | + // $plugin_slug['premium']['p'] = 'some-premium-slug'; |
|
89 | + // $plugin_slug['prerelease']['b'] = 'some-pre-release-slug'; |
|
90 | + // ..WOULD work! |
|
91 | + return array( |
|
92 | + 'free' => array('decaf' => 'event-espresso-core-decaf'), |
|
93 | + 'premium' => array('p' => 'event-espresso-core-reg'), |
|
94 | + 'prerelease' => array('beta' => 'event-espresso-core-pr'), |
|
95 | + ); |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * Return whether the site is opted in for UXIP or not. |
|
101 | + * |
|
102 | + * @return bool |
|
103 | + */ |
|
104 | + public function isOptedInForUxip() |
|
105 | + { |
|
106 | + return filter_var($this->ee_config->core->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN); |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * Return whether the site has been notified about UXIP or not. |
|
112 | + * |
|
113 | + * @return bool |
|
114 | + */ |
|
115 | + public function hasNotifiedForUxip() |
|
116 | + { |
|
117 | + return filter_var($this->ee_config->core->ee_ueip_has_notified, FILTER_VALIDATE_BOOLEAN); |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + /** |
|
122 | + * Set the site opted in for UXIP. |
|
123 | + */ |
|
124 | + public function setHasOptedInForUxip() |
|
125 | + { |
|
126 | + $this->ee_config->core->ee_ueip_optin = true; |
|
127 | + $this->ee_config->update_espresso_config(false, false); |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * Set the site opted out for UXIP |
|
133 | + */ |
|
134 | + public function setHasOptedOutForUxip() |
|
135 | + { |
|
136 | + $this->ee_config->core->ee_ueip_optin = false; |
|
137 | + $this->ee_config->update_espresso_config(false, false); |
|
138 | + } |
|
139 | + |
|
140 | + |
|
141 | + public function setHasNotifiedAboutUxip() |
|
142 | + { |
|
143 | + $this->ee_config->core->ee_ueip_has_notified = true; |
|
144 | + $this->ee_config->update_espresso_config(false, false); |
|
145 | + } |
|
146 | 146 | } |
@@ -40,494 +40,494 @@ |
||
40 | 40 | class OrganizationSettings extends FormHandler |
41 | 41 | { |
42 | 42 | |
43 | - /** |
|
44 | - * @var EE_Organization_Config |
|
45 | - */ |
|
46 | - protected $organization_config; |
|
43 | + /** |
|
44 | + * @var EE_Organization_Config |
|
45 | + */ |
|
46 | + protected $organization_config; |
|
47 | 47 | |
48 | - /** |
|
49 | - * @var EE_Core_Config |
|
50 | - */ |
|
51 | - protected $core_config; |
|
48 | + /** |
|
49 | + * @var EE_Core_Config |
|
50 | + */ |
|
51 | + protected $core_config; |
|
52 | 52 | |
53 | 53 | |
54 | - /** |
|
55 | - * @var EE_Network_Core_Config |
|
56 | - */ |
|
57 | - protected $network_core_config; |
|
54 | + /** |
|
55 | + * @var EE_Network_Core_Config |
|
56 | + */ |
|
57 | + protected $network_core_config; |
|
58 | 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 | - } |
|
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 | 88 | |
89 | 89 | |
90 | 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 | - } |
|
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 | 354 | |
355 | 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 | - } |
|
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 | 372 | |
373 | 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 | - } |
|
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 | 393 | |
394 | - if (is_main_site()) { |
|
395 | - $this->network_core_config->site_license_key = isset($form_data['ee_site_license_key']) |
|
396 | - ? sanitize_text_field($form_data['ee_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; |
|
394 | + if (is_main_site()) { |
|
395 | + $this->network_core_config->site_license_key = isset($form_data['ee_site_license_key']) |
|
396 | + ? sanitize_text_field($form_data['ee_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 | 454 | |
455 | - $this->registry->CFG->currency = new EE_Currency_Config( |
|
456 | - $this->organization_config->CNT_ISO |
|
457 | - ); |
|
458 | - return true; |
|
459 | - } |
|
455 | + $this->registry->CFG->currency = new EE_Currency_Config( |
|
456 | + $this->organization_config->CNT_ISO |
|
457 | + ); |
|
458 | + return true; |
|
459 | + } |
|
460 | 460 | |
461 | 461 | |
462 | - /** |
|
463 | - * @return string |
|
464 | - */ |
|
465 | - private function uxipOptinText() |
|
466 | - { |
|
467 | - ob_start(); |
|
468 | - Stats::optinText(false); |
|
469 | - return ob_get_clean(); |
|
470 | - } |
|
462 | + /** |
|
463 | + * @return string |
|
464 | + */ |
|
465 | + private function uxipOptinText() |
|
466 | + { |
|
467 | + ob_start(); |
|
468 | + Stats::optinText(false); |
|
469 | + return ob_get_clean(); |
|
470 | + } |
|
471 | 471 | |
472 | 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 | - } |
|
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 | 489 | |
490 | 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' => 'ee_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 | - } |
|
491 | + /** |
|
492 | + * @return EE_Text_Input |
|
493 | + */ |
|
494 | + private function getSiteLicenseKeyField() |
|
495 | + { |
|
496 | + $text_input = new EE_Text_Input( |
|
497 | + array( |
|
498 | + 'html_name' => 'ee_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 | 523 | |
524 | 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 | - } |
|
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 | 533 | } |
@@ -22,1225 +22,1225 @@ |
||
22 | 22 | class EE_Register_Addon implements EEI_Plugin_API |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * possibly truncated version of the EE core version string |
|
27 | - * |
|
28 | - * @var string |
|
29 | - */ |
|
30 | - protected static $_core_version = ''; |
|
25 | + /** |
|
26 | + * possibly truncated version of the EE core version string |
|
27 | + * |
|
28 | + * @var string |
|
29 | + */ |
|
30 | + protected static $_core_version = ''; |
|
31 | 31 | |
32 | - /** |
|
33 | - * Holds values for registered addons |
|
34 | - * |
|
35 | - * @var array |
|
36 | - */ |
|
37 | - protected static $_settings = array(); |
|
32 | + /** |
|
33 | + * Holds values for registered addons |
|
34 | + * |
|
35 | + * @var array |
|
36 | + */ |
|
37 | + protected static $_settings = array(); |
|
38 | 38 | |
39 | - /** |
|
40 | - * @var array $_incompatible_addons keys are addon SLUGS |
|
41 | - * (first argument passed to EE_Register_Addon::register()), keys are |
|
42 | - * their MINIMUM VERSION (with all 5 parts. Eg 1.2.3.rc.004). |
|
43 | - * Generally this should be used sparingly, as we don't want to muddle up |
|
44 | - * EE core with knowledge of ALL the addons out there. |
|
45 | - * If you want NO versions of an addon to run with a certain version of core, |
|
46 | - * it's usually best to define the addon's "min_core_version" as part of its call |
|
47 | - * to EE_Register_Addon::register(), rather than using this array with a super high value for its |
|
48 | - * minimum plugin version. |
|
49 | - * @access protected |
|
50 | - */ |
|
51 | - protected static $_incompatible_addons = array( |
|
52 | - 'Multi_Event_Registration' => '2.0.11.rc.002', |
|
53 | - 'Promotions' => '1.0.0.rc.084', |
|
54 | - ); |
|
39 | + /** |
|
40 | + * @var array $_incompatible_addons keys are addon SLUGS |
|
41 | + * (first argument passed to EE_Register_Addon::register()), keys are |
|
42 | + * their MINIMUM VERSION (with all 5 parts. Eg 1.2.3.rc.004). |
|
43 | + * Generally this should be used sparingly, as we don't want to muddle up |
|
44 | + * EE core with knowledge of ALL the addons out there. |
|
45 | + * If you want NO versions of an addon to run with a certain version of core, |
|
46 | + * it's usually best to define the addon's "min_core_version" as part of its call |
|
47 | + * to EE_Register_Addon::register(), rather than using this array with a super high value for its |
|
48 | + * minimum plugin version. |
|
49 | + * @access protected |
|
50 | + */ |
|
51 | + protected static $_incompatible_addons = array( |
|
52 | + 'Multi_Event_Registration' => '2.0.11.rc.002', |
|
53 | + 'Promotions' => '1.0.0.rc.084', |
|
54 | + ); |
|
55 | 55 | |
56 | 56 | |
57 | - /** |
|
58 | - * We should always be comparing core to a version like '4.3.0.rc.000', |
|
59 | - * not just '4.3.0'. |
|
60 | - * So if the addon developer doesn't provide that full version string, |
|
61 | - * fill in the blanks for them |
|
62 | - * |
|
63 | - * @param string $min_core_version |
|
64 | - * @return string always like '4.3.0.rc.000' |
|
65 | - */ |
|
66 | - protected static function _effective_version($min_core_version) |
|
67 | - { |
|
68 | - // versions: 4 . 3 . 1 . p . 123 |
|
69 | - // offsets: 0 . 1 . 2 . 3 . 4 |
|
70 | - $version_parts = explode('.', $min_core_version); |
|
71 | - // check they specified the micro version (after 2nd period) |
|
72 | - if (! isset($version_parts[2])) { |
|
73 | - $version_parts[2] = '0'; |
|
74 | - } |
|
75 | - // if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible |
|
76 | - // soon we can assume that's 'rc', but this current version is 'alpha' |
|
77 | - if (! isset($version_parts[3])) { |
|
78 | - $version_parts[3] = 'dev'; |
|
79 | - } |
|
80 | - if (! isset($version_parts[4])) { |
|
81 | - $version_parts[4] = '000'; |
|
82 | - } |
|
83 | - return implode('.', $version_parts); |
|
84 | - } |
|
57 | + /** |
|
58 | + * We should always be comparing core to a version like '4.3.0.rc.000', |
|
59 | + * not just '4.3.0'. |
|
60 | + * So if the addon developer doesn't provide that full version string, |
|
61 | + * fill in the blanks for them |
|
62 | + * |
|
63 | + * @param string $min_core_version |
|
64 | + * @return string always like '4.3.0.rc.000' |
|
65 | + */ |
|
66 | + protected static function _effective_version($min_core_version) |
|
67 | + { |
|
68 | + // versions: 4 . 3 . 1 . p . 123 |
|
69 | + // offsets: 0 . 1 . 2 . 3 . 4 |
|
70 | + $version_parts = explode('.', $min_core_version); |
|
71 | + // check they specified the micro version (after 2nd period) |
|
72 | + if (! isset($version_parts[2])) { |
|
73 | + $version_parts[2] = '0'; |
|
74 | + } |
|
75 | + // if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible |
|
76 | + // soon we can assume that's 'rc', but this current version is 'alpha' |
|
77 | + if (! isset($version_parts[3])) { |
|
78 | + $version_parts[3] = 'dev'; |
|
79 | + } |
|
80 | + if (! isset($version_parts[4])) { |
|
81 | + $version_parts[4] = '000'; |
|
82 | + } |
|
83 | + return implode('.', $version_parts); |
|
84 | + } |
|
85 | 85 | |
86 | 86 | |
87 | - /** |
|
88 | - * Returns whether or not the min core version requirement of the addon is met |
|
89 | - * |
|
90 | - * @param string $min_core_version the minimum core version required by the addon |
|
91 | - * @param string $actual_core_version the actual core version, optional |
|
92 | - * @return boolean |
|
93 | - */ |
|
94 | - public static function _meets_min_core_version_requirement( |
|
95 | - $min_core_version, |
|
96 | - $actual_core_version = EVENT_ESPRESSO_VERSION |
|
97 | - ) { |
|
98 | - return version_compare( |
|
99 | - self::_effective_version($actual_core_version), |
|
100 | - self::_effective_version($min_core_version), |
|
101 | - '>=' |
|
102 | - ); |
|
103 | - } |
|
87 | + /** |
|
88 | + * Returns whether or not the min core version requirement of the addon is met |
|
89 | + * |
|
90 | + * @param string $min_core_version the minimum core version required by the addon |
|
91 | + * @param string $actual_core_version the actual core version, optional |
|
92 | + * @return boolean |
|
93 | + */ |
|
94 | + public static function _meets_min_core_version_requirement( |
|
95 | + $min_core_version, |
|
96 | + $actual_core_version = EVENT_ESPRESSO_VERSION |
|
97 | + ) { |
|
98 | + return version_compare( |
|
99 | + self::_effective_version($actual_core_version), |
|
100 | + self::_effective_version($min_core_version), |
|
101 | + '>=' |
|
102 | + ); |
|
103 | + } |
|
104 | 104 | |
105 | 105 | |
106 | - /** |
|
107 | - * Method for registering new EE_Addons. |
|
108 | - * Should be called AFTER AHEE__EE_System__load_espresso_addons but BEFORE |
|
109 | - * AHEE__EE_System___detect_if_activation_or_upgrade__begin in order to register all its components. However, it |
|
110 | - * may also be called after the 'activate_plugin' action (when an addon is activated), because an activating addon |
|
111 | - * won't be loaded by WP until after AHEE__EE_System__load_espresso_addons has fired. If its called after |
|
112 | - * 'activate_plugin', it registers the addon still, but its components are not registered |
|
113 | - * (they shouldn't be needed anyways, because it's just an activation request and they won't have a chance to do |
|
114 | - * anything anyways). Instead, it just sets the newly-activated addon's activation indicator wp option and returns |
|
115 | - * (so that we can detect that the addon has activated on the subsequent request) |
|
116 | - * |
|
117 | - * @since 4.3.0 |
|
118 | - * @param string $addon_name [Required] the EE_Addon's name. |
|
119 | - * @param array $setup_args { |
|
120 | - * An array of arguments provided for registering |
|
121 | - * the message type. |
|
122 | - * @type string $class_name the addon's main file name. |
|
123 | - * If left blank, generated from the addon name, |
|
124 | - * changes something like "calendar" to |
|
125 | - * "EE_Calendar" |
|
126 | - * @type string $min_core_version the minimum version of EE Core that the |
|
127 | - * addon will work with. eg "4.8.1.rc.084" |
|
128 | - * @type string $version the "software" version for the addon. eg |
|
129 | - * "1.0.0.p" for a first stable release, or |
|
130 | - * "1.0.0.rc.043" for a version in progress |
|
131 | - * @type string $main_file_path the full server path to the main file |
|
132 | - * loaded directly by WP |
|
133 | - * @type DomainInterface $domain child class of |
|
134 | - * EventEspresso\core\domain\DomainBase |
|
135 | - * @type string $domain_fqcn Fully Qualified Class Name |
|
136 | - * for the addon's Domain class |
|
137 | - * (see EventEspresso\core\domain\Domain) |
|
138 | - * @type string $admin_path full server path to the folder where the |
|
139 | - * addon\'s admin files reside |
|
140 | - * @type string $admin_callback a method to be called when the EE Admin is |
|
141 | - * first invoked, can be used for hooking into |
|
142 | - * any admin page |
|
143 | - * @type string $config_section the section name for this addon's |
|
144 | - * configuration settings section |
|
145 | - * (defaults to "addons") |
|
146 | - * @type string $config_class the class name for this addon's |
|
147 | - * configuration settings object |
|
148 | - * @type string $config_name the class name for this addon's |
|
149 | - * configuration settings object |
|
150 | - * @type string $autoloader_paths [Required] an array of class names and the full |
|
151 | - * server paths to those files. |
|
152 | - * @type string $autoloader_folders an array of "full server paths" for any |
|
153 | - * folders containing classes that might be |
|
154 | - * invoked by the addon |
|
155 | - * @type string $dms_paths [Required] an array of full server paths to |
|
156 | - * folders that contain data migration scripts. |
|
157 | - * The key should be the EE_Addon class name that |
|
158 | - * this set of data migration scripts belongs to. |
|
159 | - * If the EE_Addon class is namespaced, then this |
|
160 | - * needs to be the Fully Qualified Class Name |
|
161 | - * @type string $module_paths an array of full server paths to any |
|
162 | - * EED_Modules used by the addon |
|
163 | - * @type string $shortcode_paths an array of full server paths to folders |
|
164 | - * that contain EES_Shortcodes |
|
165 | - * @type string $widget_paths an array of full server paths to folders |
|
166 | - * that contain WP_Widgets |
|
167 | - * @type string $pue_options |
|
168 | - * @type array $capabilities an array indexed by role name |
|
169 | - * (i.e administrator,author ) and the values |
|
170 | - * are an array of caps to add to the role. |
|
171 | - * 'administrator' => array( |
|
172 | - * 'read_addon', |
|
173 | - * 'edit_addon', |
|
174 | - * etc. |
|
175 | - * ). |
|
176 | - * @type EE_Meta_Capability_Map[] $capability_maps an array of EE_Meta_Capability_Map object |
|
177 | - * for any addons that need to register any |
|
178 | - * special meta mapped capabilities. Should |
|
179 | - * be indexed where the key is the |
|
180 | - * EE_Meta_Capability_Map class name and the |
|
181 | - * values are the arguments sent to the class. |
|
182 | - * @type array $model_paths array of folders containing DB models |
|
183 | - * @see EE_Register_Model |
|
184 | - * @type array $class_paths array of folders containing DB classes |
|
185 | - * @see EE_Register_Model |
|
186 | - * @type array $model_extension_paths array of folders containing DB model |
|
187 | - * extensions |
|
188 | - * @see EE_Register_Model_Extension |
|
189 | - * @type array $class_extension_paths array of folders containing DB class |
|
190 | - * extensions |
|
191 | - * @see EE_Register_Model_Extension |
|
192 | - * @type array message_types { |
|
193 | - * An array of message types with the key as |
|
194 | - * the message type name and the values as |
|
195 | - * below: |
|
196 | - * @type string $mtfilename [Required] The filename of the message type |
|
197 | - * being registered. This will be the main |
|
198 | - * EE_{Message Type Name}_message_type class. |
|
199 | - * for example: |
|
200 | - * EE_Declined_Registration_message_type.class.php |
|
201 | - * @type array $autoloadpaths [Required] An array of paths to add to the |
|
202 | - * messages autoloader for the new message type. |
|
203 | - * @type array $messengers_to_activate_with An array of messengers that this message |
|
204 | - * type should activate with. Each value in |
|
205 | - * the |
|
206 | - * array |
|
207 | - * should match the name property of a |
|
208 | - * EE_messenger. Optional. |
|
209 | - * @type array $messengers_to_validate_with An array of messengers that this message |
|
210 | - * type should validate with. Each value in |
|
211 | - * the |
|
212 | - * array |
|
213 | - * should match the name property of an |
|
214 | - * EE_messenger. |
|
215 | - * Optional. |
|
216 | - * } |
|
217 | - * @type array $custom_post_types |
|
218 | - * @type array $custom_taxonomies |
|
219 | - * @type array $payment_method_paths each element is the folder containing the |
|
220 | - * EE_PMT_Base child class |
|
221 | - * (eg, |
|
222 | - * '/wp-content/plugins/my_plugin/Payomatic/' |
|
223 | - * which contains the files |
|
224 | - * EE_PMT_Payomatic.pm.php) |
|
225 | - * @type array $default_terms |
|
226 | - * @type array $namespace { |
|
227 | - * An array with two items for registering the |
|
228 | - * addon's namespace. (If, for some reason, you |
|
229 | - * require additional namespaces, |
|
230 | - * use |
|
231 | - * EventEspresso\core\Psr4Autoloader::addNamespace() |
|
232 | - * directly) |
|
233 | - * @see EventEspresso\core\Psr4Autoloader::addNamespace() |
|
234 | - * @type string $FQNS the namespace prefix |
|
235 | - * @type string $DIR a base directory for class files in the |
|
236 | - * namespace. |
|
237 | - * } |
|
238 | - * } |
|
239 | - * @type string $privacy_policies FQNSs (namespaces, each of which contains only |
|
240 | - * privacy policy classes) or FQCNs (specific |
|
241 | - * classnames of privacy policy classes) |
|
242 | - * @type string $personal_data_exporters FQNSs (namespaces, each of which contains only |
|
243 | - * privacy policy classes) or FQCNs (specific |
|
244 | - * classnames of privacy policy classes) |
|
245 | - * @type string $personal_data_erasers FQNSs (namespaces, each of which contains only |
|
246 | - * privacy policy classes) or FQCNs (specific |
|
247 | - * classnames of privacy policy classes) |
|
248 | - * @return void |
|
249 | - * @throws DomainException |
|
250 | - * @throws EE_Error |
|
251 | - * @throws InvalidArgumentException |
|
252 | - * @throws ReflectionException |
|
253 | - * @throws InvalidDataTypeException |
|
254 | - * @throws InvalidInterfaceException |
|
255 | - */ |
|
256 | - public static function register($addon_name = '', $setup_args = array()) |
|
257 | - { |
|
258 | - // required fields MUST be present, so let's make sure they are. |
|
259 | - EE_Register_Addon::_verify_parameters($addon_name, $setup_args); |
|
260 | - // get class name for addon |
|
261 | - $class_name = EE_Register_Addon::_parse_class_name($addon_name, $setup_args); |
|
262 | - // setup $_settings array from incoming values. |
|
263 | - $addon_settings = EE_Register_Addon::_get_addon_settings($class_name, $setup_args); |
|
264 | - // setup PUE |
|
265 | - EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args); |
|
266 | - // does this addon work with this version of core or WordPress ? |
|
267 | - if (! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) { |
|
268 | - return; |
|
269 | - } |
|
270 | - // register namespaces |
|
271 | - EE_Register_Addon::_setup_namespaces($addon_settings); |
|
272 | - // check if this is an activation request |
|
273 | - if (EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) { |
|
274 | - // dont bother setting up the rest of the addon atm |
|
275 | - return; |
|
276 | - } |
|
277 | - // we need cars |
|
278 | - EE_Register_Addon::_setup_autoloaders($addon_name); |
|
279 | - // register new models and extensions |
|
280 | - EE_Register_Addon::_register_models_and_extensions($addon_name); |
|
281 | - // setup DMS |
|
282 | - EE_Register_Addon::_register_data_migration_scripts($addon_name); |
|
283 | - // if config_class is present let's register config. |
|
284 | - EE_Register_Addon::_register_config($addon_name); |
|
285 | - // register admin pages |
|
286 | - EE_Register_Addon::_register_admin_pages($addon_name); |
|
287 | - // add to list of modules to be registered |
|
288 | - EE_Register_Addon::_register_modules($addon_name); |
|
289 | - // add to list of shortcodes to be registered |
|
290 | - EE_Register_Addon::_register_shortcodes($addon_name); |
|
291 | - // add to list of widgets to be registered |
|
292 | - EE_Register_Addon::_register_widgets($addon_name); |
|
293 | - // register capability related stuff. |
|
294 | - EE_Register_Addon::_register_capabilities($addon_name); |
|
295 | - // any message type to register? |
|
296 | - EE_Register_Addon::_register_message_types($addon_name); |
|
297 | - // any custom post type/ custom capabilities or default terms to register |
|
298 | - EE_Register_Addon::_register_custom_post_types($addon_name); |
|
299 | - // and any payment methods |
|
300 | - EE_Register_Addon::_register_payment_methods($addon_name); |
|
301 | - // and privacy policy generators |
|
302 | - EE_Register_Addon::registerPrivacyPolicies($addon_name); |
|
303 | - // and privacy policy generators |
|
304 | - EE_Register_Addon::registerPersonalDataExporters($addon_name); |
|
305 | - // and privacy policy generators |
|
306 | - EE_Register_Addon::registerPersonalDataErasers($addon_name); |
|
307 | - // load and instantiate main addon class |
|
308 | - $addon = EE_Register_Addon::_load_and_init_addon_class($addon_name); |
|
309 | - // delay calling after_registration hook on each addon until after all add-ons have been registered. |
|
310 | - add_action('AHEE__EE_System__load_espresso_addons__complete', array($addon, 'after_registration'), 999); |
|
311 | - } |
|
106 | + /** |
|
107 | + * Method for registering new EE_Addons. |
|
108 | + * Should be called AFTER AHEE__EE_System__load_espresso_addons but BEFORE |
|
109 | + * AHEE__EE_System___detect_if_activation_or_upgrade__begin in order to register all its components. However, it |
|
110 | + * may also be called after the 'activate_plugin' action (when an addon is activated), because an activating addon |
|
111 | + * won't be loaded by WP until after AHEE__EE_System__load_espresso_addons has fired. If its called after |
|
112 | + * 'activate_plugin', it registers the addon still, but its components are not registered |
|
113 | + * (they shouldn't be needed anyways, because it's just an activation request and they won't have a chance to do |
|
114 | + * anything anyways). Instead, it just sets the newly-activated addon's activation indicator wp option and returns |
|
115 | + * (so that we can detect that the addon has activated on the subsequent request) |
|
116 | + * |
|
117 | + * @since 4.3.0 |
|
118 | + * @param string $addon_name [Required] the EE_Addon's name. |
|
119 | + * @param array $setup_args { |
|
120 | + * An array of arguments provided for registering |
|
121 | + * the message type. |
|
122 | + * @type string $class_name the addon's main file name. |
|
123 | + * If left blank, generated from the addon name, |
|
124 | + * changes something like "calendar" to |
|
125 | + * "EE_Calendar" |
|
126 | + * @type string $min_core_version the minimum version of EE Core that the |
|
127 | + * addon will work with. eg "4.8.1.rc.084" |
|
128 | + * @type string $version the "software" version for the addon. eg |
|
129 | + * "1.0.0.p" for a first stable release, or |
|
130 | + * "1.0.0.rc.043" for a version in progress |
|
131 | + * @type string $main_file_path the full server path to the main file |
|
132 | + * loaded directly by WP |
|
133 | + * @type DomainInterface $domain child class of |
|
134 | + * EventEspresso\core\domain\DomainBase |
|
135 | + * @type string $domain_fqcn Fully Qualified Class Name |
|
136 | + * for the addon's Domain class |
|
137 | + * (see EventEspresso\core\domain\Domain) |
|
138 | + * @type string $admin_path full server path to the folder where the |
|
139 | + * addon\'s admin files reside |
|
140 | + * @type string $admin_callback a method to be called when the EE Admin is |
|
141 | + * first invoked, can be used for hooking into |
|
142 | + * any admin page |
|
143 | + * @type string $config_section the section name for this addon's |
|
144 | + * configuration settings section |
|
145 | + * (defaults to "addons") |
|
146 | + * @type string $config_class the class name for this addon's |
|
147 | + * configuration settings object |
|
148 | + * @type string $config_name the class name for this addon's |
|
149 | + * configuration settings object |
|
150 | + * @type string $autoloader_paths [Required] an array of class names and the full |
|
151 | + * server paths to those files. |
|
152 | + * @type string $autoloader_folders an array of "full server paths" for any |
|
153 | + * folders containing classes that might be |
|
154 | + * invoked by the addon |
|
155 | + * @type string $dms_paths [Required] an array of full server paths to |
|
156 | + * folders that contain data migration scripts. |
|
157 | + * The key should be the EE_Addon class name that |
|
158 | + * this set of data migration scripts belongs to. |
|
159 | + * If the EE_Addon class is namespaced, then this |
|
160 | + * needs to be the Fully Qualified Class Name |
|
161 | + * @type string $module_paths an array of full server paths to any |
|
162 | + * EED_Modules used by the addon |
|
163 | + * @type string $shortcode_paths an array of full server paths to folders |
|
164 | + * that contain EES_Shortcodes |
|
165 | + * @type string $widget_paths an array of full server paths to folders |
|
166 | + * that contain WP_Widgets |
|
167 | + * @type string $pue_options |
|
168 | + * @type array $capabilities an array indexed by role name |
|
169 | + * (i.e administrator,author ) and the values |
|
170 | + * are an array of caps to add to the role. |
|
171 | + * 'administrator' => array( |
|
172 | + * 'read_addon', |
|
173 | + * 'edit_addon', |
|
174 | + * etc. |
|
175 | + * ). |
|
176 | + * @type EE_Meta_Capability_Map[] $capability_maps an array of EE_Meta_Capability_Map object |
|
177 | + * for any addons that need to register any |
|
178 | + * special meta mapped capabilities. Should |
|
179 | + * be indexed where the key is the |
|
180 | + * EE_Meta_Capability_Map class name and the |
|
181 | + * values are the arguments sent to the class. |
|
182 | + * @type array $model_paths array of folders containing DB models |
|
183 | + * @see EE_Register_Model |
|
184 | + * @type array $class_paths array of folders containing DB classes |
|
185 | + * @see EE_Register_Model |
|
186 | + * @type array $model_extension_paths array of folders containing DB model |
|
187 | + * extensions |
|
188 | + * @see EE_Register_Model_Extension |
|
189 | + * @type array $class_extension_paths array of folders containing DB class |
|
190 | + * extensions |
|
191 | + * @see EE_Register_Model_Extension |
|
192 | + * @type array message_types { |
|
193 | + * An array of message types with the key as |
|
194 | + * the message type name and the values as |
|
195 | + * below: |
|
196 | + * @type string $mtfilename [Required] The filename of the message type |
|
197 | + * being registered. This will be the main |
|
198 | + * EE_{Message Type Name}_message_type class. |
|
199 | + * for example: |
|
200 | + * EE_Declined_Registration_message_type.class.php |
|
201 | + * @type array $autoloadpaths [Required] An array of paths to add to the |
|
202 | + * messages autoloader for the new message type. |
|
203 | + * @type array $messengers_to_activate_with An array of messengers that this message |
|
204 | + * type should activate with. Each value in |
|
205 | + * the |
|
206 | + * array |
|
207 | + * should match the name property of a |
|
208 | + * EE_messenger. Optional. |
|
209 | + * @type array $messengers_to_validate_with An array of messengers that this message |
|
210 | + * type should validate with. Each value in |
|
211 | + * the |
|
212 | + * array |
|
213 | + * should match the name property of an |
|
214 | + * EE_messenger. |
|
215 | + * Optional. |
|
216 | + * } |
|
217 | + * @type array $custom_post_types |
|
218 | + * @type array $custom_taxonomies |
|
219 | + * @type array $payment_method_paths each element is the folder containing the |
|
220 | + * EE_PMT_Base child class |
|
221 | + * (eg, |
|
222 | + * '/wp-content/plugins/my_plugin/Payomatic/' |
|
223 | + * which contains the files |
|
224 | + * EE_PMT_Payomatic.pm.php) |
|
225 | + * @type array $default_terms |
|
226 | + * @type array $namespace { |
|
227 | + * An array with two items for registering the |
|
228 | + * addon's namespace. (If, for some reason, you |
|
229 | + * require additional namespaces, |
|
230 | + * use |
|
231 | + * EventEspresso\core\Psr4Autoloader::addNamespace() |
|
232 | + * directly) |
|
233 | + * @see EventEspresso\core\Psr4Autoloader::addNamespace() |
|
234 | + * @type string $FQNS the namespace prefix |
|
235 | + * @type string $DIR a base directory for class files in the |
|
236 | + * namespace. |
|
237 | + * } |
|
238 | + * } |
|
239 | + * @type string $privacy_policies FQNSs (namespaces, each of which contains only |
|
240 | + * privacy policy classes) or FQCNs (specific |
|
241 | + * classnames of privacy policy classes) |
|
242 | + * @type string $personal_data_exporters FQNSs (namespaces, each of which contains only |
|
243 | + * privacy policy classes) or FQCNs (specific |
|
244 | + * classnames of privacy policy classes) |
|
245 | + * @type string $personal_data_erasers FQNSs (namespaces, each of which contains only |
|
246 | + * privacy policy classes) or FQCNs (specific |
|
247 | + * classnames of privacy policy classes) |
|
248 | + * @return void |
|
249 | + * @throws DomainException |
|
250 | + * @throws EE_Error |
|
251 | + * @throws InvalidArgumentException |
|
252 | + * @throws ReflectionException |
|
253 | + * @throws InvalidDataTypeException |
|
254 | + * @throws InvalidInterfaceException |
|
255 | + */ |
|
256 | + public static function register($addon_name = '', $setup_args = array()) |
|
257 | + { |
|
258 | + // required fields MUST be present, so let's make sure they are. |
|
259 | + EE_Register_Addon::_verify_parameters($addon_name, $setup_args); |
|
260 | + // get class name for addon |
|
261 | + $class_name = EE_Register_Addon::_parse_class_name($addon_name, $setup_args); |
|
262 | + // setup $_settings array from incoming values. |
|
263 | + $addon_settings = EE_Register_Addon::_get_addon_settings($class_name, $setup_args); |
|
264 | + // setup PUE |
|
265 | + EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args); |
|
266 | + // does this addon work with this version of core or WordPress ? |
|
267 | + if (! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) { |
|
268 | + return; |
|
269 | + } |
|
270 | + // register namespaces |
|
271 | + EE_Register_Addon::_setup_namespaces($addon_settings); |
|
272 | + // check if this is an activation request |
|
273 | + if (EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) { |
|
274 | + // dont bother setting up the rest of the addon atm |
|
275 | + return; |
|
276 | + } |
|
277 | + // we need cars |
|
278 | + EE_Register_Addon::_setup_autoloaders($addon_name); |
|
279 | + // register new models and extensions |
|
280 | + EE_Register_Addon::_register_models_and_extensions($addon_name); |
|
281 | + // setup DMS |
|
282 | + EE_Register_Addon::_register_data_migration_scripts($addon_name); |
|
283 | + // if config_class is present let's register config. |
|
284 | + EE_Register_Addon::_register_config($addon_name); |
|
285 | + // register admin pages |
|
286 | + EE_Register_Addon::_register_admin_pages($addon_name); |
|
287 | + // add to list of modules to be registered |
|
288 | + EE_Register_Addon::_register_modules($addon_name); |
|
289 | + // add to list of shortcodes to be registered |
|
290 | + EE_Register_Addon::_register_shortcodes($addon_name); |
|
291 | + // add to list of widgets to be registered |
|
292 | + EE_Register_Addon::_register_widgets($addon_name); |
|
293 | + // register capability related stuff. |
|
294 | + EE_Register_Addon::_register_capabilities($addon_name); |
|
295 | + // any message type to register? |
|
296 | + EE_Register_Addon::_register_message_types($addon_name); |
|
297 | + // any custom post type/ custom capabilities or default terms to register |
|
298 | + EE_Register_Addon::_register_custom_post_types($addon_name); |
|
299 | + // and any payment methods |
|
300 | + EE_Register_Addon::_register_payment_methods($addon_name); |
|
301 | + // and privacy policy generators |
|
302 | + EE_Register_Addon::registerPrivacyPolicies($addon_name); |
|
303 | + // and privacy policy generators |
|
304 | + EE_Register_Addon::registerPersonalDataExporters($addon_name); |
|
305 | + // and privacy policy generators |
|
306 | + EE_Register_Addon::registerPersonalDataErasers($addon_name); |
|
307 | + // load and instantiate main addon class |
|
308 | + $addon = EE_Register_Addon::_load_and_init_addon_class($addon_name); |
|
309 | + // delay calling after_registration hook on each addon until after all add-ons have been registered. |
|
310 | + add_action('AHEE__EE_System__load_espresso_addons__complete', array($addon, 'after_registration'), 999); |
|
311 | + } |
|
312 | 312 | |
313 | 313 | |
314 | - /** |
|
315 | - * @param string $addon_name |
|
316 | - * @param array $setup_args |
|
317 | - * @return void |
|
318 | - * @throws EE_Error |
|
319 | - */ |
|
320 | - private static function _verify_parameters($addon_name, array $setup_args) |
|
321 | - { |
|
322 | - // required fields MUST be present, so let's make sure they are. |
|
323 | - if (empty($addon_name) || ! is_array($setup_args)) { |
|
324 | - throw new EE_Error( |
|
325 | - __( |
|
326 | - 'In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.', |
|
327 | - 'event_espresso' |
|
328 | - ) |
|
329 | - ); |
|
330 | - } |
|
331 | - if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) { |
|
332 | - throw new EE_Error( |
|
333 | - sprintf( |
|
334 | - __( |
|
335 | - 'When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s', |
|
336 | - 'event_espresso' |
|
337 | - ), |
|
338 | - implode(',', array_keys($setup_args)) |
|
339 | - ) |
|
340 | - ); |
|
341 | - } |
|
342 | - // check that addon has not already been registered with that name |
|
343 | - if (isset(self::$_settings[ $addon_name ]) && ! did_action('activate_plugin')) { |
|
344 | - throw new EE_Error( |
|
345 | - sprintf( |
|
346 | - __( |
|
347 | - 'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.', |
|
348 | - 'event_espresso' |
|
349 | - ), |
|
350 | - $addon_name |
|
351 | - ) |
|
352 | - ); |
|
353 | - } |
|
354 | - } |
|
314 | + /** |
|
315 | + * @param string $addon_name |
|
316 | + * @param array $setup_args |
|
317 | + * @return void |
|
318 | + * @throws EE_Error |
|
319 | + */ |
|
320 | + private static function _verify_parameters($addon_name, array $setup_args) |
|
321 | + { |
|
322 | + // required fields MUST be present, so let's make sure they are. |
|
323 | + if (empty($addon_name) || ! is_array($setup_args)) { |
|
324 | + throw new EE_Error( |
|
325 | + __( |
|
326 | + 'In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.', |
|
327 | + 'event_espresso' |
|
328 | + ) |
|
329 | + ); |
|
330 | + } |
|
331 | + if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) { |
|
332 | + throw new EE_Error( |
|
333 | + sprintf( |
|
334 | + __( |
|
335 | + 'When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s', |
|
336 | + 'event_espresso' |
|
337 | + ), |
|
338 | + implode(',', array_keys($setup_args)) |
|
339 | + ) |
|
340 | + ); |
|
341 | + } |
|
342 | + // check that addon has not already been registered with that name |
|
343 | + if (isset(self::$_settings[ $addon_name ]) && ! did_action('activate_plugin')) { |
|
344 | + throw new EE_Error( |
|
345 | + sprintf( |
|
346 | + __( |
|
347 | + 'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.', |
|
348 | + 'event_espresso' |
|
349 | + ), |
|
350 | + $addon_name |
|
351 | + ) |
|
352 | + ); |
|
353 | + } |
|
354 | + } |
|
355 | 355 | |
356 | 356 | |
357 | - /** |
|
358 | - * @param string $addon_name |
|
359 | - * @param array $setup_args |
|
360 | - * @return string |
|
361 | - */ |
|
362 | - private static function _parse_class_name($addon_name, array $setup_args) |
|
363 | - { |
|
364 | - if (empty($setup_args['class_name'])) { |
|
365 | - // generate one by first separating name with spaces |
|
366 | - $class_name = str_replace(array('-', '_'), ' ', trim($addon_name)); |
|
367 | - // capitalize, then replace spaces with underscores |
|
368 | - $class_name = str_replace(' ', '_', ucwords($class_name)); |
|
369 | - } else { |
|
370 | - $class_name = $setup_args['class_name']; |
|
371 | - } |
|
372 | - // check if classname is fully qualified or is a legacy classname already prefixed with 'EE_' |
|
373 | - return strpos($class_name, '\\') || strpos($class_name, 'EE_') === 0 |
|
374 | - ? $class_name |
|
375 | - : 'EE_' . $class_name; |
|
376 | - } |
|
357 | + /** |
|
358 | + * @param string $addon_name |
|
359 | + * @param array $setup_args |
|
360 | + * @return string |
|
361 | + */ |
|
362 | + private static function _parse_class_name($addon_name, array $setup_args) |
|
363 | + { |
|
364 | + if (empty($setup_args['class_name'])) { |
|
365 | + // generate one by first separating name with spaces |
|
366 | + $class_name = str_replace(array('-', '_'), ' ', trim($addon_name)); |
|
367 | + // capitalize, then replace spaces with underscores |
|
368 | + $class_name = str_replace(' ', '_', ucwords($class_name)); |
|
369 | + } else { |
|
370 | + $class_name = $setup_args['class_name']; |
|
371 | + } |
|
372 | + // check if classname is fully qualified or is a legacy classname already prefixed with 'EE_' |
|
373 | + return strpos($class_name, '\\') || strpos($class_name, 'EE_') === 0 |
|
374 | + ? $class_name |
|
375 | + : 'EE_' . $class_name; |
|
376 | + } |
|
377 | 377 | |
378 | 378 | |
379 | - /** |
|
380 | - * @param string $class_name |
|
381 | - * @param array $setup_args |
|
382 | - * @return array |
|
383 | - */ |
|
384 | - private static function _get_addon_settings($class_name, array $setup_args) |
|
385 | - { |
|
386 | - // setup $_settings array from incoming values. |
|
387 | - $addon_settings = array( |
|
388 | - // generated from the addon name, changes something like "calendar" to "EE_Calendar" |
|
389 | - 'class_name' => $class_name, |
|
390 | - // the addon slug for use in URLs, etc |
|
391 | - 'plugin_slug' => isset($setup_args['plugin_slug']) |
|
392 | - ? (string) $setup_args['plugin_slug'] |
|
393 | - : '', |
|
394 | - // page slug to be used when generating the "Settings" link on the WP plugin page |
|
395 | - 'plugin_action_slug' => isset($setup_args['plugin_action_slug']) |
|
396 | - ? (string) $setup_args['plugin_action_slug'] |
|
397 | - : '', |
|
398 | - // the "software" version for the addon |
|
399 | - 'version' => isset($setup_args['version']) |
|
400 | - ? (string) $setup_args['version'] |
|
401 | - : '', |
|
402 | - // the minimum version of EE Core that the addon will work with |
|
403 | - 'min_core_version' => isset($setup_args['min_core_version']) |
|
404 | - ? (string) $setup_args['min_core_version'] |
|
405 | - : '', |
|
406 | - // the minimum version of WordPress that the addon will work with |
|
407 | - 'min_wp_version' => isset($setup_args['min_wp_version']) |
|
408 | - ? (string) $setup_args['min_wp_version'] |
|
409 | - : EE_MIN_WP_VER_REQUIRED, |
|
410 | - // full server path to main file (file loaded directly by WP) |
|
411 | - 'main_file_path' => isset($setup_args['main_file_path']) |
|
412 | - ? (string) $setup_args['main_file_path'] |
|
413 | - : '', |
|
414 | - // instance of \EventEspresso\core\domain\DomainInterface |
|
415 | - 'domain' => isset($setup_args['domain']) && $setup_args['domain'] instanceof DomainInterface |
|
416 | - ? $setup_args['domain'] |
|
417 | - : null, |
|
418 | - // Fully Qualified Class Name for the addon's Domain class |
|
419 | - 'domain_fqcn' => isset($setup_args['domain_fqcn']) |
|
420 | - ? (string) $setup_args['domain_fqcn'] |
|
421 | - : '', |
|
422 | - // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages |
|
423 | - 'admin_path' => isset($setup_args['admin_path']) |
|
424 | - ? (string) $setup_args['admin_path'] : '', |
|
425 | - // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page |
|
426 | - 'admin_callback' => isset($setup_args['admin_callback']) |
|
427 | - ? (string) $setup_args['admin_callback'] |
|
428 | - : '', |
|
429 | - // the section name for this addon's configuration settings section (defaults to "addons") |
|
430 | - 'config_section' => isset($setup_args['config_section']) |
|
431 | - ? (string) $setup_args['config_section'] |
|
432 | - : 'addons', |
|
433 | - // the class name for this addon's configuration settings object |
|
434 | - 'config_class' => isset($setup_args['config_class']) |
|
435 | - ? (string) $setup_args['config_class'] : '', |
|
436 | - // the name given to the config for this addons' configuration settings object (optional) |
|
437 | - 'config_name' => isset($setup_args['config_name']) |
|
438 | - ? (string) $setup_args['config_name'] : '', |
|
439 | - // an array of "class names" => "full server paths" for any classes that might be invoked by the addon |
|
440 | - 'autoloader_paths' => isset($setup_args['autoloader_paths']) |
|
441 | - ? (array) $setup_args['autoloader_paths'] |
|
442 | - : array(), |
|
443 | - // an array of "full server paths" for any folders containing classes that might be invoked by the addon |
|
444 | - 'autoloader_folders' => isset($setup_args['autoloader_folders']) |
|
445 | - ? (array) $setup_args['autoloader_folders'] |
|
446 | - : array(), |
|
447 | - // array of full server paths to any EE_DMS data migration scripts used by the addon. |
|
448 | - // The key should be the EE_Addon class name that this set of data migration scripts belongs to. |
|
449 | - // If the EE_Addon class is namespaced, then this needs to be the Fully Qualified Class Name |
|
450 | - 'dms_paths' => isset($setup_args['dms_paths']) |
|
451 | - ? (array) $setup_args['dms_paths'] |
|
452 | - : array(), |
|
453 | - // array of full server paths to any EED_Modules used by the addon |
|
454 | - 'module_paths' => isset($setup_args['module_paths']) |
|
455 | - ? (array) $setup_args['module_paths'] |
|
456 | - : array(), |
|
457 | - // array of full server paths to any EES_Shortcodes used by the addon |
|
458 | - 'shortcode_paths' => isset($setup_args['shortcode_paths']) |
|
459 | - ? (array) $setup_args['shortcode_paths'] |
|
460 | - : array(), |
|
461 | - 'shortcode_fqcns' => isset($setup_args['shortcode_fqcns']) |
|
462 | - ? (array) $setup_args['shortcode_fqcns'] |
|
463 | - : array(), |
|
464 | - // array of full server paths to any WP_Widgets used by the addon |
|
465 | - 'widget_paths' => isset($setup_args['widget_paths']) |
|
466 | - ? (array) $setup_args['widget_paths'] |
|
467 | - : array(), |
|
468 | - // array of PUE options used by the addon |
|
469 | - 'pue_options' => isset($setup_args['pue_options']) |
|
470 | - ? (array) $setup_args['pue_options'] |
|
471 | - : array(), |
|
472 | - 'message_types' => isset($setup_args['message_types']) |
|
473 | - ? (array) $setup_args['message_types'] |
|
474 | - : array(), |
|
475 | - 'capabilities' => isset($setup_args['capabilities']) |
|
476 | - ? (array) $setup_args['capabilities'] |
|
477 | - : array(), |
|
478 | - 'capability_maps' => isset($setup_args['capability_maps']) |
|
479 | - ? (array) $setup_args['capability_maps'] |
|
480 | - : array(), |
|
481 | - 'model_paths' => isset($setup_args['model_paths']) |
|
482 | - ? (array) $setup_args['model_paths'] |
|
483 | - : array(), |
|
484 | - 'class_paths' => isset($setup_args['class_paths']) |
|
485 | - ? (array) $setup_args['class_paths'] |
|
486 | - : array(), |
|
487 | - 'model_extension_paths' => isset($setup_args['model_extension_paths']) |
|
488 | - ? (array) $setup_args['model_extension_paths'] |
|
489 | - : array(), |
|
490 | - 'class_extension_paths' => isset($setup_args['class_extension_paths']) |
|
491 | - ? (array) $setup_args['class_extension_paths'] |
|
492 | - : array(), |
|
493 | - 'custom_post_types' => isset($setup_args['custom_post_types']) |
|
494 | - ? (array) $setup_args['custom_post_types'] |
|
495 | - : array(), |
|
496 | - 'custom_taxonomies' => isset($setup_args['custom_taxonomies']) |
|
497 | - ? (array) $setup_args['custom_taxonomies'] |
|
498 | - : array(), |
|
499 | - 'payment_method_paths' => isset($setup_args['payment_method_paths']) |
|
500 | - ? (array) $setup_args['payment_method_paths'] |
|
501 | - : array(), |
|
502 | - 'default_terms' => isset($setup_args['default_terms']) |
|
503 | - ? (array) $setup_args['default_terms'] |
|
504 | - : array(), |
|
505 | - // if not empty, inserts a new table row after this plugin's row on the WP Plugins page |
|
506 | - // that can be used for adding upgrading/marketing info |
|
507 | - 'plugins_page_row' => isset($setup_args['plugins_page_row']) |
|
508 | - ? $setup_args['plugins_page_row'] |
|
509 | - : '', |
|
510 | - 'namespace' => isset( |
|
511 | - $setup_args['namespace']['FQNS'], |
|
512 | - $setup_args['namespace']['DIR'] |
|
513 | - ) |
|
514 | - ? (array) $setup_args['namespace'] |
|
515 | - : array(), |
|
516 | - 'privacy_policies' => isset($setup_args['privacy_policies']) |
|
517 | - ? (array) $setup_args['privacy_policies'] |
|
518 | - : '', |
|
519 | - ); |
|
520 | - // if plugin_action_slug is NOT set, but an admin page path IS set, |
|
521 | - // then let's just use the plugin_slug since that will be used for linking to the admin page |
|
522 | - $addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug']) |
|
523 | - && ! empty($addon_settings['admin_path']) |
|
524 | - ? $addon_settings['plugin_slug'] |
|
525 | - : $addon_settings['plugin_action_slug']; |
|
526 | - // full server path to main file (file loaded directly by WP) |
|
527 | - $addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']); |
|
528 | - return $addon_settings; |
|
529 | - } |
|
379 | + /** |
|
380 | + * @param string $class_name |
|
381 | + * @param array $setup_args |
|
382 | + * @return array |
|
383 | + */ |
|
384 | + private static function _get_addon_settings($class_name, array $setup_args) |
|
385 | + { |
|
386 | + // setup $_settings array from incoming values. |
|
387 | + $addon_settings = array( |
|
388 | + // generated from the addon name, changes something like "calendar" to "EE_Calendar" |
|
389 | + 'class_name' => $class_name, |
|
390 | + // the addon slug for use in URLs, etc |
|
391 | + 'plugin_slug' => isset($setup_args['plugin_slug']) |
|
392 | + ? (string) $setup_args['plugin_slug'] |
|
393 | + : '', |
|
394 | + // page slug to be used when generating the "Settings" link on the WP plugin page |
|
395 | + 'plugin_action_slug' => isset($setup_args['plugin_action_slug']) |
|
396 | + ? (string) $setup_args['plugin_action_slug'] |
|
397 | + : '', |
|
398 | + // the "software" version for the addon |
|
399 | + 'version' => isset($setup_args['version']) |
|
400 | + ? (string) $setup_args['version'] |
|
401 | + : '', |
|
402 | + // the minimum version of EE Core that the addon will work with |
|
403 | + 'min_core_version' => isset($setup_args['min_core_version']) |
|
404 | + ? (string) $setup_args['min_core_version'] |
|
405 | + : '', |
|
406 | + // the minimum version of WordPress that the addon will work with |
|
407 | + 'min_wp_version' => isset($setup_args['min_wp_version']) |
|
408 | + ? (string) $setup_args['min_wp_version'] |
|
409 | + : EE_MIN_WP_VER_REQUIRED, |
|
410 | + // full server path to main file (file loaded directly by WP) |
|
411 | + 'main_file_path' => isset($setup_args['main_file_path']) |
|
412 | + ? (string) $setup_args['main_file_path'] |
|
413 | + : '', |
|
414 | + // instance of \EventEspresso\core\domain\DomainInterface |
|
415 | + 'domain' => isset($setup_args['domain']) && $setup_args['domain'] instanceof DomainInterface |
|
416 | + ? $setup_args['domain'] |
|
417 | + : null, |
|
418 | + // Fully Qualified Class Name for the addon's Domain class |
|
419 | + 'domain_fqcn' => isset($setup_args['domain_fqcn']) |
|
420 | + ? (string) $setup_args['domain_fqcn'] |
|
421 | + : '', |
|
422 | + // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages |
|
423 | + 'admin_path' => isset($setup_args['admin_path']) |
|
424 | + ? (string) $setup_args['admin_path'] : '', |
|
425 | + // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page |
|
426 | + 'admin_callback' => isset($setup_args['admin_callback']) |
|
427 | + ? (string) $setup_args['admin_callback'] |
|
428 | + : '', |
|
429 | + // the section name for this addon's configuration settings section (defaults to "addons") |
|
430 | + 'config_section' => isset($setup_args['config_section']) |
|
431 | + ? (string) $setup_args['config_section'] |
|
432 | + : 'addons', |
|
433 | + // the class name for this addon's configuration settings object |
|
434 | + 'config_class' => isset($setup_args['config_class']) |
|
435 | + ? (string) $setup_args['config_class'] : '', |
|
436 | + // the name given to the config for this addons' configuration settings object (optional) |
|
437 | + 'config_name' => isset($setup_args['config_name']) |
|
438 | + ? (string) $setup_args['config_name'] : '', |
|
439 | + // an array of "class names" => "full server paths" for any classes that might be invoked by the addon |
|
440 | + 'autoloader_paths' => isset($setup_args['autoloader_paths']) |
|
441 | + ? (array) $setup_args['autoloader_paths'] |
|
442 | + : array(), |
|
443 | + // an array of "full server paths" for any folders containing classes that might be invoked by the addon |
|
444 | + 'autoloader_folders' => isset($setup_args['autoloader_folders']) |
|
445 | + ? (array) $setup_args['autoloader_folders'] |
|
446 | + : array(), |
|
447 | + // array of full server paths to any EE_DMS data migration scripts used by the addon. |
|
448 | + // The key should be the EE_Addon class name that this set of data migration scripts belongs to. |
|
449 | + // If the EE_Addon class is namespaced, then this needs to be the Fully Qualified Class Name |
|
450 | + 'dms_paths' => isset($setup_args['dms_paths']) |
|
451 | + ? (array) $setup_args['dms_paths'] |
|
452 | + : array(), |
|
453 | + // array of full server paths to any EED_Modules used by the addon |
|
454 | + 'module_paths' => isset($setup_args['module_paths']) |
|
455 | + ? (array) $setup_args['module_paths'] |
|
456 | + : array(), |
|
457 | + // array of full server paths to any EES_Shortcodes used by the addon |
|
458 | + 'shortcode_paths' => isset($setup_args['shortcode_paths']) |
|
459 | + ? (array) $setup_args['shortcode_paths'] |
|
460 | + : array(), |
|
461 | + 'shortcode_fqcns' => isset($setup_args['shortcode_fqcns']) |
|
462 | + ? (array) $setup_args['shortcode_fqcns'] |
|
463 | + : array(), |
|
464 | + // array of full server paths to any WP_Widgets used by the addon |
|
465 | + 'widget_paths' => isset($setup_args['widget_paths']) |
|
466 | + ? (array) $setup_args['widget_paths'] |
|
467 | + : array(), |
|
468 | + // array of PUE options used by the addon |
|
469 | + 'pue_options' => isset($setup_args['pue_options']) |
|
470 | + ? (array) $setup_args['pue_options'] |
|
471 | + : array(), |
|
472 | + 'message_types' => isset($setup_args['message_types']) |
|
473 | + ? (array) $setup_args['message_types'] |
|
474 | + : array(), |
|
475 | + 'capabilities' => isset($setup_args['capabilities']) |
|
476 | + ? (array) $setup_args['capabilities'] |
|
477 | + : array(), |
|
478 | + 'capability_maps' => isset($setup_args['capability_maps']) |
|
479 | + ? (array) $setup_args['capability_maps'] |
|
480 | + : array(), |
|
481 | + 'model_paths' => isset($setup_args['model_paths']) |
|
482 | + ? (array) $setup_args['model_paths'] |
|
483 | + : array(), |
|
484 | + 'class_paths' => isset($setup_args['class_paths']) |
|
485 | + ? (array) $setup_args['class_paths'] |
|
486 | + : array(), |
|
487 | + 'model_extension_paths' => isset($setup_args['model_extension_paths']) |
|
488 | + ? (array) $setup_args['model_extension_paths'] |
|
489 | + : array(), |
|
490 | + 'class_extension_paths' => isset($setup_args['class_extension_paths']) |
|
491 | + ? (array) $setup_args['class_extension_paths'] |
|
492 | + : array(), |
|
493 | + 'custom_post_types' => isset($setup_args['custom_post_types']) |
|
494 | + ? (array) $setup_args['custom_post_types'] |
|
495 | + : array(), |
|
496 | + 'custom_taxonomies' => isset($setup_args['custom_taxonomies']) |
|
497 | + ? (array) $setup_args['custom_taxonomies'] |
|
498 | + : array(), |
|
499 | + 'payment_method_paths' => isset($setup_args['payment_method_paths']) |
|
500 | + ? (array) $setup_args['payment_method_paths'] |
|
501 | + : array(), |
|
502 | + 'default_terms' => isset($setup_args['default_terms']) |
|
503 | + ? (array) $setup_args['default_terms'] |
|
504 | + : array(), |
|
505 | + // if not empty, inserts a new table row after this plugin's row on the WP Plugins page |
|
506 | + // that can be used for adding upgrading/marketing info |
|
507 | + 'plugins_page_row' => isset($setup_args['plugins_page_row']) |
|
508 | + ? $setup_args['plugins_page_row'] |
|
509 | + : '', |
|
510 | + 'namespace' => isset( |
|
511 | + $setup_args['namespace']['FQNS'], |
|
512 | + $setup_args['namespace']['DIR'] |
|
513 | + ) |
|
514 | + ? (array) $setup_args['namespace'] |
|
515 | + : array(), |
|
516 | + 'privacy_policies' => isset($setup_args['privacy_policies']) |
|
517 | + ? (array) $setup_args['privacy_policies'] |
|
518 | + : '', |
|
519 | + ); |
|
520 | + // if plugin_action_slug is NOT set, but an admin page path IS set, |
|
521 | + // then let's just use the plugin_slug since that will be used for linking to the admin page |
|
522 | + $addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug']) |
|
523 | + && ! empty($addon_settings['admin_path']) |
|
524 | + ? $addon_settings['plugin_slug'] |
|
525 | + : $addon_settings['plugin_action_slug']; |
|
526 | + // full server path to main file (file loaded directly by WP) |
|
527 | + $addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']); |
|
528 | + return $addon_settings; |
|
529 | + } |
|
530 | 530 | |
531 | 531 | |
532 | - /** |
|
533 | - * @param string $addon_name |
|
534 | - * @param array $addon_settings |
|
535 | - * @return boolean |
|
536 | - */ |
|
537 | - private static function _addon_is_compatible($addon_name, array $addon_settings) |
|
538 | - { |
|
539 | - global $wp_version; |
|
540 | - $incompatibility_message = ''; |
|
541 | - // check whether this addon version is compatible with EE core |
|
542 | - if (isset(EE_Register_Addon::$_incompatible_addons[ $addon_name ]) |
|
543 | - && ! self::_meets_min_core_version_requirement( |
|
544 | - EE_Register_Addon::$_incompatible_addons[ $addon_name ], |
|
545 | - $addon_settings['version'] |
|
546 | - ) |
|
547 | - ) { |
|
548 | - $incompatibility_message = sprintf( |
|
549 | - __( |
|
550 | - '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon is not compatible with this version of Event Espresso.%2$sPlease upgrade your "%1$s" addon to version %3$s or newer to resolve this issue.', |
|
551 | - 'event_espresso' |
|
552 | - ), |
|
553 | - $addon_name, |
|
554 | - '<br />', |
|
555 | - EE_Register_Addon::$_incompatible_addons[ $addon_name ], |
|
556 | - '<span style="font-weight: bold; color: #D54E21;">', |
|
557 | - '</span><br />' |
|
558 | - ); |
|
559 | - } elseif (! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version()) |
|
560 | - ) { |
|
561 | - $incompatibility_message = sprintf( |
|
562 | - __( |
|
563 | - '%5$sIMPORTANT!%6$sThe Event Espresso "%1$s" addon requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-activate "%1$s".', |
|
564 | - 'event_espresso' |
|
565 | - ), |
|
566 | - $addon_name, |
|
567 | - self::_effective_version($addon_settings['min_core_version']), |
|
568 | - self::_effective_version(espresso_version()), |
|
569 | - '<br />', |
|
570 | - '<span style="font-weight: bold; color: #D54E21;">', |
|
571 | - '</span><br />' |
|
572 | - ); |
|
573 | - } elseif (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) { |
|
574 | - $incompatibility_message = sprintf( |
|
575 | - __( |
|
576 | - '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon requires WordPress version "%2$s" or greater.%3$sPlease update your version of WordPress to use the "%1$s" addon and to keep your site secure.', |
|
577 | - 'event_espresso' |
|
578 | - ), |
|
579 | - $addon_name, |
|
580 | - $addon_settings['min_wp_version'], |
|
581 | - '<br />', |
|
582 | - '<span style="font-weight: bold; color: #D54E21;">', |
|
583 | - '</span><br />' |
|
584 | - ); |
|
585 | - } |
|
586 | - if (! empty($incompatibility_message)) { |
|
587 | - // remove 'activate' from the REQUEST |
|
588 | - // so WP doesn't erroneously tell the user the plugin activated fine when it didn't |
|
589 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
590 | - if (current_user_can('activate_plugins')) { |
|
591 | - // show an error message indicating the plugin didn't activate properly |
|
592 | - EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__); |
|
593 | - } |
|
594 | - // BAIL FROM THE ADDON REGISTRATION PROCESS |
|
595 | - return false; |
|
596 | - } |
|
597 | - // addon IS compatible |
|
598 | - return true; |
|
599 | - } |
|
532 | + /** |
|
533 | + * @param string $addon_name |
|
534 | + * @param array $addon_settings |
|
535 | + * @return boolean |
|
536 | + */ |
|
537 | + private static function _addon_is_compatible($addon_name, array $addon_settings) |
|
538 | + { |
|
539 | + global $wp_version; |
|
540 | + $incompatibility_message = ''; |
|
541 | + // check whether this addon version is compatible with EE core |
|
542 | + if (isset(EE_Register_Addon::$_incompatible_addons[ $addon_name ]) |
|
543 | + && ! self::_meets_min_core_version_requirement( |
|
544 | + EE_Register_Addon::$_incompatible_addons[ $addon_name ], |
|
545 | + $addon_settings['version'] |
|
546 | + ) |
|
547 | + ) { |
|
548 | + $incompatibility_message = sprintf( |
|
549 | + __( |
|
550 | + '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon is not compatible with this version of Event Espresso.%2$sPlease upgrade your "%1$s" addon to version %3$s or newer to resolve this issue.', |
|
551 | + 'event_espresso' |
|
552 | + ), |
|
553 | + $addon_name, |
|
554 | + '<br />', |
|
555 | + EE_Register_Addon::$_incompatible_addons[ $addon_name ], |
|
556 | + '<span style="font-weight: bold; color: #D54E21;">', |
|
557 | + '</span><br />' |
|
558 | + ); |
|
559 | + } elseif (! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version()) |
|
560 | + ) { |
|
561 | + $incompatibility_message = sprintf( |
|
562 | + __( |
|
563 | + '%5$sIMPORTANT!%6$sThe Event Espresso "%1$s" addon requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-activate "%1$s".', |
|
564 | + 'event_espresso' |
|
565 | + ), |
|
566 | + $addon_name, |
|
567 | + self::_effective_version($addon_settings['min_core_version']), |
|
568 | + self::_effective_version(espresso_version()), |
|
569 | + '<br />', |
|
570 | + '<span style="font-weight: bold; color: #D54E21;">', |
|
571 | + '</span><br />' |
|
572 | + ); |
|
573 | + } elseif (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) { |
|
574 | + $incompatibility_message = sprintf( |
|
575 | + __( |
|
576 | + '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon requires WordPress version "%2$s" or greater.%3$sPlease update your version of WordPress to use the "%1$s" addon and to keep your site secure.', |
|
577 | + 'event_espresso' |
|
578 | + ), |
|
579 | + $addon_name, |
|
580 | + $addon_settings['min_wp_version'], |
|
581 | + '<br />', |
|
582 | + '<span style="font-weight: bold; color: #D54E21;">', |
|
583 | + '</span><br />' |
|
584 | + ); |
|
585 | + } |
|
586 | + if (! empty($incompatibility_message)) { |
|
587 | + // remove 'activate' from the REQUEST |
|
588 | + // so WP doesn't erroneously tell the user the plugin activated fine when it didn't |
|
589 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
590 | + if (current_user_can('activate_plugins')) { |
|
591 | + // show an error message indicating the plugin didn't activate properly |
|
592 | + EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__); |
|
593 | + } |
|
594 | + // BAIL FROM THE ADDON REGISTRATION PROCESS |
|
595 | + return false; |
|
596 | + } |
|
597 | + // addon IS compatible |
|
598 | + return true; |
|
599 | + } |
|
600 | 600 | |
601 | 601 | |
602 | - /** |
|
603 | - * if plugin update engine is being used for auto-updates, |
|
604 | - * then let's set that up now before going any further so that ALL addons can be updated |
|
605 | - * (not needed if PUE is not being used) |
|
606 | - * |
|
607 | - * @param string $addon_name |
|
608 | - * @param string $class_name |
|
609 | - * @param array $setup_args |
|
610 | - * @return void |
|
611 | - */ |
|
612 | - private static function _parse_pue_options($addon_name, $class_name, array $setup_args) |
|
613 | - { |
|
614 | - if (! empty($setup_args['pue_options'])) { |
|
615 | - self::$_settings[ $addon_name ]['pue_options'] = array( |
|
616 | - 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug']) |
|
617 | - ? (string) $setup_args['pue_options']['pue_plugin_slug'] |
|
618 | - : 'espresso_' . strtolower($class_name), |
|
619 | - 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename']) |
|
620 | - ? (string) $setup_args['pue_options']['plugin_basename'] |
|
621 | - : plugin_basename($setup_args['main_file_path']), |
|
622 | - 'checkPeriod' => isset($setup_args['pue_options']['checkPeriod']) |
|
623 | - ? (string) $setup_args['pue_options']['checkPeriod'] |
|
624 | - : '24', |
|
625 | - 'use_wp_update' => isset($setup_args['pue_options']['use_wp_update']) |
|
626 | - ? (string) $setup_args['pue_options']['use_wp_update'] |
|
627 | - : false, |
|
628 | - ); |
|
629 | - add_action( |
|
630 | - 'AHEE__EE_System__brew_espresso__after_pue_init', |
|
631 | - array('EE_Register_Addon', 'load_pue_update') |
|
632 | - ); |
|
633 | - } |
|
634 | - } |
|
602 | + /** |
|
603 | + * if plugin update engine is being used for auto-updates, |
|
604 | + * then let's set that up now before going any further so that ALL addons can be updated |
|
605 | + * (not needed if PUE is not being used) |
|
606 | + * |
|
607 | + * @param string $addon_name |
|
608 | + * @param string $class_name |
|
609 | + * @param array $setup_args |
|
610 | + * @return void |
|
611 | + */ |
|
612 | + private static function _parse_pue_options($addon_name, $class_name, array $setup_args) |
|
613 | + { |
|
614 | + if (! empty($setup_args['pue_options'])) { |
|
615 | + self::$_settings[ $addon_name ]['pue_options'] = array( |
|
616 | + 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug']) |
|
617 | + ? (string) $setup_args['pue_options']['pue_plugin_slug'] |
|
618 | + : 'espresso_' . strtolower($class_name), |
|
619 | + 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename']) |
|
620 | + ? (string) $setup_args['pue_options']['plugin_basename'] |
|
621 | + : plugin_basename($setup_args['main_file_path']), |
|
622 | + 'checkPeriod' => isset($setup_args['pue_options']['checkPeriod']) |
|
623 | + ? (string) $setup_args['pue_options']['checkPeriod'] |
|
624 | + : '24', |
|
625 | + 'use_wp_update' => isset($setup_args['pue_options']['use_wp_update']) |
|
626 | + ? (string) $setup_args['pue_options']['use_wp_update'] |
|
627 | + : false, |
|
628 | + ); |
|
629 | + add_action( |
|
630 | + 'AHEE__EE_System__brew_espresso__after_pue_init', |
|
631 | + array('EE_Register_Addon', 'load_pue_update') |
|
632 | + ); |
|
633 | + } |
|
634 | + } |
|
635 | 635 | |
636 | 636 | |
637 | - /** |
|
638 | - * register namespaces right away before any other files or classes get loaded, but AFTER the version checks |
|
639 | - * |
|
640 | - * @param array $addon_settings |
|
641 | - * @return void |
|
642 | - */ |
|
643 | - private static function _setup_namespaces(array $addon_settings) |
|
644 | - { |
|
645 | - // |
|
646 | - if (isset( |
|
647 | - $addon_settings['namespace']['FQNS'], |
|
648 | - $addon_settings['namespace']['DIR'] |
|
649 | - )) { |
|
650 | - EE_Psr4AutoloaderInit::psr4_loader()->addNamespace( |
|
651 | - $addon_settings['namespace']['FQNS'], |
|
652 | - $addon_settings['namespace']['DIR'] |
|
653 | - ); |
|
654 | - } |
|
655 | - } |
|
637 | + /** |
|
638 | + * register namespaces right away before any other files or classes get loaded, but AFTER the version checks |
|
639 | + * |
|
640 | + * @param array $addon_settings |
|
641 | + * @return void |
|
642 | + */ |
|
643 | + private static function _setup_namespaces(array $addon_settings) |
|
644 | + { |
|
645 | + // |
|
646 | + if (isset( |
|
647 | + $addon_settings['namespace']['FQNS'], |
|
648 | + $addon_settings['namespace']['DIR'] |
|
649 | + )) { |
|
650 | + EE_Psr4AutoloaderInit::psr4_loader()->addNamespace( |
|
651 | + $addon_settings['namespace']['FQNS'], |
|
652 | + $addon_settings['namespace']['DIR'] |
|
653 | + ); |
|
654 | + } |
|
655 | + } |
|
656 | 656 | |
657 | 657 | |
658 | - /** |
|
659 | - * @param string $addon_name |
|
660 | - * @param array $addon_settings |
|
661 | - * @return bool |
|
662 | - * @throws EE_Error |
|
663 | - * @throws InvalidArgumentException |
|
664 | - * @throws ReflectionException |
|
665 | - * @throws InvalidDataTypeException |
|
666 | - * @throws InvalidInterfaceException |
|
667 | - */ |
|
668 | - private static function _addon_activation($addon_name, array $addon_settings) |
|
669 | - { |
|
670 | - // this is an activation request |
|
671 | - if (did_action( |
|
672 | - 'activate_plugin' |
|
673 | - )) {// to find if THIS is the addon that was activated, just check if we have already registered it or not |
|
674 | - // (as the newly-activated addon wasn't around the first time addons were registered). |
|
675 | - // Note: the presence of pue_options in the addon registration options will initialize the $_settings |
|
676 | - // property for the add-on, but the add-on is only partially initialized. Hence, the additional check. |
|
677 | - if (! isset(self::$_settings[ $addon_name ]) |
|
678 | - || (isset(self::$_settings[ $addon_name ]) |
|
679 | - && ! isset(self::$_settings[ $addon_name ]['class_name']) |
|
680 | - ) |
|
681 | - ) { |
|
682 | - self::$_settings[ $addon_name ] = $addon_settings; |
|
683 | - $addon = self::_load_and_init_addon_class($addon_name); |
|
684 | - $addon->set_activation_indicator_option(); |
|
685 | - // dont bother setting up the rest of the addon. |
|
686 | - // we know it was just activated and the request will end soon |
|
687 | - } |
|
688 | - return true; |
|
689 | - } |
|
690 | - // make sure this was called in the right place! |
|
691 | - if (! did_action('AHEE__EE_System__load_espresso_addons') |
|
692 | - || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
|
693 | - ) { |
|
694 | - EE_Error::doing_it_wrong( |
|
695 | - __METHOD__, |
|
696 | - sprintf( |
|
697 | - __( |
|
698 | - 'An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.', |
|
699 | - 'event_espresso' |
|
700 | - ), |
|
701 | - $addon_name |
|
702 | - ), |
|
703 | - '4.3.0' |
|
704 | - ); |
|
705 | - } |
|
706 | - // make sure addon settings are set correctly without overwriting anything existing |
|
707 | - if (isset(self::$_settings[ $addon_name ])) { |
|
708 | - self::$_settings[ $addon_name ] += $addon_settings; |
|
709 | - } else { |
|
710 | - self::$_settings[ $addon_name ] = $addon_settings; |
|
711 | - } |
|
712 | - return false; |
|
713 | - } |
|
658 | + /** |
|
659 | + * @param string $addon_name |
|
660 | + * @param array $addon_settings |
|
661 | + * @return bool |
|
662 | + * @throws EE_Error |
|
663 | + * @throws InvalidArgumentException |
|
664 | + * @throws ReflectionException |
|
665 | + * @throws InvalidDataTypeException |
|
666 | + * @throws InvalidInterfaceException |
|
667 | + */ |
|
668 | + private static function _addon_activation($addon_name, array $addon_settings) |
|
669 | + { |
|
670 | + // this is an activation request |
|
671 | + if (did_action( |
|
672 | + 'activate_plugin' |
|
673 | + )) {// to find if THIS is the addon that was activated, just check if we have already registered it or not |
|
674 | + // (as the newly-activated addon wasn't around the first time addons were registered). |
|
675 | + // Note: the presence of pue_options in the addon registration options will initialize the $_settings |
|
676 | + // property for the add-on, but the add-on is only partially initialized. Hence, the additional check. |
|
677 | + if (! isset(self::$_settings[ $addon_name ]) |
|
678 | + || (isset(self::$_settings[ $addon_name ]) |
|
679 | + && ! isset(self::$_settings[ $addon_name ]['class_name']) |
|
680 | + ) |
|
681 | + ) { |
|
682 | + self::$_settings[ $addon_name ] = $addon_settings; |
|
683 | + $addon = self::_load_and_init_addon_class($addon_name); |
|
684 | + $addon->set_activation_indicator_option(); |
|
685 | + // dont bother setting up the rest of the addon. |
|
686 | + // we know it was just activated and the request will end soon |
|
687 | + } |
|
688 | + return true; |
|
689 | + } |
|
690 | + // make sure this was called in the right place! |
|
691 | + if (! did_action('AHEE__EE_System__load_espresso_addons') |
|
692 | + || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
|
693 | + ) { |
|
694 | + EE_Error::doing_it_wrong( |
|
695 | + __METHOD__, |
|
696 | + sprintf( |
|
697 | + __( |
|
698 | + 'An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.', |
|
699 | + 'event_espresso' |
|
700 | + ), |
|
701 | + $addon_name |
|
702 | + ), |
|
703 | + '4.3.0' |
|
704 | + ); |
|
705 | + } |
|
706 | + // make sure addon settings are set correctly without overwriting anything existing |
|
707 | + if (isset(self::$_settings[ $addon_name ])) { |
|
708 | + self::$_settings[ $addon_name ] += $addon_settings; |
|
709 | + } else { |
|
710 | + self::$_settings[ $addon_name ] = $addon_settings; |
|
711 | + } |
|
712 | + return false; |
|
713 | + } |
|
714 | 714 | |
715 | 715 | |
716 | - /** |
|
717 | - * @param string $addon_name |
|
718 | - * @return void |
|
719 | - * @throws EE_Error |
|
720 | - */ |
|
721 | - private static function _setup_autoloaders($addon_name) |
|
722 | - { |
|
723 | - if (! empty(self::$_settings[ $addon_name ]['autoloader_paths'])) { |
|
724 | - // setup autoloader for single file |
|
725 | - EEH_Autoloader::instance()->register_autoloader(self::$_settings[ $addon_name ]['autoloader_paths']); |
|
726 | - } |
|
727 | - // setup autoloaders for folders |
|
728 | - if (! empty(self::$_settings[ $addon_name ]['autoloader_folders'])) { |
|
729 | - foreach ((array) self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder) { |
|
730 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder); |
|
731 | - } |
|
732 | - } |
|
733 | - } |
|
716 | + /** |
|
717 | + * @param string $addon_name |
|
718 | + * @return void |
|
719 | + * @throws EE_Error |
|
720 | + */ |
|
721 | + private static function _setup_autoloaders($addon_name) |
|
722 | + { |
|
723 | + if (! empty(self::$_settings[ $addon_name ]['autoloader_paths'])) { |
|
724 | + // setup autoloader for single file |
|
725 | + EEH_Autoloader::instance()->register_autoloader(self::$_settings[ $addon_name ]['autoloader_paths']); |
|
726 | + } |
|
727 | + // setup autoloaders for folders |
|
728 | + if (! empty(self::$_settings[ $addon_name ]['autoloader_folders'])) { |
|
729 | + foreach ((array) self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder) { |
|
730 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder); |
|
731 | + } |
|
732 | + } |
|
733 | + } |
|
734 | 734 | |
735 | 735 | |
736 | - /** |
|
737 | - * register new models and extensions |
|
738 | - * |
|
739 | - * @param string $addon_name |
|
740 | - * @return void |
|
741 | - * @throws EE_Error |
|
742 | - */ |
|
743 | - private static function _register_models_and_extensions($addon_name) |
|
744 | - { |
|
745 | - // register new models |
|
746 | - if (! empty(self::$_settings[ $addon_name ]['model_paths']) |
|
747 | - || ! empty(self::$_settings[ $addon_name ]['class_paths']) |
|
748 | - ) { |
|
749 | - EE_Register_Model::register( |
|
750 | - $addon_name, |
|
751 | - array( |
|
752 | - 'model_paths' => self::$_settings[ $addon_name ]['model_paths'], |
|
753 | - 'class_paths' => self::$_settings[ $addon_name ]['class_paths'], |
|
754 | - ) |
|
755 | - ); |
|
756 | - } |
|
757 | - // register model extensions |
|
758 | - if (! empty(self::$_settings[ $addon_name ]['model_extension_paths']) |
|
759 | - || ! empty(self::$_settings[ $addon_name ]['class_extension_paths']) |
|
760 | - ) { |
|
761 | - EE_Register_Model_Extensions::register( |
|
762 | - $addon_name, |
|
763 | - array( |
|
764 | - 'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'], |
|
765 | - 'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'], |
|
766 | - ) |
|
767 | - ); |
|
768 | - } |
|
769 | - } |
|
736 | + /** |
|
737 | + * register new models and extensions |
|
738 | + * |
|
739 | + * @param string $addon_name |
|
740 | + * @return void |
|
741 | + * @throws EE_Error |
|
742 | + */ |
|
743 | + private static function _register_models_and_extensions($addon_name) |
|
744 | + { |
|
745 | + // register new models |
|
746 | + if (! empty(self::$_settings[ $addon_name ]['model_paths']) |
|
747 | + || ! empty(self::$_settings[ $addon_name ]['class_paths']) |
|
748 | + ) { |
|
749 | + EE_Register_Model::register( |
|
750 | + $addon_name, |
|
751 | + array( |
|
752 | + 'model_paths' => self::$_settings[ $addon_name ]['model_paths'], |
|
753 | + 'class_paths' => self::$_settings[ $addon_name ]['class_paths'], |
|
754 | + ) |
|
755 | + ); |
|
756 | + } |
|
757 | + // register model extensions |
|
758 | + if (! empty(self::$_settings[ $addon_name ]['model_extension_paths']) |
|
759 | + || ! empty(self::$_settings[ $addon_name ]['class_extension_paths']) |
|
760 | + ) { |
|
761 | + EE_Register_Model_Extensions::register( |
|
762 | + $addon_name, |
|
763 | + array( |
|
764 | + 'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'], |
|
765 | + 'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'], |
|
766 | + ) |
|
767 | + ); |
|
768 | + } |
|
769 | + } |
|
770 | 770 | |
771 | 771 | |
772 | - /** |
|
773 | - * @param string $addon_name |
|
774 | - * @return void |
|
775 | - * @throws EE_Error |
|
776 | - */ |
|
777 | - private static function _register_data_migration_scripts($addon_name) |
|
778 | - { |
|
779 | - // setup DMS |
|
780 | - if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) { |
|
781 | - EE_Register_Data_Migration_Scripts::register( |
|
782 | - $addon_name, |
|
783 | - array('dms_paths' => self::$_settings[ $addon_name ]['dms_paths']) |
|
784 | - ); |
|
785 | - } |
|
786 | - } |
|
772 | + /** |
|
773 | + * @param string $addon_name |
|
774 | + * @return void |
|
775 | + * @throws EE_Error |
|
776 | + */ |
|
777 | + private static function _register_data_migration_scripts($addon_name) |
|
778 | + { |
|
779 | + // setup DMS |
|
780 | + if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) { |
|
781 | + EE_Register_Data_Migration_Scripts::register( |
|
782 | + $addon_name, |
|
783 | + array('dms_paths' => self::$_settings[ $addon_name ]['dms_paths']) |
|
784 | + ); |
|
785 | + } |
|
786 | + } |
|
787 | 787 | |
788 | 788 | |
789 | - /** |
|
790 | - * @param string $addon_name |
|
791 | - * @return void |
|
792 | - * @throws EE_Error |
|
793 | - */ |
|
794 | - private static function _register_config($addon_name) |
|
795 | - { |
|
796 | - // if config_class is present let's register config. |
|
797 | - if (! empty(self::$_settings[ $addon_name ]['config_class'])) { |
|
798 | - EE_Register_Config::register( |
|
799 | - self::$_settings[ $addon_name ]['config_class'], |
|
800 | - array( |
|
801 | - 'config_section' => self::$_settings[ $addon_name ]['config_section'], |
|
802 | - 'config_name' => self::$_settings[ $addon_name ]['config_name'], |
|
803 | - ) |
|
804 | - ); |
|
805 | - } |
|
806 | - } |
|
789 | + /** |
|
790 | + * @param string $addon_name |
|
791 | + * @return void |
|
792 | + * @throws EE_Error |
|
793 | + */ |
|
794 | + private static function _register_config($addon_name) |
|
795 | + { |
|
796 | + // if config_class is present let's register config. |
|
797 | + if (! empty(self::$_settings[ $addon_name ]['config_class'])) { |
|
798 | + EE_Register_Config::register( |
|
799 | + self::$_settings[ $addon_name ]['config_class'], |
|
800 | + array( |
|
801 | + 'config_section' => self::$_settings[ $addon_name ]['config_section'], |
|
802 | + 'config_name' => self::$_settings[ $addon_name ]['config_name'], |
|
803 | + ) |
|
804 | + ); |
|
805 | + } |
|
806 | + } |
|
807 | 807 | |
808 | 808 | |
809 | - /** |
|
810 | - * @param string $addon_name |
|
811 | - * @return void |
|
812 | - * @throws EE_Error |
|
813 | - */ |
|
814 | - private static function _register_admin_pages($addon_name) |
|
815 | - { |
|
816 | - if (! empty(self::$_settings[ $addon_name ]['admin_path'])) { |
|
817 | - EE_Register_Admin_Page::register( |
|
818 | - $addon_name, |
|
819 | - array('page_path' => self::$_settings[ $addon_name ]['admin_path']) |
|
820 | - ); |
|
821 | - } |
|
822 | - } |
|
809 | + /** |
|
810 | + * @param string $addon_name |
|
811 | + * @return void |
|
812 | + * @throws EE_Error |
|
813 | + */ |
|
814 | + private static function _register_admin_pages($addon_name) |
|
815 | + { |
|
816 | + if (! empty(self::$_settings[ $addon_name ]['admin_path'])) { |
|
817 | + EE_Register_Admin_Page::register( |
|
818 | + $addon_name, |
|
819 | + array('page_path' => self::$_settings[ $addon_name ]['admin_path']) |
|
820 | + ); |
|
821 | + } |
|
822 | + } |
|
823 | 823 | |
824 | 824 | |
825 | - /** |
|
826 | - * @param string $addon_name |
|
827 | - * @return void |
|
828 | - * @throws EE_Error |
|
829 | - */ |
|
830 | - private static function _register_modules($addon_name) |
|
831 | - { |
|
832 | - if (! empty(self::$_settings[ $addon_name ]['module_paths'])) { |
|
833 | - EE_Register_Module::register( |
|
834 | - $addon_name, |
|
835 | - array('module_paths' => self::$_settings[ $addon_name ]['module_paths']) |
|
836 | - ); |
|
837 | - } |
|
838 | - } |
|
825 | + /** |
|
826 | + * @param string $addon_name |
|
827 | + * @return void |
|
828 | + * @throws EE_Error |
|
829 | + */ |
|
830 | + private static function _register_modules($addon_name) |
|
831 | + { |
|
832 | + if (! empty(self::$_settings[ $addon_name ]['module_paths'])) { |
|
833 | + EE_Register_Module::register( |
|
834 | + $addon_name, |
|
835 | + array('module_paths' => self::$_settings[ $addon_name ]['module_paths']) |
|
836 | + ); |
|
837 | + } |
|
838 | + } |
|
839 | 839 | |
840 | 840 | |
841 | - /** |
|
842 | - * @param string $addon_name |
|
843 | - * @return void |
|
844 | - * @throws EE_Error |
|
845 | - */ |
|
846 | - private static function _register_shortcodes($addon_name) |
|
847 | - { |
|
848 | - if (! empty(self::$_settings[ $addon_name ]['shortcode_paths']) |
|
849 | - || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns']) |
|
850 | - ) { |
|
851 | - EE_Register_Shortcode::register( |
|
852 | - $addon_name, |
|
853 | - array( |
|
854 | - 'shortcode_paths' => isset(self::$_settings[ $addon_name ]['shortcode_paths']) |
|
855 | - ? self::$_settings[ $addon_name ]['shortcode_paths'] |
|
856 | - : array(), |
|
857 | - 'shortcode_fqcns' => isset(self::$_settings[ $addon_name ]['shortcode_fqcns']) |
|
858 | - ? self::$_settings[ $addon_name ]['shortcode_fqcns'] |
|
859 | - : array(), |
|
860 | - ) |
|
861 | - ); |
|
862 | - } |
|
863 | - } |
|
841 | + /** |
|
842 | + * @param string $addon_name |
|
843 | + * @return void |
|
844 | + * @throws EE_Error |
|
845 | + */ |
|
846 | + private static function _register_shortcodes($addon_name) |
|
847 | + { |
|
848 | + if (! empty(self::$_settings[ $addon_name ]['shortcode_paths']) |
|
849 | + || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns']) |
|
850 | + ) { |
|
851 | + EE_Register_Shortcode::register( |
|
852 | + $addon_name, |
|
853 | + array( |
|
854 | + 'shortcode_paths' => isset(self::$_settings[ $addon_name ]['shortcode_paths']) |
|
855 | + ? self::$_settings[ $addon_name ]['shortcode_paths'] |
|
856 | + : array(), |
|
857 | + 'shortcode_fqcns' => isset(self::$_settings[ $addon_name ]['shortcode_fqcns']) |
|
858 | + ? self::$_settings[ $addon_name ]['shortcode_fqcns'] |
|
859 | + : array(), |
|
860 | + ) |
|
861 | + ); |
|
862 | + } |
|
863 | + } |
|
864 | 864 | |
865 | 865 | |
866 | - /** |
|
867 | - * @param string $addon_name |
|
868 | - * @return void |
|
869 | - * @throws EE_Error |
|
870 | - */ |
|
871 | - private static function _register_widgets($addon_name) |
|
872 | - { |
|
873 | - if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) { |
|
874 | - EE_Register_Widget::register( |
|
875 | - $addon_name, |
|
876 | - array('widget_paths' => self::$_settings[ $addon_name ]['widget_paths']) |
|
877 | - ); |
|
878 | - } |
|
879 | - } |
|
866 | + /** |
|
867 | + * @param string $addon_name |
|
868 | + * @return void |
|
869 | + * @throws EE_Error |
|
870 | + */ |
|
871 | + private static function _register_widgets($addon_name) |
|
872 | + { |
|
873 | + if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) { |
|
874 | + EE_Register_Widget::register( |
|
875 | + $addon_name, |
|
876 | + array('widget_paths' => self::$_settings[ $addon_name ]['widget_paths']) |
|
877 | + ); |
|
878 | + } |
|
879 | + } |
|
880 | 880 | |
881 | 881 | |
882 | - /** |
|
883 | - * @param string $addon_name |
|
884 | - * @return void |
|
885 | - * @throws EE_Error |
|
886 | - */ |
|
887 | - private static function _register_capabilities($addon_name) |
|
888 | - { |
|
889 | - if (! empty(self::$_settings[ $addon_name ]['capabilities'])) { |
|
890 | - EE_Register_Capabilities::register( |
|
891 | - $addon_name, |
|
892 | - array( |
|
893 | - 'capabilities' => self::$_settings[ $addon_name ]['capabilities'], |
|
894 | - 'capability_maps' => self::$_settings[ $addon_name ]['capability_maps'], |
|
895 | - ) |
|
896 | - ); |
|
897 | - } |
|
898 | - } |
|
882 | + /** |
|
883 | + * @param string $addon_name |
|
884 | + * @return void |
|
885 | + * @throws EE_Error |
|
886 | + */ |
|
887 | + private static function _register_capabilities($addon_name) |
|
888 | + { |
|
889 | + if (! empty(self::$_settings[ $addon_name ]['capabilities'])) { |
|
890 | + EE_Register_Capabilities::register( |
|
891 | + $addon_name, |
|
892 | + array( |
|
893 | + 'capabilities' => self::$_settings[ $addon_name ]['capabilities'], |
|
894 | + 'capability_maps' => self::$_settings[ $addon_name ]['capability_maps'], |
|
895 | + ) |
|
896 | + ); |
|
897 | + } |
|
898 | + } |
|
899 | 899 | |
900 | 900 | |
901 | - /** |
|
902 | - * @param string $addon_name |
|
903 | - * @return void |
|
904 | - * @throws EE_Error |
|
905 | - */ |
|
906 | - private static function _register_message_types($addon_name) |
|
907 | - { |
|
908 | - if (! empty(self::$_settings[ $addon_name ]['message_types'])) { |
|
909 | - add_action( |
|
910 | - 'EE_Brewing_Regular___messages_caf', |
|
911 | - array('EE_Register_Addon', 'register_message_types') |
|
912 | - ); |
|
913 | - } |
|
914 | - } |
|
901 | + /** |
|
902 | + * @param string $addon_name |
|
903 | + * @return void |
|
904 | + * @throws EE_Error |
|
905 | + */ |
|
906 | + private static function _register_message_types($addon_name) |
|
907 | + { |
|
908 | + if (! empty(self::$_settings[ $addon_name ]['message_types'])) { |
|
909 | + add_action( |
|
910 | + 'EE_Brewing_Regular___messages_caf', |
|
911 | + array('EE_Register_Addon', 'register_message_types') |
|
912 | + ); |
|
913 | + } |
|
914 | + } |
|
915 | 915 | |
916 | 916 | |
917 | - /** |
|
918 | - * @param string $addon_name |
|
919 | - * @return void |
|
920 | - * @throws EE_Error |
|
921 | - */ |
|
922 | - private static function _register_custom_post_types($addon_name) |
|
923 | - { |
|
924 | - if (! empty(self::$_settings[ $addon_name ]['custom_post_types']) |
|
925 | - || ! empty(self::$_settings[ $addon_name ]['custom_taxonomies']) |
|
926 | - ) { |
|
927 | - EE_Register_CPT::register( |
|
928 | - $addon_name, |
|
929 | - array( |
|
930 | - 'cpts' => self::$_settings[ $addon_name ]['custom_post_types'], |
|
931 | - 'cts' => self::$_settings[ $addon_name ]['custom_taxonomies'], |
|
932 | - 'default_terms' => self::$_settings[ $addon_name ]['default_terms'], |
|
933 | - ) |
|
934 | - ); |
|
935 | - } |
|
936 | - } |
|
917 | + /** |
|
918 | + * @param string $addon_name |
|
919 | + * @return void |
|
920 | + * @throws EE_Error |
|
921 | + */ |
|
922 | + private static function _register_custom_post_types($addon_name) |
|
923 | + { |
|
924 | + if (! empty(self::$_settings[ $addon_name ]['custom_post_types']) |
|
925 | + || ! empty(self::$_settings[ $addon_name ]['custom_taxonomies']) |
|
926 | + ) { |
|
927 | + EE_Register_CPT::register( |
|
928 | + $addon_name, |
|
929 | + array( |
|
930 | + 'cpts' => self::$_settings[ $addon_name ]['custom_post_types'], |
|
931 | + 'cts' => self::$_settings[ $addon_name ]['custom_taxonomies'], |
|
932 | + 'default_terms' => self::$_settings[ $addon_name ]['default_terms'], |
|
933 | + ) |
|
934 | + ); |
|
935 | + } |
|
936 | + } |
|
937 | 937 | |
938 | 938 | |
939 | - /** |
|
940 | - * @param string $addon_name |
|
941 | - * @return void |
|
942 | - * @throws InvalidArgumentException |
|
943 | - * @throws InvalidInterfaceException |
|
944 | - * @throws InvalidDataTypeException |
|
945 | - * @throws DomainException |
|
946 | - * @throws EE_Error |
|
947 | - */ |
|
948 | - private static function _register_payment_methods($addon_name) |
|
949 | - { |
|
950 | - if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) { |
|
951 | - EE_Register_Payment_Method::register( |
|
952 | - $addon_name, |
|
953 | - array('payment_method_paths' => self::$_settings[ $addon_name ]['payment_method_paths']) |
|
954 | - ); |
|
955 | - } |
|
956 | - } |
|
939 | + /** |
|
940 | + * @param string $addon_name |
|
941 | + * @return void |
|
942 | + * @throws InvalidArgumentException |
|
943 | + * @throws InvalidInterfaceException |
|
944 | + * @throws InvalidDataTypeException |
|
945 | + * @throws DomainException |
|
946 | + * @throws EE_Error |
|
947 | + */ |
|
948 | + private static function _register_payment_methods($addon_name) |
|
949 | + { |
|
950 | + if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) { |
|
951 | + EE_Register_Payment_Method::register( |
|
952 | + $addon_name, |
|
953 | + array('payment_method_paths' => self::$_settings[ $addon_name ]['payment_method_paths']) |
|
954 | + ); |
|
955 | + } |
|
956 | + } |
|
957 | 957 | |
958 | 958 | |
959 | - /** |
|
960 | - * @param string $addon_name |
|
961 | - * @return void |
|
962 | - * @throws InvalidArgumentException |
|
963 | - * @throws InvalidInterfaceException |
|
964 | - * @throws InvalidDataTypeException |
|
965 | - * @throws DomainException |
|
966 | - * @throws EE_Error |
|
967 | - */ |
|
968 | - private static function registerPrivacyPolicies($addon_name) |
|
969 | - { |
|
970 | - if (! empty(self::$_settings[ $addon_name ]['privacy_policies'])) { |
|
971 | - EE_Register_Privacy_Policy::register( |
|
972 | - $addon_name, |
|
973 | - self::$_settings[ $addon_name ]['privacy_policies'] |
|
974 | - ); |
|
975 | - } |
|
976 | - } |
|
959 | + /** |
|
960 | + * @param string $addon_name |
|
961 | + * @return void |
|
962 | + * @throws InvalidArgumentException |
|
963 | + * @throws InvalidInterfaceException |
|
964 | + * @throws InvalidDataTypeException |
|
965 | + * @throws DomainException |
|
966 | + * @throws EE_Error |
|
967 | + */ |
|
968 | + private static function registerPrivacyPolicies($addon_name) |
|
969 | + { |
|
970 | + if (! empty(self::$_settings[ $addon_name ]['privacy_policies'])) { |
|
971 | + EE_Register_Privacy_Policy::register( |
|
972 | + $addon_name, |
|
973 | + self::$_settings[ $addon_name ]['privacy_policies'] |
|
974 | + ); |
|
975 | + } |
|
976 | + } |
|
977 | 977 | |
978 | 978 | |
979 | - /** |
|
980 | - * @param string $addon_name |
|
981 | - * @return void |
|
982 | - */ |
|
983 | - private static function registerPersonalDataExporters($addon_name) |
|
984 | - { |
|
985 | - if (! empty(self::$_settings[ $addon_name ]['personal_data_exporters'])) { |
|
986 | - EE_Register_Personal_Data_Eraser::register( |
|
987 | - $addon_name, |
|
988 | - self::$_settings[ $addon_name ]['personal_data_exporters'] |
|
989 | - ); |
|
990 | - } |
|
991 | - } |
|
979 | + /** |
|
980 | + * @param string $addon_name |
|
981 | + * @return void |
|
982 | + */ |
|
983 | + private static function registerPersonalDataExporters($addon_name) |
|
984 | + { |
|
985 | + if (! empty(self::$_settings[ $addon_name ]['personal_data_exporters'])) { |
|
986 | + EE_Register_Personal_Data_Eraser::register( |
|
987 | + $addon_name, |
|
988 | + self::$_settings[ $addon_name ]['personal_data_exporters'] |
|
989 | + ); |
|
990 | + } |
|
991 | + } |
|
992 | 992 | |
993 | 993 | |
994 | - /** |
|
995 | - * @param string $addon_name |
|
996 | - * @return void |
|
997 | - */ |
|
998 | - private static function registerPersonalDataErasers($addon_name) |
|
999 | - { |
|
1000 | - if (! empty(self::$_settings[ $addon_name ]['personal_data_erasers'])) { |
|
1001 | - EE_Register_Personal_Data_Eraser::register( |
|
1002 | - $addon_name, |
|
1003 | - self::$_settings[ $addon_name ]['personal_data_erasers'] |
|
1004 | - ); |
|
1005 | - } |
|
1006 | - } |
|
994 | + /** |
|
995 | + * @param string $addon_name |
|
996 | + * @return void |
|
997 | + */ |
|
998 | + private static function registerPersonalDataErasers($addon_name) |
|
999 | + { |
|
1000 | + if (! empty(self::$_settings[ $addon_name ]['personal_data_erasers'])) { |
|
1001 | + EE_Register_Personal_Data_Eraser::register( |
|
1002 | + $addon_name, |
|
1003 | + self::$_settings[ $addon_name ]['personal_data_erasers'] |
|
1004 | + ); |
|
1005 | + } |
|
1006 | + } |
|
1007 | 1007 | |
1008 | 1008 | |
1009 | - /** |
|
1010 | - * Loads and instantiates the EE_Addon class and adds it onto the registry |
|
1011 | - * |
|
1012 | - * @param string $addon_name |
|
1013 | - * @return EE_Addon |
|
1014 | - * @throws InvalidArgumentException |
|
1015 | - * @throws InvalidInterfaceException |
|
1016 | - * @throws InvalidDataTypeException |
|
1017 | - * @throws ReflectionException |
|
1018 | - * @throws EE_Error |
|
1019 | - */ |
|
1020 | - private static function _load_and_init_addon_class($addon_name) |
|
1021 | - { |
|
1022 | - $loader = EventEspresso\core\services\loaders\LoaderFactory::getLoader(); |
|
1023 | - $addon = $loader->getShared( |
|
1024 | - self::$_settings[ $addon_name ]['class_name'], |
|
1025 | - array('EE_Registry::create(addon)' => true) |
|
1026 | - ); |
|
1027 | - // setter inject dep map if required |
|
1028 | - if ($addon instanceof RequiresDependencyMapInterface && $addon->dependencyMap() === null) { |
|
1029 | - $addon->setDependencyMap($loader->getShared('EE_Dependency_Map')); |
|
1030 | - } |
|
1031 | - // setter inject domain if required |
|
1032 | - if ($addon instanceof RequiresDomainInterface |
|
1033 | - && $addon->domain() === null |
|
1034 | - ) { |
|
1035 | - // using supplied Domain object |
|
1036 | - $domain = self::$_settings[ $addon_name ]['domain'] instanceof DomainInterface |
|
1037 | - ? self::$_settings[ $addon_name ]['domain'] |
|
1038 | - : null; |
|
1039 | - // or construct one using Domain FQCN |
|
1040 | - if ($domain === null && self::$_settings[ $addon_name ]['domain_fqcn'] !== '') { |
|
1041 | - $domain = $loader->getShared( |
|
1042 | - self::$_settings[ $addon_name ]['domain_fqcn'], |
|
1043 | - array( |
|
1044 | - new EventEspresso\core\domain\values\FilePath( |
|
1045 | - self::$_settings[ $addon_name ]['main_file_path'] |
|
1046 | - ), |
|
1047 | - EventEspresso\core\domain\values\Version::fromString( |
|
1048 | - self::$_settings[ $addon_name ]['version'] |
|
1049 | - ), |
|
1050 | - ) |
|
1051 | - ); |
|
1052 | - } |
|
1053 | - if ($domain instanceof DomainInterface) { |
|
1054 | - $addon->setDomain($domain); |
|
1055 | - } |
|
1056 | - } |
|
1057 | - $addon->set_name($addon_name); |
|
1058 | - $addon->set_plugin_slug(self::$_settings[ $addon_name ]['plugin_slug']); |
|
1059 | - $addon->set_plugin_basename(self::$_settings[ $addon_name ]['plugin_basename']); |
|
1060 | - $addon->set_main_plugin_file(self::$_settings[ $addon_name ]['main_file_path']); |
|
1061 | - $addon->set_plugin_action_slug(self::$_settings[ $addon_name ]['plugin_action_slug']); |
|
1062 | - $addon->set_plugins_page_row(self::$_settings[ $addon_name ]['plugins_page_row']); |
|
1063 | - $addon->set_version(self::$_settings[ $addon_name ]['version']); |
|
1064 | - $addon->set_min_core_version(self::_effective_version(self::$_settings[ $addon_name ]['min_core_version'])); |
|
1065 | - $addon->set_config_section(self::$_settings[ $addon_name ]['config_section']); |
|
1066 | - $addon->set_config_class(self::$_settings[ $addon_name ]['config_class']); |
|
1067 | - $addon->set_config_name(self::$_settings[ $addon_name ]['config_name']); |
|
1068 | - // unfortunately this can't be hooked in upon construction, because we don't have |
|
1069 | - // the plugin mainfile's path upon construction. |
|
1070 | - register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation')); |
|
1071 | - // call any additional admin_callback functions during load_admin_controller hook |
|
1072 | - if (! empty(self::$_settings[ $addon_name ]['admin_callback'])) { |
|
1073 | - add_action( |
|
1074 | - 'AHEE__EE_System__load_controllers__load_admin_controllers', |
|
1075 | - array($addon, self::$_settings[ $addon_name ]['admin_callback']) |
|
1076 | - ); |
|
1077 | - } |
|
1078 | - return $addon; |
|
1079 | - } |
|
1009 | + /** |
|
1010 | + * Loads and instantiates the EE_Addon class and adds it onto the registry |
|
1011 | + * |
|
1012 | + * @param string $addon_name |
|
1013 | + * @return EE_Addon |
|
1014 | + * @throws InvalidArgumentException |
|
1015 | + * @throws InvalidInterfaceException |
|
1016 | + * @throws InvalidDataTypeException |
|
1017 | + * @throws ReflectionException |
|
1018 | + * @throws EE_Error |
|
1019 | + */ |
|
1020 | + private static function _load_and_init_addon_class($addon_name) |
|
1021 | + { |
|
1022 | + $loader = EventEspresso\core\services\loaders\LoaderFactory::getLoader(); |
|
1023 | + $addon = $loader->getShared( |
|
1024 | + self::$_settings[ $addon_name ]['class_name'], |
|
1025 | + array('EE_Registry::create(addon)' => true) |
|
1026 | + ); |
|
1027 | + // setter inject dep map if required |
|
1028 | + if ($addon instanceof RequiresDependencyMapInterface && $addon->dependencyMap() === null) { |
|
1029 | + $addon->setDependencyMap($loader->getShared('EE_Dependency_Map')); |
|
1030 | + } |
|
1031 | + // setter inject domain if required |
|
1032 | + if ($addon instanceof RequiresDomainInterface |
|
1033 | + && $addon->domain() === null |
|
1034 | + ) { |
|
1035 | + // using supplied Domain object |
|
1036 | + $domain = self::$_settings[ $addon_name ]['domain'] instanceof DomainInterface |
|
1037 | + ? self::$_settings[ $addon_name ]['domain'] |
|
1038 | + : null; |
|
1039 | + // or construct one using Domain FQCN |
|
1040 | + if ($domain === null && self::$_settings[ $addon_name ]['domain_fqcn'] !== '') { |
|
1041 | + $domain = $loader->getShared( |
|
1042 | + self::$_settings[ $addon_name ]['domain_fqcn'], |
|
1043 | + array( |
|
1044 | + new EventEspresso\core\domain\values\FilePath( |
|
1045 | + self::$_settings[ $addon_name ]['main_file_path'] |
|
1046 | + ), |
|
1047 | + EventEspresso\core\domain\values\Version::fromString( |
|
1048 | + self::$_settings[ $addon_name ]['version'] |
|
1049 | + ), |
|
1050 | + ) |
|
1051 | + ); |
|
1052 | + } |
|
1053 | + if ($domain instanceof DomainInterface) { |
|
1054 | + $addon->setDomain($domain); |
|
1055 | + } |
|
1056 | + } |
|
1057 | + $addon->set_name($addon_name); |
|
1058 | + $addon->set_plugin_slug(self::$_settings[ $addon_name ]['plugin_slug']); |
|
1059 | + $addon->set_plugin_basename(self::$_settings[ $addon_name ]['plugin_basename']); |
|
1060 | + $addon->set_main_plugin_file(self::$_settings[ $addon_name ]['main_file_path']); |
|
1061 | + $addon->set_plugin_action_slug(self::$_settings[ $addon_name ]['plugin_action_slug']); |
|
1062 | + $addon->set_plugins_page_row(self::$_settings[ $addon_name ]['plugins_page_row']); |
|
1063 | + $addon->set_version(self::$_settings[ $addon_name ]['version']); |
|
1064 | + $addon->set_min_core_version(self::_effective_version(self::$_settings[ $addon_name ]['min_core_version'])); |
|
1065 | + $addon->set_config_section(self::$_settings[ $addon_name ]['config_section']); |
|
1066 | + $addon->set_config_class(self::$_settings[ $addon_name ]['config_class']); |
|
1067 | + $addon->set_config_name(self::$_settings[ $addon_name ]['config_name']); |
|
1068 | + // unfortunately this can't be hooked in upon construction, because we don't have |
|
1069 | + // the plugin mainfile's path upon construction. |
|
1070 | + register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation')); |
|
1071 | + // call any additional admin_callback functions during load_admin_controller hook |
|
1072 | + if (! empty(self::$_settings[ $addon_name ]['admin_callback'])) { |
|
1073 | + add_action( |
|
1074 | + 'AHEE__EE_System__load_controllers__load_admin_controllers', |
|
1075 | + array($addon, self::$_settings[ $addon_name ]['admin_callback']) |
|
1076 | + ); |
|
1077 | + } |
|
1078 | + return $addon; |
|
1079 | + } |
|
1080 | 1080 | |
1081 | 1081 | |
1082 | - /** |
|
1083 | - * load_pue_update - Update notifications |
|
1084 | - * |
|
1085 | - * @return void |
|
1086 | - * @throws InvalidArgumentException |
|
1087 | - * @throws InvalidDataTypeException |
|
1088 | - * @throws InvalidInterfaceException |
|
1089 | - */ |
|
1090 | - public static function load_pue_update() |
|
1091 | - { |
|
1092 | - // load PUE client |
|
1093 | - require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php'; |
|
1094 | - $license_server = defined('PUE_UPDATES_ENDPOINT') ? PUE_UPDATES_ENDPOINT : 'https://eventespresso.com'; |
|
1095 | - // cycle thru settings |
|
1096 | - foreach (self::$_settings as $settings) { |
|
1097 | - if (! empty($settings['pue_options'])) { |
|
1098 | - // initiate the class and start the plugin update engine! |
|
1099 | - new PluginUpdateEngineChecker( |
|
1100 | - // host file URL |
|
1101 | - $license_server, |
|
1102 | - // plugin slug(s) |
|
1103 | - array( |
|
1104 | - 'premium' => array('p' => $settings['pue_options']['pue_plugin_slug']), |
|
1105 | - 'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'), |
|
1106 | - ), |
|
1107 | - // options |
|
1108 | - array( |
|
1109 | - 'apikey' => EE_Registry::instance()->NET_CFG->core->site_license_key, |
|
1110 | - 'lang_domain' => 'event_espresso', |
|
1111 | - 'checkPeriod' => $settings['pue_options']['checkPeriod'], |
|
1112 | - 'option_key' => 'ee_site_license_key', |
|
1113 | - 'options_page_slug' => 'event_espresso', |
|
1114 | - 'plugin_basename' => $settings['pue_options']['plugin_basename'], |
|
1115 | - // if use_wp_update is TRUE it means you want FREE versions of the plugin to be updated from WP |
|
1116 | - 'use_wp_update' => $settings['pue_options']['use_wp_update'], |
|
1117 | - ) |
|
1118 | - ); |
|
1119 | - } |
|
1120 | - } |
|
1121 | - } |
|
1082 | + /** |
|
1083 | + * load_pue_update - Update notifications |
|
1084 | + * |
|
1085 | + * @return void |
|
1086 | + * @throws InvalidArgumentException |
|
1087 | + * @throws InvalidDataTypeException |
|
1088 | + * @throws InvalidInterfaceException |
|
1089 | + */ |
|
1090 | + public static function load_pue_update() |
|
1091 | + { |
|
1092 | + // load PUE client |
|
1093 | + require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php'; |
|
1094 | + $license_server = defined('PUE_UPDATES_ENDPOINT') ? PUE_UPDATES_ENDPOINT : 'https://eventespresso.com'; |
|
1095 | + // cycle thru settings |
|
1096 | + foreach (self::$_settings as $settings) { |
|
1097 | + if (! empty($settings['pue_options'])) { |
|
1098 | + // initiate the class and start the plugin update engine! |
|
1099 | + new PluginUpdateEngineChecker( |
|
1100 | + // host file URL |
|
1101 | + $license_server, |
|
1102 | + // plugin slug(s) |
|
1103 | + array( |
|
1104 | + 'premium' => array('p' => $settings['pue_options']['pue_plugin_slug']), |
|
1105 | + 'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'), |
|
1106 | + ), |
|
1107 | + // options |
|
1108 | + array( |
|
1109 | + 'apikey' => EE_Registry::instance()->NET_CFG->core->site_license_key, |
|
1110 | + 'lang_domain' => 'event_espresso', |
|
1111 | + 'checkPeriod' => $settings['pue_options']['checkPeriod'], |
|
1112 | + 'option_key' => 'ee_site_license_key', |
|
1113 | + 'options_page_slug' => 'event_espresso', |
|
1114 | + 'plugin_basename' => $settings['pue_options']['plugin_basename'], |
|
1115 | + // if use_wp_update is TRUE it means you want FREE versions of the plugin to be updated from WP |
|
1116 | + 'use_wp_update' => $settings['pue_options']['use_wp_update'], |
|
1117 | + ) |
|
1118 | + ); |
|
1119 | + } |
|
1120 | + } |
|
1121 | + } |
|
1122 | 1122 | |
1123 | 1123 | |
1124 | - /** |
|
1125 | - * Callback for EE_Brewing_Regular__messages_caf hook used to register message types. |
|
1126 | - * |
|
1127 | - * @since 4.4.0 |
|
1128 | - * @return void |
|
1129 | - * @throws EE_Error |
|
1130 | - */ |
|
1131 | - public static function register_message_types() |
|
1132 | - { |
|
1133 | - foreach (self::$_settings as $addon_name => $settings) { |
|
1134 | - if (! empty($settings['message_types'])) { |
|
1135 | - foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) { |
|
1136 | - EE_Register_Message_Type::register($message_type, $message_type_settings); |
|
1137 | - } |
|
1138 | - } |
|
1139 | - } |
|
1140 | - } |
|
1124 | + /** |
|
1125 | + * Callback for EE_Brewing_Regular__messages_caf hook used to register message types. |
|
1126 | + * |
|
1127 | + * @since 4.4.0 |
|
1128 | + * @return void |
|
1129 | + * @throws EE_Error |
|
1130 | + */ |
|
1131 | + public static function register_message_types() |
|
1132 | + { |
|
1133 | + foreach (self::$_settings as $addon_name => $settings) { |
|
1134 | + if (! empty($settings['message_types'])) { |
|
1135 | + foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) { |
|
1136 | + EE_Register_Message_Type::register($message_type, $message_type_settings); |
|
1137 | + } |
|
1138 | + } |
|
1139 | + } |
|
1140 | + } |
|
1141 | 1141 | |
1142 | 1142 | |
1143 | - /** |
|
1144 | - * This deregisters an addon that was previously registered with a specific addon_name. |
|
1145 | - * |
|
1146 | - * @since 4.3.0 |
|
1147 | - * @param string $addon_name the name for the addon that was previously registered |
|
1148 | - * @throws DomainException |
|
1149 | - * @throws EE_Error |
|
1150 | - * @throws InvalidArgumentException |
|
1151 | - * @throws InvalidDataTypeException |
|
1152 | - * @throws InvalidInterfaceException |
|
1153 | - */ |
|
1154 | - public static function deregister($addon_name = null) |
|
1155 | - { |
|
1156 | - if (isset(self::$_settings[ $addon_name ]['class_name'])) { |
|
1157 | - try { |
|
1158 | - do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name); |
|
1159 | - $class_name = self::$_settings[ $addon_name ]['class_name']; |
|
1160 | - if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) { |
|
1161 | - // setup DMS |
|
1162 | - EE_Register_Data_Migration_Scripts::deregister($addon_name); |
|
1163 | - } |
|
1164 | - if (! empty(self::$_settings[ $addon_name ]['admin_path'])) { |
|
1165 | - // register admin page |
|
1166 | - EE_Register_Admin_Page::deregister($addon_name); |
|
1167 | - } |
|
1168 | - if (! empty(self::$_settings[ $addon_name ]['module_paths'])) { |
|
1169 | - // add to list of modules to be registered |
|
1170 | - EE_Register_Module::deregister($addon_name); |
|
1171 | - } |
|
1172 | - if (! empty(self::$_settings[ $addon_name ]['shortcode_paths']) |
|
1173 | - || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns']) |
|
1174 | - ) { |
|
1175 | - // add to list of shortcodes to be registered |
|
1176 | - EE_Register_Shortcode::deregister($addon_name); |
|
1177 | - } |
|
1178 | - if (! empty(self::$_settings[ $addon_name ]['config_class'])) { |
|
1179 | - // if config_class present let's register config. |
|
1180 | - EE_Register_Config::deregister(self::$_settings[ $addon_name ]['config_class']); |
|
1181 | - } |
|
1182 | - if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) { |
|
1183 | - // add to list of widgets to be registered |
|
1184 | - EE_Register_Widget::deregister($addon_name); |
|
1185 | - } |
|
1186 | - if (! empty(self::$_settings[ $addon_name ]['model_paths']) |
|
1187 | - || ! empty(self::$_settings[ $addon_name ]['class_paths']) |
|
1188 | - ) { |
|
1189 | - // add to list of shortcodes to be registered |
|
1190 | - EE_Register_Model::deregister($addon_name); |
|
1191 | - } |
|
1192 | - if (! empty(self::$_settings[ $addon_name ]['model_extension_paths']) |
|
1193 | - || ! empty(self::$_settings[ $addon_name ]['class_extension_paths']) |
|
1194 | - ) { |
|
1195 | - // add to list of shortcodes to be registered |
|
1196 | - EE_Register_Model_Extensions::deregister($addon_name); |
|
1197 | - } |
|
1198 | - if (! empty(self::$_settings[ $addon_name ]['message_types'])) { |
|
1199 | - foreach ((array) self::$_settings[ $addon_name ]['message_types'] as $message_type => $message_type_settings) { |
|
1200 | - EE_Register_Message_Type::deregister($message_type); |
|
1201 | - } |
|
1202 | - } |
|
1203 | - // deregister capabilities for addon |
|
1204 | - if (! empty(self::$_settings[ $addon_name ]['capabilities']) |
|
1205 | - || ! empty(self::$_settings[ $addon_name ]['capability_maps']) |
|
1206 | - ) { |
|
1207 | - EE_Register_Capabilities::deregister($addon_name); |
|
1208 | - } |
|
1209 | - // deregister custom_post_types for addon |
|
1210 | - if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])) { |
|
1211 | - EE_Register_CPT::deregister($addon_name); |
|
1212 | - } |
|
1213 | - if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) { |
|
1214 | - EE_Register_Payment_Method::deregister($addon_name); |
|
1215 | - } |
|
1216 | - $addon = EE_Registry::instance()->getAddon($class_name); |
|
1217 | - if ($addon instanceof EE_Addon) { |
|
1218 | - remove_action( |
|
1219 | - 'deactivate_' . $addon->get_main_plugin_file_basename(), |
|
1220 | - array($addon, 'deactivation') |
|
1221 | - ); |
|
1222 | - remove_action( |
|
1223 | - 'AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
1224 | - array($addon, 'initialize_db_if_no_migrations_required') |
|
1225 | - ); |
|
1226 | - // remove `after_registration` call |
|
1227 | - remove_action( |
|
1228 | - 'AHEE__EE_System__load_espresso_addons__complete', |
|
1229 | - array($addon, 'after_registration'), |
|
1230 | - 999 |
|
1231 | - ); |
|
1232 | - } |
|
1233 | - EE_Registry::instance()->removeAddon($class_name); |
|
1234 | - } catch (OutOfBoundsException $addon_not_yet_registered_exception) { |
|
1235 | - // the add-on was not yet registered in the registry, |
|
1236 | - // so RegistryContainer::__get() throws this exception. |
|
1237 | - // also no need to worry about this or log it, |
|
1238 | - // it's ok to deregister an add-on before its registered in the registry |
|
1239 | - } catch (Exception $e) { |
|
1240 | - new ExceptionLogger($e); |
|
1241 | - } |
|
1242 | - unset(self::$_settings[ $addon_name ]); |
|
1243 | - do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name); |
|
1244 | - } |
|
1245 | - } |
|
1143 | + /** |
|
1144 | + * This deregisters an addon that was previously registered with a specific addon_name. |
|
1145 | + * |
|
1146 | + * @since 4.3.0 |
|
1147 | + * @param string $addon_name the name for the addon that was previously registered |
|
1148 | + * @throws DomainException |
|
1149 | + * @throws EE_Error |
|
1150 | + * @throws InvalidArgumentException |
|
1151 | + * @throws InvalidDataTypeException |
|
1152 | + * @throws InvalidInterfaceException |
|
1153 | + */ |
|
1154 | + public static function deregister($addon_name = null) |
|
1155 | + { |
|
1156 | + if (isset(self::$_settings[ $addon_name ]['class_name'])) { |
|
1157 | + try { |
|
1158 | + do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name); |
|
1159 | + $class_name = self::$_settings[ $addon_name ]['class_name']; |
|
1160 | + if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) { |
|
1161 | + // setup DMS |
|
1162 | + EE_Register_Data_Migration_Scripts::deregister($addon_name); |
|
1163 | + } |
|
1164 | + if (! empty(self::$_settings[ $addon_name ]['admin_path'])) { |
|
1165 | + // register admin page |
|
1166 | + EE_Register_Admin_Page::deregister($addon_name); |
|
1167 | + } |
|
1168 | + if (! empty(self::$_settings[ $addon_name ]['module_paths'])) { |
|
1169 | + // add to list of modules to be registered |
|
1170 | + EE_Register_Module::deregister($addon_name); |
|
1171 | + } |
|
1172 | + if (! empty(self::$_settings[ $addon_name ]['shortcode_paths']) |
|
1173 | + || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns']) |
|
1174 | + ) { |
|
1175 | + // add to list of shortcodes to be registered |
|
1176 | + EE_Register_Shortcode::deregister($addon_name); |
|
1177 | + } |
|
1178 | + if (! empty(self::$_settings[ $addon_name ]['config_class'])) { |
|
1179 | + // if config_class present let's register config. |
|
1180 | + EE_Register_Config::deregister(self::$_settings[ $addon_name ]['config_class']); |
|
1181 | + } |
|
1182 | + if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) { |
|
1183 | + // add to list of widgets to be registered |
|
1184 | + EE_Register_Widget::deregister($addon_name); |
|
1185 | + } |
|
1186 | + if (! empty(self::$_settings[ $addon_name ]['model_paths']) |
|
1187 | + || ! empty(self::$_settings[ $addon_name ]['class_paths']) |
|
1188 | + ) { |
|
1189 | + // add to list of shortcodes to be registered |
|
1190 | + EE_Register_Model::deregister($addon_name); |
|
1191 | + } |
|
1192 | + if (! empty(self::$_settings[ $addon_name ]['model_extension_paths']) |
|
1193 | + || ! empty(self::$_settings[ $addon_name ]['class_extension_paths']) |
|
1194 | + ) { |
|
1195 | + // add to list of shortcodes to be registered |
|
1196 | + EE_Register_Model_Extensions::deregister($addon_name); |
|
1197 | + } |
|
1198 | + if (! empty(self::$_settings[ $addon_name ]['message_types'])) { |
|
1199 | + foreach ((array) self::$_settings[ $addon_name ]['message_types'] as $message_type => $message_type_settings) { |
|
1200 | + EE_Register_Message_Type::deregister($message_type); |
|
1201 | + } |
|
1202 | + } |
|
1203 | + // deregister capabilities for addon |
|
1204 | + if (! empty(self::$_settings[ $addon_name ]['capabilities']) |
|
1205 | + || ! empty(self::$_settings[ $addon_name ]['capability_maps']) |
|
1206 | + ) { |
|
1207 | + EE_Register_Capabilities::deregister($addon_name); |
|
1208 | + } |
|
1209 | + // deregister custom_post_types for addon |
|
1210 | + if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])) { |
|
1211 | + EE_Register_CPT::deregister($addon_name); |
|
1212 | + } |
|
1213 | + if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) { |
|
1214 | + EE_Register_Payment_Method::deregister($addon_name); |
|
1215 | + } |
|
1216 | + $addon = EE_Registry::instance()->getAddon($class_name); |
|
1217 | + if ($addon instanceof EE_Addon) { |
|
1218 | + remove_action( |
|
1219 | + 'deactivate_' . $addon->get_main_plugin_file_basename(), |
|
1220 | + array($addon, 'deactivation') |
|
1221 | + ); |
|
1222 | + remove_action( |
|
1223 | + 'AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
1224 | + array($addon, 'initialize_db_if_no_migrations_required') |
|
1225 | + ); |
|
1226 | + // remove `after_registration` call |
|
1227 | + remove_action( |
|
1228 | + 'AHEE__EE_System__load_espresso_addons__complete', |
|
1229 | + array($addon, 'after_registration'), |
|
1230 | + 999 |
|
1231 | + ); |
|
1232 | + } |
|
1233 | + EE_Registry::instance()->removeAddon($class_name); |
|
1234 | + } catch (OutOfBoundsException $addon_not_yet_registered_exception) { |
|
1235 | + // the add-on was not yet registered in the registry, |
|
1236 | + // so RegistryContainer::__get() throws this exception. |
|
1237 | + // also no need to worry about this or log it, |
|
1238 | + // it's ok to deregister an add-on before its registered in the registry |
|
1239 | + } catch (Exception $e) { |
|
1240 | + new ExceptionLogger($e); |
|
1241 | + } |
|
1242 | + unset(self::$_settings[ $addon_name ]); |
|
1243 | + do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name); |
|
1244 | + } |
|
1245 | + } |
|
1246 | 1246 | } |
@@ -69,15 +69,15 @@ discard block |
||
69 | 69 | // offsets: 0 . 1 . 2 . 3 . 4 |
70 | 70 | $version_parts = explode('.', $min_core_version); |
71 | 71 | // check they specified the micro version (after 2nd period) |
72 | - if (! isset($version_parts[2])) { |
|
72 | + if ( ! isset($version_parts[2])) { |
|
73 | 73 | $version_parts[2] = '0'; |
74 | 74 | } |
75 | 75 | // if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible |
76 | 76 | // soon we can assume that's 'rc', but this current version is 'alpha' |
77 | - if (! isset($version_parts[3])) { |
|
77 | + if ( ! isset($version_parts[3])) { |
|
78 | 78 | $version_parts[3] = 'dev'; |
79 | 79 | } |
80 | - if (! isset($version_parts[4])) { |
|
80 | + if ( ! isset($version_parts[4])) { |
|
81 | 81 | $version_parts[4] = '000'; |
82 | 82 | } |
83 | 83 | return implode('.', $version_parts); |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | // setup PUE |
265 | 265 | EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args); |
266 | 266 | // does this addon work with this version of core or WordPress ? |
267 | - if (! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) { |
|
267 | + if ( ! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) { |
|
268 | 268 | return; |
269 | 269 | } |
270 | 270 | // register namespaces |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | ) |
329 | 329 | ); |
330 | 330 | } |
331 | - if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) { |
|
331 | + if ( ! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) { |
|
332 | 332 | throw new EE_Error( |
333 | 333 | sprintf( |
334 | 334 | __( |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | ); |
341 | 341 | } |
342 | 342 | // check that addon has not already been registered with that name |
343 | - if (isset(self::$_settings[ $addon_name ]) && ! did_action('activate_plugin')) { |
|
343 | + if (isset(self::$_settings[$addon_name]) && ! did_action('activate_plugin')) { |
|
344 | 344 | throw new EE_Error( |
345 | 345 | sprintf( |
346 | 346 | __( |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | // check if classname is fully qualified or is a legacy classname already prefixed with 'EE_' |
373 | 373 | return strpos($class_name, '\\') || strpos($class_name, 'EE_') === 0 |
374 | 374 | ? $class_name |
375 | - : 'EE_' . $class_name; |
|
375 | + : 'EE_'.$class_name; |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | |
@@ -539,9 +539,9 @@ discard block |
||
539 | 539 | global $wp_version; |
540 | 540 | $incompatibility_message = ''; |
541 | 541 | // check whether this addon version is compatible with EE core |
542 | - if (isset(EE_Register_Addon::$_incompatible_addons[ $addon_name ]) |
|
542 | + if (isset(EE_Register_Addon::$_incompatible_addons[$addon_name]) |
|
543 | 543 | && ! self::_meets_min_core_version_requirement( |
544 | - EE_Register_Addon::$_incompatible_addons[ $addon_name ], |
|
544 | + EE_Register_Addon::$_incompatible_addons[$addon_name], |
|
545 | 545 | $addon_settings['version'] |
546 | 546 | ) |
547 | 547 | ) { |
@@ -552,11 +552,11 @@ discard block |
||
552 | 552 | ), |
553 | 553 | $addon_name, |
554 | 554 | '<br />', |
555 | - EE_Register_Addon::$_incompatible_addons[ $addon_name ], |
|
555 | + EE_Register_Addon::$_incompatible_addons[$addon_name], |
|
556 | 556 | '<span style="font-weight: bold; color: #D54E21;">', |
557 | 557 | '</span><br />' |
558 | 558 | ); |
559 | - } elseif (! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version()) |
|
559 | + } elseif ( ! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version()) |
|
560 | 560 | ) { |
561 | 561 | $incompatibility_message = sprintf( |
562 | 562 | __( |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | '</span><br />' |
584 | 584 | ); |
585 | 585 | } |
586 | - if (! empty($incompatibility_message)) { |
|
586 | + if ( ! empty($incompatibility_message)) { |
|
587 | 587 | // remove 'activate' from the REQUEST |
588 | 588 | // so WP doesn't erroneously tell the user the plugin activated fine when it didn't |
589 | 589 | unset($_GET['activate'], $_REQUEST['activate']); |
@@ -611,11 +611,11 @@ discard block |
||
611 | 611 | */ |
612 | 612 | private static function _parse_pue_options($addon_name, $class_name, array $setup_args) |
613 | 613 | { |
614 | - if (! empty($setup_args['pue_options'])) { |
|
615 | - self::$_settings[ $addon_name ]['pue_options'] = array( |
|
614 | + if ( ! empty($setup_args['pue_options'])) { |
|
615 | + self::$_settings[$addon_name]['pue_options'] = array( |
|
616 | 616 | 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug']) |
617 | 617 | ? (string) $setup_args['pue_options']['pue_plugin_slug'] |
618 | - : 'espresso_' . strtolower($class_name), |
|
618 | + : 'espresso_'.strtolower($class_name), |
|
619 | 619 | 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename']) |
620 | 620 | ? (string) $setup_args['pue_options']['plugin_basename'] |
621 | 621 | : plugin_basename($setup_args['main_file_path']), |
@@ -674,12 +674,12 @@ discard block |
||
674 | 674 | // (as the newly-activated addon wasn't around the first time addons were registered). |
675 | 675 | // Note: the presence of pue_options in the addon registration options will initialize the $_settings |
676 | 676 | // property for the add-on, but the add-on is only partially initialized. Hence, the additional check. |
677 | - if (! isset(self::$_settings[ $addon_name ]) |
|
678 | - || (isset(self::$_settings[ $addon_name ]) |
|
679 | - && ! isset(self::$_settings[ $addon_name ]['class_name']) |
|
677 | + if ( ! isset(self::$_settings[$addon_name]) |
|
678 | + || (isset(self::$_settings[$addon_name]) |
|
679 | + && ! isset(self::$_settings[$addon_name]['class_name']) |
|
680 | 680 | ) |
681 | 681 | ) { |
682 | - self::$_settings[ $addon_name ] = $addon_settings; |
|
682 | + self::$_settings[$addon_name] = $addon_settings; |
|
683 | 683 | $addon = self::_load_and_init_addon_class($addon_name); |
684 | 684 | $addon->set_activation_indicator_option(); |
685 | 685 | // dont bother setting up the rest of the addon. |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | return true; |
689 | 689 | } |
690 | 690 | // make sure this was called in the right place! |
691 | - if (! did_action('AHEE__EE_System__load_espresso_addons') |
|
691 | + if ( ! did_action('AHEE__EE_System__load_espresso_addons') |
|
692 | 692 | || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
693 | 693 | ) { |
694 | 694 | EE_Error::doing_it_wrong( |
@@ -704,10 +704,10 @@ discard block |
||
704 | 704 | ); |
705 | 705 | } |
706 | 706 | // make sure addon settings are set correctly without overwriting anything existing |
707 | - if (isset(self::$_settings[ $addon_name ])) { |
|
708 | - self::$_settings[ $addon_name ] += $addon_settings; |
|
707 | + if (isset(self::$_settings[$addon_name])) { |
|
708 | + self::$_settings[$addon_name] += $addon_settings; |
|
709 | 709 | } else { |
710 | - self::$_settings[ $addon_name ] = $addon_settings; |
|
710 | + self::$_settings[$addon_name] = $addon_settings; |
|
711 | 711 | } |
712 | 712 | return false; |
713 | 713 | } |
@@ -720,13 +720,13 @@ discard block |
||
720 | 720 | */ |
721 | 721 | private static function _setup_autoloaders($addon_name) |
722 | 722 | { |
723 | - if (! empty(self::$_settings[ $addon_name ]['autoloader_paths'])) { |
|
723 | + if ( ! empty(self::$_settings[$addon_name]['autoloader_paths'])) { |
|
724 | 724 | // setup autoloader for single file |
725 | - EEH_Autoloader::instance()->register_autoloader(self::$_settings[ $addon_name ]['autoloader_paths']); |
|
725 | + EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']); |
|
726 | 726 | } |
727 | 727 | // setup autoloaders for folders |
728 | - if (! empty(self::$_settings[ $addon_name ]['autoloader_folders'])) { |
|
729 | - foreach ((array) self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder) { |
|
728 | + if ( ! empty(self::$_settings[$addon_name]['autoloader_folders'])) { |
|
729 | + foreach ((array) self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) { |
|
730 | 730 | EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder); |
731 | 731 | } |
732 | 732 | } |
@@ -743,26 +743,26 @@ discard block |
||
743 | 743 | private static function _register_models_and_extensions($addon_name) |
744 | 744 | { |
745 | 745 | // register new models |
746 | - if (! empty(self::$_settings[ $addon_name ]['model_paths']) |
|
747 | - || ! empty(self::$_settings[ $addon_name ]['class_paths']) |
|
746 | + if ( ! empty(self::$_settings[$addon_name]['model_paths']) |
|
747 | + || ! empty(self::$_settings[$addon_name]['class_paths']) |
|
748 | 748 | ) { |
749 | 749 | EE_Register_Model::register( |
750 | 750 | $addon_name, |
751 | 751 | array( |
752 | - 'model_paths' => self::$_settings[ $addon_name ]['model_paths'], |
|
753 | - 'class_paths' => self::$_settings[ $addon_name ]['class_paths'], |
|
752 | + 'model_paths' => self::$_settings[$addon_name]['model_paths'], |
|
753 | + 'class_paths' => self::$_settings[$addon_name]['class_paths'], |
|
754 | 754 | ) |
755 | 755 | ); |
756 | 756 | } |
757 | 757 | // register model extensions |
758 | - if (! empty(self::$_settings[ $addon_name ]['model_extension_paths']) |
|
759 | - || ! empty(self::$_settings[ $addon_name ]['class_extension_paths']) |
|
758 | + if ( ! empty(self::$_settings[$addon_name]['model_extension_paths']) |
|
759 | + || ! empty(self::$_settings[$addon_name]['class_extension_paths']) |
|
760 | 760 | ) { |
761 | 761 | EE_Register_Model_Extensions::register( |
762 | 762 | $addon_name, |
763 | 763 | array( |
764 | - 'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'], |
|
765 | - 'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'], |
|
764 | + 'model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'], |
|
765 | + 'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths'], |
|
766 | 766 | ) |
767 | 767 | ); |
768 | 768 | } |
@@ -777,10 +777,10 @@ discard block |
||
777 | 777 | private static function _register_data_migration_scripts($addon_name) |
778 | 778 | { |
779 | 779 | // setup DMS |
780 | - if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) { |
|
780 | + if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
781 | 781 | EE_Register_Data_Migration_Scripts::register( |
782 | 782 | $addon_name, |
783 | - array('dms_paths' => self::$_settings[ $addon_name ]['dms_paths']) |
|
783 | + array('dms_paths' => self::$_settings[$addon_name]['dms_paths']) |
|
784 | 784 | ); |
785 | 785 | } |
786 | 786 | } |
@@ -794,12 +794,12 @@ discard block |
||
794 | 794 | private static function _register_config($addon_name) |
795 | 795 | { |
796 | 796 | // if config_class is present let's register config. |
797 | - if (! empty(self::$_settings[ $addon_name ]['config_class'])) { |
|
797 | + if ( ! empty(self::$_settings[$addon_name]['config_class'])) { |
|
798 | 798 | EE_Register_Config::register( |
799 | - self::$_settings[ $addon_name ]['config_class'], |
|
799 | + self::$_settings[$addon_name]['config_class'], |
|
800 | 800 | array( |
801 | - 'config_section' => self::$_settings[ $addon_name ]['config_section'], |
|
802 | - 'config_name' => self::$_settings[ $addon_name ]['config_name'], |
|
801 | + 'config_section' => self::$_settings[$addon_name]['config_section'], |
|
802 | + 'config_name' => self::$_settings[$addon_name]['config_name'], |
|
803 | 803 | ) |
804 | 804 | ); |
805 | 805 | } |
@@ -813,10 +813,10 @@ discard block |
||
813 | 813 | */ |
814 | 814 | private static function _register_admin_pages($addon_name) |
815 | 815 | { |
816 | - if (! empty(self::$_settings[ $addon_name ]['admin_path'])) { |
|
816 | + if ( ! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
817 | 817 | EE_Register_Admin_Page::register( |
818 | 818 | $addon_name, |
819 | - array('page_path' => self::$_settings[ $addon_name ]['admin_path']) |
|
819 | + array('page_path' => self::$_settings[$addon_name]['admin_path']) |
|
820 | 820 | ); |
821 | 821 | } |
822 | 822 | } |
@@ -829,10 +829,10 @@ discard block |
||
829 | 829 | */ |
830 | 830 | private static function _register_modules($addon_name) |
831 | 831 | { |
832 | - if (! empty(self::$_settings[ $addon_name ]['module_paths'])) { |
|
832 | + if ( ! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
833 | 833 | EE_Register_Module::register( |
834 | 834 | $addon_name, |
835 | - array('module_paths' => self::$_settings[ $addon_name ]['module_paths']) |
|
835 | + array('module_paths' => self::$_settings[$addon_name]['module_paths']) |
|
836 | 836 | ); |
837 | 837 | } |
838 | 838 | } |
@@ -845,17 +845,17 @@ discard block |
||
845 | 845 | */ |
846 | 846 | private static function _register_shortcodes($addon_name) |
847 | 847 | { |
848 | - if (! empty(self::$_settings[ $addon_name ]['shortcode_paths']) |
|
849 | - || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns']) |
|
848 | + if ( ! empty(self::$_settings[$addon_name]['shortcode_paths']) |
|
849 | + || ! empty(self::$_settings[$addon_name]['shortcode_fqcns']) |
|
850 | 850 | ) { |
851 | 851 | EE_Register_Shortcode::register( |
852 | 852 | $addon_name, |
853 | 853 | array( |
854 | - 'shortcode_paths' => isset(self::$_settings[ $addon_name ]['shortcode_paths']) |
|
855 | - ? self::$_settings[ $addon_name ]['shortcode_paths'] |
|
854 | + 'shortcode_paths' => isset(self::$_settings[$addon_name]['shortcode_paths']) |
|
855 | + ? self::$_settings[$addon_name]['shortcode_paths'] |
|
856 | 856 | : array(), |
857 | - 'shortcode_fqcns' => isset(self::$_settings[ $addon_name ]['shortcode_fqcns']) |
|
858 | - ? self::$_settings[ $addon_name ]['shortcode_fqcns'] |
|
857 | + 'shortcode_fqcns' => isset(self::$_settings[$addon_name]['shortcode_fqcns']) |
|
858 | + ? self::$_settings[$addon_name]['shortcode_fqcns'] |
|
859 | 859 | : array(), |
860 | 860 | ) |
861 | 861 | ); |
@@ -870,10 +870,10 @@ discard block |
||
870 | 870 | */ |
871 | 871 | private static function _register_widgets($addon_name) |
872 | 872 | { |
873 | - if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) { |
|
873 | + if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
874 | 874 | EE_Register_Widget::register( |
875 | 875 | $addon_name, |
876 | - array('widget_paths' => self::$_settings[ $addon_name ]['widget_paths']) |
|
876 | + array('widget_paths' => self::$_settings[$addon_name]['widget_paths']) |
|
877 | 877 | ); |
878 | 878 | } |
879 | 879 | } |
@@ -886,12 +886,12 @@ discard block |
||
886 | 886 | */ |
887 | 887 | private static function _register_capabilities($addon_name) |
888 | 888 | { |
889 | - if (! empty(self::$_settings[ $addon_name ]['capabilities'])) { |
|
889 | + if ( ! empty(self::$_settings[$addon_name]['capabilities'])) { |
|
890 | 890 | EE_Register_Capabilities::register( |
891 | 891 | $addon_name, |
892 | 892 | array( |
893 | - 'capabilities' => self::$_settings[ $addon_name ]['capabilities'], |
|
894 | - 'capability_maps' => self::$_settings[ $addon_name ]['capability_maps'], |
|
893 | + 'capabilities' => self::$_settings[$addon_name]['capabilities'], |
|
894 | + 'capability_maps' => self::$_settings[$addon_name]['capability_maps'], |
|
895 | 895 | ) |
896 | 896 | ); |
897 | 897 | } |
@@ -905,7 +905,7 @@ discard block |
||
905 | 905 | */ |
906 | 906 | private static function _register_message_types($addon_name) |
907 | 907 | { |
908 | - if (! empty(self::$_settings[ $addon_name ]['message_types'])) { |
|
908 | + if ( ! empty(self::$_settings[$addon_name]['message_types'])) { |
|
909 | 909 | add_action( |
910 | 910 | 'EE_Brewing_Regular___messages_caf', |
911 | 911 | array('EE_Register_Addon', 'register_message_types') |
@@ -921,15 +921,15 @@ discard block |
||
921 | 921 | */ |
922 | 922 | private static function _register_custom_post_types($addon_name) |
923 | 923 | { |
924 | - if (! empty(self::$_settings[ $addon_name ]['custom_post_types']) |
|
925 | - || ! empty(self::$_settings[ $addon_name ]['custom_taxonomies']) |
|
924 | + if ( ! empty(self::$_settings[$addon_name]['custom_post_types']) |
|
925 | + || ! empty(self::$_settings[$addon_name]['custom_taxonomies']) |
|
926 | 926 | ) { |
927 | 927 | EE_Register_CPT::register( |
928 | 928 | $addon_name, |
929 | 929 | array( |
930 | - 'cpts' => self::$_settings[ $addon_name ]['custom_post_types'], |
|
931 | - 'cts' => self::$_settings[ $addon_name ]['custom_taxonomies'], |
|
932 | - 'default_terms' => self::$_settings[ $addon_name ]['default_terms'], |
|
930 | + 'cpts' => self::$_settings[$addon_name]['custom_post_types'], |
|
931 | + 'cts' => self::$_settings[$addon_name]['custom_taxonomies'], |
|
932 | + 'default_terms' => self::$_settings[$addon_name]['default_terms'], |
|
933 | 933 | ) |
934 | 934 | ); |
935 | 935 | } |
@@ -947,10 +947,10 @@ discard block |
||
947 | 947 | */ |
948 | 948 | private static function _register_payment_methods($addon_name) |
949 | 949 | { |
950 | - if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) { |
|
950 | + if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) { |
|
951 | 951 | EE_Register_Payment_Method::register( |
952 | 952 | $addon_name, |
953 | - array('payment_method_paths' => self::$_settings[ $addon_name ]['payment_method_paths']) |
|
953 | + array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths']) |
|
954 | 954 | ); |
955 | 955 | } |
956 | 956 | } |
@@ -967,10 +967,10 @@ discard block |
||
967 | 967 | */ |
968 | 968 | private static function registerPrivacyPolicies($addon_name) |
969 | 969 | { |
970 | - if (! empty(self::$_settings[ $addon_name ]['privacy_policies'])) { |
|
970 | + if ( ! empty(self::$_settings[$addon_name]['privacy_policies'])) { |
|
971 | 971 | EE_Register_Privacy_Policy::register( |
972 | 972 | $addon_name, |
973 | - self::$_settings[ $addon_name ]['privacy_policies'] |
|
973 | + self::$_settings[$addon_name]['privacy_policies'] |
|
974 | 974 | ); |
975 | 975 | } |
976 | 976 | } |
@@ -982,10 +982,10 @@ discard block |
||
982 | 982 | */ |
983 | 983 | private static function registerPersonalDataExporters($addon_name) |
984 | 984 | { |
985 | - if (! empty(self::$_settings[ $addon_name ]['personal_data_exporters'])) { |
|
985 | + if ( ! empty(self::$_settings[$addon_name]['personal_data_exporters'])) { |
|
986 | 986 | EE_Register_Personal_Data_Eraser::register( |
987 | 987 | $addon_name, |
988 | - self::$_settings[ $addon_name ]['personal_data_exporters'] |
|
988 | + self::$_settings[$addon_name]['personal_data_exporters'] |
|
989 | 989 | ); |
990 | 990 | } |
991 | 991 | } |
@@ -997,10 +997,10 @@ discard block |
||
997 | 997 | */ |
998 | 998 | private static function registerPersonalDataErasers($addon_name) |
999 | 999 | { |
1000 | - if (! empty(self::$_settings[ $addon_name ]['personal_data_erasers'])) { |
|
1000 | + if ( ! empty(self::$_settings[$addon_name]['personal_data_erasers'])) { |
|
1001 | 1001 | EE_Register_Personal_Data_Eraser::register( |
1002 | 1002 | $addon_name, |
1003 | - self::$_settings[ $addon_name ]['personal_data_erasers'] |
|
1003 | + self::$_settings[$addon_name]['personal_data_erasers'] |
|
1004 | 1004 | ); |
1005 | 1005 | } |
1006 | 1006 | } |
@@ -1021,7 +1021,7 @@ discard block |
||
1021 | 1021 | { |
1022 | 1022 | $loader = EventEspresso\core\services\loaders\LoaderFactory::getLoader(); |
1023 | 1023 | $addon = $loader->getShared( |
1024 | - self::$_settings[ $addon_name ]['class_name'], |
|
1024 | + self::$_settings[$addon_name]['class_name'], |
|
1025 | 1025 | array('EE_Registry::create(addon)' => true) |
1026 | 1026 | ); |
1027 | 1027 | // setter inject dep map if required |
@@ -1033,19 +1033,19 @@ discard block |
||
1033 | 1033 | && $addon->domain() === null |
1034 | 1034 | ) { |
1035 | 1035 | // using supplied Domain object |
1036 | - $domain = self::$_settings[ $addon_name ]['domain'] instanceof DomainInterface |
|
1037 | - ? self::$_settings[ $addon_name ]['domain'] |
|
1036 | + $domain = self::$_settings[$addon_name]['domain'] instanceof DomainInterface |
|
1037 | + ? self::$_settings[$addon_name]['domain'] |
|
1038 | 1038 | : null; |
1039 | 1039 | // or construct one using Domain FQCN |
1040 | - if ($domain === null && self::$_settings[ $addon_name ]['domain_fqcn'] !== '') { |
|
1040 | + if ($domain === null && self::$_settings[$addon_name]['domain_fqcn'] !== '') { |
|
1041 | 1041 | $domain = $loader->getShared( |
1042 | - self::$_settings[ $addon_name ]['domain_fqcn'], |
|
1042 | + self::$_settings[$addon_name]['domain_fqcn'], |
|
1043 | 1043 | array( |
1044 | 1044 | new EventEspresso\core\domain\values\FilePath( |
1045 | - self::$_settings[ $addon_name ]['main_file_path'] |
|
1045 | + self::$_settings[$addon_name]['main_file_path'] |
|
1046 | 1046 | ), |
1047 | 1047 | EventEspresso\core\domain\values\Version::fromString( |
1048 | - self::$_settings[ $addon_name ]['version'] |
|
1048 | + self::$_settings[$addon_name]['version'] |
|
1049 | 1049 | ), |
1050 | 1050 | ) |
1051 | 1051 | ); |
@@ -1055,24 +1055,24 @@ discard block |
||
1055 | 1055 | } |
1056 | 1056 | } |
1057 | 1057 | $addon->set_name($addon_name); |
1058 | - $addon->set_plugin_slug(self::$_settings[ $addon_name ]['plugin_slug']); |
|
1059 | - $addon->set_plugin_basename(self::$_settings[ $addon_name ]['plugin_basename']); |
|
1060 | - $addon->set_main_plugin_file(self::$_settings[ $addon_name ]['main_file_path']); |
|
1061 | - $addon->set_plugin_action_slug(self::$_settings[ $addon_name ]['plugin_action_slug']); |
|
1062 | - $addon->set_plugins_page_row(self::$_settings[ $addon_name ]['plugins_page_row']); |
|
1063 | - $addon->set_version(self::$_settings[ $addon_name ]['version']); |
|
1064 | - $addon->set_min_core_version(self::_effective_version(self::$_settings[ $addon_name ]['min_core_version'])); |
|
1065 | - $addon->set_config_section(self::$_settings[ $addon_name ]['config_section']); |
|
1066 | - $addon->set_config_class(self::$_settings[ $addon_name ]['config_class']); |
|
1067 | - $addon->set_config_name(self::$_settings[ $addon_name ]['config_name']); |
|
1058 | + $addon->set_plugin_slug(self::$_settings[$addon_name]['plugin_slug']); |
|
1059 | + $addon->set_plugin_basename(self::$_settings[$addon_name]['plugin_basename']); |
|
1060 | + $addon->set_main_plugin_file(self::$_settings[$addon_name]['main_file_path']); |
|
1061 | + $addon->set_plugin_action_slug(self::$_settings[$addon_name]['plugin_action_slug']); |
|
1062 | + $addon->set_plugins_page_row(self::$_settings[$addon_name]['plugins_page_row']); |
|
1063 | + $addon->set_version(self::$_settings[$addon_name]['version']); |
|
1064 | + $addon->set_min_core_version(self::_effective_version(self::$_settings[$addon_name]['min_core_version'])); |
|
1065 | + $addon->set_config_section(self::$_settings[$addon_name]['config_section']); |
|
1066 | + $addon->set_config_class(self::$_settings[$addon_name]['config_class']); |
|
1067 | + $addon->set_config_name(self::$_settings[$addon_name]['config_name']); |
|
1068 | 1068 | // unfortunately this can't be hooked in upon construction, because we don't have |
1069 | 1069 | // the plugin mainfile's path upon construction. |
1070 | 1070 | register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation')); |
1071 | 1071 | // call any additional admin_callback functions during load_admin_controller hook |
1072 | - if (! empty(self::$_settings[ $addon_name ]['admin_callback'])) { |
|
1072 | + if ( ! empty(self::$_settings[$addon_name]['admin_callback'])) { |
|
1073 | 1073 | add_action( |
1074 | 1074 | 'AHEE__EE_System__load_controllers__load_admin_controllers', |
1075 | - array($addon, self::$_settings[ $addon_name ]['admin_callback']) |
|
1075 | + array($addon, self::$_settings[$addon_name]['admin_callback']) |
|
1076 | 1076 | ); |
1077 | 1077 | } |
1078 | 1078 | return $addon; |
@@ -1090,11 +1090,11 @@ discard block |
||
1090 | 1090 | public static function load_pue_update() |
1091 | 1091 | { |
1092 | 1092 | // load PUE client |
1093 | - require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php'; |
|
1093 | + require_once EE_THIRD_PARTY.'pue'.DS.'pue-client.php'; |
|
1094 | 1094 | $license_server = defined('PUE_UPDATES_ENDPOINT') ? PUE_UPDATES_ENDPOINT : 'https://eventespresso.com'; |
1095 | 1095 | // cycle thru settings |
1096 | 1096 | foreach (self::$_settings as $settings) { |
1097 | - if (! empty($settings['pue_options'])) { |
|
1097 | + if ( ! empty($settings['pue_options'])) { |
|
1098 | 1098 | // initiate the class and start the plugin update engine! |
1099 | 1099 | new PluginUpdateEngineChecker( |
1100 | 1100 | // host file URL |
@@ -1102,7 +1102,7 @@ discard block |
||
1102 | 1102 | // plugin slug(s) |
1103 | 1103 | array( |
1104 | 1104 | 'premium' => array('p' => $settings['pue_options']['pue_plugin_slug']), |
1105 | - 'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'), |
|
1105 | + 'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'].'-pr'), |
|
1106 | 1106 | ), |
1107 | 1107 | // options |
1108 | 1108 | array( |
@@ -1131,7 +1131,7 @@ discard block |
||
1131 | 1131 | public static function register_message_types() |
1132 | 1132 | { |
1133 | 1133 | foreach (self::$_settings as $addon_name => $settings) { |
1134 | - if (! empty($settings['message_types'])) { |
|
1134 | + if ( ! empty($settings['message_types'])) { |
|
1135 | 1135 | foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) { |
1136 | 1136 | EE_Register_Message_Type::register($message_type, $message_type_settings); |
1137 | 1137 | } |
@@ -1153,70 +1153,70 @@ discard block |
||
1153 | 1153 | */ |
1154 | 1154 | public static function deregister($addon_name = null) |
1155 | 1155 | { |
1156 | - if (isset(self::$_settings[ $addon_name ]['class_name'])) { |
|
1156 | + if (isset(self::$_settings[$addon_name]['class_name'])) { |
|
1157 | 1157 | try { |
1158 | 1158 | do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name); |
1159 | - $class_name = self::$_settings[ $addon_name ]['class_name']; |
|
1160 | - if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) { |
|
1159 | + $class_name = self::$_settings[$addon_name]['class_name']; |
|
1160 | + if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
1161 | 1161 | // setup DMS |
1162 | 1162 | EE_Register_Data_Migration_Scripts::deregister($addon_name); |
1163 | 1163 | } |
1164 | - if (! empty(self::$_settings[ $addon_name ]['admin_path'])) { |
|
1164 | + if ( ! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
1165 | 1165 | // register admin page |
1166 | 1166 | EE_Register_Admin_Page::deregister($addon_name); |
1167 | 1167 | } |
1168 | - if (! empty(self::$_settings[ $addon_name ]['module_paths'])) { |
|
1168 | + if ( ! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
1169 | 1169 | // add to list of modules to be registered |
1170 | 1170 | EE_Register_Module::deregister($addon_name); |
1171 | 1171 | } |
1172 | - if (! empty(self::$_settings[ $addon_name ]['shortcode_paths']) |
|
1173 | - || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns']) |
|
1172 | + if ( ! empty(self::$_settings[$addon_name]['shortcode_paths']) |
|
1173 | + || ! empty(self::$_settings[$addon_name]['shortcode_fqcns']) |
|
1174 | 1174 | ) { |
1175 | 1175 | // add to list of shortcodes to be registered |
1176 | 1176 | EE_Register_Shortcode::deregister($addon_name); |
1177 | 1177 | } |
1178 | - if (! empty(self::$_settings[ $addon_name ]['config_class'])) { |
|
1178 | + if ( ! empty(self::$_settings[$addon_name]['config_class'])) { |
|
1179 | 1179 | // if config_class present let's register config. |
1180 | - EE_Register_Config::deregister(self::$_settings[ $addon_name ]['config_class']); |
|
1180 | + EE_Register_Config::deregister(self::$_settings[$addon_name]['config_class']); |
|
1181 | 1181 | } |
1182 | - if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) { |
|
1182 | + if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
1183 | 1183 | // add to list of widgets to be registered |
1184 | 1184 | EE_Register_Widget::deregister($addon_name); |
1185 | 1185 | } |
1186 | - if (! empty(self::$_settings[ $addon_name ]['model_paths']) |
|
1187 | - || ! empty(self::$_settings[ $addon_name ]['class_paths']) |
|
1186 | + if ( ! empty(self::$_settings[$addon_name]['model_paths']) |
|
1187 | + || ! empty(self::$_settings[$addon_name]['class_paths']) |
|
1188 | 1188 | ) { |
1189 | 1189 | // add to list of shortcodes to be registered |
1190 | 1190 | EE_Register_Model::deregister($addon_name); |
1191 | 1191 | } |
1192 | - if (! empty(self::$_settings[ $addon_name ]['model_extension_paths']) |
|
1193 | - || ! empty(self::$_settings[ $addon_name ]['class_extension_paths']) |
|
1192 | + if ( ! empty(self::$_settings[$addon_name]['model_extension_paths']) |
|
1193 | + || ! empty(self::$_settings[$addon_name]['class_extension_paths']) |
|
1194 | 1194 | ) { |
1195 | 1195 | // add to list of shortcodes to be registered |
1196 | 1196 | EE_Register_Model_Extensions::deregister($addon_name); |
1197 | 1197 | } |
1198 | - if (! empty(self::$_settings[ $addon_name ]['message_types'])) { |
|
1199 | - foreach ((array) self::$_settings[ $addon_name ]['message_types'] as $message_type => $message_type_settings) { |
|
1198 | + if ( ! empty(self::$_settings[$addon_name]['message_types'])) { |
|
1199 | + foreach ((array) self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings) { |
|
1200 | 1200 | EE_Register_Message_Type::deregister($message_type); |
1201 | 1201 | } |
1202 | 1202 | } |
1203 | 1203 | // deregister capabilities for addon |
1204 | - if (! empty(self::$_settings[ $addon_name ]['capabilities']) |
|
1205 | - || ! empty(self::$_settings[ $addon_name ]['capability_maps']) |
|
1204 | + if ( ! empty(self::$_settings[$addon_name]['capabilities']) |
|
1205 | + || ! empty(self::$_settings[$addon_name]['capability_maps']) |
|
1206 | 1206 | ) { |
1207 | 1207 | EE_Register_Capabilities::deregister($addon_name); |
1208 | 1208 | } |
1209 | 1209 | // deregister custom_post_types for addon |
1210 | - if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])) { |
|
1210 | + if ( ! empty(self::$_settings[$addon_name]['custom_post_types'])) { |
|
1211 | 1211 | EE_Register_CPT::deregister($addon_name); |
1212 | 1212 | } |
1213 | - if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) { |
|
1213 | + if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) { |
|
1214 | 1214 | EE_Register_Payment_Method::deregister($addon_name); |
1215 | 1215 | } |
1216 | 1216 | $addon = EE_Registry::instance()->getAddon($class_name); |
1217 | 1217 | if ($addon instanceof EE_Addon) { |
1218 | 1218 | remove_action( |
1219 | - 'deactivate_' . $addon->get_main_plugin_file_basename(), |
|
1219 | + 'deactivate_'.$addon->get_main_plugin_file_basename(), |
|
1220 | 1220 | array($addon, 'deactivation') |
1221 | 1221 | ); |
1222 | 1222 | remove_action( |
@@ -1239,7 +1239,7 @@ discard block |
||
1239 | 1239 | } catch (Exception $e) { |
1240 | 1240 | new ExceptionLogger($e); |
1241 | 1241 | } |
1242 | - unset(self::$_settings[ $addon_name ]); |
|
1242 | + unset(self::$_settings[$addon_name]); |
|
1243 | 1243 | do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name); |
1244 | 1244 | } |
1245 | 1245 | } |