@@ -44,530 +44,530 @@ |
||
44 | 44 | class OrganizationSettings extends FormHandler |
45 | 45 | { |
46 | 46 | |
47 | - /** |
|
48 | - * @var EE_Organization_Config |
|
49 | - */ |
|
50 | - protected $organization_config; |
|
47 | + /** |
|
48 | + * @var EE_Organization_Config |
|
49 | + */ |
|
50 | + protected $organization_config; |
|
51 | 51 | |
52 | - /** |
|
53 | - * @var EE_Core_Config |
|
54 | - */ |
|
55 | - protected $core_config; |
|
52 | + /** |
|
53 | + * @var EE_Core_Config |
|
54 | + */ |
|
55 | + protected $core_config; |
|
56 | 56 | |
57 | 57 | |
58 | - /** |
|
59 | - * @var EE_Network_Core_Config |
|
60 | - */ |
|
61 | - protected $network_core_config; |
|
58 | + /** |
|
59 | + * @var EE_Network_Core_Config |
|
60 | + */ |
|
61 | + protected $network_core_config; |
|
62 | 62 | |
63 | - /** |
|
64 | - * @var CountrySubRegionDao $countrySubRegionDao |
|
65 | - */ |
|
66 | - protected $countrySubRegionDao; |
|
63 | + /** |
|
64 | + * @var CountrySubRegionDao $countrySubRegionDao |
|
65 | + */ |
|
66 | + protected $countrySubRegionDao; |
|
67 | 67 | |
68 | - /** |
|
69 | - * Form constructor. |
|
70 | - * |
|
71 | - * @param EE_Registry $registry |
|
72 | - * @param EE_Organization_Config $organization_config |
|
73 | - * @param EE_Core_Config $core_config |
|
74 | - * @param EE_Network_Core_Config $network_core_config |
|
75 | - * @param CountrySubRegionDao $countrySubRegionDao |
|
76 | - * @throws InvalidArgumentException |
|
77 | - * @throws InvalidDataTypeException |
|
78 | - * @throws DomainException |
|
79 | - */ |
|
80 | - public function __construct( |
|
81 | - EE_Registry $registry, |
|
82 | - EE_Organization_Config $organization_config, |
|
83 | - EE_Core_Config $core_config, |
|
84 | - EE_Network_Core_Config $network_core_config, |
|
85 | - CountrySubRegionDao $countrySubRegionDao |
|
86 | - ) { |
|
87 | - $this->organization_config = $organization_config; |
|
88 | - $this->core_config = $core_config; |
|
89 | - $this->network_core_config = $network_core_config; |
|
90 | - $this->countrySubRegionDao = $countrySubRegionDao; |
|
91 | - parent::__construct( |
|
92 | - esc_html__('Your Organization Settings', 'event_espresso'), |
|
93 | - esc_html__('Your Organization Settings', 'event_espresso'), |
|
94 | - 'organization_settings', |
|
95 | - '', |
|
96 | - FormHandler::DO_NOT_SETUP_FORM, |
|
97 | - $registry |
|
98 | - ); |
|
99 | - } |
|
68 | + /** |
|
69 | + * Form constructor. |
|
70 | + * |
|
71 | + * @param EE_Registry $registry |
|
72 | + * @param EE_Organization_Config $organization_config |
|
73 | + * @param EE_Core_Config $core_config |
|
74 | + * @param EE_Network_Core_Config $network_core_config |
|
75 | + * @param CountrySubRegionDao $countrySubRegionDao |
|
76 | + * @throws InvalidArgumentException |
|
77 | + * @throws InvalidDataTypeException |
|
78 | + * @throws DomainException |
|
79 | + */ |
|
80 | + public function __construct( |
|
81 | + EE_Registry $registry, |
|
82 | + EE_Organization_Config $organization_config, |
|
83 | + EE_Core_Config $core_config, |
|
84 | + EE_Network_Core_Config $network_core_config, |
|
85 | + CountrySubRegionDao $countrySubRegionDao |
|
86 | + ) { |
|
87 | + $this->organization_config = $organization_config; |
|
88 | + $this->core_config = $core_config; |
|
89 | + $this->network_core_config = $network_core_config; |
|
90 | + $this->countrySubRegionDao = $countrySubRegionDao; |
|
91 | + parent::__construct( |
|
92 | + esc_html__('Your Organization Settings', 'event_espresso'), |
|
93 | + esc_html__('Your Organization Settings', 'event_espresso'), |
|
94 | + 'organization_settings', |
|
95 | + '', |
|
96 | + FormHandler::DO_NOT_SETUP_FORM, |
|
97 | + $registry |
|
98 | + ); |
|
99 | + } |
|
100 | 100 | |
101 | 101 | |
102 | - /** |
|
103 | - * creates and returns the actual form |
|
104 | - * |
|
105 | - * @return EE_Form_Section_Proper |
|
106 | - * @throws EE_Error |
|
107 | - * @throws InvalidArgumentException |
|
108 | - * @throws InvalidDataTypeException |
|
109 | - * @throws InvalidInterfaceException |
|
110 | - * @throws ReflectionException |
|
111 | - */ |
|
112 | - public function generate() |
|
113 | - { |
|
114 | - $has_sub_regions = EEM_State::instance()->count( |
|
115 | - array(array('Country.CNT_ISO' => $this->organization_config->CNT_ISO)) |
|
116 | - ); |
|
117 | - $form = new EE_Form_Section_Proper( |
|
118 | - array( |
|
119 | - 'name' => 'organization_settings', |
|
120 | - 'html_id' => 'organization_settings', |
|
121 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
122 | - 'subsections' => array( |
|
123 | - 'contact_information_hdr' => new EE_Form_Section_HTML( |
|
124 | - EEH_HTML::h2( |
|
125 | - esc_html__('Contact Information', 'event_espresso') |
|
126 | - . ' ' |
|
127 | - . EEH_HTML::span(EEH_Template::get_help_tab_link('contact_info_info')), |
|
128 | - '', |
|
129 | - 'contact-information-hdr' |
|
130 | - ) |
|
131 | - ), |
|
132 | - 'organization_name' => new EE_Text_Input( |
|
133 | - array( |
|
134 | - 'html_name' => 'organization_name', |
|
135 | - 'html_label_text' => esc_html__('Organization Name', 'event_espresso'), |
|
136 | - 'html_help_text' => esc_html__( |
|
137 | - 'Displayed on all emails and invoices.', |
|
138 | - 'event_espresso' |
|
139 | - ), |
|
140 | - 'default' => $this->organization_config->get_pretty('name'), |
|
141 | - 'required' => false, |
|
142 | - ) |
|
143 | - ), |
|
144 | - 'organization_address_1' => new EE_Text_Input( |
|
145 | - array( |
|
146 | - 'html_name' => 'organization_address_1', |
|
147 | - 'html_label_text' => esc_html__('Street Address', 'event_espresso'), |
|
148 | - 'default' => $this->organization_config->get_pretty('address_1'), |
|
149 | - 'required' => false, |
|
150 | - ) |
|
151 | - ), |
|
152 | - 'organization_address_2' => new EE_Text_Input( |
|
153 | - array( |
|
154 | - 'html_name' => 'organization_address_2', |
|
155 | - 'html_label_text' => esc_html__('Street Address 2', 'event_espresso'), |
|
156 | - 'default' => $this->organization_config->get_pretty('address_2'), |
|
157 | - 'required' => false, |
|
158 | - ) |
|
159 | - ), |
|
160 | - 'organization_city' => new EE_Text_Input( |
|
161 | - array( |
|
162 | - 'html_name' => 'organization_city', |
|
163 | - 'html_label_text' => esc_html__('City', 'event_espresso'), |
|
164 | - 'default' => $this->organization_config->get_pretty('city'), |
|
165 | - 'required' => false, |
|
166 | - ) |
|
167 | - ), |
|
168 | - 'organization_country' => new EE_Country_Select_Input( |
|
169 | - null, |
|
170 | - array( |
|
171 | - EE_Country_Select_Input::OPTION_GET_KEY => EE_Country_Select_Input::OPTION_GET_ALL, |
|
172 | - 'html_name' => 'organization_country', |
|
173 | - 'html_label_text' => esc_html__('Country', 'event_espresso'), |
|
174 | - 'default' => $this->organization_config->CNT_ISO, |
|
175 | - 'required' => false, |
|
176 | - 'html_help_text' => sprintf( |
|
177 | - esc_html__( |
|
178 | - '%1$sThe Country set here will have the effect of setting the currency used for all ticket prices.%2$s', |
|
179 | - 'event_espresso' |
|
180 | - ), |
|
181 | - '<span class="reminder-spn">', |
|
182 | - '</span>' |
|
183 | - ), |
|
184 | - ) |
|
185 | - ), |
|
186 | - 'organization_state' => new EE_State_Select_Input( |
|
187 | - null, |
|
188 | - array( |
|
189 | - 'html_name' => 'organization_state', |
|
190 | - 'html_label_text' => esc_html__('State/Province', 'event_espresso'), |
|
191 | - 'default' => $this->organization_config->STA_ID, |
|
192 | - 'required' => false, |
|
193 | - 'html_help_text' => empty($this->organization_config->STA_ID) || ! $has_sub_regions |
|
194 | - ? sprintf( |
|
195 | - esc_html__( |
|
196 | - 'If the States/Provinces for the selected Country do not appear in this list, then click "Save".%3$sIf data exists, then the list will be populated when the page reloads and you will be able to make a selection at that time.%3$s%1$sMake sure you click "Save" again after selecting a State/Province that has just been loaded in order to keep that selection.%2$s', |
|
197 | - 'event_espresso' |
|
198 | - ), |
|
199 | - '<span class="reminder-spn">', |
|
200 | - '</span>', |
|
201 | - '<br />' |
|
202 | - ) |
|
203 | - : '', |
|
204 | - ) |
|
205 | - ), |
|
206 | - 'organization_zip' => new EE_Text_Input( |
|
207 | - array( |
|
208 | - 'html_name' => 'organization_zip', |
|
209 | - 'html_label_text' => esc_html__('Zip/Postal Code', 'event_espresso'), |
|
210 | - 'default' => $this->organization_config->get_pretty('zip'), |
|
211 | - 'required' => false, |
|
212 | - ) |
|
213 | - ), |
|
214 | - 'organization_email' => new EE_Text_Input( |
|
215 | - array( |
|
216 | - 'html_name' => 'organization_email', |
|
217 | - 'html_label_text' => esc_html__('Primary Contact Email', 'event_espresso'), |
|
218 | - 'html_help_text' => sprintf( |
|
219 | - esc_html__( |
|
220 | - 'This is where notifications go to when you use the %1$s and %2$s shortcodes in the message templates.', |
|
221 | - 'event_espresso' |
|
222 | - ), |
|
223 | - '<code>[CO_FORMATTED_EMAIL]</code>', |
|
224 | - '<code>[CO_EMAIL]</code>' |
|
225 | - ), |
|
226 | - 'default' => $this->organization_config->get_pretty('email'), |
|
227 | - 'required' => false, |
|
228 | - ) |
|
229 | - ), |
|
230 | - 'organization_phone' => new EE_Text_Input( |
|
231 | - array( |
|
232 | - 'html_name' => 'organization_phone', |
|
233 | - 'html_label_text' => esc_html__('Phone Number', 'event_espresso'), |
|
234 | - 'html_help_text' => esc_html__( |
|
235 | - 'The phone number for your organization.', |
|
236 | - 'event_espresso' |
|
237 | - ), |
|
238 | - 'default' => $this->organization_config->get_pretty('phone'), |
|
239 | - 'required' => false, |
|
240 | - ) |
|
241 | - ), |
|
242 | - 'organization_vat' => new EE_Text_Input( |
|
243 | - array( |
|
244 | - 'html_name' => 'organization_vat', |
|
245 | - 'html_label_text' => esc_html__('VAT/Tax Number', 'event_espresso'), |
|
246 | - 'html_help_text' => esc_html__( |
|
247 | - 'The VAT/Tax Number may be displayed on invoices and receipts.', |
|
248 | - 'event_espresso' |
|
249 | - ), |
|
250 | - 'default' => $this->organization_config->get_pretty('vat'), |
|
251 | - 'required' => false, |
|
252 | - ) |
|
253 | - ), |
|
254 | - 'company_logo_hdr' => new EE_Form_Section_HTML( |
|
255 | - EEH_HTML::h2( |
|
256 | - esc_html__('Company Logo', 'event_espresso') |
|
257 | - . ' ' |
|
258 | - . EEH_HTML::span(EEH_Template::get_help_tab_link('organization_logo_info')), |
|
259 | - '', |
|
260 | - 'company-logo-hdr' |
|
261 | - ) |
|
262 | - ), |
|
263 | - 'organization_logo_url' => new EE_Admin_File_Uploader_Input( |
|
264 | - array( |
|
265 | - 'html_name' => 'organization_logo_url', |
|
266 | - 'html_label_text' => esc_html__('Upload New Logo', 'event_espresso'), |
|
267 | - 'html_help_text' => esc_html__( |
|
268 | - 'Your logo will be used on custom invoices, tickets, certificates, and payment templates.', |
|
269 | - 'event_espresso' |
|
270 | - ), |
|
271 | - 'default' => $this->organization_config->get_pretty('logo_url'), |
|
272 | - 'required' => false, |
|
273 | - ) |
|
274 | - ), |
|
275 | - 'social_links_hdr' => new EE_Form_Section_HTML( |
|
276 | - EEH_HTML::h2( |
|
277 | - esc_html__('Social Links', 'event_espresso') |
|
278 | - . ' ' |
|
279 | - . EEH_HTML::span(EEH_Template::get_help_tab_link('social_links_info')) |
|
280 | - . EEH_HTML::br() |
|
281 | - . EEH_HTML::p( |
|
282 | - esc_html__( |
|
283 | - 'Enter any links to social accounts for your organization here', |
|
284 | - 'event_espresso' |
|
285 | - ), |
|
286 | - '', |
|
287 | - 'description' |
|
288 | - ), |
|
289 | - '', |
|
290 | - 'social-links-hdr' |
|
291 | - ) |
|
292 | - ), |
|
293 | - 'organization_facebook' => new EE_Text_Input( |
|
294 | - array( |
|
295 | - 'html_name' => 'organization_facebook', |
|
296 | - 'html_label_text' => esc_html__('Facebook', 'event_espresso'), |
|
297 | - 'other_html_attributes' => ' placeholder="facebook.com/profile.name"', |
|
298 | - 'default' => $this->organization_config->get_pretty('facebook'), |
|
299 | - 'required' => false, |
|
300 | - ) |
|
301 | - ), |
|
302 | - 'organization_twitter' => new EE_Text_Input( |
|
303 | - array( |
|
304 | - 'html_name' => 'organization_twitter', |
|
305 | - 'html_label_text' => esc_html__('Twitter', 'event_espresso'), |
|
306 | - 'other_html_attributes' => ' placeholder="twitter.com/twitterhandle"', |
|
307 | - 'default' => $this->organization_config->get_pretty('twitter'), |
|
308 | - 'required' => false, |
|
309 | - ) |
|
310 | - ), |
|
311 | - 'organization_linkedin' => new EE_Text_Input( |
|
312 | - array( |
|
313 | - 'html_name' => 'organization_linkedin', |
|
314 | - 'html_label_text' => esc_html__('LinkedIn', 'event_espresso'), |
|
315 | - 'other_html_attributes' => ' placeholder="linkedin.com/in/profilename"', |
|
316 | - 'default' => $this->organization_config->get_pretty('linkedin'), |
|
317 | - 'required' => false, |
|
318 | - ) |
|
319 | - ), |
|
320 | - 'organization_pinterest' => new EE_Text_Input( |
|
321 | - array( |
|
322 | - 'html_name' => 'organization_pinterest', |
|
323 | - 'html_label_text' => esc_html__('Pinterest', 'event_espresso'), |
|
324 | - 'other_html_attributes' => ' placeholder="pinterest.com/profilename"', |
|
325 | - 'default' => $this->organization_config->get_pretty('pinterest'), |
|
326 | - 'required' => false, |
|
327 | - ) |
|
328 | - ), |
|
329 | - 'organization_instagram' => new EE_Text_Input( |
|
330 | - array( |
|
331 | - 'html_name' => 'organization_instagram', |
|
332 | - 'html_label_text' => esc_html__('Instagram', 'event_espresso'), |
|
333 | - 'other_html_attributes' => ' placeholder="instagram.com/handle"', |
|
334 | - 'default' => $this->organization_config->get_pretty('instagram'), |
|
335 | - 'required' => false, |
|
336 | - ) |
|
337 | - ), |
|
338 | - ), |
|
339 | - ) |
|
340 | - ); |
|
341 | - if (is_main_site()) { |
|
342 | - $form->add_subsections( |
|
343 | - array( |
|
344 | - 'site_license_key_hdr' => new EE_Form_Section_HTML( |
|
345 | - EEH_HTML::h2( |
|
346 | - esc_html__('Your Event Espresso License Key', 'event_espresso') |
|
347 | - . ' ' |
|
348 | - . EEH_HTML::span( |
|
349 | - EEH_Template::get_help_tab_link('site_license_key_info') |
|
350 | - ), |
|
351 | - '', |
|
352 | - 'site-license-key-hdr' |
|
353 | - ) |
|
354 | - ), |
|
355 | - 'site_license_key' => $this->getSiteLicenseKeyField() |
|
356 | - ) |
|
357 | - ); |
|
358 | - $form->add_subsections( |
|
359 | - array( |
|
360 | - 'uxip_optin_hdr' => new EE_Form_Section_HTML( |
|
361 | - $this->uxipOptinText() |
|
362 | - ), |
|
363 | - 'ueip_optin' => new EE_Checkbox_Multi_Input( |
|
364 | - array( |
|
365 | - true => esc_html__('Yes! I want to help improve Event Espresso!', 'event_espresso') |
|
366 | - ), |
|
367 | - array( |
|
368 | - 'html_name' => EE_Core_Config::OPTION_NAME_UXIP, |
|
369 | - 'html_label_text' => esc_html__( |
|
370 | - 'UXIP Opt In?', |
|
371 | - 'event_espresso' |
|
372 | - ), |
|
373 | - 'default' => isset($this->core_config->ee_ueip_optin) |
|
374 | - ? filter_var($this->core_config->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN) |
|
375 | - : false, |
|
376 | - 'required' => false, |
|
377 | - ) |
|
378 | - ), |
|
379 | - ), |
|
380 | - 'organization_instagram', |
|
381 | - false |
|
382 | - ); |
|
383 | - } |
|
384 | - return $form; |
|
385 | - } |
|
102 | + /** |
|
103 | + * creates and returns the actual form |
|
104 | + * |
|
105 | + * @return EE_Form_Section_Proper |
|
106 | + * @throws EE_Error |
|
107 | + * @throws InvalidArgumentException |
|
108 | + * @throws InvalidDataTypeException |
|
109 | + * @throws InvalidInterfaceException |
|
110 | + * @throws ReflectionException |
|
111 | + */ |
|
112 | + public function generate() |
|
113 | + { |
|
114 | + $has_sub_regions = EEM_State::instance()->count( |
|
115 | + array(array('Country.CNT_ISO' => $this->organization_config->CNT_ISO)) |
|
116 | + ); |
|
117 | + $form = new EE_Form_Section_Proper( |
|
118 | + array( |
|
119 | + 'name' => 'organization_settings', |
|
120 | + 'html_id' => 'organization_settings', |
|
121 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
122 | + 'subsections' => array( |
|
123 | + 'contact_information_hdr' => new EE_Form_Section_HTML( |
|
124 | + EEH_HTML::h2( |
|
125 | + esc_html__('Contact Information', 'event_espresso') |
|
126 | + . ' ' |
|
127 | + . EEH_HTML::span(EEH_Template::get_help_tab_link('contact_info_info')), |
|
128 | + '', |
|
129 | + 'contact-information-hdr' |
|
130 | + ) |
|
131 | + ), |
|
132 | + 'organization_name' => new EE_Text_Input( |
|
133 | + array( |
|
134 | + 'html_name' => 'organization_name', |
|
135 | + 'html_label_text' => esc_html__('Organization Name', 'event_espresso'), |
|
136 | + 'html_help_text' => esc_html__( |
|
137 | + 'Displayed on all emails and invoices.', |
|
138 | + 'event_espresso' |
|
139 | + ), |
|
140 | + 'default' => $this->organization_config->get_pretty('name'), |
|
141 | + 'required' => false, |
|
142 | + ) |
|
143 | + ), |
|
144 | + 'organization_address_1' => new EE_Text_Input( |
|
145 | + array( |
|
146 | + 'html_name' => 'organization_address_1', |
|
147 | + 'html_label_text' => esc_html__('Street Address', 'event_espresso'), |
|
148 | + 'default' => $this->organization_config->get_pretty('address_1'), |
|
149 | + 'required' => false, |
|
150 | + ) |
|
151 | + ), |
|
152 | + 'organization_address_2' => new EE_Text_Input( |
|
153 | + array( |
|
154 | + 'html_name' => 'organization_address_2', |
|
155 | + 'html_label_text' => esc_html__('Street Address 2', 'event_espresso'), |
|
156 | + 'default' => $this->organization_config->get_pretty('address_2'), |
|
157 | + 'required' => false, |
|
158 | + ) |
|
159 | + ), |
|
160 | + 'organization_city' => new EE_Text_Input( |
|
161 | + array( |
|
162 | + 'html_name' => 'organization_city', |
|
163 | + 'html_label_text' => esc_html__('City', 'event_espresso'), |
|
164 | + 'default' => $this->organization_config->get_pretty('city'), |
|
165 | + 'required' => false, |
|
166 | + ) |
|
167 | + ), |
|
168 | + 'organization_country' => new EE_Country_Select_Input( |
|
169 | + null, |
|
170 | + array( |
|
171 | + EE_Country_Select_Input::OPTION_GET_KEY => EE_Country_Select_Input::OPTION_GET_ALL, |
|
172 | + 'html_name' => 'organization_country', |
|
173 | + 'html_label_text' => esc_html__('Country', 'event_espresso'), |
|
174 | + 'default' => $this->organization_config->CNT_ISO, |
|
175 | + 'required' => false, |
|
176 | + 'html_help_text' => sprintf( |
|
177 | + esc_html__( |
|
178 | + '%1$sThe Country set here will have the effect of setting the currency used for all ticket prices.%2$s', |
|
179 | + 'event_espresso' |
|
180 | + ), |
|
181 | + '<span class="reminder-spn">', |
|
182 | + '</span>' |
|
183 | + ), |
|
184 | + ) |
|
185 | + ), |
|
186 | + 'organization_state' => new EE_State_Select_Input( |
|
187 | + null, |
|
188 | + array( |
|
189 | + 'html_name' => 'organization_state', |
|
190 | + 'html_label_text' => esc_html__('State/Province', 'event_espresso'), |
|
191 | + 'default' => $this->organization_config->STA_ID, |
|
192 | + 'required' => false, |
|
193 | + 'html_help_text' => empty($this->organization_config->STA_ID) || ! $has_sub_regions |
|
194 | + ? sprintf( |
|
195 | + esc_html__( |
|
196 | + 'If the States/Provinces for the selected Country do not appear in this list, then click "Save".%3$sIf data exists, then the list will be populated when the page reloads and you will be able to make a selection at that time.%3$s%1$sMake sure you click "Save" again after selecting a State/Province that has just been loaded in order to keep that selection.%2$s', |
|
197 | + 'event_espresso' |
|
198 | + ), |
|
199 | + '<span class="reminder-spn">', |
|
200 | + '</span>', |
|
201 | + '<br />' |
|
202 | + ) |
|
203 | + : '', |
|
204 | + ) |
|
205 | + ), |
|
206 | + 'organization_zip' => new EE_Text_Input( |
|
207 | + array( |
|
208 | + 'html_name' => 'organization_zip', |
|
209 | + 'html_label_text' => esc_html__('Zip/Postal Code', 'event_espresso'), |
|
210 | + 'default' => $this->organization_config->get_pretty('zip'), |
|
211 | + 'required' => false, |
|
212 | + ) |
|
213 | + ), |
|
214 | + 'organization_email' => new EE_Text_Input( |
|
215 | + array( |
|
216 | + 'html_name' => 'organization_email', |
|
217 | + 'html_label_text' => esc_html__('Primary Contact Email', 'event_espresso'), |
|
218 | + 'html_help_text' => sprintf( |
|
219 | + esc_html__( |
|
220 | + 'This is where notifications go to when you use the %1$s and %2$s shortcodes in the message templates.', |
|
221 | + 'event_espresso' |
|
222 | + ), |
|
223 | + '<code>[CO_FORMATTED_EMAIL]</code>', |
|
224 | + '<code>[CO_EMAIL]</code>' |
|
225 | + ), |
|
226 | + 'default' => $this->organization_config->get_pretty('email'), |
|
227 | + 'required' => false, |
|
228 | + ) |
|
229 | + ), |
|
230 | + 'organization_phone' => new EE_Text_Input( |
|
231 | + array( |
|
232 | + 'html_name' => 'organization_phone', |
|
233 | + 'html_label_text' => esc_html__('Phone Number', 'event_espresso'), |
|
234 | + 'html_help_text' => esc_html__( |
|
235 | + 'The phone number for your organization.', |
|
236 | + 'event_espresso' |
|
237 | + ), |
|
238 | + 'default' => $this->organization_config->get_pretty('phone'), |
|
239 | + 'required' => false, |
|
240 | + ) |
|
241 | + ), |
|
242 | + 'organization_vat' => new EE_Text_Input( |
|
243 | + array( |
|
244 | + 'html_name' => 'organization_vat', |
|
245 | + 'html_label_text' => esc_html__('VAT/Tax Number', 'event_espresso'), |
|
246 | + 'html_help_text' => esc_html__( |
|
247 | + 'The VAT/Tax Number may be displayed on invoices and receipts.', |
|
248 | + 'event_espresso' |
|
249 | + ), |
|
250 | + 'default' => $this->organization_config->get_pretty('vat'), |
|
251 | + 'required' => false, |
|
252 | + ) |
|
253 | + ), |
|
254 | + 'company_logo_hdr' => new EE_Form_Section_HTML( |
|
255 | + EEH_HTML::h2( |
|
256 | + esc_html__('Company Logo', 'event_espresso') |
|
257 | + . ' ' |
|
258 | + . EEH_HTML::span(EEH_Template::get_help_tab_link('organization_logo_info')), |
|
259 | + '', |
|
260 | + 'company-logo-hdr' |
|
261 | + ) |
|
262 | + ), |
|
263 | + 'organization_logo_url' => new EE_Admin_File_Uploader_Input( |
|
264 | + array( |
|
265 | + 'html_name' => 'organization_logo_url', |
|
266 | + 'html_label_text' => esc_html__('Upload New Logo', 'event_espresso'), |
|
267 | + 'html_help_text' => esc_html__( |
|
268 | + 'Your logo will be used on custom invoices, tickets, certificates, and payment templates.', |
|
269 | + 'event_espresso' |
|
270 | + ), |
|
271 | + 'default' => $this->organization_config->get_pretty('logo_url'), |
|
272 | + 'required' => false, |
|
273 | + ) |
|
274 | + ), |
|
275 | + 'social_links_hdr' => new EE_Form_Section_HTML( |
|
276 | + EEH_HTML::h2( |
|
277 | + esc_html__('Social Links', 'event_espresso') |
|
278 | + . ' ' |
|
279 | + . EEH_HTML::span(EEH_Template::get_help_tab_link('social_links_info')) |
|
280 | + . EEH_HTML::br() |
|
281 | + . EEH_HTML::p( |
|
282 | + esc_html__( |
|
283 | + 'Enter any links to social accounts for your organization here', |
|
284 | + 'event_espresso' |
|
285 | + ), |
|
286 | + '', |
|
287 | + 'description' |
|
288 | + ), |
|
289 | + '', |
|
290 | + 'social-links-hdr' |
|
291 | + ) |
|
292 | + ), |
|
293 | + 'organization_facebook' => new EE_Text_Input( |
|
294 | + array( |
|
295 | + 'html_name' => 'organization_facebook', |
|
296 | + 'html_label_text' => esc_html__('Facebook', 'event_espresso'), |
|
297 | + 'other_html_attributes' => ' placeholder="facebook.com/profile.name"', |
|
298 | + 'default' => $this->organization_config->get_pretty('facebook'), |
|
299 | + 'required' => false, |
|
300 | + ) |
|
301 | + ), |
|
302 | + 'organization_twitter' => new EE_Text_Input( |
|
303 | + array( |
|
304 | + 'html_name' => 'organization_twitter', |
|
305 | + 'html_label_text' => esc_html__('Twitter', 'event_espresso'), |
|
306 | + 'other_html_attributes' => ' placeholder="twitter.com/twitterhandle"', |
|
307 | + 'default' => $this->organization_config->get_pretty('twitter'), |
|
308 | + 'required' => false, |
|
309 | + ) |
|
310 | + ), |
|
311 | + 'organization_linkedin' => new EE_Text_Input( |
|
312 | + array( |
|
313 | + 'html_name' => 'organization_linkedin', |
|
314 | + 'html_label_text' => esc_html__('LinkedIn', 'event_espresso'), |
|
315 | + 'other_html_attributes' => ' placeholder="linkedin.com/in/profilename"', |
|
316 | + 'default' => $this->organization_config->get_pretty('linkedin'), |
|
317 | + 'required' => false, |
|
318 | + ) |
|
319 | + ), |
|
320 | + 'organization_pinterest' => new EE_Text_Input( |
|
321 | + array( |
|
322 | + 'html_name' => 'organization_pinterest', |
|
323 | + 'html_label_text' => esc_html__('Pinterest', 'event_espresso'), |
|
324 | + 'other_html_attributes' => ' placeholder="pinterest.com/profilename"', |
|
325 | + 'default' => $this->organization_config->get_pretty('pinterest'), |
|
326 | + 'required' => false, |
|
327 | + ) |
|
328 | + ), |
|
329 | + 'organization_instagram' => new EE_Text_Input( |
|
330 | + array( |
|
331 | + 'html_name' => 'organization_instagram', |
|
332 | + 'html_label_text' => esc_html__('Instagram', 'event_espresso'), |
|
333 | + 'other_html_attributes' => ' placeholder="instagram.com/handle"', |
|
334 | + 'default' => $this->organization_config->get_pretty('instagram'), |
|
335 | + 'required' => false, |
|
336 | + ) |
|
337 | + ), |
|
338 | + ), |
|
339 | + ) |
|
340 | + ); |
|
341 | + if (is_main_site()) { |
|
342 | + $form->add_subsections( |
|
343 | + array( |
|
344 | + 'site_license_key_hdr' => new EE_Form_Section_HTML( |
|
345 | + EEH_HTML::h2( |
|
346 | + esc_html__('Your Event Espresso License Key', 'event_espresso') |
|
347 | + . ' ' |
|
348 | + . EEH_HTML::span( |
|
349 | + EEH_Template::get_help_tab_link('site_license_key_info') |
|
350 | + ), |
|
351 | + '', |
|
352 | + 'site-license-key-hdr' |
|
353 | + ) |
|
354 | + ), |
|
355 | + 'site_license_key' => $this->getSiteLicenseKeyField() |
|
356 | + ) |
|
357 | + ); |
|
358 | + $form->add_subsections( |
|
359 | + array( |
|
360 | + 'uxip_optin_hdr' => new EE_Form_Section_HTML( |
|
361 | + $this->uxipOptinText() |
|
362 | + ), |
|
363 | + 'ueip_optin' => new EE_Checkbox_Multi_Input( |
|
364 | + array( |
|
365 | + true => esc_html__('Yes! I want to help improve Event Espresso!', 'event_espresso') |
|
366 | + ), |
|
367 | + array( |
|
368 | + 'html_name' => EE_Core_Config::OPTION_NAME_UXIP, |
|
369 | + 'html_label_text' => esc_html__( |
|
370 | + 'UXIP Opt In?', |
|
371 | + 'event_espresso' |
|
372 | + ), |
|
373 | + 'default' => isset($this->core_config->ee_ueip_optin) |
|
374 | + ? filter_var($this->core_config->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN) |
|
375 | + : false, |
|
376 | + 'required' => false, |
|
377 | + ) |
|
378 | + ), |
|
379 | + ), |
|
380 | + 'organization_instagram', |
|
381 | + false |
|
382 | + ); |
|
383 | + } |
|
384 | + return $form; |
|
385 | + } |
|
386 | 386 | |
387 | 387 | |
388 | - /** |
|
389 | - * takes the generated form and displays it along with ony other non-form HTML that may be required |
|
390 | - * returns a string of HTML that can be directly echoed in a template |
|
391 | - * |
|
392 | - * @return string |
|
393 | - * @throws EE_Error |
|
394 | - * @throws InvalidArgumentException |
|
395 | - * @throws InvalidDataTypeException |
|
396 | - * @throws InvalidInterfaceException |
|
397 | - * @throws LogicException |
|
398 | - */ |
|
399 | - public function display() |
|
400 | - { |
|
401 | - $this->form()->enqueue_js(); |
|
402 | - return parent::display(); |
|
403 | - } |
|
388 | + /** |
|
389 | + * takes the generated form and displays it along with ony other non-form HTML that may be required |
|
390 | + * returns a string of HTML that can be directly echoed in a template |
|
391 | + * |
|
392 | + * @return string |
|
393 | + * @throws EE_Error |
|
394 | + * @throws InvalidArgumentException |
|
395 | + * @throws InvalidDataTypeException |
|
396 | + * @throws InvalidInterfaceException |
|
397 | + * @throws LogicException |
|
398 | + */ |
|
399 | + public function display() |
|
400 | + { |
|
401 | + $this->form()->enqueue_js(); |
|
402 | + return parent::display(); |
|
403 | + } |
|
404 | 404 | |
405 | 405 | |
406 | - /** |
|
407 | - * handles processing the form submission |
|
408 | - * returns true or false depending on whether the form was processed successfully or not |
|
409 | - * |
|
410 | - * @param array $form_data |
|
411 | - * @return bool |
|
412 | - * @throws InvalidFormSubmissionException |
|
413 | - * @throws EE_Error |
|
414 | - * @throws LogicException |
|
415 | - * @throws InvalidArgumentException |
|
416 | - * @throws InvalidDataTypeException |
|
417 | - * @throws ReflectionException |
|
418 | - */ |
|
419 | - public function process($form_data = array()) |
|
420 | - { |
|
421 | - // process form |
|
422 | - $valid_data = (array) parent::process($form_data); |
|
423 | - if (empty($valid_data)) { |
|
424 | - return false; |
|
425 | - } |
|
406 | + /** |
|
407 | + * handles processing the form submission |
|
408 | + * returns true or false depending on whether the form was processed successfully or not |
|
409 | + * |
|
410 | + * @param array $form_data |
|
411 | + * @return bool |
|
412 | + * @throws InvalidFormSubmissionException |
|
413 | + * @throws EE_Error |
|
414 | + * @throws LogicException |
|
415 | + * @throws InvalidArgumentException |
|
416 | + * @throws InvalidDataTypeException |
|
417 | + * @throws ReflectionException |
|
418 | + */ |
|
419 | + public function process($form_data = array()) |
|
420 | + { |
|
421 | + // process form |
|
422 | + $valid_data = (array) parent::process($form_data); |
|
423 | + if (empty($valid_data)) { |
|
424 | + return false; |
|
425 | + } |
|
426 | 426 | |
427 | - if (is_main_site()) { |
|
428 | - $this->network_core_config->site_license_key = isset($form_data['ee_site_license_key']) |
|
429 | - ? sanitize_text_field($form_data['ee_site_license_key']) |
|
430 | - : $this->network_core_config->site_license_key; |
|
431 | - } |
|
432 | - $this->organization_config->name = isset($form_data['organization_name']) |
|
433 | - ? sanitize_text_field($form_data['organization_name']) |
|
434 | - : $this->organization_config->name; |
|
435 | - $this->organization_config->address_1 = isset($form_data['organization_address_1']) |
|
436 | - ? sanitize_text_field($form_data['organization_address_1']) |
|
437 | - : $this->organization_config->address_1; |
|
438 | - $this->organization_config->address_2 = isset($form_data['organization_address_2']) |
|
439 | - ? sanitize_text_field($form_data['organization_address_2']) |
|
440 | - : $this->organization_config->address_2; |
|
441 | - $this->organization_config->city = isset($form_data['organization_city']) |
|
442 | - ? sanitize_text_field($form_data['organization_city']) |
|
443 | - : $this->organization_config->city; |
|
444 | - $this->organization_config->STA_ID = isset($form_data['organization_state']) |
|
445 | - ? absint($form_data['organization_state']) |
|
446 | - : $this->organization_config->STA_ID; |
|
447 | - $this->organization_config->CNT_ISO = isset($form_data['organization_country']) |
|
448 | - ? sanitize_text_field($form_data['organization_country']) |
|
449 | - : $this->organization_config->CNT_ISO; |
|
450 | - $this->organization_config->zip = isset($form_data['organization_zip']) |
|
451 | - ? sanitize_text_field($form_data['organization_zip']) |
|
452 | - : $this->organization_config->zip; |
|
453 | - $this->organization_config->email = isset($form_data['organization_email']) |
|
454 | - ? sanitize_email($form_data['organization_email']) |
|
455 | - : $this->organization_config->email; |
|
456 | - $this->organization_config->vat = isset($form_data['organization_vat']) |
|
457 | - ? sanitize_text_field($form_data['organization_vat']) |
|
458 | - : $this->organization_config->vat; |
|
459 | - $this->organization_config->phone = isset($form_data['organization_phone']) |
|
460 | - ? sanitize_text_field($form_data['organization_phone']) |
|
461 | - : $this->organization_config->phone; |
|
462 | - $this->organization_config->logo_url = isset($form_data['organization_logo_url']) |
|
463 | - ? esc_url_raw($form_data['organization_logo_url']) |
|
464 | - : $this->organization_config->logo_url; |
|
465 | - $this->organization_config->facebook = isset($form_data['organization_facebook']) |
|
466 | - ? esc_url_raw($form_data['organization_facebook']) |
|
467 | - : $this->organization_config->facebook; |
|
468 | - $this->organization_config->twitter = isset($form_data['organization_twitter']) |
|
469 | - ? esc_url_raw($form_data['organization_twitter']) |
|
470 | - : $this->organization_config->twitter; |
|
471 | - $this->organization_config->linkedin = isset($form_data['organization_linkedin']) |
|
472 | - ? esc_url_raw($form_data['organization_linkedin']) |
|
473 | - : $this->organization_config->linkedin; |
|
474 | - $this->organization_config->pinterest = isset($form_data['organization_pinterest']) |
|
475 | - ? esc_url_raw($form_data['organization_pinterest']) |
|
476 | - : $this->organization_config->pinterest; |
|
477 | - $this->organization_config->google = isset($form_data['organization_google']) |
|
478 | - ? esc_url_raw($form_data['organization_google']) |
|
479 | - : $this->organization_config->google; |
|
480 | - $this->organization_config->instagram = isset($form_data['organization_instagram']) |
|
481 | - ? esc_url_raw($form_data['organization_instagram']) |
|
482 | - : $this->organization_config->instagram; |
|
483 | - $this->core_config->ee_ueip_optin = isset($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0]) |
|
484 | - ? filter_var($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0], FILTER_VALIDATE_BOOLEAN) |
|
485 | - : false; |
|
486 | - $this->core_config->ee_ueip_has_notified = true; |
|
427 | + if (is_main_site()) { |
|
428 | + $this->network_core_config->site_license_key = isset($form_data['ee_site_license_key']) |
|
429 | + ? sanitize_text_field($form_data['ee_site_license_key']) |
|
430 | + : $this->network_core_config->site_license_key; |
|
431 | + } |
|
432 | + $this->organization_config->name = isset($form_data['organization_name']) |
|
433 | + ? sanitize_text_field($form_data['organization_name']) |
|
434 | + : $this->organization_config->name; |
|
435 | + $this->organization_config->address_1 = isset($form_data['organization_address_1']) |
|
436 | + ? sanitize_text_field($form_data['organization_address_1']) |
|
437 | + : $this->organization_config->address_1; |
|
438 | + $this->organization_config->address_2 = isset($form_data['organization_address_2']) |
|
439 | + ? sanitize_text_field($form_data['organization_address_2']) |
|
440 | + : $this->organization_config->address_2; |
|
441 | + $this->organization_config->city = isset($form_data['organization_city']) |
|
442 | + ? sanitize_text_field($form_data['organization_city']) |
|
443 | + : $this->organization_config->city; |
|
444 | + $this->organization_config->STA_ID = isset($form_data['organization_state']) |
|
445 | + ? absint($form_data['organization_state']) |
|
446 | + : $this->organization_config->STA_ID; |
|
447 | + $this->organization_config->CNT_ISO = isset($form_data['organization_country']) |
|
448 | + ? sanitize_text_field($form_data['organization_country']) |
|
449 | + : $this->organization_config->CNT_ISO; |
|
450 | + $this->organization_config->zip = isset($form_data['organization_zip']) |
|
451 | + ? sanitize_text_field($form_data['organization_zip']) |
|
452 | + : $this->organization_config->zip; |
|
453 | + $this->organization_config->email = isset($form_data['organization_email']) |
|
454 | + ? sanitize_email($form_data['organization_email']) |
|
455 | + : $this->organization_config->email; |
|
456 | + $this->organization_config->vat = isset($form_data['organization_vat']) |
|
457 | + ? sanitize_text_field($form_data['organization_vat']) |
|
458 | + : $this->organization_config->vat; |
|
459 | + $this->organization_config->phone = isset($form_data['organization_phone']) |
|
460 | + ? sanitize_text_field($form_data['organization_phone']) |
|
461 | + : $this->organization_config->phone; |
|
462 | + $this->organization_config->logo_url = isset($form_data['organization_logo_url']) |
|
463 | + ? esc_url_raw($form_data['organization_logo_url']) |
|
464 | + : $this->organization_config->logo_url; |
|
465 | + $this->organization_config->facebook = isset($form_data['organization_facebook']) |
|
466 | + ? esc_url_raw($form_data['organization_facebook']) |
|
467 | + : $this->organization_config->facebook; |
|
468 | + $this->organization_config->twitter = isset($form_data['organization_twitter']) |
|
469 | + ? esc_url_raw($form_data['organization_twitter']) |
|
470 | + : $this->organization_config->twitter; |
|
471 | + $this->organization_config->linkedin = isset($form_data['organization_linkedin']) |
|
472 | + ? esc_url_raw($form_data['organization_linkedin']) |
|
473 | + : $this->organization_config->linkedin; |
|
474 | + $this->organization_config->pinterest = isset($form_data['organization_pinterest']) |
|
475 | + ? esc_url_raw($form_data['organization_pinterest']) |
|
476 | + : $this->organization_config->pinterest; |
|
477 | + $this->organization_config->google = isset($form_data['organization_google']) |
|
478 | + ? esc_url_raw($form_data['organization_google']) |
|
479 | + : $this->organization_config->google; |
|
480 | + $this->organization_config->instagram = isset($form_data['organization_instagram']) |
|
481 | + ? esc_url_raw($form_data['organization_instagram']) |
|
482 | + : $this->organization_config->instagram; |
|
483 | + $this->core_config->ee_ueip_optin = isset($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0]) |
|
484 | + ? filter_var($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0], FILTER_VALIDATE_BOOLEAN) |
|
485 | + : false; |
|
486 | + $this->core_config->ee_ueip_has_notified = true; |
|
487 | 487 | |
488 | - $this->registry->CFG->currency = new EE_Currency_Config( |
|
489 | - $this->organization_config->CNT_ISO |
|
490 | - ); |
|
491 | - /** @var EE_Country $country */ |
|
492 | - $country = EEM_Country::instance()->get_one_by_ID($this->organization_config->CNT_ISO); |
|
493 | - if ($country instanceof EE_Country) { |
|
494 | - $country->set('CNT_active', 1); |
|
495 | - $country->save(); |
|
496 | - $this->countrySubRegionDao->saveCountrySubRegions($country); |
|
497 | - } |
|
498 | - return true; |
|
499 | - } |
|
488 | + $this->registry->CFG->currency = new EE_Currency_Config( |
|
489 | + $this->organization_config->CNT_ISO |
|
490 | + ); |
|
491 | + /** @var EE_Country $country */ |
|
492 | + $country = EEM_Country::instance()->get_one_by_ID($this->organization_config->CNT_ISO); |
|
493 | + if ($country instanceof EE_Country) { |
|
494 | + $country->set('CNT_active', 1); |
|
495 | + $country->save(); |
|
496 | + $this->countrySubRegionDao->saveCountrySubRegions($country); |
|
497 | + } |
|
498 | + return true; |
|
499 | + } |
|
500 | 500 | |
501 | 501 | |
502 | - /** |
|
503 | - * @return string |
|
504 | - */ |
|
505 | - private function uxipOptinText() |
|
506 | - { |
|
507 | - ob_start(); |
|
508 | - Stats::optinText(false); |
|
509 | - return ob_get_clean(); |
|
510 | - } |
|
502 | + /** |
|
503 | + * @return string |
|
504 | + */ |
|
505 | + private function uxipOptinText() |
|
506 | + { |
|
507 | + ob_start(); |
|
508 | + Stats::optinText(false); |
|
509 | + return ob_get_clean(); |
|
510 | + } |
|
511 | 511 | |
512 | 512 | |
513 | - /** |
|
514 | - * Return whether the site license key has been verified or not. |
|
515 | - * @return bool |
|
516 | - */ |
|
517 | - private function licenseKeyVerified() |
|
518 | - { |
|
519 | - if (empty($this->network_core_config->site_license_key)) { |
|
520 | - return false; |
|
521 | - } |
|
522 | - $ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME); |
|
523 | - $verify_fail = get_option($ver_option_key, false); |
|
524 | - return $verify_fail === false |
|
525 | - || (! empty($this->network_core_config->site_license_key) |
|
526 | - && $verify_fail === false |
|
527 | - ); |
|
528 | - } |
|
513 | + /** |
|
514 | + * Return whether the site license key has been verified or not. |
|
515 | + * @return bool |
|
516 | + */ |
|
517 | + private function licenseKeyVerified() |
|
518 | + { |
|
519 | + if (empty($this->network_core_config->site_license_key)) { |
|
520 | + return false; |
|
521 | + } |
|
522 | + $ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME); |
|
523 | + $verify_fail = get_option($ver_option_key, false); |
|
524 | + return $verify_fail === false |
|
525 | + || (! empty($this->network_core_config->site_license_key) |
|
526 | + && $verify_fail === false |
|
527 | + ); |
|
528 | + } |
|
529 | 529 | |
530 | 530 | |
531 | - /** |
|
532 | - * @return EE_Text_Input |
|
533 | - */ |
|
534 | - private function getSiteLicenseKeyField() |
|
535 | - { |
|
536 | - $text_input = new EE_Text_Input( |
|
537 | - array( |
|
538 | - 'html_name' => 'ee_site_license_key', |
|
539 | - 'html_id' => 'site_license_key', |
|
540 | - 'html_label_text' => esc_html__('Support License Key', 'event_espresso'), |
|
541 | - /** phpcs:disable WordPress.WP.I18n.UnorderedPlaceholdersText */ |
|
542 | - 'html_help_text' => sprintf( |
|
543 | - esc_html__( |
|
544 | - '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.', |
|
545 | - 'event_espresso' |
|
546 | - ), |
|
547 | - '<strong>', |
|
548 | - '</strong>' |
|
549 | - ), |
|
550 | - /** phpcs:enable */ |
|
551 | - 'default' => isset($this->network_core_config->site_license_key) |
|
552 | - ? $this->network_core_config->site_license_key |
|
553 | - : '', |
|
554 | - 'required' => false, |
|
555 | - 'form_html_filter' => new VsprintfFilter( |
|
556 | - '%2$s %1$s', |
|
557 | - array($this->getValidationIndicator()) |
|
558 | - ) |
|
559 | - ) |
|
560 | - ); |
|
561 | - return $text_input; |
|
562 | - } |
|
531 | + /** |
|
532 | + * @return EE_Text_Input |
|
533 | + */ |
|
534 | + private function getSiteLicenseKeyField() |
|
535 | + { |
|
536 | + $text_input = new EE_Text_Input( |
|
537 | + array( |
|
538 | + 'html_name' => 'ee_site_license_key', |
|
539 | + 'html_id' => 'site_license_key', |
|
540 | + 'html_label_text' => esc_html__('Support License Key', 'event_espresso'), |
|
541 | + /** phpcs:disable WordPress.WP.I18n.UnorderedPlaceholdersText */ |
|
542 | + 'html_help_text' => sprintf( |
|
543 | + esc_html__( |
|
544 | + '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.', |
|
545 | + 'event_espresso' |
|
546 | + ), |
|
547 | + '<strong>', |
|
548 | + '</strong>' |
|
549 | + ), |
|
550 | + /** phpcs:enable */ |
|
551 | + 'default' => isset($this->network_core_config->site_license_key) |
|
552 | + ? $this->network_core_config->site_license_key |
|
553 | + : '', |
|
554 | + 'required' => false, |
|
555 | + 'form_html_filter' => new VsprintfFilter( |
|
556 | + '%2$s %1$s', |
|
557 | + array($this->getValidationIndicator()) |
|
558 | + ) |
|
559 | + ) |
|
560 | + ); |
|
561 | + return $text_input; |
|
562 | + } |
|
563 | 563 | |
564 | 564 | |
565 | - /** |
|
566 | - * @return string |
|
567 | - */ |
|
568 | - private function getValidationIndicator() |
|
569 | - { |
|
570 | - $verified_class = $this->licenseKeyVerified() ? 'ee-icon-color-ee-green' : 'ee-icon-color-ee-red'; |
|
571 | - return '<span class="dashicons dashicons-admin-network ' . $verified_class . ' ee-icon-size-20"></span>'; |
|
572 | - } |
|
565 | + /** |
|
566 | + * @return string |
|
567 | + */ |
|
568 | + private function getValidationIndicator() |
|
569 | + { |
|
570 | + $verified_class = $this->licenseKeyVerified() ? 'ee-icon-color-ee-green' : 'ee-icon-color-ee-red'; |
|
571 | + return '<span class="dashicons dashicons-admin-network ' . $verified_class . ' ee-icon-size-20"></span>'; |
|
572 | + } |
|
573 | 573 | } |
@@ -9,15 +9,15 @@ discard block |
||
9 | 9 | </p> |
10 | 10 | <p> |
11 | 11 | <?php esc_html_e( |
12 | - 'Select your country from the dropdown field. Selecting a different country will partially re-load the page and show updated information.', |
|
13 | - 'event_espresso' |
|
14 | - ); ?> |
|
12 | + 'Select your country from the dropdown field. Selecting a different country will partially re-load the page and show updated information.', |
|
13 | + 'event_espresso' |
|
14 | + ); ?> |
|
15 | 15 | </p> |
16 | 16 | <p class="ee-attention"> |
17 | 17 | <?php esc_html_e( |
18 | - 'Notice: Certain options in Country Details and States/Provinces use a 1 or 0 to indicate a selection. A value of 1 equals yes. A value of 0 equals no.', |
|
19 | - 'event_espresso' |
|
20 | - ); ?> |
|
18 | + 'Notice: Certain options in Country Details and States/Provinces use a 1 or 0 to indicate a selection. A value of 1 equals yes. A value of 0 equals no.', |
|
19 | + 'event_espresso' |
|
20 | + ); ?> |
|
21 | 21 | </p> |
22 | 22 | <p> |
23 | 23 | <strong><?php esc_html_e('Country Details', 'event_espresso'); ?></strong> |
@@ -26,32 +26,32 @@ discard block |
||
26 | 26 | <?php esc_html_e('Fine tune currency and contact data for your own country.', 'event_espresso'); ?> |
27 | 27 | <br /> |
28 | 28 | <?php esc_html_e( |
29 | - 'Your country selection affects the currency that is used throughout Event Espresso. For example, if your country is currently set to United States, then your currency is USD. If you were to switch your country to United Kingdom, then your currency would change to GBP. If you do change your country, be sure to update your contact information on the Your Organization page. This will ensure that your currency and organization information is up-to-date throughout Event Espresso.', |
|
30 | - 'event_espresso' |
|
31 | - ); ?> |
|
29 | + 'Your country selection affects the currency that is used throughout Event Espresso. For example, if your country is currently set to United States, then your currency is USD. If you were to switch your country to United Kingdom, then your currency would change to GBP. If you do change your country, be sure to update your contact information on the Your Organization page. This will ensure that your currency and organization information is up-to-date throughout Event Espresso.', |
|
30 | + 'event_espresso' |
|
31 | + ); ?> |
|
32 | 32 | </p> |
33 | 33 | <p> |
34 | 34 | <strong><?php esc_html_e('States/Provinces', 'event_espresso'); ?></strong> |
35 | 35 | </p> |
36 | 36 | <p> |
37 | 37 | <?php esc_html_e( |
38 | - 'Define the states/provinces that are used in Event Espresso. New states / provinces can be added using the Add New State/Province field.', |
|
39 | - 'event_espresso' |
|
40 | - ); ?> |
|
38 | + 'Define the states/provinces that are used in Event Espresso. New states / provinces can be added using the Add New State/Province field.', |
|
39 | + 'event_espresso' |
|
40 | + ); ?> |
|
41 | 41 | </p> |
42 | 42 | <p> |
43 | 43 | <strong><?php esc_html_e('Recommendations', 'event_espresso'); ?></strong> |
44 | 44 | <br /> |
45 | 45 | <?php esc_html_e( |
46 | - 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
47 | - 'event_espresso' |
|
48 | - ); ?> |
|
46 | + 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
47 | + 'event_espresso' |
|
48 | + ); ?> |
|
49 | 49 | </p> |
50 | 50 | <p> |
51 | 51 | <strong><?php esc_html_e('Screen Options', 'event_espresso'); ?></strong> |
52 | 52 | <br /> |
53 | 53 | <?php esc_html_e( |
54 | - 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
55 | - 'event_espresso' |
|
56 | - ); ?> |
|
54 | + 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
55 | + 'event_espresso' |
|
56 | + ); ?> |
|
57 | 57 | </p> |
58 | 58 | \ No newline at end of file |
@@ -9,77 +9,77 @@ |
||
9 | 9 | </p> |
10 | 10 | <p> |
11 | 11 | <?php printf( |
12 | - esc_html__( |
|
13 | - 'Enter your support license key in this field to benefit from one-click updates. To manage your support license key, please %1$slogin to your Event Espresso account%2$s. Then click on Edit Account Details which appears in the left sidebar menu.', |
|
14 | - 'event_espresso' |
|
15 | - ), |
|
16 | - '<a href="https://eventespresso.com/wp-login.php">', |
|
17 | - '</a>' |
|
18 | - );?> |
|
12 | + esc_html__( |
|
13 | + 'Enter your support license key in this field to benefit from one-click updates. To manage your support license key, please %1$slogin to your Event Espresso account%2$s. Then click on Edit Account Details which appears in the left sidebar menu.', |
|
14 | + 'event_espresso' |
|
15 | + ), |
|
16 | + '<a href="https://eventespresso.com/wp-login.php">', |
|
17 | + '</a>' |
|
18 | + );?> |
|
19 | 19 | </p> |
20 | 20 | <p class="ee-attention"> |
21 | 21 | <?php printf( |
22 | - esc_html__( |
|
23 | - 'Site license keys are now called support license keys. Your support license key should only be entered on live/production sites. If this is a development or test site, %sdo not%s enter your support license key.', |
|
24 | - 'event_espresso' |
|
25 | - ), |
|
26 | - '<strong>', |
|
27 | - '</strong>' |
|
28 | - ); ?> |
|
22 | + esc_html__( |
|
23 | + 'Site license keys are now called support license keys. Your support license key should only be entered on live/production sites. If this is a development or test site, %sdo not%s enter your support license key.', |
|
24 | + 'event_espresso' |
|
25 | + ), |
|
26 | + '<strong>', |
|
27 | + '</strong>' |
|
28 | + ); ?> |
|
29 | 29 | </p> |
30 | 30 | <p> |
31 | 31 | <strong><?php esc_html_e('Contact Information', 'event_espresso'); ?></strong> |
32 | 32 | </p> |
33 | 33 | <p> |
34 | 34 | <?php esc_html_e( |
35 | - 'Enter information about your organization here. Be sure to keep your information up-to-date.', |
|
36 | - 'event_espresso' |
|
37 | - ); ?><br /> |
|
35 | + 'Enter information about your organization here. Be sure to keep your information up-to-date.', |
|
36 | + 'event_espresso' |
|
37 | + ); ?><br /> |
|
38 | 38 | <?php esc_html_e( |
39 | - 'Changing your country on this page will also change your country on the Countries page. This will affect your currency options which are used through Event Espresso. For example, if your country is currently set to United States, then your currency is USD. If you were to switch your country to United Kingdom, then your currency would change to GBP.', |
|
40 | - 'event_espresso' |
|
41 | - ); ?> |
|
39 | + 'Changing your country on this page will also change your country on the Countries page. This will affect your currency options which are used through Event Espresso. For example, if your country is currently set to United States, then your currency is USD. If you were to switch your country to United Kingdom, then your currency would change to GBP.', |
|
40 | + 'event_espresso' |
|
41 | + ); ?> |
|
42 | 42 | </p> |
43 | 43 | <p> |
44 | 44 | <strong><?php esc_html_e('Company Logo', 'event_espresso'); ?></strong> |
45 | 45 | </p> |
46 | 46 | <p> |
47 | 47 | <?php esc_html_e( |
48 | - 'You can upload a new logo here. We recommend an image that is 400 pixels wide or smaller. Your logo will be used on custom invoices, tickets, certificates, and payment templates.', |
|
49 | - 'event_espresso' |
|
50 | - ); ?> |
|
48 | + 'You can upload a new logo here. We recommend an image that is 400 pixels wide or smaller. Your logo will be used on custom invoices, tickets, certificates, and payment templates.', |
|
49 | + 'event_espresso' |
|
50 | + ); ?> |
|
51 | 51 | </p> |
52 | 52 | <p> |
53 | 53 | <strong><?php esc_html_e('Social Links', 'event_espresso'); ?></strong> |
54 | 54 | </p> |
55 | 55 | <p> |
56 | 56 | <?php esc_html_e( |
57 | - 'These URLs can be displayed automatically within your emails (using shortcodes) and front-end templates (using template tags).', |
|
58 | - 'event_espresso' |
|
59 | - ); ?> |
|
57 | + 'These URLs can be displayed automatically within your emails (using shortcodes) and front-end templates (using template tags).', |
|
58 | + 'event_espresso' |
|
59 | + ); ?> |
|
60 | 60 | </p> |
61 | 61 | <p> |
62 | 62 | <strong><?php esc_html_e('User eXperience Improvement Program (UXIP)', 'event_espresso'); ?></strong> |
63 | 63 | </p> |
64 | 64 | <p> |
65 | 65 | <?php esc_html_e( |
66 | - 'You can take part in making Event Espresso better! Your information will never be sold, traded, or misused in any way. This programs is voluntary and you can opt out at any time.', |
|
67 | - 'event_espresso' |
|
68 | - ); ?> |
|
66 | + 'You can take part in making Event Espresso better! Your information will never be sold, traded, or misused in any way. This programs is voluntary and you can opt out at any time.', |
|
67 | + 'event_espresso' |
|
68 | + ); ?> |
|
69 | 69 | </p> |
70 | 70 | <p> |
71 | 71 | <strong><?php esc_html_e('Recommendations', 'event_espresso'); ?></strong> |
72 | 72 | <br /> |
73 | 73 | <?php esc_html_e( |
74 | - 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
75 | - 'event_espresso' |
|
76 | - ); ?> |
|
74 | + 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
75 | + 'event_espresso' |
|
76 | + ); ?> |
|
77 | 77 | </p> |
78 | 78 | <p> |
79 | 79 | <strong><?php esc_html_e('Screen Options', 'event_espresso'); ?></strong> |
80 | 80 | <br /> |
81 | 81 | <?php esc_html_e( |
82 | - 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
83 | - 'event_espresso' |
|
84 | - ); ?> |
|
82 | + 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
83 | + 'event_espresso' |
|
84 | + ); ?> |
|
85 | 85 | </p> |
86 | 86 | \ No newline at end of file |
@@ -3,9 +3,9 @@ discard block |
||
3 | 3 | </p> |
4 | 4 | <p> |
5 | 5 | <?php esc_html_e( |
6 | - 'This page shows all critical pages that Event Espresso needs to work correctly.', |
|
7 | - 'event_espresso' |
|
8 | - ); ?> |
|
6 | + 'This page shows all critical pages that Event Espresso needs to work correctly.', |
|
7 | + 'event_espresso' |
|
8 | + ); ?> |
|
9 | 9 | </p> |
10 | 10 | <p><strong><?php esc_html_e('Shortcodes', 'event_espresso'); ?></strong></p> |
11 | 11 | <ul> |
@@ -13,77 +13,77 @@ discard block |
||
13 | 13 | <strong><?php esc_html_e('Registration Checkout Page', 'event_espresso'); ?></strong> |
14 | 14 | <br /> |
15 | 15 | <?php printf( |
16 | - esc_html__( |
|
17 | - 'This page displays all your events and is required. It is important that this page always contain the %s shortcode. It is not required to be in your navigation menu.', |
|
18 | - 'event_espresso' |
|
19 | - ), |
|
20 | - '<strong>[ESPRESSO_CHECKOUT]</strong>' |
|
21 | - ); ?> |
|
16 | + esc_html__( |
|
17 | + 'This page displays all your events and is required. It is important that this page always contain the %s shortcode. It is not required to be in your navigation menu.', |
|
18 | + 'event_espresso' |
|
19 | + ), |
|
20 | + '<strong>[ESPRESSO_CHECKOUT]</strong>' |
|
21 | + ); ?> |
|
22 | 22 | </li> |
23 | 23 | <li> |
24 | 24 | <strong><?php esc_html_e('Transactions Page', 'event_espresso'); ?></strong> |
25 | 25 | <br /> |
26 | 26 | <?php printf( |
27 | - esc_html__( |
|
28 | - 'This page processes the payments and is required. It should only contain the %s shortcode. No other content should be added and it should be hidden from your navigation menu.', |
|
29 | - 'event_espresso' |
|
30 | - ), |
|
31 | - '<strong>[ESPRESSO_TXN_PAGE]</strong>' |
|
32 | - ); ?> |
|
27 | + esc_html__( |
|
28 | + 'This page processes the payments and is required. It should only contain the %s shortcode. No other content should be added and it should be hidden from your navigation menu.', |
|
29 | + 'event_espresso' |
|
30 | + ), |
|
31 | + '<strong>[ESPRESSO_TXN_PAGE]</strong>' |
|
32 | + ); ?> |
|
33 | 33 | </li> |
34 | 34 | <li> |
35 | 35 | <strong><?php esc_html_e('Thank You Page', 'event_espresso'); ?></strong> |
36 | 36 | <br /> |
37 | 37 | <?php printf( |
38 | - esc_html__( |
|
39 | - 'This page is displayed after a successful transaction and is required. It should contain the %s shortcode. Additionally, you may customize this page by adding extra content to the page. It should be hidden from your navigation menu.', |
|
40 | - 'event_espresso' |
|
41 | - ), |
|
42 | - '<strong>[ESPRESSO_THANK_YOU]</strong>' |
|
43 | - ); ?> |
|
38 | + esc_html__( |
|
39 | + 'This page is displayed after a successful transaction and is required. It should contain the %s shortcode. Additionally, you may customize this page by adding extra content to the page. It should be hidden from your navigation menu.', |
|
40 | + 'event_espresso' |
|
41 | + ), |
|
42 | + '<strong>[ESPRESSO_THANK_YOU]</strong>' |
|
43 | + ); ?> |
|
44 | 44 | </li> |
45 | 45 | <li> |
46 | 46 | <strong><?php esc_html_e('Cancel / Return Page', 'event_espresso'); ?></strong> |
47 | 47 | <br /> |
48 | 48 | <?php printf( |
49 | - esc_html__( |
|
50 | - 'This page is displayed after an unsuccessful transaction and is required. It should contain the %s shortcode. Additionally, you may customize this page by adding extra content to the page. It should be hidden from your navigation menu.', |
|
51 | - 'event_espresso' |
|
52 | - ), |
|
53 | - '<strong>[ESPRESSO_CANCELLED]</strong>' |
|
54 | - ); ?> |
|
49 | + esc_html__( |
|
50 | + 'This page is displayed after an unsuccessful transaction and is required. It should contain the %s shortcode. Additionally, you may customize this page by adding extra content to the page. It should be hidden from your navigation menu.', |
|
51 | + 'event_espresso' |
|
52 | + ), |
|
53 | + '<strong>[ESPRESSO_CANCELLED]</strong>' |
|
54 | + ); ?> |
|
55 | 55 | </li> |
56 | 56 | <li> |
57 | 57 | <strong><?php esc_html_e('Event List', 'event_espresso'); ?></strong> |
58 | 58 | <br /> |
59 | 59 | <?php printf( |
60 | - esc_html__( |
|
61 | - 'If you would like to style the look of your events archive page, then follow the WordPress instructions for %1$screating a custom template for archive pages%2$s.', |
|
62 | - 'event_espresso' |
|
63 | - ), |
|
64 | - '<a href="https://codex.wordpress.org/Post_Type_Templates">', |
|
65 | - '</a>' |
|
66 | - ); ?> |
|
60 | + esc_html__( |
|
61 | + 'If you would like to style the look of your events archive page, then follow the WordPress instructions for %1$screating a custom template for archive pages%2$s.', |
|
62 | + 'event_espresso' |
|
63 | + ), |
|
64 | + '<a href="https://codex.wordpress.org/Post_Type_Templates">', |
|
65 | + '</a>' |
|
66 | + ); ?> |
|
67 | 67 | <ul> |
68 | 68 | <li style="list-style-type: circle;"> |
69 | 69 | <?php printf( |
70 | - esc_html__( |
|
71 | - 'Build a template for your events - create a theme template named %1$s Then place it in your theme\'s root directory. For the default WordPress Twenty Thirteen theme, this location will be %2$s.', |
|
72 | - 'event_espresso' |
|
73 | - ), |
|
74 | - '<strong>archive-espresso_events.php</strong>', |
|
75 | - 'wp-content/themes/twenty-fourteen' |
|
76 | - ); ?> |
|
70 | + esc_html__( |
|
71 | + 'Build a template for your events - create a theme template named %1$s Then place it in your theme\'s root directory. For the default WordPress Twenty Thirteen theme, this location will be %2$s.', |
|
72 | + 'event_espresso' |
|
73 | + ), |
|
74 | + '<strong>archive-espresso_events.php</strong>', |
|
75 | + 'wp-content/themes/twenty-fourteen' |
|
76 | + ); ?> |
|
77 | 77 | </li> |
78 | 78 | <li style="list-style-type: circle;"> |
79 | 79 | <?php printf( |
80 | - esc_html__( |
|
81 | - 'Build a template for a single event - create a theme template named %1$s Then place it in your theme\'s root directory. For the default WordPress Twenty Thirteen theme, this location will be %2$s.', |
|
82 | - 'event_espresso' |
|
83 | - ), |
|
84 | - '<strong>single-espresso_events.php</strong>', |
|
85 | - 'wp-content/themes/twenty-fourteen' |
|
86 | - ); ?> |
|
80 | + esc_html__( |
|
81 | + 'Build a template for a single event - create a theme template named %1$s Then place it in your theme\'s root directory. For the default WordPress Twenty Thirteen theme, this location will be %2$s.', |
|
82 | + 'event_espresso' |
|
83 | + ), |
|
84 | + '<strong>single-espresso_events.php</strong>', |
|
85 | + 'wp-content/themes/twenty-fourteen' |
|
86 | + ); ?> |
|
87 | 87 | </li> |
88 | 88 | </ul> |
89 | 89 | </li> |
@@ -91,33 +91,33 @@ discard block |
||
91 | 91 | <strong><?php esc_html_e('Venue List', 'event_espresso'); ?></strong> |
92 | 92 | <br /> |
93 | 93 | <?php printf( |
94 | - esc_html__( |
|
95 | - 'If you would like to style the look of your venues archive page, then follow the WordPress instructions for %1$screating a custom template for archive pages%2$s.', |
|
96 | - 'event_espresso' |
|
97 | - ), |
|
98 | - '<a href="https://codex.wordpress.org/Post_Type_Templates">', |
|
99 | - '</a>' |
|
100 | - ); ?> |
|
94 | + esc_html__( |
|
95 | + 'If you would like to style the look of your venues archive page, then follow the WordPress instructions for %1$screating a custom template for archive pages%2$s.', |
|
96 | + 'event_espresso' |
|
97 | + ), |
|
98 | + '<a href="https://codex.wordpress.org/Post_Type_Templates">', |
|
99 | + '</a>' |
|
100 | + ); ?> |
|
101 | 101 | <ul> |
102 | 102 | <li style="list-style-type: circle;"> |
103 | 103 | <?php printf( |
104 | - esc_html__( |
|
105 | - 'Build a template for your events - create a theme template named %1$s Then place it in your theme\'s root directory. For the default WordPress Twenty Thirteen theme, this location will be %2$s.', |
|
106 | - 'event_espresso' |
|
107 | - ), |
|
108 | - '<strong>archive-espresso_venues.php</strong>', |
|
109 | - 'wp-content/themes/twenty-fourteen' |
|
110 | - ); ?> |
|
104 | + esc_html__( |
|
105 | + 'Build a template for your events - create a theme template named %1$s Then place it in your theme\'s root directory. For the default WordPress Twenty Thirteen theme, this location will be %2$s.', |
|
106 | + 'event_espresso' |
|
107 | + ), |
|
108 | + '<strong>archive-espresso_venues.php</strong>', |
|
109 | + 'wp-content/themes/twenty-fourteen' |
|
110 | + ); ?> |
|
111 | 111 | </li> |
112 | 112 | <li style="list-style-type: circle;"> |
113 | 113 | <?php printf( |
114 | - esc_html__( |
|
115 | - 'Build a template for a single event - create a theme template named %1$s Then place it in your theme\'s root directory. For the default WordPress Twenty Thirteen theme, this location will be %2$s.', |
|
116 | - 'event_espresso' |
|
117 | - ), |
|
118 | - '<strong>single-espresso_venues.php</strong>', |
|
119 | - 'wp-content/themes/twenty-fourteen' |
|
120 | - ); ?> |
|
114 | + esc_html__( |
|
115 | + 'Build a template for a single event - create a theme template named %1$s Then place it in your theme\'s root directory. For the default WordPress Twenty Thirteen theme, this location will be %2$s.', |
|
116 | + 'event_espresso' |
|
117 | + ), |
|
118 | + '<strong>single-espresso_venues.php</strong>', |
|
119 | + 'wp-content/themes/twenty-fourteen' |
|
120 | + ); ?> |
|
121 | 121 | </li> |
122 | 122 | </ul> |
123 | 123 | </li> |
@@ -127,15 +127,15 @@ discard block |
||
127 | 127 | <strong><?php esc_html_e('Recommendations', 'event_espresso'); ?></strong> |
128 | 128 | <br /> |
129 | 129 | <?php esc_html_e( |
130 | - 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
131 | - 'event_espresso' |
|
132 | - ); ?> |
|
130 | + 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
131 | + 'event_espresso' |
|
132 | + ); ?> |
|
133 | 133 | </p> |
134 | 134 | <p> |
135 | 135 | <strong><?php esc_html_e('Screen Options', 'event_espresso'); ?></strong> |
136 | 136 | <br /> |
137 | 137 | <?php esc_html_e( |
138 | - 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
139 | - 'event_espresso' |
|
140 | - ); ?> |
|
138 | + 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
139 | + 'event_espresso' |
|
140 | + ); ?> |
|
141 | 141 | </p> |
142 | 142 | \ No newline at end of file |
@@ -7,35 +7,35 @@ discard block |
||
7 | 7 | </p> |
8 | 8 | <p class="ee-attention"> |
9 | 9 | <?php esc_html_e( |
10 | - 'Notice: Your log files may be publicly accessible. Logging should be turned off when its not needed.', |
|
11 | - 'event_espresso' |
|
12 | - ); ?> |
|
10 | + 'Notice: Your log files may be publicly accessible. Logging should be turned off when its not needed.', |
|
11 | + 'event_espresso' |
|
12 | + ); ?> |
|
13 | 13 | </p> |
14 | 14 | <ul> |
15 | 15 | <li> |
16 | 16 | <strong><?php esc_html_e('Enable Remote Logging', 'event_espresso'); ?></strong><br /> |
17 | 17 | <?php esc_html_e( |
18 | - 'Every time a page is accessed on your site, this option will send all Event Espresso registration form data, your server details, and debugging information to a remote server.', |
|
19 | - 'event_espresso' |
|
20 | - ); ?> |
|
18 | + 'Every time a page is accessed on your site, this option will send all Event Espresso registration form data, your server details, and debugging information to a remote server.', |
|
19 | + 'event_espresso' |
|
20 | + ); ?> |
|
21 | 21 | </li> |
22 | 22 | <li> |
23 | 23 | <strong><?php esc_html_e('Remote Logging URL', 'event_espresso'); ?></strong><br /> |
24 | 24 | <?php esc_html_e( |
25 | - 'This option sends all Event Espresso debugging data and get / post variables to the specified URL.', |
|
26 | - 'event_espresso' |
|
27 | - ); ?> |
|
25 | + 'This option sends all Event Espresso debugging data and get / post variables to the specified URL.', |
|
26 | + 'event_espresso' |
|
27 | + ); ?> |
|
28 | 28 | </li> |
29 | 29 | <li> |
30 | 30 | <strong><?php esc_html_e('Send Login Information (Optional)', 'event_espresso'); ?></strong><br /> |
31 | 31 | <?php esc_html_e( |
32 | - 'By using constants in th wp-config.php file, you can send a "key" and "pass" parameters in the remote logging action.', |
|
33 | - 'event_espresso' |
|
34 | - ); ?> |
|
32 | + 'By using constants in th wp-config.php file, you can send a "key" and "pass" parameters in the remote logging action.', |
|
33 | + 'event_espresso' |
|
34 | + ); ?> |
|
35 | 35 | <?php esc_html_e( |
36 | - 'Add the constants below to your wp-config.php file, above the line that says "That\'s all, stop editing! Happy blogging."', |
|
37 | - 'event_espresso' |
|
38 | - ); ?> |
|
36 | + 'Add the constants below to your wp-config.php file, above the line that says "That\'s all, stop editing! Happy blogging."', |
|
37 | + 'event_espresso' |
|
38 | + ); ?> |
|
39 | 39 | <pre> |
40 | 40 | define( 'EELOGGING_PASS', 'YOUR PASSWORD' ); |
41 | 41 | define( 'EELOGGING_KEY', 'YOUR REMOTE KEY' ); |
@@ -48,39 +48,39 @@ discard block |
||
48 | 48 | <ul> |
49 | 49 | <li> |
50 | 50 | <strong><?php esc_html_e( |
51 | - 'Link to Event Espresso in your Registration Page?', |
|
52 | - 'event_espresso' |
|
53 | - ); ?> |
|
51 | + 'Link to Event Espresso in your Registration Page?', |
|
52 | + 'event_espresso' |
|
53 | + ); ?> |
|
54 | 54 | </strong> |
55 | 55 | <br /> |
56 | 56 | <?php esc_html_e( |
57 | - 'Help spread the word about Event Espresso by allowing us to show a small link back to the to Event Espresso website in your registration page.', |
|
58 | - 'event_espresso' |
|
59 | - ); ?> |
|
57 | + 'Help spread the word about Event Espresso by allowing us to show a small link back to the to Event Espresso website in your registration page.', |
|
58 | + 'event_espresso' |
|
59 | + ); ?> |
|
60 | 60 | </li> |
61 | 61 | <li> |
62 | 62 | <strong><?php esc_html_e('Event Espresso Affiliate ID', 'event_espresso'); ?></strong><br /> |
63 | 63 | <?php printf( |
64 | - esc_html__( |
|
65 | - 'You can also monetize this link by signing up to our %1$saffiliate program%2$s and adding in your affiliate ID here.', |
|
66 | - 'event_espresso' |
|
67 | - ), |
|
68 | - '<a href="https://eventespresso.com/affiliates/">', |
|
69 | - '</a>' |
|
70 | - ); ?> |
|
64 | + esc_html__( |
|
65 | + 'You can also monetize this link by signing up to our %1$saffiliate program%2$s and adding in your affiliate ID here.', |
|
66 | + 'event_espresso' |
|
67 | + ), |
|
68 | + '<a href="https://eventespresso.com/affiliates/">', |
|
69 | + '</a>' |
|
70 | + ); ?> |
|
71 | 71 | </li> |
72 | 72 | </ul> |
73 | 73 | <p> |
74 | 74 | <strong><?php esc_html_e('Recommendations', 'event_espresso'); ?></strong> |
75 | 75 | <?php esc_html_e( |
76 | - 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
77 | - 'event_espresso' |
|
78 | - ); ?> |
|
76 | + 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
77 | + 'event_espresso' |
|
78 | + ); ?> |
|
79 | 79 | </p> |
80 | 80 | <p> |
81 | 81 | <strong><?php esc_html_e('Screen Options', 'event_espresso'); ?></strong><br /> |
82 | 82 | <?php esc_html_e( |
83 | - 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
84 | - 'event_espresso' |
|
85 | - ); ?> |
|
83 | + 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
84 | + 'event_espresso' |
|
85 | + ); ?> |
|
86 | 86 | </p> |
@@ -17,1412 +17,1412 @@ |
||
17 | 17 | class General_Settings_Admin_Page extends EE_Admin_Page |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * _question_group |
|
22 | - * holds the specific question group object for the question group details screen |
|
23 | - * |
|
24 | - * @var object |
|
25 | - */ |
|
26 | - protected $_question_group; |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * Initialize basic properties. |
|
31 | - */ |
|
32 | - protected function _init_page_props() |
|
33 | - { |
|
34 | - $this->page_slug = GEN_SET_PG_SLUG; |
|
35 | - $this->page_label = GEN_SET_LABEL; |
|
36 | - $this->_admin_base_url = GEN_SET_ADMIN_URL; |
|
37 | - $this->_admin_base_path = GEN_SET_ADMIN; |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * Set ajax hooks |
|
43 | - */ |
|
44 | - protected function _ajax_hooks() |
|
45 | - { |
|
46 | - add_action('wp_ajax_espresso_display_country_settings', [$this, 'display_country_settings']); |
|
47 | - add_action('wp_ajax_espresso_display_country_states', [$this, 'display_country_states']); |
|
48 | - add_action('wp_ajax_espresso_delete_state', [$this, 'delete_state'], 10, 3); |
|
49 | - add_action('wp_ajax_espresso_add_new_state', [$this, 'add_new_state']); |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * More page properties initialization. |
|
55 | - */ |
|
56 | - protected function _define_page_props() |
|
57 | - { |
|
58 | - $this->_admin_page_title = GEN_SET_LABEL; |
|
59 | - $this->_labels = [ |
|
60 | - 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
61 | - ]; |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * Set page routes property. |
|
67 | - */ |
|
68 | - protected function _set_page_routes() |
|
69 | - { |
|
70 | - $this->_page_routes = [ |
|
71 | - |
|
72 | - 'critical_pages' => [ |
|
73 | - 'func' => '_espresso_page_settings', |
|
74 | - 'capability' => 'manage_options', |
|
75 | - ], |
|
76 | - 'update_espresso_page_settings' => [ |
|
77 | - 'func' => '_update_espresso_page_settings', |
|
78 | - 'capability' => 'manage_options', |
|
79 | - 'noheader' => true, |
|
80 | - ], |
|
81 | - 'default' => [ |
|
82 | - 'func' => '_your_organization_settings', |
|
83 | - 'capability' => 'manage_options', |
|
84 | - ], |
|
85 | - |
|
86 | - 'update_your_organization_settings' => [ |
|
87 | - 'func' => '_update_your_organization_settings', |
|
88 | - 'capability' => 'manage_options', |
|
89 | - 'noheader' => true, |
|
90 | - ], |
|
91 | - |
|
92 | - 'admin_option_settings' => [ |
|
93 | - 'func' => '_admin_option_settings', |
|
94 | - 'capability' => 'manage_options', |
|
95 | - ], |
|
96 | - |
|
97 | - 'update_admin_option_settings' => [ |
|
98 | - 'func' => '_update_admin_option_settings', |
|
99 | - 'capability' => 'manage_options', |
|
100 | - 'noheader' => true, |
|
101 | - ], |
|
102 | - |
|
103 | - 'country_settings' => [ |
|
104 | - 'func' => '_country_settings', |
|
105 | - 'capability' => 'manage_options', |
|
106 | - ], |
|
107 | - |
|
108 | - 'update_country_settings' => [ |
|
109 | - 'func' => '_update_country_settings', |
|
110 | - 'capability' => 'manage_options', |
|
111 | - 'noheader' => true, |
|
112 | - ], |
|
113 | - |
|
114 | - 'display_country_settings' => [ |
|
115 | - 'func' => 'display_country_settings', |
|
116 | - 'capability' => 'manage_options', |
|
117 | - 'noheader' => true, |
|
118 | - ], |
|
119 | - |
|
120 | - 'add_new_state' => [ |
|
121 | - 'func' => 'add_new_state', |
|
122 | - 'capability' => 'manage_options', |
|
123 | - 'noheader' => true, |
|
124 | - ], |
|
125 | - |
|
126 | - 'delete_state' => [ |
|
127 | - 'func' => 'delete_state', |
|
128 | - 'capability' => 'manage_options', |
|
129 | - 'noheader' => true, |
|
130 | - ], |
|
131 | - 'privacy_settings' => [ |
|
132 | - 'func' => 'privacySettings', |
|
133 | - 'capability' => 'manage_options', |
|
134 | - ], |
|
135 | - 'update_privacy_settings' => [ |
|
136 | - 'func' => 'updatePrivacySettings', |
|
137 | - 'capability' => 'manage_options', |
|
138 | - 'noheader' => true, |
|
139 | - 'headers_sent_route' => 'privacy_settings', |
|
140 | - ], |
|
141 | - ]; |
|
142 | - } |
|
143 | - |
|
144 | - |
|
145 | - /** |
|
146 | - * Set page configuration property |
|
147 | - */ |
|
148 | - protected function _set_page_config() |
|
149 | - { |
|
150 | - $this->_page_config = [ |
|
151 | - 'critical_pages' => [ |
|
152 | - 'nav' => [ |
|
153 | - 'label' => esc_html__('Critical Pages', 'event_espresso'), |
|
154 | - 'order' => 50, |
|
155 | - ], |
|
156 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']), |
|
157 | - 'help_tabs' => [ |
|
158 | - 'general_settings_critical_pages_help_tab' => [ |
|
159 | - 'title' => esc_html__('Critical Pages', 'event_espresso'), |
|
160 | - 'filename' => 'general_settings_critical_pages', |
|
161 | - ], |
|
162 | - ], |
|
163 | - 'require_nonce' => false, |
|
164 | - ], |
|
165 | - 'default' => [ |
|
166 | - 'nav' => [ |
|
167 | - 'label' => esc_html__('Your Organization', 'event_espresso'), |
|
168 | - 'order' => 20, |
|
169 | - ], |
|
170 | - 'help_tabs' => [ |
|
171 | - 'general_settings_your_organization_help_tab' => [ |
|
172 | - 'title' => esc_html__('Your Organization', 'event_espresso'), |
|
173 | - 'filename' => 'general_settings_your_organization', |
|
174 | - ], |
|
175 | - ], |
|
176 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']), |
|
177 | - 'require_nonce' => false, |
|
178 | - ], |
|
179 | - 'admin_option_settings' => [ |
|
180 | - 'nav' => [ |
|
181 | - 'label' => esc_html__('Admin Options', 'event_espresso'), |
|
182 | - 'order' => 60, |
|
183 | - ], |
|
184 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']), |
|
185 | - 'help_tabs' => [ |
|
186 | - 'general_settings_admin_options_help_tab' => [ |
|
187 | - 'title' => esc_html__('Admin Options', 'event_espresso'), |
|
188 | - 'filename' => 'general_settings_admin_options', |
|
189 | - ], |
|
190 | - ], |
|
191 | - 'require_nonce' => false, |
|
192 | - ], |
|
193 | - 'country_settings' => [ |
|
194 | - 'nav' => [ |
|
195 | - 'label' => esc_html__('Countries', 'event_espresso'), |
|
196 | - 'order' => 70, |
|
197 | - ], |
|
198 | - 'help_tabs' => [ |
|
199 | - 'general_settings_countries_help_tab' => [ |
|
200 | - 'title' => esc_html__('Countries', 'event_espresso'), |
|
201 | - 'filename' => 'general_settings_countries', |
|
202 | - ], |
|
203 | - ], |
|
204 | - 'require_nonce' => false, |
|
205 | - ], |
|
206 | - 'privacy_settings' => [ |
|
207 | - 'nav' => [ |
|
208 | - 'label' => esc_html__('Privacy', 'event_espresso'), |
|
209 | - 'order' => 80, |
|
210 | - ], |
|
211 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']), |
|
212 | - 'require_nonce' => false, |
|
213 | - ], |
|
214 | - ]; |
|
215 | - } |
|
216 | - |
|
217 | - |
|
218 | - protected function _add_screen_options() |
|
219 | - { |
|
220 | - } |
|
221 | - |
|
222 | - |
|
223 | - protected function _add_feature_pointers() |
|
224 | - { |
|
225 | - } |
|
226 | - |
|
227 | - |
|
228 | - /** |
|
229 | - * Enqueue global scripts and styles for all routes in the General Settings Admin Pages. |
|
230 | - */ |
|
231 | - public function load_scripts_styles() |
|
232 | - { |
|
233 | - // styles |
|
234 | - wp_enqueue_style('espresso-ui-theme'); |
|
235 | - // scripts |
|
236 | - wp_enqueue_script('ee_admin_js'); |
|
237 | - } |
|
238 | - |
|
239 | - |
|
240 | - /** |
|
241 | - * Execute logic running on `admin_init` |
|
242 | - */ |
|
243 | - public function admin_init() |
|
244 | - { |
|
245 | - EE_Registry::$i18n_js_strings['invalid_server_response'] = wp_strip_all_tags(__( |
|
246 | - 'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', |
|
247 | - 'event_espresso' |
|
248 | - )); |
|
249 | - EE_Registry::$i18n_js_strings['error_occurred'] = wp_strip_all_tags(__( |
|
250 | - 'An error occurred! Please refresh the page and try again.', |
|
251 | - 'event_espresso' |
|
252 | - )); |
|
253 | - EE_Registry::$i18n_js_strings['confirm_delete_state'] = wp_strip_all_tags(__( |
|
254 | - 'Are you sure you want to delete this State / Province?', |
|
255 | - 'event_espresso' |
|
256 | - )); |
|
257 | - $protocol = is_ssl() ? 'https://' : 'http://'; |
|
258 | - EE_Registry::$i18n_js_strings['ajax_url'] = admin_url( |
|
259 | - 'admin-ajax.php?page=espresso_general_settings', |
|
260 | - $protocol |
|
261 | - ); |
|
262 | - } |
|
263 | - |
|
264 | - |
|
265 | - public function admin_notices() |
|
266 | - { |
|
267 | - } |
|
268 | - |
|
269 | - |
|
270 | - public function admin_footer_scripts() |
|
271 | - { |
|
272 | - } |
|
273 | - |
|
274 | - |
|
275 | - /** |
|
276 | - * Enqueue scripts and styles for the default route. |
|
277 | - */ |
|
278 | - public function load_scripts_styles_default() |
|
279 | - { |
|
280 | - // styles |
|
281 | - wp_enqueue_style('thickbox'); |
|
282 | - // scripts |
|
283 | - wp_enqueue_script('media-upload'); |
|
284 | - wp_enqueue_script('thickbox'); |
|
285 | - wp_register_script( |
|
286 | - 'organization_settings', |
|
287 | - GEN_SET_ASSETS_URL . 'your_organization_settings.js', |
|
288 | - ['jquery', 'media-upload', 'thickbox'], |
|
289 | - EVENT_ESPRESSO_VERSION, |
|
290 | - true |
|
291 | - ); |
|
292 | - wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION); |
|
293 | - wp_enqueue_script('organization_settings'); |
|
294 | - wp_enqueue_style('organization-css'); |
|
295 | - $confirm_image_delete = [ |
|
296 | - 'text' => wp_strip_all_tags( |
|
297 | - __( |
|
298 | - 'Do you really want to delete this image? Please remember to save your settings to complete the removal.', |
|
299 | - 'event_espresso' |
|
300 | - ) |
|
301 | - ), |
|
302 | - ]; |
|
303 | - wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete); |
|
304 | - } |
|
305 | - |
|
306 | - |
|
307 | - /** |
|
308 | - * Enqueue scripts and styles for the country settings route. |
|
309 | - */ |
|
310 | - public function load_scripts_styles_country_settings() |
|
311 | - { |
|
312 | - // scripts |
|
313 | - wp_register_script( |
|
314 | - 'gen_settings_countries', |
|
315 | - GEN_SET_ASSETS_URL . 'gen_settings_countries.js', |
|
316 | - ['ee_admin_js'], |
|
317 | - EVENT_ESPRESSO_VERSION, |
|
318 | - true |
|
319 | - ); |
|
320 | - wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION); |
|
321 | - wp_enqueue_script('gen_settings_countries'); |
|
322 | - wp_enqueue_style('organization-css'); |
|
323 | - } |
|
324 | - |
|
325 | - |
|
326 | - /************* Espresso Pages *************/ |
|
327 | - /** |
|
328 | - * _espresso_page_settings |
|
329 | - * |
|
330 | - * @throws EE_Error |
|
331 | - * @throws DomainException |
|
332 | - * @throws DomainException |
|
333 | - * @throws InvalidDataTypeException |
|
334 | - * @throws InvalidArgumentException |
|
335 | - */ |
|
336 | - protected function _espresso_page_settings() |
|
337 | - { |
|
338 | - // Check to make sure all of the main pages are set up properly, |
|
339 | - // if not create the default pages and display an admin notice |
|
340 | - EEH_Activation::verify_default_pages_exist(); |
|
341 | - $this->_transient_garbage_collection(); |
|
342 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
343 | - $this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) |
|
344 | - ? EE_Registry::instance()->CFG->core->reg_page_id |
|
345 | - : null; |
|
346 | - $this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) |
|
347 | - ? get_post(EE_Registry::instance()->CFG->core->reg_page_id) |
|
348 | - : false; |
|
349 | - $this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) |
|
350 | - ? EE_Registry::instance()->CFG->core->txn_page_id |
|
351 | - : null; |
|
352 | - $this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) |
|
353 | - ? get_post(EE_Registry::instance()->CFG->core->txn_page_id) |
|
354 | - : false; |
|
355 | - $this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
356 | - ? EE_Registry::instance()->CFG->core->thank_you_page_id |
|
357 | - : null; |
|
358 | - $this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
359 | - ? get_post(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
360 | - : false; |
|
361 | - $this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
362 | - ? EE_Registry::instance()->CFG->core->cancel_page_id |
|
363 | - : null; |
|
364 | - $this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
365 | - ? get_post(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
366 | - : false; |
|
367 | - $this->_set_add_edit_form_tags('update_espresso_page_settings'); |
|
368 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
369 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
370 | - GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php', |
|
371 | - $this->_template_args, |
|
372 | - true |
|
373 | - ); |
|
374 | - $this->display_admin_page_with_sidebar(); |
|
375 | - } |
|
376 | - |
|
377 | - |
|
378 | - /** |
|
379 | - * Handler for updating espresso page settings. |
|
380 | - * |
|
381 | - * @throws EE_Error |
|
382 | - */ |
|
383 | - protected function _update_espresso_page_settings() |
|
384 | - { |
|
385 | - // capture incoming request data && set page IDs |
|
386 | - EE_Registry::instance()->CFG->core->reg_page_id = isset($this->_req_data['reg_page_id']) |
|
387 | - ? absint($this->_req_data['reg_page_id']) |
|
388 | - : EE_Registry::instance()->CFG->core->reg_page_id; |
|
389 | - EE_Registry::instance()->CFG->core->txn_page_id = isset($this->_req_data['txn_page_id']) |
|
390 | - ? absint($this->_req_data['txn_page_id']) |
|
391 | - : EE_Registry::instance()->CFG->core->txn_page_id; |
|
392 | - EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id']) |
|
393 | - ? absint($this->_req_data['thank_you_page_id']) |
|
394 | - : EE_Registry::instance()->CFG->core->thank_you_page_id; |
|
395 | - EE_Registry::instance()->CFG->core->cancel_page_id = isset($this->_req_data['cancel_page_id']) |
|
396 | - ? absint($this->_req_data['cancel_page_id']) |
|
397 | - : EE_Registry::instance()->CFG->core->cancel_page_id; |
|
398 | - |
|
399 | - EE_Registry::instance()->CFG->core = apply_filters( |
|
400 | - 'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core', |
|
401 | - EE_Registry::instance()->CFG->core, |
|
402 | - $this->_req_data |
|
403 | - ); |
|
404 | - $what = esc_html__('Critical Pages & Shortcodes', 'event_espresso'); |
|
405 | - $this->_redirect_after_action( |
|
406 | - $this->_update_espresso_configuration( |
|
407 | - $what, |
|
408 | - EE_Registry::instance()->CFG->core, |
|
409 | - __FILE__, |
|
410 | - __FUNCTION__, |
|
411 | - __LINE__ |
|
412 | - ), |
|
413 | - $what, |
|
414 | - '', |
|
415 | - [ |
|
416 | - 'action' => 'critical_pages', |
|
417 | - ], |
|
418 | - true |
|
419 | - ); |
|
420 | - } |
|
421 | - |
|
422 | - |
|
423 | - /************* Your Organization *************/ |
|
424 | - |
|
425 | - |
|
426 | - /** |
|
427 | - * @throws DomainException |
|
428 | - * @throws EE_Error |
|
429 | - * @throws InvalidArgumentException |
|
430 | - * @throws InvalidDataTypeException |
|
431 | - * @throws InvalidInterfaceException |
|
432 | - */ |
|
433 | - protected function _your_organization_settings() |
|
434 | - { |
|
435 | - $this->_template_args['admin_page_content'] = ''; |
|
436 | - try { |
|
437 | - /** @var EventEspresso\admin_pages\general_settings\OrganizationSettings $organization_settings_form */ |
|
438 | - $organization_settings_form = $this->loader->getShared( |
|
439 | - 'EventEspresso\admin_pages\general_settings\OrganizationSettings' |
|
440 | - ); |
|
441 | - $this->_template_args['admin_page_content'] = $organization_settings_form->display(); |
|
442 | - } catch (Exception $e) { |
|
443 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
444 | - } |
|
445 | - $this->_set_add_edit_form_tags('update_your_organization_settings'); |
|
446 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
447 | - $this->display_admin_page_with_sidebar(); |
|
448 | - } |
|
449 | - |
|
450 | - |
|
451 | - /** |
|
452 | - * Handler for updating organization settings. |
|
453 | - * |
|
454 | - * @throws EE_Error |
|
455 | - */ |
|
456 | - protected function _update_your_organization_settings() |
|
457 | - { |
|
458 | - try { |
|
459 | - /** @var EventEspresso\admin_pages\general_settings\OrganizationSettings $organization_settings_form */ |
|
460 | - $organization_settings_form = $this->loader->getShared( |
|
461 | - 'EventEspresso\admin_pages\general_settings\OrganizationSettings' |
|
462 | - ); |
|
463 | - $success = $organization_settings_form->process($this->_req_data); |
|
464 | - EE_Registry::instance()->CFG = apply_filters( |
|
465 | - 'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG', |
|
466 | - EE_Registry::instance()->CFG |
|
467 | - ); |
|
468 | - } catch (Exception $e) { |
|
469 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
470 | - $success = false; |
|
471 | - } |
|
472 | - |
|
473 | - if ($success) { |
|
474 | - $success = $this->_update_espresso_configuration( |
|
475 | - esc_html__('Your Organization Settings', 'event_espresso'), |
|
476 | - EE_Registry::instance()->CFG, |
|
477 | - __FILE__, |
|
478 | - __FUNCTION__, |
|
479 | - __LINE__ |
|
480 | - ); |
|
481 | - } |
|
482 | - |
|
483 | - $this->_redirect_after_action($success, '', '', ['action' => 'default'], true); |
|
484 | - } |
|
485 | - |
|
486 | - |
|
487 | - |
|
488 | - /************* Admin Options *************/ |
|
489 | - |
|
490 | - |
|
491 | - /** |
|
492 | - * _admin_option_settings |
|
493 | - * |
|
494 | - * @throws EE_Error |
|
495 | - * @throws LogicException |
|
496 | - */ |
|
497 | - protected function _admin_option_settings() |
|
498 | - { |
|
499 | - $this->_template_args['admin_page_content'] = ''; |
|
500 | - try { |
|
501 | - $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
|
502 | - // still need this for the old school form in Extend_General_Settings_Admin_Page |
|
503 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
504 | - // also need to account for the do_action that was in the old template |
|
505 | - $admin_options_settings_form->setTemplateArgs($this->_template_args); |
|
506 | - $this->_template_args['admin_page_content'] = $admin_options_settings_form->display(); |
|
507 | - } catch (Exception $e) { |
|
508 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
509 | - } |
|
510 | - $this->_set_add_edit_form_tags('update_admin_option_settings'); |
|
511 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
512 | - $this->display_admin_page_with_sidebar(); |
|
513 | - } |
|
514 | - |
|
515 | - |
|
516 | - /** |
|
517 | - * _update_admin_option_settings |
|
518 | - * |
|
519 | - * @throws EE_Error |
|
520 | - * @throws InvalidDataTypeException |
|
521 | - * @throws InvalidFormSubmissionException |
|
522 | - * @throws InvalidArgumentException |
|
523 | - * @throws LogicException |
|
524 | - */ |
|
525 | - protected function _update_admin_option_settings() |
|
526 | - { |
|
527 | - try { |
|
528 | - $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
|
529 | - $admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]); |
|
530 | - EE_Registry::instance()->CFG->admin = apply_filters( |
|
531 | - 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', |
|
532 | - EE_Registry::instance()->CFG->admin |
|
533 | - ); |
|
534 | - } catch (Exception $e) { |
|
535 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
536 | - } |
|
537 | - $this->_redirect_after_action( |
|
538 | - apply_filters( |
|
539 | - 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success', |
|
540 | - $this->_update_espresso_configuration( |
|
541 | - 'Admin Options', |
|
542 | - EE_Registry::instance()->CFG->admin, |
|
543 | - __FILE__, |
|
544 | - __FUNCTION__, |
|
545 | - __LINE__ |
|
546 | - ) |
|
547 | - ), |
|
548 | - 'Admin Options', |
|
549 | - 'updated', |
|
550 | - ['action' => 'admin_option_settings'] |
|
551 | - ); |
|
552 | - } |
|
553 | - |
|
554 | - |
|
555 | - /************* Countries *************/ |
|
556 | - |
|
557 | - |
|
558 | - /** |
|
559 | - * @return string |
|
560 | - */ |
|
561 | - protected function getCountryIsoForSite() |
|
562 | - { |
|
563 | - return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
564 | - ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
565 | - : 'US'; |
|
566 | - } |
|
567 | - |
|
568 | - |
|
569 | - /** |
|
570 | - * @param string $CNT_ISO |
|
571 | - * @param EE_Country|null $country |
|
572 | - * @return EE_Base_Class|EE_Country |
|
573 | - * @throws EE_Error |
|
574 | - * @throws InvalidArgumentException |
|
575 | - * @throws InvalidDataTypeException |
|
576 | - * @throws InvalidInterfaceException |
|
577 | - * @throws ReflectionException |
|
578 | - */ |
|
579 | - protected function verifyOrGetCountryFromIso($CNT_ISO, EE_Country $country = null) |
|
580 | - { |
|
581 | - /** @var EE_Country $country */ |
|
582 | - return $country instanceof EE_Country && $country->ID() === $CNT_ISO |
|
583 | - ? $country |
|
584 | - : EEM_Country::instance()->get_one_by_ID($CNT_ISO); |
|
585 | - } |
|
586 | - |
|
587 | - |
|
588 | - /** |
|
589 | - * Output Country Settings view. |
|
590 | - * |
|
591 | - * @throws DomainException |
|
592 | - * @throws EE_Error |
|
593 | - * @throws InvalidArgumentException |
|
594 | - * @throws InvalidDataTypeException |
|
595 | - * @throws InvalidInterfaceException |
|
596 | - * @throws ReflectionException |
|
597 | - */ |
|
598 | - protected function _country_settings() |
|
599 | - { |
|
600 | - $CNT_ISO_for_site = $this->getCountryIsoForSite(); |
|
601 | - $CNT_ISO = isset($this->_req_data['country']) |
|
602 | - ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
603 | - : $CNT_ISO_for_site; |
|
604 | - |
|
605 | - // load field generator helper |
|
606 | - |
|
607 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
608 | - |
|
609 | - $this->_template_args['countries'] = new EE_Question_Form_Input( |
|
610 | - EE_Question::new_instance( |
|
611 | - [ |
|
612 | - 'QST_ID' => 0, |
|
613 | - 'QST_display_text' => esc_html__('Select Country', 'event_espresso'), |
|
614 | - 'QST_system' => 'admin-country', |
|
615 | - ] |
|
616 | - ), |
|
617 | - EE_Answer::new_instance( |
|
618 | - [ |
|
619 | - 'ANS_ID' => 0, |
|
620 | - 'ANS_value' => $CNT_ISO, |
|
621 | - ] |
|
622 | - ), |
|
623 | - [ |
|
624 | - 'input_id' => 'country', |
|
625 | - 'input_name' => 'country', |
|
626 | - 'input_prefix' => '', |
|
627 | - 'append_qstn_id' => false, |
|
628 | - ] |
|
629 | - ); |
|
630 | - $country = $this->verifyOrGetCountryFromIso($CNT_ISO_for_site); |
|
631 | - add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2); |
|
632 | - add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2); |
|
633 | - $this->_template_args['country_details_settings'] = $this->display_country_settings( |
|
634 | - $country->ID(), |
|
635 | - $country |
|
636 | - ); |
|
637 | - $this->_template_args['country_states_settings'] = $this->display_country_states( |
|
638 | - $country->ID(), |
|
639 | - $country |
|
640 | - ); |
|
641 | - $this->_template_args['CNT_name_for_site'] = $country->name(); |
|
642 | - |
|
643 | - $this->_set_add_edit_form_tags('update_country_settings'); |
|
644 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
645 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
646 | - GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php', |
|
647 | - $this->_template_args, |
|
648 | - true |
|
649 | - ); |
|
650 | - $this->display_admin_page_with_no_sidebar(); |
|
651 | - } |
|
652 | - |
|
653 | - |
|
654 | - /** |
|
655 | - * @param string $CNT_ISO |
|
656 | - * @param EE_Country|null $country |
|
657 | - * @return string |
|
658 | - * @throws DomainException |
|
659 | - * @throws EE_Error |
|
660 | - * @throws InvalidArgumentException |
|
661 | - * @throws InvalidDataTypeException |
|
662 | - * @throws InvalidInterfaceException |
|
663 | - * @throws ReflectionException |
|
664 | - */ |
|
665 | - public function display_country_settings($CNT_ISO = '', EE_Country $country = null) |
|
666 | - { |
|
667 | - $CNT_ISO_for_site = $this->getCountryIsoForSite(); |
|
668 | - |
|
669 | - $CNT_ISO = isset($this->_req_data['country']) |
|
670 | - ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
671 | - : $CNT_ISO; |
|
672 | - if (! $CNT_ISO) { |
|
673 | - return ''; |
|
674 | - } |
|
675 | - |
|
676 | - // for ajax |
|
677 | - remove_all_filters('FHEE__EEH_Form_Fields__label_html'); |
|
678 | - remove_all_filters('FHEE__EEH_Form_Fields__input_html'); |
|
679 | - add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2); |
|
680 | - add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2); |
|
681 | - $country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country); |
|
682 | - $CNT_cur_disabled = $CNT_ISO !== $CNT_ISO_for_site; |
|
683 | - $this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled; |
|
684 | - |
|
685 | - $country_input_types = [ |
|
686 | - 'CNT_active' => [ |
|
687 | - 'type' => 'RADIO_BTN', |
|
688 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
689 | - 'class' => '', |
|
690 | - 'options' => $this->_yes_no_values, |
|
691 | - 'use_desc_4_label' => true, |
|
692 | - ], |
|
693 | - 'CNT_ISO' => [ |
|
694 | - 'type' => 'TEXT', |
|
695 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
696 | - 'class' => 'small-text', |
|
697 | - ], |
|
698 | - 'CNT_ISO3' => [ |
|
699 | - 'type' => 'TEXT', |
|
700 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
701 | - 'class' => 'small-text', |
|
702 | - ], |
|
703 | - 'RGN_ID' => [ |
|
704 | - 'type' => 'TEXT', |
|
705 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
706 | - 'class' => 'small-text', |
|
707 | - ], |
|
708 | - 'CNT_name' => [ |
|
709 | - 'type' => 'TEXT', |
|
710 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
711 | - 'class' => 'regular-text', |
|
712 | - ], |
|
713 | - 'CNT_cur_code' => [ |
|
714 | - 'type' => 'TEXT', |
|
715 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
716 | - 'class' => 'small-text', |
|
717 | - 'disabled' => $CNT_cur_disabled, |
|
718 | - ], |
|
719 | - 'CNT_cur_single' => [ |
|
720 | - 'type' => 'TEXT', |
|
721 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
722 | - 'class' => 'medium-text', |
|
723 | - 'disabled' => $CNT_cur_disabled, |
|
724 | - ], |
|
725 | - 'CNT_cur_plural' => [ |
|
726 | - 'type' => 'TEXT', |
|
727 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
728 | - 'class' => 'medium-text', |
|
729 | - 'disabled' => $CNT_cur_disabled, |
|
730 | - ], |
|
731 | - 'CNT_cur_sign' => [ |
|
732 | - 'type' => 'TEXT', |
|
733 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
734 | - 'class' => 'small-text', |
|
735 | - 'htmlentities' => false, |
|
736 | - 'disabled' => $CNT_cur_disabled, |
|
737 | - ], |
|
738 | - 'CNT_cur_sign_b4' => [ |
|
739 | - 'type' => 'RADIO_BTN', |
|
740 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
741 | - 'class' => '', |
|
742 | - 'options' => $this->_yes_no_values, |
|
743 | - 'use_desc_4_label' => true, |
|
744 | - 'disabled' => $CNT_cur_disabled, |
|
745 | - ], |
|
746 | - 'CNT_cur_dec_plc' => [ |
|
747 | - 'type' => 'RADIO_BTN', |
|
748 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
749 | - 'class' => '', |
|
750 | - 'options' => [ |
|
751 | - ['id' => 0, 'text' => ''], |
|
752 | - ['id' => 1, 'text' => ''], |
|
753 | - ['id' => 2, 'text' => ''], |
|
754 | - ['id' => 3, 'text' => ''], |
|
755 | - ], |
|
756 | - 'disabled' => $CNT_cur_disabled, |
|
757 | - ], |
|
758 | - 'CNT_cur_dec_mrk' => [ |
|
759 | - 'type' => 'RADIO_BTN', |
|
760 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
761 | - 'class' => '', |
|
762 | - 'options' => [ |
|
763 | - [ |
|
764 | - 'id' => ',', |
|
765 | - 'text' => esc_html__(', (comma)', 'event_espresso'), |
|
766 | - ], |
|
767 | - ['id' => '.', 'text' => esc_html__('. (decimal)', 'event_espresso')], |
|
768 | - ], |
|
769 | - 'use_desc_4_label' => true, |
|
770 | - 'disabled' => $CNT_cur_disabled, |
|
771 | - ], |
|
772 | - 'CNT_cur_thsnds' => [ |
|
773 | - 'type' => 'RADIO_BTN', |
|
774 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
775 | - 'class' => '', |
|
776 | - 'options' => [ |
|
777 | - [ |
|
778 | - 'id' => ',', |
|
779 | - 'text' => esc_html__(', (comma)', 'event_espresso'), |
|
780 | - ], |
|
781 | - [ |
|
782 | - 'id' => '.', |
|
783 | - 'text' => esc_html__('. (decimal)', 'event_espresso'), |
|
784 | - ], |
|
785 | - [ |
|
786 | - 'id' => ' ', |
|
787 | - 'text' => esc_html__('(space)', 'event_espresso'), |
|
788 | - ], |
|
789 | - ], |
|
790 | - 'use_desc_4_label' => true, |
|
791 | - 'disabled' => $CNT_cur_disabled, |
|
792 | - ], |
|
793 | - 'CNT_tel_code' => [ |
|
794 | - 'type' => 'TEXT', |
|
795 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
796 | - 'class' => 'small-text', |
|
797 | - ], |
|
798 | - 'CNT_is_EU' => [ |
|
799 | - 'type' => 'RADIO_BTN', |
|
800 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
801 | - 'class' => '', |
|
802 | - 'options' => $this->_yes_no_values, |
|
803 | - 'use_desc_4_label' => true, |
|
804 | - ], |
|
805 | - ]; |
|
806 | - $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object( |
|
807 | - $country, |
|
808 | - $country_input_types |
|
809 | - ); |
|
810 | - $country_details_settings = EEH_Template::display_template( |
|
811 | - GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php', |
|
812 | - $this->_template_args, |
|
813 | - true |
|
814 | - ); |
|
815 | - |
|
816 | - if (defined('DOING_AJAX')) { |
|
817 | - $notices = EE_Error::get_notices(false, false, false); |
|
818 | - echo wp_json_encode( |
|
819 | - [ |
|
820 | - 'return_data' => $country_details_settings, |
|
821 | - 'success' => $notices['success'], |
|
822 | - 'errors' => $notices['errors'], |
|
823 | - ] |
|
824 | - ); |
|
825 | - die(); |
|
826 | - } else { |
|
827 | - return $country_details_settings; |
|
828 | - } |
|
829 | - } |
|
830 | - |
|
831 | - |
|
832 | - /** |
|
833 | - * @param string $CNT_ISO |
|
834 | - * @param EE_Country|null $country |
|
835 | - * @return string |
|
836 | - * @throws DomainException |
|
837 | - * @throws EE_Error |
|
838 | - * @throws InvalidArgumentException |
|
839 | - * @throws InvalidDataTypeException |
|
840 | - * @throws InvalidInterfaceException |
|
841 | - * @throws ReflectionException |
|
842 | - */ |
|
843 | - public function display_country_states($CNT_ISO = '', EE_Country $country = null) |
|
844 | - { |
|
845 | - |
|
846 | - $CNT_ISO = isset($this->_req_data['country']) |
|
847 | - ? sanitize_text_field($this->_req_data['country']) |
|
848 | - : $CNT_ISO; |
|
849 | - if (! $CNT_ISO) { |
|
850 | - return ''; |
|
851 | - } |
|
852 | - // for ajax |
|
853 | - remove_all_filters('FHEE__EEH_Form_Fields__label_html'); |
|
854 | - remove_all_filters('FHEE__EEH_Form_Fields__input_html'); |
|
855 | - add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'state_form_field_label_wrap'], 10, 2); |
|
856 | - add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'state_form_field_input__wrap'], 10, 2); |
|
857 | - $states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]); |
|
858 | - if (empty($states)) { |
|
859 | - /** @var EventEspresso\core\services\address\CountrySubRegionDao $countrySubRegionDao */ |
|
860 | - $countrySubRegionDao = $this->loader->getShared( |
|
861 | - 'EventEspresso\core\services\address\CountrySubRegionDao' |
|
862 | - ); |
|
863 | - if ($countrySubRegionDao instanceof EventEspresso\core\services\address\CountrySubRegionDao) { |
|
864 | - $country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country); |
|
865 | - if ($countrySubRegionDao->saveCountrySubRegions($country)) { |
|
866 | - $states = EEM_State::instance()->get_all_states_for_these_countries( |
|
867 | - [$CNT_ISO => $CNT_ISO] |
|
868 | - ); |
|
869 | - } |
|
870 | - } |
|
871 | - } |
|
872 | - if (is_array($states)) { |
|
873 | - foreach ($states as $STA_ID => $state) { |
|
874 | - if ($state instanceof EE_State) { |
|
875 | - // STA_abbrev STA_name STA_active |
|
876 | - $state_input_types = [ |
|
877 | - 'STA_abbrev' => [ |
|
878 | - 'type' => 'TEXT', |
|
879 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
880 | - 'class' => 'small-text', |
|
881 | - ], |
|
882 | - 'STA_name' => [ |
|
883 | - 'type' => 'TEXT', |
|
884 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
885 | - 'class' => 'regular-text', |
|
886 | - ], |
|
887 | - 'STA_active' => [ |
|
888 | - 'type' => 'RADIO_BTN', |
|
889 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
890 | - 'options' => $this->_yes_no_values, |
|
891 | - 'use_desc_4_label' => true, |
|
892 | - ], |
|
893 | - ]; |
|
894 | - $this->_template_args['states'][ $STA_ID ]['inputs'] = |
|
895 | - EE_Question_Form_Input::generate_question_form_inputs_for_object( |
|
896 | - $state, |
|
897 | - $state_input_types |
|
898 | - ); |
|
899 | - $query_args = [ |
|
900 | - 'action' => 'delete_state', |
|
901 | - 'STA_ID' => $STA_ID, |
|
902 | - 'CNT_ISO' => $CNT_ISO, |
|
903 | - 'STA_abbrev' => $state->abbrev(), |
|
904 | - ]; |
|
905 | - $this->_template_args['states'][ $STA_ID ]['delete_state_url'] = |
|
906 | - EE_Admin_Page::add_query_args_and_nonce( |
|
907 | - $query_args, |
|
908 | - GEN_SET_ADMIN_URL |
|
909 | - ); |
|
910 | - } |
|
911 | - } |
|
912 | - } else { |
|
913 | - $this->_template_args['states'] = false; |
|
914 | - } |
|
915 | - |
|
916 | - $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
917 | - ['action' => 'add_new_state'], |
|
918 | - GEN_SET_ADMIN_URL |
|
919 | - ); |
|
920 | - |
|
921 | - $state_details_settings = EEH_Template::display_template( |
|
922 | - GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php', |
|
923 | - $this->_template_args, |
|
924 | - true |
|
925 | - ); |
|
926 | - |
|
927 | - if (defined('DOING_AJAX')) { |
|
928 | - $notices = EE_Error::get_notices(false, false, false); |
|
929 | - echo wp_json_encode( |
|
930 | - [ |
|
931 | - 'return_data' => $state_details_settings, |
|
932 | - 'success' => $notices['success'], |
|
933 | - 'errors' => $notices['errors'], |
|
934 | - ] |
|
935 | - ); |
|
936 | - die(); |
|
937 | - } else { |
|
938 | - return $state_details_settings; |
|
939 | - } |
|
940 | - } |
|
941 | - |
|
942 | - |
|
943 | - /** |
|
944 | - * add_new_state |
|
945 | - * |
|
946 | - * @access public |
|
947 | - * @return void |
|
948 | - * @throws EE_Error |
|
949 | - * @throws InvalidArgumentException |
|
950 | - * @throws InvalidDataTypeException |
|
951 | - * @throws InvalidInterfaceException |
|
952 | - */ |
|
953 | - public function add_new_state() |
|
954 | - { |
|
955 | - |
|
956 | - $success = true; |
|
957 | - |
|
958 | - $CNT_ISO = isset($this->_req_data['CNT_ISO']) |
|
959 | - ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) |
|
960 | - : false; |
|
961 | - if (! $CNT_ISO) { |
|
962 | - EE_Error::add_error( |
|
963 | - esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
|
964 | - __FILE__, |
|
965 | - __FUNCTION__, |
|
966 | - __LINE__ |
|
967 | - ); |
|
968 | - $success = false; |
|
969 | - } |
|
970 | - $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
|
971 | - ? sanitize_text_field($this->_req_data['STA_abbrev']) |
|
972 | - : false; |
|
973 | - if (! $STA_abbrev) { |
|
974 | - EE_Error::add_error( |
|
975 | - esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'), |
|
976 | - __FILE__, |
|
977 | - __FUNCTION__, |
|
978 | - __LINE__ |
|
979 | - ); |
|
980 | - $success = false; |
|
981 | - } |
|
982 | - $STA_name = isset($this->_req_data['STA_name']) |
|
983 | - ? sanitize_text_field($this->_req_data['STA_name']) |
|
984 | - : false; |
|
985 | - if (! $STA_name) { |
|
986 | - EE_Error::add_error( |
|
987 | - esc_html__('No State name or an invalid State name was received.', 'event_espresso'), |
|
988 | - __FILE__, |
|
989 | - __FUNCTION__, |
|
990 | - __LINE__ |
|
991 | - ); |
|
992 | - $success = false; |
|
993 | - } |
|
994 | - |
|
995 | - if ($success) { |
|
996 | - $cols_n_values = [ |
|
997 | - 'CNT_ISO' => $CNT_ISO, |
|
998 | - 'STA_abbrev' => $STA_abbrev, |
|
999 | - 'STA_name' => $STA_name, |
|
1000 | - 'STA_active' => true, |
|
1001 | - ]; |
|
1002 | - $success = EEM_State::instance()->insert($cols_n_values); |
|
1003 | - EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso')); |
|
1004 | - } |
|
1005 | - |
|
1006 | - if (defined('DOING_AJAX')) { |
|
1007 | - $notices = EE_Error::get_notices(false, false, false); |
|
1008 | - echo wp_json_encode(array_merge($notices, ['return_data' => $CNT_ISO])); |
|
1009 | - die(); |
|
1010 | - } else { |
|
1011 | - $this->_redirect_after_action($success, 'State', 'added', ['action' => 'country_settings']); |
|
1012 | - } |
|
1013 | - } |
|
1014 | - |
|
1015 | - |
|
1016 | - /** |
|
1017 | - * @return void |
|
1018 | - * @throws EE_Error |
|
1019 | - * @throws InvalidArgumentException |
|
1020 | - * @throws InvalidDataTypeException |
|
1021 | - * @throws InvalidInterfaceException |
|
1022 | - */ |
|
1023 | - public function delete_state() |
|
1024 | - { |
|
1025 | - $CNT_ISO = isset($this->_req_data['CNT_ISO']) |
|
1026 | - ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) |
|
1027 | - : false; |
|
1028 | - $STA_ID = isset($this->_req_data['STA_ID']) |
|
1029 | - ? sanitize_text_field($this->_req_data['STA_ID']) |
|
1030 | - : false; |
|
1031 | - $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
|
1032 | - ? sanitize_text_field($this->_req_data['STA_abbrev']) |
|
1033 | - : false; |
|
1034 | - if (! $STA_ID) { |
|
1035 | - EE_Error::add_error( |
|
1036 | - esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'), |
|
1037 | - __FILE__, |
|
1038 | - __FUNCTION__, |
|
1039 | - __LINE__ |
|
1040 | - ); |
|
1041 | - return; |
|
1042 | - } |
|
1043 | - |
|
1044 | - $success = EEM_State::instance()->delete_by_ID($STA_ID); |
|
1045 | - if ($success !== false) { |
|
1046 | - do_action( |
|
1047 | - 'AHEE__General_Settings_Admin_Page__delete_state__state_deleted', |
|
1048 | - $CNT_ISO, |
|
1049 | - $STA_ID, |
|
1050 | - ['STA_abbrev' => $STA_abbrev] |
|
1051 | - ); |
|
1052 | - EE_Error::add_success(esc_html__('The State was deleted successfully.', 'event_espresso')); |
|
1053 | - } |
|
1054 | - if (defined('DOING_AJAX')) { |
|
1055 | - $notices = EE_Error::get_notices(false); |
|
1056 | - $notices['return_data'] = true; |
|
1057 | - echo wp_json_encode($notices); |
|
1058 | - die(); |
|
1059 | - } else { |
|
1060 | - $this->_redirect_after_action( |
|
1061 | - $success, |
|
1062 | - 'State', |
|
1063 | - 'deleted', |
|
1064 | - ['action' => 'country_settings'] |
|
1065 | - ); |
|
1066 | - } |
|
1067 | - } |
|
1068 | - |
|
1069 | - |
|
1070 | - /** |
|
1071 | - * _update_country_settings |
|
1072 | - * |
|
1073 | - * @return void |
|
1074 | - * @throws EE_Error |
|
1075 | - * @throws InvalidArgumentException |
|
1076 | - * @throws InvalidDataTypeException |
|
1077 | - * @throws InvalidInterfaceException |
|
1078 | - */ |
|
1079 | - protected function _update_country_settings() |
|
1080 | - { |
|
1081 | - // grab the country ISO code |
|
1082 | - $CNT_ISO = isset($this->_req_data['country']) |
|
1083 | - ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
1084 | - : false; |
|
1085 | - if (! $CNT_ISO) { |
|
1086 | - EE_Error::add_error( |
|
1087 | - esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
|
1088 | - __FILE__, |
|
1089 | - __FUNCTION__, |
|
1090 | - __LINE__ |
|
1091 | - ); |
|
1092 | - |
|
1093 | - return; |
|
1094 | - } |
|
1095 | - $cols_n_values = []; |
|
1096 | - $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']) |
|
1097 | - ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])) |
|
1098 | - : false; |
|
1099 | - $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID']) |
|
1100 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID']) |
|
1101 | - : null; |
|
1102 | - $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name']) |
|
1103 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name']) |
|
1104 | - : null; |
|
1105 | - if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])) { |
|
1106 | - $cols_n_values['CNT_cur_code'] = strtoupper( |
|
1107 | - sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code']) |
|
1108 | - ); |
|
1109 | - } |
|
1110 | - if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'])) { |
|
1111 | - $cols_n_values['CNT_cur_single'] = sanitize_text_field( |
|
1112 | - $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'] |
|
1113 | - ); |
|
1114 | - } |
|
1115 | - if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'])) { |
|
1116 | - $cols_n_values['CNT_cur_plural'] = sanitize_text_field( |
|
1117 | - $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'] |
|
1118 | - ); |
|
1119 | - } |
|
1120 | - if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'])) { |
|
1121 | - $cols_n_values['CNT_cur_sign'] = sanitize_text_field( |
|
1122 | - $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'] |
|
1123 | - ); |
|
1124 | - } |
|
1125 | - if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'])) { |
|
1126 | - $cols_n_values['CNT_cur_sign_b4'] = absint( |
|
1127 | - $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'] |
|
1128 | - ); |
|
1129 | - } |
|
1130 | - if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'])) { |
|
1131 | - $cols_n_values['CNT_cur_dec_plc'] = absint( |
|
1132 | - $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'] |
|
1133 | - ); |
|
1134 | - } |
|
1135 | - if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'])) { |
|
1136 | - $cols_n_values['CNT_cur_dec_mrk'] = sanitize_text_field( |
|
1137 | - $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'] |
|
1138 | - ); |
|
1139 | - } |
|
1140 | - if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'])) { |
|
1141 | - $cols_n_values['CNT_cur_thsnds'] = sanitize_text_field( |
|
1142 | - $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'] |
|
1143 | - ); |
|
1144 | - } |
|
1145 | - $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code']) |
|
1146 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code']) |
|
1147 | - : null; |
|
1148 | - $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU']) |
|
1149 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU']) |
|
1150 | - : false; |
|
1151 | - $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active']) |
|
1152 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active']) |
|
1153 | - : false; |
|
1154 | - // allow filtering of country data |
|
1155 | - $cols_n_values = apply_filters( |
|
1156 | - 'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values', |
|
1157 | - $cols_n_values |
|
1158 | - ); |
|
1159 | - |
|
1160 | - // where values |
|
1161 | - $where_cols_n_values = [['CNT_ISO' => $CNT_ISO]]; |
|
1162 | - // run the update |
|
1163 | - $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values); |
|
1164 | - |
|
1165 | - if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) { |
|
1166 | - // allow filtering of states data |
|
1167 | - $states = apply_filters( |
|
1168 | - 'FHEE__General_Settings_Admin_Page___update_country_settings__states', |
|
1169 | - $this->_req_data['states'] |
|
1170 | - ); |
|
1171 | - |
|
1172 | - // loop thru state data ( looks like : states[75][STA_name] ) |
|
1173 | - foreach ($states as $STA_ID => $state) { |
|
1174 | - $cols_n_values = [ |
|
1175 | - 'CNT_ISO' => $CNT_ISO, |
|
1176 | - 'STA_abbrev' => sanitize_text_field($state['STA_abbrev']), |
|
1177 | - 'STA_name' => sanitize_text_field($state['STA_name']), |
|
1178 | - 'STA_active' => (bool) absint($state['STA_active']), |
|
1179 | - ]; |
|
1180 | - // where values |
|
1181 | - $where_cols_n_values = [['STA_ID' => $STA_ID]]; |
|
1182 | - // run the update |
|
1183 | - $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values); |
|
1184 | - if ($success !== false) { |
|
1185 | - do_action( |
|
1186 | - 'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', |
|
1187 | - $CNT_ISO, |
|
1188 | - $STA_ID, |
|
1189 | - $cols_n_values |
|
1190 | - ); |
|
1191 | - } |
|
1192 | - } |
|
1193 | - } |
|
1194 | - // check if country being edited matches org option country, and if so, then update EE_Config with new settings |
|
1195 | - if ( |
|
1196 | - isset(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
1197 | - && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO |
|
1198 | - ) { |
|
1199 | - EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO); |
|
1200 | - EE_Registry::instance()->CFG->update_espresso_config(); |
|
1201 | - } |
|
1202 | - |
|
1203 | - if ($success !== false) { |
|
1204 | - EE_Error::add_success( |
|
1205 | - esc_html__('Country Settings updated successfully.', 'event_espresso') |
|
1206 | - ); |
|
1207 | - } |
|
1208 | - $this->_redirect_after_action( |
|
1209 | - $success, |
|
1210 | - '', |
|
1211 | - '', |
|
1212 | - ['action' => 'country_settings', 'country' => $CNT_ISO], |
|
1213 | - true |
|
1214 | - ); |
|
1215 | - } |
|
1216 | - |
|
1217 | - |
|
1218 | - /** |
|
1219 | - * form_form_field_label_wrap |
|
1220 | - * |
|
1221 | - * @param string $label |
|
1222 | - * @return string |
|
1223 | - */ |
|
1224 | - public function country_form_field_label_wrap($label, $required_text) |
|
1225 | - { |
|
1226 | - return ' |
|
20 | + /** |
|
21 | + * _question_group |
|
22 | + * holds the specific question group object for the question group details screen |
|
23 | + * |
|
24 | + * @var object |
|
25 | + */ |
|
26 | + protected $_question_group; |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * Initialize basic properties. |
|
31 | + */ |
|
32 | + protected function _init_page_props() |
|
33 | + { |
|
34 | + $this->page_slug = GEN_SET_PG_SLUG; |
|
35 | + $this->page_label = GEN_SET_LABEL; |
|
36 | + $this->_admin_base_url = GEN_SET_ADMIN_URL; |
|
37 | + $this->_admin_base_path = GEN_SET_ADMIN; |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * Set ajax hooks |
|
43 | + */ |
|
44 | + protected function _ajax_hooks() |
|
45 | + { |
|
46 | + add_action('wp_ajax_espresso_display_country_settings', [$this, 'display_country_settings']); |
|
47 | + add_action('wp_ajax_espresso_display_country_states', [$this, 'display_country_states']); |
|
48 | + add_action('wp_ajax_espresso_delete_state', [$this, 'delete_state'], 10, 3); |
|
49 | + add_action('wp_ajax_espresso_add_new_state', [$this, 'add_new_state']); |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * More page properties initialization. |
|
55 | + */ |
|
56 | + protected function _define_page_props() |
|
57 | + { |
|
58 | + $this->_admin_page_title = GEN_SET_LABEL; |
|
59 | + $this->_labels = [ |
|
60 | + 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
61 | + ]; |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * Set page routes property. |
|
67 | + */ |
|
68 | + protected function _set_page_routes() |
|
69 | + { |
|
70 | + $this->_page_routes = [ |
|
71 | + |
|
72 | + 'critical_pages' => [ |
|
73 | + 'func' => '_espresso_page_settings', |
|
74 | + 'capability' => 'manage_options', |
|
75 | + ], |
|
76 | + 'update_espresso_page_settings' => [ |
|
77 | + 'func' => '_update_espresso_page_settings', |
|
78 | + 'capability' => 'manage_options', |
|
79 | + 'noheader' => true, |
|
80 | + ], |
|
81 | + 'default' => [ |
|
82 | + 'func' => '_your_organization_settings', |
|
83 | + 'capability' => 'manage_options', |
|
84 | + ], |
|
85 | + |
|
86 | + 'update_your_organization_settings' => [ |
|
87 | + 'func' => '_update_your_organization_settings', |
|
88 | + 'capability' => 'manage_options', |
|
89 | + 'noheader' => true, |
|
90 | + ], |
|
91 | + |
|
92 | + 'admin_option_settings' => [ |
|
93 | + 'func' => '_admin_option_settings', |
|
94 | + 'capability' => 'manage_options', |
|
95 | + ], |
|
96 | + |
|
97 | + 'update_admin_option_settings' => [ |
|
98 | + 'func' => '_update_admin_option_settings', |
|
99 | + 'capability' => 'manage_options', |
|
100 | + 'noheader' => true, |
|
101 | + ], |
|
102 | + |
|
103 | + 'country_settings' => [ |
|
104 | + 'func' => '_country_settings', |
|
105 | + 'capability' => 'manage_options', |
|
106 | + ], |
|
107 | + |
|
108 | + 'update_country_settings' => [ |
|
109 | + 'func' => '_update_country_settings', |
|
110 | + 'capability' => 'manage_options', |
|
111 | + 'noheader' => true, |
|
112 | + ], |
|
113 | + |
|
114 | + 'display_country_settings' => [ |
|
115 | + 'func' => 'display_country_settings', |
|
116 | + 'capability' => 'manage_options', |
|
117 | + 'noheader' => true, |
|
118 | + ], |
|
119 | + |
|
120 | + 'add_new_state' => [ |
|
121 | + 'func' => 'add_new_state', |
|
122 | + 'capability' => 'manage_options', |
|
123 | + 'noheader' => true, |
|
124 | + ], |
|
125 | + |
|
126 | + 'delete_state' => [ |
|
127 | + 'func' => 'delete_state', |
|
128 | + 'capability' => 'manage_options', |
|
129 | + 'noheader' => true, |
|
130 | + ], |
|
131 | + 'privacy_settings' => [ |
|
132 | + 'func' => 'privacySettings', |
|
133 | + 'capability' => 'manage_options', |
|
134 | + ], |
|
135 | + 'update_privacy_settings' => [ |
|
136 | + 'func' => 'updatePrivacySettings', |
|
137 | + 'capability' => 'manage_options', |
|
138 | + 'noheader' => true, |
|
139 | + 'headers_sent_route' => 'privacy_settings', |
|
140 | + ], |
|
141 | + ]; |
|
142 | + } |
|
143 | + |
|
144 | + |
|
145 | + /** |
|
146 | + * Set page configuration property |
|
147 | + */ |
|
148 | + protected function _set_page_config() |
|
149 | + { |
|
150 | + $this->_page_config = [ |
|
151 | + 'critical_pages' => [ |
|
152 | + 'nav' => [ |
|
153 | + 'label' => esc_html__('Critical Pages', 'event_espresso'), |
|
154 | + 'order' => 50, |
|
155 | + ], |
|
156 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']), |
|
157 | + 'help_tabs' => [ |
|
158 | + 'general_settings_critical_pages_help_tab' => [ |
|
159 | + 'title' => esc_html__('Critical Pages', 'event_espresso'), |
|
160 | + 'filename' => 'general_settings_critical_pages', |
|
161 | + ], |
|
162 | + ], |
|
163 | + 'require_nonce' => false, |
|
164 | + ], |
|
165 | + 'default' => [ |
|
166 | + 'nav' => [ |
|
167 | + 'label' => esc_html__('Your Organization', 'event_espresso'), |
|
168 | + 'order' => 20, |
|
169 | + ], |
|
170 | + 'help_tabs' => [ |
|
171 | + 'general_settings_your_organization_help_tab' => [ |
|
172 | + 'title' => esc_html__('Your Organization', 'event_espresso'), |
|
173 | + 'filename' => 'general_settings_your_organization', |
|
174 | + ], |
|
175 | + ], |
|
176 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']), |
|
177 | + 'require_nonce' => false, |
|
178 | + ], |
|
179 | + 'admin_option_settings' => [ |
|
180 | + 'nav' => [ |
|
181 | + 'label' => esc_html__('Admin Options', 'event_espresso'), |
|
182 | + 'order' => 60, |
|
183 | + ], |
|
184 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']), |
|
185 | + 'help_tabs' => [ |
|
186 | + 'general_settings_admin_options_help_tab' => [ |
|
187 | + 'title' => esc_html__('Admin Options', 'event_espresso'), |
|
188 | + 'filename' => 'general_settings_admin_options', |
|
189 | + ], |
|
190 | + ], |
|
191 | + 'require_nonce' => false, |
|
192 | + ], |
|
193 | + 'country_settings' => [ |
|
194 | + 'nav' => [ |
|
195 | + 'label' => esc_html__('Countries', 'event_espresso'), |
|
196 | + 'order' => 70, |
|
197 | + ], |
|
198 | + 'help_tabs' => [ |
|
199 | + 'general_settings_countries_help_tab' => [ |
|
200 | + 'title' => esc_html__('Countries', 'event_espresso'), |
|
201 | + 'filename' => 'general_settings_countries', |
|
202 | + ], |
|
203 | + ], |
|
204 | + 'require_nonce' => false, |
|
205 | + ], |
|
206 | + 'privacy_settings' => [ |
|
207 | + 'nav' => [ |
|
208 | + 'label' => esc_html__('Privacy', 'event_espresso'), |
|
209 | + 'order' => 80, |
|
210 | + ], |
|
211 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']), |
|
212 | + 'require_nonce' => false, |
|
213 | + ], |
|
214 | + ]; |
|
215 | + } |
|
216 | + |
|
217 | + |
|
218 | + protected function _add_screen_options() |
|
219 | + { |
|
220 | + } |
|
221 | + |
|
222 | + |
|
223 | + protected function _add_feature_pointers() |
|
224 | + { |
|
225 | + } |
|
226 | + |
|
227 | + |
|
228 | + /** |
|
229 | + * Enqueue global scripts and styles for all routes in the General Settings Admin Pages. |
|
230 | + */ |
|
231 | + public function load_scripts_styles() |
|
232 | + { |
|
233 | + // styles |
|
234 | + wp_enqueue_style('espresso-ui-theme'); |
|
235 | + // scripts |
|
236 | + wp_enqueue_script('ee_admin_js'); |
|
237 | + } |
|
238 | + |
|
239 | + |
|
240 | + /** |
|
241 | + * Execute logic running on `admin_init` |
|
242 | + */ |
|
243 | + public function admin_init() |
|
244 | + { |
|
245 | + EE_Registry::$i18n_js_strings['invalid_server_response'] = wp_strip_all_tags(__( |
|
246 | + 'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', |
|
247 | + 'event_espresso' |
|
248 | + )); |
|
249 | + EE_Registry::$i18n_js_strings['error_occurred'] = wp_strip_all_tags(__( |
|
250 | + 'An error occurred! Please refresh the page and try again.', |
|
251 | + 'event_espresso' |
|
252 | + )); |
|
253 | + EE_Registry::$i18n_js_strings['confirm_delete_state'] = wp_strip_all_tags(__( |
|
254 | + 'Are you sure you want to delete this State / Province?', |
|
255 | + 'event_espresso' |
|
256 | + )); |
|
257 | + $protocol = is_ssl() ? 'https://' : 'http://'; |
|
258 | + EE_Registry::$i18n_js_strings['ajax_url'] = admin_url( |
|
259 | + 'admin-ajax.php?page=espresso_general_settings', |
|
260 | + $protocol |
|
261 | + ); |
|
262 | + } |
|
263 | + |
|
264 | + |
|
265 | + public function admin_notices() |
|
266 | + { |
|
267 | + } |
|
268 | + |
|
269 | + |
|
270 | + public function admin_footer_scripts() |
|
271 | + { |
|
272 | + } |
|
273 | + |
|
274 | + |
|
275 | + /** |
|
276 | + * Enqueue scripts and styles for the default route. |
|
277 | + */ |
|
278 | + public function load_scripts_styles_default() |
|
279 | + { |
|
280 | + // styles |
|
281 | + wp_enqueue_style('thickbox'); |
|
282 | + // scripts |
|
283 | + wp_enqueue_script('media-upload'); |
|
284 | + wp_enqueue_script('thickbox'); |
|
285 | + wp_register_script( |
|
286 | + 'organization_settings', |
|
287 | + GEN_SET_ASSETS_URL . 'your_organization_settings.js', |
|
288 | + ['jquery', 'media-upload', 'thickbox'], |
|
289 | + EVENT_ESPRESSO_VERSION, |
|
290 | + true |
|
291 | + ); |
|
292 | + wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION); |
|
293 | + wp_enqueue_script('organization_settings'); |
|
294 | + wp_enqueue_style('organization-css'); |
|
295 | + $confirm_image_delete = [ |
|
296 | + 'text' => wp_strip_all_tags( |
|
297 | + __( |
|
298 | + 'Do you really want to delete this image? Please remember to save your settings to complete the removal.', |
|
299 | + 'event_espresso' |
|
300 | + ) |
|
301 | + ), |
|
302 | + ]; |
|
303 | + wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete); |
|
304 | + } |
|
305 | + |
|
306 | + |
|
307 | + /** |
|
308 | + * Enqueue scripts and styles for the country settings route. |
|
309 | + */ |
|
310 | + public function load_scripts_styles_country_settings() |
|
311 | + { |
|
312 | + // scripts |
|
313 | + wp_register_script( |
|
314 | + 'gen_settings_countries', |
|
315 | + GEN_SET_ASSETS_URL . 'gen_settings_countries.js', |
|
316 | + ['ee_admin_js'], |
|
317 | + EVENT_ESPRESSO_VERSION, |
|
318 | + true |
|
319 | + ); |
|
320 | + wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION); |
|
321 | + wp_enqueue_script('gen_settings_countries'); |
|
322 | + wp_enqueue_style('organization-css'); |
|
323 | + } |
|
324 | + |
|
325 | + |
|
326 | + /************* Espresso Pages *************/ |
|
327 | + /** |
|
328 | + * _espresso_page_settings |
|
329 | + * |
|
330 | + * @throws EE_Error |
|
331 | + * @throws DomainException |
|
332 | + * @throws DomainException |
|
333 | + * @throws InvalidDataTypeException |
|
334 | + * @throws InvalidArgumentException |
|
335 | + */ |
|
336 | + protected function _espresso_page_settings() |
|
337 | + { |
|
338 | + // Check to make sure all of the main pages are set up properly, |
|
339 | + // if not create the default pages and display an admin notice |
|
340 | + EEH_Activation::verify_default_pages_exist(); |
|
341 | + $this->_transient_garbage_collection(); |
|
342 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
343 | + $this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) |
|
344 | + ? EE_Registry::instance()->CFG->core->reg_page_id |
|
345 | + : null; |
|
346 | + $this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) |
|
347 | + ? get_post(EE_Registry::instance()->CFG->core->reg_page_id) |
|
348 | + : false; |
|
349 | + $this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) |
|
350 | + ? EE_Registry::instance()->CFG->core->txn_page_id |
|
351 | + : null; |
|
352 | + $this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) |
|
353 | + ? get_post(EE_Registry::instance()->CFG->core->txn_page_id) |
|
354 | + : false; |
|
355 | + $this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
356 | + ? EE_Registry::instance()->CFG->core->thank_you_page_id |
|
357 | + : null; |
|
358 | + $this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
359 | + ? get_post(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
360 | + : false; |
|
361 | + $this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
362 | + ? EE_Registry::instance()->CFG->core->cancel_page_id |
|
363 | + : null; |
|
364 | + $this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
365 | + ? get_post(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
366 | + : false; |
|
367 | + $this->_set_add_edit_form_tags('update_espresso_page_settings'); |
|
368 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
369 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
370 | + GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php', |
|
371 | + $this->_template_args, |
|
372 | + true |
|
373 | + ); |
|
374 | + $this->display_admin_page_with_sidebar(); |
|
375 | + } |
|
376 | + |
|
377 | + |
|
378 | + /** |
|
379 | + * Handler for updating espresso page settings. |
|
380 | + * |
|
381 | + * @throws EE_Error |
|
382 | + */ |
|
383 | + protected function _update_espresso_page_settings() |
|
384 | + { |
|
385 | + // capture incoming request data && set page IDs |
|
386 | + EE_Registry::instance()->CFG->core->reg_page_id = isset($this->_req_data['reg_page_id']) |
|
387 | + ? absint($this->_req_data['reg_page_id']) |
|
388 | + : EE_Registry::instance()->CFG->core->reg_page_id; |
|
389 | + EE_Registry::instance()->CFG->core->txn_page_id = isset($this->_req_data['txn_page_id']) |
|
390 | + ? absint($this->_req_data['txn_page_id']) |
|
391 | + : EE_Registry::instance()->CFG->core->txn_page_id; |
|
392 | + EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id']) |
|
393 | + ? absint($this->_req_data['thank_you_page_id']) |
|
394 | + : EE_Registry::instance()->CFG->core->thank_you_page_id; |
|
395 | + EE_Registry::instance()->CFG->core->cancel_page_id = isset($this->_req_data['cancel_page_id']) |
|
396 | + ? absint($this->_req_data['cancel_page_id']) |
|
397 | + : EE_Registry::instance()->CFG->core->cancel_page_id; |
|
398 | + |
|
399 | + EE_Registry::instance()->CFG->core = apply_filters( |
|
400 | + 'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core', |
|
401 | + EE_Registry::instance()->CFG->core, |
|
402 | + $this->_req_data |
|
403 | + ); |
|
404 | + $what = esc_html__('Critical Pages & Shortcodes', 'event_espresso'); |
|
405 | + $this->_redirect_after_action( |
|
406 | + $this->_update_espresso_configuration( |
|
407 | + $what, |
|
408 | + EE_Registry::instance()->CFG->core, |
|
409 | + __FILE__, |
|
410 | + __FUNCTION__, |
|
411 | + __LINE__ |
|
412 | + ), |
|
413 | + $what, |
|
414 | + '', |
|
415 | + [ |
|
416 | + 'action' => 'critical_pages', |
|
417 | + ], |
|
418 | + true |
|
419 | + ); |
|
420 | + } |
|
421 | + |
|
422 | + |
|
423 | + /************* Your Organization *************/ |
|
424 | + |
|
425 | + |
|
426 | + /** |
|
427 | + * @throws DomainException |
|
428 | + * @throws EE_Error |
|
429 | + * @throws InvalidArgumentException |
|
430 | + * @throws InvalidDataTypeException |
|
431 | + * @throws InvalidInterfaceException |
|
432 | + */ |
|
433 | + protected function _your_organization_settings() |
|
434 | + { |
|
435 | + $this->_template_args['admin_page_content'] = ''; |
|
436 | + try { |
|
437 | + /** @var EventEspresso\admin_pages\general_settings\OrganizationSettings $organization_settings_form */ |
|
438 | + $organization_settings_form = $this->loader->getShared( |
|
439 | + 'EventEspresso\admin_pages\general_settings\OrganizationSettings' |
|
440 | + ); |
|
441 | + $this->_template_args['admin_page_content'] = $organization_settings_form->display(); |
|
442 | + } catch (Exception $e) { |
|
443 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
444 | + } |
|
445 | + $this->_set_add_edit_form_tags('update_your_organization_settings'); |
|
446 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
447 | + $this->display_admin_page_with_sidebar(); |
|
448 | + } |
|
449 | + |
|
450 | + |
|
451 | + /** |
|
452 | + * Handler for updating organization settings. |
|
453 | + * |
|
454 | + * @throws EE_Error |
|
455 | + */ |
|
456 | + protected function _update_your_organization_settings() |
|
457 | + { |
|
458 | + try { |
|
459 | + /** @var EventEspresso\admin_pages\general_settings\OrganizationSettings $organization_settings_form */ |
|
460 | + $organization_settings_form = $this->loader->getShared( |
|
461 | + 'EventEspresso\admin_pages\general_settings\OrganizationSettings' |
|
462 | + ); |
|
463 | + $success = $organization_settings_form->process($this->_req_data); |
|
464 | + EE_Registry::instance()->CFG = apply_filters( |
|
465 | + 'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG', |
|
466 | + EE_Registry::instance()->CFG |
|
467 | + ); |
|
468 | + } catch (Exception $e) { |
|
469 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
470 | + $success = false; |
|
471 | + } |
|
472 | + |
|
473 | + if ($success) { |
|
474 | + $success = $this->_update_espresso_configuration( |
|
475 | + esc_html__('Your Organization Settings', 'event_espresso'), |
|
476 | + EE_Registry::instance()->CFG, |
|
477 | + __FILE__, |
|
478 | + __FUNCTION__, |
|
479 | + __LINE__ |
|
480 | + ); |
|
481 | + } |
|
482 | + |
|
483 | + $this->_redirect_after_action($success, '', '', ['action' => 'default'], true); |
|
484 | + } |
|
485 | + |
|
486 | + |
|
487 | + |
|
488 | + /************* Admin Options *************/ |
|
489 | + |
|
490 | + |
|
491 | + /** |
|
492 | + * _admin_option_settings |
|
493 | + * |
|
494 | + * @throws EE_Error |
|
495 | + * @throws LogicException |
|
496 | + */ |
|
497 | + protected function _admin_option_settings() |
|
498 | + { |
|
499 | + $this->_template_args['admin_page_content'] = ''; |
|
500 | + try { |
|
501 | + $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
|
502 | + // still need this for the old school form in Extend_General_Settings_Admin_Page |
|
503 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
504 | + // also need to account for the do_action that was in the old template |
|
505 | + $admin_options_settings_form->setTemplateArgs($this->_template_args); |
|
506 | + $this->_template_args['admin_page_content'] = $admin_options_settings_form->display(); |
|
507 | + } catch (Exception $e) { |
|
508 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
509 | + } |
|
510 | + $this->_set_add_edit_form_tags('update_admin_option_settings'); |
|
511 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
512 | + $this->display_admin_page_with_sidebar(); |
|
513 | + } |
|
514 | + |
|
515 | + |
|
516 | + /** |
|
517 | + * _update_admin_option_settings |
|
518 | + * |
|
519 | + * @throws EE_Error |
|
520 | + * @throws InvalidDataTypeException |
|
521 | + * @throws InvalidFormSubmissionException |
|
522 | + * @throws InvalidArgumentException |
|
523 | + * @throws LogicException |
|
524 | + */ |
|
525 | + protected function _update_admin_option_settings() |
|
526 | + { |
|
527 | + try { |
|
528 | + $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
|
529 | + $admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]); |
|
530 | + EE_Registry::instance()->CFG->admin = apply_filters( |
|
531 | + 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', |
|
532 | + EE_Registry::instance()->CFG->admin |
|
533 | + ); |
|
534 | + } catch (Exception $e) { |
|
535 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
536 | + } |
|
537 | + $this->_redirect_after_action( |
|
538 | + apply_filters( |
|
539 | + 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success', |
|
540 | + $this->_update_espresso_configuration( |
|
541 | + 'Admin Options', |
|
542 | + EE_Registry::instance()->CFG->admin, |
|
543 | + __FILE__, |
|
544 | + __FUNCTION__, |
|
545 | + __LINE__ |
|
546 | + ) |
|
547 | + ), |
|
548 | + 'Admin Options', |
|
549 | + 'updated', |
|
550 | + ['action' => 'admin_option_settings'] |
|
551 | + ); |
|
552 | + } |
|
553 | + |
|
554 | + |
|
555 | + /************* Countries *************/ |
|
556 | + |
|
557 | + |
|
558 | + /** |
|
559 | + * @return string |
|
560 | + */ |
|
561 | + protected function getCountryIsoForSite() |
|
562 | + { |
|
563 | + return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
564 | + ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
565 | + : 'US'; |
|
566 | + } |
|
567 | + |
|
568 | + |
|
569 | + /** |
|
570 | + * @param string $CNT_ISO |
|
571 | + * @param EE_Country|null $country |
|
572 | + * @return EE_Base_Class|EE_Country |
|
573 | + * @throws EE_Error |
|
574 | + * @throws InvalidArgumentException |
|
575 | + * @throws InvalidDataTypeException |
|
576 | + * @throws InvalidInterfaceException |
|
577 | + * @throws ReflectionException |
|
578 | + */ |
|
579 | + protected function verifyOrGetCountryFromIso($CNT_ISO, EE_Country $country = null) |
|
580 | + { |
|
581 | + /** @var EE_Country $country */ |
|
582 | + return $country instanceof EE_Country && $country->ID() === $CNT_ISO |
|
583 | + ? $country |
|
584 | + : EEM_Country::instance()->get_one_by_ID($CNT_ISO); |
|
585 | + } |
|
586 | + |
|
587 | + |
|
588 | + /** |
|
589 | + * Output Country Settings view. |
|
590 | + * |
|
591 | + * @throws DomainException |
|
592 | + * @throws EE_Error |
|
593 | + * @throws InvalidArgumentException |
|
594 | + * @throws InvalidDataTypeException |
|
595 | + * @throws InvalidInterfaceException |
|
596 | + * @throws ReflectionException |
|
597 | + */ |
|
598 | + protected function _country_settings() |
|
599 | + { |
|
600 | + $CNT_ISO_for_site = $this->getCountryIsoForSite(); |
|
601 | + $CNT_ISO = isset($this->_req_data['country']) |
|
602 | + ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
603 | + : $CNT_ISO_for_site; |
|
604 | + |
|
605 | + // load field generator helper |
|
606 | + |
|
607 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
608 | + |
|
609 | + $this->_template_args['countries'] = new EE_Question_Form_Input( |
|
610 | + EE_Question::new_instance( |
|
611 | + [ |
|
612 | + 'QST_ID' => 0, |
|
613 | + 'QST_display_text' => esc_html__('Select Country', 'event_espresso'), |
|
614 | + 'QST_system' => 'admin-country', |
|
615 | + ] |
|
616 | + ), |
|
617 | + EE_Answer::new_instance( |
|
618 | + [ |
|
619 | + 'ANS_ID' => 0, |
|
620 | + 'ANS_value' => $CNT_ISO, |
|
621 | + ] |
|
622 | + ), |
|
623 | + [ |
|
624 | + 'input_id' => 'country', |
|
625 | + 'input_name' => 'country', |
|
626 | + 'input_prefix' => '', |
|
627 | + 'append_qstn_id' => false, |
|
628 | + ] |
|
629 | + ); |
|
630 | + $country = $this->verifyOrGetCountryFromIso($CNT_ISO_for_site); |
|
631 | + add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2); |
|
632 | + add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2); |
|
633 | + $this->_template_args['country_details_settings'] = $this->display_country_settings( |
|
634 | + $country->ID(), |
|
635 | + $country |
|
636 | + ); |
|
637 | + $this->_template_args['country_states_settings'] = $this->display_country_states( |
|
638 | + $country->ID(), |
|
639 | + $country |
|
640 | + ); |
|
641 | + $this->_template_args['CNT_name_for_site'] = $country->name(); |
|
642 | + |
|
643 | + $this->_set_add_edit_form_tags('update_country_settings'); |
|
644 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
645 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
646 | + GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php', |
|
647 | + $this->_template_args, |
|
648 | + true |
|
649 | + ); |
|
650 | + $this->display_admin_page_with_no_sidebar(); |
|
651 | + } |
|
652 | + |
|
653 | + |
|
654 | + /** |
|
655 | + * @param string $CNT_ISO |
|
656 | + * @param EE_Country|null $country |
|
657 | + * @return string |
|
658 | + * @throws DomainException |
|
659 | + * @throws EE_Error |
|
660 | + * @throws InvalidArgumentException |
|
661 | + * @throws InvalidDataTypeException |
|
662 | + * @throws InvalidInterfaceException |
|
663 | + * @throws ReflectionException |
|
664 | + */ |
|
665 | + public function display_country_settings($CNT_ISO = '', EE_Country $country = null) |
|
666 | + { |
|
667 | + $CNT_ISO_for_site = $this->getCountryIsoForSite(); |
|
668 | + |
|
669 | + $CNT_ISO = isset($this->_req_data['country']) |
|
670 | + ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
671 | + : $CNT_ISO; |
|
672 | + if (! $CNT_ISO) { |
|
673 | + return ''; |
|
674 | + } |
|
675 | + |
|
676 | + // for ajax |
|
677 | + remove_all_filters('FHEE__EEH_Form_Fields__label_html'); |
|
678 | + remove_all_filters('FHEE__EEH_Form_Fields__input_html'); |
|
679 | + add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2); |
|
680 | + add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2); |
|
681 | + $country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country); |
|
682 | + $CNT_cur_disabled = $CNT_ISO !== $CNT_ISO_for_site; |
|
683 | + $this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled; |
|
684 | + |
|
685 | + $country_input_types = [ |
|
686 | + 'CNT_active' => [ |
|
687 | + 'type' => 'RADIO_BTN', |
|
688 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
689 | + 'class' => '', |
|
690 | + 'options' => $this->_yes_no_values, |
|
691 | + 'use_desc_4_label' => true, |
|
692 | + ], |
|
693 | + 'CNT_ISO' => [ |
|
694 | + 'type' => 'TEXT', |
|
695 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
696 | + 'class' => 'small-text', |
|
697 | + ], |
|
698 | + 'CNT_ISO3' => [ |
|
699 | + 'type' => 'TEXT', |
|
700 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
701 | + 'class' => 'small-text', |
|
702 | + ], |
|
703 | + 'RGN_ID' => [ |
|
704 | + 'type' => 'TEXT', |
|
705 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
706 | + 'class' => 'small-text', |
|
707 | + ], |
|
708 | + 'CNT_name' => [ |
|
709 | + 'type' => 'TEXT', |
|
710 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
711 | + 'class' => 'regular-text', |
|
712 | + ], |
|
713 | + 'CNT_cur_code' => [ |
|
714 | + 'type' => 'TEXT', |
|
715 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
716 | + 'class' => 'small-text', |
|
717 | + 'disabled' => $CNT_cur_disabled, |
|
718 | + ], |
|
719 | + 'CNT_cur_single' => [ |
|
720 | + 'type' => 'TEXT', |
|
721 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
722 | + 'class' => 'medium-text', |
|
723 | + 'disabled' => $CNT_cur_disabled, |
|
724 | + ], |
|
725 | + 'CNT_cur_plural' => [ |
|
726 | + 'type' => 'TEXT', |
|
727 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
728 | + 'class' => 'medium-text', |
|
729 | + 'disabled' => $CNT_cur_disabled, |
|
730 | + ], |
|
731 | + 'CNT_cur_sign' => [ |
|
732 | + 'type' => 'TEXT', |
|
733 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
734 | + 'class' => 'small-text', |
|
735 | + 'htmlentities' => false, |
|
736 | + 'disabled' => $CNT_cur_disabled, |
|
737 | + ], |
|
738 | + 'CNT_cur_sign_b4' => [ |
|
739 | + 'type' => 'RADIO_BTN', |
|
740 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
741 | + 'class' => '', |
|
742 | + 'options' => $this->_yes_no_values, |
|
743 | + 'use_desc_4_label' => true, |
|
744 | + 'disabled' => $CNT_cur_disabled, |
|
745 | + ], |
|
746 | + 'CNT_cur_dec_plc' => [ |
|
747 | + 'type' => 'RADIO_BTN', |
|
748 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
749 | + 'class' => '', |
|
750 | + 'options' => [ |
|
751 | + ['id' => 0, 'text' => ''], |
|
752 | + ['id' => 1, 'text' => ''], |
|
753 | + ['id' => 2, 'text' => ''], |
|
754 | + ['id' => 3, 'text' => ''], |
|
755 | + ], |
|
756 | + 'disabled' => $CNT_cur_disabled, |
|
757 | + ], |
|
758 | + 'CNT_cur_dec_mrk' => [ |
|
759 | + 'type' => 'RADIO_BTN', |
|
760 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
761 | + 'class' => '', |
|
762 | + 'options' => [ |
|
763 | + [ |
|
764 | + 'id' => ',', |
|
765 | + 'text' => esc_html__(', (comma)', 'event_espresso'), |
|
766 | + ], |
|
767 | + ['id' => '.', 'text' => esc_html__('. (decimal)', 'event_espresso')], |
|
768 | + ], |
|
769 | + 'use_desc_4_label' => true, |
|
770 | + 'disabled' => $CNT_cur_disabled, |
|
771 | + ], |
|
772 | + 'CNT_cur_thsnds' => [ |
|
773 | + 'type' => 'RADIO_BTN', |
|
774 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
775 | + 'class' => '', |
|
776 | + 'options' => [ |
|
777 | + [ |
|
778 | + 'id' => ',', |
|
779 | + 'text' => esc_html__(', (comma)', 'event_espresso'), |
|
780 | + ], |
|
781 | + [ |
|
782 | + 'id' => '.', |
|
783 | + 'text' => esc_html__('. (decimal)', 'event_espresso'), |
|
784 | + ], |
|
785 | + [ |
|
786 | + 'id' => ' ', |
|
787 | + 'text' => esc_html__('(space)', 'event_espresso'), |
|
788 | + ], |
|
789 | + ], |
|
790 | + 'use_desc_4_label' => true, |
|
791 | + 'disabled' => $CNT_cur_disabled, |
|
792 | + ], |
|
793 | + 'CNT_tel_code' => [ |
|
794 | + 'type' => 'TEXT', |
|
795 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
796 | + 'class' => 'small-text', |
|
797 | + ], |
|
798 | + 'CNT_is_EU' => [ |
|
799 | + 'type' => 'RADIO_BTN', |
|
800 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
801 | + 'class' => '', |
|
802 | + 'options' => $this->_yes_no_values, |
|
803 | + 'use_desc_4_label' => true, |
|
804 | + ], |
|
805 | + ]; |
|
806 | + $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object( |
|
807 | + $country, |
|
808 | + $country_input_types |
|
809 | + ); |
|
810 | + $country_details_settings = EEH_Template::display_template( |
|
811 | + GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php', |
|
812 | + $this->_template_args, |
|
813 | + true |
|
814 | + ); |
|
815 | + |
|
816 | + if (defined('DOING_AJAX')) { |
|
817 | + $notices = EE_Error::get_notices(false, false, false); |
|
818 | + echo wp_json_encode( |
|
819 | + [ |
|
820 | + 'return_data' => $country_details_settings, |
|
821 | + 'success' => $notices['success'], |
|
822 | + 'errors' => $notices['errors'], |
|
823 | + ] |
|
824 | + ); |
|
825 | + die(); |
|
826 | + } else { |
|
827 | + return $country_details_settings; |
|
828 | + } |
|
829 | + } |
|
830 | + |
|
831 | + |
|
832 | + /** |
|
833 | + * @param string $CNT_ISO |
|
834 | + * @param EE_Country|null $country |
|
835 | + * @return string |
|
836 | + * @throws DomainException |
|
837 | + * @throws EE_Error |
|
838 | + * @throws InvalidArgumentException |
|
839 | + * @throws InvalidDataTypeException |
|
840 | + * @throws InvalidInterfaceException |
|
841 | + * @throws ReflectionException |
|
842 | + */ |
|
843 | + public function display_country_states($CNT_ISO = '', EE_Country $country = null) |
|
844 | + { |
|
845 | + |
|
846 | + $CNT_ISO = isset($this->_req_data['country']) |
|
847 | + ? sanitize_text_field($this->_req_data['country']) |
|
848 | + : $CNT_ISO; |
|
849 | + if (! $CNT_ISO) { |
|
850 | + return ''; |
|
851 | + } |
|
852 | + // for ajax |
|
853 | + remove_all_filters('FHEE__EEH_Form_Fields__label_html'); |
|
854 | + remove_all_filters('FHEE__EEH_Form_Fields__input_html'); |
|
855 | + add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'state_form_field_label_wrap'], 10, 2); |
|
856 | + add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'state_form_field_input__wrap'], 10, 2); |
|
857 | + $states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]); |
|
858 | + if (empty($states)) { |
|
859 | + /** @var EventEspresso\core\services\address\CountrySubRegionDao $countrySubRegionDao */ |
|
860 | + $countrySubRegionDao = $this->loader->getShared( |
|
861 | + 'EventEspresso\core\services\address\CountrySubRegionDao' |
|
862 | + ); |
|
863 | + if ($countrySubRegionDao instanceof EventEspresso\core\services\address\CountrySubRegionDao) { |
|
864 | + $country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country); |
|
865 | + if ($countrySubRegionDao->saveCountrySubRegions($country)) { |
|
866 | + $states = EEM_State::instance()->get_all_states_for_these_countries( |
|
867 | + [$CNT_ISO => $CNT_ISO] |
|
868 | + ); |
|
869 | + } |
|
870 | + } |
|
871 | + } |
|
872 | + if (is_array($states)) { |
|
873 | + foreach ($states as $STA_ID => $state) { |
|
874 | + if ($state instanceof EE_State) { |
|
875 | + // STA_abbrev STA_name STA_active |
|
876 | + $state_input_types = [ |
|
877 | + 'STA_abbrev' => [ |
|
878 | + 'type' => 'TEXT', |
|
879 | + 'input_name' => 'states[' . $STA_ID . ']', |
|
880 | + 'class' => 'small-text', |
|
881 | + ], |
|
882 | + 'STA_name' => [ |
|
883 | + 'type' => 'TEXT', |
|
884 | + 'input_name' => 'states[' . $STA_ID . ']', |
|
885 | + 'class' => 'regular-text', |
|
886 | + ], |
|
887 | + 'STA_active' => [ |
|
888 | + 'type' => 'RADIO_BTN', |
|
889 | + 'input_name' => 'states[' . $STA_ID . ']', |
|
890 | + 'options' => $this->_yes_no_values, |
|
891 | + 'use_desc_4_label' => true, |
|
892 | + ], |
|
893 | + ]; |
|
894 | + $this->_template_args['states'][ $STA_ID ]['inputs'] = |
|
895 | + EE_Question_Form_Input::generate_question_form_inputs_for_object( |
|
896 | + $state, |
|
897 | + $state_input_types |
|
898 | + ); |
|
899 | + $query_args = [ |
|
900 | + 'action' => 'delete_state', |
|
901 | + 'STA_ID' => $STA_ID, |
|
902 | + 'CNT_ISO' => $CNT_ISO, |
|
903 | + 'STA_abbrev' => $state->abbrev(), |
|
904 | + ]; |
|
905 | + $this->_template_args['states'][ $STA_ID ]['delete_state_url'] = |
|
906 | + EE_Admin_Page::add_query_args_and_nonce( |
|
907 | + $query_args, |
|
908 | + GEN_SET_ADMIN_URL |
|
909 | + ); |
|
910 | + } |
|
911 | + } |
|
912 | + } else { |
|
913 | + $this->_template_args['states'] = false; |
|
914 | + } |
|
915 | + |
|
916 | + $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
917 | + ['action' => 'add_new_state'], |
|
918 | + GEN_SET_ADMIN_URL |
|
919 | + ); |
|
920 | + |
|
921 | + $state_details_settings = EEH_Template::display_template( |
|
922 | + GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php', |
|
923 | + $this->_template_args, |
|
924 | + true |
|
925 | + ); |
|
926 | + |
|
927 | + if (defined('DOING_AJAX')) { |
|
928 | + $notices = EE_Error::get_notices(false, false, false); |
|
929 | + echo wp_json_encode( |
|
930 | + [ |
|
931 | + 'return_data' => $state_details_settings, |
|
932 | + 'success' => $notices['success'], |
|
933 | + 'errors' => $notices['errors'], |
|
934 | + ] |
|
935 | + ); |
|
936 | + die(); |
|
937 | + } else { |
|
938 | + return $state_details_settings; |
|
939 | + } |
|
940 | + } |
|
941 | + |
|
942 | + |
|
943 | + /** |
|
944 | + * add_new_state |
|
945 | + * |
|
946 | + * @access public |
|
947 | + * @return void |
|
948 | + * @throws EE_Error |
|
949 | + * @throws InvalidArgumentException |
|
950 | + * @throws InvalidDataTypeException |
|
951 | + * @throws InvalidInterfaceException |
|
952 | + */ |
|
953 | + public function add_new_state() |
|
954 | + { |
|
955 | + |
|
956 | + $success = true; |
|
957 | + |
|
958 | + $CNT_ISO = isset($this->_req_data['CNT_ISO']) |
|
959 | + ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) |
|
960 | + : false; |
|
961 | + if (! $CNT_ISO) { |
|
962 | + EE_Error::add_error( |
|
963 | + esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
|
964 | + __FILE__, |
|
965 | + __FUNCTION__, |
|
966 | + __LINE__ |
|
967 | + ); |
|
968 | + $success = false; |
|
969 | + } |
|
970 | + $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
|
971 | + ? sanitize_text_field($this->_req_data['STA_abbrev']) |
|
972 | + : false; |
|
973 | + if (! $STA_abbrev) { |
|
974 | + EE_Error::add_error( |
|
975 | + esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'), |
|
976 | + __FILE__, |
|
977 | + __FUNCTION__, |
|
978 | + __LINE__ |
|
979 | + ); |
|
980 | + $success = false; |
|
981 | + } |
|
982 | + $STA_name = isset($this->_req_data['STA_name']) |
|
983 | + ? sanitize_text_field($this->_req_data['STA_name']) |
|
984 | + : false; |
|
985 | + if (! $STA_name) { |
|
986 | + EE_Error::add_error( |
|
987 | + esc_html__('No State name or an invalid State name was received.', 'event_espresso'), |
|
988 | + __FILE__, |
|
989 | + __FUNCTION__, |
|
990 | + __LINE__ |
|
991 | + ); |
|
992 | + $success = false; |
|
993 | + } |
|
994 | + |
|
995 | + if ($success) { |
|
996 | + $cols_n_values = [ |
|
997 | + 'CNT_ISO' => $CNT_ISO, |
|
998 | + 'STA_abbrev' => $STA_abbrev, |
|
999 | + 'STA_name' => $STA_name, |
|
1000 | + 'STA_active' => true, |
|
1001 | + ]; |
|
1002 | + $success = EEM_State::instance()->insert($cols_n_values); |
|
1003 | + EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso')); |
|
1004 | + } |
|
1005 | + |
|
1006 | + if (defined('DOING_AJAX')) { |
|
1007 | + $notices = EE_Error::get_notices(false, false, false); |
|
1008 | + echo wp_json_encode(array_merge($notices, ['return_data' => $CNT_ISO])); |
|
1009 | + die(); |
|
1010 | + } else { |
|
1011 | + $this->_redirect_after_action($success, 'State', 'added', ['action' => 'country_settings']); |
|
1012 | + } |
|
1013 | + } |
|
1014 | + |
|
1015 | + |
|
1016 | + /** |
|
1017 | + * @return void |
|
1018 | + * @throws EE_Error |
|
1019 | + * @throws InvalidArgumentException |
|
1020 | + * @throws InvalidDataTypeException |
|
1021 | + * @throws InvalidInterfaceException |
|
1022 | + */ |
|
1023 | + public function delete_state() |
|
1024 | + { |
|
1025 | + $CNT_ISO = isset($this->_req_data['CNT_ISO']) |
|
1026 | + ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) |
|
1027 | + : false; |
|
1028 | + $STA_ID = isset($this->_req_data['STA_ID']) |
|
1029 | + ? sanitize_text_field($this->_req_data['STA_ID']) |
|
1030 | + : false; |
|
1031 | + $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
|
1032 | + ? sanitize_text_field($this->_req_data['STA_abbrev']) |
|
1033 | + : false; |
|
1034 | + if (! $STA_ID) { |
|
1035 | + EE_Error::add_error( |
|
1036 | + esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'), |
|
1037 | + __FILE__, |
|
1038 | + __FUNCTION__, |
|
1039 | + __LINE__ |
|
1040 | + ); |
|
1041 | + return; |
|
1042 | + } |
|
1043 | + |
|
1044 | + $success = EEM_State::instance()->delete_by_ID($STA_ID); |
|
1045 | + if ($success !== false) { |
|
1046 | + do_action( |
|
1047 | + 'AHEE__General_Settings_Admin_Page__delete_state__state_deleted', |
|
1048 | + $CNT_ISO, |
|
1049 | + $STA_ID, |
|
1050 | + ['STA_abbrev' => $STA_abbrev] |
|
1051 | + ); |
|
1052 | + EE_Error::add_success(esc_html__('The State was deleted successfully.', 'event_espresso')); |
|
1053 | + } |
|
1054 | + if (defined('DOING_AJAX')) { |
|
1055 | + $notices = EE_Error::get_notices(false); |
|
1056 | + $notices['return_data'] = true; |
|
1057 | + echo wp_json_encode($notices); |
|
1058 | + die(); |
|
1059 | + } else { |
|
1060 | + $this->_redirect_after_action( |
|
1061 | + $success, |
|
1062 | + 'State', |
|
1063 | + 'deleted', |
|
1064 | + ['action' => 'country_settings'] |
|
1065 | + ); |
|
1066 | + } |
|
1067 | + } |
|
1068 | + |
|
1069 | + |
|
1070 | + /** |
|
1071 | + * _update_country_settings |
|
1072 | + * |
|
1073 | + * @return void |
|
1074 | + * @throws EE_Error |
|
1075 | + * @throws InvalidArgumentException |
|
1076 | + * @throws InvalidDataTypeException |
|
1077 | + * @throws InvalidInterfaceException |
|
1078 | + */ |
|
1079 | + protected function _update_country_settings() |
|
1080 | + { |
|
1081 | + // grab the country ISO code |
|
1082 | + $CNT_ISO = isset($this->_req_data['country']) |
|
1083 | + ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
1084 | + : false; |
|
1085 | + if (! $CNT_ISO) { |
|
1086 | + EE_Error::add_error( |
|
1087 | + esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
|
1088 | + __FILE__, |
|
1089 | + __FUNCTION__, |
|
1090 | + __LINE__ |
|
1091 | + ); |
|
1092 | + |
|
1093 | + return; |
|
1094 | + } |
|
1095 | + $cols_n_values = []; |
|
1096 | + $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']) |
|
1097 | + ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])) |
|
1098 | + : false; |
|
1099 | + $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID']) |
|
1100 | + ? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID']) |
|
1101 | + : null; |
|
1102 | + $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name']) |
|
1103 | + ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name']) |
|
1104 | + : null; |
|
1105 | + if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])) { |
|
1106 | + $cols_n_values['CNT_cur_code'] = strtoupper( |
|
1107 | + sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code']) |
|
1108 | + ); |
|
1109 | + } |
|
1110 | + if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'])) { |
|
1111 | + $cols_n_values['CNT_cur_single'] = sanitize_text_field( |
|
1112 | + $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'] |
|
1113 | + ); |
|
1114 | + } |
|
1115 | + if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'])) { |
|
1116 | + $cols_n_values['CNT_cur_plural'] = sanitize_text_field( |
|
1117 | + $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'] |
|
1118 | + ); |
|
1119 | + } |
|
1120 | + if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'])) { |
|
1121 | + $cols_n_values['CNT_cur_sign'] = sanitize_text_field( |
|
1122 | + $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'] |
|
1123 | + ); |
|
1124 | + } |
|
1125 | + if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'])) { |
|
1126 | + $cols_n_values['CNT_cur_sign_b4'] = absint( |
|
1127 | + $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'] |
|
1128 | + ); |
|
1129 | + } |
|
1130 | + if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'])) { |
|
1131 | + $cols_n_values['CNT_cur_dec_plc'] = absint( |
|
1132 | + $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'] |
|
1133 | + ); |
|
1134 | + } |
|
1135 | + if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'])) { |
|
1136 | + $cols_n_values['CNT_cur_dec_mrk'] = sanitize_text_field( |
|
1137 | + $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'] |
|
1138 | + ); |
|
1139 | + } |
|
1140 | + if (isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'])) { |
|
1141 | + $cols_n_values['CNT_cur_thsnds'] = sanitize_text_field( |
|
1142 | + $this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'] |
|
1143 | + ); |
|
1144 | + } |
|
1145 | + $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code']) |
|
1146 | + ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code']) |
|
1147 | + : null; |
|
1148 | + $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU']) |
|
1149 | + ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU']) |
|
1150 | + : false; |
|
1151 | + $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active']) |
|
1152 | + ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active']) |
|
1153 | + : false; |
|
1154 | + // allow filtering of country data |
|
1155 | + $cols_n_values = apply_filters( |
|
1156 | + 'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values', |
|
1157 | + $cols_n_values |
|
1158 | + ); |
|
1159 | + |
|
1160 | + // where values |
|
1161 | + $where_cols_n_values = [['CNT_ISO' => $CNT_ISO]]; |
|
1162 | + // run the update |
|
1163 | + $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values); |
|
1164 | + |
|
1165 | + if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) { |
|
1166 | + // allow filtering of states data |
|
1167 | + $states = apply_filters( |
|
1168 | + 'FHEE__General_Settings_Admin_Page___update_country_settings__states', |
|
1169 | + $this->_req_data['states'] |
|
1170 | + ); |
|
1171 | + |
|
1172 | + // loop thru state data ( looks like : states[75][STA_name] ) |
|
1173 | + foreach ($states as $STA_ID => $state) { |
|
1174 | + $cols_n_values = [ |
|
1175 | + 'CNT_ISO' => $CNT_ISO, |
|
1176 | + 'STA_abbrev' => sanitize_text_field($state['STA_abbrev']), |
|
1177 | + 'STA_name' => sanitize_text_field($state['STA_name']), |
|
1178 | + 'STA_active' => (bool) absint($state['STA_active']), |
|
1179 | + ]; |
|
1180 | + // where values |
|
1181 | + $where_cols_n_values = [['STA_ID' => $STA_ID]]; |
|
1182 | + // run the update |
|
1183 | + $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values); |
|
1184 | + if ($success !== false) { |
|
1185 | + do_action( |
|
1186 | + 'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', |
|
1187 | + $CNT_ISO, |
|
1188 | + $STA_ID, |
|
1189 | + $cols_n_values |
|
1190 | + ); |
|
1191 | + } |
|
1192 | + } |
|
1193 | + } |
|
1194 | + // check if country being edited matches org option country, and if so, then update EE_Config with new settings |
|
1195 | + if ( |
|
1196 | + isset(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
1197 | + && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO |
|
1198 | + ) { |
|
1199 | + EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO); |
|
1200 | + EE_Registry::instance()->CFG->update_espresso_config(); |
|
1201 | + } |
|
1202 | + |
|
1203 | + if ($success !== false) { |
|
1204 | + EE_Error::add_success( |
|
1205 | + esc_html__('Country Settings updated successfully.', 'event_espresso') |
|
1206 | + ); |
|
1207 | + } |
|
1208 | + $this->_redirect_after_action( |
|
1209 | + $success, |
|
1210 | + '', |
|
1211 | + '', |
|
1212 | + ['action' => 'country_settings', 'country' => $CNT_ISO], |
|
1213 | + true |
|
1214 | + ); |
|
1215 | + } |
|
1216 | + |
|
1217 | + |
|
1218 | + /** |
|
1219 | + * form_form_field_label_wrap |
|
1220 | + * |
|
1221 | + * @param string $label |
|
1222 | + * @return string |
|
1223 | + */ |
|
1224 | + public function country_form_field_label_wrap($label, $required_text) |
|
1225 | + { |
|
1226 | + return ' |
|
1227 | 1227 | <tr> |
1228 | 1228 | <th> |
1229 | 1229 | ' . $label . ' |
1230 | 1230 | </th>'; |
1231 | - } |
|
1232 | - |
|
1233 | - |
|
1234 | - /** |
|
1235 | - * form_form_field_input__wrap |
|
1236 | - * |
|
1237 | - * @param string $label |
|
1238 | - * @return string |
|
1239 | - */ |
|
1240 | - public function country_form_field_input__wrap($input, $label) |
|
1241 | - { |
|
1242 | - return ' |
|
1231 | + } |
|
1232 | + |
|
1233 | + |
|
1234 | + /** |
|
1235 | + * form_form_field_input__wrap |
|
1236 | + * |
|
1237 | + * @param string $label |
|
1238 | + * @return string |
|
1239 | + */ |
|
1240 | + public function country_form_field_input__wrap($input, $label) |
|
1241 | + { |
|
1242 | + return ' |
|
1243 | 1243 | <td class="general-settings-country-input-td"> |
1244 | 1244 | ' . $input . ' |
1245 | 1245 | </td> |
1246 | 1246 | </tr>'; |
1247 | - } |
|
1248 | - |
|
1249 | - |
|
1250 | - /** |
|
1251 | - * form_form_field_label_wrap |
|
1252 | - * |
|
1253 | - * @param string $label |
|
1254 | - * @param string $required_text |
|
1255 | - * @return string |
|
1256 | - */ |
|
1257 | - public function state_form_field_label_wrap($label, $required_text) |
|
1258 | - { |
|
1259 | - return $required_text; |
|
1260 | - } |
|
1261 | - |
|
1262 | - |
|
1263 | - /** |
|
1264 | - * form_form_field_input__wrap |
|
1265 | - * |
|
1266 | - * @param string $label |
|
1267 | - * @return string |
|
1268 | - */ |
|
1269 | - public function state_form_field_input__wrap($input, $label) |
|
1270 | - { |
|
1271 | - return ' |
|
1247 | + } |
|
1248 | + |
|
1249 | + |
|
1250 | + /** |
|
1251 | + * form_form_field_label_wrap |
|
1252 | + * |
|
1253 | + * @param string $label |
|
1254 | + * @param string $required_text |
|
1255 | + * @return string |
|
1256 | + */ |
|
1257 | + public function state_form_field_label_wrap($label, $required_text) |
|
1258 | + { |
|
1259 | + return $required_text; |
|
1260 | + } |
|
1261 | + |
|
1262 | + |
|
1263 | + /** |
|
1264 | + * form_form_field_input__wrap |
|
1265 | + * |
|
1266 | + * @param string $label |
|
1267 | + * @return string |
|
1268 | + */ |
|
1269 | + public function state_form_field_input__wrap($input, $label) |
|
1270 | + { |
|
1271 | + return ' |
|
1272 | 1272 | <td class="general-settings-country-state-input-td"> |
1273 | 1273 | ' . $input . ' |
1274 | 1274 | </td>'; |
1275 | - } |
|
1276 | - |
|
1277 | - |
|
1278 | - /***********/ |
|
1279 | - |
|
1280 | - |
|
1281 | - /** |
|
1282 | - * displays edit and view links for critical EE pages |
|
1283 | - * |
|
1284 | - * @param int $ee_page_id |
|
1285 | - * @return string |
|
1286 | - */ |
|
1287 | - public static function edit_view_links($ee_page_id) |
|
1288 | - { |
|
1289 | - $links = '<a href="' |
|
1290 | - . add_query_arg( |
|
1291 | - ['post' => $ee_page_id, 'action' => 'edit'], |
|
1292 | - admin_url('post.php') |
|
1293 | - ) |
|
1294 | - . '" >' |
|
1295 | - . esc_html__('Edit', 'event_espresso') |
|
1296 | - . '</a>'; |
|
1297 | - $links .= ' | '; |
|
1298 | - $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>'; |
|
1299 | - |
|
1300 | - return $links; |
|
1301 | - } |
|
1302 | - |
|
1303 | - |
|
1304 | - /** |
|
1305 | - * displays page and shortcode status for critical EE pages |
|
1306 | - * |
|
1307 | - * @param WP page object $ee_page |
|
1308 | - * @return string |
|
1309 | - */ |
|
1310 | - public static function page_and_shortcode_status($ee_page, $shortcode) |
|
1311 | - { |
|
1312 | - |
|
1313 | - // page status |
|
1314 | - if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') { |
|
1315 | - $pg_colour = 'green'; |
|
1316 | - $pg_status = sprintf(esc_html__('Page%sStatus%sOK', 'event_espresso'), ' ', ' '); |
|
1317 | - } else { |
|
1318 | - $pg_colour = 'red'; |
|
1319 | - $pg_status = sprintf(esc_html__('Page%sVisibility%sProblem', 'event_espresso'), ' ', ' '); |
|
1320 | - } |
|
1321 | - |
|
1322 | - // shortcode status |
|
1323 | - if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) { |
|
1324 | - $sc_colour = 'green'; |
|
1325 | - $sc_status = sprintf(esc_html__('Shortcode%sOK', 'event_espresso'), ' '); |
|
1326 | - } else { |
|
1327 | - $sc_colour = 'red'; |
|
1328 | - $sc_status = sprintf(esc_html__('Shortcode%sProblem', 'event_espresso'), ' '); |
|
1329 | - } |
|
1330 | - |
|
1331 | - return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>' |
|
1332 | - . $pg_status |
|
1333 | - . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>'; |
|
1334 | - } |
|
1335 | - |
|
1336 | - |
|
1337 | - /** |
|
1338 | - * generates a dropdown of all parent pages - copied from WP core |
|
1339 | - * |
|
1340 | - * @param int $default |
|
1341 | - * @param int $parent |
|
1342 | - * @param int $level |
|
1343 | - * @param bool $echo |
|
1344 | - * @return string; |
|
1345 | - */ |
|
1346 | - public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0, $echo = true) |
|
1347 | - { |
|
1348 | - global $wpdb; |
|
1349 | - $items = $wpdb->get_results( |
|
1350 | - $wpdb->prepare( |
|
1351 | - "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order", |
|
1352 | - $parent |
|
1353 | - ) |
|
1354 | - ); |
|
1355 | - $output = ''; |
|
1356 | - |
|
1357 | - if ($items) { |
|
1358 | - $level = absint($level); |
|
1359 | - foreach ($items as $item) { |
|
1360 | - $ID = absint($item->ID); |
|
1361 | - $post_title = wp_strip_all_tags($item->post_title); |
|
1362 | - $pad = str_repeat(' ', $level * 3); |
|
1363 | - $option = "\n\t"; |
|
1364 | - $option .= '<option class="level-' . $level . '" '; |
|
1365 | - $option .= 'value="' . $ID . '" '; |
|
1366 | - $option .= $ID === absint($default) ? ' selected="selected"' : ''; |
|
1367 | - $option .= '>'; |
|
1368 | - $option .= "$pad {$post_title}"; |
|
1369 | - $option .= '</option>'; |
|
1370 | - $output .= $option; |
|
1371 | - ob_start(); |
|
1372 | - parent_dropdown($default, $item->ID, $level + 1); |
|
1373 | - $output .= ob_get_clean(); |
|
1374 | - } |
|
1375 | - } |
|
1376 | - if ($echo) { |
|
1377 | - echo $output; |
|
1378 | - return ''; |
|
1379 | - } |
|
1380 | - return $output; |
|
1381 | - } |
|
1382 | - |
|
1383 | - |
|
1384 | - /** |
|
1385 | - * Loads the scripts for the privacy settings form |
|
1386 | - */ |
|
1387 | - public function load_scripts_styles_privacy_settings() |
|
1388 | - { |
|
1389 | - $form_handler = |
|
1390 | - $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'); |
|
1391 | - $form_handler->enqueueStylesAndScripts(); |
|
1392 | - } |
|
1393 | - |
|
1394 | - |
|
1395 | - /** |
|
1396 | - * display the privacy settings form |
|
1397 | - * |
|
1398 | - * @throws EE_Error |
|
1399 | - */ |
|
1400 | - public function privacySettings() |
|
1401 | - { |
|
1402 | - $this->_set_add_edit_form_tags('update_privacy_settings'); |
|
1403 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
1404 | - $form_handler = |
|
1405 | - $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'); |
|
1406 | - $this->_template_args['admin_page_content'] = $form_handler->display(); |
|
1407 | - $this->display_admin_page_with_sidebar(); |
|
1408 | - } |
|
1409 | - |
|
1410 | - |
|
1411 | - /** |
|
1412 | - * Update the privacy settings from form data |
|
1413 | - * |
|
1414 | - * @throws EE_Error |
|
1415 | - */ |
|
1416 | - public function updatePrivacySettings() |
|
1417 | - { |
|
1418 | - $form_handler = |
|
1419 | - $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'); |
|
1420 | - $success = $form_handler->process($this->get_request_data()); |
|
1421 | - $this->_redirect_after_action( |
|
1422 | - $success, |
|
1423 | - esc_html__('Registration Form Options', 'event_espresso'), |
|
1424 | - 'updated', |
|
1425 | - ['action' => 'privacy_settings'] |
|
1426 | - ); |
|
1427 | - } |
|
1275 | + } |
|
1276 | + |
|
1277 | + |
|
1278 | + /***********/ |
|
1279 | + |
|
1280 | + |
|
1281 | + /** |
|
1282 | + * displays edit and view links for critical EE pages |
|
1283 | + * |
|
1284 | + * @param int $ee_page_id |
|
1285 | + * @return string |
|
1286 | + */ |
|
1287 | + public static function edit_view_links($ee_page_id) |
|
1288 | + { |
|
1289 | + $links = '<a href="' |
|
1290 | + . add_query_arg( |
|
1291 | + ['post' => $ee_page_id, 'action' => 'edit'], |
|
1292 | + admin_url('post.php') |
|
1293 | + ) |
|
1294 | + . '" >' |
|
1295 | + . esc_html__('Edit', 'event_espresso') |
|
1296 | + . '</a>'; |
|
1297 | + $links .= ' | '; |
|
1298 | + $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>'; |
|
1299 | + |
|
1300 | + return $links; |
|
1301 | + } |
|
1302 | + |
|
1303 | + |
|
1304 | + /** |
|
1305 | + * displays page and shortcode status for critical EE pages |
|
1306 | + * |
|
1307 | + * @param WP page object $ee_page |
|
1308 | + * @return string |
|
1309 | + */ |
|
1310 | + public static function page_and_shortcode_status($ee_page, $shortcode) |
|
1311 | + { |
|
1312 | + |
|
1313 | + // page status |
|
1314 | + if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') { |
|
1315 | + $pg_colour = 'green'; |
|
1316 | + $pg_status = sprintf(esc_html__('Page%sStatus%sOK', 'event_espresso'), ' ', ' '); |
|
1317 | + } else { |
|
1318 | + $pg_colour = 'red'; |
|
1319 | + $pg_status = sprintf(esc_html__('Page%sVisibility%sProblem', 'event_espresso'), ' ', ' '); |
|
1320 | + } |
|
1321 | + |
|
1322 | + // shortcode status |
|
1323 | + if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) { |
|
1324 | + $sc_colour = 'green'; |
|
1325 | + $sc_status = sprintf(esc_html__('Shortcode%sOK', 'event_espresso'), ' '); |
|
1326 | + } else { |
|
1327 | + $sc_colour = 'red'; |
|
1328 | + $sc_status = sprintf(esc_html__('Shortcode%sProblem', 'event_espresso'), ' '); |
|
1329 | + } |
|
1330 | + |
|
1331 | + return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>' |
|
1332 | + . $pg_status |
|
1333 | + . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>'; |
|
1334 | + } |
|
1335 | + |
|
1336 | + |
|
1337 | + /** |
|
1338 | + * generates a dropdown of all parent pages - copied from WP core |
|
1339 | + * |
|
1340 | + * @param int $default |
|
1341 | + * @param int $parent |
|
1342 | + * @param int $level |
|
1343 | + * @param bool $echo |
|
1344 | + * @return string; |
|
1345 | + */ |
|
1346 | + public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0, $echo = true) |
|
1347 | + { |
|
1348 | + global $wpdb; |
|
1349 | + $items = $wpdb->get_results( |
|
1350 | + $wpdb->prepare( |
|
1351 | + "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order", |
|
1352 | + $parent |
|
1353 | + ) |
|
1354 | + ); |
|
1355 | + $output = ''; |
|
1356 | + |
|
1357 | + if ($items) { |
|
1358 | + $level = absint($level); |
|
1359 | + foreach ($items as $item) { |
|
1360 | + $ID = absint($item->ID); |
|
1361 | + $post_title = wp_strip_all_tags($item->post_title); |
|
1362 | + $pad = str_repeat(' ', $level * 3); |
|
1363 | + $option = "\n\t"; |
|
1364 | + $option .= '<option class="level-' . $level . '" '; |
|
1365 | + $option .= 'value="' . $ID . '" '; |
|
1366 | + $option .= $ID === absint($default) ? ' selected="selected"' : ''; |
|
1367 | + $option .= '>'; |
|
1368 | + $option .= "$pad {$post_title}"; |
|
1369 | + $option .= '</option>'; |
|
1370 | + $output .= $option; |
|
1371 | + ob_start(); |
|
1372 | + parent_dropdown($default, $item->ID, $level + 1); |
|
1373 | + $output .= ob_get_clean(); |
|
1374 | + } |
|
1375 | + } |
|
1376 | + if ($echo) { |
|
1377 | + echo $output; |
|
1378 | + return ''; |
|
1379 | + } |
|
1380 | + return $output; |
|
1381 | + } |
|
1382 | + |
|
1383 | + |
|
1384 | + /** |
|
1385 | + * Loads the scripts for the privacy settings form |
|
1386 | + */ |
|
1387 | + public function load_scripts_styles_privacy_settings() |
|
1388 | + { |
|
1389 | + $form_handler = |
|
1390 | + $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'); |
|
1391 | + $form_handler->enqueueStylesAndScripts(); |
|
1392 | + } |
|
1393 | + |
|
1394 | + |
|
1395 | + /** |
|
1396 | + * display the privacy settings form |
|
1397 | + * |
|
1398 | + * @throws EE_Error |
|
1399 | + */ |
|
1400 | + public function privacySettings() |
|
1401 | + { |
|
1402 | + $this->_set_add_edit_form_tags('update_privacy_settings'); |
|
1403 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
1404 | + $form_handler = |
|
1405 | + $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'); |
|
1406 | + $this->_template_args['admin_page_content'] = $form_handler->display(); |
|
1407 | + $this->display_admin_page_with_sidebar(); |
|
1408 | + } |
|
1409 | + |
|
1410 | + |
|
1411 | + /** |
|
1412 | + * Update the privacy settings from form data |
|
1413 | + * |
|
1414 | + * @throws EE_Error |
|
1415 | + */ |
|
1416 | + public function updatePrivacySettings() |
|
1417 | + { |
|
1418 | + $form_handler = |
|
1419 | + $this->loader->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'); |
|
1420 | + $success = $form_handler->process($this->get_request_data()); |
|
1421 | + $this->_redirect_after_action( |
|
1422 | + $success, |
|
1423 | + esc_html__('Registration Form Options', 'event_espresso'), |
|
1424 | + 'updated', |
|
1425 | + ['action' => 'privacy_settings'] |
|
1426 | + ); |
|
1427 | + } |
|
1428 | 1428 | } |
@@ -15,1195 +15,1195 @@ |
||
15 | 15 | class Payments_Admin_Page extends EE_Admin_Page |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * Variables used for when we're re-sorting the logs results, |
|
20 | - * in case we needed to do two queries, and we need to resort |
|
21 | - * |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - private $_sort_logs_again_direction; |
|
25 | - |
|
26 | - |
|
27 | - /** |
|
28 | - * @Constructor |
|
29 | - * @access public |
|
30 | - * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
|
31 | - * @throws EE_Error |
|
32 | - * @throws InvalidArgumentException |
|
33 | - * @throws InvalidDataTypeException |
|
34 | - * @throws InvalidInterfaceException |
|
35 | - * @throws ReflectionException |
|
36 | - */ |
|
37 | - public function __construct($routing = true) |
|
38 | - { |
|
39 | - parent::__construct($routing); |
|
40 | - } |
|
41 | - |
|
42 | - |
|
43 | - protected function _init_page_props() |
|
44 | - { |
|
45 | - $this->page_slug = EE_PAYMENTS_PG_SLUG; |
|
46 | - $this->page_label = esc_html__('Payment Methods', 'event_espresso'); |
|
47 | - $this->_admin_base_url = EE_PAYMENTS_ADMIN_URL; |
|
48 | - $this->_admin_base_path = EE_PAYMENTS_ADMIN; |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - protected function _ajax_hooks() |
|
53 | - { |
|
54 | - // todo: all hooks for ajax goes here. |
|
55 | - } |
|
56 | - |
|
57 | - |
|
58 | - protected function _define_page_props() |
|
59 | - { |
|
60 | - $this->_admin_page_title = $this->page_label; |
|
61 | - $this->_labels = array( |
|
62 | - 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
63 | - ); |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - protected function _set_page_routes() |
|
68 | - { |
|
69 | - /** |
|
70 | - * note that with payment method capabilities, although we've implemented |
|
71 | - * capability mapping which will be used for accessing payment methods owned by |
|
72 | - * other users. This is not fully implemented yet in the payment method ui. |
|
73 | - * Currently, only the "plural" caps are in active use. |
|
74 | - * When cap mapping is implemented, some routes will need to use the singular form of |
|
75 | - * capability method and also include the $id of the payment method for the route. |
|
76 | - **/ |
|
77 | - $this->_page_routes = array( |
|
78 | - 'default' => array( |
|
79 | - 'func' => '_payment_methods_list', |
|
80 | - 'capability' => 'ee_edit_payment_methods', |
|
81 | - ), |
|
82 | - 'payment_settings' => array( |
|
83 | - 'func' => '_payment_settings', |
|
84 | - 'capability' => 'ee_manage_gateways', |
|
85 | - ), |
|
86 | - 'activate_payment_method' => array( |
|
87 | - 'func' => '_activate_payment_method', |
|
88 | - 'noheader' => true, |
|
89 | - 'capability' => 'ee_edit_payment_methods', |
|
90 | - ), |
|
91 | - 'deactivate_payment_method' => array( |
|
92 | - 'func' => '_deactivate_payment_method', |
|
93 | - 'noheader' => true, |
|
94 | - 'capability' => 'ee_delete_payment_methods', |
|
95 | - ), |
|
96 | - 'update_payment_method' => array( |
|
97 | - 'func' => '_update_payment_method', |
|
98 | - 'noheader' => true, |
|
99 | - 'headers_sent_route' => 'default', |
|
100 | - 'capability' => 'ee_edit_payment_methods', |
|
101 | - ), |
|
102 | - 'update_payment_settings' => array( |
|
103 | - 'func' => '_update_payment_settings', |
|
104 | - 'noheader' => true, |
|
105 | - 'capability' => 'ee_manage_gateways', |
|
106 | - ), |
|
107 | - 'payment_log' => array( |
|
108 | - 'func' => '_payment_log_overview_list_table', |
|
109 | - 'capability' => 'ee_read_payment_methods', |
|
110 | - ), |
|
111 | - 'payment_log_details' => array( |
|
112 | - 'func' => '_payment_log_details', |
|
113 | - 'capability' => 'ee_read_payment_methods', |
|
114 | - ), |
|
115 | - ); |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - /** |
|
120 | - * @throws EE_Error |
|
121 | - * @throws ReflectionException |
|
122 | - */ |
|
123 | - protected function _set_page_config() |
|
124 | - { |
|
125 | - $payment_method_list_config = array( |
|
126 | - 'nav' => array( |
|
127 | - 'label' => esc_html__('Payment Methods', 'event_espresso'), |
|
128 | - 'order' => 10, |
|
129 | - ), |
|
130 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
131 | - 'help_tabs' => array_merge( |
|
132 | - array( |
|
133 | - 'payment_methods_overview_help_tab' => array( |
|
134 | - 'title' => esc_html__('Payment Methods Overview', 'event_espresso'), |
|
135 | - 'filename' => 'payment_methods_overview', |
|
136 | - ), |
|
137 | - ), |
|
138 | - $this->_add_payment_method_help_tabs() |
|
139 | - ), |
|
140 | - 'require_nonce' => false, |
|
141 | - ); |
|
142 | - $this->_page_config = array( |
|
143 | - 'default' => $payment_method_list_config, |
|
144 | - 'payment_settings' => array( |
|
145 | - 'nav' => array( |
|
146 | - 'label' => esc_html__('Settings', 'event_espresso'), |
|
147 | - 'order' => 20, |
|
148 | - ), |
|
149 | - 'help_tabs' => array( |
|
150 | - 'payment_methods_settings_help_tab' => array( |
|
151 | - 'title' => esc_html__('Payment Method Settings', 'event_espresso'), |
|
152 | - 'filename' => 'payment_methods_settings', |
|
153 | - ), |
|
154 | - ), |
|
155 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
156 | - 'require_nonce' => false, |
|
157 | - ), |
|
158 | - 'payment_log' => array( |
|
159 | - 'nav' => array( |
|
160 | - 'label' => esc_html__("Logs", 'event_espresso'), |
|
161 | - 'order' => 30, |
|
162 | - ), |
|
163 | - 'list_table' => 'Payment_Log_Admin_List_Table', |
|
164 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
165 | - 'require_nonce' => false, |
|
166 | - ), |
|
167 | - ); |
|
168 | - } |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * @return array |
|
173 | - * @throws DomainException |
|
174 | - * @throws EE_Error |
|
175 | - * @throws InvalidArgumentException |
|
176 | - * @throws InvalidDataTypeException |
|
177 | - * @throws InvalidInterfaceException |
|
178 | - * @throws ReflectionException |
|
179 | - */ |
|
180 | - protected function _add_payment_method_help_tabs() |
|
181 | - { |
|
182 | - EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
183 | - $payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types(); |
|
184 | - $all_pmt_help_tabs_config = array(); |
|
185 | - foreach ($payment_method_types as $payment_method_type) { |
|
186 | - if ( |
|
187 | - ! EE_Registry::instance()->CAP->current_user_can( |
|
188 | - $payment_method_type->cap_name(), |
|
189 | - 'specific_payment_method_type_access' |
|
190 | - ) |
|
191 | - ) { |
|
192 | - continue; |
|
193 | - } |
|
194 | - foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) { |
|
195 | - $template_args = isset($config['template_args']) ? $config['template_args'] : array(); |
|
196 | - $template_args['admin_page_obj'] = $this; |
|
197 | - $all_pmt_help_tabs_config[ $help_tab_name ] = array( |
|
198 | - 'title' => $config['title'], |
|
199 | - 'content' => EEH_Template::display_template( |
|
200 | - $payment_method_type->file_folder() . 'help_tabs/' . $config['filename'] . '.help_tab.php', |
|
201 | - $template_args, |
|
202 | - true |
|
203 | - ), |
|
204 | - ); |
|
205 | - } |
|
206 | - } |
|
207 | - return $all_pmt_help_tabs_config; |
|
208 | - } |
|
209 | - |
|
210 | - |
|
211 | - // none of the below group are currently used for Gateway Settings |
|
212 | - protected function _add_screen_options() |
|
213 | - { |
|
214 | - } |
|
215 | - |
|
216 | - |
|
217 | - protected function _add_feature_pointers() |
|
218 | - { |
|
219 | - } |
|
220 | - |
|
221 | - |
|
222 | - public function admin_init() |
|
223 | - { |
|
224 | - } |
|
225 | - |
|
226 | - |
|
227 | - public function admin_notices() |
|
228 | - { |
|
229 | - } |
|
230 | - |
|
231 | - |
|
232 | - public function admin_footer_scripts() |
|
233 | - { |
|
234 | - } |
|
235 | - |
|
236 | - |
|
237 | - public function load_scripts_styles() |
|
238 | - { |
|
239 | - // styles |
|
240 | - wp_enqueue_style('espresso-ui-theme'); |
|
241 | - // scripts |
|
242 | - wp_enqueue_script('ee_admin_js'); |
|
243 | - wp_enqueue_script('ee-text-links'); |
|
244 | - wp_enqueue_script( |
|
245 | - 'espresso_payments', |
|
246 | - EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js', |
|
247 | - array('ee-datepicker'), |
|
248 | - EVENT_ESPRESSO_VERSION, |
|
249 | - true |
|
250 | - ); |
|
251 | - } |
|
252 | - |
|
253 | - |
|
254 | - public function load_scripts_styles_default() |
|
255 | - { |
|
256 | - // styles |
|
257 | - wp_register_style( |
|
258 | - 'espresso_payments', |
|
259 | - EE_PAYMENTS_ASSETS_URL . 'ee-payments.css', |
|
260 | - array(), |
|
261 | - EVENT_ESPRESSO_VERSION |
|
262 | - ); |
|
263 | - wp_enqueue_style('espresso_payments'); |
|
264 | - wp_enqueue_style('ee-text-links'); |
|
265 | - // scripts |
|
266 | - } |
|
267 | - |
|
268 | - |
|
269 | - /** |
|
270 | - * @throws EE_Error |
|
271 | - * @throws ReflectionException |
|
272 | - */ |
|
273 | - protected function _payment_methods_list() |
|
274 | - { |
|
275 | - /** |
|
276 | - * first let's ensure payment methods have been set up. |
|
277 | - * We do this here because when people activate a payment method for the first time (as an addon), |
|
278 | - * it may not set up its capabilities or get registered correctly due to the loading process. |
|
279 | - * However, people MUST set up the details for the payment method, |
|
280 | - * so it's safe to do a recheck here. |
|
281 | - */ |
|
282 | - EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
283 | - EEM_Payment_Method::instance()->verify_button_urls(); |
|
284 | - // set up tabs, one for each payment method type |
|
285 | - $tabs = array(); |
|
286 | - $payment_methods = array(); |
|
287 | - foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) { |
|
288 | - // we don't want to show admin-only PMTs for now |
|
289 | - if ($pmt_obj instanceof EE_PMT_Admin_Only) { |
|
290 | - continue; |
|
291 | - } |
|
292 | - // check access |
|
293 | - if ( |
|
294 | - ! EE_Registry::instance()->CAP->current_user_can( |
|
295 | - $pmt_obj->cap_name(), |
|
296 | - 'specific_payment_method_type_access' |
|
297 | - ) |
|
298 | - ) { |
|
299 | - continue; |
|
300 | - } |
|
301 | - // check for any active pms of that type |
|
302 | - $payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name()); |
|
303 | - if (! $payment_method instanceof EE_Payment_Method) { |
|
304 | - $payment_method = EE_Payment_Method::new_instance( |
|
305 | - array( |
|
306 | - 'PMD_slug' => sanitize_key($pmt_obj->system_name()), |
|
307 | - 'PMD_type' => $pmt_obj->system_name(), |
|
308 | - 'PMD_name' => $pmt_obj->pretty_name(), |
|
309 | - 'PMD_admin_name' => $pmt_obj->pretty_name(), |
|
310 | - ) |
|
311 | - ); |
|
312 | - } |
|
313 | - $payment_methods[ $payment_method->slug() ] = $payment_method; |
|
314 | - } |
|
315 | - $payment_methods = apply_filters( |
|
316 | - 'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', |
|
317 | - $payment_methods |
|
318 | - ); |
|
319 | - foreach ($payment_methods as $payment_method) { |
|
320 | - if ($payment_method instanceof EE_Payment_Method) { |
|
321 | - add_meta_box( |
|
322 | - // html id |
|
323 | - 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
324 | - // title |
|
325 | - sprintf(esc_html__('%s Settings', 'event_espresso'), $payment_method->admin_name()), |
|
326 | - // callback |
|
327 | - array($this, 'payment_method_settings_meta_box'), |
|
328 | - // post type |
|
329 | - null, |
|
330 | - // context |
|
331 | - 'normal', |
|
332 | - // priority |
|
333 | - 'default', |
|
334 | - // callback args |
|
335 | - array('payment_method' => $payment_method) |
|
336 | - ); |
|
337 | - // setup for tabbed content |
|
338 | - $tabs[ $payment_method->slug() ] = array( |
|
339 | - 'label' => $payment_method->admin_name(), |
|
340 | - 'class' => $payment_method->active() ? 'gateway-active' : '', |
|
341 | - 'href' => 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
342 | - 'title' => esc_html__('Modify this Payment Method', 'event_espresso'), |
|
343 | - 'slug' => $payment_method->slug(), |
|
344 | - ); |
|
345 | - } |
|
346 | - } |
|
347 | - $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( |
|
348 | - $tabs, |
|
349 | - 'payment_method_links', |
|
350 | - '|', |
|
351 | - $this->_get_active_payment_method_slug() |
|
352 | - ); |
|
353 | - $this->display_admin_page_with_sidebar(); |
|
354 | - } |
|
355 | - |
|
356 | - |
|
357 | - /** |
|
358 | - * _get_active_payment_method_slug |
|
359 | - * |
|
360 | - * @return string |
|
361 | - * @throws EE_Error |
|
362 | - */ |
|
363 | - protected function _get_active_payment_method_slug() |
|
364 | - { |
|
365 | - $payment_method_slug = false; |
|
366 | - // decide which payment method tab to open first, as dictated by the request's 'payment_method' |
|
367 | - if (isset($this->_req_data['payment_method'])) { |
|
368 | - // if they provided the current payment method, use it |
|
369 | - $payment_method_slug = sanitize_key($this->_req_data['payment_method']); |
|
370 | - } |
|
371 | - /** @var EE_Payment_Method $payment_method */ |
|
372 | - $payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug))); |
|
373 | - // if that didn't work or wasn't provided, find another way to select the current pm |
|
374 | - if (! $this->_verify_payment_method($payment_method)) { |
|
375 | - // like, looking for an active one |
|
376 | - $payment_method = EEM_Payment_Method::instance()->get_one_active('CART'); |
|
377 | - // test that one as well |
|
378 | - if ($this->_verify_payment_method($payment_method)) { |
|
379 | - $payment_method_slug = $payment_method->slug(); |
|
380 | - } else { |
|
381 | - $payment_method_slug = 'paypal_standard'; |
|
382 | - } |
|
383 | - } |
|
384 | - return $payment_method_slug; |
|
385 | - } |
|
386 | - |
|
387 | - |
|
388 | - /** |
|
389 | - * payment_method_settings_meta_box |
|
390 | - * returns TRUE if the passed payment method is properly constructed and the logged-in user has the correct |
|
391 | - * capabilities to access it |
|
392 | - * |
|
393 | - * @param EE_Payment_Method $payment_method |
|
394 | - * @return boolean |
|
395 | - * @throws EE_Error |
|
396 | - */ |
|
397 | - protected function _verify_payment_method($payment_method) |
|
398 | - { |
|
399 | - if ( |
|
400 | - $payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base |
|
401 | - && EE_Registry::instance()->CAP->current_user_can( |
|
402 | - $payment_method->type_obj()->cap_name(), |
|
403 | - 'specific_payment_method_type_access' |
|
404 | - ) |
|
405 | - ) { |
|
406 | - return true; |
|
407 | - } |
|
408 | - return false; |
|
409 | - } |
|
410 | - |
|
411 | - |
|
412 | - /** |
|
413 | - * payment_method_settings_meta_box |
|
414 | - * |
|
415 | - * @param NULL $post_obj_which_is_null is an object containing the current post (as a $post object) |
|
416 | - * @param array $metabox is an array with metabox id, title, callback, and args elements. the value |
|
417 | - * at 'args' has key 'payment_method', as set within _payment_methods_list |
|
418 | - * @return void |
|
419 | - * @throws EE_Error |
|
420 | - * @throws ReflectionException |
|
421 | - */ |
|
422 | - public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox) |
|
423 | - { |
|
424 | - $payment_method = isset($metabox['args'], $metabox['args']['payment_method']) |
|
425 | - ? $metabox['args']['payment_method'] : null; |
|
426 | - if (! $payment_method instanceof EE_Payment_Method) { |
|
427 | - throw new EE_Error( |
|
428 | - esc_html__( |
|
429 | - 'Payment method metabox setup incorrectly. No Payment method object was supplied', |
|
430 | - 'event_espresso' |
|
431 | - ) |
|
432 | - ); |
|
433 | - } |
|
434 | - $payment_method_scopes = $payment_method->active(); |
|
435 | - // if the payment method really exists show its form, otherwise the activation template |
|
436 | - if ($payment_method->ID() && ! empty($payment_method_scopes)) { |
|
437 | - $form = $this->_generate_payment_method_settings_form($payment_method); |
|
438 | - if ($form->form_data_present_in($this->_req_data)) { |
|
439 | - $form->receive_form_submission($this->_req_data); |
|
440 | - } |
|
441 | - echo $form->form_open() . $form->get_html_and_js() . $form->form_close(); // already escaped |
|
442 | - } else { |
|
443 | - echo $this->_activate_payment_method_button($payment_method)->get_html_and_js(); // already escaped |
|
444 | - } |
|
445 | - } |
|
446 | - |
|
447 | - |
|
448 | - /** |
|
449 | - * Gets the form for all the settings related to this payment method type |
|
450 | - * |
|
451 | - * @access protected |
|
452 | - * @param EE_Payment_Method $payment_method |
|
453 | - * @return EE_Form_Section_Proper |
|
454 | - * @throws EE_Error |
|
455 | - */ |
|
456 | - protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method = null) |
|
457 | - { |
|
458 | - if (! $payment_method instanceof EE_Payment_Method) { |
|
459 | - return new EE_Form_Section_Proper(); |
|
460 | - } |
|
461 | - return new EE_Form_Section_Proper( |
|
462 | - array( |
|
463 | - 'name' => $payment_method->slug() . '_settings_form', |
|
464 | - 'html_id' => $payment_method->slug() . '_settings_form', |
|
465 | - 'action' => EE_Admin_Page::add_query_args_and_nonce( |
|
466 | - array( |
|
467 | - 'action' => 'update_payment_method', |
|
468 | - 'payment_method' => $payment_method->slug(), |
|
469 | - ), |
|
470 | - EE_PAYMENTS_ADMIN_URL |
|
471 | - ), |
|
472 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
473 | - 'subsections' => apply_filters( |
|
474 | - 'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections', |
|
475 | - array( |
|
476 | - 'pci_dss_compliance' => $this->_pci_dss_compliance($payment_method), |
|
477 | - 'currency_support' => $this->_currency_support($payment_method), |
|
478 | - 'payment_method_settings' => $this->_payment_method_settings($payment_method), |
|
479 | - 'update' => $this->_update_payment_method_button($payment_method), |
|
480 | - 'deactivate' => $this->_deactivate_payment_method_button($payment_method), |
|
481 | - 'fine_print' => $this->_fine_print(), |
|
482 | - ), |
|
483 | - $payment_method |
|
484 | - ), |
|
485 | - ) |
|
486 | - ); |
|
487 | - } |
|
488 | - |
|
489 | - |
|
490 | - /** |
|
491 | - * _pci_dss_compliance |
|
492 | - * |
|
493 | - * @access protected |
|
494 | - * @param EE_Payment_Method $payment_method |
|
495 | - * @return EE_Form_Section_HTML |
|
496 | - * @throws EE_Error |
|
497 | - */ |
|
498 | - protected function _pci_dss_compliance(EE_Payment_Method $payment_method) |
|
499 | - { |
|
500 | - if ($payment_method->type_obj()->requires_https()) { |
|
501 | - return new EE_Form_Section_HTML( |
|
502 | - EEH_HTML::table( |
|
503 | - EEH_HTML::tr( |
|
504 | - EEH_HTML::th( |
|
505 | - EEH_HTML::label( |
|
506 | - EEH_HTML::strong( |
|
507 | - esc_html__('IMPORTANT', 'event_espresso'), |
|
508 | - '', |
|
509 | - 'important-notice' |
|
510 | - ) |
|
511 | - ) |
|
512 | - ) . |
|
513 | - EEH_HTML::td( |
|
514 | - EEH_HTML::strong( |
|
515 | - esc_html__( |
|
516 | - 'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', |
|
517 | - 'event_espresso' |
|
518 | - ) |
|
519 | - ) |
|
520 | - . |
|
521 | - EEH_HTML::br() |
|
522 | - . |
|
523 | - esc_html__('Learn more about ', 'event_espresso') |
|
524 | - . EEH_HTML::link( |
|
525 | - 'https://www.pcisecuritystandards.org/merchants/index.php', |
|
526 | - esc_html__('PCI DSS compliance', 'event_espresso') |
|
527 | - ) |
|
528 | - ) |
|
529 | - ) |
|
530 | - ) |
|
531 | - ); |
|
532 | - } |
|
533 | - return new EE_Form_Section_HTML(''); |
|
534 | - } |
|
535 | - |
|
536 | - |
|
537 | - /** |
|
538 | - * _currency_support |
|
539 | - * |
|
540 | - * @access protected |
|
541 | - * @param EE_Payment_Method $payment_method |
|
542 | - * @return EE_Form_Section_HTML |
|
543 | - * @throws EE_Error |
|
544 | - */ |
|
545 | - protected function _currency_support(EE_Payment_Method $payment_method) |
|
546 | - { |
|
547 | - if (! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) { |
|
548 | - return new EE_Form_Section_HTML( |
|
549 | - EEH_HTML::table( |
|
550 | - EEH_HTML::tr( |
|
551 | - EEH_HTML::th( |
|
552 | - EEH_HTML::label( |
|
553 | - EEH_HTML::strong( |
|
554 | - esc_html__('IMPORTANT', 'event_espresso'), |
|
555 | - '', |
|
556 | - 'important-notice' |
|
557 | - ) |
|
558 | - ) |
|
559 | - ) . |
|
560 | - EEH_HTML::td( |
|
561 | - EEH_HTML::strong( |
|
562 | - sprintf( |
|
563 | - esc_html__( |
|
564 | - 'This payment method does not support the currency set on your site (%1$s). Please activate a different payment method or change your site\'s country and associated currency.', |
|
565 | - 'event_espresso' |
|
566 | - ), |
|
567 | - EE_Config::instance()->currency->code |
|
568 | - ) |
|
569 | - ) |
|
570 | - ) |
|
571 | - ) |
|
572 | - ) |
|
573 | - ); |
|
574 | - } |
|
575 | - return new EE_Form_Section_HTML(''); |
|
576 | - } |
|
577 | - |
|
578 | - |
|
579 | - /** |
|
580 | - * _update_payment_method_button |
|
581 | - * |
|
582 | - * @access protected |
|
583 | - * @param EE_Payment_Method $payment_method |
|
584 | - * @return EE_Payment_Method_Form |
|
585 | - * @throws EE_Error |
|
586 | - */ |
|
587 | - protected function _payment_method_settings(EE_Payment_Method $payment_method) |
|
588 | - { |
|
589 | - // modify the form, so we only have/show fields that will be implemented for this version |
|
590 | - return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name()); |
|
591 | - } |
|
592 | - |
|
593 | - |
|
594 | - /** |
|
595 | - * Simplifies the form to merely reproduce 4.1's gateway settings functionality |
|
596 | - * |
|
597 | - * @param EE_Form_Section_Proper $form_section |
|
598 | - * @param string $payment_method_name |
|
599 | - * @return EE_Payment_Method_Form |
|
600 | - * @throws EE_Error |
|
601 | - */ |
|
602 | - protected function _simplify_form($form_section, $payment_method_name = '') |
|
603 | - { |
|
604 | - if ($form_section instanceof EE_Payment_Method_Form) { |
|
605 | - $form_section->exclude( |
|
606 | - array( |
|
607 | - 'PMD_type', // don't want them changing the type |
|
608 | - 'PMD_slug', // or the slug (probably never) |
|
609 | - 'PMD_wp_user', // or the user's ID |
|
610 | - 'Currency' // or the currency, until the rest of EE supports simultaneous currencies |
|
611 | - ) |
|
612 | - ); |
|
613 | - return $form_section; |
|
614 | - } else { |
|
615 | - throw new EE_Error( |
|
616 | - sprintf( |
|
617 | - esc_html__( |
|
618 | - 'The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', |
|
619 | - 'event_espresso' |
|
620 | - ), |
|
621 | - $payment_method_name |
|
622 | - ) |
|
623 | - ); |
|
624 | - } |
|
625 | - } |
|
626 | - |
|
627 | - |
|
628 | - /** |
|
629 | - * _update_payment_method_button |
|
630 | - * |
|
631 | - * @access protected |
|
632 | - * @param EE_Payment_Method $payment_method |
|
633 | - * @return EE_Form_Section_HTML |
|
634 | - * @throws EE_Error |
|
635 | - */ |
|
636 | - protected function _update_payment_method_button(EE_Payment_Method $payment_method) |
|
637 | - { |
|
638 | - $update_button = new EE_Submit_Input( |
|
639 | - array( |
|
640 | - 'name' => 'submit', |
|
641 | - 'html_id' => 'save_' . $payment_method->slug() . '_settings', |
|
642 | - 'default' => sprintf( |
|
643 | - esc_html__('Update %s Payment Settings', 'event_espresso'), |
|
644 | - $payment_method->admin_name() |
|
645 | - ), |
|
646 | - 'html_label' => EEH_HTML::nbsp(), |
|
647 | - ) |
|
648 | - ); |
|
649 | - return new EE_Form_Section_HTML( |
|
650 | - EEH_HTML::table( |
|
651 | - EEH_HTML::no_row(EEH_HTML::br(2)) . |
|
652 | - EEH_HTML::tr( |
|
653 | - EEH_HTML::th(esc_html__('Update Settings', 'event_espresso')) . |
|
654 | - EEH_HTML::td( |
|
655 | - $update_button->get_html_for_input() |
|
656 | - ) |
|
657 | - ) |
|
658 | - ) |
|
659 | - ); |
|
660 | - } |
|
661 | - |
|
662 | - |
|
663 | - /** |
|
664 | - * _deactivate_payment_method_button |
|
665 | - * |
|
666 | - * @access protected |
|
667 | - * @param EE_Payment_Method $payment_method |
|
668 | - * @return EE_Form_Section_HTML |
|
669 | - */ |
|
670 | - protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method) |
|
671 | - { |
|
672 | - $link_text_and_title = sprintf( |
|
673 | - esc_html__('Deactivate %1$s Payments?', 'event_espresso'), |
|
674 | - $payment_method->admin_name() |
|
675 | - ); |
|
676 | - return new EE_Form_Section_HTML( |
|
677 | - EEH_HTML::table( |
|
678 | - EEH_HTML::tr( |
|
679 | - EEH_HTML::th(esc_html__('Deactivate Payment Method', 'event_espresso')) . |
|
680 | - EEH_HTML::td( |
|
681 | - EEH_HTML::link( |
|
682 | - EE_Admin_Page::add_query_args_and_nonce( |
|
683 | - array( |
|
684 | - 'action' => 'deactivate_payment_method', |
|
685 | - 'payment_method' => $payment_method->slug(), |
|
686 | - ), |
|
687 | - EE_PAYMENTS_ADMIN_URL |
|
688 | - ), |
|
689 | - $link_text_and_title, |
|
690 | - $link_text_and_title, |
|
691 | - 'deactivate_' . $payment_method->slug(), |
|
692 | - 'espresso-button button-secondary' |
|
693 | - ) |
|
694 | - ) |
|
695 | - ) |
|
696 | - ) |
|
697 | - ); |
|
698 | - } |
|
699 | - |
|
700 | - |
|
701 | - /** |
|
702 | - * _activate_payment_method_button |
|
703 | - * |
|
704 | - * @access protected |
|
705 | - * @param EE_Payment_Method $payment_method |
|
706 | - * @return EE_Form_Section_Proper |
|
707 | - * @throws EE_Error |
|
708 | - */ |
|
709 | - protected function _activate_payment_method_button(EE_Payment_Method $payment_method) |
|
710 | - { |
|
711 | - $link_text_and_title = sprintf( |
|
712 | - esc_html__('Activate %1$s Payment Method?', 'event_espresso'), |
|
713 | - $payment_method->admin_name() |
|
714 | - ); |
|
715 | - return new EE_Form_Section_Proper( |
|
716 | - array( |
|
717 | - 'name' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
718 | - 'html_id' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
719 | - 'action' => '#', |
|
720 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
721 | - 'subsections' => apply_filters( |
|
722 | - 'FHEE__Payments_Admin_Page___activate_payment_method_button__form_subsections', |
|
723 | - array( |
|
724 | - new EE_Form_Section_HTML( |
|
725 | - EEH_HTML::table( |
|
726 | - EEH_HTML::tr( |
|
727 | - EEH_HTML::td( |
|
728 | - $payment_method->type_obj()->introductory_html(), |
|
729 | - '', |
|
730 | - '', |
|
731 | - '', |
|
732 | - 'colspan="2"' |
|
733 | - ) |
|
734 | - ) . |
|
735 | - EEH_HTML::tr( |
|
736 | - EEH_HTML::th( |
|
737 | - EEH_HTML::label(esc_html__('Click to Activate ', 'event_espresso')) |
|
738 | - ) . |
|
739 | - EEH_HTML::td( |
|
740 | - EEH_HTML::link( |
|
741 | - EE_Admin_Page::add_query_args_and_nonce( |
|
742 | - array( |
|
743 | - 'action' => 'activate_payment_method', |
|
744 | - 'payment_method_type' => $payment_method->type(), |
|
745 | - ), |
|
746 | - EE_PAYMENTS_ADMIN_URL |
|
747 | - ), |
|
748 | - $link_text_and_title, |
|
749 | - $link_text_and_title, |
|
750 | - 'activate_' . $payment_method->slug(), |
|
751 | - 'espresso-button-green button-primary' |
|
752 | - ) |
|
753 | - ) |
|
754 | - ) |
|
755 | - ) |
|
756 | - ), |
|
757 | - ), |
|
758 | - $payment_method |
|
759 | - ), |
|
760 | - ) |
|
761 | - ); |
|
762 | - } |
|
763 | - |
|
764 | - |
|
765 | - /** |
|
766 | - * _fine_print |
|
767 | - * |
|
768 | - * @access protected |
|
769 | - * @return EE_Form_Section_HTML |
|
770 | - */ |
|
771 | - protected function _fine_print() |
|
772 | - { |
|
773 | - return new EE_Form_Section_HTML( |
|
774 | - EEH_HTML::table( |
|
775 | - EEH_HTML::tr( |
|
776 | - EEH_HTML::th() . |
|
777 | - EEH_HTML::td( |
|
778 | - EEH_HTML::p(esc_html__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text') |
|
779 | - ) |
|
780 | - ) |
|
781 | - ) |
|
782 | - ); |
|
783 | - } |
|
784 | - |
|
785 | - |
|
786 | - /** |
|
787 | - * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far) |
|
788 | - * |
|
789 | - * @throws EE_Error |
|
790 | - * @throws ReflectionException |
|
791 | - * @global WP_User $current_user |
|
792 | - */ |
|
793 | - protected function _activate_payment_method() |
|
794 | - { |
|
795 | - if (isset($this->_req_data['payment_method_type'])) { |
|
796 | - $payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']); |
|
797 | - // see if one exists |
|
798 | - EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
799 | - $payment_method = EE_Payment_Method_Manager::instance() |
|
800 | - ->activate_a_payment_method_of_type($payment_method_type); |
|
801 | - $this->_redirect_after_action( |
|
802 | - 1, |
|
803 | - 'Payment Method', |
|
804 | - 'activated', |
|
805 | - array('action' => 'default', 'payment_method' => $payment_method->slug()) |
|
806 | - ); |
|
807 | - } else { |
|
808 | - $this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default')); |
|
809 | - } |
|
810 | - } |
|
811 | - |
|
812 | - |
|
813 | - /** |
|
814 | - * @throws EE_Error |
|
815 | - * @throws ReflectionException |
|
816 | - */ |
|
817 | - protected function _deactivate_payment_method() |
|
818 | - { |
|
819 | - if (isset($this->_req_data['payment_method'])) { |
|
820 | - $payment_method_slug = sanitize_key($this->_req_data['payment_method']); |
|
821 | - // deactivate it |
|
822 | - EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
823 | - $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug); |
|
824 | - $this->_redirect_after_action( |
|
825 | - $count_updated, |
|
826 | - 'Payment Method', |
|
827 | - 'deactivated', |
|
828 | - array('action' => 'default', 'payment_method' => $payment_method_slug) |
|
829 | - ); |
|
830 | - } else { |
|
831 | - $this->_redirect_after_action(false, 'Payment Method', 'deactivated', array('action' => 'default')); |
|
832 | - } |
|
833 | - } |
|
834 | - |
|
835 | - |
|
836 | - /** |
|
837 | - * Processes the payment method form that was submitted. This is slightly trickier than usual form |
|
838 | - * processing because we first need to identify WHICH form was processed and which payment method |
|
839 | - * it corresponds to. Once we have done that, we see if the form is valid. If it is, the |
|
840 | - * form's data is saved, and we redirect to the default payment methods page, setting the updated payment method |
|
841 | - * as the currently-selected one. If it DOESN'T validate, we render the page with the form's errors (in the |
|
842 | - * subsequently called 'headers_sent_func' which is _payment_methods_list) |
|
843 | - * |
|
844 | - * @return void |
|
845 | - * @throws EE_Error |
|
846 | - * @throws ReflectionException |
|
847 | - */ |
|
848 | - protected function _update_payment_method() |
|
849 | - { |
|
850 | - if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
851 | - // ok let's find which gateway form to use based on the form input |
|
852 | - EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
853 | - /** @var $correct_pmt_form_to_use EE_Payment_Method_Form */ |
|
854 | - $correct_pmt_form_to_use = null; |
|
855 | - $payment_method = null; |
|
856 | - foreach (EEM_Payment_Method::instance()->get_all() as $payment_method) { |
|
857 | - if ($payment_method instanceof EE_Payment_Method) { |
|
858 | - // get the form and simplify it, like what we do when we display it |
|
859 | - $pmt_form = $this->_generate_payment_method_settings_form($payment_method); |
|
860 | - if ($pmt_form->form_data_present_in($this->_req_data)) { |
|
861 | - $correct_pmt_form_to_use = $pmt_form; |
|
862 | - break; |
|
863 | - } |
|
864 | - } |
|
865 | - } |
|
866 | - // if we couldn't find the correct payment method type... |
|
867 | - if (! $correct_pmt_form_to_use) { |
|
868 | - EE_Error::add_error( |
|
869 | - esc_html__( |
|
870 | - "We could not find which payment method type your form submission related to. Please contact support", |
|
871 | - 'event_espresso' |
|
872 | - ), |
|
873 | - __FILE__, |
|
874 | - __FUNCTION__, |
|
875 | - __LINE__ |
|
876 | - ); |
|
877 | - $this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default')); |
|
878 | - } |
|
879 | - $correct_pmt_form_to_use->receive_form_submission($this->_req_data); |
|
880 | - if ($correct_pmt_form_to_use->is_valid()) { |
|
881 | - $payment_settings_subform = $correct_pmt_form_to_use->get_subsection('payment_method_settings'); |
|
882 | - if (! $payment_settings_subform instanceof EE_Payment_Method_Form) { |
|
883 | - throw new EE_Error( |
|
884 | - sprintf( |
|
885 | - esc_html__( |
|
886 | - 'The payment method could not be saved because the form sections were misnamed. We expected to find %1$s, but did not.', |
|
887 | - 'event_espresso' |
|
888 | - ), |
|
889 | - 'payment_method_settings' |
|
890 | - ) |
|
891 | - ); |
|
892 | - } |
|
893 | - $payment_settings_subform->save(); |
|
894 | - /** @var $pm EE_Payment_Method */ |
|
895 | - $this->_redirect_after_action( |
|
896 | - true, |
|
897 | - 'Payment Method', |
|
898 | - 'updated', |
|
899 | - array('action' => 'default', 'payment_method' => $payment_method->slug()) |
|
900 | - ); |
|
901 | - } else { |
|
902 | - EE_Error::add_error( |
|
903 | - sprintf( |
|
904 | - esc_html__( |
|
905 | - 'Payment method of type %s was not saved because there were validation errors. They have been marked in the form', |
|
906 | - 'event_espresso' |
|
907 | - ), |
|
908 | - $payment_method instanceof EE_Payment_Method ? $payment_method->type_obj()->pretty_name() |
|
909 | - : esc_html__('"(unknown)"', 'event_espresso') |
|
910 | - ), |
|
911 | - __FILE__, |
|
912 | - __FUNCTION__, |
|
913 | - __LINE__ |
|
914 | - ); |
|
915 | - } |
|
916 | - } |
|
917 | - } |
|
918 | - |
|
919 | - |
|
920 | - /** |
|
921 | - * Displays payment settings (not payment METHOD settings, that's _payment_method_settings) |
|
922 | - * @throws DomainException |
|
923 | - * @throws EE_Error |
|
924 | - * @throws InvalidArgumentException |
|
925 | - * @throws InvalidDataTypeException |
|
926 | - * @throws InvalidInterfaceException |
|
927 | - */ |
|
928 | - protected function _payment_settings() |
|
929 | - { |
|
930 | - $form = $this->getPaymentSettingsForm(); |
|
931 | - $this->_set_add_edit_form_tags('update_payment_settings'); |
|
932 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
933 | - $this->_template_args['admin_page_content'] = $form->get_html_and_js(); |
|
934 | - $this->display_admin_page_with_sidebar(); |
|
935 | - } |
|
936 | - |
|
937 | - |
|
938 | - /** |
|
939 | - * _update_payment_settings |
|
940 | - * |
|
941 | - * @access protected |
|
942 | - * @return void |
|
943 | - * @throws EE_Error |
|
944 | - * @throws InvalidArgumentException |
|
945 | - * @throws InvalidDataTypeException |
|
946 | - * @throws InvalidInterfaceException |
|
947 | - */ |
|
948 | - protected function _update_payment_settings() |
|
949 | - { |
|
950 | - $form = $this->getPaymentSettingsForm(); |
|
951 | - if ($form->was_submitted($this->_req_data)) { |
|
952 | - $form->receive_form_submission($this->_req_data); |
|
953 | - if ($form->is_valid()) { |
|
954 | - /** |
|
955 | - * @var $reg_config EE_Registration_Config |
|
956 | - */ |
|
957 | - $loader = LoaderFactory::getLoader(); |
|
958 | - $reg_config = $loader->getShared('EE_Registration_Config'); |
|
959 | - $valid_data = $form->valid_data(); |
|
960 | - $reg_config->show_pending_payment_options = $valid_data['show_pending_payment_options']; |
|
961 | - $reg_config->gateway_log_lifespan = $valid_data['gateway_log_lifespan']; |
|
962 | - } |
|
963 | - } |
|
964 | - EE_Registry::instance()->CFG = apply_filters( |
|
965 | - 'FHEE__Payments_Admin_Page___update_payment_settings__CFG', |
|
966 | - EE_Registry::instance()->CFG |
|
967 | - ); |
|
968 | - |
|
969 | - $what = esc_html__('Payment Settings', 'event_espresso'); |
|
970 | - $success = $this->_update_espresso_configuration( |
|
971 | - $what, |
|
972 | - EE_Registry::instance()->CFG, |
|
973 | - __FILE__, |
|
974 | - __FUNCTION__, |
|
975 | - __LINE__ |
|
976 | - ); |
|
977 | - $this->_redirect_after_action( |
|
978 | - $success, |
|
979 | - $what, |
|
980 | - esc_html__('updated', 'event_espresso'), |
|
981 | - array('action' => 'payment_settings') |
|
982 | - ); |
|
983 | - } |
|
984 | - |
|
985 | - |
|
986 | - /** |
|
987 | - * Gets the form used for updating payment settings |
|
988 | - * |
|
989 | - * @return EE_Form_Section_Proper |
|
990 | - * @throws EE_Error |
|
991 | - * @throws InvalidArgumentException |
|
992 | - * @throws InvalidDataTypeException |
|
993 | - * @throws InvalidInterfaceException |
|
994 | - */ |
|
995 | - protected function getPaymentSettingsForm() |
|
996 | - { |
|
997 | - /** |
|
998 | - * @var $reg_config EE_Registration_Config |
|
999 | - */ |
|
1000 | - $reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config'); |
|
1001 | - return new EE_Form_Section_Proper( |
|
1002 | - array( |
|
1003 | - 'name' => 'payment-settings', |
|
1004 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
1005 | - 'subsections' => array( |
|
1006 | - 'show_pending_payment_options' => new EE_Yes_No_Input( |
|
1007 | - array( |
|
1008 | - 'html_name' => 'show_pending_payment_options', |
|
1009 | - 'default' => $reg_config->show_pending_payment_options, |
|
1010 | - 'html_help_text' => esc_html__( |
|
1011 | - "If a payment is marked as 'Pending Payment', or if payment is deferred (ie, an offline gateway like Check, Bank, or Invoice is used), then give registrants the option to retry payment. ", |
|
1012 | - 'event_espresso' |
|
1013 | - ) |
|
1014 | - ) |
|
1015 | - ), |
|
1016 | - 'gateway_log_lifespan' => new EE_Select_Input( |
|
1017 | - $reg_config->gatewayLogLifespanOptions(), |
|
1018 | - array( |
|
1019 | - 'html_label_text' => esc_html__('Gateway Logs Lifespan', 'event_espresso'), |
|
1020 | - 'html_help_text' => esc_html__('If issues arise with payments being made through a payment gateway, it\'s helpful to log non-sensitive communications with the payment gateway. But it\'s a security responsibility, so it\'s a good idea to not keep them for any longer than necessary.', 'event_espresso'), |
|
1021 | - 'default' => $reg_config->gateway_log_lifespan, |
|
1022 | - ) |
|
1023 | - ) |
|
1024 | - ) |
|
1025 | - ) |
|
1026 | - ); |
|
1027 | - } |
|
1028 | - |
|
1029 | - |
|
1030 | - /** |
|
1031 | - * @throws EE_Error |
|
1032 | - */ |
|
1033 | - protected function _payment_log_overview_list_table() |
|
1034 | - { |
|
1035 | - $this->display_admin_list_table_page_with_sidebar(); |
|
1036 | - } |
|
1037 | - |
|
1038 | - |
|
1039 | - protected function _set_list_table_views_payment_log() |
|
1040 | - { |
|
1041 | - $this->_views = array( |
|
1042 | - 'all' => array( |
|
1043 | - 'slug' => 'all', |
|
1044 | - 'label' => esc_html__('View All Logs', 'event_espresso'), |
|
1045 | - 'count' => 0, |
|
1046 | - ), |
|
1047 | - ); |
|
1048 | - } |
|
1049 | - |
|
1050 | - |
|
1051 | - /** |
|
1052 | - * @param int $per_page |
|
1053 | - * @param int $current_page |
|
1054 | - * @param bool $count |
|
1055 | - * @return array|int |
|
1056 | - * @throws EE_Error |
|
1057 | - * @throws ReflectionException |
|
1058 | - */ |
|
1059 | - public function get_payment_logs($per_page = 50, $current_page = 0, $count = false) |
|
1060 | - { |
|
1061 | - EE_Registry::instance()->load_model('Change_Log'); |
|
1062 | - // we may need to do multiple queries (joining differently), so we actually want an array of query params |
|
1063 | - $query_params = array(array('LOG_type' => EEM_Change_Log::type_gateway)); |
|
1064 | - // check if they've selected a specific payment method |
|
1065 | - if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') { |
|
1066 | - $query_params[0]['OR*pm_or_pay_pm'] = array( |
|
1067 | - 'Payment.Payment_Method.PMD_ID' => $this->_req_data['_payment_method'], |
|
1068 | - 'Payment_Method.PMD_ID' => $this->_req_data['_payment_method'], |
|
1069 | - ); |
|
1070 | - } |
|
1071 | - // take into account search |
|
1072 | - if (isset($this->_req_data['s']) && $this->_req_data['s']) { |
|
1073 | - $similarity_string = array('LIKE', '%' . str_replace("", "%", $this->_req_data['s']) . '%'); |
|
1074 | - $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string; |
|
1075 | - $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string; |
|
1076 | - $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string; |
|
1077 | - $query_params[0]['OR*s']['Payment.Payment_Method.PMD_name'] = $similarity_string; |
|
1078 | - $query_params[0]['OR*s']['Payment.Payment_Method.PMD_admin_name'] = $similarity_string; |
|
1079 | - $query_params[0]['OR*s']['Payment.Payment_Method.PMD_type'] = $similarity_string; |
|
1080 | - $query_params[0]['OR*s']['LOG_message'] = $similarity_string; |
|
1081 | - $query_params[0]['OR*s']['Payment_Method.PMD_name'] = $similarity_string; |
|
1082 | - $query_params[0]['OR*s']['Payment_Method.PMD_admin_name'] = $similarity_string; |
|
1083 | - $query_params[0]['OR*s']['Payment_Method.PMD_type'] = $similarity_string; |
|
1084 | - $query_params[0]['OR*s']['LOG_message'] = $similarity_string; |
|
1085 | - } |
|
1086 | - if ( |
|
1087 | - isset($this->_req_data['payment-filter-start-date']) |
|
1088 | - && isset($this->_req_data['payment-filter-end-date']) |
|
1089 | - ) { |
|
1090 | - // add date |
|
1091 | - $start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']); |
|
1092 | - $end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']); |
|
1093 | - // make sure our timestamps start and end right at the boundaries for each day |
|
1094 | - $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00'; |
|
1095 | - $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59'; |
|
1096 | - // convert to timestamps |
|
1097 | - $start_date = strtotime($start_date); |
|
1098 | - $end_date = strtotime($end_date); |
|
1099 | - // makes sure start date is the lowest value and vice versa |
|
1100 | - $start_date = min($start_date, $end_date); |
|
1101 | - $end_date = max($start_date, $end_date); |
|
1102 | - // convert for query |
|
1103 | - $start_date = EEM_Change_Log::instance()->convert_datetime_for_query( |
|
1104 | - 'LOG_time', |
|
1105 | - date('Y-m-d H:i:s', $start_date), |
|
1106 | - 'Y-m-d H:i:s' |
|
1107 | - ); |
|
1108 | - $end_date = EEM_Change_Log::instance()->convert_datetime_for_query( |
|
1109 | - 'LOG_time', |
|
1110 | - date('Y-m-d H:i:s', $end_date), |
|
1111 | - 'Y-m-d H:i:s' |
|
1112 | - ); |
|
1113 | - $query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date)); |
|
1114 | - } |
|
1115 | - if ($count) { |
|
1116 | - return EEM_Change_Log::instance()->count($query_params); |
|
1117 | - } |
|
1118 | - if (isset($this->_req_data['order'])) { |
|
1119 | - $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) |
|
1120 | - ? $this->_req_data['order'] |
|
1121 | - : 'DESC'; |
|
1122 | - $query_params['order_by'] = array('LOG_time' => $sort); |
|
1123 | - } else { |
|
1124 | - $query_params['order_by'] = array('LOG_time' => 'DESC'); |
|
1125 | - } |
|
1126 | - $offset = ($current_page - 1) * $per_page; |
|
1127 | - if (! isset($this->_req_data['download_results'])) { |
|
1128 | - $query_params['limit'] = array($offset, $per_page); |
|
1129 | - } |
|
1130 | - // now they've requested to instead just download the file instead of viewing it. |
|
1131 | - if (isset($this->_req_data['download_results'])) { |
|
1132 | - $wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params); |
|
1133 | - header('Content-Disposition: attachment'); |
|
1134 | - header("Content-Disposition: attachment; filename=ee_payment_logs_for_" . sanitize_key(site_url())); |
|
1135 | - echo '<h1> ' |
|
1136 | - . sprintf( |
|
1137 | - esc_html__('Payment Logs for %1$s', 'event_espresso'), |
|
1138 | - esc_url_raw(site_url()) |
|
1139 | - ) |
|
1140 | - . '</h1 >'; |
|
1141 | - echo '<h3>' . esc_html__('Query:', 'event_espresso') . '</h3>'; |
|
1142 | - echo esc_html(var_export($query_params, true)); |
|
1143 | - echo '<h3>' . esc_html__('Results:', 'event_espresso') . '</h3>'; |
|
1144 | - echo esc_html(var_export($wpdb_results, true)); |
|
1145 | - die; |
|
1146 | - } |
|
1147 | - return EEM_Change_Log::instance()->get_all($query_params); |
|
1148 | - } |
|
1149 | - |
|
1150 | - |
|
1151 | - /** |
|
1152 | - * Used by usort to RE-sort log query results, because we lose the ordering |
|
1153 | - * because we're possibly combining the results from two queries |
|
1154 | - * |
|
1155 | - * @param EE_Change_Log $logA |
|
1156 | - * @param EE_Change_Log $logB |
|
1157 | - * @return int |
|
1158 | - * @throws EE_Error |
|
1159 | - * @throws ReflectionException |
|
1160 | - */ |
|
1161 | - protected function _sort_logs_again($logA, $logB) |
|
1162 | - { |
|
1163 | - $timeA = $logA->get_raw('LOG_time'); |
|
1164 | - $timeB = $logB->get_raw('LOG_time'); |
|
1165 | - if ($timeA == $timeB) { |
|
1166 | - return 0; |
|
1167 | - } |
|
1168 | - $comparison = $timeA < $timeB ? -1 : 1; |
|
1169 | - if (strtoupper($this->_sort_logs_again_direction) == 'DESC') { |
|
1170 | - return $comparison * -1; |
|
1171 | - } |
|
1172 | - return $comparison; |
|
1173 | - } |
|
1174 | - |
|
1175 | - |
|
1176 | - /** |
|
1177 | - * @throws EE_Error |
|
1178 | - * @throws ReflectionException |
|
1179 | - */ |
|
1180 | - protected function _payment_log_details() |
|
1181 | - { |
|
1182 | - EE_Registry::instance()->load_model('Change_Log'); |
|
1183 | - /** @var $payment_log EE_Change_Log */ |
|
1184 | - $payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']); |
|
1185 | - $payment_method = null; |
|
1186 | - $transaction = null; |
|
1187 | - if ($payment_log instanceof EE_Change_Log) { |
|
1188 | - if ($payment_log->object() instanceof EE_Payment) { |
|
1189 | - $payment_method = $payment_log->object()->payment_method(); |
|
1190 | - $transaction = $payment_log->object()->transaction(); |
|
1191 | - } elseif ($payment_log->object() instanceof EE_Payment_Method) { |
|
1192 | - $payment_method = $payment_log->object(); |
|
1193 | - } elseif ($payment_log->object() instanceof EE_Transaction) { |
|
1194 | - $transaction = $payment_log->object(); |
|
1195 | - $payment_method = $transaction->payment_method(); |
|
1196 | - } |
|
1197 | - } |
|
1198 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
1199 | - EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php', |
|
1200 | - array( |
|
1201 | - 'payment_log' => $payment_log, |
|
1202 | - 'payment_method' => $payment_method, |
|
1203 | - 'transaction' => $transaction, |
|
1204 | - ), |
|
1205 | - true |
|
1206 | - ); |
|
1207 | - $this->display_admin_page_with_sidebar(); |
|
1208 | - } |
|
18 | + /** |
|
19 | + * Variables used for when we're re-sorting the logs results, |
|
20 | + * in case we needed to do two queries, and we need to resort |
|
21 | + * |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + private $_sort_logs_again_direction; |
|
25 | + |
|
26 | + |
|
27 | + /** |
|
28 | + * @Constructor |
|
29 | + * @access public |
|
30 | + * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
|
31 | + * @throws EE_Error |
|
32 | + * @throws InvalidArgumentException |
|
33 | + * @throws InvalidDataTypeException |
|
34 | + * @throws InvalidInterfaceException |
|
35 | + * @throws ReflectionException |
|
36 | + */ |
|
37 | + public function __construct($routing = true) |
|
38 | + { |
|
39 | + parent::__construct($routing); |
|
40 | + } |
|
41 | + |
|
42 | + |
|
43 | + protected function _init_page_props() |
|
44 | + { |
|
45 | + $this->page_slug = EE_PAYMENTS_PG_SLUG; |
|
46 | + $this->page_label = esc_html__('Payment Methods', 'event_espresso'); |
|
47 | + $this->_admin_base_url = EE_PAYMENTS_ADMIN_URL; |
|
48 | + $this->_admin_base_path = EE_PAYMENTS_ADMIN; |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + protected function _ajax_hooks() |
|
53 | + { |
|
54 | + // todo: all hooks for ajax goes here. |
|
55 | + } |
|
56 | + |
|
57 | + |
|
58 | + protected function _define_page_props() |
|
59 | + { |
|
60 | + $this->_admin_page_title = $this->page_label; |
|
61 | + $this->_labels = array( |
|
62 | + 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
63 | + ); |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + protected function _set_page_routes() |
|
68 | + { |
|
69 | + /** |
|
70 | + * note that with payment method capabilities, although we've implemented |
|
71 | + * capability mapping which will be used for accessing payment methods owned by |
|
72 | + * other users. This is not fully implemented yet in the payment method ui. |
|
73 | + * Currently, only the "plural" caps are in active use. |
|
74 | + * When cap mapping is implemented, some routes will need to use the singular form of |
|
75 | + * capability method and also include the $id of the payment method for the route. |
|
76 | + **/ |
|
77 | + $this->_page_routes = array( |
|
78 | + 'default' => array( |
|
79 | + 'func' => '_payment_methods_list', |
|
80 | + 'capability' => 'ee_edit_payment_methods', |
|
81 | + ), |
|
82 | + 'payment_settings' => array( |
|
83 | + 'func' => '_payment_settings', |
|
84 | + 'capability' => 'ee_manage_gateways', |
|
85 | + ), |
|
86 | + 'activate_payment_method' => array( |
|
87 | + 'func' => '_activate_payment_method', |
|
88 | + 'noheader' => true, |
|
89 | + 'capability' => 'ee_edit_payment_methods', |
|
90 | + ), |
|
91 | + 'deactivate_payment_method' => array( |
|
92 | + 'func' => '_deactivate_payment_method', |
|
93 | + 'noheader' => true, |
|
94 | + 'capability' => 'ee_delete_payment_methods', |
|
95 | + ), |
|
96 | + 'update_payment_method' => array( |
|
97 | + 'func' => '_update_payment_method', |
|
98 | + 'noheader' => true, |
|
99 | + 'headers_sent_route' => 'default', |
|
100 | + 'capability' => 'ee_edit_payment_methods', |
|
101 | + ), |
|
102 | + 'update_payment_settings' => array( |
|
103 | + 'func' => '_update_payment_settings', |
|
104 | + 'noheader' => true, |
|
105 | + 'capability' => 'ee_manage_gateways', |
|
106 | + ), |
|
107 | + 'payment_log' => array( |
|
108 | + 'func' => '_payment_log_overview_list_table', |
|
109 | + 'capability' => 'ee_read_payment_methods', |
|
110 | + ), |
|
111 | + 'payment_log_details' => array( |
|
112 | + 'func' => '_payment_log_details', |
|
113 | + 'capability' => 'ee_read_payment_methods', |
|
114 | + ), |
|
115 | + ); |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + /** |
|
120 | + * @throws EE_Error |
|
121 | + * @throws ReflectionException |
|
122 | + */ |
|
123 | + protected function _set_page_config() |
|
124 | + { |
|
125 | + $payment_method_list_config = array( |
|
126 | + 'nav' => array( |
|
127 | + 'label' => esc_html__('Payment Methods', 'event_espresso'), |
|
128 | + 'order' => 10, |
|
129 | + ), |
|
130 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
131 | + 'help_tabs' => array_merge( |
|
132 | + array( |
|
133 | + 'payment_methods_overview_help_tab' => array( |
|
134 | + 'title' => esc_html__('Payment Methods Overview', 'event_espresso'), |
|
135 | + 'filename' => 'payment_methods_overview', |
|
136 | + ), |
|
137 | + ), |
|
138 | + $this->_add_payment_method_help_tabs() |
|
139 | + ), |
|
140 | + 'require_nonce' => false, |
|
141 | + ); |
|
142 | + $this->_page_config = array( |
|
143 | + 'default' => $payment_method_list_config, |
|
144 | + 'payment_settings' => array( |
|
145 | + 'nav' => array( |
|
146 | + 'label' => esc_html__('Settings', 'event_espresso'), |
|
147 | + 'order' => 20, |
|
148 | + ), |
|
149 | + 'help_tabs' => array( |
|
150 | + 'payment_methods_settings_help_tab' => array( |
|
151 | + 'title' => esc_html__('Payment Method Settings', 'event_espresso'), |
|
152 | + 'filename' => 'payment_methods_settings', |
|
153 | + ), |
|
154 | + ), |
|
155 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
156 | + 'require_nonce' => false, |
|
157 | + ), |
|
158 | + 'payment_log' => array( |
|
159 | + 'nav' => array( |
|
160 | + 'label' => esc_html__("Logs", 'event_espresso'), |
|
161 | + 'order' => 30, |
|
162 | + ), |
|
163 | + 'list_table' => 'Payment_Log_Admin_List_Table', |
|
164 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
165 | + 'require_nonce' => false, |
|
166 | + ), |
|
167 | + ); |
|
168 | + } |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * @return array |
|
173 | + * @throws DomainException |
|
174 | + * @throws EE_Error |
|
175 | + * @throws InvalidArgumentException |
|
176 | + * @throws InvalidDataTypeException |
|
177 | + * @throws InvalidInterfaceException |
|
178 | + * @throws ReflectionException |
|
179 | + */ |
|
180 | + protected function _add_payment_method_help_tabs() |
|
181 | + { |
|
182 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
183 | + $payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types(); |
|
184 | + $all_pmt_help_tabs_config = array(); |
|
185 | + foreach ($payment_method_types as $payment_method_type) { |
|
186 | + if ( |
|
187 | + ! EE_Registry::instance()->CAP->current_user_can( |
|
188 | + $payment_method_type->cap_name(), |
|
189 | + 'specific_payment_method_type_access' |
|
190 | + ) |
|
191 | + ) { |
|
192 | + continue; |
|
193 | + } |
|
194 | + foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) { |
|
195 | + $template_args = isset($config['template_args']) ? $config['template_args'] : array(); |
|
196 | + $template_args['admin_page_obj'] = $this; |
|
197 | + $all_pmt_help_tabs_config[ $help_tab_name ] = array( |
|
198 | + 'title' => $config['title'], |
|
199 | + 'content' => EEH_Template::display_template( |
|
200 | + $payment_method_type->file_folder() . 'help_tabs/' . $config['filename'] . '.help_tab.php', |
|
201 | + $template_args, |
|
202 | + true |
|
203 | + ), |
|
204 | + ); |
|
205 | + } |
|
206 | + } |
|
207 | + return $all_pmt_help_tabs_config; |
|
208 | + } |
|
209 | + |
|
210 | + |
|
211 | + // none of the below group are currently used for Gateway Settings |
|
212 | + protected function _add_screen_options() |
|
213 | + { |
|
214 | + } |
|
215 | + |
|
216 | + |
|
217 | + protected function _add_feature_pointers() |
|
218 | + { |
|
219 | + } |
|
220 | + |
|
221 | + |
|
222 | + public function admin_init() |
|
223 | + { |
|
224 | + } |
|
225 | + |
|
226 | + |
|
227 | + public function admin_notices() |
|
228 | + { |
|
229 | + } |
|
230 | + |
|
231 | + |
|
232 | + public function admin_footer_scripts() |
|
233 | + { |
|
234 | + } |
|
235 | + |
|
236 | + |
|
237 | + public function load_scripts_styles() |
|
238 | + { |
|
239 | + // styles |
|
240 | + wp_enqueue_style('espresso-ui-theme'); |
|
241 | + // scripts |
|
242 | + wp_enqueue_script('ee_admin_js'); |
|
243 | + wp_enqueue_script('ee-text-links'); |
|
244 | + wp_enqueue_script( |
|
245 | + 'espresso_payments', |
|
246 | + EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js', |
|
247 | + array('ee-datepicker'), |
|
248 | + EVENT_ESPRESSO_VERSION, |
|
249 | + true |
|
250 | + ); |
|
251 | + } |
|
252 | + |
|
253 | + |
|
254 | + public function load_scripts_styles_default() |
|
255 | + { |
|
256 | + // styles |
|
257 | + wp_register_style( |
|
258 | + 'espresso_payments', |
|
259 | + EE_PAYMENTS_ASSETS_URL . 'ee-payments.css', |
|
260 | + array(), |
|
261 | + EVENT_ESPRESSO_VERSION |
|
262 | + ); |
|
263 | + wp_enqueue_style('espresso_payments'); |
|
264 | + wp_enqueue_style('ee-text-links'); |
|
265 | + // scripts |
|
266 | + } |
|
267 | + |
|
268 | + |
|
269 | + /** |
|
270 | + * @throws EE_Error |
|
271 | + * @throws ReflectionException |
|
272 | + */ |
|
273 | + protected function _payment_methods_list() |
|
274 | + { |
|
275 | + /** |
|
276 | + * first let's ensure payment methods have been set up. |
|
277 | + * We do this here because when people activate a payment method for the first time (as an addon), |
|
278 | + * it may not set up its capabilities or get registered correctly due to the loading process. |
|
279 | + * However, people MUST set up the details for the payment method, |
|
280 | + * so it's safe to do a recheck here. |
|
281 | + */ |
|
282 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
283 | + EEM_Payment_Method::instance()->verify_button_urls(); |
|
284 | + // set up tabs, one for each payment method type |
|
285 | + $tabs = array(); |
|
286 | + $payment_methods = array(); |
|
287 | + foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) { |
|
288 | + // we don't want to show admin-only PMTs for now |
|
289 | + if ($pmt_obj instanceof EE_PMT_Admin_Only) { |
|
290 | + continue; |
|
291 | + } |
|
292 | + // check access |
|
293 | + if ( |
|
294 | + ! EE_Registry::instance()->CAP->current_user_can( |
|
295 | + $pmt_obj->cap_name(), |
|
296 | + 'specific_payment_method_type_access' |
|
297 | + ) |
|
298 | + ) { |
|
299 | + continue; |
|
300 | + } |
|
301 | + // check for any active pms of that type |
|
302 | + $payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name()); |
|
303 | + if (! $payment_method instanceof EE_Payment_Method) { |
|
304 | + $payment_method = EE_Payment_Method::new_instance( |
|
305 | + array( |
|
306 | + 'PMD_slug' => sanitize_key($pmt_obj->system_name()), |
|
307 | + 'PMD_type' => $pmt_obj->system_name(), |
|
308 | + 'PMD_name' => $pmt_obj->pretty_name(), |
|
309 | + 'PMD_admin_name' => $pmt_obj->pretty_name(), |
|
310 | + ) |
|
311 | + ); |
|
312 | + } |
|
313 | + $payment_methods[ $payment_method->slug() ] = $payment_method; |
|
314 | + } |
|
315 | + $payment_methods = apply_filters( |
|
316 | + 'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', |
|
317 | + $payment_methods |
|
318 | + ); |
|
319 | + foreach ($payment_methods as $payment_method) { |
|
320 | + if ($payment_method instanceof EE_Payment_Method) { |
|
321 | + add_meta_box( |
|
322 | + // html id |
|
323 | + 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
324 | + // title |
|
325 | + sprintf(esc_html__('%s Settings', 'event_espresso'), $payment_method->admin_name()), |
|
326 | + // callback |
|
327 | + array($this, 'payment_method_settings_meta_box'), |
|
328 | + // post type |
|
329 | + null, |
|
330 | + // context |
|
331 | + 'normal', |
|
332 | + // priority |
|
333 | + 'default', |
|
334 | + // callback args |
|
335 | + array('payment_method' => $payment_method) |
|
336 | + ); |
|
337 | + // setup for tabbed content |
|
338 | + $tabs[ $payment_method->slug() ] = array( |
|
339 | + 'label' => $payment_method->admin_name(), |
|
340 | + 'class' => $payment_method->active() ? 'gateway-active' : '', |
|
341 | + 'href' => 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
342 | + 'title' => esc_html__('Modify this Payment Method', 'event_espresso'), |
|
343 | + 'slug' => $payment_method->slug(), |
|
344 | + ); |
|
345 | + } |
|
346 | + } |
|
347 | + $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( |
|
348 | + $tabs, |
|
349 | + 'payment_method_links', |
|
350 | + '|', |
|
351 | + $this->_get_active_payment_method_slug() |
|
352 | + ); |
|
353 | + $this->display_admin_page_with_sidebar(); |
|
354 | + } |
|
355 | + |
|
356 | + |
|
357 | + /** |
|
358 | + * _get_active_payment_method_slug |
|
359 | + * |
|
360 | + * @return string |
|
361 | + * @throws EE_Error |
|
362 | + */ |
|
363 | + protected function _get_active_payment_method_slug() |
|
364 | + { |
|
365 | + $payment_method_slug = false; |
|
366 | + // decide which payment method tab to open first, as dictated by the request's 'payment_method' |
|
367 | + if (isset($this->_req_data['payment_method'])) { |
|
368 | + // if they provided the current payment method, use it |
|
369 | + $payment_method_slug = sanitize_key($this->_req_data['payment_method']); |
|
370 | + } |
|
371 | + /** @var EE_Payment_Method $payment_method */ |
|
372 | + $payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug))); |
|
373 | + // if that didn't work or wasn't provided, find another way to select the current pm |
|
374 | + if (! $this->_verify_payment_method($payment_method)) { |
|
375 | + // like, looking for an active one |
|
376 | + $payment_method = EEM_Payment_Method::instance()->get_one_active('CART'); |
|
377 | + // test that one as well |
|
378 | + if ($this->_verify_payment_method($payment_method)) { |
|
379 | + $payment_method_slug = $payment_method->slug(); |
|
380 | + } else { |
|
381 | + $payment_method_slug = 'paypal_standard'; |
|
382 | + } |
|
383 | + } |
|
384 | + return $payment_method_slug; |
|
385 | + } |
|
386 | + |
|
387 | + |
|
388 | + /** |
|
389 | + * payment_method_settings_meta_box |
|
390 | + * returns TRUE if the passed payment method is properly constructed and the logged-in user has the correct |
|
391 | + * capabilities to access it |
|
392 | + * |
|
393 | + * @param EE_Payment_Method $payment_method |
|
394 | + * @return boolean |
|
395 | + * @throws EE_Error |
|
396 | + */ |
|
397 | + protected function _verify_payment_method($payment_method) |
|
398 | + { |
|
399 | + if ( |
|
400 | + $payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base |
|
401 | + && EE_Registry::instance()->CAP->current_user_can( |
|
402 | + $payment_method->type_obj()->cap_name(), |
|
403 | + 'specific_payment_method_type_access' |
|
404 | + ) |
|
405 | + ) { |
|
406 | + return true; |
|
407 | + } |
|
408 | + return false; |
|
409 | + } |
|
410 | + |
|
411 | + |
|
412 | + /** |
|
413 | + * payment_method_settings_meta_box |
|
414 | + * |
|
415 | + * @param NULL $post_obj_which_is_null is an object containing the current post (as a $post object) |
|
416 | + * @param array $metabox is an array with metabox id, title, callback, and args elements. the value |
|
417 | + * at 'args' has key 'payment_method', as set within _payment_methods_list |
|
418 | + * @return void |
|
419 | + * @throws EE_Error |
|
420 | + * @throws ReflectionException |
|
421 | + */ |
|
422 | + public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox) |
|
423 | + { |
|
424 | + $payment_method = isset($metabox['args'], $metabox['args']['payment_method']) |
|
425 | + ? $metabox['args']['payment_method'] : null; |
|
426 | + if (! $payment_method instanceof EE_Payment_Method) { |
|
427 | + throw new EE_Error( |
|
428 | + esc_html__( |
|
429 | + 'Payment method metabox setup incorrectly. No Payment method object was supplied', |
|
430 | + 'event_espresso' |
|
431 | + ) |
|
432 | + ); |
|
433 | + } |
|
434 | + $payment_method_scopes = $payment_method->active(); |
|
435 | + // if the payment method really exists show its form, otherwise the activation template |
|
436 | + if ($payment_method->ID() && ! empty($payment_method_scopes)) { |
|
437 | + $form = $this->_generate_payment_method_settings_form($payment_method); |
|
438 | + if ($form->form_data_present_in($this->_req_data)) { |
|
439 | + $form->receive_form_submission($this->_req_data); |
|
440 | + } |
|
441 | + echo $form->form_open() . $form->get_html_and_js() . $form->form_close(); // already escaped |
|
442 | + } else { |
|
443 | + echo $this->_activate_payment_method_button($payment_method)->get_html_and_js(); // already escaped |
|
444 | + } |
|
445 | + } |
|
446 | + |
|
447 | + |
|
448 | + /** |
|
449 | + * Gets the form for all the settings related to this payment method type |
|
450 | + * |
|
451 | + * @access protected |
|
452 | + * @param EE_Payment_Method $payment_method |
|
453 | + * @return EE_Form_Section_Proper |
|
454 | + * @throws EE_Error |
|
455 | + */ |
|
456 | + protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method = null) |
|
457 | + { |
|
458 | + if (! $payment_method instanceof EE_Payment_Method) { |
|
459 | + return new EE_Form_Section_Proper(); |
|
460 | + } |
|
461 | + return new EE_Form_Section_Proper( |
|
462 | + array( |
|
463 | + 'name' => $payment_method->slug() . '_settings_form', |
|
464 | + 'html_id' => $payment_method->slug() . '_settings_form', |
|
465 | + 'action' => EE_Admin_Page::add_query_args_and_nonce( |
|
466 | + array( |
|
467 | + 'action' => 'update_payment_method', |
|
468 | + 'payment_method' => $payment_method->slug(), |
|
469 | + ), |
|
470 | + EE_PAYMENTS_ADMIN_URL |
|
471 | + ), |
|
472 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
473 | + 'subsections' => apply_filters( |
|
474 | + 'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections', |
|
475 | + array( |
|
476 | + 'pci_dss_compliance' => $this->_pci_dss_compliance($payment_method), |
|
477 | + 'currency_support' => $this->_currency_support($payment_method), |
|
478 | + 'payment_method_settings' => $this->_payment_method_settings($payment_method), |
|
479 | + 'update' => $this->_update_payment_method_button($payment_method), |
|
480 | + 'deactivate' => $this->_deactivate_payment_method_button($payment_method), |
|
481 | + 'fine_print' => $this->_fine_print(), |
|
482 | + ), |
|
483 | + $payment_method |
|
484 | + ), |
|
485 | + ) |
|
486 | + ); |
|
487 | + } |
|
488 | + |
|
489 | + |
|
490 | + /** |
|
491 | + * _pci_dss_compliance |
|
492 | + * |
|
493 | + * @access protected |
|
494 | + * @param EE_Payment_Method $payment_method |
|
495 | + * @return EE_Form_Section_HTML |
|
496 | + * @throws EE_Error |
|
497 | + */ |
|
498 | + protected function _pci_dss_compliance(EE_Payment_Method $payment_method) |
|
499 | + { |
|
500 | + if ($payment_method->type_obj()->requires_https()) { |
|
501 | + return new EE_Form_Section_HTML( |
|
502 | + EEH_HTML::table( |
|
503 | + EEH_HTML::tr( |
|
504 | + EEH_HTML::th( |
|
505 | + EEH_HTML::label( |
|
506 | + EEH_HTML::strong( |
|
507 | + esc_html__('IMPORTANT', 'event_espresso'), |
|
508 | + '', |
|
509 | + 'important-notice' |
|
510 | + ) |
|
511 | + ) |
|
512 | + ) . |
|
513 | + EEH_HTML::td( |
|
514 | + EEH_HTML::strong( |
|
515 | + esc_html__( |
|
516 | + 'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', |
|
517 | + 'event_espresso' |
|
518 | + ) |
|
519 | + ) |
|
520 | + . |
|
521 | + EEH_HTML::br() |
|
522 | + . |
|
523 | + esc_html__('Learn more about ', 'event_espresso') |
|
524 | + . EEH_HTML::link( |
|
525 | + 'https://www.pcisecuritystandards.org/merchants/index.php', |
|
526 | + esc_html__('PCI DSS compliance', 'event_espresso') |
|
527 | + ) |
|
528 | + ) |
|
529 | + ) |
|
530 | + ) |
|
531 | + ); |
|
532 | + } |
|
533 | + return new EE_Form_Section_HTML(''); |
|
534 | + } |
|
535 | + |
|
536 | + |
|
537 | + /** |
|
538 | + * _currency_support |
|
539 | + * |
|
540 | + * @access protected |
|
541 | + * @param EE_Payment_Method $payment_method |
|
542 | + * @return EE_Form_Section_HTML |
|
543 | + * @throws EE_Error |
|
544 | + */ |
|
545 | + protected function _currency_support(EE_Payment_Method $payment_method) |
|
546 | + { |
|
547 | + if (! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) { |
|
548 | + return new EE_Form_Section_HTML( |
|
549 | + EEH_HTML::table( |
|
550 | + EEH_HTML::tr( |
|
551 | + EEH_HTML::th( |
|
552 | + EEH_HTML::label( |
|
553 | + EEH_HTML::strong( |
|
554 | + esc_html__('IMPORTANT', 'event_espresso'), |
|
555 | + '', |
|
556 | + 'important-notice' |
|
557 | + ) |
|
558 | + ) |
|
559 | + ) . |
|
560 | + EEH_HTML::td( |
|
561 | + EEH_HTML::strong( |
|
562 | + sprintf( |
|
563 | + esc_html__( |
|
564 | + 'This payment method does not support the currency set on your site (%1$s). Please activate a different payment method or change your site\'s country and associated currency.', |
|
565 | + 'event_espresso' |
|
566 | + ), |
|
567 | + EE_Config::instance()->currency->code |
|
568 | + ) |
|
569 | + ) |
|
570 | + ) |
|
571 | + ) |
|
572 | + ) |
|
573 | + ); |
|
574 | + } |
|
575 | + return new EE_Form_Section_HTML(''); |
|
576 | + } |
|
577 | + |
|
578 | + |
|
579 | + /** |
|
580 | + * _update_payment_method_button |
|
581 | + * |
|
582 | + * @access protected |
|
583 | + * @param EE_Payment_Method $payment_method |
|
584 | + * @return EE_Payment_Method_Form |
|
585 | + * @throws EE_Error |
|
586 | + */ |
|
587 | + protected function _payment_method_settings(EE_Payment_Method $payment_method) |
|
588 | + { |
|
589 | + // modify the form, so we only have/show fields that will be implemented for this version |
|
590 | + return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name()); |
|
591 | + } |
|
592 | + |
|
593 | + |
|
594 | + /** |
|
595 | + * Simplifies the form to merely reproduce 4.1's gateway settings functionality |
|
596 | + * |
|
597 | + * @param EE_Form_Section_Proper $form_section |
|
598 | + * @param string $payment_method_name |
|
599 | + * @return EE_Payment_Method_Form |
|
600 | + * @throws EE_Error |
|
601 | + */ |
|
602 | + protected function _simplify_form($form_section, $payment_method_name = '') |
|
603 | + { |
|
604 | + if ($form_section instanceof EE_Payment_Method_Form) { |
|
605 | + $form_section->exclude( |
|
606 | + array( |
|
607 | + 'PMD_type', // don't want them changing the type |
|
608 | + 'PMD_slug', // or the slug (probably never) |
|
609 | + 'PMD_wp_user', // or the user's ID |
|
610 | + 'Currency' // or the currency, until the rest of EE supports simultaneous currencies |
|
611 | + ) |
|
612 | + ); |
|
613 | + return $form_section; |
|
614 | + } else { |
|
615 | + throw new EE_Error( |
|
616 | + sprintf( |
|
617 | + esc_html__( |
|
618 | + 'The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', |
|
619 | + 'event_espresso' |
|
620 | + ), |
|
621 | + $payment_method_name |
|
622 | + ) |
|
623 | + ); |
|
624 | + } |
|
625 | + } |
|
626 | + |
|
627 | + |
|
628 | + /** |
|
629 | + * _update_payment_method_button |
|
630 | + * |
|
631 | + * @access protected |
|
632 | + * @param EE_Payment_Method $payment_method |
|
633 | + * @return EE_Form_Section_HTML |
|
634 | + * @throws EE_Error |
|
635 | + */ |
|
636 | + protected function _update_payment_method_button(EE_Payment_Method $payment_method) |
|
637 | + { |
|
638 | + $update_button = new EE_Submit_Input( |
|
639 | + array( |
|
640 | + 'name' => 'submit', |
|
641 | + 'html_id' => 'save_' . $payment_method->slug() . '_settings', |
|
642 | + 'default' => sprintf( |
|
643 | + esc_html__('Update %s Payment Settings', 'event_espresso'), |
|
644 | + $payment_method->admin_name() |
|
645 | + ), |
|
646 | + 'html_label' => EEH_HTML::nbsp(), |
|
647 | + ) |
|
648 | + ); |
|
649 | + return new EE_Form_Section_HTML( |
|
650 | + EEH_HTML::table( |
|
651 | + EEH_HTML::no_row(EEH_HTML::br(2)) . |
|
652 | + EEH_HTML::tr( |
|
653 | + EEH_HTML::th(esc_html__('Update Settings', 'event_espresso')) . |
|
654 | + EEH_HTML::td( |
|
655 | + $update_button->get_html_for_input() |
|
656 | + ) |
|
657 | + ) |
|
658 | + ) |
|
659 | + ); |
|
660 | + } |
|
661 | + |
|
662 | + |
|
663 | + /** |
|
664 | + * _deactivate_payment_method_button |
|
665 | + * |
|
666 | + * @access protected |
|
667 | + * @param EE_Payment_Method $payment_method |
|
668 | + * @return EE_Form_Section_HTML |
|
669 | + */ |
|
670 | + protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method) |
|
671 | + { |
|
672 | + $link_text_and_title = sprintf( |
|
673 | + esc_html__('Deactivate %1$s Payments?', 'event_espresso'), |
|
674 | + $payment_method->admin_name() |
|
675 | + ); |
|
676 | + return new EE_Form_Section_HTML( |
|
677 | + EEH_HTML::table( |
|
678 | + EEH_HTML::tr( |
|
679 | + EEH_HTML::th(esc_html__('Deactivate Payment Method', 'event_espresso')) . |
|
680 | + EEH_HTML::td( |
|
681 | + EEH_HTML::link( |
|
682 | + EE_Admin_Page::add_query_args_and_nonce( |
|
683 | + array( |
|
684 | + 'action' => 'deactivate_payment_method', |
|
685 | + 'payment_method' => $payment_method->slug(), |
|
686 | + ), |
|
687 | + EE_PAYMENTS_ADMIN_URL |
|
688 | + ), |
|
689 | + $link_text_and_title, |
|
690 | + $link_text_and_title, |
|
691 | + 'deactivate_' . $payment_method->slug(), |
|
692 | + 'espresso-button button-secondary' |
|
693 | + ) |
|
694 | + ) |
|
695 | + ) |
|
696 | + ) |
|
697 | + ); |
|
698 | + } |
|
699 | + |
|
700 | + |
|
701 | + /** |
|
702 | + * _activate_payment_method_button |
|
703 | + * |
|
704 | + * @access protected |
|
705 | + * @param EE_Payment_Method $payment_method |
|
706 | + * @return EE_Form_Section_Proper |
|
707 | + * @throws EE_Error |
|
708 | + */ |
|
709 | + protected function _activate_payment_method_button(EE_Payment_Method $payment_method) |
|
710 | + { |
|
711 | + $link_text_and_title = sprintf( |
|
712 | + esc_html__('Activate %1$s Payment Method?', 'event_espresso'), |
|
713 | + $payment_method->admin_name() |
|
714 | + ); |
|
715 | + return new EE_Form_Section_Proper( |
|
716 | + array( |
|
717 | + 'name' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
718 | + 'html_id' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
719 | + 'action' => '#', |
|
720 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
721 | + 'subsections' => apply_filters( |
|
722 | + 'FHEE__Payments_Admin_Page___activate_payment_method_button__form_subsections', |
|
723 | + array( |
|
724 | + new EE_Form_Section_HTML( |
|
725 | + EEH_HTML::table( |
|
726 | + EEH_HTML::tr( |
|
727 | + EEH_HTML::td( |
|
728 | + $payment_method->type_obj()->introductory_html(), |
|
729 | + '', |
|
730 | + '', |
|
731 | + '', |
|
732 | + 'colspan="2"' |
|
733 | + ) |
|
734 | + ) . |
|
735 | + EEH_HTML::tr( |
|
736 | + EEH_HTML::th( |
|
737 | + EEH_HTML::label(esc_html__('Click to Activate ', 'event_espresso')) |
|
738 | + ) . |
|
739 | + EEH_HTML::td( |
|
740 | + EEH_HTML::link( |
|
741 | + EE_Admin_Page::add_query_args_and_nonce( |
|
742 | + array( |
|
743 | + 'action' => 'activate_payment_method', |
|
744 | + 'payment_method_type' => $payment_method->type(), |
|
745 | + ), |
|
746 | + EE_PAYMENTS_ADMIN_URL |
|
747 | + ), |
|
748 | + $link_text_and_title, |
|
749 | + $link_text_and_title, |
|
750 | + 'activate_' . $payment_method->slug(), |
|
751 | + 'espresso-button-green button-primary' |
|
752 | + ) |
|
753 | + ) |
|
754 | + ) |
|
755 | + ) |
|
756 | + ), |
|
757 | + ), |
|
758 | + $payment_method |
|
759 | + ), |
|
760 | + ) |
|
761 | + ); |
|
762 | + } |
|
763 | + |
|
764 | + |
|
765 | + /** |
|
766 | + * _fine_print |
|
767 | + * |
|
768 | + * @access protected |
|
769 | + * @return EE_Form_Section_HTML |
|
770 | + */ |
|
771 | + protected function _fine_print() |
|
772 | + { |
|
773 | + return new EE_Form_Section_HTML( |
|
774 | + EEH_HTML::table( |
|
775 | + EEH_HTML::tr( |
|
776 | + EEH_HTML::th() . |
|
777 | + EEH_HTML::td( |
|
778 | + EEH_HTML::p(esc_html__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text') |
|
779 | + ) |
|
780 | + ) |
|
781 | + ) |
|
782 | + ); |
|
783 | + } |
|
784 | + |
|
785 | + |
|
786 | + /** |
|
787 | + * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far) |
|
788 | + * |
|
789 | + * @throws EE_Error |
|
790 | + * @throws ReflectionException |
|
791 | + * @global WP_User $current_user |
|
792 | + */ |
|
793 | + protected function _activate_payment_method() |
|
794 | + { |
|
795 | + if (isset($this->_req_data['payment_method_type'])) { |
|
796 | + $payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']); |
|
797 | + // see if one exists |
|
798 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
799 | + $payment_method = EE_Payment_Method_Manager::instance() |
|
800 | + ->activate_a_payment_method_of_type($payment_method_type); |
|
801 | + $this->_redirect_after_action( |
|
802 | + 1, |
|
803 | + 'Payment Method', |
|
804 | + 'activated', |
|
805 | + array('action' => 'default', 'payment_method' => $payment_method->slug()) |
|
806 | + ); |
|
807 | + } else { |
|
808 | + $this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default')); |
|
809 | + } |
|
810 | + } |
|
811 | + |
|
812 | + |
|
813 | + /** |
|
814 | + * @throws EE_Error |
|
815 | + * @throws ReflectionException |
|
816 | + */ |
|
817 | + protected function _deactivate_payment_method() |
|
818 | + { |
|
819 | + if (isset($this->_req_data['payment_method'])) { |
|
820 | + $payment_method_slug = sanitize_key($this->_req_data['payment_method']); |
|
821 | + // deactivate it |
|
822 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
823 | + $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug); |
|
824 | + $this->_redirect_after_action( |
|
825 | + $count_updated, |
|
826 | + 'Payment Method', |
|
827 | + 'deactivated', |
|
828 | + array('action' => 'default', 'payment_method' => $payment_method_slug) |
|
829 | + ); |
|
830 | + } else { |
|
831 | + $this->_redirect_after_action(false, 'Payment Method', 'deactivated', array('action' => 'default')); |
|
832 | + } |
|
833 | + } |
|
834 | + |
|
835 | + |
|
836 | + /** |
|
837 | + * Processes the payment method form that was submitted. This is slightly trickier than usual form |
|
838 | + * processing because we first need to identify WHICH form was processed and which payment method |
|
839 | + * it corresponds to. Once we have done that, we see if the form is valid. If it is, the |
|
840 | + * form's data is saved, and we redirect to the default payment methods page, setting the updated payment method |
|
841 | + * as the currently-selected one. If it DOESN'T validate, we render the page with the form's errors (in the |
|
842 | + * subsequently called 'headers_sent_func' which is _payment_methods_list) |
|
843 | + * |
|
844 | + * @return void |
|
845 | + * @throws EE_Error |
|
846 | + * @throws ReflectionException |
|
847 | + */ |
|
848 | + protected function _update_payment_method() |
|
849 | + { |
|
850 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
851 | + // ok let's find which gateway form to use based on the form input |
|
852 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
853 | + /** @var $correct_pmt_form_to_use EE_Payment_Method_Form */ |
|
854 | + $correct_pmt_form_to_use = null; |
|
855 | + $payment_method = null; |
|
856 | + foreach (EEM_Payment_Method::instance()->get_all() as $payment_method) { |
|
857 | + if ($payment_method instanceof EE_Payment_Method) { |
|
858 | + // get the form and simplify it, like what we do when we display it |
|
859 | + $pmt_form = $this->_generate_payment_method_settings_form($payment_method); |
|
860 | + if ($pmt_form->form_data_present_in($this->_req_data)) { |
|
861 | + $correct_pmt_form_to_use = $pmt_form; |
|
862 | + break; |
|
863 | + } |
|
864 | + } |
|
865 | + } |
|
866 | + // if we couldn't find the correct payment method type... |
|
867 | + if (! $correct_pmt_form_to_use) { |
|
868 | + EE_Error::add_error( |
|
869 | + esc_html__( |
|
870 | + "We could not find which payment method type your form submission related to. Please contact support", |
|
871 | + 'event_espresso' |
|
872 | + ), |
|
873 | + __FILE__, |
|
874 | + __FUNCTION__, |
|
875 | + __LINE__ |
|
876 | + ); |
|
877 | + $this->_redirect_after_action(false, 'Payment Method', 'activated', array('action' => 'default')); |
|
878 | + } |
|
879 | + $correct_pmt_form_to_use->receive_form_submission($this->_req_data); |
|
880 | + if ($correct_pmt_form_to_use->is_valid()) { |
|
881 | + $payment_settings_subform = $correct_pmt_form_to_use->get_subsection('payment_method_settings'); |
|
882 | + if (! $payment_settings_subform instanceof EE_Payment_Method_Form) { |
|
883 | + throw new EE_Error( |
|
884 | + sprintf( |
|
885 | + esc_html__( |
|
886 | + 'The payment method could not be saved because the form sections were misnamed. We expected to find %1$s, but did not.', |
|
887 | + 'event_espresso' |
|
888 | + ), |
|
889 | + 'payment_method_settings' |
|
890 | + ) |
|
891 | + ); |
|
892 | + } |
|
893 | + $payment_settings_subform->save(); |
|
894 | + /** @var $pm EE_Payment_Method */ |
|
895 | + $this->_redirect_after_action( |
|
896 | + true, |
|
897 | + 'Payment Method', |
|
898 | + 'updated', |
|
899 | + array('action' => 'default', 'payment_method' => $payment_method->slug()) |
|
900 | + ); |
|
901 | + } else { |
|
902 | + EE_Error::add_error( |
|
903 | + sprintf( |
|
904 | + esc_html__( |
|
905 | + 'Payment method of type %s was not saved because there were validation errors. They have been marked in the form', |
|
906 | + 'event_espresso' |
|
907 | + ), |
|
908 | + $payment_method instanceof EE_Payment_Method ? $payment_method->type_obj()->pretty_name() |
|
909 | + : esc_html__('"(unknown)"', 'event_espresso') |
|
910 | + ), |
|
911 | + __FILE__, |
|
912 | + __FUNCTION__, |
|
913 | + __LINE__ |
|
914 | + ); |
|
915 | + } |
|
916 | + } |
|
917 | + } |
|
918 | + |
|
919 | + |
|
920 | + /** |
|
921 | + * Displays payment settings (not payment METHOD settings, that's _payment_method_settings) |
|
922 | + * @throws DomainException |
|
923 | + * @throws EE_Error |
|
924 | + * @throws InvalidArgumentException |
|
925 | + * @throws InvalidDataTypeException |
|
926 | + * @throws InvalidInterfaceException |
|
927 | + */ |
|
928 | + protected function _payment_settings() |
|
929 | + { |
|
930 | + $form = $this->getPaymentSettingsForm(); |
|
931 | + $this->_set_add_edit_form_tags('update_payment_settings'); |
|
932 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
933 | + $this->_template_args['admin_page_content'] = $form->get_html_and_js(); |
|
934 | + $this->display_admin_page_with_sidebar(); |
|
935 | + } |
|
936 | + |
|
937 | + |
|
938 | + /** |
|
939 | + * _update_payment_settings |
|
940 | + * |
|
941 | + * @access protected |
|
942 | + * @return void |
|
943 | + * @throws EE_Error |
|
944 | + * @throws InvalidArgumentException |
|
945 | + * @throws InvalidDataTypeException |
|
946 | + * @throws InvalidInterfaceException |
|
947 | + */ |
|
948 | + protected function _update_payment_settings() |
|
949 | + { |
|
950 | + $form = $this->getPaymentSettingsForm(); |
|
951 | + if ($form->was_submitted($this->_req_data)) { |
|
952 | + $form->receive_form_submission($this->_req_data); |
|
953 | + if ($form->is_valid()) { |
|
954 | + /** |
|
955 | + * @var $reg_config EE_Registration_Config |
|
956 | + */ |
|
957 | + $loader = LoaderFactory::getLoader(); |
|
958 | + $reg_config = $loader->getShared('EE_Registration_Config'); |
|
959 | + $valid_data = $form->valid_data(); |
|
960 | + $reg_config->show_pending_payment_options = $valid_data['show_pending_payment_options']; |
|
961 | + $reg_config->gateway_log_lifespan = $valid_data['gateway_log_lifespan']; |
|
962 | + } |
|
963 | + } |
|
964 | + EE_Registry::instance()->CFG = apply_filters( |
|
965 | + 'FHEE__Payments_Admin_Page___update_payment_settings__CFG', |
|
966 | + EE_Registry::instance()->CFG |
|
967 | + ); |
|
968 | + |
|
969 | + $what = esc_html__('Payment Settings', 'event_espresso'); |
|
970 | + $success = $this->_update_espresso_configuration( |
|
971 | + $what, |
|
972 | + EE_Registry::instance()->CFG, |
|
973 | + __FILE__, |
|
974 | + __FUNCTION__, |
|
975 | + __LINE__ |
|
976 | + ); |
|
977 | + $this->_redirect_after_action( |
|
978 | + $success, |
|
979 | + $what, |
|
980 | + esc_html__('updated', 'event_espresso'), |
|
981 | + array('action' => 'payment_settings') |
|
982 | + ); |
|
983 | + } |
|
984 | + |
|
985 | + |
|
986 | + /** |
|
987 | + * Gets the form used for updating payment settings |
|
988 | + * |
|
989 | + * @return EE_Form_Section_Proper |
|
990 | + * @throws EE_Error |
|
991 | + * @throws InvalidArgumentException |
|
992 | + * @throws InvalidDataTypeException |
|
993 | + * @throws InvalidInterfaceException |
|
994 | + */ |
|
995 | + protected function getPaymentSettingsForm() |
|
996 | + { |
|
997 | + /** |
|
998 | + * @var $reg_config EE_Registration_Config |
|
999 | + */ |
|
1000 | + $reg_config = LoaderFactory::getLoader()->getShared('EE_Registration_Config'); |
|
1001 | + return new EE_Form_Section_Proper( |
|
1002 | + array( |
|
1003 | + 'name' => 'payment-settings', |
|
1004 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
1005 | + 'subsections' => array( |
|
1006 | + 'show_pending_payment_options' => new EE_Yes_No_Input( |
|
1007 | + array( |
|
1008 | + 'html_name' => 'show_pending_payment_options', |
|
1009 | + 'default' => $reg_config->show_pending_payment_options, |
|
1010 | + 'html_help_text' => esc_html__( |
|
1011 | + "If a payment is marked as 'Pending Payment', or if payment is deferred (ie, an offline gateway like Check, Bank, or Invoice is used), then give registrants the option to retry payment. ", |
|
1012 | + 'event_espresso' |
|
1013 | + ) |
|
1014 | + ) |
|
1015 | + ), |
|
1016 | + 'gateway_log_lifespan' => new EE_Select_Input( |
|
1017 | + $reg_config->gatewayLogLifespanOptions(), |
|
1018 | + array( |
|
1019 | + 'html_label_text' => esc_html__('Gateway Logs Lifespan', 'event_espresso'), |
|
1020 | + 'html_help_text' => esc_html__('If issues arise with payments being made through a payment gateway, it\'s helpful to log non-sensitive communications with the payment gateway. But it\'s a security responsibility, so it\'s a good idea to not keep them for any longer than necessary.', 'event_espresso'), |
|
1021 | + 'default' => $reg_config->gateway_log_lifespan, |
|
1022 | + ) |
|
1023 | + ) |
|
1024 | + ) |
|
1025 | + ) |
|
1026 | + ); |
|
1027 | + } |
|
1028 | + |
|
1029 | + |
|
1030 | + /** |
|
1031 | + * @throws EE_Error |
|
1032 | + */ |
|
1033 | + protected function _payment_log_overview_list_table() |
|
1034 | + { |
|
1035 | + $this->display_admin_list_table_page_with_sidebar(); |
|
1036 | + } |
|
1037 | + |
|
1038 | + |
|
1039 | + protected function _set_list_table_views_payment_log() |
|
1040 | + { |
|
1041 | + $this->_views = array( |
|
1042 | + 'all' => array( |
|
1043 | + 'slug' => 'all', |
|
1044 | + 'label' => esc_html__('View All Logs', 'event_espresso'), |
|
1045 | + 'count' => 0, |
|
1046 | + ), |
|
1047 | + ); |
|
1048 | + } |
|
1049 | + |
|
1050 | + |
|
1051 | + /** |
|
1052 | + * @param int $per_page |
|
1053 | + * @param int $current_page |
|
1054 | + * @param bool $count |
|
1055 | + * @return array|int |
|
1056 | + * @throws EE_Error |
|
1057 | + * @throws ReflectionException |
|
1058 | + */ |
|
1059 | + public function get_payment_logs($per_page = 50, $current_page = 0, $count = false) |
|
1060 | + { |
|
1061 | + EE_Registry::instance()->load_model('Change_Log'); |
|
1062 | + // we may need to do multiple queries (joining differently), so we actually want an array of query params |
|
1063 | + $query_params = array(array('LOG_type' => EEM_Change_Log::type_gateway)); |
|
1064 | + // check if they've selected a specific payment method |
|
1065 | + if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') { |
|
1066 | + $query_params[0]['OR*pm_or_pay_pm'] = array( |
|
1067 | + 'Payment.Payment_Method.PMD_ID' => $this->_req_data['_payment_method'], |
|
1068 | + 'Payment_Method.PMD_ID' => $this->_req_data['_payment_method'], |
|
1069 | + ); |
|
1070 | + } |
|
1071 | + // take into account search |
|
1072 | + if (isset($this->_req_data['s']) && $this->_req_data['s']) { |
|
1073 | + $similarity_string = array('LIKE', '%' . str_replace("", "%", $this->_req_data['s']) . '%'); |
|
1074 | + $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string; |
|
1075 | + $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string; |
|
1076 | + $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string; |
|
1077 | + $query_params[0]['OR*s']['Payment.Payment_Method.PMD_name'] = $similarity_string; |
|
1078 | + $query_params[0]['OR*s']['Payment.Payment_Method.PMD_admin_name'] = $similarity_string; |
|
1079 | + $query_params[0]['OR*s']['Payment.Payment_Method.PMD_type'] = $similarity_string; |
|
1080 | + $query_params[0]['OR*s']['LOG_message'] = $similarity_string; |
|
1081 | + $query_params[0]['OR*s']['Payment_Method.PMD_name'] = $similarity_string; |
|
1082 | + $query_params[0]['OR*s']['Payment_Method.PMD_admin_name'] = $similarity_string; |
|
1083 | + $query_params[0]['OR*s']['Payment_Method.PMD_type'] = $similarity_string; |
|
1084 | + $query_params[0]['OR*s']['LOG_message'] = $similarity_string; |
|
1085 | + } |
|
1086 | + if ( |
|
1087 | + isset($this->_req_data['payment-filter-start-date']) |
|
1088 | + && isset($this->_req_data['payment-filter-end-date']) |
|
1089 | + ) { |
|
1090 | + // add date |
|
1091 | + $start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']); |
|
1092 | + $end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']); |
|
1093 | + // make sure our timestamps start and end right at the boundaries for each day |
|
1094 | + $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00'; |
|
1095 | + $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59'; |
|
1096 | + // convert to timestamps |
|
1097 | + $start_date = strtotime($start_date); |
|
1098 | + $end_date = strtotime($end_date); |
|
1099 | + // makes sure start date is the lowest value and vice versa |
|
1100 | + $start_date = min($start_date, $end_date); |
|
1101 | + $end_date = max($start_date, $end_date); |
|
1102 | + // convert for query |
|
1103 | + $start_date = EEM_Change_Log::instance()->convert_datetime_for_query( |
|
1104 | + 'LOG_time', |
|
1105 | + date('Y-m-d H:i:s', $start_date), |
|
1106 | + 'Y-m-d H:i:s' |
|
1107 | + ); |
|
1108 | + $end_date = EEM_Change_Log::instance()->convert_datetime_for_query( |
|
1109 | + 'LOG_time', |
|
1110 | + date('Y-m-d H:i:s', $end_date), |
|
1111 | + 'Y-m-d H:i:s' |
|
1112 | + ); |
|
1113 | + $query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date)); |
|
1114 | + } |
|
1115 | + if ($count) { |
|
1116 | + return EEM_Change_Log::instance()->count($query_params); |
|
1117 | + } |
|
1118 | + if (isset($this->_req_data['order'])) { |
|
1119 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) |
|
1120 | + ? $this->_req_data['order'] |
|
1121 | + : 'DESC'; |
|
1122 | + $query_params['order_by'] = array('LOG_time' => $sort); |
|
1123 | + } else { |
|
1124 | + $query_params['order_by'] = array('LOG_time' => 'DESC'); |
|
1125 | + } |
|
1126 | + $offset = ($current_page - 1) * $per_page; |
|
1127 | + if (! isset($this->_req_data['download_results'])) { |
|
1128 | + $query_params['limit'] = array($offset, $per_page); |
|
1129 | + } |
|
1130 | + // now they've requested to instead just download the file instead of viewing it. |
|
1131 | + if (isset($this->_req_data['download_results'])) { |
|
1132 | + $wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params); |
|
1133 | + header('Content-Disposition: attachment'); |
|
1134 | + header("Content-Disposition: attachment; filename=ee_payment_logs_for_" . sanitize_key(site_url())); |
|
1135 | + echo '<h1> ' |
|
1136 | + . sprintf( |
|
1137 | + esc_html__('Payment Logs for %1$s', 'event_espresso'), |
|
1138 | + esc_url_raw(site_url()) |
|
1139 | + ) |
|
1140 | + . '</h1 >'; |
|
1141 | + echo '<h3>' . esc_html__('Query:', 'event_espresso') . '</h3>'; |
|
1142 | + echo esc_html(var_export($query_params, true)); |
|
1143 | + echo '<h3>' . esc_html__('Results:', 'event_espresso') . '</h3>'; |
|
1144 | + echo esc_html(var_export($wpdb_results, true)); |
|
1145 | + die; |
|
1146 | + } |
|
1147 | + return EEM_Change_Log::instance()->get_all($query_params); |
|
1148 | + } |
|
1149 | + |
|
1150 | + |
|
1151 | + /** |
|
1152 | + * Used by usort to RE-sort log query results, because we lose the ordering |
|
1153 | + * because we're possibly combining the results from two queries |
|
1154 | + * |
|
1155 | + * @param EE_Change_Log $logA |
|
1156 | + * @param EE_Change_Log $logB |
|
1157 | + * @return int |
|
1158 | + * @throws EE_Error |
|
1159 | + * @throws ReflectionException |
|
1160 | + */ |
|
1161 | + protected function _sort_logs_again($logA, $logB) |
|
1162 | + { |
|
1163 | + $timeA = $logA->get_raw('LOG_time'); |
|
1164 | + $timeB = $logB->get_raw('LOG_time'); |
|
1165 | + if ($timeA == $timeB) { |
|
1166 | + return 0; |
|
1167 | + } |
|
1168 | + $comparison = $timeA < $timeB ? -1 : 1; |
|
1169 | + if (strtoupper($this->_sort_logs_again_direction) == 'DESC') { |
|
1170 | + return $comparison * -1; |
|
1171 | + } |
|
1172 | + return $comparison; |
|
1173 | + } |
|
1174 | + |
|
1175 | + |
|
1176 | + /** |
|
1177 | + * @throws EE_Error |
|
1178 | + * @throws ReflectionException |
|
1179 | + */ |
|
1180 | + protected function _payment_log_details() |
|
1181 | + { |
|
1182 | + EE_Registry::instance()->load_model('Change_Log'); |
|
1183 | + /** @var $payment_log EE_Change_Log */ |
|
1184 | + $payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']); |
|
1185 | + $payment_method = null; |
|
1186 | + $transaction = null; |
|
1187 | + if ($payment_log instanceof EE_Change_Log) { |
|
1188 | + if ($payment_log->object() instanceof EE_Payment) { |
|
1189 | + $payment_method = $payment_log->object()->payment_method(); |
|
1190 | + $transaction = $payment_log->object()->transaction(); |
|
1191 | + } elseif ($payment_log->object() instanceof EE_Payment_Method) { |
|
1192 | + $payment_method = $payment_log->object(); |
|
1193 | + } elseif ($payment_log->object() instanceof EE_Transaction) { |
|
1194 | + $transaction = $payment_log->object(); |
|
1195 | + $payment_method = $transaction->payment_method(); |
|
1196 | + } |
|
1197 | + } |
|
1198 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
1199 | + EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php', |
|
1200 | + array( |
|
1201 | + 'payment_log' => $payment_log, |
|
1202 | + 'payment_method' => $payment_method, |
|
1203 | + 'transaction' => $transaction, |
|
1204 | + ), |
|
1205 | + true |
|
1206 | + ); |
|
1207 | + $this->display_admin_page_with_sidebar(); |
|
1208 | + } |
|
1209 | 1209 | } |
@@ -12,62 +12,62 @@ discard block |
||
12 | 12 | <strong><?php esc_html_e('Name', 'event_espresso'); ?></strong> |
13 | 13 | <br> |
14 | 14 | <?php esc_html_e( |
15 | - 'The name of the payment method as customers see it in the registration form, in emails, in receipts, etc.', |
|
16 | - 'event_espresso' |
|
17 | - ); ?> |
|
15 | + 'The name of the payment method as customers see it in the registration form, in emails, in receipts, etc.', |
|
16 | + 'event_espresso' |
|
17 | + ); ?> |
|
18 | 18 | </li> |
19 | 19 | <li> |
20 | 20 | <strong><?php esc_html_e('Description', 'event_espresso'); ?></strong> |
21 | 21 | <br /> |
22 | 22 | <?php esc_html_e( |
23 | - 'The description of how to use the payment method as customers will see it. This is mostly only seen during registration.', |
|
24 | - 'event_espresso' |
|
25 | - ); ?> |
|
23 | + 'The description of how to use the payment method as customers will see it. This is mostly only seen during registration.', |
|
24 | + 'event_espresso' |
|
25 | + ); ?> |
|
26 | 26 | </li> |
27 | 27 | <li> |
28 | 28 | <strong><?php esc_html_e('Admin-Only Name', 'event_espresso'); ?></strong> |
29 | 29 | <br /> |
30 | 30 | <?php esc_html_e( |
31 | - 'The name of the payment method as seen internally by site administrators and staff.', |
|
32 | - 'event_espresso' |
|
33 | - ); ?> |
|
31 | + 'The name of the payment method as seen internally by site administrators and staff.', |
|
32 | + 'event_espresso' |
|
33 | + ); ?> |
|
34 | 34 | </li> |
35 | 35 | <li> |
36 | 36 | <strong><?php esc_html_e('Admin-Only Description', 'event_espresso'); ?></strong> |
37 | 37 | <br /> |
38 | 38 | <?php esc_html_e( |
39 | - 'The description of the payment method as seen internally by site administrators and staff.', |
|
40 | - 'event_espresso' |
|
41 | - ); ?> |
|
39 | + 'The description of the payment method as seen internally by site administrators and staff.', |
|
40 | + 'event_espresso' |
|
41 | + ); ?> |
|
42 | 42 | </li> |
43 | 43 | <li> |
44 | 44 | <strong><?php esc_html_e('Debug (sandbox) Mode', 'event_espresso'); ?></strong> |
45 | 45 | <br /> |
46 | 46 | <?php esc_html_e( |
47 | - 'Many payment methods have a debug/sandbox mode where payments are not processed but are only simulated. This is helpful when setup and debugging.', |
|
48 | - 'event_espresso' |
|
49 | - ); ?> |
|
47 | + 'Many payment methods have a debug/sandbox mode where payments are not processed but are only simulated. This is helpful when setup and debugging.', |
|
48 | + 'event_espresso' |
|
49 | + ); ?> |
|
50 | 50 | </li> |
51 | 51 | <li> |
52 | 52 | <strong><?php esc_html_e('Open by Default', 'event_espresso'); ?></strong> |
53 | 53 | <br /> |
54 | 54 | <?php esc_html_e( |
55 | - 'If checked, this payment method will be selected by default (assuming no other valid payment methods are also marked as open by default.)', |
|
56 | - 'event_espresso' |
|
57 | - ); ?> |
|
55 | + 'If checked, this payment method will be selected by default (assuming no other valid payment methods are also marked as open by default.)', |
|
56 | + 'event_espresso' |
|
57 | + ); ?> |
|
58 | 58 | </li> |
59 | 59 | <li> |
60 | 60 | <strong><?php esc_html_e('Button URL', 'event_espresso'); ?></strong> |
61 | 61 | <br /> |
62 | 62 | <?php |
63 | - printf( |
|
64 | - esc_html__( |
|
65 | - 'The URL of the button image for this payment method in the registration process. You may use any uploaded image on your website (click %s next to the field to select). If left blank, the default button image will be used.', |
|
66 | - 'event_espresso' |
|
67 | - ), |
|
68 | - '<img src="' . admin_url('images/media-button-image.gif') . '">' |
|
69 | - ); |
|
70 | - ?> |
|
63 | + printf( |
|
64 | + esc_html__( |
|
65 | + 'The URL of the button image for this payment method in the registration process. You may use any uploaded image on your website (click %s next to the field to select). If left blank, the default button image will be used.', |
|
66 | + 'event_espresso' |
|
67 | + ), |
|
68 | + '<img src="' . admin_url('images/media-button-image.gif') . '">' |
|
69 | + ); |
|
70 | + ?> |
|
71 | 71 | </li> |
72 | 72 | <li><strong><?php esc_html_e('Usable From', 'event_espresso'); ?></strong> |
73 | 73 | <br /> |
@@ -75,15 +75,15 @@ discard block |
||
75 | 75 | <ul> |
76 | 76 | <li> |
77 | 77 | <?php esc_html_e( |
78 | - 'Front-end Registration Page: the payment method will appear as an option during the normal registration process to customers and they can use it to process payments.', |
|
79 | - 'event_espresso' |
|
80 | - ); ?> |
|
78 | + 'Front-end Registration Page: the payment method will appear as an option during the normal registration process to customers and they can use it to process payments.', |
|
79 | + 'event_espresso' |
|
80 | + ); ?> |
|
81 | 81 | </li> |
82 | 82 | <li> |
83 | 83 | <?php esc_html_e( |
84 | - 'Admin Registration Page: when recording payments made from the transaction admin page, the payment method will appear as an option. Note: currently payments can only be RECORDED from the admin, they cannot be PROCESSED.', |
|
85 | - 'event_espresso' |
|
86 | - ); ?> |
|
84 | + 'Admin Registration Page: when recording payments made from the transaction admin page, the payment method will appear as an option. Note: currently payments can only be RECORDED from the admin, they cannot be PROCESSED.', |
|
85 | + 'event_espresso' |
|
86 | + ); ?> |
|
87 | 87 | </li> |
88 | 88 | </ul> |
89 | 89 | </li> |
@@ -91,14 +91,14 @@ discard block |
||
91 | 91 | <strong><?php esc_html_e('Recommendations', 'event_espresso'); ?></strong> |
92 | 92 | <br /> |
93 | 93 | <?php esc_html_e( |
94 | - 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
95 | - 'event_espresso' |
|
94 | + 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
95 | + 'event_espresso' |
|
96 | 96 | ); ?> |
97 | 97 | <p> |
98 | 98 | <strong><?php esc_html_e('Screen Options', 'event_espresso'); ?></strong> |
99 | 99 | <br /> |
100 | 100 | <?php esc_html_e( |
101 | - 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
102 | - 'event_espresso' |
|
103 | - ); ?> |
|
101 | + 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
102 | + 'event_espresso' |
|
103 | + ); ?> |
|
104 | 104 | </p> |
105 | 105 | \ No newline at end of file |
@@ -9,21 +9,21 @@ |
||
9 | 9 | </p> |
10 | 10 | <p> |
11 | 11 | <?php esc_html_e( |
12 | - 'Specify if registrants should be allowed to attempt additional payments if the original payment is delayed.', |
|
13 | - 'event_espresso' |
|
14 | - ); ?> |
|
12 | + 'Specify if registrants should be allowed to attempt additional payments if the original payment is delayed.', |
|
13 | + 'event_espresso' |
|
14 | + ); ?> |
|
15 | 15 | </p> |
16 | 16 | <p> |
17 | 17 | <strong><?php esc_html_e('Recommendations', 'event_espresso'); ?></strong><br /> |
18 | 18 | <?php esc_html_e( |
19 | - 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
20 | - 'event_espresso' |
|
21 | - ); ?> |
|
19 | + 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
20 | + 'event_espresso' |
|
21 | + ); ?> |
|
22 | 22 | </p> |
23 | 23 | <p> |
24 | 24 | <strong><?php esc_html_e('Screen Options', 'event_espresso'); ?></strong><br /> |
25 | 25 | <?php esc_html_e( |
26 | - 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
27 | - 'event_espresso' |
|
28 | - ); ?> |
|
26 | + 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
27 | + 'event_espresso' |
|
28 | + ); ?> |
|
29 | 29 | </p> |
30 | 30 | \ No newline at end of file |