@@ -15,1800 +15,1800 @@ |
||
15 | 15 | class EED_Single_Page_Checkout extends EED_Module |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * $_initialized - has the SPCO controller already been initialized ? |
|
20 | - * |
|
21 | - * @access private |
|
22 | - * @var bool $_initialized |
|
23 | - */ |
|
24 | - private static $_initialized = false; |
|
25 | - |
|
26 | - |
|
27 | - /** |
|
28 | - * $_checkout_verified - is the EE_Checkout verified as correct for this request ? |
|
29 | - * |
|
30 | - * @access private |
|
31 | - * @var bool $_valid_checkout |
|
32 | - */ |
|
33 | - private static $_checkout_verified = true; |
|
34 | - |
|
35 | - /** |
|
36 | - * $_reg_steps_array - holds initial array of reg steps |
|
37 | - * |
|
38 | - * @access private |
|
39 | - * @var array $_reg_steps_array |
|
40 | - */ |
|
41 | - private static $_reg_steps_array = array(); |
|
42 | - |
|
43 | - /** |
|
44 | - * $checkout - EE_Checkout object for handling the properties of the current checkout process |
|
45 | - * |
|
46 | - * @access public |
|
47 | - * @var EE_Checkout $checkout |
|
48 | - */ |
|
49 | - public $checkout; |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * @return EED_Module|EED_Single_Page_Checkout |
|
54 | - */ |
|
55 | - public static function instance() |
|
56 | - { |
|
57 | - add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true'); |
|
58 | - return parent::get_instance(__CLASS__); |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * @return EE_CART |
|
64 | - */ |
|
65 | - public function cart() |
|
66 | - { |
|
67 | - return $this->checkout->cart; |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * @return EE_Transaction |
|
73 | - */ |
|
74 | - public function transaction() |
|
75 | - { |
|
76 | - return $this->checkout->transaction; |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
82 | - * |
|
83 | - * @access public |
|
84 | - * @return void |
|
85 | - * @throws EE_Error |
|
86 | - */ |
|
87 | - public static function set_hooks() |
|
88 | - { |
|
89 | - EED_Single_Page_Checkout::set_definitions(); |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
95 | - * |
|
96 | - * @access public |
|
97 | - * @return void |
|
98 | - * @throws EE_Error |
|
99 | - */ |
|
100 | - public static function set_hooks_admin() |
|
101 | - { |
|
102 | - EED_Single_Page_Checkout::set_definitions(); |
|
103 | - if (! (defined('DOING_AJAX') && DOING_AJAX)) { |
|
104 | - return; |
|
105 | - } |
|
106 | - // going to start an output buffer in case anything gets accidentally output |
|
107 | - // that might disrupt our JSON response |
|
108 | - ob_start(); |
|
109 | - EED_Single_Page_Checkout::load_request_handler(); |
|
110 | - EED_Single_Page_Checkout::load_reg_steps(); |
|
111 | - // set ajax hooks |
|
112 | - add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
113 | - add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
114 | - add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
115 | - add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
116 | - add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
117 | - add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - /** |
|
122 | - * process ajax request |
|
123 | - * |
|
124 | - * @param string $ajax_action |
|
125 | - * @throws EE_Error |
|
126 | - */ |
|
127 | - public static function process_ajax_request($ajax_action) |
|
128 | - { |
|
129 | - EE_Registry::instance()->REQ->set('action', $ajax_action); |
|
130 | - EED_Single_Page_Checkout::instance()->_initialize(); |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * ajax display registration step |
|
136 | - * |
|
137 | - * @throws EE_Error |
|
138 | - */ |
|
139 | - public static function display_reg_step() |
|
140 | - { |
|
141 | - EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step'); |
|
142 | - } |
|
143 | - |
|
144 | - |
|
145 | - /** |
|
146 | - * ajax process registration step |
|
147 | - * |
|
148 | - * @throws EE_Error |
|
149 | - */ |
|
150 | - public static function process_reg_step() |
|
151 | - { |
|
152 | - EED_Single_Page_Checkout::process_ajax_request('process_reg_step'); |
|
153 | - } |
|
154 | - |
|
155 | - |
|
156 | - /** |
|
157 | - * ajax process registration step |
|
158 | - * |
|
159 | - * @throws EE_Error |
|
160 | - */ |
|
161 | - public static function update_reg_step() |
|
162 | - { |
|
163 | - EED_Single_Page_Checkout::process_ajax_request('update_reg_step'); |
|
164 | - } |
|
165 | - |
|
166 | - |
|
167 | - /** |
|
168 | - * update_checkout |
|
169 | - * |
|
170 | - * @access public |
|
171 | - * @return void |
|
172 | - * @throws EE_Error |
|
173 | - */ |
|
174 | - public static function update_checkout() |
|
175 | - { |
|
176 | - EED_Single_Page_Checkout::process_ajax_request('update_checkout'); |
|
177 | - } |
|
178 | - |
|
179 | - |
|
180 | - /** |
|
181 | - * load_request_handler |
|
182 | - * |
|
183 | - * @access public |
|
184 | - * @return void |
|
185 | - */ |
|
186 | - public static function load_request_handler() |
|
187 | - { |
|
188 | - // load core Request_Handler class |
|
189 | - if (EE_Registry::instance()->REQ !== null) { |
|
190 | - EE_Registry::instance()->load_core('Request_Handler'); |
|
191 | - } |
|
192 | - } |
|
193 | - |
|
194 | - |
|
195 | - /** |
|
196 | - * set_definitions |
|
197 | - * |
|
198 | - * @access public |
|
199 | - * @return void |
|
200 | - * @throws EE_Error |
|
201 | - */ |
|
202 | - public static function set_definitions() |
|
203 | - { |
|
204 | - if (defined('SPCO_BASE_PATH')) { |
|
205 | - return; |
|
206 | - } |
|
207 | - define( |
|
208 | - 'SPCO_BASE_PATH', |
|
209 | - rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS |
|
210 | - ); |
|
211 | - define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS); |
|
212 | - define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS); |
|
213 | - define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS); |
|
214 | - define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS); |
|
215 | - define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS); |
|
216 | - define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS); |
|
217 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true); |
|
218 | - EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice( |
|
219 | - ); |
|
220 | - } |
|
221 | - |
|
222 | - |
|
223 | - /** |
|
224 | - * load_reg_steps |
|
225 | - * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array |
|
226 | - * |
|
227 | - * @access private |
|
228 | - * @throws EE_Error |
|
229 | - */ |
|
230 | - public static function load_reg_steps() |
|
231 | - { |
|
232 | - static $reg_steps_loaded = false; |
|
233 | - if ($reg_steps_loaded) { |
|
234 | - return; |
|
235 | - } |
|
236 | - // filter list of reg_steps |
|
237 | - $reg_steps_to_load = (array) apply_filters( |
|
238 | - 'AHEE__SPCO__load_reg_steps__reg_steps_to_load', |
|
239 | - EED_Single_Page_Checkout::get_reg_steps() |
|
240 | - ); |
|
241 | - // sort by key (order) |
|
242 | - ksort($reg_steps_to_load); |
|
243 | - // loop through folders |
|
244 | - foreach ($reg_steps_to_load as $order => $reg_step) { |
|
245 | - // we need a |
|
246 | - if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
247 | - // copy over to the reg_steps_array |
|
248 | - EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step; |
|
249 | - // register custom key route for each reg step |
|
250 | - // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
|
251 | - EE_Config::register_route( |
|
252 | - $reg_step['slug'], |
|
253 | - 'EED_Single_Page_Checkout', |
|
254 | - 'run', |
|
255 | - 'step' |
|
256 | - ); |
|
257 | - // add AJAX or other hooks |
|
258 | - if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
|
259 | - // setup autoloaders if necessary |
|
260 | - if (! class_exists($reg_step['class_name'])) { |
|
261 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( |
|
262 | - $reg_step['file_path'], |
|
263 | - true |
|
264 | - ); |
|
265 | - } |
|
266 | - if (is_callable($reg_step['class_name'], 'set_hooks')) { |
|
267 | - call_user_func(array($reg_step['class_name'], 'set_hooks')); |
|
268 | - } |
|
269 | - } |
|
270 | - } |
|
271 | - } |
|
272 | - $reg_steps_loaded = true; |
|
273 | - } |
|
274 | - |
|
275 | - |
|
276 | - /** |
|
277 | - * get_reg_steps |
|
278 | - * |
|
279 | - * @access public |
|
280 | - * @return array |
|
281 | - */ |
|
282 | - public static function get_reg_steps() |
|
283 | - { |
|
284 | - $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps; |
|
285 | - if (empty($reg_steps)) { |
|
286 | - $reg_steps = array( |
|
287 | - 10 => array( |
|
288 | - 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
289 | - 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
|
290 | - 'slug' => 'attendee_information', |
|
291 | - 'has_hooks' => false, |
|
292 | - ), |
|
293 | - 30 => array( |
|
294 | - 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
295 | - 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
|
296 | - 'slug' => 'payment_options', |
|
297 | - 'has_hooks' => true, |
|
298 | - ), |
|
299 | - 999 => array( |
|
300 | - 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
301 | - 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
|
302 | - 'slug' => 'finalize_registration', |
|
303 | - 'has_hooks' => false, |
|
304 | - ), |
|
305 | - ); |
|
306 | - } |
|
307 | - return $reg_steps; |
|
308 | - } |
|
309 | - |
|
310 | - |
|
311 | - /** |
|
312 | - * registration_checkout_for_admin |
|
313 | - * |
|
314 | - * @access public |
|
315 | - * @return string |
|
316 | - * @throws EE_Error |
|
317 | - */ |
|
318 | - public static function registration_checkout_for_admin() |
|
319 | - { |
|
320 | - EED_Single_Page_Checkout::load_request_handler(); |
|
321 | - EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
322 | - EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step'); |
|
323 | - EE_Registry::instance()->REQ->set('process_form_submission', false); |
|
324 | - EED_Single_Page_Checkout::instance()->_initialize(); |
|
325 | - EED_Single_Page_Checkout::instance()->_display_spco_reg_form(); |
|
326 | - return EE_Registry::instance()->REQ->get_output(); |
|
327 | - } |
|
328 | - |
|
329 | - |
|
330 | - /** |
|
331 | - * process_registration_from_admin |
|
332 | - * |
|
333 | - * @access public |
|
334 | - * @return \EE_Transaction |
|
335 | - * @throws EE_Error |
|
336 | - */ |
|
337 | - public static function process_registration_from_admin() |
|
338 | - { |
|
339 | - EED_Single_Page_Checkout::load_request_handler(); |
|
340 | - EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
341 | - EE_Registry::instance()->REQ->set('action', 'process_reg_step'); |
|
342 | - EE_Registry::instance()->REQ->set('process_form_submission', true); |
|
343 | - EED_Single_Page_Checkout::instance()->_initialize(); |
|
344 | - if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) { |
|
345 | - $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps); |
|
346 | - if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
347 | - EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step); |
|
348 | - if ($final_reg_step->process_reg_step()) { |
|
349 | - $final_reg_step->set_completed(); |
|
350 | - EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array(); |
|
351 | - return EED_Single_Page_Checkout::instance()->checkout->transaction; |
|
352 | - } |
|
353 | - } |
|
354 | - } |
|
355 | - return null; |
|
356 | - } |
|
357 | - |
|
358 | - |
|
359 | - /** |
|
360 | - * run |
|
361 | - * |
|
362 | - * @access public |
|
363 | - * @param WP_Query $WP_Query |
|
364 | - * @return void |
|
365 | - * @throws EE_Error |
|
366 | - */ |
|
367 | - public function run($WP_Query) |
|
368 | - { |
|
369 | - if ($WP_Query instanceof WP_Query |
|
370 | - && $WP_Query->is_main_query() |
|
371 | - && apply_filters('FHEE__EED_Single_Page_Checkout__run', true) |
|
372 | - && $this->_is_reg_checkout() |
|
373 | - ) { |
|
374 | - $this->_initialize(); |
|
375 | - } |
|
376 | - } |
|
377 | - |
|
378 | - |
|
379 | - /** |
|
380 | - * determines whether current url matches reg page url |
|
381 | - * |
|
382 | - * @return bool |
|
383 | - */ |
|
384 | - protected function _is_reg_checkout() |
|
385 | - { |
|
386 | - // get current permalink for reg page without any extra query args |
|
387 | - $reg_page_url = \get_permalink(EE_Config::instance()->core->reg_page_id); |
|
388 | - // get request URI for current request, but without the scheme or host |
|
389 | - $current_request_uri = \EEH_URL::filter_input_server_url('REQUEST_URI'); |
|
390 | - $current_request_uri = html_entity_decode($current_request_uri); |
|
391 | - // get array of query args from the current request URI |
|
392 | - $query_args = \EEH_URL::get_query_string($current_request_uri); |
|
393 | - // grab page id if it is set |
|
394 | - $page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0; |
|
395 | - // and remove the page id from the query args (we will re-add it later) |
|
396 | - unset($query_args['page_id']); |
|
397 | - // now strip all query args from current request URI |
|
398 | - $current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri); |
|
399 | - // and re-add the page id if it was set |
|
400 | - if ($page_id) { |
|
401 | - $current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri); |
|
402 | - } |
|
403 | - // remove slashes and ? |
|
404 | - $current_request_uri = trim($current_request_uri, '?/'); |
|
405 | - // is current request URI part of the known full reg page URL ? |
|
406 | - return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false; |
|
407 | - } |
|
408 | - |
|
409 | - |
|
410 | - /** |
|
411 | - * @param WP_Query $wp_query |
|
412 | - * @return void |
|
413 | - * @throws EE_Error |
|
414 | - */ |
|
415 | - public static function init($wp_query) |
|
416 | - { |
|
417 | - EED_Single_Page_Checkout::instance()->run($wp_query); |
|
418 | - } |
|
419 | - |
|
420 | - |
|
421 | - /** |
|
422 | - * _initialize - initial module setup |
|
423 | - * |
|
424 | - * @access private |
|
425 | - * @throws EE_Error |
|
426 | - * @return void |
|
427 | - */ |
|
428 | - private function _initialize() |
|
429 | - { |
|
430 | - // ensure SPCO doesn't run twice |
|
431 | - if (EED_Single_Page_Checkout::$_initialized) { |
|
432 | - return; |
|
433 | - } |
|
434 | - try { |
|
435 | - EED_Single_Page_Checkout::load_reg_steps(); |
|
436 | - $this->_verify_session(); |
|
437 | - // setup the EE_Checkout object |
|
438 | - $this->checkout = $this->_initialize_checkout(); |
|
439 | - // filter checkout |
|
440 | - $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); |
|
441 | - // get the $_GET |
|
442 | - $this->_get_request_vars(); |
|
443 | - if ($this->_block_bots()) { |
|
444 | - return; |
|
445 | - } |
|
446 | - // filter continue_reg |
|
447 | - $this->checkout->continue_reg = apply_filters( |
|
448 | - 'FHEE__EED_Single_Page_Checkout__init___continue_reg', |
|
449 | - true, |
|
450 | - $this->checkout |
|
451 | - ); |
|
452 | - // load the reg steps array |
|
453 | - if (! $this->_load_and_instantiate_reg_steps()) { |
|
454 | - EED_Single_Page_Checkout::$_initialized = true; |
|
455 | - return; |
|
456 | - } |
|
457 | - // set the current step |
|
458 | - $this->checkout->set_current_step($this->checkout->step); |
|
459 | - // and the next step |
|
460 | - $this->checkout->set_next_step(); |
|
461 | - // verify that everything has been setup correctly |
|
462 | - if (! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) { |
|
463 | - EED_Single_Page_Checkout::$_initialized = true; |
|
464 | - return; |
|
465 | - } |
|
466 | - // lock the transaction |
|
467 | - $this->checkout->transaction->lock(); |
|
468 | - // make sure all of our cached objects are added to their respective model entity mappers |
|
469 | - $this->checkout->refresh_all_entities(); |
|
470 | - // set amount owing |
|
471 | - $this->checkout->amount_owing = $this->checkout->transaction->remaining(); |
|
472 | - // initialize each reg step, which gives them the chance to potentially alter the process |
|
473 | - $this->_initialize_reg_steps(); |
|
474 | - // DEBUG LOG |
|
475 | - // $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
|
476 | - // get reg form |
|
477 | - if (! $this->_check_form_submission()) { |
|
478 | - EED_Single_Page_Checkout::$_initialized = true; |
|
479 | - return; |
|
480 | - } |
|
481 | - // checkout the action!!! |
|
482 | - $this->_process_form_action(); |
|
483 | - // add some style and make it dance |
|
484 | - $this->add_styles_and_scripts(); |
|
485 | - // kk... SPCO has successfully run |
|
486 | - EED_Single_Page_Checkout::$_initialized = true; |
|
487 | - // set no cache headers and constants |
|
488 | - EE_System::do_not_cache(); |
|
489 | - // add anchor |
|
490 | - add_action('loop_start', array($this, 'set_checkout_anchor'), 1); |
|
491 | - // remove transaction lock |
|
492 | - add_action('shutdown', array($this, 'unlock_transaction'), 1); |
|
493 | - } catch (Exception $e) { |
|
494 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
495 | - } |
|
496 | - } |
|
497 | - |
|
498 | - |
|
499 | - /** |
|
500 | - * _verify_session |
|
501 | - * checks that the session is valid and not expired |
|
502 | - * |
|
503 | - * @access private |
|
504 | - * @throws EE_Error |
|
505 | - */ |
|
506 | - private function _verify_session() |
|
507 | - { |
|
508 | - if (! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
509 | - throw new EE_Error(esc_html__('The EE_Session class could not be loaded.', 'event_espresso')); |
|
510 | - } |
|
511 | - $clear_session_requested = filter_var( |
|
512 | - EE_Registry::instance()->REQ->get('clear_session', false), |
|
513 | - FILTER_VALIDATE_BOOLEAN |
|
514 | - ); |
|
515 | - // is session still valid ? |
|
516 | - if ($clear_session_requested |
|
517 | - || (EE_Registry::instance()->SSN->expired() |
|
518 | - && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === '' |
|
519 | - ) |
|
520 | - ) { |
|
521 | - $this->checkout = new EE_Checkout(); |
|
522 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
523 | - // EE_Registry::instance()->SSN->reset_cart(); |
|
524 | - // EE_Registry::instance()->SSN->reset_checkout(); |
|
525 | - // EE_Registry::instance()->SSN->reset_transaction(); |
|
526 | - if (! $clear_session_requested) { |
|
527 | - EE_Error::add_attention( |
|
528 | - EE_Registry::$i18n_js_strings['registration_expiration_notice'], |
|
529 | - __FILE__, |
|
530 | - __FUNCTION__, |
|
531 | - __LINE__ |
|
532 | - ); |
|
533 | - } |
|
534 | - // EE_Registry::instance()->SSN->reset_expired(); |
|
535 | - } |
|
536 | - } |
|
537 | - |
|
538 | - |
|
539 | - /** |
|
540 | - * _initialize_checkout |
|
541 | - * loads and instantiates EE_Checkout |
|
542 | - * |
|
543 | - * @access private |
|
544 | - * @throws EE_Error |
|
545 | - * @return EE_Checkout |
|
546 | - */ |
|
547 | - private function _initialize_checkout() |
|
548 | - { |
|
549 | - // look in session for existing checkout |
|
550 | - /** @type EE_Checkout $checkout */ |
|
551 | - $checkout = EE_Registry::instance()->SSN->checkout(); |
|
552 | - // verify |
|
553 | - if (! $checkout instanceof EE_Checkout) { |
|
554 | - // instantiate EE_Checkout object for handling the properties of the current checkout process |
|
555 | - $checkout = EE_Registry::instance()->load_file( |
|
556 | - SPCO_INC_PATH, |
|
557 | - 'EE_Checkout', |
|
558 | - 'class', |
|
559 | - array(), |
|
560 | - false |
|
561 | - ); |
|
562 | - } else { |
|
563 | - if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) { |
|
564 | - $this->unlock_transaction(); |
|
565 | - wp_safe_redirect($checkout->redirect_url); |
|
566 | - exit(); |
|
567 | - } |
|
568 | - } |
|
569 | - $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
|
570 | - // verify again |
|
571 | - if (! $checkout instanceof EE_Checkout) { |
|
572 | - throw new EE_Error(esc_html__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
|
573 | - } |
|
574 | - // reset anything that needs a clean slate for each request |
|
575 | - $checkout->reset_for_current_request(); |
|
576 | - return $checkout; |
|
577 | - } |
|
578 | - |
|
579 | - |
|
580 | - /** |
|
581 | - * _get_request_vars |
|
582 | - * |
|
583 | - * @access private |
|
584 | - * @return void |
|
585 | - * @throws EE_Error |
|
586 | - */ |
|
587 | - private function _get_request_vars() |
|
588 | - { |
|
589 | - // load classes |
|
590 | - EED_Single_Page_Checkout::load_request_handler(); |
|
591 | - // make sure this request is marked as belonging to EE |
|
592 | - EE_Registry::instance()->REQ->set_espresso_page(true); |
|
593 | - // which step is being requested ? |
|
594 | - $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step()); |
|
595 | - // which step is being edited ? |
|
596 | - $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', ''); |
|
597 | - // and what we're doing on the current step |
|
598 | - $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step'); |
|
599 | - // timestamp |
|
600 | - $this->checkout->uts = EE_Registry::instance()->REQ->get('uts', 0); |
|
601 | - // returning to edit ? |
|
602 | - $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', ''); |
|
603 | - // add reg url link to registration query params |
|
604 | - if ($this->checkout->reg_url_link && strpos($this->checkout->reg_url_link, '1-') !== 0) { |
|
605 | - $this->checkout->reg_cache_where_params[0]['REG_url_link'] = $this->checkout->reg_url_link; |
|
606 | - } |
|
607 | - // or some other kind of revisit ? |
|
608 | - $this->checkout->revisit = filter_var( |
|
609 | - EE_Registry::instance()->REQ->get('revisit', false), |
|
610 | - FILTER_VALIDATE_BOOLEAN |
|
611 | - ); |
|
612 | - // and whether or not to generate a reg form for this request |
|
613 | - $this->checkout->generate_reg_form = filter_var( |
|
614 | - EE_Registry::instance()->REQ->get('generate_reg_form', true), |
|
615 | - FILTER_VALIDATE_BOOLEAN |
|
616 | - ); |
|
617 | - // and whether or not to process a reg form submission for this request |
|
618 | - $this->checkout->process_form_submission = filter_var( |
|
619 | - EE_Registry::instance()->REQ->get( |
|
620 | - 'process_form_submission', |
|
621 | - $this->checkout->action === 'process_reg_step' |
|
622 | - ), |
|
623 | - FILTER_VALIDATE_BOOLEAN |
|
624 | - ); |
|
625 | - $this->checkout->process_form_submission = filter_var( |
|
626 | - $this->checkout->action !== 'display_spco_reg_step' |
|
627 | - ? $this->checkout->process_form_submission |
|
628 | - : false, |
|
629 | - FILTER_VALIDATE_BOOLEAN |
|
630 | - ); |
|
631 | - // $this->_display_request_vars(); |
|
632 | - } |
|
633 | - |
|
634 | - |
|
635 | - /** |
|
636 | - * _display_request_vars |
|
637 | - * |
|
638 | - * @access protected |
|
639 | - * @return void |
|
640 | - */ |
|
641 | - protected function _display_request_vars() |
|
642 | - { |
|
643 | - if (! WP_DEBUG) { |
|
644 | - return; |
|
645 | - } |
|
646 | - EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__); |
|
647 | - EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__); |
|
648 | - EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__); |
|
649 | - EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__); |
|
650 | - EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__); |
|
651 | - EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__); |
|
652 | - EEH_Debug_Tools::printr( |
|
653 | - $this->checkout->generate_reg_form, |
|
654 | - '$this->checkout->generate_reg_form', |
|
655 | - __FILE__, |
|
656 | - __LINE__ |
|
657 | - ); |
|
658 | - EEH_Debug_Tools::printr( |
|
659 | - $this->checkout->process_form_submission, |
|
660 | - '$this->checkout->process_form_submission', |
|
661 | - __FILE__, |
|
662 | - __LINE__ |
|
663 | - ); |
|
664 | - } |
|
665 | - |
|
666 | - |
|
667 | - /** |
|
668 | - * _block_bots |
|
669 | - * checks that the incoming request has either of the following set: |
|
670 | - * a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector |
|
671 | - * a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN |
|
672 | - * so if you're not coming from the Ticket Selector nor returning for a valid IP... |
|
673 | - * then where you coming from man? |
|
674 | - * |
|
675 | - * @return boolean |
|
676 | - */ |
|
677 | - private function _block_bots() |
|
678 | - { |
|
679 | - $invalid_checkout_access = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
680 | - if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) { |
|
681 | - return true; |
|
682 | - } |
|
683 | - return false; |
|
684 | - } |
|
685 | - |
|
686 | - |
|
687 | - /** |
|
688 | - * _get_first_step |
|
689 | - * gets slug for first step in $_reg_steps_array |
|
690 | - * |
|
691 | - * @access private |
|
692 | - * @throws EE_Error |
|
693 | - * @return string |
|
694 | - */ |
|
695 | - private function _get_first_step() |
|
696 | - { |
|
697 | - $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array); |
|
698 | - return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information'; |
|
699 | - } |
|
700 | - |
|
701 | - |
|
702 | - /** |
|
703 | - * instantiates each reg step based on the loaded reg_steps array |
|
704 | - * |
|
705 | - * @return bool |
|
706 | - * @throws EE_Error |
|
707 | - * @throws InvalidArgumentException |
|
708 | - * @throws InvalidDataTypeException |
|
709 | - * @throws InvalidInterfaceException |
|
710 | - */ |
|
711 | - private function _load_and_instantiate_reg_steps() |
|
712 | - { |
|
713 | - do_action('AHEE__Single_Page_Checkout___load_and_instantiate_reg_steps__start', $this->checkout); |
|
714 | - // have reg_steps already been instantiated ? |
|
715 | - if (empty($this->checkout->reg_steps) |
|
716 | - || apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout) |
|
717 | - ) { |
|
718 | - // if not, then loop through raw reg steps array |
|
719 | - foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
|
720 | - if (! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
721 | - return false; |
|
722 | - } |
|
723 | - } |
|
724 | - if (isset($this->checkout->reg_steps['registration_confirmation'])) { |
|
725 | - // skip the registration_confirmation page ? |
|
726 | - if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) { |
|
727 | - // just remove it from the reg steps array |
|
728 | - $this->checkout->remove_reg_step('registration_confirmation', false); |
|
729 | - } elseif (EE_Registry::instance()->CFG->registration->reg_confirmation_last |
|
730 | - ) { |
|
731 | - // set the order to something big like 100 |
|
732 | - $this->checkout->set_reg_step_order('registration_confirmation', 100); |
|
733 | - } |
|
734 | - } |
|
735 | - // filter the array for good luck |
|
736 | - $this->checkout->reg_steps = apply_filters( |
|
737 | - 'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps', |
|
738 | - $this->checkout->reg_steps |
|
739 | - ); |
|
740 | - // finally re-sort based on the reg step class order properties |
|
741 | - $this->checkout->sort_reg_steps(); |
|
742 | - } else { |
|
743 | - foreach ($this->checkout->reg_steps as $reg_step) { |
|
744 | - // set all current step stati to FALSE |
|
745 | - $reg_step->set_is_current_step(false); |
|
746 | - } |
|
747 | - } |
|
748 | - if (empty($this->checkout->reg_steps)) { |
|
749 | - EE_Error::add_error( |
|
750 | - esc_html__('No Reg Steps were loaded..', 'event_espresso'), |
|
751 | - __FILE__, |
|
752 | - __FUNCTION__, |
|
753 | - __LINE__ |
|
754 | - ); |
|
755 | - return false; |
|
756 | - } |
|
757 | - // make reg step details available to JS |
|
758 | - $this->checkout->set_reg_step_JSON_info(); |
|
759 | - return true; |
|
760 | - } |
|
761 | - |
|
762 | - |
|
763 | - /** |
|
764 | - * _load_and_instantiate_reg_step |
|
765 | - * |
|
766 | - * @access private |
|
767 | - * @param array $reg_step |
|
768 | - * @param int $order |
|
769 | - * @return bool |
|
770 | - */ |
|
771 | - private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) |
|
772 | - { |
|
773 | - // we need a file_path, class_name, and slug to add a reg step |
|
774 | - if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
775 | - // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
|
776 | - if ($this->checkout->reg_url_link |
|
777 | - && $this->checkout->step !== $reg_step['slug'] |
|
778 | - && $reg_step['slug'] !== 'finalize_registration' |
|
779 | - // normally at this point we would NOT load the reg step, but this filter can change that |
|
780 | - && apply_filters( |
|
781 | - 'FHEE__Single_Page_Checkout___load_and_instantiate_reg_step__bypass_reg_step', |
|
782 | - true, |
|
783 | - $reg_step, |
|
784 | - $this->checkout |
|
785 | - ) |
|
786 | - ) { |
|
787 | - return true; |
|
788 | - } |
|
789 | - // instantiate step class using file path and class name |
|
790 | - $reg_step_obj = EE_Registry::instance()->load_file( |
|
791 | - $reg_step['file_path'], |
|
792 | - $reg_step['class_name'], |
|
793 | - 'class', |
|
794 | - $this->checkout, |
|
795 | - false |
|
796 | - ); |
|
797 | - // did we gets the goods ? |
|
798 | - if ($reg_step_obj instanceof EE_SPCO_Reg_Step) { |
|
799 | - // set reg step order based on config |
|
800 | - $reg_step_obj->set_order($order); |
|
801 | - // add instantiated reg step object to the master reg steps array |
|
802 | - $this->checkout->add_reg_step($reg_step_obj); |
|
803 | - } else { |
|
804 | - EE_Error::add_error( |
|
805 | - esc_html__('The current step could not be set.', 'event_espresso'), |
|
806 | - __FILE__, |
|
807 | - __FUNCTION__, |
|
808 | - __LINE__ |
|
809 | - ); |
|
810 | - return false; |
|
811 | - } |
|
812 | - } else { |
|
813 | - if (WP_DEBUG) { |
|
814 | - EE_Error::add_error( |
|
815 | - sprintf( |
|
816 | - esc_html__( |
|
817 | - 'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', |
|
818 | - 'event_espresso' |
|
819 | - ), |
|
820 | - isset($reg_step['file_path']) ? $reg_step['file_path'] : '', |
|
821 | - isset($reg_step['class_name']) ? $reg_step['class_name'] : '', |
|
822 | - isset($reg_step['slug']) ? $reg_step['slug'] : '', |
|
823 | - '<ul>', |
|
824 | - '<li>', |
|
825 | - '</li>', |
|
826 | - '</ul>' |
|
827 | - ), |
|
828 | - __FILE__, |
|
829 | - __FUNCTION__, |
|
830 | - __LINE__ |
|
831 | - ); |
|
832 | - } |
|
833 | - return false; |
|
834 | - } |
|
835 | - return true; |
|
836 | - } |
|
837 | - |
|
838 | - |
|
839 | - /** |
|
840 | - * _verify_transaction_and_get_registrations |
|
841 | - * |
|
842 | - * @access private |
|
843 | - * @return bool |
|
844 | - * @throws InvalidDataTypeException |
|
845 | - * @throws InvalidEntityException |
|
846 | - * @throws EE_Error |
|
847 | - */ |
|
848 | - private function _verify_transaction_and_get_registrations() |
|
849 | - { |
|
850 | - // was there already a valid transaction in the checkout from the session ? |
|
851 | - if (! $this->checkout->transaction instanceof EE_Transaction) { |
|
852 | - // get transaction from db or session |
|
853 | - $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
|
854 | - ? $this->_get_transaction_and_cart_for_previous_visit() |
|
855 | - : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
|
856 | - if (! $this->checkout->transaction instanceof EE_Transaction) { |
|
857 | - EE_Error::add_error( |
|
858 | - esc_html__( |
|
859 | - 'Your Registration and Transaction information could not be retrieved from the db.', |
|
860 | - 'event_espresso' |
|
861 | - ), |
|
862 | - __FILE__, |
|
863 | - __FUNCTION__, |
|
864 | - __LINE__ |
|
865 | - ); |
|
866 | - $this->checkout->transaction = EE_Transaction::new_instance(); |
|
867 | - // add some style and make it dance |
|
868 | - $this->add_styles_and_scripts(); |
|
869 | - EED_Single_Page_Checkout::$_initialized = true; |
|
870 | - return false; |
|
871 | - } |
|
872 | - // and the registrations for the transaction |
|
873 | - $this->_get_registrations($this->checkout->transaction); |
|
874 | - } |
|
875 | - return true; |
|
876 | - } |
|
877 | - |
|
878 | - |
|
879 | - /** |
|
880 | - * _get_transaction_and_cart_for_previous_visit |
|
881 | - * |
|
882 | - * @access private |
|
883 | - * @return mixed EE_Transaction|NULL |
|
884 | - */ |
|
885 | - private function _get_transaction_and_cart_for_previous_visit() |
|
886 | - { |
|
887 | - /** @var $TXN_model EEM_Transaction */ |
|
888 | - $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
889 | - // because the reg_url_link is present in the request, |
|
890 | - // this is a return visit to SPCO, so we'll get the transaction data from the db |
|
891 | - $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link); |
|
892 | - // verify transaction |
|
893 | - if ($transaction instanceof EE_Transaction) { |
|
894 | - // and get the cart that was used for that transaction |
|
895 | - $this->checkout->cart = $this->_get_cart_for_transaction($transaction); |
|
896 | - return $transaction; |
|
897 | - } |
|
898 | - EE_Error::add_error( |
|
899 | - esc_html__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), |
|
900 | - __FILE__, |
|
901 | - __FUNCTION__, |
|
902 | - __LINE__ |
|
903 | - ); |
|
904 | - return null; |
|
905 | - } |
|
906 | - |
|
907 | - |
|
908 | - /** |
|
909 | - * _get_cart_for_transaction |
|
910 | - * |
|
911 | - * @access private |
|
912 | - * @param EE_Transaction $transaction |
|
913 | - * @return EE_Cart |
|
914 | - */ |
|
915 | - private function _get_cart_for_transaction($transaction) |
|
916 | - { |
|
917 | - return $this->checkout->get_cart_for_transaction($transaction); |
|
918 | - } |
|
919 | - |
|
920 | - |
|
921 | - /** |
|
922 | - * get_cart_for_transaction |
|
923 | - * |
|
924 | - * @access public |
|
925 | - * @param EE_Transaction $transaction |
|
926 | - * @return EE_Cart |
|
927 | - */ |
|
928 | - public function get_cart_for_transaction(EE_Transaction $transaction) |
|
929 | - { |
|
930 | - return $this->checkout->get_cart_for_transaction($transaction); |
|
931 | - } |
|
932 | - |
|
933 | - |
|
934 | - /** |
|
935 | - * _get_transaction_and_cart_for_current_session |
|
936 | - * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
937 | - * |
|
938 | - * @access private |
|
939 | - * @return EE_Transaction |
|
940 | - * @throws EE_Error |
|
941 | - */ |
|
942 | - private function _get_cart_for_current_session_and_setup_new_transaction() |
|
943 | - { |
|
944 | - // if there's no transaction, then this is the FIRST visit to SPCO |
|
945 | - // so load up the cart ( passing nothing for the TXN because it doesn't exist yet ) |
|
946 | - $this->checkout->cart = $this->_get_cart_for_transaction(null); |
|
947 | - // and then create a new transaction |
|
948 | - $transaction = $this->_initialize_transaction(); |
|
949 | - // verify transaction |
|
950 | - if ($transaction instanceof EE_Transaction) { |
|
951 | - // save it so that we have an ID for other objects to use |
|
952 | - $transaction->save(); |
|
953 | - // and save TXN data to the cart |
|
954 | - $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID()); |
|
955 | - } else { |
|
956 | - EE_Error::add_error( |
|
957 | - esc_html__('A Valid Transaction could not be initialized.', 'event_espresso'), |
|
958 | - __FILE__, |
|
959 | - __FUNCTION__, |
|
960 | - __LINE__ |
|
961 | - ); |
|
962 | - } |
|
963 | - return $transaction; |
|
964 | - } |
|
965 | - |
|
966 | - |
|
967 | - /** |
|
968 | - * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
969 | - * |
|
970 | - * @access private |
|
971 | - * @return mixed EE_Transaction|NULL |
|
972 | - */ |
|
973 | - private function _initialize_transaction() |
|
974 | - { |
|
975 | - try { |
|
976 | - // ensure cart totals have been calculated |
|
977 | - $this->checkout->cart->get_grand_total()->recalculate_total_including_taxes(); |
|
978 | - // grab the cart grand total |
|
979 | - $cart_total = $this->checkout->cart->get_cart_grand_total(); |
|
980 | - // create new TXN |
|
981 | - $transaction = EE_Transaction::new_instance( |
|
982 | - array( |
|
983 | - 'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(), |
|
984 | - 'TXN_total' => $cart_total > 0 ? $cart_total : 0, |
|
985 | - 'TXN_paid' => 0, |
|
986 | - 'STS_ID' => EEM_Transaction::failed_status_code, |
|
987 | - ) |
|
988 | - ); |
|
989 | - // save it so that we have an ID for other objects to use |
|
990 | - $transaction->save(); |
|
991 | - // set cron job for following up on TXNs after their session has expired |
|
992 | - EE_Cron_Tasks::schedule_expired_transaction_check( |
|
993 | - EE_Registry::instance()->SSN->expiration() + 1, |
|
994 | - $transaction->ID() |
|
995 | - ); |
|
996 | - return $transaction; |
|
997 | - } catch (Exception $e) { |
|
998 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
999 | - } |
|
1000 | - return null; |
|
1001 | - } |
|
1002 | - |
|
1003 | - |
|
1004 | - /** |
|
1005 | - * _get_registrations |
|
1006 | - * |
|
1007 | - * @access private |
|
1008 | - * @param EE_Transaction $transaction |
|
1009 | - * @return void |
|
1010 | - * @throws InvalidDataTypeException |
|
1011 | - * @throws InvalidEntityException |
|
1012 | - * @throws EE_Error |
|
1013 | - */ |
|
1014 | - private function _get_registrations(EE_Transaction $transaction) |
|
1015 | - { |
|
1016 | - // first step: grab the registrants { : o |
|
1017 | - $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
1018 | - $this->checkout->total_ticket_count = count($registrations); |
|
1019 | - // verify registrations have been set |
|
1020 | - if (empty($registrations)) { |
|
1021 | - // if no cached registrations, then check the db |
|
1022 | - $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
1023 | - // still nothing ? well as long as this isn't a revisit |
|
1024 | - if (empty($registrations) && ! $this->checkout->revisit) { |
|
1025 | - // generate new registrations from scratch |
|
1026 | - $registrations = $this->_initialize_registrations($transaction); |
|
1027 | - } |
|
1028 | - } |
|
1029 | - // sort by their original registration order |
|
1030 | - usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count')); |
|
1031 | - // then loop thru the array |
|
1032 | - foreach ($registrations as $registration) { |
|
1033 | - // verify each registration |
|
1034 | - if ($registration instanceof EE_Registration) { |
|
1035 | - // we display all attendee info for the primary registrant |
|
1036 | - if ($this->checkout->reg_url_link === $registration->reg_url_link() |
|
1037 | - && $registration->is_primary_registrant() |
|
1038 | - ) { |
|
1039 | - $this->checkout->primary_revisit = true; |
|
1040 | - break; |
|
1041 | - } |
|
1042 | - if ($this->checkout->revisit && $this->checkout->reg_url_link !== $registration->reg_url_link()) { |
|
1043 | - // but hide info if it doesn't belong to you |
|
1044 | - $transaction->clear_cache('Registration', $registration->ID()); |
|
1045 | - $this->checkout->total_ticket_count--; |
|
1046 | - } |
|
1047 | - $this->checkout->set_reg_status_updated($registration->ID(), false); |
|
1048 | - } |
|
1049 | - } |
|
1050 | - } |
|
1051 | - |
|
1052 | - |
|
1053 | - /** |
|
1054 | - * adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object |
|
1055 | - * |
|
1056 | - * @access private |
|
1057 | - * @param EE_Transaction $transaction |
|
1058 | - * @return array |
|
1059 | - * @throws InvalidDataTypeException |
|
1060 | - * @throws InvalidEntityException |
|
1061 | - * @throws EE_Error |
|
1062 | - */ |
|
1063 | - private function _initialize_registrations(EE_Transaction $transaction) |
|
1064 | - { |
|
1065 | - $att_nmbr = 0; |
|
1066 | - $registrations = array(); |
|
1067 | - if ($transaction instanceof EE_Transaction) { |
|
1068 | - /** @type EE_Registration_Processor $registration_processor */ |
|
1069 | - $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1070 | - $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count(); |
|
1071 | - // now let's add the cart items to the $transaction |
|
1072 | - foreach ($this->checkout->cart->get_tickets() as $line_item) { |
|
1073 | - // do the following for each ticket of this type they selected |
|
1074 | - for ($x = 1; $x <= $line_item->quantity(); $x++) { |
|
1075 | - $att_nmbr++; |
|
1076 | - /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */ |
|
1077 | - $CreateRegistrationCommand = EE_Registry::instance()->create( |
|
1078 | - 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
1079 | - array( |
|
1080 | - $transaction, |
|
1081 | - $line_item, |
|
1082 | - $att_nmbr, |
|
1083 | - $this->checkout->total_ticket_count, |
|
1084 | - ) |
|
1085 | - ); |
|
1086 | - // override capabilities for frontend registrations |
|
1087 | - if (! is_admin()) { |
|
1088 | - $CreateRegistrationCommand->setCapCheck( |
|
1089 | - new PublicCapabilities('', 'create_new_registration') |
|
1090 | - ); |
|
1091 | - } |
|
1092 | - $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand); |
|
1093 | - if (! $registration instanceof EE_Registration) { |
|
1094 | - throw new InvalidEntityException($registration, 'EE_Registration'); |
|
1095 | - } |
|
1096 | - $registrations[ $registration->ID() ] = $registration; |
|
1097 | - } |
|
1098 | - } |
|
1099 | - $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
|
1100 | - } |
|
1101 | - return $registrations; |
|
1102 | - } |
|
1103 | - |
|
1104 | - |
|
1105 | - /** |
|
1106 | - * sorts registrations by REG_count |
|
1107 | - * |
|
1108 | - * @access public |
|
1109 | - * @param EE_Registration $reg_A |
|
1110 | - * @param EE_Registration $reg_B |
|
1111 | - * @return int |
|
1112 | - */ |
|
1113 | - public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) |
|
1114 | - { |
|
1115 | - // this shouldn't ever happen within the same TXN, but oh well |
|
1116 | - if ($reg_A->count() === $reg_B->count()) { |
|
1117 | - return 0; |
|
1118 | - } |
|
1119 | - return ($reg_A->count() > $reg_B->count()) ? 1 : -1; |
|
1120 | - } |
|
1121 | - |
|
1122 | - |
|
1123 | - /** |
|
1124 | - * _final_verifications |
|
1125 | - * just makes sure that everything is set up correctly before proceeding |
|
1126 | - * |
|
1127 | - * @access private |
|
1128 | - * @return bool |
|
1129 | - * @throws EE_Error |
|
1130 | - */ |
|
1131 | - private function _final_verifications() |
|
1132 | - { |
|
1133 | - // filter checkout |
|
1134 | - $this->checkout = apply_filters( |
|
1135 | - 'FHEE__EED_Single_Page_Checkout___final_verifications__checkout', |
|
1136 | - $this->checkout |
|
1137 | - ); |
|
1138 | - // verify that current step is still set correctly |
|
1139 | - if (! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
1140 | - EE_Error::add_error( |
|
1141 | - esc_html__( |
|
1142 | - 'We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', |
|
1143 | - 'event_espresso' |
|
1144 | - ), |
|
1145 | - __FILE__, |
|
1146 | - __FUNCTION__, |
|
1147 | - __LINE__ |
|
1148 | - ); |
|
1149 | - return false; |
|
1150 | - } |
|
1151 | - // if returning to SPCO, then verify that primary registrant is set |
|
1152 | - if (! empty($this->checkout->reg_url_link)) { |
|
1153 | - $valid_registrant = $this->checkout->transaction->primary_registration(); |
|
1154 | - if (! $valid_registrant instanceof EE_Registration) { |
|
1155 | - EE_Error::add_error( |
|
1156 | - esc_html__( |
|
1157 | - 'We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', |
|
1158 | - 'event_espresso' |
|
1159 | - ), |
|
1160 | - __FILE__, |
|
1161 | - __FUNCTION__, |
|
1162 | - __LINE__ |
|
1163 | - ); |
|
1164 | - return false; |
|
1165 | - } |
|
1166 | - $valid_registrant = null; |
|
1167 | - foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) { |
|
1168 | - if ($registration instanceof EE_Registration |
|
1169 | - && $registration->reg_url_link() === $this->checkout->reg_url_link |
|
1170 | - ) { |
|
1171 | - $valid_registrant = $registration; |
|
1172 | - } |
|
1173 | - } |
|
1174 | - if (! $valid_registrant instanceof EE_Registration) { |
|
1175 | - // hmmm... maybe we have the wrong session because the user is opening multiple tabs ? |
|
1176 | - if (EED_Single_Page_Checkout::$_checkout_verified) { |
|
1177 | - // clear the session, mark the checkout as unverified, and try again |
|
1178 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
1179 | - EED_Single_Page_Checkout::$_initialized = false; |
|
1180 | - EED_Single_Page_Checkout::$_checkout_verified = false; |
|
1181 | - $this->_initialize(); |
|
1182 | - EE_Error::reset_notices(); |
|
1183 | - return false; |
|
1184 | - } |
|
1185 | - EE_Error::add_error( |
|
1186 | - esc_html__( |
|
1187 | - 'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', |
|
1188 | - 'event_espresso' |
|
1189 | - ), |
|
1190 | - __FILE__, |
|
1191 | - __FUNCTION__, |
|
1192 | - __LINE__ |
|
1193 | - ); |
|
1194 | - return false; |
|
1195 | - } |
|
1196 | - } |
|
1197 | - // now that things have been kinda sufficiently verified, |
|
1198 | - // let's add the checkout to the session so that it's available to other systems |
|
1199 | - EE_Registry::instance()->SSN->set_checkout($this->checkout); |
|
1200 | - return true; |
|
1201 | - } |
|
1202 | - |
|
1203 | - |
|
1204 | - /** |
|
1205 | - * _initialize_reg_steps |
|
1206 | - * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required |
|
1207 | - * then loops thru all of the active reg steps and calls the initialize_reg_step() method |
|
1208 | - * |
|
1209 | - * @access private |
|
1210 | - * @param bool $reinitializing |
|
1211 | - * @throws EE_Error |
|
1212 | - */ |
|
1213 | - private function _initialize_reg_steps($reinitializing = false) |
|
1214 | - { |
|
1215 | - $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
|
1216 | - // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
|
1217 | - foreach ($this->checkout->reg_steps as $reg_step) { |
|
1218 | - if (! $reg_step->initialize_reg_step()) { |
|
1219 | - // if not initialized then maybe this step is being removed... |
|
1220 | - if (! $reinitializing && $reg_step->is_current_step()) { |
|
1221 | - // if it was the current step, then we need to start over here |
|
1222 | - $this->_initialize_reg_steps(true); |
|
1223 | - return; |
|
1224 | - } |
|
1225 | - continue; |
|
1226 | - } |
|
1227 | - // add css and JS for current step |
|
1228 | - $reg_step->enqueue_styles_and_scripts(); |
|
1229 | - // i18n |
|
1230 | - $reg_step->translate_js_strings(); |
|
1231 | - if ($reg_step->is_current_step()) { |
|
1232 | - // the text that appears on the reg step form submit button |
|
1233 | - $reg_step->set_submit_button_text(); |
|
1234 | - } |
|
1235 | - } |
|
1236 | - // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information |
|
1237 | - do_action( |
|
1238 | - "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", |
|
1239 | - $this->checkout->current_step |
|
1240 | - ); |
|
1241 | - } |
|
1242 | - |
|
1243 | - |
|
1244 | - /** |
|
1245 | - * _check_form_submission |
|
1246 | - * |
|
1247 | - * @access private |
|
1248 | - * @return boolean |
|
1249 | - */ |
|
1250 | - private function _check_form_submission() |
|
1251 | - { |
|
1252 | - // does this request require the reg form to be generated ? |
|
1253 | - if ($this->checkout->generate_reg_form) { |
|
1254 | - // ever heard that song by Blue Rodeo ? |
|
1255 | - try { |
|
1256 | - $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form(); |
|
1257 | - // if not displaying a form, then check for form submission |
|
1258 | - if ($this->checkout->process_form_submission |
|
1259 | - && $this->checkout->current_step->reg_form->was_submitted() |
|
1260 | - ) { |
|
1261 | - // clear out any old data in case this step is being run again |
|
1262 | - $this->checkout->current_step->set_valid_data(array()); |
|
1263 | - // capture submitted form data |
|
1264 | - $this->checkout->current_step->reg_form->receive_form_submission( |
|
1265 | - apply_filters( |
|
1266 | - 'FHEE__Single_Page_Checkout___check_form_submission__request_params', |
|
1267 | - EE_Registry::instance()->REQ->params(), |
|
1268 | - $this->checkout |
|
1269 | - ) |
|
1270 | - ); |
|
1271 | - // validate submitted form data |
|
1272 | - if (! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) { |
|
1273 | - // thou shall not pass !!! |
|
1274 | - $this->checkout->continue_reg = false; |
|
1275 | - // any form validation errors? |
|
1276 | - if ($this->checkout->current_step->reg_form->submission_error_message() !== '') { |
|
1277 | - EE_Error::add_error( |
|
1278 | - $this->checkout->current_step->reg_form->submission_error_message(), |
|
1279 | - __FILE__, |
|
1280 | - __FUNCTION__, |
|
1281 | - __LINE__ |
|
1282 | - ); |
|
1283 | - } |
|
1284 | - // well not really... what will happen is |
|
1285 | - // we'll just get redirected back to redo the current step |
|
1286 | - $this->go_to_next_step(); |
|
1287 | - return false; |
|
1288 | - } |
|
1289 | - } |
|
1290 | - } catch (EE_Error $e) { |
|
1291 | - $e->get_error(); |
|
1292 | - } |
|
1293 | - } |
|
1294 | - return true; |
|
1295 | - } |
|
1296 | - |
|
1297 | - |
|
1298 | - /** |
|
1299 | - * _process_action |
|
1300 | - * |
|
1301 | - * @access private |
|
1302 | - * @return void |
|
1303 | - * @throws EE_Error |
|
1304 | - */ |
|
1305 | - private function _process_form_action() |
|
1306 | - { |
|
1307 | - // what cha wanna do? |
|
1308 | - switch ($this->checkout->action) { |
|
1309 | - // AJAX next step reg form |
|
1310 | - case 'display_spco_reg_step': |
|
1311 | - $this->checkout->redirect = false; |
|
1312 | - if (EE_Registry::instance()->REQ->ajax) { |
|
1313 | - $this->checkout->json_response->set_reg_step_html( |
|
1314 | - $this->checkout->current_step->display_reg_form() |
|
1315 | - ); |
|
1316 | - } |
|
1317 | - break; |
|
1318 | - default: |
|
1319 | - // meh... do one of those other steps first |
|
1320 | - if (! empty($this->checkout->action) |
|
1321 | - && is_callable(array($this->checkout->current_step, $this->checkout->action)) |
|
1322 | - ) { |
|
1323 | - // dynamically creates hook point like: |
|
1324 | - // AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step |
|
1325 | - do_action( |
|
1326 | - "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", |
|
1327 | - $this->checkout->current_step |
|
1328 | - ); |
|
1329 | - // call action on current step |
|
1330 | - if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) { |
|
1331 | - // good registrant, you get to proceed |
|
1332 | - if ($this->checkout->current_step->success_message() !== '' |
|
1333 | - && apply_filters( |
|
1334 | - 'FHEE__Single_Page_Checkout___process_form_action__display_success', |
|
1335 | - false |
|
1336 | - ) |
|
1337 | - ) { |
|
1338 | - EE_Error::add_success( |
|
1339 | - $this->checkout->current_step->success_message() |
|
1340 | - . '<br />' . $this->checkout->next_step->_instructions() |
|
1341 | - ); |
|
1342 | - } |
|
1343 | - // pack it up, pack it in... |
|
1344 | - $this->_setup_redirect(); |
|
1345 | - } |
|
1346 | - // dynamically creates hook point like: |
|
1347 | - // AHEE__Single_Page_Checkout__after_payment_options__process_reg_step |
|
1348 | - do_action( |
|
1349 | - "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", |
|
1350 | - $this->checkout->current_step |
|
1351 | - ); |
|
1352 | - } else { |
|
1353 | - EE_Error::add_error( |
|
1354 | - sprintf( |
|
1355 | - esc_html__( |
|
1356 | - 'The requested form action "%s" does not exist for the current "%s" registration step.', |
|
1357 | - 'event_espresso' |
|
1358 | - ), |
|
1359 | - $this->checkout->action, |
|
1360 | - $this->checkout->current_step->name() |
|
1361 | - ), |
|
1362 | - __FILE__, |
|
1363 | - __FUNCTION__, |
|
1364 | - __LINE__ |
|
1365 | - ); |
|
1366 | - } |
|
1367 | - // end default |
|
1368 | - } |
|
1369 | - // store our progress so far |
|
1370 | - $this->checkout->stash_transaction_and_checkout(); |
|
1371 | - // advance to the next step! If you pass GO, collect $200 |
|
1372 | - $this->go_to_next_step(); |
|
1373 | - } |
|
1374 | - |
|
1375 | - |
|
1376 | - /** |
|
1377 | - * add_styles_and_scripts |
|
1378 | - * |
|
1379 | - * @access public |
|
1380 | - * @return void |
|
1381 | - */ |
|
1382 | - public function add_styles_and_scripts() |
|
1383 | - { |
|
1384 | - // i18n |
|
1385 | - $this->translate_js_strings(); |
|
1386 | - if ($this->checkout->admin_request) { |
|
1387 | - add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1388 | - } else { |
|
1389 | - add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1390 | - } |
|
1391 | - } |
|
1392 | - |
|
1393 | - |
|
1394 | - /** |
|
1395 | - * translate_js_strings |
|
1396 | - * |
|
1397 | - * @access public |
|
1398 | - * @return void |
|
1399 | - */ |
|
1400 | - public function translate_js_strings() |
|
1401 | - { |
|
1402 | - EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit; |
|
1403 | - EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link; |
|
1404 | - EE_Registry::$i18n_js_strings['server_error'] = esc_html__( |
|
1405 | - 'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', |
|
1406 | - 'event_espresso' |
|
1407 | - ); |
|
1408 | - EE_Registry::$i18n_js_strings['invalid_json_response'] = esc_html__( |
|
1409 | - 'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', |
|
1410 | - 'event_espresso' |
|
1411 | - ); |
|
1412 | - EE_Registry::$i18n_js_strings['validation_error'] = esc_html__( |
|
1413 | - 'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', |
|
1414 | - 'event_espresso' |
|
1415 | - ); |
|
1416 | - EE_Registry::$i18n_js_strings['invalid_payment_method'] = esc_html__( |
|
1417 | - 'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', |
|
1418 | - 'event_espresso' |
|
1419 | - ); |
|
1420 | - EE_Registry::$i18n_js_strings['reg_step_error'] = esc_html__( |
|
1421 | - 'This registration step could not be completed. Please refresh the page and try again.', |
|
1422 | - 'event_espresso' |
|
1423 | - ); |
|
1424 | - EE_Registry::$i18n_js_strings['invalid_coupon'] = esc_html__( |
|
1425 | - 'We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', |
|
1426 | - 'event_espresso' |
|
1427 | - ); |
|
1428 | - EE_Registry::$i18n_js_strings['process_registration'] = sprintf( |
|
1429 | - esc_html__( |
|
1430 | - 'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', |
|
1431 | - 'event_espresso' |
|
1432 | - ), |
|
1433 | - '<br/>', |
|
1434 | - '<br/>' |
|
1435 | - ); |
|
1436 | - EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language'); |
|
1437 | - EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id(); |
|
1438 | - EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency; |
|
1439 | - EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20'; |
|
1440 | - EE_Registry::$i18n_js_strings['timer_years'] = esc_html__('years', 'event_espresso'); |
|
1441 | - EE_Registry::$i18n_js_strings['timer_months'] = esc_html__('months', 'event_espresso'); |
|
1442 | - EE_Registry::$i18n_js_strings['timer_weeks'] = esc_html__('weeks', 'event_espresso'); |
|
1443 | - EE_Registry::$i18n_js_strings['timer_days'] = esc_html__('days', 'event_espresso'); |
|
1444 | - EE_Registry::$i18n_js_strings['timer_hours'] = esc_html__('hours', 'event_espresso'); |
|
1445 | - EE_Registry::$i18n_js_strings['timer_minutes'] = esc_html__('minutes', 'event_espresso'); |
|
1446 | - EE_Registry::$i18n_js_strings['timer_seconds'] = esc_html__('seconds', 'event_espresso'); |
|
1447 | - EE_Registry::$i18n_js_strings['timer_year'] = esc_html__('year', 'event_espresso'); |
|
1448 | - EE_Registry::$i18n_js_strings['timer_month'] = esc_html__('month', 'event_espresso'); |
|
1449 | - EE_Registry::$i18n_js_strings['timer_week'] = esc_html__('week', 'event_espresso'); |
|
1450 | - EE_Registry::$i18n_js_strings['timer_day'] = esc_html__('day', 'event_espresso'); |
|
1451 | - EE_Registry::$i18n_js_strings['timer_hour'] = esc_html__('hour', 'event_espresso'); |
|
1452 | - EE_Registry::$i18n_js_strings['timer_minute'] = esc_html__('minute', 'event_espresso'); |
|
1453 | - EE_Registry::$i18n_js_strings['timer_second'] = esc_html__('second', 'event_espresso'); |
|
1454 | - EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice( |
|
1455 | - ); |
|
1456 | - EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters( |
|
1457 | - 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', |
|
1458 | - true |
|
1459 | - ); |
|
1460 | - EE_Registry::$i18n_js_strings['session_extension'] = absint( |
|
1461 | - apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS) |
|
1462 | - ); |
|
1463 | - EE_Registry::$i18n_js_strings['session_expiration'] = gmdate( |
|
1464 | - 'M d, Y H:i:s', |
|
1465 | - EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
1466 | - ); |
|
1467 | - } |
|
1468 | - |
|
1469 | - |
|
1470 | - /** |
|
1471 | - * enqueue_styles_and_scripts |
|
1472 | - * |
|
1473 | - * @access public |
|
1474 | - * @return void |
|
1475 | - * @throws EE_Error |
|
1476 | - */ |
|
1477 | - public function enqueue_styles_and_scripts() |
|
1478 | - { |
|
1479 | - // load css |
|
1480 | - wp_register_style( |
|
1481 | - 'single_page_checkout', |
|
1482 | - SPCO_CSS_URL . 'single_page_checkout.css', |
|
1483 | - array('espresso_default'), |
|
1484 | - EVENT_ESPRESSO_VERSION |
|
1485 | - ); |
|
1486 | - wp_enqueue_style('single_page_checkout'); |
|
1487 | - // load JS |
|
1488 | - wp_register_script( |
|
1489 | - 'jquery_plugin', |
|
1490 | - EE_THIRD_PARTY_URL . 'jquery .plugin.min.js', |
|
1491 | - array('jquery'), |
|
1492 | - '1.0.1', |
|
1493 | - true |
|
1494 | - ); |
|
1495 | - wp_register_script( |
|
1496 | - 'jquery_countdown', |
|
1497 | - EE_THIRD_PARTY_URL . 'jquery .countdown.min.js', |
|
1498 | - array('jquery_plugin'), |
|
1499 | - '2.1.0', |
|
1500 | - true |
|
1501 | - ); |
|
1502 | - wp_register_script( |
|
1503 | - 'single_page_checkout', |
|
1504 | - SPCO_JS_URL . 'single_page_checkout.js', |
|
1505 | - array('espresso_core', 'underscore', 'ee_form_section_validation'), |
|
1506 | - EVENT_ESPRESSO_VERSION, |
|
1507 | - true |
|
1508 | - ); |
|
1509 | - if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) { |
|
1510 | - $this->checkout->registration_form->enqueue_js(); |
|
1511 | - } |
|
1512 | - if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) { |
|
1513 | - $this->checkout->current_step->reg_form->enqueue_js(); |
|
1514 | - } |
|
1515 | - wp_enqueue_script('single_page_checkout'); |
|
1516 | - if (apply_filters('FHEE__registration_page_wrapper_template__display_time_limit', false)) { |
|
1517 | - wp_enqueue_script('jquery_countdown'); |
|
1518 | - } |
|
1519 | - /** |
|
1520 | - * global action hook for enqueueing styles and scripts with |
|
1521 | - * spco calls. |
|
1522 | - */ |
|
1523 | - do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this); |
|
1524 | - /** |
|
1525 | - * dynamic action hook for enqueueing styles and scripts with spco calls. |
|
1526 | - * The hook will end up being something like: |
|
1527 | - * AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
|
1528 | - */ |
|
1529 | - do_action( |
|
1530 | - 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), |
|
1531 | - $this |
|
1532 | - ); |
|
1533 | - } |
|
1534 | - |
|
1535 | - |
|
1536 | - /** |
|
1537 | - * display the Registration Single Page Checkout Form |
|
1538 | - * |
|
1539 | - * @access private |
|
1540 | - * @return void |
|
1541 | - * @throws EE_Error |
|
1542 | - */ |
|
1543 | - private function _display_spco_reg_form() |
|
1544 | - { |
|
1545 | - // if registering via the admin, just display the reg form for the current step |
|
1546 | - if ($this->checkout->admin_request) { |
|
1547 | - EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form()); |
|
1548 | - } else { |
|
1549 | - // add powered by EE msg |
|
1550 | - add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer')); |
|
1551 | - $empty_cart = count($this->checkout->transaction |
|
1552 | - ->registrations($this->checkout->reg_cache_where_params)) < 1; |
|
1553 | - EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart; |
|
1554 | - $cookies_not_set_msg = ''; |
|
1555 | - if ($empty_cart) { |
|
1556 | - $cookies_not_set_msg = apply_filters( |
|
1557 | - 'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg', |
|
1558 | - sprintf( |
|
1559 | - esc_html__( |
|
1560 | - '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', |
|
1561 | - 'event_espresso' |
|
1562 | - ), |
|
1563 | - '<div class="ee-attention hidden" id="ee-cookies-not-set-msg">', |
|
1564 | - '</div>', |
|
1565 | - '<h6 class="important-notice">', |
|
1566 | - '</h6>', |
|
1567 | - '<p>', |
|
1568 | - '</p>', |
|
1569 | - '<br />', |
|
1570 | - '<a href="http://www.whatarecookies.com/enable.asp" target="_blank" rel="noopener noreferrer">', |
|
1571 | - '</a>' |
|
1572 | - ) |
|
1573 | - ); |
|
1574 | - } |
|
1575 | - $this->checkout->registration_form = new EE_Form_Section_Proper( |
|
1576 | - array( |
|
1577 | - 'name' => 'single-page-checkout', |
|
1578 | - 'html_id' => 'ee-single-page-checkout-dv', |
|
1579 | - 'layout_strategy' => |
|
1580 | - new EE_Template_Layout( |
|
1581 | - array( |
|
1582 | - 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
1583 | - 'template_args' => array( |
|
1584 | - 'empty_cart' => $empty_cart, |
|
1585 | - 'revisit' => $this->checkout->revisit, |
|
1586 | - 'reg_steps' => $this->checkout->reg_steps, |
|
1587 | - 'next_step' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
|
1588 | - ? $this->checkout->next_step->slug() |
|
1589 | - : '', |
|
1590 | - 'empty_msg' => apply_filters( |
|
1591 | - 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
|
1592 | - sprintf( |
|
1593 | - esc_html__( |
|
1594 | - 'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', |
|
1595 | - 'event_espresso' |
|
1596 | - ), |
|
1597 | - '<a href="' |
|
1598 | - . get_post_type_archive_link('espresso_events') |
|
1599 | - . '" title="', |
|
1600 | - '">', |
|
1601 | - '</a>' |
|
1602 | - ) |
|
1603 | - ), |
|
1604 | - 'cookies_not_set_msg' => $cookies_not_set_msg, |
|
1605 | - 'registration_time_limit' => $this->checkout->get_registration_time_limit(), |
|
1606 | - 'session_expiration' => gmdate( |
|
1607 | - 'M d, Y H:i:s', |
|
1608 | - EE_Registry::instance()->SSN->expiration() |
|
1609 | - + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
1610 | - ), |
|
1611 | - ), |
|
1612 | - ) |
|
1613 | - ), |
|
1614 | - ) |
|
1615 | - ); |
|
1616 | - // load template and add to output sent that gets filtered into the_content() |
|
1617 | - EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html()); |
|
1618 | - } |
|
1619 | - } |
|
1620 | - |
|
1621 | - |
|
1622 | - /** |
|
1623 | - * add_extra_finalize_registration_inputs |
|
1624 | - * |
|
1625 | - * @access public |
|
1626 | - * @param $next_step |
|
1627 | - * @internal param string $label |
|
1628 | - * @return void |
|
1629 | - */ |
|
1630 | - public function add_extra_finalize_registration_inputs($next_step) |
|
1631 | - { |
|
1632 | - if ($next_step === 'finalize_registration') { |
|
1633 | - echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>'; |
|
1634 | - } |
|
1635 | - } |
|
1636 | - |
|
1637 | - |
|
1638 | - /** |
|
1639 | - * display_registration_footer |
|
1640 | - * |
|
1641 | - * @access public |
|
1642 | - * @return string |
|
1643 | - */ |
|
1644 | - public static function display_registration_footer() |
|
1645 | - { |
|
1646 | - if (apply_filters( |
|
1647 | - 'FHEE__EE_Front__Controller__show_reg_footer', |
|
1648 | - EE_Registry::instance()->CFG->admin->show_reg_footer |
|
1649 | - )) { |
|
1650 | - add_filter( |
|
1651 | - 'FHEE__EEH_Template__powered_by_event_espresso__url', |
|
1652 | - function ($url) { |
|
1653 | - return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
|
1654 | - } |
|
1655 | - ); |
|
1656 | - echo apply_filters( |
|
1657 | - 'FHEE__EE_Front_Controller__display_registration_footer', |
|
1658 | - \EEH_Template::powered_by_event_espresso( |
|
1659 | - '', |
|
1660 | - 'espresso-registration-footer-dv', |
|
1661 | - array('utm_content' => 'registration_checkout') |
|
1662 | - ) |
|
1663 | - ); |
|
1664 | - } |
|
1665 | - return ''; |
|
1666 | - } |
|
1667 | - |
|
1668 | - |
|
1669 | - /** |
|
1670 | - * unlock_transaction |
|
1671 | - * |
|
1672 | - * @access public |
|
1673 | - * @return void |
|
1674 | - * @throws EE_Error |
|
1675 | - */ |
|
1676 | - public function unlock_transaction() |
|
1677 | - { |
|
1678 | - if ($this->checkout->transaction instanceof EE_Transaction) { |
|
1679 | - $this->checkout->transaction->unlock(); |
|
1680 | - } |
|
1681 | - } |
|
1682 | - |
|
1683 | - |
|
1684 | - /** |
|
1685 | - * _setup_redirect |
|
1686 | - * |
|
1687 | - * @access private |
|
1688 | - * @return void |
|
1689 | - */ |
|
1690 | - private function _setup_redirect() |
|
1691 | - { |
|
1692 | - if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
1693 | - $this->checkout->redirect = true; |
|
1694 | - if (empty($this->checkout->redirect_url)) { |
|
1695 | - $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url(); |
|
1696 | - } |
|
1697 | - $this->checkout->redirect_url = apply_filters( |
|
1698 | - 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', |
|
1699 | - $this->checkout->redirect_url, |
|
1700 | - $this->checkout |
|
1701 | - ); |
|
1702 | - } |
|
1703 | - } |
|
1704 | - |
|
1705 | - |
|
1706 | - /** |
|
1707 | - * handle ajax message responses and redirects |
|
1708 | - * |
|
1709 | - * @access public |
|
1710 | - * @return void |
|
1711 | - * @throws EE_Error |
|
1712 | - */ |
|
1713 | - public function go_to_next_step() |
|
1714 | - { |
|
1715 | - if (EE_Registry::instance()->REQ->ajax) { |
|
1716 | - // capture contents of output buffer we started earlier in the request, and insert into JSON response |
|
1717 | - $this->checkout->json_response->set_unexpected_errors(ob_get_clean()); |
|
1718 | - } |
|
1719 | - $this->unlock_transaction(); |
|
1720 | - // just return for these conditions |
|
1721 | - if ($this->checkout->admin_request |
|
1722 | - || $this->checkout->action === 'redirect_form' |
|
1723 | - || $this->checkout->action === 'update_checkout' |
|
1724 | - ) { |
|
1725 | - return; |
|
1726 | - } |
|
1727 | - // AJAX response |
|
1728 | - $this->_handle_json_response(); |
|
1729 | - // redirect to next step or the Thank You page |
|
1730 | - $this->_handle_html_redirects(); |
|
1731 | - // hmmm... must be something wrong, so let's just display the form again ! |
|
1732 | - $this->_display_spco_reg_form(); |
|
1733 | - } |
|
1734 | - |
|
1735 | - |
|
1736 | - /** |
|
1737 | - * _handle_json_response |
|
1738 | - * |
|
1739 | - * @access protected |
|
1740 | - * @return void |
|
1741 | - */ |
|
1742 | - protected function _handle_json_response() |
|
1743 | - { |
|
1744 | - // if this is an ajax request |
|
1745 | - if (EE_Registry::instance()->REQ->ajax) { |
|
1746 | - $this->checkout->json_response->set_registration_time_limit( |
|
1747 | - $this->checkout->get_registration_time_limit() |
|
1748 | - ); |
|
1749 | - $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing); |
|
1750 | - // just send the ajax ( |
|
1751 | - $json_response = apply_filters( |
|
1752 | - 'FHEE__EE_Single_Page_Checkout__JSON_response', |
|
1753 | - $this->checkout->json_response |
|
1754 | - ); |
|
1755 | - echo $json_response; |
|
1756 | - exit(); |
|
1757 | - } |
|
1758 | - } |
|
1759 | - |
|
1760 | - |
|
1761 | - /** |
|
1762 | - * _handle_redirects |
|
1763 | - * |
|
1764 | - * @access protected |
|
1765 | - * @return void |
|
1766 | - */ |
|
1767 | - protected function _handle_html_redirects() |
|
1768 | - { |
|
1769 | - // going somewhere ? |
|
1770 | - if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) { |
|
1771 | - // store notices in a transient |
|
1772 | - EE_Error::get_notices(false, true, true); |
|
1773 | - wp_safe_redirect($this->checkout->redirect_url); |
|
1774 | - exit(); |
|
1775 | - } |
|
1776 | - } |
|
1777 | - |
|
1778 | - |
|
1779 | - /** |
|
1780 | - * set_checkout_anchor |
|
1781 | - * |
|
1782 | - * @access public |
|
1783 | - * @return void |
|
1784 | - */ |
|
1785 | - public function set_checkout_anchor() |
|
1786 | - { |
|
1787 | - echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>'; |
|
1788 | - } |
|
1789 | - |
|
1790 | - /** |
|
1791 | - * getRegistrationExpirationNotice |
|
1792 | - * |
|
1793 | - * @since 4.9.59.p |
|
1794 | - * @access public |
|
1795 | - * @return string |
|
1796 | - */ |
|
1797 | - public static function getRegistrationExpirationNotice() |
|
1798 | - { |
|
1799 | - return sprintf( |
|
1800 | - esc_html__( |
|
1801 | - '%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please accept our apologies for any inconvenience this may have caused.%8$s', |
|
1802 | - 'event_espresso' |
|
1803 | - ), |
|
1804 | - '<h4 class="important-notice">', |
|
1805 | - '</h4>', |
|
1806 | - '<br />', |
|
1807 | - '<p>', |
|
1808 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
1809 | - '">', |
|
1810 | - '</a>', |
|
1811 | - '</p>' |
|
1812 | - ); |
|
1813 | - } |
|
18 | + /** |
|
19 | + * $_initialized - has the SPCO controller already been initialized ? |
|
20 | + * |
|
21 | + * @access private |
|
22 | + * @var bool $_initialized |
|
23 | + */ |
|
24 | + private static $_initialized = false; |
|
25 | + |
|
26 | + |
|
27 | + /** |
|
28 | + * $_checkout_verified - is the EE_Checkout verified as correct for this request ? |
|
29 | + * |
|
30 | + * @access private |
|
31 | + * @var bool $_valid_checkout |
|
32 | + */ |
|
33 | + private static $_checkout_verified = true; |
|
34 | + |
|
35 | + /** |
|
36 | + * $_reg_steps_array - holds initial array of reg steps |
|
37 | + * |
|
38 | + * @access private |
|
39 | + * @var array $_reg_steps_array |
|
40 | + */ |
|
41 | + private static $_reg_steps_array = array(); |
|
42 | + |
|
43 | + /** |
|
44 | + * $checkout - EE_Checkout object for handling the properties of the current checkout process |
|
45 | + * |
|
46 | + * @access public |
|
47 | + * @var EE_Checkout $checkout |
|
48 | + */ |
|
49 | + public $checkout; |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * @return EED_Module|EED_Single_Page_Checkout |
|
54 | + */ |
|
55 | + public static function instance() |
|
56 | + { |
|
57 | + add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true'); |
|
58 | + return parent::get_instance(__CLASS__); |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * @return EE_CART |
|
64 | + */ |
|
65 | + public function cart() |
|
66 | + { |
|
67 | + return $this->checkout->cart; |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * @return EE_Transaction |
|
73 | + */ |
|
74 | + public function transaction() |
|
75 | + { |
|
76 | + return $this->checkout->transaction; |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
82 | + * |
|
83 | + * @access public |
|
84 | + * @return void |
|
85 | + * @throws EE_Error |
|
86 | + */ |
|
87 | + public static function set_hooks() |
|
88 | + { |
|
89 | + EED_Single_Page_Checkout::set_definitions(); |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
95 | + * |
|
96 | + * @access public |
|
97 | + * @return void |
|
98 | + * @throws EE_Error |
|
99 | + */ |
|
100 | + public static function set_hooks_admin() |
|
101 | + { |
|
102 | + EED_Single_Page_Checkout::set_definitions(); |
|
103 | + if (! (defined('DOING_AJAX') && DOING_AJAX)) { |
|
104 | + return; |
|
105 | + } |
|
106 | + // going to start an output buffer in case anything gets accidentally output |
|
107 | + // that might disrupt our JSON response |
|
108 | + ob_start(); |
|
109 | + EED_Single_Page_Checkout::load_request_handler(); |
|
110 | + EED_Single_Page_Checkout::load_reg_steps(); |
|
111 | + // set ajax hooks |
|
112 | + add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
113 | + add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
114 | + add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
115 | + add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
116 | + add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
117 | + add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + /** |
|
122 | + * process ajax request |
|
123 | + * |
|
124 | + * @param string $ajax_action |
|
125 | + * @throws EE_Error |
|
126 | + */ |
|
127 | + public static function process_ajax_request($ajax_action) |
|
128 | + { |
|
129 | + EE_Registry::instance()->REQ->set('action', $ajax_action); |
|
130 | + EED_Single_Page_Checkout::instance()->_initialize(); |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * ajax display registration step |
|
136 | + * |
|
137 | + * @throws EE_Error |
|
138 | + */ |
|
139 | + public static function display_reg_step() |
|
140 | + { |
|
141 | + EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step'); |
|
142 | + } |
|
143 | + |
|
144 | + |
|
145 | + /** |
|
146 | + * ajax process registration step |
|
147 | + * |
|
148 | + * @throws EE_Error |
|
149 | + */ |
|
150 | + public static function process_reg_step() |
|
151 | + { |
|
152 | + EED_Single_Page_Checkout::process_ajax_request('process_reg_step'); |
|
153 | + } |
|
154 | + |
|
155 | + |
|
156 | + /** |
|
157 | + * ajax process registration step |
|
158 | + * |
|
159 | + * @throws EE_Error |
|
160 | + */ |
|
161 | + public static function update_reg_step() |
|
162 | + { |
|
163 | + EED_Single_Page_Checkout::process_ajax_request('update_reg_step'); |
|
164 | + } |
|
165 | + |
|
166 | + |
|
167 | + /** |
|
168 | + * update_checkout |
|
169 | + * |
|
170 | + * @access public |
|
171 | + * @return void |
|
172 | + * @throws EE_Error |
|
173 | + */ |
|
174 | + public static function update_checkout() |
|
175 | + { |
|
176 | + EED_Single_Page_Checkout::process_ajax_request('update_checkout'); |
|
177 | + } |
|
178 | + |
|
179 | + |
|
180 | + /** |
|
181 | + * load_request_handler |
|
182 | + * |
|
183 | + * @access public |
|
184 | + * @return void |
|
185 | + */ |
|
186 | + public static function load_request_handler() |
|
187 | + { |
|
188 | + // load core Request_Handler class |
|
189 | + if (EE_Registry::instance()->REQ !== null) { |
|
190 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
191 | + } |
|
192 | + } |
|
193 | + |
|
194 | + |
|
195 | + /** |
|
196 | + * set_definitions |
|
197 | + * |
|
198 | + * @access public |
|
199 | + * @return void |
|
200 | + * @throws EE_Error |
|
201 | + */ |
|
202 | + public static function set_definitions() |
|
203 | + { |
|
204 | + if (defined('SPCO_BASE_PATH')) { |
|
205 | + return; |
|
206 | + } |
|
207 | + define( |
|
208 | + 'SPCO_BASE_PATH', |
|
209 | + rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS |
|
210 | + ); |
|
211 | + define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS); |
|
212 | + define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS); |
|
213 | + define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS); |
|
214 | + define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS); |
|
215 | + define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS); |
|
216 | + define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS); |
|
217 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true); |
|
218 | + EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice( |
|
219 | + ); |
|
220 | + } |
|
221 | + |
|
222 | + |
|
223 | + /** |
|
224 | + * load_reg_steps |
|
225 | + * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array |
|
226 | + * |
|
227 | + * @access private |
|
228 | + * @throws EE_Error |
|
229 | + */ |
|
230 | + public static function load_reg_steps() |
|
231 | + { |
|
232 | + static $reg_steps_loaded = false; |
|
233 | + if ($reg_steps_loaded) { |
|
234 | + return; |
|
235 | + } |
|
236 | + // filter list of reg_steps |
|
237 | + $reg_steps_to_load = (array) apply_filters( |
|
238 | + 'AHEE__SPCO__load_reg_steps__reg_steps_to_load', |
|
239 | + EED_Single_Page_Checkout::get_reg_steps() |
|
240 | + ); |
|
241 | + // sort by key (order) |
|
242 | + ksort($reg_steps_to_load); |
|
243 | + // loop through folders |
|
244 | + foreach ($reg_steps_to_load as $order => $reg_step) { |
|
245 | + // we need a |
|
246 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
247 | + // copy over to the reg_steps_array |
|
248 | + EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step; |
|
249 | + // register custom key route for each reg step |
|
250 | + // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
|
251 | + EE_Config::register_route( |
|
252 | + $reg_step['slug'], |
|
253 | + 'EED_Single_Page_Checkout', |
|
254 | + 'run', |
|
255 | + 'step' |
|
256 | + ); |
|
257 | + // add AJAX or other hooks |
|
258 | + if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
|
259 | + // setup autoloaders if necessary |
|
260 | + if (! class_exists($reg_step['class_name'])) { |
|
261 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder( |
|
262 | + $reg_step['file_path'], |
|
263 | + true |
|
264 | + ); |
|
265 | + } |
|
266 | + if (is_callable($reg_step['class_name'], 'set_hooks')) { |
|
267 | + call_user_func(array($reg_step['class_name'], 'set_hooks')); |
|
268 | + } |
|
269 | + } |
|
270 | + } |
|
271 | + } |
|
272 | + $reg_steps_loaded = true; |
|
273 | + } |
|
274 | + |
|
275 | + |
|
276 | + /** |
|
277 | + * get_reg_steps |
|
278 | + * |
|
279 | + * @access public |
|
280 | + * @return array |
|
281 | + */ |
|
282 | + public static function get_reg_steps() |
|
283 | + { |
|
284 | + $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps; |
|
285 | + if (empty($reg_steps)) { |
|
286 | + $reg_steps = array( |
|
287 | + 10 => array( |
|
288 | + 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
289 | + 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
|
290 | + 'slug' => 'attendee_information', |
|
291 | + 'has_hooks' => false, |
|
292 | + ), |
|
293 | + 30 => array( |
|
294 | + 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
295 | + 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
|
296 | + 'slug' => 'payment_options', |
|
297 | + 'has_hooks' => true, |
|
298 | + ), |
|
299 | + 999 => array( |
|
300 | + 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
301 | + 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
|
302 | + 'slug' => 'finalize_registration', |
|
303 | + 'has_hooks' => false, |
|
304 | + ), |
|
305 | + ); |
|
306 | + } |
|
307 | + return $reg_steps; |
|
308 | + } |
|
309 | + |
|
310 | + |
|
311 | + /** |
|
312 | + * registration_checkout_for_admin |
|
313 | + * |
|
314 | + * @access public |
|
315 | + * @return string |
|
316 | + * @throws EE_Error |
|
317 | + */ |
|
318 | + public static function registration_checkout_for_admin() |
|
319 | + { |
|
320 | + EED_Single_Page_Checkout::load_request_handler(); |
|
321 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
322 | + EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step'); |
|
323 | + EE_Registry::instance()->REQ->set('process_form_submission', false); |
|
324 | + EED_Single_Page_Checkout::instance()->_initialize(); |
|
325 | + EED_Single_Page_Checkout::instance()->_display_spco_reg_form(); |
|
326 | + return EE_Registry::instance()->REQ->get_output(); |
|
327 | + } |
|
328 | + |
|
329 | + |
|
330 | + /** |
|
331 | + * process_registration_from_admin |
|
332 | + * |
|
333 | + * @access public |
|
334 | + * @return \EE_Transaction |
|
335 | + * @throws EE_Error |
|
336 | + */ |
|
337 | + public static function process_registration_from_admin() |
|
338 | + { |
|
339 | + EED_Single_Page_Checkout::load_request_handler(); |
|
340 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
341 | + EE_Registry::instance()->REQ->set('action', 'process_reg_step'); |
|
342 | + EE_Registry::instance()->REQ->set('process_form_submission', true); |
|
343 | + EED_Single_Page_Checkout::instance()->_initialize(); |
|
344 | + if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) { |
|
345 | + $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps); |
|
346 | + if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
347 | + EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step); |
|
348 | + if ($final_reg_step->process_reg_step()) { |
|
349 | + $final_reg_step->set_completed(); |
|
350 | + EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array(); |
|
351 | + return EED_Single_Page_Checkout::instance()->checkout->transaction; |
|
352 | + } |
|
353 | + } |
|
354 | + } |
|
355 | + return null; |
|
356 | + } |
|
357 | + |
|
358 | + |
|
359 | + /** |
|
360 | + * run |
|
361 | + * |
|
362 | + * @access public |
|
363 | + * @param WP_Query $WP_Query |
|
364 | + * @return void |
|
365 | + * @throws EE_Error |
|
366 | + */ |
|
367 | + public function run($WP_Query) |
|
368 | + { |
|
369 | + if ($WP_Query instanceof WP_Query |
|
370 | + && $WP_Query->is_main_query() |
|
371 | + && apply_filters('FHEE__EED_Single_Page_Checkout__run', true) |
|
372 | + && $this->_is_reg_checkout() |
|
373 | + ) { |
|
374 | + $this->_initialize(); |
|
375 | + } |
|
376 | + } |
|
377 | + |
|
378 | + |
|
379 | + /** |
|
380 | + * determines whether current url matches reg page url |
|
381 | + * |
|
382 | + * @return bool |
|
383 | + */ |
|
384 | + protected function _is_reg_checkout() |
|
385 | + { |
|
386 | + // get current permalink for reg page without any extra query args |
|
387 | + $reg_page_url = \get_permalink(EE_Config::instance()->core->reg_page_id); |
|
388 | + // get request URI for current request, but without the scheme or host |
|
389 | + $current_request_uri = \EEH_URL::filter_input_server_url('REQUEST_URI'); |
|
390 | + $current_request_uri = html_entity_decode($current_request_uri); |
|
391 | + // get array of query args from the current request URI |
|
392 | + $query_args = \EEH_URL::get_query_string($current_request_uri); |
|
393 | + // grab page id if it is set |
|
394 | + $page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0; |
|
395 | + // and remove the page id from the query args (we will re-add it later) |
|
396 | + unset($query_args['page_id']); |
|
397 | + // now strip all query args from current request URI |
|
398 | + $current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri); |
|
399 | + // and re-add the page id if it was set |
|
400 | + if ($page_id) { |
|
401 | + $current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri); |
|
402 | + } |
|
403 | + // remove slashes and ? |
|
404 | + $current_request_uri = trim($current_request_uri, '?/'); |
|
405 | + // is current request URI part of the known full reg page URL ? |
|
406 | + return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false; |
|
407 | + } |
|
408 | + |
|
409 | + |
|
410 | + /** |
|
411 | + * @param WP_Query $wp_query |
|
412 | + * @return void |
|
413 | + * @throws EE_Error |
|
414 | + */ |
|
415 | + public static function init($wp_query) |
|
416 | + { |
|
417 | + EED_Single_Page_Checkout::instance()->run($wp_query); |
|
418 | + } |
|
419 | + |
|
420 | + |
|
421 | + /** |
|
422 | + * _initialize - initial module setup |
|
423 | + * |
|
424 | + * @access private |
|
425 | + * @throws EE_Error |
|
426 | + * @return void |
|
427 | + */ |
|
428 | + private function _initialize() |
|
429 | + { |
|
430 | + // ensure SPCO doesn't run twice |
|
431 | + if (EED_Single_Page_Checkout::$_initialized) { |
|
432 | + return; |
|
433 | + } |
|
434 | + try { |
|
435 | + EED_Single_Page_Checkout::load_reg_steps(); |
|
436 | + $this->_verify_session(); |
|
437 | + // setup the EE_Checkout object |
|
438 | + $this->checkout = $this->_initialize_checkout(); |
|
439 | + // filter checkout |
|
440 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); |
|
441 | + // get the $_GET |
|
442 | + $this->_get_request_vars(); |
|
443 | + if ($this->_block_bots()) { |
|
444 | + return; |
|
445 | + } |
|
446 | + // filter continue_reg |
|
447 | + $this->checkout->continue_reg = apply_filters( |
|
448 | + 'FHEE__EED_Single_Page_Checkout__init___continue_reg', |
|
449 | + true, |
|
450 | + $this->checkout |
|
451 | + ); |
|
452 | + // load the reg steps array |
|
453 | + if (! $this->_load_and_instantiate_reg_steps()) { |
|
454 | + EED_Single_Page_Checkout::$_initialized = true; |
|
455 | + return; |
|
456 | + } |
|
457 | + // set the current step |
|
458 | + $this->checkout->set_current_step($this->checkout->step); |
|
459 | + // and the next step |
|
460 | + $this->checkout->set_next_step(); |
|
461 | + // verify that everything has been setup correctly |
|
462 | + if (! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) { |
|
463 | + EED_Single_Page_Checkout::$_initialized = true; |
|
464 | + return; |
|
465 | + } |
|
466 | + // lock the transaction |
|
467 | + $this->checkout->transaction->lock(); |
|
468 | + // make sure all of our cached objects are added to their respective model entity mappers |
|
469 | + $this->checkout->refresh_all_entities(); |
|
470 | + // set amount owing |
|
471 | + $this->checkout->amount_owing = $this->checkout->transaction->remaining(); |
|
472 | + // initialize each reg step, which gives them the chance to potentially alter the process |
|
473 | + $this->_initialize_reg_steps(); |
|
474 | + // DEBUG LOG |
|
475 | + // $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
|
476 | + // get reg form |
|
477 | + if (! $this->_check_form_submission()) { |
|
478 | + EED_Single_Page_Checkout::$_initialized = true; |
|
479 | + return; |
|
480 | + } |
|
481 | + // checkout the action!!! |
|
482 | + $this->_process_form_action(); |
|
483 | + // add some style and make it dance |
|
484 | + $this->add_styles_and_scripts(); |
|
485 | + // kk... SPCO has successfully run |
|
486 | + EED_Single_Page_Checkout::$_initialized = true; |
|
487 | + // set no cache headers and constants |
|
488 | + EE_System::do_not_cache(); |
|
489 | + // add anchor |
|
490 | + add_action('loop_start', array($this, 'set_checkout_anchor'), 1); |
|
491 | + // remove transaction lock |
|
492 | + add_action('shutdown', array($this, 'unlock_transaction'), 1); |
|
493 | + } catch (Exception $e) { |
|
494 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
495 | + } |
|
496 | + } |
|
497 | + |
|
498 | + |
|
499 | + /** |
|
500 | + * _verify_session |
|
501 | + * checks that the session is valid and not expired |
|
502 | + * |
|
503 | + * @access private |
|
504 | + * @throws EE_Error |
|
505 | + */ |
|
506 | + private function _verify_session() |
|
507 | + { |
|
508 | + if (! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
509 | + throw new EE_Error(esc_html__('The EE_Session class could not be loaded.', 'event_espresso')); |
|
510 | + } |
|
511 | + $clear_session_requested = filter_var( |
|
512 | + EE_Registry::instance()->REQ->get('clear_session', false), |
|
513 | + FILTER_VALIDATE_BOOLEAN |
|
514 | + ); |
|
515 | + // is session still valid ? |
|
516 | + if ($clear_session_requested |
|
517 | + || (EE_Registry::instance()->SSN->expired() |
|
518 | + && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === '' |
|
519 | + ) |
|
520 | + ) { |
|
521 | + $this->checkout = new EE_Checkout(); |
|
522 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
523 | + // EE_Registry::instance()->SSN->reset_cart(); |
|
524 | + // EE_Registry::instance()->SSN->reset_checkout(); |
|
525 | + // EE_Registry::instance()->SSN->reset_transaction(); |
|
526 | + if (! $clear_session_requested) { |
|
527 | + EE_Error::add_attention( |
|
528 | + EE_Registry::$i18n_js_strings['registration_expiration_notice'], |
|
529 | + __FILE__, |
|
530 | + __FUNCTION__, |
|
531 | + __LINE__ |
|
532 | + ); |
|
533 | + } |
|
534 | + // EE_Registry::instance()->SSN->reset_expired(); |
|
535 | + } |
|
536 | + } |
|
537 | + |
|
538 | + |
|
539 | + /** |
|
540 | + * _initialize_checkout |
|
541 | + * loads and instantiates EE_Checkout |
|
542 | + * |
|
543 | + * @access private |
|
544 | + * @throws EE_Error |
|
545 | + * @return EE_Checkout |
|
546 | + */ |
|
547 | + private function _initialize_checkout() |
|
548 | + { |
|
549 | + // look in session for existing checkout |
|
550 | + /** @type EE_Checkout $checkout */ |
|
551 | + $checkout = EE_Registry::instance()->SSN->checkout(); |
|
552 | + // verify |
|
553 | + if (! $checkout instanceof EE_Checkout) { |
|
554 | + // instantiate EE_Checkout object for handling the properties of the current checkout process |
|
555 | + $checkout = EE_Registry::instance()->load_file( |
|
556 | + SPCO_INC_PATH, |
|
557 | + 'EE_Checkout', |
|
558 | + 'class', |
|
559 | + array(), |
|
560 | + false |
|
561 | + ); |
|
562 | + } else { |
|
563 | + if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) { |
|
564 | + $this->unlock_transaction(); |
|
565 | + wp_safe_redirect($checkout->redirect_url); |
|
566 | + exit(); |
|
567 | + } |
|
568 | + } |
|
569 | + $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
|
570 | + // verify again |
|
571 | + if (! $checkout instanceof EE_Checkout) { |
|
572 | + throw new EE_Error(esc_html__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
|
573 | + } |
|
574 | + // reset anything that needs a clean slate for each request |
|
575 | + $checkout->reset_for_current_request(); |
|
576 | + return $checkout; |
|
577 | + } |
|
578 | + |
|
579 | + |
|
580 | + /** |
|
581 | + * _get_request_vars |
|
582 | + * |
|
583 | + * @access private |
|
584 | + * @return void |
|
585 | + * @throws EE_Error |
|
586 | + */ |
|
587 | + private function _get_request_vars() |
|
588 | + { |
|
589 | + // load classes |
|
590 | + EED_Single_Page_Checkout::load_request_handler(); |
|
591 | + // make sure this request is marked as belonging to EE |
|
592 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
593 | + // which step is being requested ? |
|
594 | + $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step()); |
|
595 | + // which step is being edited ? |
|
596 | + $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', ''); |
|
597 | + // and what we're doing on the current step |
|
598 | + $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step'); |
|
599 | + // timestamp |
|
600 | + $this->checkout->uts = EE_Registry::instance()->REQ->get('uts', 0); |
|
601 | + // returning to edit ? |
|
602 | + $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', ''); |
|
603 | + // add reg url link to registration query params |
|
604 | + if ($this->checkout->reg_url_link && strpos($this->checkout->reg_url_link, '1-') !== 0) { |
|
605 | + $this->checkout->reg_cache_where_params[0]['REG_url_link'] = $this->checkout->reg_url_link; |
|
606 | + } |
|
607 | + // or some other kind of revisit ? |
|
608 | + $this->checkout->revisit = filter_var( |
|
609 | + EE_Registry::instance()->REQ->get('revisit', false), |
|
610 | + FILTER_VALIDATE_BOOLEAN |
|
611 | + ); |
|
612 | + // and whether or not to generate a reg form for this request |
|
613 | + $this->checkout->generate_reg_form = filter_var( |
|
614 | + EE_Registry::instance()->REQ->get('generate_reg_form', true), |
|
615 | + FILTER_VALIDATE_BOOLEAN |
|
616 | + ); |
|
617 | + // and whether or not to process a reg form submission for this request |
|
618 | + $this->checkout->process_form_submission = filter_var( |
|
619 | + EE_Registry::instance()->REQ->get( |
|
620 | + 'process_form_submission', |
|
621 | + $this->checkout->action === 'process_reg_step' |
|
622 | + ), |
|
623 | + FILTER_VALIDATE_BOOLEAN |
|
624 | + ); |
|
625 | + $this->checkout->process_form_submission = filter_var( |
|
626 | + $this->checkout->action !== 'display_spco_reg_step' |
|
627 | + ? $this->checkout->process_form_submission |
|
628 | + : false, |
|
629 | + FILTER_VALIDATE_BOOLEAN |
|
630 | + ); |
|
631 | + // $this->_display_request_vars(); |
|
632 | + } |
|
633 | + |
|
634 | + |
|
635 | + /** |
|
636 | + * _display_request_vars |
|
637 | + * |
|
638 | + * @access protected |
|
639 | + * @return void |
|
640 | + */ |
|
641 | + protected function _display_request_vars() |
|
642 | + { |
|
643 | + if (! WP_DEBUG) { |
|
644 | + return; |
|
645 | + } |
|
646 | + EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__); |
|
647 | + EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__); |
|
648 | + EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__); |
|
649 | + EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__); |
|
650 | + EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__); |
|
651 | + EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__); |
|
652 | + EEH_Debug_Tools::printr( |
|
653 | + $this->checkout->generate_reg_form, |
|
654 | + '$this->checkout->generate_reg_form', |
|
655 | + __FILE__, |
|
656 | + __LINE__ |
|
657 | + ); |
|
658 | + EEH_Debug_Tools::printr( |
|
659 | + $this->checkout->process_form_submission, |
|
660 | + '$this->checkout->process_form_submission', |
|
661 | + __FILE__, |
|
662 | + __LINE__ |
|
663 | + ); |
|
664 | + } |
|
665 | + |
|
666 | + |
|
667 | + /** |
|
668 | + * _block_bots |
|
669 | + * checks that the incoming request has either of the following set: |
|
670 | + * a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector |
|
671 | + * a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN |
|
672 | + * so if you're not coming from the Ticket Selector nor returning for a valid IP... |
|
673 | + * then where you coming from man? |
|
674 | + * |
|
675 | + * @return boolean |
|
676 | + */ |
|
677 | + private function _block_bots() |
|
678 | + { |
|
679 | + $invalid_checkout_access = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
680 | + if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) { |
|
681 | + return true; |
|
682 | + } |
|
683 | + return false; |
|
684 | + } |
|
685 | + |
|
686 | + |
|
687 | + /** |
|
688 | + * _get_first_step |
|
689 | + * gets slug for first step in $_reg_steps_array |
|
690 | + * |
|
691 | + * @access private |
|
692 | + * @throws EE_Error |
|
693 | + * @return string |
|
694 | + */ |
|
695 | + private function _get_first_step() |
|
696 | + { |
|
697 | + $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array); |
|
698 | + return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information'; |
|
699 | + } |
|
700 | + |
|
701 | + |
|
702 | + /** |
|
703 | + * instantiates each reg step based on the loaded reg_steps array |
|
704 | + * |
|
705 | + * @return bool |
|
706 | + * @throws EE_Error |
|
707 | + * @throws InvalidArgumentException |
|
708 | + * @throws InvalidDataTypeException |
|
709 | + * @throws InvalidInterfaceException |
|
710 | + */ |
|
711 | + private function _load_and_instantiate_reg_steps() |
|
712 | + { |
|
713 | + do_action('AHEE__Single_Page_Checkout___load_and_instantiate_reg_steps__start', $this->checkout); |
|
714 | + // have reg_steps already been instantiated ? |
|
715 | + if (empty($this->checkout->reg_steps) |
|
716 | + || apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout) |
|
717 | + ) { |
|
718 | + // if not, then loop through raw reg steps array |
|
719 | + foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
|
720 | + if (! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
721 | + return false; |
|
722 | + } |
|
723 | + } |
|
724 | + if (isset($this->checkout->reg_steps['registration_confirmation'])) { |
|
725 | + // skip the registration_confirmation page ? |
|
726 | + if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) { |
|
727 | + // just remove it from the reg steps array |
|
728 | + $this->checkout->remove_reg_step('registration_confirmation', false); |
|
729 | + } elseif (EE_Registry::instance()->CFG->registration->reg_confirmation_last |
|
730 | + ) { |
|
731 | + // set the order to something big like 100 |
|
732 | + $this->checkout->set_reg_step_order('registration_confirmation', 100); |
|
733 | + } |
|
734 | + } |
|
735 | + // filter the array for good luck |
|
736 | + $this->checkout->reg_steps = apply_filters( |
|
737 | + 'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps', |
|
738 | + $this->checkout->reg_steps |
|
739 | + ); |
|
740 | + // finally re-sort based on the reg step class order properties |
|
741 | + $this->checkout->sort_reg_steps(); |
|
742 | + } else { |
|
743 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
744 | + // set all current step stati to FALSE |
|
745 | + $reg_step->set_is_current_step(false); |
|
746 | + } |
|
747 | + } |
|
748 | + if (empty($this->checkout->reg_steps)) { |
|
749 | + EE_Error::add_error( |
|
750 | + esc_html__('No Reg Steps were loaded..', 'event_espresso'), |
|
751 | + __FILE__, |
|
752 | + __FUNCTION__, |
|
753 | + __LINE__ |
|
754 | + ); |
|
755 | + return false; |
|
756 | + } |
|
757 | + // make reg step details available to JS |
|
758 | + $this->checkout->set_reg_step_JSON_info(); |
|
759 | + return true; |
|
760 | + } |
|
761 | + |
|
762 | + |
|
763 | + /** |
|
764 | + * _load_and_instantiate_reg_step |
|
765 | + * |
|
766 | + * @access private |
|
767 | + * @param array $reg_step |
|
768 | + * @param int $order |
|
769 | + * @return bool |
|
770 | + */ |
|
771 | + private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) |
|
772 | + { |
|
773 | + // we need a file_path, class_name, and slug to add a reg step |
|
774 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
775 | + // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
|
776 | + if ($this->checkout->reg_url_link |
|
777 | + && $this->checkout->step !== $reg_step['slug'] |
|
778 | + && $reg_step['slug'] !== 'finalize_registration' |
|
779 | + // normally at this point we would NOT load the reg step, but this filter can change that |
|
780 | + && apply_filters( |
|
781 | + 'FHEE__Single_Page_Checkout___load_and_instantiate_reg_step__bypass_reg_step', |
|
782 | + true, |
|
783 | + $reg_step, |
|
784 | + $this->checkout |
|
785 | + ) |
|
786 | + ) { |
|
787 | + return true; |
|
788 | + } |
|
789 | + // instantiate step class using file path and class name |
|
790 | + $reg_step_obj = EE_Registry::instance()->load_file( |
|
791 | + $reg_step['file_path'], |
|
792 | + $reg_step['class_name'], |
|
793 | + 'class', |
|
794 | + $this->checkout, |
|
795 | + false |
|
796 | + ); |
|
797 | + // did we gets the goods ? |
|
798 | + if ($reg_step_obj instanceof EE_SPCO_Reg_Step) { |
|
799 | + // set reg step order based on config |
|
800 | + $reg_step_obj->set_order($order); |
|
801 | + // add instantiated reg step object to the master reg steps array |
|
802 | + $this->checkout->add_reg_step($reg_step_obj); |
|
803 | + } else { |
|
804 | + EE_Error::add_error( |
|
805 | + esc_html__('The current step could not be set.', 'event_espresso'), |
|
806 | + __FILE__, |
|
807 | + __FUNCTION__, |
|
808 | + __LINE__ |
|
809 | + ); |
|
810 | + return false; |
|
811 | + } |
|
812 | + } else { |
|
813 | + if (WP_DEBUG) { |
|
814 | + EE_Error::add_error( |
|
815 | + sprintf( |
|
816 | + esc_html__( |
|
817 | + 'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', |
|
818 | + 'event_espresso' |
|
819 | + ), |
|
820 | + isset($reg_step['file_path']) ? $reg_step['file_path'] : '', |
|
821 | + isset($reg_step['class_name']) ? $reg_step['class_name'] : '', |
|
822 | + isset($reg_step['slug']) ? $reg_step['slug'] : '', |
|
823 | + '<ul>', |
|
824 | + '<li>', |
|
825 | + '</li>', |
|
826 | + '</ul>' |
|
827 | + ), |
|
828 | + __FILE__, |
|
829 | + __FUNCTION__, |
|
830 | + __LINE__ |
|
831 | + ); |
|
832 | + } |
|
833 | + return false; |
|
834 | + } |
|
835 | + return true; |
|
836 | + } |
|
837 | + |
|
838 | + |
|
839 | + /** |
|
840 | + * _verify_transaction_and_get_registrations |
|
841 | + * |
|
842 | + * @access private |
|
843 | + * @return bool |
|
844 | + * @throws InvalidDataTypeException |
|
845 | + * @throws InvalidEntityException |
|
846 | + * @throws EE_Error |
|
847 | + */ |
|
848 | + private function _verify_transaction_and_get_registrations() |
|
849 | + { |
|
850 | + // was there already a valid transaction in the checkout from the session ? |
|
851 | + if (! $this->checkout->transaction instanceof EE_Transaction) { |
|
852 | + // get transaction from db or session |
|
853 | + $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
|
854 | + ? $this->_get_transaction_and_cart_for_previous_visit() |
|
855 | + : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
|
856 | + if (! $this->checkout->transaction instanceof EE_Transaction) { |
|
857 | + EE_Error::add_error( |
|
858 | + esc_html__( |
|
859 | + 'Your Registration and Transaction information could not be retrieved from the db.', |
|
860 | + 'event_espresso' |
|
861 | + ), |
|
862 | + __FILE__, |
|
863 | + __FUNCTION__, |
|
864 | + __LINE__ |
|
865 | + ); |
|
866 | + $this->checkout->transaction = EE_Transaction::new_instance(); |
|
867 | + // add some style and make it dance |
|
868 | + $this->add_styles_and_scripts(); |
|
869 | + EED_Single_Page_Checkout::$_initialized = true; |
|
870 | + return false; |
|
871 | + } |
|
872 | + // and the registrations for the transaction |
|
873 | + $this->_get_registrations($this->checkout->transaction); |
|
874 | + } |
|
875 | + return true; |
|
876 | + } |
|
877 | + |
|
878 | + |
|
879 | + /** |
|
880 | + * _get_transaction_and_cart_for_previous_visit |
|
881 | + * |
|
882 | + * @access private |
|
883 | + * @return mixed EE_Transaction|NULL |
|
884 | + */ |
|
885 | + private function _get_transaction_and_cart_for_previous_visit() |
|
886 | + { |
|
887 | + /** @var $TXN_model EEM_Transaction */ |
|
888 | + $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
889 | + // because the reg_url_link is present in the request, |
|
890 | + // this is a return visit to SPCO, so we'll get the transaction data from the db |
|
891 | + $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link); |
|
892 | + // verify transaction |
|
893 | + if ($transaction instanceof EE_Transaction) { |
|
894 | + // and get the cart that was used for that transaction |
|
895 | + $this->checkout->cart = $this->_get_cart_for_transaction($transaction); |
|
896 | + return $transaction; |
|
897 | + } |
|
898 | + EE_Error::add_error( |
|
899 | + esc_html__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), |
|
900 | + __FILE__, |
|
901 | + __FUNCTION__, |
|
902 | + __LINE__ |
|
903 | + ); |
|
904 | + return null; |
|
905 | + } |
|
906 | + |
|
907 | + |
|
908 | + /** |
|
909 | + * _get_cart_for_transaction |
|
910 | + * |
|
911 | + * @access private |
|
912 | + * @param EE_Transaction $transaction |
|
913 | + * @return EE_Cart |
|
914 | + */ |
|
915 | + private function _get_cart_for_transaction($transaction) |
|
916 | + { |
|
917 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
918 | + } |
|
919 | + |
|
920 | + |
|
921 | + /** |
|
922 | + * get_cart_for_transaction |
|
923 | + * |
|
924 | + * @access public |
|
925 | + * @param EE_Transaction $transaction |
|
926 | + * @return EE_Cart |
|
927 | + */ |
|
928 | + public function get_cart_for_transaction(EE_Transaction $transaction) |
|
929 | + { |
|
930 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
931 | + } |
|
932 | + |
|
933 | + |
|
934 | + /** |
|
935 | + * _get_transaction_and_cart_for_current_session |
|
936 | + * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
937 | + * |
|
938 | + * @access private |
|
939 | + * @return EE_Transaction |
|
940 | + * @throws EE_Error |
|
941 | + */ |
|
942 | + private function _get_cart_for_current_session_and_setup_new_transaction() |
|
943 | + { |
|
944 | + // if there's no transaction, then this is the FIRST visit to SPCO |
|
945 | + // so load up the cart ( passing nothing for the TXN because it doesn't exist yet ) |
|
946 | + $this->checkout->cart = $this->_get_cart_for_transaction(null); |
|
947 | + // and then create a new transaction |
|
948 | + $transaction = $this->_initialize_transaction(); |
|
949 | + // verify transaction |
|
950 | + if ($transaction instanceof EE_Transaction) { |
|
951 | + // save it so that we have an ID for other objects to use |
|
952 | + $transaction->save(); |
|
953 | + // and save TXN data to the cart |
|
954 | + $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID()); |
|
955 | + } else { |
|
956 | + EE_Error::add_error( |
|
957 | + esc_html__('A Valid Transaction could not be initialized.', 'event_espresso'), |
|
958 | + __FILE__, |
|
959 | + __FUNCTION__, |
|
960 | + __LINE__ |
|
961 | + ); |
|
962 | + } |
|
963 | + return $transaction; |
|
964 | + } |
|
965 | + |
|
966 | + |
|
967 | + /** |
|
968 | + * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
969 | + * |
|
970 | + * @access private |
|
971 | + * @return mixed EE_Transaction|NULL |
|
972 | + */ |
|
973 | + private function _initialize_transaction() |
|
974 | + { |
|
975 | + try { |
|
976 | + // ensure cart totals have been calculated |
|
977 | + $this->checkout->cart->get_grand_total()->recalculate_total_including_taxes(); |
|
978 | + // grab the cart grand total |
|
979 | + $cart_total = $this->checkout->cart->get_cart_grand_total(); |
|
980 | + // create new TXN |
|
981 | + $transaction = EE_Transaction::new_instance( |
|
982 | + array( |
|
983 | + 'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(), |
|
984 | + 'TXN_total' => $cart_total > 0 ? $cart_total : 0, |
|
985 | + 'TXN_paid' => 0, |
|
986 | + 'STS_ID' => EEM_Transaction::failed_status_code, |
|
987 | + ) |
|
988 | + ); |
|
989 | + // save it so that we have an ID for other objects to use |
|
990 | + $transaction->save(); |
|
991 | + // set cron job for following up on TXNs after their session has expired |
|
992 | + EE_Cron_Tasks::schedule_expired_transaction_check( |
|
993 | + EE_Registry::instance()->SSN->expiration() + 1, |
|
994 | + $transaction->ID() |
|
995 | + ); |
|
996 | + return $transaction; |
|
997 | + } catch (Exception $e) { |
|
998 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
999 | + } |
|
1000 | + return null; |
|
1001 | + } |
|
1002 | + |
|
1003 | + |
|
1004 | + /** |
|
1005 | + * _get_registrations |
|
1006 | + * |
|
1007 | + * @access private |
|
1008 | + * @param EE_Transaction $transaction |
|
1009 | + * @return void |
|
1010 | + * @throws InvalidDataTypeException |
|
1011 | + * @throws InvalidEntityException |
|
1012 | + * @throws EE_Error |
|
1013 | + */ |
|
1014 | + private function _get_registrations(EE_Transaction $transaction) |
|
1015 | + { |
|
1016 | + // first step: grab the registrants { : o |
|
1017 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
1018 | + $this->checkout->total_ticket_count = count($registrations); |
|
1019 | + // verify registrations have been set |
|
1020 | + if (empty($registrations)) { |
|
1021 | + // if no cached registrations, then check the db |
|
1022 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
1023 | + // still nothing ? well as long as this isn't a revisit |
|
1024 | + if (empty($registrations) && ! $this->checkout->revisit) { |
|
1025 | + // generate new registrations from scratch |
|
1026 | + $registrations = $this->_initialize_registrations($transaction); |
|
1027 | + } |
|
1028 | + } |
|
1029 | + // sort by their original registration order |
|
1030 | + usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count')); |
|
1031 | + // then loop thru the array |
|
1032 | + foreach ($registrations as $registration) { |
|
1033 | + // verify each registration |
|
1034 | + if ($registration instanceof EE_Registration) { |
|
1035 | + // we display all attendee info for the primary registrant |
|
1036 | + if ($this->checkout->reg_url_link === $registration->reg_url_link() |
|
1037 | + && $registration->is_primary_registrant() |
|
1038 | + ) { |
|
1039 | + $this->checkout->primary_revisit = true; |
|
1040 | + break; |
|
1041 | + } |
|
1042 | + if ($this->checkout->revisit && $this->checkout->reg_url_link !== $registration->reg_url_link()) { |
|
1043 | + // but hide info if it doesn't belong to you |
|
1044 | + $transaction->clear_cache('Registration', $registration->ID()); |
|
1045 | + $this->checkout->total_ticket_count--; |
|
1046 | + } |
|
1047 | + $this->checkout->set_reg_status_updated($registration->ID(), false); |
|
1048 | + } |
|
1049 | + } |
|
1050 | + } |
|
1051 | + |
|
1052 | + |
|
1053 | + /** |
|
1054 | + * adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object |
|
1055 | + * |
|
1056 | + * @access private |
|
1057 | + * @param EE_Transaction $transaction |
|
1058 | + * @return array |
|
1059 | + * @throws InvalidDataTypeException |
|
1060 | + * @throws InvalidEntityException |
|
1061 | + * @throws EE_Error |
|
1062 | + */ |
|
1063 | + private function _initialize_registrations(EE_Transaction $transaction) |
|
1064 | + { |
|
1065 | + $att_nmbr = 0; |
|
1066 | + $registrations = array(); |
|
1067 | + if ($transaction instanceof EE_Transaction) { |
|
1068 | + /** @type EE_Registration_Processor $registration_processor */ |
|
1069 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1070 | + $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count(); |
|
1071 | + // now let's add the cart items to the $transaction |
|
1072 | + foreach ($this->checkout->cart->get_tickets() as $line_item) { |
|
1073 | + // do the following for each ticket of this type they selected |
|
1074 | + for ($x = 1; $x <= $line_item->quantity(); $x++) { |
|
1075 | + $att_nmbr++; |
|
1076 | + /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */ |
|
1077 | + $CreateRegistrationCommand = EE_Registry::instance()->create( |
|
1078 | + 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
1079 | + array( |
|
1080 | + $transaction, |
|
1081 | + $line_item, |
|
1082 | + $att_nmbr, |
|
1083 | + $this->checkout->total_ticket_count, |
|
1084 | + ) |
|
1085 | + ); |
|
1086 | + // override capabilities for frontend registrations |
|
1087 | + if (! is_admin()) { |
|
1088 | + $CreateRegistrationCommand->setCapCheck( |
|
1089 | + new PublicCapabilities('', 'create_new_registration') |
|
1090 | + ); |
|
1091 | + } |
|
1092 | + $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand); |
|
1093 | + if (! $registration instanceof EE_Registration) { |
|
1094 | + throw new InvalidEntityException($registration, 'EE_Registration'); |
|
1095 | + } |
|
1096 | + $registrations[ $registration->ID() ] = $registration; |
|
1097 | + } |
|
1098 | + } |
|
1099 | + $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
|
1100 | + } |
|
1101 | + return $registrations; |
|
1102 | + } |
|
1103 | + |
|
1104 | + |
|
1105 | + /** |
|
1106 | + * sorts registrations by REG_count |
|
1107 | + * |
|
1108 | + * @access public |
|
1109 | + * @param EE_Registration $reg_A |
|
1110 | + * @param EE_Registration $reg_B |
|
1111 | + * @return int |
|
1112 | + */ |
|
1113 | + public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) |
|
1114 | + { |
|
1115 | + // this shouldn't ever happen within the same TXN, but oh well |
|
1116 | + if ($reg_A->count() === $reg_B->count()) { |
|
1117 | + return 0; |
|
1118 | + } |
|
1119 | + return ($reg_A->count() > $reg_B->count()) ? 1 : -1; |
|
1120 | + } |
|
1121 | + |
|
1122 | + |
|
1123 | + /** |
|
1124 | + * _final_verifications |
|
1125 | + * just makes sure that everything is set up correctly before proceeding |
|
1126 | + * |
|
1127 | + * @access private |
|
1128 | + * @return bool |
|
1129 | + * @throws EE_Error |
|
1130 | + */ |
|
1131 | + private function _final_verifications() |
|
1132 | + { |
|
1133 | + // filter checkout |
|
1134 | + $this->checkout = apply_filters( |
|
1135 | + 'FHEE__EED_Single_Page_Checkout___final_verifications__checkout', |
|
1136 | + $this->checkout |
|
1137 | + ); |
|
1138 | + // verify that current step is still set correctly |
|
1139 | + if (! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
1140 | + EE_Error::add_error( |
|
1141 | + esc_html__( |
|
1142 | + 'We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', |
|
1143 | + 'event_espresso' |
|
1144 | + ), |
|
1145 | + __FILE__, |
|
1146 | + __FUNCTION__, |
|
1147 | + __LINE__ |
|
1148 | + ); |
|
1149 | + return false; |
|
1150 | + } |
|
1151 | + // if returning to SPCO, then verify that primary registrant is set |
|
1152 | + if (! empty($this->checkout->reg_url_link)) { |
|
1153 | + $valid_registrant = $this->checkout->transaction->primary_registration(); |
|
1154 | + if (! $valid_registrant instanceof EE_Registration) { |
|
1155 | + EE_Error::add_error( |
|
1156 | + esc_html__( |
|
1157 | + 'We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', |
|
1158 | + 'event_espresso' |
|
1159 | + ), |
|
1160 | + __FILE__, |
|
1161 | + __FUNCTION__, |
|
1162 | + __LINE__ |
|
1163 | + ); |
|
1164 | + return false; |
|
1165 | + } |
|
1166 | + $valid_registrant = null; |
|
1167 | + foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) { |
|
1168 | + if ($registration instanceof EE_Registration |
|
1169 | + && $registration->reg_url_link() === $this->checkout->reg_url_link |
|
1170 | + ) { |
|
1171 | + $valid_registrant = $registration; |
|
1172 | + } |
|
1173 | + } |
|
1174 | + if (! $valid_registrant instanceof EE_Registration) { |
|
1175 | + // hmmm... maybe we have the wrong session because the user is opening multiple tabs ? |
|
1176 | + if (EED_Single_Page_Checkout::$_checkout_verified) { |
|
1177 | + // clear the session, mark the checkout as unverified, and try again |
|
1178 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
1179 | + EED_Single_Page_Checkout::$_initialized = false; |
|
1180 | + EED_Single_Page_Checkout::$_checkout_verified = false; |
|
1181 | + $this->_initialize(); |
|
1182 | + EE_Error::reset_notices(); |
|
1183 | + return false; |
|
1184 | + } |
|
1185 | + EE_Error::add_error( |
|
1186 | + esc_html__( |
|
1187 | + 'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', |
|
1188 | + 'event_espresso' |
|
1189 | + ), |
|
1190 | + __FILE__, |
|
1191 | + __FUNCTION__, |
|
1192 | + __LINE__ |
|
1193 | + ); |
|
1194 | + return false; |
|
1195 | + } |
|
1196 | + } |
|
1197 | + // now that things have been kinda sufficiently verified, |
|
1198 | + // let's add the checkout to the session so that it's available to other systems |
|
1199 | + EE_Registry::instance()->SSN->set_checkout($this->checkout); |
|
1200 | + return true; |
|
1201 | + } |
|
1202 | + |
|
1203 | + |
|
1204 | + /** |
|
1205 | + * _initialize_reg_steps |
|
1206 | + * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required |
|
1207 | + * then loops thru all of the active reg steps and calls the initialize_reg_step() method |
|
1208 | + * |
|
1209 | + * @access private |
|
1210 | + * @param bool $reinitializing |
|
1211 | + * @throws EE_Error |
|
1212 | + */ |
|
1213 | + private function _initialize_reg_steps($reinitializing = false) |
|
1214 | + { |
|
1215 | + $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
|
1216 | + // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
|
1217 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
1218 | + if (! $reg_step->initialize_reg_step()) { |
|
1219 | + // if not initialized then maybe this step is being removed... |
|
1220 | + if (! $reinitializing && $reg_step->is_current_step()) { |
|
1221 | + // if it was the current step, then we need to start over here |
|
1222 | + $this->_initialize_reg_steps(true); |
|
1223 | + return; |
|
1224 | + } |
|
1225 | + continue; |
|
1226 | + } |
|
1227 | + // add css and JS for current step |
|
1228 | + $reg_step->enqueue_styles_and_scripts(); |
|
1229 | + // i18n |
|
1230 | + $reg_step->translate_js_strings(); |
|
1231 | + if ($reg_step->is_current_step()) { |
|
1232 | + // the text that appears on the reg step form submit button |
|
1233 | + $reg_step->set_submit_button_text(); |
|
1234 | + } |
|
1235 | + } |
|
1236 | + // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information |
|
1237 | + do_action( |
|
1238 | + "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", |
|
1239 | + $this->checkout->current_step |
|
1240 | + ); |
|
1241 | + } |
|
1242 | + |
|
1243 | + |
|
1244 | + /** |
|
1245 | + * _check_form_submission |
|
1246 | + * |
|
1247 | + * @access private |
|
1248 | + * @return boolean |
|
1249 | + */ |
|
1250 | + private function _check_form_submission() |
|
1251 | + { |
|
1252 | + // does this request require the reg form to be generated ? |
|
1253 | + if ($this->checkout->generate_reg_form) { |
|
1254 | + // ever heard that song by Blue Rodeo ? |
|
1255 | + try { |
|
1256 | + $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form(); |
|
1257 | + // if not displaying a form, then check for form submission |
|
1258 | + if ($this->checkout->process_form_submission |
|
1259 | + && $this->checkout->current_step->reg_form->was_submitted() |
|
1260 | + ) { |
|
1261 | + // clear out any old data in case this step is being run again |
|
1262 | + $this->checkout->current_step->set_valid_data(array()); |
|
1263 | + // capture submitted form data |
|
1264 | + $this->checkout->current_step->reg_form->receive_form_submission( |
|
1265 | + apply_filters( |
|
1266 | + 'FHEE__Single_Page_Checkout___check_form_submission__request_params', |
|
1267 | + EE_Registry::instance()->REQ->params(), |
|
1268 | + $this->checkout |
|
1269 | + ) |
|
1270 | + ); |
|
1271 | + // validate submitted form data |
|
1272 | + if (! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) { |
|
1273 | + // thou shall not pass !!! |
|
1274 | + $this->checkout->continue_reg = false; |
|
1275 | + // any form validation errors? |
|
1276 | + if ($this->checkout->current_step->reg_form->submission_error_message() !== '') { |
|
1277 | + EE_Error::add_error( |
|
1278 | + $this->checkout->current_step->reg_form->submission_error_message(), |
|
1279 | + __FILE__, |
|
1280 | + __FUNCTION__, |
|
1281 | + __LINE__ |
|
1282 | + ); |
|
1283 | + } |
|
1284 | + // well not really... what will happen is |
|
1285 | + // we'll just get redirected back to redo the current step |
|
1286 | + $this->go_to_next_step(); |
|
1287 | + return false; |
|
1288 | + } |
|
1289 | + } |
|
1290 | + } catch (EE_Error $e) { |
|
1291 | + $e->get_error(); |
|
1292 | + } |
|
1293 | + } |
|
1294 | + return true; |
|
1295 | + } |
|
1296 | + |
|
1297 | + |
|
1298 | + /** |
|
1299 | + * _process_action |
|
1300 | + * |
|
1301 | + * @access private |
|
1302 | + * @return void |
|
1303 | + * @throws EE_Error |
|
1304 | + */ |
|
1305 | + private function _process_form_action() |
|
1306 | + { |
|
1307 | + // what cha wanna do? |
|
1308 | + switch ($this->checkout->action) { |
|
1309 | + // AJAX next step reg form |
|
1310 | + case 'display_spco_reg_step': |
|
1311 | + $this->checkout->redirect = false; |
|
1312 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1313 | + $this->checkout->json_response->set_reg_step_html( |
|
1314 | + $this->checkout->current_step->display_reg_form() |
|
1315 | + ); |
|
1316 | + } |
|
1317 | + break; |
|
1318 | + default: |
|
1319 | + // meh... do one of those other steps first |
|
1320 | + if (! empty($this->checkout->action) |
|
1321 | + && is_callable(array($this->checkout->current_step, $this->checkout->action)) |
|
1322 | + ) { |
|
1323 | + // dynamically creates hook point like: |
|
1324 | + // AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step |
|
1325 | + do_action( |
|
1326 | + "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", |
|
1327 | + $this->checkout->current_step |
|
1328 | + ); |
|
1329 | + // call action on current step |
|
1330 | + if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) { |
|
1331 | + // good registrant, you get to proceed |
|
1332 | + if ($this->checkout->current_step->success_message() !== '' |
|
1333 | + && apply_filters( |
|
1334 | + 'FHEE__Single_Page_Checkout___process_form_action__display_success', |
|
1335 | + false |
|
1336 | + ) |
|
1337 | + ) { |
|
1338 | + EE_Error::add_success( |
|
1339 | + $this->checkout->current_step->success_message() |
|
1340 | + . '<br />' . $this->checkout->next_step->_instructions() |
|
1341 | + ); |
|
1342 | + } |
|
1343 | + // pack it up, pack it in... |
|
1344 | + $this->_setup_redirect(); |
|
1345 | + } |
|
1346 | + // dynamically creates hook point like: |
|
1347 | + // AHEE__Single_Page_Checkout__after_payment_options__process_reg_step |
|
1348 | + do_action( |
|
1349 | + "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", |
|
1350 | + $this->checkout->current_step |
|
1351 | + ); |
|
1352 | + } else { |
|
1353 | + EE_Error::add_error( |
|
1354 | + sprintf( |
|
1355 | + esc_html__( |
|
1356 | + 'The requested form action "%s" does not exist for the current "%s" registration step.', |
|
1357 | + 'event_espresso' |
|
1358 | + ), |
|
1359 | + $this->checkout->action, |
|
1360 | + $this->checkout->current_step->name() |
|
1361 | + ), |
|
1362 | + __FILE__, |
|
1363 | + __FUNCTION__, |
|
1364 | + __LINE__ |
|
1365 | + ); |
|
1366 | + } |
|
1367 | + // end default |
|
1368 | + } |
|
1369 | + // store our progress so far |
|
1370 | + $this->checkout->stash_transaction_and_checkout(); |
|
1371 | + // advance to the next step! If you pass GO, collect $200 |
|
1372 | + $this->go_to_next_step(); |
|
1373 | + } |
|
1374 | + |
|
1375 | + |
|
1376 | + /** |
|
1377 | + * add_styles_and_scripts |
|
1378 | + * |
|
1379 | + * @access public |
|
1380 | + * @return void |
|
1381 | + */ |
|
1382 | + public function add_styles_and_scripts() |
|
1383 | + { |
|
1384 | + // i18n |
|
1385 | + $this->translate_js_strings(); |
|
1386 | + if ($this->checkout->admin_request) { |
|
1387 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1388 | + } else { |
|
1389 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1390 | + } |
|
1391 | + } |
|
1392 | + |
|
1393 | + |
|
1394 | + /** |
|
1395 | + * translate_js_strings |
|
1396 | + * |
|
1397 | + * @access public |
|
1398 | + * @return void |
|
1399 | + */ |
|
1400 | + public function translate_js_strings() |
|
1401 | + { |
|
1402 | + EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit; |
|
1403 | + EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link; |
|
1404 | + EE_Registry::$i18n_js_strings['server_error'] = esc_html__( |
|
1405 | + 'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', |
|
1406 | + 'event_espresso' |
|
1407 | + ); |
|
1408 | + EE_Registry::$i18n_js_strings['invalid_json_response'] = esc_html__( |
|
1409 | + 'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', |
|
1410 | + 'event_espresso' |
|
1411 | + ); |
|
1412 | + EE_Registry::$i18n_js_strings['validation_error'] = esc_html__( |
|
1413 | + 'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', |
|
1414 | + 'event_espresso' |
|
1415 | + ); |
|
1416 | + EE_Registry::$i18n_js_strings['invalid_payment_method'] = esc_html__( |
|
1417 | + 'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', |
|
1418 | + 'event_espresso' |
|
1419 | + ); |
|
1420 | + EE_Registry::$i18n_js_strings['reg_step_error'] = esc_html__( |
|
1421 | + 'This registration step could not be completed. Please refresh the page and try again.', |
|
1422 | + 'event_espresso' |
|
1423 | + ); |
|
1424 | + EE_Registry::$i18n_js_strings['invalid_coupon'] = esc_html__( |
|
1425 | + 'We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', |
|
1426 | + 'event_espresso' |
|
1427 | + ); |
|
1428 | + EE_Registry::$i18n_js_strings['process_registration'] = sprintf( |
|
1429 | + esc_html__( |
|
1430 | + 'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', |
|
1431 | + 'event_espresso' |
|
1432 | + ), |
|
1433 | + '<br/>', |
|
1434 | + '<br/>' |
|
1435 | + ); |
|
1436 | + EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language'); |
|
1437 | + EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id(); |
|
1438 | + EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency; |
|
1439 | + EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20'; |
|
1440 | + EE_Registry::$i18n_js_strings['timer_years'] = esc_html__('years', 'event_espresso'); |
|
1441 | + EE_Registry::$i18n_js_strings['timer_months'] = esc_html__('months', 'event_espresso'); |
|
1442 | + EE_Registry::$i18n_js_strings['timer_weeks'] = esc_html__('weeks', 'event_espresso'); |
|
1443 | + EE_Registry::$i18n_js_strings['timer_days'] = esc_html__('days', 'event_espresso'); |
|
1444 | + EE_Registry::$i18n_js_strings['timer_hours'] = esc_html__('hours', 'event_espresso'); |
|
1445 | + EE_Registry::$i18n_js_strings['timer_minutes'] = esc_html__('minutes', 'event_espresso'); |
|
1446 | + EE_Registry::$i18n_js_strings['timer_seconds'] = esc_html__('seconds', 'event_espresso'); |
|
1447 | + EE_Registry::$i18n_js_strings['timer_year'] = esc_html__('year', 'event_espresso'); |
|
1448 | + EE_Registry::$i18n_js_strings['timer_month'] = esc_html__('month', 'event_espresso'); |
|
1449 | + EE_Registry::$i18n_js_strings['timer_week'] = esc_html__('week', 'event_espresso'); |
|
1450 | + EE_Registry::$i18n_js_strings['timer_day'] = esc_html__('day', 'event_espresso'); |
|
1451 | + EE_Registry::$i18n_js_strings['timer_hour'] = esc_html__('hour', 'event_espresso'); |
|
1452 | + EE_Registry::$i18n_js_strings['timer_minute'] = esc_html__('minute', 'event_espresso'); |
|
1453 | + EE_Registry::$i18n_js_strings['timer_second'] = esc_html__('second', 'event_espresso'); |
|
1454 | + EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice( |
|
1455 | + ); |
|
1456 | + EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters( |
|
1457 | + 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', |
|
1458 | + true |
|
1459 | + ); |
|
1460 | + EE_Registry::$i18n_js_strings['session_extension'] = absint( |
|
1461 | + apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS) |
|
1462 | + ); |
|
1463 | + EE_Registry::$i18n_js_strings['session_expiration'] = gmdate( |
|
1464 | + 'M d, Y H:i:s', |
|
1465 | + EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
1466 | + ); |
|
1467 | + } |
|
1468 | + |
|
1469 | + |
|
1470 | + /** |
|
1471 | + * enqueue_styles_and_scripts |
|
1472 | + * |
|
1473 | + * @access public |
|
1474 | + * @return void |
|
1475 | + * @throws EE_Error |
|
1476 | + */ |
|
1477 | + public function enqueue_styles_and_scripts() |
|
1478 | + { |
|
1479 | + // load css |
|
1480 | + wp_register_style( |
|
1481 | + 'single_page_checkout', |
|
1482 | + SPCO_CSS_URL . 'single_page_checkout.css', |
|
1483 | + array('espresso_default'), |
|
1484 | + EVENT_ESPRESSO_VERSION |
|
1485 | + ); |
|
1486 | + wp_enqueue_style('single_page_checkout'); |
|
1487 | + // load JS |
|
1488 | + wp_register_script( |
|
1489 | + 'jquery_plugin', |
|
1490 | + EE_THIRD_PARTY_URL . 'jquery .plugin.min.js', |
|
1491 | + array('jquery'), |
|
1492 | + '1.0.1', |
|
1493 | + true |
|
1494 | + ); |
|
1495 | + wp_register_script( |
|
1496 | + 'jquery_countdown', |
|
1497 | + EE_THIRD_PARTY_URL . 'jquery .countdown.min.js', |
|
1498 | + array('jquery_plugin'), |
|
1499 | + '2.1.0', |
|
1500 | + true |
|
1501 | + ); |
|
1502 | + wp_register_script( |
|
1503 | + 'single_page_checkout', |
|
1504 | + SPCO_JS_URL . 'single_page_checkout.js', |
|
1505 | + array('espresso_core', 'underscore', 'ee_form_section_validation'), |
|
1506 | + EVENT_ESPRESSO_VERSION, |
|
1507 | + true |
|
1508 | + ); |
|
1509 | + if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) { |
|
1510 | + $this->checkout->registration_form->enqueue_js(); |
|
1511 | + } |
|
1512 | + if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) { |
|
1513 | + $this->checkout->current_step->reg_form->enqueue_js(); |
|
1514 | + } |
|
1515 | + wp_enqueue_script('single_page_checkout'); |
|
1516 | + if (apply_filters('FHEE__registration_page_wrapper_template__display_time_limit', false)) { |
|
1517 | + wp_enqueue_script('jquery_countdown'); |
|
1518 | + } |
|
1519 | + /** |
|
1520 | + * global action hook for enqueueing styles and scripts with |
|
1521 | + * spco calls. |
|
1522 | + */ |
|
1523 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this); |
|
1524 | + /** |
|
1525 | + * dynamic action hook for enqueueing styles and scripts with spco calls. |
|
1526 | + * The hook will end up being something like: |
|
1527 | + * AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
|
1528 | + */ |
|
1529 | + do_action( |
|
1530 | + 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), |
|
1531 | + $this |
|
1532 | + ); |
|
1533 | + } |
|
1534 | + |
|
1535 | + |
|
1536 | + /** |
|
1537 | + * display the Registration Single Page Checkout Form |
|
1538 | + * |
|
1539 | + * @access private |
|
1540 | + * @return void |
|
1541 | + * @throws EE_Error |
|
1542 | + */ |
|
1543 | + private function _display_spco_reg_form() |
|
1544 | + { |
|
1545 | + // if registering via the admin, just display the reg form for the current step |
|
1546 | + if ($this->checkout->admin_request) { |
|
1547 | + EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form()); |
|
1548 | + } else { |
|
1549 | + // add powered by EE msg |
|
1550 | + add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer')); |
|
1551 | + $empty_cart = count($this->checkout->transaction |
|
1552 | + ->registrations($this->checkout->reg_cache_where_params)) < 1; |
|
1553 | + EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart; |
|
1554 | + $cookies_not_set_msg = ''; |
|
1555 | + if ($empty_cart) { |
|
1556 | + $cookies_not_set_msg = apply_filters( |
|
1557 | + 'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg', |
|
1558 | + sprintf( |
|
1559 | + esc_html__( |
|
1560 | + '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', |
|
1561 | + 'event_espresso' |
|
1562 | + ), |
|
1563 | + '<div class="ee-attention hidden" id="ee-cookies-not-set-msg">', |
|
1564 | + '</div>', |
|
1565 | + '<h6 class="important-notice">', |
|
1566 | + '</h6>', |
|
1567 | + '<p>', |
|
1568 | + '</p>', |
|
1569 | + '<br />', |
|
1570 | + '<a href="http://www.whatarecookies.com/enable.asp" target="_blank" rel="noopener noreferrer">', |
|
1571 | + '</a>' |
|
1572 | + ) |
|
1573 | + ); |
|
1574 | + } |
|
1575 | + $this->checkout->registration_form = new EE_Form_Section_Proper( |
|
1576 | + array( |
|
1577 | + 'name' => 'single-page-checkout', |
|
1578 | + 'html_id' => 'ee-single-page-checkout-dv', |
|
1579 | + 'layout_strategy' => |
|
1580 | + new EE_Template_Layout( |
|
1581 | + array( |
|
1582 | + 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
1583 | + 'template_args' => array( |
|
1584 | + 'empty_cart' => $empty_cart, |
|
1585 | + 'revisit' => $this->checkout->revisit, |
|
1586 | + 'reg_steps' => $this->checkout->reg_steps, |
|
1587 | + 'next_step' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
|
1588 | + ? $this->checkout->next_step->slug() |
|
1589 | + : '', |
|
1590 | + 'empty_msg' => apply_filters( |
|
1591 | + 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
|
1592 | + sprintf( |
|
1593 | + esc_html__( |
|
1594 | + 'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', |
|
1595 | + 'event_espresso' |
|
1596 | + ), |
|
1597 | + '<a href="' |
|
1598 | + . get_post_type_archive_link('espresso_events') |
|
1599 | + . '" title="', |
|
1600 | + '">', |
|
1601 | + '</a>' |
|
1602 | + ) |
|
1603 | + ), |
|
1604 | + 'cookies_not_set_msg' => $cookies_not_set_msg, |
|
1605 | + 'registration_time_limit' => $this->checkout->get_registration_time_limit(), |
|
1606 | + 'session_expiration' => gmdate( |
|
1607 | + 'M d, Y H:i:s', |
|
1608 | + EE_Registry::instance()->SSN->expiration() |
|
1609 | + + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
1610 | + ), |
|
1611 | + ), |
|
1612 | + ) |
|
1613 | + ), |
|
1614 | + ) |
|
1615 | + ); |
|
1616 | + // load template and add to output sent that gets filtered into the_content() |
|
1617 | + EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html()); |
|
1618 | + } |
|
1619 | + } |
|
1620 | + |
|
1621 | + |
|
1622 | + /** |
|
1623 | + * add_extra_finalize_registration_inputs |
|
1624 | + * |
|
1625 | + * @access public |
|
1626 | + * @param $next_step |
|
1627 | + * @internal param string $label |
|
1628 | + * @return void |
|
1629 | + */ |
|
1630 | + public function add_extra_finalize_registration_inputs($next_step) |
|
1631 | + { |
|
1632 | + if ($next_step === 'finalize_registration') { |
|
1633 | + echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>'; |
|
1634 | + } |
|
1635 | + } |
|
1636 | + |
|
1637 | + |
|
1638 | + /** |
|
1639 | + * display_registration_footer |
|
1640 | + * |
|
1641 | + * @access public |
|
1642 | + * @return string |
|
1643 | + */ |
|
1644 | + public static function display_registration_footer() |
|
1645 | + { |
|
1646 | + if (apply_filters( |
|
1647 | + 'FHEE__EE_Front__Controller__show_reg_footer', |
|
1648 | + EE_Registry::instance()->CFG->admin->show_reg_footer |
|
1649 | + )) { |
|
1650 | + add_filter( |
|
1651 | + 'FHEE__EEH_Template__powered_by_event_espresso__url', |
|
1652 | + function ($url) { |
|
1653 | + return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
|
1654 | + } |
|
1655 | + ); |
|
1656 | + echo apply_filters( |
|
1657 | + 'FHEE__EE_Front_Controller__display_registration_footer', |
|
1658 | + \EEH_Template::powered_by_event_espresso( |
|
1659 | + '', |
|
1660 | + 'espresso-registration-footer-dv', |
|
1661 | + array('utm_content' => 'registration_checkout') |
|
1662 | + ) |
|
1663 | + ); |
|
1664 | + } |
|
1665 | + return ''; |
|
1666 | + } |
|
1667 | + |
|
1668 | + |
|
1669 | + /** |
|
1670 | + * unlock_transaction |
|
1671 | + * |
|
1672 | + * @access public |
|
1673 | + * @return void |
|
1674 | + * @throws EE_Error |
|
1675 | + */ |
|
1676 | + public function unlock_transaction() |
|
1677 | + { |
|
1678 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
1679 | + $this->checkout->transaction->unlock(); |
|
1680 | + } |
|
1681 | + } |
|
1682 | + |
|
1683 | + |
|
1684 | + /** |
|
1685 | + * _setup_redirect |
|
1686 | + * |
|
1687 | + * @access private |
|
1688 | + * @return void |
|
1689 | + */ |
|
1690 | + private function _setup_redirect() |
|
1691 | + { |
|
1692 | + if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
1693 | + $this->checkout->redirect = true; |
|
1694 | + if (empty($this->checkout->redirect_url)) { |
|
1695 | + $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url(); |
|
1696 | + } |
|
1697 | + $this->checkout->redirect_url = apply_filters( |
|
1698 | + 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', |
|
1699 | + $this->checkout->redirect_url, |
|
1700 | + $this->checkout |
|
1701 | + ); |
|
1702 | + } |
|
1703 | + } |
|
1704 | + |
|
1705 | + |
|
1706 | + /** |
|
1707 | + * handle ajax message responses and redirects |
|
1708 | + * |
|
1709 | + * @access public |
|
1710 | + * @return void |
|
1711 | + * @throws EE_Error |
|
1712 | + */ |
|
1713 | + public function go_to_next_step() |
|
1714 | + { |
|
1715 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1716 | + // capture contents of output buffer we started earlier in the request, and insert into JSON response |
|
1717 | + $this->checkout->json_response->set_unexpected_errors(ob_get_clean()); |
|
1718 | + } |
|
1719 | + $this->unlock_transaction(); |
|
1720 | + // just return for these conditions |
|
1721 | + if ($this->checkout->admin_request |
|
1722 | + || $this->checkout->action === 'redirect_form' |
|
1723 | + || $this->checkout->action === 'update_checkout' |
|
1724 | + ) { |
|
1725 | + return; |
|
1726 | + } |
|
1727 | + // AJAX response |
|
1728 | + $this->_handle_json_response(); |
|
1729 | + // redirect to next step or the Thank You page |
|
1730 | + $this->_handle_html_redirects(); |
|
1731 | + // hmmm... must be something wrong, so let's just display the form again ! |
|
1732 | + $this->_display_spco_reg_form(); |
|
1733 | + } |
|
1734 | + |
|
1735 | + |
|
1736 | + /** |
|
1737 | + * _handle_json_response |
|
1738 | + * |
|
1739 | + * @access protected |
|
1740 | + * @return void |
|
1741 | + */ |
|
1742 | + protected function _handle_json_response() |
|
1743 | + { |
|
1744 | + // if this is an ajax request |
|
1745 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1746 | + $this->checkout->json_response->set_registration_time_limit( |
|
1747 | + $this->checkout->get_registration_time_limit() |
|
1748 | + ); |
|
1749 | + $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing); |
|
1750 | + // just send the ajax ( |
|
1751 | + $json_response = apply_filters( |
|
1752 | + 'FHEE__EE_Single_Page_Checkout__JSON_response', |
|
1753 | + $this->checkout->json_response |
|
1754 | + ); |
|
1755 | + echo $json_response; |
|
1756 | + exit(); |
|
1757 | + } |
|
1758 | + } |
|
1759 | + |
|
1760 | + |
|
1761 | + /** |
|
1762 | + * _handle_redirects |
|
1763 | + * |
|
1764 | + * @access protected |
|
1765 | + * @return void |
|
1766 | + */ |
|
1767 | + protected function _handle_html_redirects() |
|
1768 | + { |
|
1769 | + // going somewhere ? |
|
1770 | + if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) { |
|
1771 | + // store notices in a transient |
|
1772 | + EE_Error::get_notices(false, true, true); |
|
1773 | + wp_safe_redirect($this->checkout->redirect_url); |
|
1774 | + exit(); |
|
1775 | + } |
|
1776 | + } |
|
1777 | + |
|
1778 | + |
|
1779 | + /** |
|
1780 | + * set_checkout_anchor |
|
1781 | + * |
|
1782 | + * @access public |
|
1783 | + * @return void |
|
1784 | + */ |
|
1785 | + public function set_checkout_anchor() |
|
1786 | + { |
|
1787 | + echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>'; |
|
1788 | + } |
|
1789 | + |
|
1790 | + /** |
|
1791 | + * getRegistrationExpirationNotice |
|
1792 | + * |
|
1793 | + * @since 4.9.59.p |
|
1794 | + * @access public |
|
1795 | + * @return string |
|
1796 | + */ |
|
1797 | + public static function getRegistrationExpirationNotice() |
|
1798 | + { |
|
1799 | + return sprintf( |
|
1800 | + esc_html__( |
|
1801 | + '%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please accept our apologies for any inconvenience this may have caused.%8$s', |
|
1802 | + 'event_espresso' |
|
1803 | + ), |
|
1804 | + '<h4 class="important-notice">', |
|
1805 | + '</h4>', |
|
1806 | + '<br />', |
|
1807 | + '<p>', |
|
1808 | + '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
1809 | + '">', |
|
1810 | + '</a>', |
|
1811 | + '</p>' |
|
1812 | + ); |
|
1813 | + } |
|
1814 | 1814 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | public static function set_hooks_admin() |
101 | 101 | { |
102 | 102 | EED_Single_Page_Checkout::set_definitions(); |
103 | - if (! (defined('DOING_AJAX') && DOING_AJAX)) { |
|
103 | + if ( ! (defined('DOING_AJAX') && DOING_AJAX)) { |
|
104 | 104 | return; |
105 | 105 | } |
106 | 106 | // going to start an output buffer in case anything gets accidentally output |
@@ -206,14 +206,14 @@ discard block |
||
206 | 206 | } |
207 | 207 | define( |
208 | 208 | 'SPCO_BASE_PATH', |
209 | - rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS |
|
209 | + rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS).DS |
|
210 | 210 | ); |
211 | - define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS); |
|
212 | - define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS); |
|
213 | - define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS); |
|
214 | - define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS); |
|
215 | - define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS); |
|
216 | - define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS); |
|
211 | + define('SPCO_CSS_URL', plugin_dir_url(__FILE__).'css'.DS); |
|
212 | + define('SPCO_IMG_URL', plugin_dir_url(__FILE__).'img'.DS); |
|
213 | + define('SPCO_JS_URL', plugin_dir_url(__FILE__).'js'.DS); |
|
214 | + define('SPCO_INC_PATH', SPCO_BASE_PATH.'inc'.DS); |
|
215 | + define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH.'reg_steps'.DS); |
|
216 | + define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH.'templates'.DS); |
|
217 | 217 | EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true); |
218 | 218 | EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice( |
219 | 219 | ); |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | // we need a |
246 | 246 | if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
247 | 247 | // copy over to the reg_steps_array |
248 | - EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step; |
|
248 | + EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step; |
|
249 | 249 | // register custom key route for each reg step |
250 | 250 | // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
251 | 251 | EE_Config::register_route( |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | // add AJAX or other hooks |
258 | 258 | if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
259 | 259 | // setup autoloaders if necessary |
260 | - if (! class_exists($reg_step['class_name'])) { |
|
260 | + if ( ! class_exists($reg_step['class_name'])) { |
|
261 | 261 | EEH_Autoloader::register_autoloaders_for_each_file_in_folder( |
262 | 262 | $reg_step['file_path'], |
263 | 263 | true |
@@ -285,19 +285,19 @@ discard block |
||
285 | 285 | if (empty($reg_steps)) { |
286 | 286 | $reg_steps = array( |
287 | 287 | 10 => array( |
288 | - 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
288 | + 'file_path' => SPCO_REG_STEPS_PATH.'attendee_information', |
|
289 | 289 | 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
290 | 290 | 'slug' => 'attendee_information', |
291 | 291 | 'has_hooks' => false, |
292 | 292 | ), |
293 | 293 | 30 => array( |
294 | - 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
294 | + 'file_path' => SPCO_REG_STEPS_PATH.'payment_options', |
|
295 | 295 | 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
296 | 296 | 'slug' => 'payment_options', |
297 | 297 | 'has_hooks' => true, |
298 | 298 | ), |
299 | 299 | 999 => array( |
300 | - 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
300 | + 'file_path' => SPCO_REG_STEPS_PATH.'finalize_registration', |
|
301 | 301 | 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
302 | 302 | 'slug' => 'finalize_registration', |
303 | 303 | 'has_hooks' => false, |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | $this->checkout |
451 | 451 | ); |
452 | 452 | // load the reg steps array |
453 | - if (! $this->_load_and_instantiate_reg_steps()) { |
|
453 | + if ( ! $this->_load_and_instantiate_reg_steps()) { |
|
454 | 454 | EED_Single_Page_Checkout::$_initialized = true; |
455 | 455 | return; |
456 | 456 | } |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | // and the next step |
460 | 460 | $this->checkout->set_next_step(); |
461 | 461 | // verify that everything has been setup correctly |
462 | - if (! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) { |
|
462 | + if ( ! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) { |
|
463 | 463 | EED_Single_Page_Checkout::$_initialized = true; |
464 | 464 | return; |
465 | 465 | } |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | // DEBUG LOG |
475 | 475 | // $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
476 | 476 | // get reg form |
477 | - if (! $this->_check_form_submission()) { |
|
477 | + if ( ! $this->_check_form_submission()) { |
|
478 | 478 | EED_Single_Page_Checkout::$_initialized = true; |
479 | 479 | return; |
480 | 480 | } |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | */ |
506 | 506 | private function _verify_session() |
507 | 507 | { |
508 | - if (! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
508 | + if ( ! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
509 | 509 | throw new EE_Error(esc_html__('The EE_Session class could not be loaded.', 'event_espresso')); |
510 | 510 | } |
511 | 511 | $clear_session_requested = filter_var( |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | // EE_Registry::instance()->SSN->reset_cart(); |
524 | 524 | // EE_Registry::instance()->SSN->reset_checkout(); |
525 | 525 | // EE_Registry::instance()->SSN->reset_transaction(); |
526 | - if (! $clear_session_requested) { |
|
526 | + if ( ! $clear_session_requested) { |
|
527 | 527 | EE_Error::add_attention( |
528 | 528 | EE_Registry::$i18n_js_strings['registration_expiration_notice'], |
529 | 529 | __FILE__, |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | /** @type EE_Checkout $checkout */ |
551 | 551 | $checkout = EE_Registry::instance()->SSN->checkout(); |
552 | 552 | // verify |
553 | - if (! $checkout instanceof EE_Checkout) { |
|
553 | + if ( ! $checkout instanceof EE_Checkout) { |
|
554 | 554 | // instantiate EE_Checkout object for handling the properties of the current checkout process |
555 | 555 | $checkout = EE_Registry::instance()->load_file( |
556 | 556 | SPCO_INC_PATH, |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | } |
569 | 569 | $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
570 | 570 | // verify again |
571 | - if (! $checkout instanceof EE_Checkout) { |
|
571 | + if ( ! $checkout instanceof EE_Checkout) { |
|
572 | 572 | throw new EE_Error(esc_html__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
573 | 573 | } |
574 | 574 | // reset anything that needs a clean slate for each request |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | */ |
641 | 641 | protected function _display_request_vars() |
642 | 642 | { |
643 | - if (! WP_DEBUG) { |
|
643 | + if ( ! WP_DEBUG) { |
|
644 | 644 | return; |
645 | 645 | } |
646 | 646 | EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__); |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | ) { |
718 | 718 | // if not, then loop through raw reg steps array |
719 | 719 | foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
720 | - if (! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
720 | + if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
721 | 721 | return false; |
722 | 722 | } |
723 | 723 | } |
@@ -848,12 +848,12 @@ discard block |
||
848 | 848 | private function _verify_transaction_and_get_registrations() |
849 | 849 | { |
850 | 850 | // was there already a valid transaction in the checkout from the session ? |
851 | - if (! $this->checkout->transaction instanceof EE_Transaction) { |
|
851 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
852 | 852 | // get transaction from db or session |
853 | 853 | $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
854 | 854 | ? $this->_get_transaction_and_cart_for_previous_visit() |
855 | 855 | : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
856 | - if (! $this->checkout->transaction instanceof EE_Transaction) { |
|
856 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
857 | 857 | EE_Error::add_error( |
858 | 858 | esc_html__( |
859 | 859 | 'Your Registration and Transaction information could not be retrieved from the db.', |
@@ -1084,16 +1084,16 @@ discard block |
||
1084 | 1084 | ) |
1085 | 1085 | ); |
1086 | 1086 | // override capabilities for frontend registrations |
1087 | - if (! is_admin()) { |
|
1087 | + if ( ! is_admin()) { |
|
1088 | 1088 | $CreateRegistrationCommand->setCapCheck( |
1089 | 1089 | new PublicCapabilities('', 'create_new_registration') |
1090 | 1090 | ); |
1091 | 1091 | } |
1092 | 1092 | $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand); |
1093 | - if (! $registration instanceof EE_Registration) { |
|
1093 | + if ( ! $registration instanceof EE_Registration) { |
|
1094 | 1094 | throw new InvalidEntityException($registration, 'EE_Registration'); |
1095 | 1095 | } |
1096 | - $registrations[ $registration->ID() ] = $registration; |
|
1096 | + $registrations[$registration->ID()] = $registration; |
|
1097 | 1097 | } |
1098 | 1098 | } |
1099 | 1099 | $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
@@ -1136,7 +1136,7 @@ discard block |
||
1136 | 1136 | $this->checkout |
1137 | 1137 | ); |
1138 | 1138 | // verify that current step is still set correctly |
1139 | - if (! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
1139 | + if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
1140 | 1140 | EE_Error::add_error( |
1141 | 1141 | esc_html__( |
1142 | 1142 | 'We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', |
@@ -1149,9 +1149,9 @@ discard block |
||
1149 | 1149 | return false; |
1150 | 1150 | } |
1151 | 1151 | // if returning to SPCO, then verify that primary registrant is set |
1152 | - if (! empty($this->checkout->reg_url_link)) { |
|
1152 | + if ( ! empty($this->checkout->reg_url_link)) { |
|
1153 | 1153 | $valid_registrant = $this->checkout->transaction->primary_registration(); |
1154 | - if (! $valid_registrant instanceof EE_Registration) { |
|
1154 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
1155 | 1155 | EE_Error::add_error( |
1156 | 1156 | esc_html__( |
1157 | 1157 | 'We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', |
@@ -1171,7 +1171,7 @@ discard block |
||
1171 | 1171 | $valid_registrant = $registration; |
1172 | 1172 | } |
1173 | 1173 | } |
1174 | - if (! $valid_registrant instanceof EE_Registration) { |
|
1174 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
1175 | 1175 | // hmmm... maybe we have the wrong session because the user is opening multiple tabs ? |
1176 | 1176 | if (EED_Single_Page_Checkout::$_checkout_verified) { |
1177 | 1177 | // clear the session, mark the checkout as unverified, and try again |
@@ -1215,9 +1215,9 @@ discard block |
||
1215 | 1215 | $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
1216 | 1216 | // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
1217 | 1217 | foreach ($this->checkout->reg_steps as $reg_step) { |
1218 | - if (! $reg_step->initialize_reg_step()) { |
|
1218 | + if ( ! $reg_step->initialize_reg_step()) { |
|
1219 | 1219 | // if not initialized then maybe this step is being removed... |
1220 | - if (! $reinitializing && $reg_step->is_current_step()) { |
|
1220 | + if ( ! $reinitializing && $reg_step->is_current_step()) { |
|
1221 | 1221 | // if it was the current step, then we need to start over here |
1222 | 1222 | $this->_initialize_reg_steps(true); |
1223 | 1223 | return; |
@@ -1269,7 +1269,7 @@ discard block |
||
1269 | 1269 | ) |
1270 | 1270 | ); |
1271 | 1271 | // validate submitted form data |
1272 | - if (! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) { |
|
1272 | + if ( ! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) { |
|
1273 | 1273 | // thou shall not pass !!! |
1274 | 1274 | $this->checkout->continue_reg = false; |
1275 | 1275 | // any form validation errors? |
@@ -1317,7 +1317,7 @@ discard block |
||
1317 | 1317 | break; |
1318 | 1318 | default: |
1319 | 1319 | // meh... do one of those other steps first |
1320 | - if (! empty($this->checkout->action) |
|
1320 | + if ( ! empty($this->checkout->action) |
|
1321 | 1321 | && is_callable(array($this->checkout->current_step, $this->checkout->action)) |
1322 | 1322 | ) { |
1323 | 1323 | // dynamically creates hook point like: |
@@ -1337,7 +1337,7 @@ discard block |
||
1337 | 1337 | ) { |
1338 | 1338 | EE_Error::add_success( |
1339 | 1339 | $this->checkout->current_step->success_message() |
1340 | - . '<br />' . $this->checkout->next_step->_instructions() |
|
1340 | + . '<br />'.$this->checkout->next_step->_instructions() |
|
1341 | 1341 | ); |
1342 | 1342 | } |
1343 | 1343 | // pack it up, pack it in... |
@@ -1479,7 +1479,7 @@ discard block |
||
1479 | 1479 | // load css |
1480 | 1480 | wp_register_style( |
1481 | 1481 | 'single_page_checkout', |
1482 | - SPCO_CSS_URL . 'single_page_checkout.css', |
|
1482 | + SPCO_CSS_URL.'single_page_checkout.css', |
|
1483 | 1483 | array('espresso_default'), |
1484 | 1484 | EVENT_ESPRESSO_VERSION |
1485 | 1485 | ); |
@@ -1487,21 +1487,21 @@ discard block |
||
1487 | 1487 | // load JS |
1488 | 1488 | wp_register_script( |
1489 | 1489 | 'jquery_plugin', |
1490 | - EE_THIRD_PARTY_URL . 'jquery .plugin.min.js', |
|
1490 | + EE_THIRD_PARTY_URL.'jquery .plugin.min.js', |
|
1491 | 1491 | array('jquery'), |
1492 | 1492 | '1.0.1', |
1493 | 1493 | true |
1494 | 1494 | ); |
1495 | 1495 | wp_register_script( |
1496 | 1496 | 'jquery_countdown', |
1497 | - EE_THIRD_PARTY_URL . 'jquery .countdown.min.js', |
|
1497 | + EE_THIRD_PARTY_URL.'jquery .countdown.min.js', |
|
1498 | 1498 | array('jquery_plugin'), |
1499 | 1499 | '2.1.0', |
1500 | 1500 | true |
1501 | 1501 | ); |
1502 | 1502 | wp_register_script( |
1503 | 1503 | 'single_page_checkout', |
1504 | - SPCO_JS_URL . 'single_page_checkout.js', |
|
1504 | + SPCO_JS_URL.'single_page_checkout.js', |
|
1505 | 1505 | array('espresso_core', 'underscore', 'ee_form_section_validation'), |
1506 | 1506 | EVENT_ESPRESSO_VERSION, |
1507 | 1507 | true |
@@ -1527,7 +1527,7 @@ discard block |
||
1527 | 1527 | * AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
1528 | 1528 | */ |
1529 | 1529 | do_action( |
1530 | - 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), |
|
1530 | + 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__'.$this->checkout->current_step->slug(), |
|
1531 | 1531 | $this |
1532 | 1532 | ); |
1533 | 1533 | } |
@@ -1579,7 +1579,7 @@ discard block |
||
1579 | 1579 | 'layout_strategy' => |
1580 | 1580 | new EE_Template_Layout( |
1581 | 1581 | array( |
1582 | - 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
1582 | + 'layout_template_file' => SPCO_TEMPLATES_PATH.'registration_page_wrapper.template.php', |
|
1583 | 1583 | 'template_args' => array( |
1584 | 1584 | 'empty_cart' => $empty_cart, |
1585 | 1585 | 'revisit' => $this->checkout->revisit, |
@@ -1649,7 +1649,7 @@ discard block |
||
1649 | 1649 | )) { |
1650 | 1650 | add_filter( |
1651 | 1651 | 'FHEE__EEH_Template__powered_by_event_espresso__url', |
1652 | - function ($url) { |
|
1652 | + function($url) { |
|
1653 | 1653 | return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
1654 | 1654 | } |
1655 | 1655 | ); |
@@ -1805,7 +1805,7 @@ discard block |
||
1805 | 1805 | '</h4>', |
1806 | 1806 | '<br />', |
1807 | 1807 | '<p>', |
1808 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
1808 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
1809 | 1809 | '">', |
1810 | 1810 | '</a>', |
1811 | 1811 | '</p>' |
@@ -4,10 +4,10 @@ discard block |
||
4 | 4 | </p> |
5 | 5 | <p> |
6 | 6 | <?php printf( |
7 | - esc_html__('See %1$shere%2$s for list of currencies supported by Paypal Pro.', 'event_espresso'), |
|
8 | - "<a href='https://www.paypal.com/multicurrency' target='_blank' rel='noopener noreferrer'>", |
|
9 | - "</a>" |
|
10 | - ); ?> |
|
7 | + esc_html__('See %1$shere%2$s for list of currencies supported by Paypal Pro.', 'event_espresso'), |
|
8 | + "<a href='https://www.paypal.com/multicurrency' target='_blank' rel='noopener noreferrer'>", |
|
9 | + "</a>" |
|
10 | + ); ?> |
|
11 | 11 | </p> |
12 | 12 | <p><strong><?php esc_html_e('PayPal Pro Settings', 'event_espresso'); ?></strong></p> |
13 | 13 | <ul> |
@@ -18,42 +18,42 @@ discard block |
||
18 | 18 | <li> |
19 | 19 | <strong><?php esc_html_e('PayPal API Username', 'event_espresso'); ?></strong><br/> |
20 | 20 | <?php printf( |
21 | - esc_html__( |
|
22 | - 'Enter your API Username for PayPal. Learn how to find your %1$sAPI Username%2$s.', |
|
23 | - 'event_espresso' |
|
24 | - ), |
|
25 | - '<a href="https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/cps/merchant/wppro/WPProIntegrationSteps-outside#SectionB" target="_blank" rel="noopener noreferrer">', |
|
26 | - '</a>' |
|
27 | - ); ?> |
|
21 | + esc_html__( |
|
22 | + 'Enter your API Username for PayPal. Learn how to find your %1$sAPI Username%2$s.', |
|
23 | + 'event_espresso' |
|
24 | + ), |
|
25 | + '<a href="https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/cps/merchant/wppro/WPProIntegrationSteps-outside#SectionB" target="_blank" rel="noopener noreferrer">', |
|
26 | + '</a>' |
|
27 | + ); ?> |
|
28 | 28 | </li> |
29 | 29 | <li> |
30 | 30 | <strong><?php esc_html_e('PayPal API Password', 'event_espresso'); ?></strong><br/> |
31 | 31 | <?php printf( |
32 | - esc_html__( |
|
33 | - 'Enter your API Password for PayPal. Learn how to find your %1$sAPI Password%2$s.', |
|
34 | - 'event_espresso' |
|
35 | - ), |
|
36 | - '<a href="https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/cps/merchant/wppro/WPProIntegrationSteps-outside#SectionB" target="_blank" rel="noopener noreferrer">', |
|
37 | - '</a>' |
|
38 | - ); ?> |
|
32 | + esc_html__( |
|
33 | + 'Enter your API Password for PayPal. Learn how to find your %1$sAPI Password%2$s.', |
|
34 | + 'event_espresso' |
|
35 | + ), |
|
36 | + '<a href="https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/cps/merchant/wppro/WPProIntegrationSteps-outside#SectionB" target="_blank" rel="noopener noreferrer">', |
|
37 | + '</a>' |
|
38 | + ); ?> |
|
39 | 39 | </li> |
40 | 40 | <li> |
41 | 41 | <strong><?php esc_html_e('PayPal API Signature', 'event_espresso'); ?></strong><br/> |
42 | 42 | <?php printf( |
43 | - esc_html__( |
|
44 | - 'Enter your API Signature for PayPal. Learn how to find your %1$sAPI Signature%2$s.', |
|
45 | - 'event_espresso' |
|
46 | - ), |
|
47 | - '<a href="https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/cps/merchant/wppro/WPProIntegrationSteps-outside#SectionB" target="_blank" rel="noopener noreferrer">', |
|
48 | - '</a>' |
|
49 | - ); ?> |
|
43 | + esc_html__( |
|
44 | + 'Enter your API Signature for PayPal. Learn how to find your %1$sAPI Signature%2$s.', |
|
45 | + 'event_espresso' |
|
46 | + ), |
|
47 | + '<a href="https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/cps/merchant/wppro/WPProIntegrationSteps-outside#SectionB" target="_blank" rel="noopener noreferrer">', |
|
48 | + '</a>' |
|
49 | + ); ?> |
|
50 | 50 | </li> |
51 | 51 | <li> |
52 | 52 | <strong><?php esc_html_e('Country Currency', 'event_espresso'); ?></strong><br/> |
53 | 53 | <?php esc_html_e( |
54 | - 'Select the currency for your country. Payments will be accepted in this currency.', |
|
55 | - 'event_espresso' |
|
56 | - ); ?> |
|
54 | + 'Select the currency for your country. Payments will be accepted in this currency.', |
|
55 | + 'event_espresso' |
|
56 | + ); ?> |
|
57 | 57 | </li> |
58 | 58 | <li> |
59 | 59 | <strong><?php esc_html_e('Accepted Card Types', 'event_espresso'); ?></strong><br/> |
@@ -62,9 +62,9 @@ discard block |
||
62 | 62 | <li> |
63 | 63 | <strong><?php esc_html_e('Use the Debugging Feature and the PayPal Sandbox', 'event_espresso'); ?></strong><br/> |
64 | 64 | <?php esc_html_e( |
65 | - 'Specify if you want to test the payment gateway by submitting a test transaction. If this option is enabled, be sure to enter your PayPal sandbox credentials in the fields above. Be sure to turn this setting off when you are done testing.', |
|
66 | - 'event_espresso' |
|
67 | - ); ?> |
|
65 | + 'Specify if you want to test the payment gateway by submitting a test transaction. If this option is enabled, be sure to enter your PayPal sandbox credentials in the fields above. Be sure to turn this setting off when you are done testing.', |
|
66 | + 'event_espresso' |
|
67 | + ); ?> |
|
68 | 68 | </li> |
69 | 69 | <li> |
70 | 70 | <strong><?php esc_html_e('Button Image URL', 'event_espresso'); ?></strong><br/> |
@@ -20,1087 +20,1087 @@ |
||
20 | 20 | class EE_Dependency_Map |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * This means that the requested class dependency is not present in the dependency map |
|
25 | - */ |
|
26 | - const not_registered = 0; |
|
27 | - |
|
28 | - /** |
|
29 | - * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
30 | - */ |
|
31 | - const load_new_object = 1; |
|
32 | - |
|
33 | - /** |
|
34 | - * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
35 | - * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
36 | - */ |
|
37 | - const load_from_cache = 2; |
|
38 | - |
|
39 | - /** |
|
40 | - * When registering a dependency, |
|
41 | - * this indicates to keep any existing dependencies that already exist, |
|
42 | - * and simply discard any new dependencies declared in the incoming data |
|
43 | - */ |
|
44 | - const KEEP_EXISTING_DEPENDENCIES = 0; |
|
45 | - |
|
46 | - /** |
|
47 | - * When registering a dependency, |
|
48 | - * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
49 | - */ |
|
50 | - const OVERWRITE_DEPENDENCIES = 1; |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * @type EE_Dependency_Map $_instance |
|
55 | - */ |
|
56 | - protected static $_instance; |
|
57 | - |
|
58 | - /** |
|
59 | - * @var ClassInterfaceCache $class_cache |
|
60 | - */ |
|
61 | - private $class_cache; |
|
62 | - |
|
63 | - /** |
|
64 | - * @type RequestInterface $request |
|
65 | - */ |
|
66 | - protected $request; |
|
67 | - |
|
68 | - /** |
|
69 | - * @type LegacyRequestInterface $legacy_request |
|
70 | - */ |
|
71 | - protected $legacy_request; |
|
72 | - |
|
73 | - /** |
|
74 | - * @type ResponseInterface $response |
|
75 | - */ |
|
76 | - protected $response; |
|
77 | - |
|
78 | - /** |
|
79 | - * @type LoaderInterface $loader |
|
80 | - */ |
|
81 | - protected $loader; |
|
82 | - |
|
83 | - /** |
|
84 | - * @type array $_dependency_map |
|
85 | - */ |
|
86 | - protected $_dependency_map = array(); |
|
87 | - |
|
88 | - /** |
|
89 | - * @type array $_class_loaders |
|
90 | - */ |
|
91 | - protected $_class_loaders = array(); |
|
92 | - |
|
93 | - |
|
94 | - /** |
|
95 | - * EE_Dependency_Map constructor. |
|
96 | - * |
|
97 | - * @param ClassInterfaceCache $class_cache |
|
98 | - */ |
|
99 | - protected function __construct(ClassInterfaceCache $class_cache) |
|
100 | - { |
|
101 | - $this->class_cache = $class_cache; |
|
102 | - do_action('EE_Dependency_Map____construct', $this); |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - /** |
|
107 | - * @return void |
|
108 | - */ |
|
109 | - public function initialize() |
|
110 | - { |
|
111 | - $this->_register_core_dependencies(); |
|
112 | - $this->_register_core_class_loaders(); |
|
113 | - $this->_register_core_aliases(); |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * @singleton method used to instantiate class object |
|
119 | - * @param ClassInterfaceCache|null $class_cache |
|
120 | - * @return EE_Dependency_Map |
|
121 | - */ |
|
122 | - public static function instance(ClassInterfaceCache $class_cache = null) |
|
123 | - { |
|
124 | - // check if class object is instantiated, and instantiated properly |
|
125 | - if (! self::$_instance instanceof EE_Dependency_Map |
|
126 | - && $class_cache instanceof ClassInterfaceCache |
|
127 | - ) { |
|
128 | - self::$_instance = new EE_Dependency_Map($class_cache); |
|
129 | - } |
|
130 | - return self::$_instance; |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * @param RequestInterface $request |
|
136 | - */ |
|
137 | - public function setRequest(RequestInterface $request) |
|
138 | - { |
|
139 | - $this->request = $request; |
|
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * @param LegacyRequestInterface $legacy_request |
|
145 | - */ |
|
146 | - public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
147 | - { |
|
148 | - $this->legacy_request = $legacy_request; |
|
149 | - } |
|
150 | - |
|
151 | - |
|
152 | - /** |
|
153 | - * @param ResponseInterface $response |
|
154 | - */ |
|
155 | - public function setResponse(ResponseInterface $response) |
|
156 | - { |
|
157 | - $this->response = $response; |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * @param LoaderInterface $loader |
|
163 | - */ |
|
164 | - public function setLoader(LoaderInterface $loader) |
|
165 | - { |
|
166 | - $this->loader = $loader; |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - /** |
|
171 | - * @param string $class |
|
172 | - * @param array $dependencies |
|
173 | - * @param int $overwrite |
|
174 | - * @return bool |
|
175 | - */ |
|
176 | - public static function register_dependencies( |
|
177 | - $class, |
|
178 | - array $dependencies, |
|
179 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
180 | - ) { |
|
181 | - return self::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
182 | - } |
|
183 | - |
|
184 | - |
|
185 | - /** |
|
186 | - * Assigns an array of class names and corresponding load sources (new or cached) |
|
187 | - * to the class specified by the first parameter. |
|
188 | - * IMPORTANT !!! |
|
189 | - * The order of elements in the incoming $dependencies array MUST match |
|
190 | - * the order of the constructor parameters for the class in question. |
|
191 | - * This is especially important when overriding any existing dependencies that are registered. |
|
192 | - * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
193 | - * |
|
194 | - * @param string $class |
|
195 | - * @param array $dependencies |
|
196 | - * @param int $overwrite |
|
197 | - * @return bool |
|
198 | - */ |
|
199 | - public function registerDependencies( |
|
200 | - $class, |
|
201 | - array $dependencies, |
|
202 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
203 | - ) { |
|
204 | - $class = trim($class, '\\'); |
|
205 | - $registered = false; |
|
206 | - if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
207 | - self::$_instance->_dependency_map[ $class ] = array(); |
|
208 | - } |
|
209 | - // we need to make sure that any aliases used when registering a dependency |
|
210 | - // get resolved to the correct class name |
|
211 | - foreach ($dependencies as $dependency => $load_source) { |
|
212 | - $alias = self::$_instance->getFqnForAlias($dependency); |
|
213 | - if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
214 | - || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
215 | - ) { |
|
216 | - unset($dependencies[ $dependency ]); |
|
217 | - $dependencies[ $alias ] = $load_source; |
|
218 | - $registered = true; |
|
219 | - } |
|
220 | - } |
|
221 | - // now add our two lists of dependencies together. |
|
222 | - // using Union (+=) favours the arrays in precedence from left to right, |
|
223 | - // so $dependencies is NOT overwritten because it is listed first |
|
224 | - // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
225 | - // Union is way faster than array_merge() but should be used with caution... |
|
226 | - // especially with numerically indexed arrays |
|
227 | - $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
228 | - // now we need to ensure that the resulting dependencies |
|
229 | - // array only has the entries that are required for the class |
|
230 | - // so first count how many dependencies were originally registered for the class |
|
231 | - $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
232 | - // if that count is non-zero (meaning dependencies were already registered) |
|
233 | - self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
234 | - // then truncate the final array to match that count |
|
235 | - ? array_slice($dependencies, 0, $dependency_count) |
|
236 | - // otherwise just take the incoming array because nothing previously existed |
|
237 | - : $dependencies; |
|
238 | - return $registered; |
|
239 | - } |
|
240 | - |
|
241 | - |
|
242 | - /** |
|
243 | - * @param string $class_name |
|
244 | - * @param string $loader |
|
245 | - * @return bool |
|
246 | - * @throws DomainException |
|
247 | - */ |
|
248 | - public static function register_class_loader($class_name, $loader = 'load_core') |
|
249 | - { |
|
250 | - if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
251 | - throw new DomainException( |
|
252 | - esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
253 | - ); |
|
254 | - } |
|
255 | - // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
256 | - if (! is_callable($loader) |
|
257 | - && ( |
|
258 | - strpos($loader, 'load_') !== 0 |
|
259 | - || ! method_exists('EE_Registry', $loader) |
|
260 | - ) |
|
261 | - ) { |
|
262 | - throw new DomainException( |
|
263 | - sprintf( |
|
264 | - esc_html__( |
|
265 | - '"%1$s" is not a valid loader method on EE_Registry.', |
|
266 | - 'event_espresso' |
|
267 | - ), |
|
268 | - $loader |
|
269 | - ) |
|
270 | - ); |
|
271 | - } |
|
272 | - $class_name = self::$_instance->getFqnForAlias($class_name); |
|
273 | - if (! isset(self::$_instance->_class_loaders[ $class_name ])) { |
|
274 | - self::$_instance->_class_loaders[ $class_name ] = $loader; |
|
275 | - return true; |
|
276 | - } |
|
277 | - return false; |
|
278 | - } |
|
279 | - |
|
280 | - |
|
281 | - /** |
|
282 | - * @return array |
|
283 | - */ |
|
284 | - public function dependency_map() |
|
285 | - { |
|
286 | - return $this->_dependency_map; |
|
287 | - } |
|
288 | - |
|
289 | - |
|
290 | - /** |
|
291 | - * returns TRUE if dependency map contains a listing for the provided class name |
|
292 | - * |
|
293 | - * @param string $class_name |
|
294 | - * @return boolean |
|
295 | - */ |
|
296 | - public function has($class_name = '') |
|
297 | - { |
|
298 | - // all legacy models have the same dependencies |
|
299 | - if (strpos($class_name, 'EEM_') === 0) { |
|
300 | - $class_name = 'LEGACY_MODELS'; |
|
301 | - } |
|
302 | - return isset($this->_dependency_map[ $class_name ]) ? true : false; |
|
303 | - } |
|
304 | - |
|
305 | - |
|
306 | - /** |
|
307 | - * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
308 | - * |
|
309 | - * @param string $class_name |
|
310 | - * @param string $dependency |
|
311 | - * @return bool |
|
312 | - */ |
|
313 | - public function has_dependency_for_class($class_name = '', $dependency = '') |
|
314 | - { |
|
315 | - // all legacy models have the same dependencies |
|
316 | - if (strpos($class_name, 'EEM_') === 0) { |
|
317 | - $class_name = 'LEGACY_MODELS'; |
|
318 | - } |
|
319 | - $dependency = $this->getFqnForAlias($dependency, $class_name); |
|
320 | - return isset($this->_dependency_map[ $class_name ][ $dependency ]) |
|
321 | - ? true |
|
322 | - : false; |
|
323 | - } |
|
324 | - |
|
325 | - |
|
326 | - /** |
|
327 | - * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
328 | - * |
|
329 | - * @param string $class_name |
|
330 | - * @param string $dependency |
|
331 | - * @return int |
|
332 | - */ |
|
333 | - public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
334 | - { |
|
335 | - // all legacy models have the same dependencies |
|
336 | - if (strpos($class_name, 'EEM_') === 0) { |
|
337 | - $class_name = 'LEGACY_MODELS'; |
|
338 | - } |
|
339 | - $dependency = $this->getFqnForAlias($dependency); |
|
340 | - return $this->has_dependency_for_class($class_name, $dependency) |
|
341 | - ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
342 | - : EE_Dependency_Map::not_registered; |
|
343 | - } |
|
344 | - |
|
345 | - |
|
346 | - /** |
|
347 | - * @param string $class_name |
|
348 | - * @return string | Closure |
|
349 | - */ |
|
350 | - public function class_loader($class_name) |
|
351 | - { |
|
352 | - // all legacy models use load_model() |
|
353 | - if (strpos($class_name, 'EEM_') === 0) { |
|
354 | - return 'load_model'; |
|
355 | - } |
|
356 | - // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc |
|
357 | - // perform strpos() first to avoid loading regex every time we load a class |
|
358 | - if (strpos($class_name, 'EE_CPT_') === 0 |
|
359 | - && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name) |
|
360 | - ) { |
|
361 | - return 'load_core'; |
|
362 | - } |
|
363 | - $class_name = $this->getFqnForAlias($class_name); |
|
364 | - return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : ''; |
|
365 | - } |
|
366 | - |
|
367 | - |
|
368 | - /** |
|
369 | - * @return array |
|
370 | - */ |
|
371 | - public function class_loaders() |
|
372 | - { |
|
373 | - return $this->_class_loaders; |
|
374 | - } |
|
375 | - |
|
376 | - |
|
377 | - /** |
|
378 | - * adds an alias for a classname |
|
379 | - * |
|
380 | - * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
381 | - * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
382 | - * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
383 | - */ |
|
384 | - public function add_alias($fqcn, $alias, $for_class = '') |
|
385 | - { |
|
386 | - $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
387 | - } |
|
388 | - |
|
389 | - |
|
390 | - /** |
|
391 | - * Returns TRUE if the provided fully qualified name IS an alias |
|
392 | - * WHY? |
|
393 | - * Because if a class is type hinting for a concretion, |
|
394 | - * then why would we need to find another class to supply it? |
|
395 | - * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
396 | - * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
397 | - * Don't go looking for some substitute. |
|
398 | - * Whereas if a class is type hinting for an interface... |
|
399 | - * then we need to find an actual class to use. |
|
400 | - * So the interface IS the alias for some other FQN, |
|
401 | - * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
402 | - * represents some other class. |
|
403 | - * |
|
404 | - * @param string $fqn |
|
405 | - * @param string $for_class |
|
406 | - * @return bool |
|
407 | - */ |
|
408 | - public function isAlias($fqn = '', $for_class = '') |
|
409 | - { |
|
410 | - return $this->class_cache->isAlias($fqn, $for_class); |
|
411 | - } |
|
412 | - |
|
413 | - |
|
414 | - /** |
|
415 | - * Returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
416 | - * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
417 | - * for example: |
|
418 | - * if the following two entries were added to the _aliases array: |
|
419 | - * array( |
|
420 | - * 'interface_alias' => 'some\namespace\interface' |
|
421 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
422 | - * ) |
|
423 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
424 | - * to load an instance of 'some\namespace\classname' |
|
425 | - * |
|
426 | - * @param string $alias |
|
427 | - * @param string $for_class |
|
428 | - * @return string |
|
429 | - */ |
|
430 | - public function getFqnForAlias($alias = '', $for_class = '') |
|
431 | - { |
|
432 | - return (string) $this->class_cache->getFqnForAlias($alias, $for_class); |
|
433 | - } |
|
434 | - |
|
435 | - |
|
436 | - /** |
|
437 | - * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
438 | - * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
439 | - * This is done by using the following class constants: |
|
440 | - * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
441 | - * EE_Dependency_Map::load_new_object - generates a new object every time |
|
442 | - */ |
|
443 | - protected function _register_core_dependencies() |
|
444 | - { |
|
445 | - $this->_dependency_map = array( |
|
446 | - 'EE_Request_Handler' => array( |
|
447 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
448 | - ), |
|
449 | - 'EE_System' => array( |
|
450 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
451 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
452 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
453 | - 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
454 | - ), |
|
455 | - 'EE_Session' => array( |
|
456 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
457 | - 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
458 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
459 | - 'EventEspresso\core\services\session\SessionStartHandler' => EE_Dependency_Map::load_from_cache, |
|
460 | - 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
461 | - ), |
|
462 | - 'EE_Cart' => array( |
|
463 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
464 | - ), |
|
465 | - 'EE_Front_Controller' => array( |
|
466 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
467 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
468 | - 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
469 | - ), |
|
470 | - 'EE_Messenger_Collection_Loader' => array( |
|
471 | - 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
472 | - ), |
|
473 | - 'EE_Message_Type_Collection_Loader' => array( |
|
474 | - 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
475 | - ), |
|
476 | - 'EE_Message_Resource_Manager' => array( |
|
477 | - 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
478 | - 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
479 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
480 | - ), |
|
481 | - 'EE_Message_Factory' => array( |
|
482 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
483 | - ), |
|
484 | - 'EE_messages' => array( |
|
485 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
486 | - ), |
|
487 | - 'EE_Messages_Generator' => array( |
|
488 | - 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
489 | - 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
490 | - 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
491 | - 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
492 | - ), |
|
493 | - 'EE_Messages_Processor' => array( |
|
494 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
495 | - ), |
|
496 | - 'EE_Messages_Queue' => array( |
|
497 | - 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
498 | - ), |
|
499 | - 'EE_Messages_Template_Defaults' => array( |
|
500 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
501 | - 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
502 | - ), |
|
503 | - 'EE_Message_To_Generate_From_Request' => array( |
|
504 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
505 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
506 | - ), |
|
507 | - 'EventEspresso\core\services\commands\CommandBus' => array( |
|
508 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
509 | - ), |
|
510 | - 'EventEspresso\services\commands\CommandHandler' => array( |
|
511 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
512 | - 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
513 | - ), |
|
514 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => array( |
|
515 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
516 | - ), |
|
517 | - 'EventEspresso\core\services\commands\CompositeCommandHandler' => array( |
|
518 | - 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
519 | - 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
520 | - ), |
|
521 | - 'EventEspresso\core\services\commands\CommandFactory' => array( |
|
522 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
523 | - ), |
|
524 | - 'EventEspresso\core\services\commands\middleware\CapChecker' => array( |
|
525 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
526 | - ), |
|
527 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => array( |
|
528 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
529 | - ), |
|
530 | - 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => array( |
|
531 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
532 | - ), |
|
533 | - 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => array( |
|
534 | - 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
535 | - ), |
|
536 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => array( |
|
537 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
538 | - ), |
|
539 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => array( |
|
540 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
541 | - ), |
|
542 | - 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => array( |
|
543 | - 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
544 | - ), |
|
545 | - 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array( |
|
546 | - 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
547 | - ), |
|
548 | - 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => array( |
|
549 | - 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
550 | - ), |
|
551 | - 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => array( |
|
552 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
553 | - ), |
|
554 | - 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => array( |
|
555 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
556 | - ), |
|
557 | - 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => array( |
|
558 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
559 | - ), |
|
560 | - 'EventEspresso\core\services\database\TableManager' => array( |
|
561 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
562 | - ), |
|
563 | - 'EE_Data_Migration_Class_Base' => array( |
|
564 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
565 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
566 | - ), |
|
567 | - 'EE_DMS_Core_4_1_0' => array( |
|
568 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
569 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
570 | - ), |
|
571 | - 'EE_DMS_Core_4_2_0' => array( |
|
572 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
573 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
574 | - ), |
|
575 | - 'EE_DMS_Core_4_3_0' => array( |
|
576 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
577 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
578 | - ), |
|
579 | - 'EE_DMS_Core_4_4_0' => array( |
|
580 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
581 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
582 | - ), |
|
583 | - 'EE_DMS_Core_4_5_0' => array( |
|
584 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
585 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
586 | - ), |
|
587 | - 'EE_DMS_Core_4_6_0' => array( |
|
588 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
589 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
590 | - ), |
|
591 | - 'EE_DMS_Core_4_7_0' => array( |
|
592 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
593 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
594 | - ), |
|
595 | - 'EE_DMS_Core_4_8_0' => array( |
|
596 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
597 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
598 | - ), |
|
599 | - 'EE_DMS_Core_4_9_0' => array( |
|
600 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
601 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
602 | - ), |
|
603 | - 'EventEspresso\core\services\assets\I18nRegistry' => array( |
|
604 | - array(), |
|
605 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
606 | - ), |
|
607 | - 'EventEspresso\core\services\assets\Registry' => array( |
|
608 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
609 | - 'EventEspresso\core\services\assets\I18nRegistry' => EE_Dependency_Map::load_from_cache, |
|
610 | - ), |
|
611 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => array( |
|
612 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
613 | - ), |
|
614 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => array( |
|
615 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
616 | - ), |
|
617 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => array( |
|
618 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
619 | - ), |
|
620 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => array( |
|
621 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
622 | - ), |
|
623 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => array( |
|
624 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
625 | - ), |
|
626 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => array( |
|
627 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
628 | - ), |
|
629 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => array( |
|
630 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
631 | - ), |
|
632 | - 'EventEspresso\core\services\cache\BasicCacheManager' => array( |
|
633 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
634 | - ), |
|
635 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => array( |
|
636 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
637 | - ), |
|
638 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array( |
|
639 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
640 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
641 | - ), |
|
642 | - 'EventEspresso\core\domain\values\EmailAddress' => array( |
|
643 | - null, |
|
644 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
645 | - ), |
|
646 | - 'EventEspresso\core\services\orm\ModelFieldFactory' => array( |
|
647 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
648 | - ), |
|
649 | - 'LEGACY_MODELS' => array( |
|
650 | - null, |
|
651 | - 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
652 | - ), |
|
653 | - 'EE_Module_Request_Router' => array( |
|
654 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
655 | - ), |
|
656 | - 'EE_Registration_Processor' => array( |
|
657 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
658 | - ), |
|
659 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array( |
|
660 | - null, |
|
661 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
662 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
663 | - ), |
|
664 | - 'EventEspresso\core\services\licensing\LicenseService' => array( |
|
665 | - 'EventEspresso\core\domain\services\pue\Stats' => EE_Dependency_Map::load_from_cache, |
|
666 | - 'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache, |
|
667 | - ), |
|
668 | - 'EE_Admin_Transactions_List_Table' => array( |
|
669 | - null, |
|
670 | - 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
671 | - ), |
|
672 | - 'EventEspresso\core\domain\services\pue\Stats' => array( |
|
673 | - 'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache, |
|
674 | - 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
675 | - 'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache, |
|
676 | - ), |
|
677 | - 'EventEspresso\core\domain\services\pue\Config' => array( |
|
678 | - 'EE_Network_Config' => EE_Dependency_Map::load_from_cache, |
|
679 | - 'EE_Config' => EE_Dependency_Map::load_from_cache, |
|
680 | - ), |
|
681 | - 'EventEspresso\core\domain\services\pue\StatsGatherer' => array( |
|
682 | - 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
683 | - 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
684 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
685 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
686 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
687 | - 'EEM_Transaction' => EE_Dependency_Map::load_from_cache, |
|
688 | - 'EE_Config' => EE_Dependency_Map::load_from_cache, |
|
689 | - ), |
|
690 | - 'EventEspresso\core\domain\services\admin\ExitModal' => array( |
|
691 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
692 | - ), |
|
693 | - 'EventEspresso\core\domain\services\admin\PluginUpsells' => array( |
|
694 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
695 | - ), |
|
696 | - 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => array( |
|
697 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
698 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
699 | - ), |
|
700 | - 'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings' => array( |
|
701 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
702 | - ), |
|
703 | - 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => array( |
|
704 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
705 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
706 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
707 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
708 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
709 | - ), |
|
710 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => array( |
|
711 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
712 | - ), |
|
713 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => array( |
|
714 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
715 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
716 | - ), |
|
717 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' => array( |
|
718 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
719 | - ), |
|
720 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' => array( |
|
721 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
722 | - ), |
|
723 | - 'EE_CPT_Strategy' => array( |
|
724 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
725 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
726 | - ), |
|
727 | - 'EventEspresso\core\services\loaders\ObjectIdentifier' => array( |
|
728 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
729 | - ), |
|
730 | - 'EventEspresso\core\domain\services\assets\CoreAssetManager' => array( |
|
731 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
732 | - 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
733 | - 'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
|
734 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
735 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
736 | - ), |
|
737 | - 'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => array( |
|
738 | - 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
739 | - 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache |
|
740 | - ), |
|
741 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => array( |
|
742 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
743 | - ), |
|
744 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => array( |
|
745 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
746 | - 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache |
|
747 | - ), |
|
748 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => array( |
|
749 | - 'EEM_Checkin' => EE_Dependency_Map::load_from_cache, |
|
750 | - ), |
|
751 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => array( |
|
752 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
753 | - ), |
|
754 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => array( |
|
755 | - 'EEM_Transaction' => EE_Dependency_Map::load_from_cache, |
|
756 | - ), |
|
757 | - 'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => array( |
|
758 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
759 | - ), |
|
760 | - 'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => array( |
|
761 | - 'EEM_Answer' => EE_Dependency_Map::load_from_cache, |
|
762 | - 'EEM_Question' => EE_Dependency_Map::load_from_cache, |
|
763 | - ), |
|
764 | - 'EventEspresso\core\CPTs\CptQueryModifier' => array( |
|
765 | - null, |
|
766 | - null, |
|
767 | - null, |
|
768 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
769 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
770 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
771 | - ), |
|
772 | - 'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler' => array( |
|
773 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
774 | - 'EE_Config' => EE_Dependency_Map::load_from_cache |
|
775 | - ), |
|
776 | - 'EventEspresso\core\services\editor\BlockRegistrationManager' => array( |
|
777 | - 'EventEspresso\core\services\assets\BlockAssetManagerCollection' => EE_Dependency_Map::load_from_cache, |
|
778 | - 'EventEspresso\core\domain\entities\editor\BlockCollection' => EE_Dependency_Map::load_from_cache, |
|
779 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache, |
|
780 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
781 | - ), |
|
782 | - 'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => array( |
|
783 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
784 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
785 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
786 | - ), |
|
787 | - 'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => array( |
|
788 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
789 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
790 | - ), |
|
791 | - 'EventEspresso\core\domain\entities\editor\blocks\EventAttendees' => array( |
|
792 | - 'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => self::load_from_cache, |
|
793 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
794 | - 'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => self::load_from_cache, |
|
795 | - ), |
|
796 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => array( |
|
797 | - 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
798 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
799 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
800 | - ), |
|
801 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => array( |
|
802 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache, |
|
803 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
804 | - ), |
|
805 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => array( |
|
806 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache, |
|
807 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache, |
|
808 | - ), |
|
809 | - 'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => array( |
|
810 | - 'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => EE_Dependency_Map::load_from_cache |
|
811 | - ), |
|
812 | - 'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => array( |
|
813 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
814 | - ), |
|
815 | - 'EventEspresso\core\libraries\rest_api\controllers\model\Read' => array( |
|
816 | - 'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => EE_Dependency_Map::load_from_cache |
|
817 | - ), |
|
818 | - 'EventEspresso\core\libraries\rest_api\calculations\Datetime' => array( |
|
819 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
820 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache |
|
821 | - ), |
|
822 | - 'EventEspresso\core\libraries\rest_api\calculations\Event' => array( |
|
823 | - 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
824 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache |
|
825 | - ), |
|
826 | - 'EventEspresso\core\libraries\rest_api\calculations\Registration' => array( |
|
827 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache |
|
828 | - ), |
|
829 | - 'EventEspresso\core\services\session\SessionStartHandler' => array( |
|
830 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
831 | - ), |
|
832 | - 'EE_URL_Validation_Strategy' => array( |
|
833 | - null, |
|
834 | - null, |
|
835 | - 'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache |
|
836 | - ), |
|
837 | - 'EventEspresso\admin_pages\general_settings\OrganizationSettings' => array( |
|
838 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
839 | - 'EE_Organization_Config' => EE_Dependency_Map::load_from_cache, |
|
840 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
841 | - 'EE_Network_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
842 | - 'EventEspresso\core\services\address\CountrySubRegionDao' => EE_Dependency_Map::load_from_cache, |
|
843 | - ), |
|
844 | - 'EventEspresso\core\services\address\CountrySubRegionDao' => array( |
|
845 | - 'EEM_State' => EE_Dependency_Map::load_from_cache, |
|
846 | - 'EventEspresso\core\services\validators\JsonValidator' => EE_Dependency_Map::load_from_cache |
|
847 | - ), |
|
848 | - 'EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat' => array( |
|
849 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
850 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
851 | - ), |
|
852 | - 'EventEspresso\core\domain\services\admin\ajax\EventEditorHeartbeat' => array( |
|
853 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
854 | - 'EE_Environment_Config' => EE_Dependency_Map::load_from_cache, |
|
855 | - ), |
|
856 | - 'EventEspresso\core\services\request\files\FilesDataHandler' => array( |
|
857 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
858 | - ), |
|
859 | - ); |
|
860 | - } |
|
861 | - |
|
862 | - |
|
863 | - /** |
|
864 | - * Registers how core classes are loaded. |
|
865 | - * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
866 | - * 'EE_Request_Handler' => 'load_core' |
|
867 | - * 'EE_Messages_Queue' => 'load_lib' |
|
868 | - * 'EEH_Debug_Tools' => 'load_helper' |
|
869 | - * or, if greater control is required, by providing a custom closure. For example: |
|
870 | - * 'Some_Class' => function () { |
|
871 | - * return new Some_Class(); |
|
872 | - * }, |
|
873 | - * This is required for instantiating dependencies |
|
874 | - * where an interface has been type hinted in a class constructor. For example: |
|
875 | - * 'Required_Interface' => function () { |
|
876 | - * return new A_Class_That_Implements_Required_Interface(); |
|
877 | - * }, |
|
878 | - */ |
|
879 | - protected function _register_core_class_loaders() |
|
880 | - { |
|
881 | - $this->_class_loaders = array( |
|
882 | - // load_core |
|
883 | - 'EE_Dependency_Map' => function () { |
|
884 | - return $this; |
|
885 | - }, |
|
886 | - 'EE_Capabilities' => 'load_core', |
|
887 | - 'EE_Encryption' => 'load_core', |
|
888 | - 'EE_Front_Controller' => 'load_core', |
|
889 | - 'EE_Module_Request_Router' => 'load_core', |
|
890 | - 'EE_Registry' => 'load_core', |
|
891 | - 'EE_Request' => function () { |
|
892 | - return $this->legacy_request; |
|
893 | - }, |
|
894 | - 'EventEspresso\core\services\request\Request' => function () { |
|
895 | - return $this->request; |
|
896 | - }, |
|
897 | - 'EventEspresso\core\services\request\Response' => function () { |
|
898 | - return $this->response; |
|
899 | - }, |
|
900 | - 'EE_Base' => 'load_core', |
|
901 | - 'EE_Request_Handler' => 'load_core', |
|
902 | - 'EE_Session' => 'load_core', |
|
903 | - 'EE_Cron_Tasks' => 'load_core', |
|
904 | - 'EE_System' => 'load_core', |
|
905 | - 'EE_Maintenance_Mode' => 'load_core', |
|
906 | - 'EE_Register_CPTs' => 'load_core', |
|
907 | - 'EE_Admin' => 'load_core', |
|
908 | - 'EE_CPT_Strategy' => 'load_core', |
|
909 | - // load_lib |
|
910 | - 'EE_Message_Resource_Manager' => 'load_lib', |
|
911 | - 'EE_Message_Type_Collection' => 'load_lib', |
|
912 | - 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
913 | - 'EE_Messenger_Collection' => 'load_lib', |
|
914 | - 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
915 | - 'EE_Messages_Processor' => 'load_lib', |
|
916 | - 'EE_Message_Repository' => 'load_lib', |
|
917 | - 'EE_Messages_Queue' => 'load_lib', |
|
918 | - 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
919 | - 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
920 | - 'EE_Payment_Method_Manager' => 'load_lib', |
|
921 | - 'EE_Messages_Generator' => function () { |
|
922 | - return EE_Registry::instance()->load_lib( |
|
923 | - 'Messages_Generator', |
|
924 | - array(), |
|
925 | - false, |
|
926 | - false |
|
927 | - ); |
|
928 | - }, |
|
929 | - 'EE_Messages_Template_Defaults' => function ($arguments = array()) { |
|
930 | - return EE_Registry::instance()->load_lib( |
|
931 | - 'Messages_Template_Defaults', |
|
932 | - $arguments, |
|
933 | - false, |
|
934 | - false |
|
935 | - ); |
|
936 | - }, |
|
937 | - // load_helper |
|
938 | - 'EEH_Parse_Shortcodes' => function () { |
|
939 | - if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
940 | - return new EEH_Parse_Shortcodes(); |
|
941 | - } |
|
942 | - return null; |
|
943 | - }, |
|
944 | - 'EE_Template_Config' => function () { |
|
945 | - return EE_Config::instance()->template_settings; |
|
946 | - }, |
|
947 | - 'EE_Currency_Config' => function () { |
|
948 | - return EE_Config::instance()->currency; |
|
949 | - }, |
|
950 | - 'EE_Registration_Config' => function () { |
|
951 | - return EE_Config::instance()->registration; |
|
952 | - }, |
|
953 | - 'EE_Core_Config' => function () { |
|
954 | - return EE_Config::instance()->core; |
|
955 | - }, |
|
956 | - 'EventEspresso\core\services\loaders\Loader' => function () { |
|
957 | - return LoaderFactory::getLoader(); |
|
958 | - }, |
|
959 | - 'EE_Network_Config' => function () { |
|
960 | - return EE_Network_Config::instance(); |
|
961 | - }, |
|
962 | - 'EE_Config' => function () { |
|
963 | - return EE_Config::instance(); |
|
964 | - }, |
|
965 | - 'EventEspresso\core\domain\Domain' => function () { |
|
966 | - return DomainFactory::getEventEspressoCoreDomain(); |
|
967 | - }, |
|
968 | - 'EE_Admin_Config' => function () { |
|
969 | - return EE_Config::instance()->admin; |
|
970 | - }, |
|
971 | - 'EE_Organization_Config' => function () { |
|
972 | - return EE_Config::instance()->organization; |
|
973 | - }, |
|
974 | - 'EE_Network_Core_Config' => function () { |
|
975 | - return EE_Network_Config::instance()->core; |
|
976 | - }, |
|
977 | - 'EE_Environment_Config' => function () { |
|
978 | - return EE_Config::instance()->environment; |
|
979 | - }, |
|
980 | - ); |
|
981 | - } |
|
982 | - |
|
983 | - |
|
984 | - /** |
|
985 | - * can be used for supplying alternate names for classes, |
|
986 | - * or for connecting interface names to instantiable classes |
|
987 | - */ |
|
988 | - protected function _register_core_aliases() |
|
989 | - { |
|
990 | - $aliases = array( |
|
991 | - 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
992 | - 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
993 | - 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
994 | - 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
995 | - 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
996 | - 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
997 | - 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
998 | - 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
999 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
1000 | - 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
1001 | - 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
1002 | - 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
1003 | - 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
1004 | - 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
1005 | - 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
1006 | - 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
1007 | - 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
1008 | - 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
1009 | - 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
1010 | - 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
1011 | - 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
1012 | - 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
1013 | - 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
1014 | - 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
1015 | - 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
1016 | - 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
1017 | - 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
1018 | - 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
1019 | - 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
1020 | - 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
1021 | - 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
1022 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
1023 | - 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
1024 | - 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
1025 | - 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
1026 | - 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
1027 | - 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
1028 | - ); |
|
1029 | - foreach ($aliases as $alias => $fqn) { |
|
1030 | - if (is_array($fqn)) { |
|
1031 | - foreach ($fqn as $class => $for_class) { |
|
1032 | - $this->class_cache->addAlias($class, $alias, $for_class); |
|
1033 | - } |
|
1034 | - continue; |
|
1035 | - } |
|
1036 | - $this->class_cache->addAlias($fqn, $alias); |
|
1037 | - } |
|
1038 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
1039 | - $this->class_cache->addAlias( |
|
1040 | - 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices', |
|
1041 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' |
|
1042 | - ); |
|
1043 | - } |
|
1044 | - } |
|
1045 | - |
|
1046 | - |
|
1047 | - /** |
|
1048 | - * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
1049 | - * request Primarily used by unit tests. |
|
1050 | - */ |
|
1051 | - public function reset() |
|
1052 | - { |
|
1053 | - $this->_register_core_class_loaders(); |
|
1054 | - $this->_register_core_dependencies(); |
|
1055 | - } |
|
1056 | - |
|
1057 | - |
|
1058 | - /** |
|
1059 | - * PLZ NOTE: a better name for this method would be is_alias() |
|
1060 | - * because it returns TRUE if the provided fully qualified name IS an alias |
|
1061 | - * WHY? |
|
1062 | - * Because if a class is type hinting for a concretion, |
|
1063 | - * then why would we need to find another class to supply it? |
|
1064 | - * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
1065 | - * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
1066 | - * Don't go looking for some substitute. |
|
1067 | - * Whereas if a class is type hinting for an interface... |
|
1068 | - * then we need to find an actual class to use. |
|
1069 | - * So the interface IS the alias for some other FQN, |
|
1070 | - * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
1071 | - * represents some other class. |
|
1072 | - * |
|
1073 | - * @deprecated 4.9.62.p |
|
1074 | - * @param string $fqn |
|
1075 | - * @param string $for_class |
|
1076 | - * @return bool |
|
1077 | - */ |
|
1078 | - public function has_alias($fqn = '', $for_class = '') |
|
1079 | - { |
|
1080 | - return $this->isAlias($fqn, $for_class); |
|
1081 | - } |
|
1082 | - |
|
1083 | - |
|
1084 | - /** |
|
1085 | - * PLZ NOTE: a better name for this method would be get_fqn_for_alias() |
|
1086 | - * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
1087 | - * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
1088 | - * for example: |
|
1089 | - * if the following two entries were added to the _aliases array: |
|
1090 | - * array( |
|
1091 | - * 'interface_alias' => 'some\namespace\interface' |
|
1092 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
1093 | - * ) |
|
1094 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
1095 | - * to load an instance of 'some\namespace\classname' |
|
1096 | - * |
|
1097 | - * @deprecated 4.9.62.p |
|
1098 | - * @param string $alias |
|
1099 | - * @param string $for_class |
|
1100 | - * @return string |
|
1101 | - */ |
|
1102 | - public function get_alias($alias = '', $for_class = '') |
|
1103 | - { |
|
1104 | - return $this->getFqnForAlias($alias, $for_class); |
|
1105 | - } |
|
23 | + /** |
|
24 | + * This means that the requested class dependency is not present in the dependency map |
|
25 | + */ |
|
26 | + const not_registered = 0; |
|
27 | + |
|
28 | + /** |
|
29 | + * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
30 | + */ |
|
31 | + const load_new_object = 1; |
|
32 | + |
|
33 | + /** |
|
34 | + * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
35 | + * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
36 | + */ |
|
37 | + const load_from_cache = 2; |
|
38 | + |
|
39 | + /** |
|
40 | + * When registering a dependency, |
|
41 | + * this indicates to keep any existing dependencies that already exist, |
|
42 | + * and simply discard any new dependencies declared in the incoming data |
|
43 | + */ |
|
44 | + const KEEP_EXISTING_DEPENDENCIES = 0; |
|
45 | + |
|
46 | + /** |
|
47 | + * When registering a dependency, |
|
48 | + * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
49 | + */ |
|
50 | + const OVERWRITE_DEPENDENCIES = 1; |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * @type EE_Dependency_Map $_instance |
|
55 | + */ |
|
56 | + protected static $_instance; |
|
57 | + |
|
58 | + /** |
|
59 | + * @var ClassInterfaceCache $class_cache |
|
60 | + */ |
|
61 | + private $class_cache; |
|
62 | + |
|
63 | + /** |
|
64 | + * @type RequestInterface $request |
|
65 | + */ |
|
66 | + protected $request; |
|
67 | + |
|
68 | + /** |
|
69 | + * @type LegacyRequestInterface $legacy_request |
|
70 | + */ |
|
71 | + protected $legacy_request; |
|
72 | + |
|
73 | + /** |
|
74 | + * @type ResponseInterface $response |
|
75 | + */ |
|
76 | + protected $response; |
|
77 | + |
|
78 | + /** |
|
79 | + * @type LoaderInterface $loader |
|
80 | + */ |
|
81 | + protected $loader; |
|
82 | + |
|
83 | + /** |
|
84 | + * @type array $_dependency_map |
|
85 | + */ |
|
86 | + protected $_dependency_map = array(); |
|
87 | + |
|
88 | + /** |
|
89 | + * @type array $_class_loaders |
|
90 | + */ |
|
91 | + protected $_class_loaders = array(); |
|
92 | + |
|
93 | + |
|
94 | + /** |
|
95 | + * EE_Dependency_Map constructor. |
|
96 | + * |
|
97 | + * @param ClassInterfaceCache $class_cache |
|
98 | + */ |
|
99 | + protected function __construct(ClassInterfaceCache $class_cache) |
|
100 | + { |
|
101 | + $this->class_cache = $class_cache; |
|
102 | + do_action('EE_Dependency_Map____construct', $this); |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + /** |
|
107 | + * @return void |
|
108 | + */ |
|
109 | + public function initialize() |
|
110 | + { |
|
111 | + $this->_register_core_dependencies(); |
|
112 | + $this->_register_core_class_loaders(); |
|
113 | + $this->_register_core_aliases(); |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * @singleton method used to instantiate class object |
|
119 | + * @param ClassInterfaceCache|null $class_cache |
|
120 | + * @return EE_Dependency_Map |
|
121 | + */ |
|
122 | + public static function instance(ClassInterfaceCache $class_cache = null) |
|
123 | + { |
|
124 | + // check if class object is instantiated, and instantiated properly |
|
125 | + if (! self::$_instance instanceof EE_Dependency_Map |
|
126 | + && $class_cache instanceof ClassInterfaceCache |
|
127 | + ) { |
|
128 | + self::$_instance = new EE_Dependency_Map($class_cache); |
|
129 | + } |
|
130 | + return self::$_instance; |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * @param RequestInterface $request |
|
136 | + */ |
|
137 | + public function setRequest(RequestInterface $request) |
|
138 | + { |
|
139 | + $this->request = $request; |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * @param LegacyRequestInterface $legacy_request |
|
145 | + */ |
|
146 | + public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
147 | + { |
|
148 | + $this->legacy_request = $legacy_request; |
|
149 | + } |
|
150 | + |
|
151 | + |
|
152 | + /** |
|
153 | + * @param ResponseInterface $response |
|
154 | + */ |
|
155 | + public function setResponse(ResponseInterface $response) |
|
156 | + { |
|
157 | + $this->response = $response; |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * @param LoaderInterface $loader |
|
163 | + */ |
|
164 | + public function setLoader(LoaderInterface $loader) |
|
165 | + { |
|
166 | + $this->loader = $loader; |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + /** |
|
171 | + * @param string $class |
|
172 | + * @param array $dependencies |
|
173 | + * @param int $overwrite |
|
174 | + * @return bool |
|
175 | + */ |
|
176 | + public static function register_dependencies( |
|
177 | + $class, |
|
178 | + array $dependencies, |
|
179 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
180 | + ) { |
|
181 | + return self::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
182 | + } |
|
183 | + |
|
184 | + |
|
185 | + /** |
|
186 | + * Assigns an array of class names and corresponding load sources (new or cached) |
|
187 | + * to the class specified by the first parameter. |
|
188 | + * IMPORTANT !!! |
|
189 | + * The order of elements in the incoming $dependencies array MUST match |
|
190 | + * the order of the constructor parameters for the class in question. |
|
191 | + * This is especially important when overriding any existing dependencies that are registered. |
|
192 | + * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
193 | + * |
|
194 | + * @param string $class |
|
195 | + * @param array $dependencies |
|
196 | + * @param int $overwrite |
|
197 | + * @return bool |
|
198 | + */ |
|
199 | + public function registerDependencies( |
|
200 | + $class, |
|
201 | + array $dependencies, |
|
202 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
203 | + ) { |
|
204 | + $class = trim($class, '\\'); |
|
205 | + $registered = false; |
|
206 | + if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
207 | + self::$_instance->_dependency_map[ $class ] = array(); |
|
208 | + } |
|
209 | + // we need to make sure that any aliases used when registering a dependency |
|
210 | + // get resolved to the correct class name |
|
211 | + foreach ($dependencies as $dependency => $load_source) { |
|
212 | + $alias = self::$_instance->getFqnForAlias($dependency); |
|
213 | + if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
214 | + || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
215 | + ) { |
|
216 | + unset($dependencies[ $dependency ]); |
|
217 | + $dependencies[ $alias ] = $load_source; |
|
218 | + $registered = true; |
|
219 | + } |
|
220 | + } |
|
221 | + // now add our two lists of dependencies together. |
|
222 | + // using Union (+=) favours the arrays in precedence from left to right, |
|
223 | + // so $dependencies is NOT overwritten because it is listed first |
|
224 | + // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
225 | + // Union is way faster than array_merge() but should be used with caution... |
|
226 | + // especially with numerically indexed arrays |
|
227 | + $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
228 | + // now we need to ensure that the resulting dependencies |
|
229 | + // array only has the entries that are required for the class |
|
230 | + // so first count how many dependencies were originally registered for the class |
|
231 | + $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
232 | + // if that count is non-zero (meaning dependencies were already registered) |
|
233 | + self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
234 | + // then truncate the final array to match that count |
|
235 | + ? array_slice($dependencies, 0, $dependency_count) |
|
236 | + // otherwise just take the incoming array because nothing previously existed |
|
237 | + : $dependencies; |
|
238 | + return $registered; |
|
239 | + } |
|
240 | + |
|
241 | + |
|
242 | + /** |
|
243 | + * @param string $class_name |
|
244 | + * @param string $loader |
|
245 | + * @return bool |
|
246 | + * @throws DomainException |
|
247 | + */ |
|
248 | + public static function register_class_loader($class_name, $loader = 'load_core') |
|
249 | + { |
|
250 | + if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
251 | + throw new DomainException( |
|
252 | + esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
253 | + ); |
|
254 | + } |
|
255 | + // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
256 | + if (! is_callable($loader) |
|
257 | + && ( |
|
258 | + strpos($loader, 'load_') !== 0 |
|
259 | + || ! method_exists('EE_Registry', $loader) |
|
260 | + ) |
|
261 | + ) { |
|
262 | + throw new DomainException( |
|
263 | + sprintf( |
|
264 | + esc_html__( |
|
265 | + '"%1$s" is not a valid loader method on EE_Registry.', |
|
266 | + 'event_espresso' |
|
267 | + ), |
|
268 | + $loader |
|
269 | + ) |
|
270 | + ); |
|
271 | + } |
|
272 | + $class_name = self::$_instance->getFqnForAlias($class_name); |
|
273 | + if (! isset(self::$_instance->_class_loaders[ $class_name ])) { |
|
274 | + self::$_instance->_class_loaders[ $class_name ] = $loader; |
|
275 | + return true; |
|
276 | + } |
|
277 | + return false; |
|
278 | + } |
|
279 | + |
|
280 | + |
|
281 | + /** |
|
282 | + * @return array |
|
283 | + */ |
|
284 | + public function dependency_map() |
|
285 | + { |
|
286 | + return $this->_dependency_map; |
|
287 | + } |
|
288 | + |
|
289 | + |
|
290 | + /** |
|
291 | + * returns TRUE if dependency map contains a listing for the provided class name |
|
292 | + * |
|
293 | + * @param string $class_name |
|
294 | + * @return boolean |
|
295 | + */ |
|
296 | + public function has($class_name = '') |
|
297 | + { |
|
298 | + // all legacy models have the same dependencies |
|
299 | + if (strpos($class_name, 'EEM_') === 0) { |
|
300 | + $class_name = 'LEGACY_MODELS'; |
|
301 | + } |
|
302 | + return isset($this->_dependency_map[ $class_name ]) ? true : false; |
|
303 | + } |
|
304 | + |
|
305 | + |
|
306 | + /** |
|
307 | + * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
308 | + * |
|
309 | + * @param string $class_name |
|
310 | + * @param string $dependency |
|
311 | + * @return bool |
|
312 | + */ |
|
313 | + public function has_dependency_for_class($class_name = '', $dependency = '') |
|
314 | + { |
|
315 | + // all legacy models have the same dependencies |
|
316 | + if (strpos($class_name, 'EEM_') === 0) { |
|
317 | + $class_name = 'LEGACY_MODELS'; |
|
318 | + } |
|
319 | + $dependency = $this->getFqnForAlias($dependency, $class_name); |
|
320 | + return isset($this->_dependency_map[ $class_name ][ $dependency ]) |
|
321 | + ? true |
|
322 | + : false; |
|
323 | + } |
|
324 | + |
|
325 | + |
|
326 | + /** |
|
327 | + * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
328 | + * |
|
329 | + * @param string $class_name |
|
330 | + * @param string $dependency |
|
331 | + * @return int |
|
332 | + */ |
|
333 | + public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
334 | + { |
|
335 | + // all legacy models have the same dependencies |
|
336 | + if (strpos($class_name, 'EEM_') === 0) { |
|
337 | + $class_name = 'LEGACY_MODELS'; |
|
338 | + } |
|
339 | + $dependency = $this->getFqnForAlias($dependency); |
|
340 | + return $this->has_dependency_for_class($class_name, $dependency) |
|
341 | + ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
342 | + : EE_Dependency_Map::not_registered; |
|
343 | + } |
|
344 | + |
|
345 | + |
|
346 | + /** |
|
347 | + * @param string $class_name |
|
348 | + * @return string | Closure |
|
349 | + */ |
|
350 | + public function class_loader($class_name) |
|
351 | + { |
|
352 | + // all legacy models use load_model() |
|
353 | + if (strpos($class_name, 'EEM_') === 0) { |
|
354 | + return 'load_model'; |
|
355 | + } |
|
356 | + // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc |
|
357 | + // perform strpos() first to avoid loading regex every time we load a class |
|
358 | + if (strpos($class_name, 'EE_CPT_') === 0 |
|
359 | + && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name) |
|
360 | + ) { |
|
361 | + return 'load_core'; |
|
362 | + } |
|
363 | + $class_name = $this->getFqnForAlias($class_name); |
|
364 | + return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : ''; |
|
365 | + } |
|
366 | + |
|
367 | + |
|
368 | + /** |
|
369 | + * @return array |
|
370 | + */ |
|
371 | + public function class_loaders() |
|
372 | + { |
|
373 | + return $this->_class_loaders; |
|
374 | + } |
|
375 | + |
|
376 | + |
|
377 | + /** |
|
378 | + * adds an alias for a classname |
|
379 | + * |
|
380 | + * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
381 | + * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
382 | + * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
383 | + */ |
|
384 | + public function add_alias($fqcn, $alias, $for_class = '') |
|
385 | + { |
|
386 | + $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
387 | + } |
|
388 | + |
|
389 | + |
|
390 | + /** |
|
391 | + * Returns TRUE if the provided fully qualified name IS an alias |
|
392 | + * WHY? |
|
393 | + * Because if a class is type hinting for a concretion, |
|
394 | + * then why would we need to find another class to supply it? |
|
395 | + * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
396 | + * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
397 | + * Don't go looking for some substitute. |
|
398 | + * Whereas if a class is type hinting for an interface... |
|
399 | + * then we need to find an actual class to use. |
|
400 | + * So the interface IS the alias for some other FQN, |
|
401 | + * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
402 | + * represents some other class. |
|
403 | + * |
|
404 | + * @param string $fqn |
|
405 | + * @param string $for_class |
|
406 | + * @return bool |
|
407 | + */ |
|
408 | + public function isAlias($fqn = '', $for_class = '') |
|
409 | + { |
|
410 | + return $this->class_cache->isAlias($fqn, $for_class); |
|
411 | + } |
|
412 | + |
|
413 | + |
|
414 | + /** |
|
415 | + * Returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
416 | + * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
417 | + * for example: |
|
418 | + * if the following two entries were added to the _aliases array: |
|
419 | + * array( |
|
420 | + * 'interface_alias' => 'some\namespace\interface' |
|
421 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
422 | + * ) |
|
423 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
424 | + * to load an instance of 'some\namespace\classname' |
|
425 | + * |
|
426 | + * @param string $alias |
|
427 | + * @param string $for_class |
|
428 | + * @return string |
|
429 | + */ |
|
430 | + public function getFqnForAlias($alias = '', $for_class = '') |
|
431 | + { |
|
432 | + return (string) $this->class_cache->getFqnForAlias($alias, $for_class); |
|
433 | + } |
|
434 | + |
|
435 | + |
|
436 | + /** |
|
437 | + * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
438 | + * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
439 | + * This is done by using the following class constants: |
|
440 | + * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
441 | + * EE_Dependency_Map::load_new_object - generates a new object every time |
|
442 | + */ |
|
443 | + protected function _register_core_dependencies() |
|
444 | + { |
|
445 | + $this->_dependency_map = array( |
|
446 | + 'EE_Request_Handler' => array( |
|
447 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
448 | + ), |
|
449 | + 'EE_System' => array( |
|
450 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
451 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
452 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
453 | + 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
454 | + ), |
|
455 | + 'EE_Session' => array( |
|
456 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
457 | + 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
458 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
459 | + 'EventEspresso\core\services\session\SessionStartHandler' => EE_Dependency_Map::load_from_cache, |
|
460 | + 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
461 | + ), |
|
462 | + 'EE_Cart' => array( |
|
463 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
464 | + ), |
|
465 | + 'EE_Front_Controller' => array( |
|
466 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
467 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
468 | + 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
469 | + ), |
|
470 | + 'EE_Messenger_Collection_Loader' => array( |
|
471 | + 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
472 | + ), |
|
473 | + 'EE_Message_Type_Collection_Loader' => array( |
|
474 | + 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
475 | + ), |
|
476 | + 'EE_Message_Resource_Manager' => array( |
|
477 | + 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
478 | + 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
479 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
480 | + ), |
|
481 | + 'EE_Message_Factory' => array( |
|
482 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
483 | + ), |
|
484 | + 'EE_messages' => array( |
|
485 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
486 | + ), |
|
487 | + 'EE_Messages_Generator' => array( |
|
488 | + 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
489 | + 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
490 | + 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
491 | + 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
492 | + ), |
|
493 | + 'EE_Messages_Processor' => array( |
|
494 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
495 | + ), |
|
496 | + 'EE_Messages_Queue' => array( |
|
497 | + 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
498 | + ), |
|
499 | + 'EE_Messages_Template_Defaults' => array( |
|
500 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
501 | + 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
502 | + ), |
|
503 | + 'EE_Message_To_Generate_From_Request' => array( |
|
504 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
505 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
506 | + ), |
|
507 | + 'EventEspresso\core\services\commands\CommandBus' => array( |
|
508 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
509 | + ), |
|
510 | + 'EventEspresso\services\commands\CommandHandler' => array( |
|
511 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
512 | + 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
513 | + ), |
|
514 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => array( |
|
515 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
516 | + ), |
|
517 | + 'EventEspresso\core\services\commands\CompositeCommandHandler' => array( |
|
518 | + 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
519 | + 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
520 | + ), |
|
521 | + 'EventEspresso\core\services\commands\CommandFactory' => array( |
|
522 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
523 | + ), |
|
524 | + 'EventEspresso\core\services\commands\middleware\CapChecker' => array( |
|
525 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
526 | + ), |
|
527 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => array( |
|
528 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
529 | + ), |
|
530 | + 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => array( |
|
531 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
532 | + ), |
|
533 | + 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => array( |
|
534 | + 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
535 | + ), |
|
536 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => array( |
|
537 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
538 | + ), |
|
539 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => array( |
|
540 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
541 | + ), |
|
542 | + 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => array( |
|
543 | + 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
544 | + ), |
|
545 | + 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array( |
|
546 | + 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
547 | + ), |
|
548 | + 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => array( |
|
549 | + 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
550 | + ), |
|
551 | + 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => array( |
|
552 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
553 | + ), |
|
554 | + 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => array( |
|
555 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
556 | + ), |
|
557 | + 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => array( |
|
558 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
559 | + ), |
|
560 | + 'EventEspresso\core\services\database\TableManager' => array( |
|
561 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
562 | + ), |
|
563 | + 'EE_Data_Migration_Class_Base' => array( |
|
564 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
565 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
566 | + ), |
|
567 | + 'EE_DMS_Core_4_1_0' => array( |
|
568 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
569 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
570 | + ), |
|
571 | + 'EE_DMS_Core_4_2_0' => array( |
|
572 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
573 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
574 | + ), |
|
575 | + 'EE_DMS_Core_4_3_0' => array( |
|
576 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
577 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
578 | + ), |
|
579 | + 'EE_DMS_Core_4_4_0' => array( |
|
580 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
581 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
582 | + ), |
|
583 | + 'EE_DMS_Core_4_5_0' => array( |
|
584 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
585 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
586 | + ), |
|
587 | + 'EE_DMS_Core_4_6_0' => array( |
|
588 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
589 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
590 | + ), |
|
591 | + 'EE_DMS_Core_4_7_0' => array( |
|
592 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
593 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
594 | + ), |
|
595 | + 'EE_DMS_Core_4_8_0' => array( |
|
596 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
597 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
598 | + ), |
|
599 | + 'EE_DMS_Core_4_9_0' => array( |
|
600 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
601 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
602 | + ), |
|
603 | + 'EventEspresso\core\services\assets\I18nRegistry' => array( |
|
604 | + array(), |
|
605 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
606 | + ), |
|
607 | + 'EventEspresso\core\services\assets\Registry' => array( |
|
608 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
609 | + 'EventEspresso\core\services\assets\I18nRegistry' => EE_Dependency_Map::load_from_cache, |
|
610 | + ), |
|
611 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => array( |
|
612 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
613 | + ), |
|
614 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => array( |
|
615 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
616 | + ), |
|
617 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => array( |
|
618 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
619 | + ), |
|
620 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => array( |
|
621 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
622 | + ), |
|
623 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => array( |
|
624 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
625 | + ), |
|
626 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => array( |
|
627 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
628 | + ), |
|
629 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => array( |
|
630 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
631 | + ), |
|
632 | + 'EventEspresso\core\services\cache\BasicCacheManager' => array( |
|
633 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
634 | + ), |
|
635 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => array( |
|
636 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
637 | + ), |
|
638 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array( |
|
639 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
640 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
641 | + ), |
|
642 | + 'EventEspresso\core\domain\values\EmailAddress' => array( |
|
643 | + null, |
|
644 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
645 | + ), |
|
646 | + 'EventEspresso\core\services\orm\ModelFieldFactory' => array( |
|
647 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
648 | + ), |
|
649 | + 'LEGACY_MODELS' => array( |
|
650 | + null, |
|
651 | + 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
652 | + ), |
|
653 | + 'EE_Module_Request_Router' => array( |
|
654 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
655 | + ), |
|
656 | + 'EE_Registration_Processor' => array( |
|
657 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
658 | + ), |
|
659 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array( |
|
660 | + null, |
|
661 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
662 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
663 | + ), |
|
664 | + 'EventEspresso\core\services\licensing\LicenseService' => array( |
|
665 | + 'EventEspresso\core\domain\services\pue\Stats' => EE_Dependency_Map::load_from_cache, |
|
666 | + 'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache, |
|
667 | + ), |
|
668 | + 'EE_Admin_Transactions_List_Table' => array( |
|
669 | + null, |
|
670 | + 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
671 | + ), |
|
672 | + 'EventEspresso\core\domain\services\pue\Stats' => array( |
|
673 | + 'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache, |
|
674 | + 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
675 | + 'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache, |
|
676 | + ), |
|
677 | + 'EventEspresso\core\domain\services\pue\Config' => array( |
|
678 | + 'EE_Network_Config' => EE_Dependency_Map::load_from_cache, |
|
679 | + 'EE_Config' => EE_Dependency_Map::load_from_cache, |
|
680 | + ), |
|
681 | + 'EventEspresso\core\domain\services\pue\StatsGatherer' => array( |
|
682 | + 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
683 | + 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
684 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
685 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
686 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
687 | + 'EEM_Transaction' => EE_Dependency_Map::load_from_cache, |
|
688 | + 'EE_Config' => EE_Dependency_Map::load_from_cache, |
|
689 | + ), |
|
690 | + 'EventEspresso\core\domain\services\admin\ExitModal' => array( |
|
691 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
692 | + ), |
|
693 | + 'EventEspresso\core\domain\services\admin\PluginUpsells' => array( |
|
694 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
695 | + ), |
|
696 | + 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => array( |
|
697 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
698 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
699 | + ), |
|
700 | + 'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings' => array( |
|
701 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
702 | + ), |
|
703 | + 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => array( |
|
704 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
705 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
706 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
707 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
708 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
709 | + ), |
|
710 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => array( |
|
711 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
712 | + ), |
|
713 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => array( |
|
714 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
715 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
716 | + ), |
|
717 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' => array( |
|
718 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
719 | + ), |
|
720 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' => array( |
|
721 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
722 | + ), |
|
723 | + 'EE_CPT_Strategy' => array( |
|
724 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
725 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
726 | + ), |
|
727 | + 'EventEspresso\core\services\loaders\ObjectIdentifier' => array( |
|
728 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
729 | + ), |
|
730 | + 'EventEspresso\core\domain\services\assets\CoreAssetManager' => array( |
|
731 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
732 | + 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
733 | + 'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
|
734 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
735 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
736 | + ), |
|
737 | + 'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => array( |
|
738 | + 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
739 | + 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache |
|
740 | + ), |
|
741 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => array( |
|
742 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
743 | + ), |
|
744 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => array( |
|
745 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
746 | + 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache |
|
747 | + ), |
|
748 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => array( |
|
749 | + 'EEM_Checkin' => EE_Dependency_Map::load_from_cache, |
|
750 | + ), |
|
751 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => array( |
|
752 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
753 | + ), |
|
754 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => array( |
|
755 | + 'EEM_Transaction' => EE_Dependency_Map::load_from_cache, |
|
756 | + ), |
|
757 | + 'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => array( |
|
758 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
759 | + ), |
|
760 | + 'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => array( |
|
761 | + 'EEM_Answer' => EE_Dependency_Map::load_from_cache, |
|
762 | + 'EEM_Question' => EE_Dependency_Map::load_from_cache, |
|
763 | + ), |
|
764 | + 'EventEspresso\core\CPTs\CptQueryModifier' => array( |
|
765 | + null, |
|
766 | + null, |
|
767 | + null, |
|
768 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
769 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
770 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
771 | + ), |
|
772 | + 'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler' => array( |
|
773 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
774 | + 'EE_Config' => EE_Dependency_Map::load_from_cache |
|
775 | + ), |
|
776 | + 'EventEspresso\core\services\editor\BlockRegistrationManager' => array( |
|
777 | + 'EventEspresso\core\services\assets\BlockAssetManagerCollection' => EE_Dependency_Map::load_from_cache, |
|
778 | + 'EventEspresso\core\domain\entities\editor\BlockCollection' => EE_Dependency_Map::load_from_cache, |
|
779 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache, |
|
780 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
781 | + ), |
|
782 | + 'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => array( |
|
783 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
784 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
785 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
786 | + ), |
|
787 | + 'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => array( |
|
788 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
789 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
790 | + ), |
|
791 | + 'EventEspresso\core\domain\entities\editor\blocks\EventAttendees' => array( |
|
792 | + 'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => self::load_from_cache, |
|
793 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
794 | + 'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => self::load_from_cache, |
|
795 | + ), |
|
796 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => array( |
|
797 | + 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
798 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
799 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
800 | + ), |
|
801 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => array( |
|
802 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache, |
|
803 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
804 | + ), |
|
805 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => array( |
|
806 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache, |
|
807 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache, |
|
808 | + ), |
|
809 | + 'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => array( |
|
810 | + 'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => EE_Dependency_Map::load_from_cache |
|
811 | + ), |
|
812 | + 'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => array( |
|
813 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
814 | + ), |
|
815 | + 'EventEspresso\core\libraries\rest_api\controllers\model\Read' => array( |
|
816 | + 'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => EE_Dependency_Map::load_from_cache |
|
817 | + ), |
|
818 | + 'EventEspresso\core\libraries\rest_api\calculations\Datetime' => array( |
|
819 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
820 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache |
|
821 | + ), |
|
822 | + 'EventEspresso\core\libraries\rest_api\calculations\Event' => array( |
|
823 | + 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
824 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache |
|
825 | + ), |
|
826 | + 'EventEspresso\core\libraries\rest_api\calculations\Registration' => array( |
|
827 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache |
|
828 | + ), |
|
829 | + 'EventEspresso\core\services\session\SessionStartHandler' => array( |
|
830 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
831 | + ), |
|
832 | + 'EE_URL_Validation_Strategy' => array( |
|
833 | + null, |
|
834 | + null, |
|
835 | + 'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache |
|
836 | + ), |
|
837 | + 'EventEspresso\admin_pages\general_settings\OrganizationSettings' => array( |
|
838 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
839 | + 'EE_Organization_Config' => EE_Dependency_Map::load_from_cache, |
|
840 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
841 | + 'EE_Network_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
842 | + 'EventEspresso\core\services\address\CountrySubRegionDao' => EE_Dependency_Map::load_from_cache, |
|
843 | + ), |
|
844 | + 'EventEspresso\core\services\address\CountrySubRegionDao' => array( |
|
845 | + 'EEM_State' => EE_Dependency_Map::load_from_cache, |
|
846 | + 'EventEspresso\core\services\validators\JsonValidator' => EE_Dependency_Map::load_from_cache |
|
847 | + ), |
|
848 | + 'EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat' => array( |
|
849 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
850 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
851 | + ), |
|
852 | + 'EventEspresso\core\domain\services\admin\ajax\EventEditorHeartbeat' => array( |
|
853 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
854 | + 'EE_Environment_Config' => EE_Dependency_Map::load_from_cache, |
|
855 | + ), |
|
856 | + 'EventEspresso\core\services\request\files\FilesDataHandler' => array( |
|
857 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
858 | + ), |
|
859 | + ); |
|
860 | + } |
|
861 | + |
|
862 | + |
|
863 | + /** |
|
864 | + * Registers how core classes are loaded. |
|
865 | + * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
866 | + * 'EE_Request_Handler' => 'load_core' |
|
867 | + * 'EE_Messages_Queue' => 'load_lib' |
|
868 | + * 'EEH_Debug_Tools' => 'load_helper' |
|
869 | + * or, if greater control is required, by providing a custom closure. For example: |
|
870 | + * 'Some_Class' => function () { |
|
871 | + * return new Some_Class(); |
|
872 | + * }, |
|
873 | + * This is required for instantiating dependencies |
|
874 | + * where an interface has been type hinted in a class constructor. For example: |
|
875 | + * 'Required_Interface' => function () { |
|
876 | + * return new A_Class_That_Implements_Required_Interface(); |
|
877 | + * }, |
|
878 | + */ |
|
879 | + protected function _register_core_class_loaders() |
|
880 | + { |
|
881 | + $this->_class_loaders = array( |
|
882 | + // load_core |
|
883 | + 'EE_Dependency_Map' => function () { |
|
884 | + return $this; |
|
885 | + }, |
|
886 | + 'EE_Capabilities' => 'load_core', |
|
887 | + 'EE_Encryption' => 'load_core', |
|
888 | + 'EE_Front_Controller' => 'load_core', |
|
889 | + 'EE_Module_Request_Router' => 'load_core', |
|
890 | + 'EE_Registry' => 'load_core', |
|
891 | + 'EE_Request' => function () { |
|
892 | + return $this->legacy_request; |
|
893 | + }, |
|
894 | + 'EventEspresso\core\services\request\Request' => function () { |
|
895 | + return $this->request; |
|
896 | + }, |
|
897 | + 'EventEspresso\core\services\request\Response' => function () { |
|
898 | + return $this->response; |
|
899 | + }, |
|
900 | + 'EE_Base' => 'load_core', |
|
901 | + 'EE_Request_Handler' => 'load_core', |
|
902 | + 'EE_Session' => 'load_core', |
|
903 | + 'EE_Cron_Tasks' => 'load_core', |
|
904 | + 'EE_System' => 'load_core', |
|
905 | + 'EE_Maintenance_Mode' => 'load_core', |
|
906 | + 'EE_Register_CPTs' => 'load_core', |
|
907 | + 'EE_Admin' => 'load_core', |
|
908 | + 'EE_CPT_Strategy' => 'load_core', |
|
909 | + // load_lib |
|
910 | + 'EE_Message_Resource_Manager' => 'load_lib', |
|
911 | + 'EE_Message_Type_Collection' => 'load_lib', |
|
912 | + 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
913 | + 'EE_Messenger_Collection' => 'load_lib', |
|
914 | + 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
915 | + 'EE_Messages_Processor' => 'load_lib', |
|
916 | + 'EE_Message_Repository' => 'load_lib', |
|
917 | + 'EE_Messages_Queue' => 'load_lib', |
|
918 | + 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
919 | + 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
920 | + 'EE_Payment_Method_Manager' => 'load_lib', |
|
921 | + 'EE_Messages_Generator' => function () { |
|
922 | + return EE_Registry::instance()->load_lib( |
|
923 | + 'Messages_Generator', |
|
924 | + array(), |
|
925 | + false, |
|
926 | + false |
|
927 | + ); |
|
928 | + }, |
|
929 | + 'EE_Messages_Template_Defaults' => function ($arguments = array()) { |
|
930 | + return EE_Registry::instance()->load_lib( |
|
931 | + 'Messages_Template_Defaults', |
|
932 | + $arguments, |
|
933 | + false, |
|
934 | + false |
|
935 | + ); |
|
936 | + }, |
|
937 | + // load_helper |
|
938 | + 'EEH_Parse_Shortcodes' => function () { |
|
939 | + if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
940 | + return new EEH_Parse_Shortcodes(); |
|
941 | + } |
|
942 | + return null; |
|
943 | + }, |
|
944 | + 'EE_Template_Config' => function () { |
|
945 | + return EE_Config::instance()->template_settings; |
|
946 | + }, |
|
947 | + 'EE_Currency_Config' => function () { |
|
948 | + return EE_Config::instance()->currency; |
|
949 | + }, |
|
950 | + 'EE_Registration_Config' => function () { |
|
951 | + return EE_Config::instance()->registration; |
|
952 | + }, |
|
953 | + 'EE_Core_Config' => function () { |
|
954 | + return EE_Config::instance()->core; |
|
955 | + }, |
|
956 | + 'EventEspresso\core\services\loaders\Loader' => function () { |
|
957 | + return LoaderFactory::getLoader(); |
|
958 | + }, |
|
959 | + 'EE_Network_Config' => function () { |
|
960 | + return EE_Network_Config::instance(); |
|
961 | + }, |
|
962 | + 'EE_Config' => function () { |
|
963 | + return EE_Config::instance(); |
|
964 | + }, |
|
965 | + 'EventEspresso\core\domain\Domain' => function () { |
|
966 | + return DomainFactory::getEventEspressoCoreDomain(); |
|
967 | + }, |
|
968 | + 'EE_Admin_Config' => function () { |
|
969 | + return EE_Config::instance()->admin; |
|
970 | + }, |
|
971 | + 'EE_Organization_Config' => function () { |
|
972 | + return EE_Config::instance()->organization; |
|
973 | + }, |
|
974 | + 'EE_Network_Core_Config' => function () { |
|
975 | + return EE_Network_Config::instance()->core; |
|
976 | + }, |
|
977 | + 'EE_Environment_Config' => function () { |
|
978 | + return EE_Config::instance()->environment; |
|
979 | + }, |
|
980 | + ); |
|
981 | + } |
|
982 | + |
|
983 | + |
|
984 | + /** |
|
985 | + * can be used for supplying alternate names for classes, |
|
986 | + * or for connecting interface names to instantiable classes |
|
987 | + */ |
|
988 | + protected function _register_core_aliases() |
|
989 | + { |
|
990 | + $aliases = array( |
|
991 | + 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
992 | + 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
993 | + 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
994 | + 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
995 | + 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
996 | + 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
997 | + 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
998 | + 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
999 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
1000 | + 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
1001 | + 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
1002 | + 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
1003 | + 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
1004 | + 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
1005 | + 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
1006 | + 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
1007 | + 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
1008 | + 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
1009 | + 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
1010 | + 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
1011 | + 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
1012 | + 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
1013 | + 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
1014 | + 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
1015 | + 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
1016 | + 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
1017 | + 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
1018 | + 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
1019 | + 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
1020 | + 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
1021 | + 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
1022 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
1023 | + 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
1024 | + 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
1025 | + 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
1026 | + 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
1027 | + 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
1028 | + ); |
|
1029 | + foreach ($aliases as $alias => $fqn) { |
|
1030 | + if (is_array($fqn)) { |
|
1031 | + foreach ($fqn as $class => $for_class) { |
|
1032 | + $this->class_cache->addAlias($class, $alias, $for_class); |
|
1033 | + } |
|
1034 | + continue; |
|
1035 | + } |
|
1036 | + $this->class_cache->addAlias($fqn, $alias); |
|
1037 | + } |
|
1038 | + if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
1039 | + $this->class_cache->addAlias( |
|
1040 | + 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices', |
|
1041 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' |
|
1042 | + ); |
|
1043 | + } |
|
1044 | + } |
|
1045 | + |
|
1046 | + |
|
1047 | + /** |
|
1048 | + * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
1049 | + * request Primarily used by unit tests. |
|
1050 | + */ |
|
1051 | + public function reset() |
|
1052 | + { |
|
1053 | + $this->_register_core_class_loaders(); |
|
1054 | + $this->_register_core_dependencies(); |
|
1055 | + } |
|
1056 | + |
|
1057 | + |
|
1058 | + /** |
|
1059 | + * PLZ NOTE: a better name for this method would be is_alias() |
|
1060 | + * because it returns TRUE if the provided fully qualified name IS an alias |
|
1061 | + * WHY? |
|
1062 | + * Because if a class is type hinting for a concretion, |
|
1063 | + * then why would we need to find another class to supply it? |
|
1064 | + * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
1065 | + * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
1066 | + * Don't go looking for some substitute. |
|
1067 | + * Whereas if a class is type hinting for an interface... |
|
1068 | + * then we need to find an actual class to use. |
|
1069 | + * So the interface IS the alias for some other FQN, |
|
1070 | + * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
1071 | + * represents some other class. |
|
1072 | + * |
|
1073 | + * @deprecated 4.9.62.p |
|
1074 | + * @param string $fqn |
|
1075 | + * @param string $for_class |
|
1076 | + * @return bool |
|
1077 | + */ |
|
1078 | + public function has_alias($fqn = '', $for_class = '') |
|
1079 | + { |
|
1080 | + return $this->isAlias($fqn, $for_class); |
|
1081 | + } |
|
1082 | + |
|
1083 | + |
|
1084 | + /** |
|
1085 | + * PLZ NOTE: a better name for this method would be get_fqn_for_alias() |
|
1086 | + * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
1087 | + * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
1088 | + * for example: |
|
1089 | + * if the following two entries were added to the _aliases array: |
|
1090 | + * array( |
|
1091 | + * 'interface_alias' => 'some\namespace\interface' |
|
1092 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
1093 | + * ) |
|
1094 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
1095 | + * to load an instance of 'some\namespace\classname' |
|
1096 | + * |
|
1097 | + * @deprecated 4.9.62.p |
|
1098 | + * @param string $alias |
|
1099 | + * @param string $for_class |
|
1100 | + * @return string |
|
1101 | + */ |
|
1102 | + public function get_alias($alias = '', $for_class = '') |
|
1103 | + { |
|
1104 | + return $this->getFqnForAlias($alias, $for_class); |
|
1105 | + } |
|
1106 | 1106 | } |
@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | <?php esc_html_e('This option will save all Event Espresso registration form data, and debugging information to a file in the /wp-content/uploads/espresso/logs directory on your server. This will occur each time a page is accessed on your site until this option is turned off.', 'event_espresso'); ?> |
13 | 13 | <br/> |
14 | 14 | <?php printf( |
15 | - esc_html__('Note that if you are accessing your filesystem over FTP or SSH, and logging writes to the filesystem on every request, you should put your credentials in your wp-config.php file, as described %1$shere.%2$s', 'event_espresso'), |
|
16 | - '<a href="https://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants" target="_blank" rel="noopener noreferrer">', |
|
17 | - '</a>' |
|
15 | + esc_html__('Note that if you are accessing your filesystem over FTP or SSH, and logging writes to the filesystem on every request, you should put your credentials in your wp-config.php file, as described %1$shere.%2$s', 'event_espresso'), |
|
16 | + '<a href="https://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants" target="_blank" rel="noopener noreferrer">', |
|
17 | + '</a>' |
|
18 | 18 | ); ?> |
19 | 19 | </li> |
20 | 20 | <li> |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | <li> |
43 | 43 | <strong><?php esc_html_e('Event Espresso Affiliate ID', 'event_espresso'); ?></strong><br /> |
44 | 44 | <?php printf( |
45 | - esc_html__( |
|
46 | - 'You can also monetize this link by signing up to our %1$saffiliate program%2$s and adding in your affiliate ID here.', |
|
47 | - 'event_espresso' |
|
48 | - ), |
|
49 | - '<a href="https://eventespresso.com/affiliates/">', |
|
50 | - '</a>' |
|
45 | + esc_html__( |
|
46 | + 'You can also monetize this link by signing up to our %1$saffiliate program%2$s and adding in your affiliate ID here.', |
|
47 | + 'event_espresso' |
|
48 | + ), |
|
49 | + '<a href="https://eventespresso.com/affiliates/">', |
|
50 | + '</a>' |
|
51 | 51 | ); ?> |
52 | 52 | </li> |
53 | 53 | </ul> |
@@ -38,103 +38,103 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - echo esc_html__( |
|
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
52 | + echo esc_html__( |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | - /** |
|
98 | - * espresso_version |
|
99 | - * Returns the plugin version |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - function espresso_version() |
|
104 | - { |
|
105 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.80.rc.006'); |
|
106 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | + /** |
|
98 | + * espresso_version |
|
99 | + * Returns the plugin version |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + function espresso_version() |
|
104 | + { |
|
105 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.80.rc.006'); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * espresso_plugin_activation |
|
110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | - */ |
|
112 | - function espresso_plugin_activation() |
|
113 | - { |
|
114 | - update_option('ee_espresso_activation', true); |
|
115 | - } |
|
108 | + /** |
|
109 | + * espresso_plugin_activation |
|
110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | + */ |
|
112 | + function espresso_plugin_activation() |
|
113 | + { |
|
114 | + update_option('ee_espresso_activation', true); |
|
115 | + } |
|
116 | 116 | |
117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | 118 | |
119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | - bootstrap_espresso(); |
|
121 | - } |
|
119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | + bootstrap_espresso(); |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
124 | - /** |
|
125 | - * deactivate_plugin |
|
126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | - * |
|
128 | - * @access public |
|
129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | - { |
|
134 | - if (! function_exists('deactivate_plugins')) { |
|
135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | - } |
|
137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | - deactivate_plugins($plugin_basename); |
|
139 | - } |
|
124 | + /** |
|
125 | + * deactivate_plugin |
|
126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | + * |
|
128 | + * @access public |
|
129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | + { |
|
134 | + if (! function_exists('deactivate_plugins')) { |
|
135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | + } |
|
137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | + deactivate_plugins($plugin_basename); |
|
139 | + } |
|
140 | 140 | } |
@@ -38,264 +38,264 @@ |
||
38 | 38 | */ |
39 | 39 | class FilesDataHandler |
40 | 40 | { |
41 | - /** |
|
42 | - * @var Request |
|
43 | - */ |
|
44 | - protected $request; |
|
41 | + /** |
|
42 | + * @var Request |
|
43 | + */ |
|
44 | + protected $request; |
|
45 | 45 | |
46 | - /** |
|
47 | - * @var CollectionInterface | FileSubmissionInterface[] |
|
48 | - */ |
|
49 | - protected $file_objects; |
|
46 | + /** |
|
47 | + * @var CollectionInterface | FileSubmissionInterface[] |
|
48 | + */ |
|
49 | + protected $file_objects; |
|
50 | 50 | |
51 | - /** |
|
52 | - * @var bool |
|
53 | - */ |
|
54 | - protected $initialized = false; |
|
51 | + /** |
|
52 | + * @var bool |
|
53 | + */ |
|
54 | + protected $initialized = false; |
|
55 | 55 | |
56 | - /** |
|
57 | - * FilesDataHandler constructor. |
|
58 | - * @param Request $request |
|
59 | - */ |
|
60 | - public function __construct(Request $request) |
|
61 | - { |
|
62 | - $this->request = $request; |
|
63 | - } |
|
56 | + /** |
|
57 | + * FilesDataHandler constructor. |
|
58 | + * @param Request $request |
|
59 | + */ |
|
60 | + public function __construct(Request $request) |
|
61 | + { |
|
62 | + $this->request = $request; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @since $VID:$ |
|
67 | - * @return CollectionInterface | FileSubmissionInterface[] |
|
68 | - * @throws UnexpectedValueException |
|
69 | - * @throws InvalidArgumentException |
|
70 | - */ |
|
71 | - protected function getFileObjects() |
|
72 | - { |
|
73 | - $this->initialize(); |
|
74 | - return $this->file_objects; |
|
75 | - } |
|
65 | + /** |
|
66 | + * @since $VID:$ |
|
67 | + * @return CollectionInterface | FileSubmissionInterface[] |
|
68 | + * @throws UnexpectedValueException |
|
69 | + * @throws InvalidArgumentException |
|
70 | + */ |
|
71 | + protected function getFileObjects() |
|
72 | + { |
|
73 | + $this->initialize(); |
|
74 | + return $this->file_objects; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * Sets up the file objects from the request's $_FILES data. |
|
79 | - * @since $VID:$ |
|
80 | - * @throws UnexpectedValueException |
|
81 | - * @throws InvalidArgumentException |
|
82 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
83 | - */ |
|
84 | - protected function initialize() |
|
85 | - { |
|
86 | - if ($this->initialized) { |
|
87 | - return; |
|
88 | - } |
|
89 | - $this->file_objects = new Collection( |
|
90 | - // collection interface |
|
91 | - 'EventEspresso\core\services\request\files\FileSubmissionInterface', |
|
92 | - // collection name |
|
93 | - 'submitted_files' |
|
94 | - ); |
|
95 | - $files_raw_data = $this->request->filesParams(); |
|
96 | - if (empty($files_raw_data)) { |
|
97 | - return; |
|
98 | - } |
|
99 | - if ($this->isStrangeFilesArray($files_raw_data)) { |
|
100 | - $data = $this->fixFilesDataArray($files_raw_data); |
|
101 | - } else { |
|
102 | - $data = $files_raw_data; |
|
103 | - } |
|
104 | - $this->createFileObjects($data); |
|
105 | - $this->initialized = true; |
|
106 | - } |
|
77 | + /** |
|
78 | + * Sets up the file objects from the request's $_FILES data. |
|
79 | + * @since $VID:$ |
|
80 | + * @throws UnexpectedValueException |
|
81 | + * @throws InvalidArgumentException |
|
82 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
83 | + */ |
|
84 | + protected function initialize() |
|
85 | + { |
|
86 | + if ($this->initialized) { |
|
87 | + return; |
|
88 | + } |
|
89 | + $this->file_objects = new Collection( |
|
90 | + // collection interface |
|
91 | + 'EventEspresso\core\services\request\files\FileSubmissionInterface', |
|
92 | + // collection name |
|
93 | + 'submitted_files' |
|
94 | + ); |
|
95 | + $files_raw_data = $this->request->filesParams(); |
|
96 | + if (empty($files_raw_data)) { |
|
97 | + return; |
|
98 | + } |
|
99 | + if ($this->isStrangeFilesArray($files_raw_data)) { |
|
100 | + $data = $this->fixFilesDataArray($files_raw_data); |
|
101 | + } else { |
|
102 | + $data = $files_raw_data; |
|
103 | + } |
|
104 | + $this->createFileObjects($data); |
|
105 | + $this->initialized = true; |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * Detects if $_FILES is a weird multi-dimensional array that needs fixing or not. |
|
110 | - * @since $VID:$ |
|
111 | - * @param $files_data |
|
112 | - * @return bool |
|
113 | - * @throws UnexpectedValueException |
|
114 | - */ |
|
115 | - protected function isStrangeFilesArray($files_data) |
|
116 | - { |
|
117 | - if (!is_array($files_data)) { |
|
118 | - throw new UnexpectedValueException( |
|
119 | - sprintf( |
|
120 | - esc_html__( |
|
121 | - 'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.', |
|
122 | - 'event_espresso' |
|
123 | - ), |
|
124 | - (string) $files_data |
|
125 | - ) |
|
126 | - ); |
|
127 | - } |
|
128 | - $first_value = reset($files_data); |
|
129 | - if (!is_array($first_value)) { |
|
130 | - throw new UnexpectedValueException( |
|
131 | - sprintf( |
|
132 | - esc_html__( |
|
133 | - 'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.', |
|
134 | - 'event_espresso' |
|
135 | - ), |
|
136 | - (string) $first_value |
|
137 | - ) |
|
138 | - ); |
|
139 | - } |
|
140 | - $first_sub_array_item = reset($first_value); |
|
141 | - if (is_array($first_sub_array_item)) { |
|
142 | - // not just a 2d array |
|
143 | - return true; |
|
144 | - } |
|
145 | - // yep, just 2d array |
|
146 | - return false; |
|
147 | - } |
|
108 | + /** |
|
109 | + * Detects if $_FILES is a weird multi-dimensional array that needs fixing or not. |
|
110 | + * @since $VID:$ |
|
111 | + * @param $files_data |
|
112 | + * @return bool |
|
113 | + * @throws UnexpectedValueException |
|
114 | + */ |
|
115 | + protected function isStrangeFilesArray($files_data) |
|
116 | + { |
|
117 | + if (!is_array($files_data)) { |
|
118 | + throw new UnexpectedValueException( |
|
119 | + sprintf( |
|
120 | + esc_html__( |
|
121 | + 'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.', |
|
122 | + 'event_espresso' |
|
123 | + ), |
|
124 | + (string) $files_data |
|
125 | + ) |
|
126 | + ); |
|
127 | + } |
|
128 | + $first_value = reset($files_data); |
|
129 | + if (!is_array($first_value)) { |
|
130 | + throw new UnexpectedValueException( |
|
131 | + sprintf( |
|
132 | + esc_html__( |
|
133 | + 'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.', |
|
134 | + 'event_espresso' |
|
135 | + ), |
|
136 | + (string) $first_value |
|
137 | + ) |
|
138 | + ); |
|
139 | + } |
|
140 | + $first_sub_array_item = reset($first_value); |
|
141 | + if (is_array($first_sub_array_item)) { |
|
142 | + // not just a 2d array |
|
143 | + return true; |
|
144 | + } |
|
145 | + // yep, just 2d array |
|
146 | + return false; |
|
147 | + } |
|
148 | 148 | |
149 | - /** |
|
150 | - * Takes into account that $_FILES does a weird thing when you have hierarchical form names (eg `<input type="file" |
|
151 | - * name="my[hierarchical][form]">`): it leaves the top-level form part alone, but replaces the SECOND part with |
|
152 | - * "name", "size", "tmp_name", etc. So that file's data is located at "my[name][hierarchical][form]", |
|
153 | - * "my[size][hierarchical][form]", "my[tmp_name][hierarchical][form]", etc. It's really weird. |
|
154 | - * @since $VID:$ |
|
155 | - * @param $files_data |
|
156 | - * @return array |
|
157 | - */ |
|
158 | - protected function fixFilesDataArray($files_data) |
|
159 | - { |
|
160 | - $sane_files_array = []; |
|
161 | - foreach ($files_data as $top_level_name => $top_level_children) { |
|
162 | - $sub_array = []; |
|
163 | - $sane_files_array[ $top_level_name ] = []; |
|
164 | - foreach ($top_level_children as $file_data_part => $second_level_children) { |
|
165 | - foreach ($second_level_children as $next_level_name => $sub_values) { |
|
166 | - $sub_array[ $next_level_name ] = $this->organizeFilesData($sub_values, $file_data_part); |
|
167 | - } |
|
168 | - $sane_files_array[ $top_level_name ] = array_replace_recursive( |
|
169 | - $sub_array, |
|
170 | - $sane_files_array[ $top_level_name ] |
|
171 | - ); |
|
172 | - } |
|
173 | - } |
|
174 | - return $sane_files_array; |
|
175 | - } |
|
149 | + /** |
|
150 | + * Takes into account that $_FILES does a weird thing when you have hierarchical form names (eg `<input type="file" |
|
151 | + * name="my[hierarchical][form]">`): it leaves the top-level form part alone, but replaces the SECOND part with |
|
152 | + * "name", "size", "tmp_name", etc. So that file's data is located at "my[name][hierarchical][form]", |
|
153 | + * "my[size][hierarchical][form]", "my[tmp_name][hierarchical][form]", etc. It's really weird. |
|
154 | + * @since $VID:$ |
|
155 | + * @param $files_data |
|
156 | + * @return array |
|
157 | + */ |
|
158 | + protected function fixFilesDataArray($files_data) |
|
159 | + { |
|
160 | + $sane_files_array = []; |
|
161 | + foreach ($files_data as $top_level_name => $top_level_children) { |
|
162 | + $sub_array = []; |
|
163 | + $sane_files_array[ $top_level_name ] = []; |
|
164 | + foreach ($top_level_children as $file_data_part => $second_level_children) { |
|
165 | + foreach ($second_level_children as $next_level_name => $sub_values) { |
|
166 | + $sub_array[ $next_level_name ] = $this->organizeFilesData($sub_values, $file_data_part); |
|
167 | + } |
|
168 | + $sane_files_array[ $top_level_name ] = array_replace_recursive( |
|
169 | + $sub_array, |
|
170 | + $sane_files_array[ $top_level_name ] |
|
171 | + ); |
|
172 | + } |
|
173 | + } |
|
174 | + return $sane_files_array; |
|
175 | + } |
|
176 | 176 | |
177 | - /** |
|
178 | - * Recursively explores the array until it finds a leaf node, and tacks `$type` as a final index in front of it. |
|
179 | - * @since $VID:$ |
|
180 | - * @param $data array|string |
|
181 | - * @param $type 'name', 'tmp_name', 'size', or 'error' |
|
182 | - * @param $name string |
|
183 | - * @return array|string |
|
184 | - */ |
|
185 | - protected function organizeFilesData($data, $type) |
|
186 | - { |
|
187 | - if (! is_array($data)) { |
|
188 | - return [ |
|
189 | - $type => $data |
|
190 | - ]; |
|
191 | - } |
|
192 | - $organized_data = []; |
|
193 | - foreach ($data as $input_name_part => $sub_inputs_or_value) { |
|
194 | - if (is_array($sub_inputs_or_value)) { |
|
195 | - $organized_data[ $input_name_part ] = $this->organizeFilesData($sub_inputs_or_value, $type); |
|
196 | - } else { |
|
197 | - $organized_data[ $input_name_part ][ $type ] = $sub_inputs_or_value; |
|
198 | - } |
|
199 | - } |
|
200 | - return $organized_data; |
|
201 | - } |
|
177 | + /** |
|
178 | + * Recursively explores the array until it finds a leaf node, and tacks `$type` as a final index in front of it. |
|
179 | + * @since $VID:$ |
|
180 | + * @param $data array|string |
|
181 | + * @param $type 'name', 'tmp_name', 'size', or 'error' |
|
182 | + * @param $name string |
|
183 | + * @return array|string |
|
184 | + */ |
|
185 | + protected function organizeFilesData($data, $type) |
|
186 | + { |
|
187 | + if (! is_array($data)) { |
|
188 | + return [ |
|
189 | + $type => $data |
|
190 | + ]; |
|
191 | + } |
|
192 | + $organized_data = []; |
|
193 | + foreach ($data as $input_name_part => $sub_inputs_or_value) { |
|
194 | + if (is_array($sub_inputs_or_value)) { |
|
195 | + $organized_data[ $input_name_part ] = $this->organizeFilesData($sub_inputs_or_value, $type); |
|
196 | + } else { |
|
197 | + $organized_data[ $input_name_part ][ $type ] = $sub_inputs_or_value; |
|
198 | + } |
|
199 | + } |
|
200 | + return $organized_data; |
|
201 | + } |
|
202 | 202 | |
203 | - /** |
|
204 | - * Takes the organized $_FILES array (where all file info is located at the same spot as you'd expect an input |
|
205 | - * to be in $_GET or $_POST, with all the file's data located side-by-side in an array) and creates a |
|
206 | - * multi-dimensional array of FileSubmissionInterface objects. Stores it in `$this->file_objects`. |
|
207 | - * @since $VID:$ |
|
208 | - * @param array $organized_files $_FILES but organized like $_POST |
|
209 | - * @param array $name_parts_so_far for multidimensional HTML form names, |
|
210 | - * @throws UnexpectedValueException |
|
211 | - * @throws InvalidArgumentException |
|
212 | - */ |
|
213 | - protected function createFileObjects($organized_files, $name_parts_so_far = []) |
|
214 | - { |
|
215 | - if (!is_array($organized_files)) { |
|
216 | - throw new UnexpectedValueException( |
|
217 | - sprintf( |
|
218 | - esc_html__( |
|
219 | - 'Unexpected PHP $organized_files data format. "%1$s" was expected to be an array.', |
|
220 | - 'event_espresso' |
|
221 | - ), |
|
222 | - (string) $organized_files |
|
223 | - ) |
|
224 | - ); |
|
225 | - } |
|
226 | - foreach ($organized_files as $key => $value) { |
|
227 | - $this_input_name_parts = $name_parts_so_far; |
|
228 | - array_push( |
|
229 | - $this_input_name_parts, |
|
230 | - $key |
|
231 | - ); |
|
232 | - if (isset($value['name'], $value['tmp_name'], $value['size'])) { |
|
233 | - $html_name = $this->inputNameFromParts($this_input_name_parts); |
|
234 | - $this->file_objects->add( |
|
235 | - new FileSubmission( |
|
236 | - $value['name'], |
|
237 | - $value['tmp_name'], |
|
238 | - $value['size'], |
|
239 | - $value['error'] |
|
240 | - ), |
|
241 | - $html_name |
|
242 | - ); |
|
243 | - } else { |
|
244 | - $this->createFileObjects($value, $this_input_name_parts); |
|
245 | - } |
|
246 | - } |
|
247 | - } |
|
203 | + /** |
|
204 | + * Takes the organized $_FILES array (where all file info is located at the same spot as you'd expect an input |
|
205 | + * to be in $_GET or $_POST, with all the file's data located side-by-side in an array) and creates a |
|
206 | + * multi-dimensional array of FileSubmissionInterface objects. Stores it in `$this->file_objects`. |
|
207 | + * @since $VID:$ |
|
208 | + * @param array $organized_files $_FILES but organized like $_POST |
|
209 | + * @param array $name_parts_so_far for multidimensional HTML form names, |
|
210 | + * @throws UnexpectedValueException |
|
211 | + * @throws InvalidArgumentException |
|
212 | + */ |
|
213 | + protected function createFileObjects($organized_files, $name_parts_so_far = []) |
|
214 | + { |
|
215 | + if (!is_array($organized_files)) { |
|
216 | + throw new UnexpectedValueException( |
|
217 | + sprintf( |
|
218 | + esc_html__( |
|
219 | + 'Unexpected PHP $organized_files data format. "%1$s" was expected to be an array.', |
|
220 | + 'event_espresso' |
|
221 | + ), |
|
222 | + (string) $organized_files |
|
223 | + ) |
|
224 | + ); |
|
225 | + } |
|
226 | + foreach ($organized_files as $key => $value) { |
|
227 | + $this_input_name_parts = $name_parts_so_far; |
|
228 | + array_push( |
|
229 | + $this_input_name_parts, |
|
230 | + $key |
|
231 | + ); |
|
232 | + if (isset($value['name'], $value['tmp_name'], $value['size'])) { |
|
233 | + $html_name = $this->inputNameFromParts($this_input_name_parts); |
|
234 | + $this->file_objects->add( |
|
235 | + new FileSubmission( |
|
236 | + $value['name'], |
|
237 | + $value['tmp_name'], |
|
238 | + $value['size'], |
|
239 | + $value['error'] |
|
240 | + ), |
|
241 | + $html_name |
|
242 | + ); |
|
243 | + } else { |
|
244 | + $this->createFileObjects($value, $this_input_name_parts); |
|
245 | + } |
|
246 | + } |
|
247 | + } |
|
248 | 248 | |
249 | - /** |
|
250 | - * Takes the input name parts, like `['my', 'great', 'file', 'input1']` |
|
251 | - * and returns the HTML name for it, "my[great][file][input1]" |
|
252 | - * @since $VID:$ |
|
253 | - * @param $parts |
|
254 | - * @throws UnexpectedValueException |
|
255 | - */ |
|
256 | - protected function inputNameFromParts($parts) |
|
257 | - { |
|
258 | - if (!is_array($parts)) { |
|
259 | - throw new UnexpectedValueException(esc_html__('Name parts should be an array.', 'event_espresso')); |
|
260 | - } |
|
261 | - $generated_string = ''; |
|
262 | - foreach ($parts as $part) { |
|
263 | - if ($generated_string === '') { |
|
264 | - $generated_string = (string) $part; |
|
265 | - } else { |
|
266 | - $generated_string .= '[' . (string) $part . ']'; |
|
267 | - } |
|
268 | - } |
|
269 | - return $generated_string; |
|
270 | - } |
|
249 | + /** |
|
250 | + * Takes the input name parts, like `['my', 'great', 'file', 'input1']` |
|
251 | + * and returns the HTML name for it, "my[great][file][input1]" |
|
252 | + * @since $VID:$ |
|
253 | + * @param $parts |
|
254 | + * @throws UnexpectedValueException |
|
255 | + */ |
|
256 | + protected function inputNameFromParts($parts) |
|
257 | + { |
|
258 | + if (!is_array($parts)) { |
|
259 | + throw new UnexpectedValueException(esc_html__('Name parts should be an array.', 'event_espresso')); |
|
260 | + } |
|
261 | + $generated_string = ''; |
|
262 | + foreach ($parts as $part) { |
|
263 | + if ($generated_string === '') { |
|
264 | + $generated_string = (string) $part; |
|
265 | + } else { |
|
266 | + $generated_string .= '[' . (string) $part . ']'; |
|
267 | + } |
|
268 | + } |
|
269 | + return $generated_string; |
|
270 | + } |
|
271 | 271 | |
272 | - /** |
|
273 | - * Gets the input by the indicated $name_parts. |
|
274 | - * Eg if you're looking for an input named "my[great][file][input1]", $name_parts |
|
275 | - * should be `['my', 'great', 'file', 'input1']`. |
|
276 | - * Alternatively, you could use `FileDataHandler::getFileObject('my[great][file][input1]');` |
|
277 | - * @since $VID:$ |
|
278 | - * @param $name_parts |
|
279 | - * @throws UnexpectedValueException |
|
280 | - * @return FileSubmissionInterface |
|
281 | - */ |
|
282 | - public function getFileObjectFromNameParts($name_parts) |
|
283 | - { |
|
284 | - return $this->getFileObjects()->get($this->inputNameFromParts($name_parts)); |
|
285 | - } |
|
272 | + /** |
|
273 | + * Gets the input by the indicated $name_parts. |
|
274 | + * Eg if you're looking for an input named "my[great][file][input1]", $name_parts |
|
275 | + * should be `['my', 'great', 'file', 'input1']`. |
|
276 | + * Alternatively, you could use `FileDataHandler::getFileObject('my[great][file][input1]');` |
|
277 | + * @since $VID:$ |
|
278 | + * @param $name_parts |
|
279 | + * @throws UnexpectedValueException |
|
280 | + * @return FileSubmissionInterface |
|
281 | + */ |
|
282 | + public function getFileObjectFromNameParts($name_parts) |
|
283 | + { |
|
284 | + return $this->getFileObjects()->get($this->inputNameFromParts($name_parts)); |
|
285 | + } |
|
286 | 286 | |
287 | - /** |
|
288 | - * Gets the FileSubmissionInterface corresponding to the HTML name provided. |
|
289 | - * @since $VID:$ |
|
290 | - * @param $html_name |
|
291 | - * @return mixed |
|
292 | - * @throws InvalidArgumentException |
|
293 | - * @throws UnexpectedValueException |
|
294 | - */ |
|
295 | - public function getFileObject($html_name) |
|
296 | - { |
|
297 | - return $this->getFileObjects()->get($html_name); |
|
298 | - } |
|
287 | + /** |
|
288 | + * Gets the FileSubmissionInterface corresponding to the HTML name provided. |
|
289 | + * @since $VID:$ |
|
290 | + * @param $html_name |
|
291 | + * @return mixed |
|
292 | + * @throws InvalidArgumentException |
|
293 | + * @throws UnexpectedValueException |
|
294 | + */ |
|
295 | + public function getFileObject($html_name) |
|
296 | + { |
|
297 | + return $this->getFileObjects()->get($html_name); |
|
298 | + } |
|
299 | 299 | } |
300 | 300 | // End of file FilesDataHandler.php |
301 | 301 | // Location: EventEspresso\core\services\request\files/FilesDataHandler.php |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | protected function isStrangeFilesArray($files_data) |
116 | 116 | { |
117 | - if (!is_array($files_data)) { |
|
117 | + if ( ! is_array($files_data)) { |
|
118 | 118 | throw new UnexpectedValueException( |
119 | 119 | sprintf( |
120 | 120 | esc_html__( |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | ); |
127 | 127 | } |
128 | 128 | $first_value = reset($files_data); |
129 | - if (!is_array($first_value)) { |
|
129 | + if ( ! is_array($first_value)) { |
|
130 | 130 | throw new UnexpectedValueException( |
131 | 131 | sprintf( |
132 | 132 | esc_html__( |
@@ -160,14 +160,14 @@ discard block |
||
160 | 160 | $sane_files_array = []; |
161 | 161 | foreach ($files_data as $top_level_name => $top_level_children) { |
162 | 162 | $sub_array = []; |
163 | - $sane_files_array[ $top_level_name ] = []; |
|
163 | + $sane_files_array[$top_level_name] = []; |
|
164 | 164 | foreach ($top_level_children as $file_data_part => $second_level_children) { |
165 | 165 | foreach ($second_level_children as $next_level_name => $sub_values) { |
166 | - $sub_array[ $next_level_name ] = $this->organizeFilesData($sub_values, $file_data_part); |
|
166 | + $sub_array[$next_level_name] = $this->organizeFilesData($sub_values, $file_data_part); |
|
167 | 167 | } |
168 | - $sane_files_array[ $top_level_name ] = array_replace_recursive( |
|
168 | + $sane_files_array[$top_level_name] = array_replace_recursive( |
|
169 | 169 | $sub_array, |
170 | - $sane_files_array[ $top_level_name ] |
|
170 | + $sane_files_array[$top_level_name] |
|
171 | 171 | ); |
172 | 172 | } |
173 | 173 | } |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | protected function organizeFilesData($data, $type) |
186 | 186 | { |
187 | - if (! is_array($data)) { |
|
187 | + if ( ! is_array($data)) { |
|
188 | 188 | return [ |
189 | 189 | $type => $data |
190 | 190 | ]; |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | $organized_data = []; |
193 | 193 | foreach ($data as $input_name_part => $sub_inputs_or_value) { |
194 | 194 | if (is_array($sub_inputs_or_value)) { |
195 | - $organized_data[ $input_name_part ] = $this->organizeFilesData($sub_inputs_or_value, $type); |
|
195 | + $organized_data[$input_name_part] = $this->organizeFilesData($sub_inputs_or_value, $type); |
|
196 | 196 | } else { |
197 | - $organized_data[ $input_name_part ][ $type ] = $sub_inputs_or_value; |
|
197 | + $organized_data[$input_name_part][$type] = $sub_inputs_or_value; |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 | return $organized_data; |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | */ |
213 | 213 | protected function createFileObjects($organized_files, $name_parts_so_far = []) |
214 | 214 | { |
215 | - if (!is_array($organized_files)) { |
|
215 | + if ( ! is_array($organized_files)) { |
|
216 | 216 | throw new UnexpectedValueException( |
217 | 217 | sprintf( |
218 | 218 | esc_html__( |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | */ |
256 | 256 | protected function inputNameFromParts($parts) |
257 | 257 | { |
258 | - if (!is_array($parts)) { |
|
258 | + if ( ! is_array($parts)) { |
|
259 | 259 | throw new UnexpectedValueException(esc_html__('Name parts should be an array.', 'event_espresso')); |
260 | 260 | } |
261 | 261 | $generated_string = ''; |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | if ($generated_string === '') { |
264 | 264 | $generated_string = (string) $part; |
265 | 265 | } else { |
266 | - $generated_string .= '[' . (string) $part . ']'; |
|
266 | + $generated_string .= '['.(string) $part.']'; |
|
267 | 267 | } |
268 | 268 | } |
269 | 269 | return $generated_string; |
@@ -17,59 +17,59 @@ discard block |
||
17 | 17 | */ |
18 | 18 | class EE_File_Input extends EE_Form_Input_Base |
19 | 19 | { |
20 | - /** |
|
21 | - * @var array |
|
22 | - */ |
|
23 | - protected $allowed_file_extensions; |
|
20 | + /** |
|
21 | + * @var array |
|
22 | + */ |
|
23 | + protected $allowed_file_extensions; |
|
24 | 24 | |
25 | - /** |
|
26 | - * @var |
|
27 | - */ |
|
28 | - protected $allowed_mime_types; |
|
25 | + /** |
|
26 | + * @var |
|
27 | + */ |
|
28 | + protected $allowed_mime_types; |
|
29 | 29 | |
30 | - /** |
|
31 | - * @param array $options |
|
32 | - * @throws InvalidArgumentException |
|
33 | - */ |
|
34 | - public function __construct($options = array()) |
|
35 | - { |
|
36 | - if (isset($options['allowed_file_extensions'])) { |
|
37 | - if (!is_array($options['allowed_file_extensions'])) { |
|
38 | - throw new InvalidArgumentException(esc_html__('A valid allowed_file_extensions array was not provided to EE_File_Input', 'event_espresso')); |
|
39 | - } |
|
40 | - $this->allowed_file_extensions = $options['allowed_file_extensions']; |
|
41 | - } else { |
|
42 | - $this->allowed_file_extensions = ['csv']; |
|
43 | - } |
|
44 | - if (isset($options['allowed_mime_types'])) { |
|
45 | - if (!is_array($options['allowed_mime_types'])) { |
|
46 | - throw new InvalidArgumentException(esc_html__('A valid allowed_mime_types array was not provided to EE_File_Input', 'event_espresso')); |
|
47 | - } |
|
48 | - $this->allowed_mime_types = $options['allowed_file_extensions']; |
|
49 | - } else { |
|
50 | - $this->allowed_mime_types = ['text/csv']; |
|
51 | - } |
|
30 | + /** |
|
31 | + * @param array $options |
|
32 | + * @throws InvalidArgumentException |
|
33 | + */ |
|
34 | + public function __construct($options = array()) |
|
35 | + { |
|
36 | + if (isset($options['allowed_file_extensions'])) { |
|
37 | + if (!is_array($options['allowed_file_extensions'])) { |
|
38 | + throw new InvalidArgumentException(esc_html__('A valid allowed_file_extensions array was not provided to EE_File_Input', 'event_espresso')); |
|
39 | + } |
|
40 | + $this->allowed_file_extensions = $options['allowed_file_extensions']; |
|
41 | + } else { |
|
42 | + $this->allowed_file_extensions = ['csv']; |
|
43 | + } |
|
44 | + if (isset($options['allowed_mime_types'])) { |
|
45 | + if (!is_array($options['allowed_mime_types'])) { |
|
46 | + throw new InvalidArgumentException(esc_html__('A valid allowed_mime_types array was not provided to EE_File_Input', 'event_espresso')); |
|
47 | + } |
|
48 | + $this->allowed_mime_types = $options['allowed_file_extensions']; |
|
49 | + } else { |
|
50 | + $this->allowed_mime_types = ['text/csv']; |
|
51 | + } |
|
52 | 52 | |
53 | - $this->_set_display_strategy(new EE_File_Input_Display_Strategy()); |
|
54 | - $this->_set_normalization_strategy(new EE_File_Normalization()); |
|
55 | - $this->add_validation_strategy( |
|
56 | - new EE_Text_Validation_Strategy( |
|
57 | - sprintf( |
|
58 | - // translators: %1$s is a list of allowed file extensions. |
|
59 | - esc_html__('Please provide a file of the requested filetype: %1$s', 'event_espresso'), |
|
60 | - implode(', ', $this->allowed_file_extensions) |
|
61 | - ), |
|
62 | - '~.*\.(' . implode('|', $this->allowed_file_extensions) . ')$~' |
|
63 | - ) |
|
64 | - ); |
|
65 | - parent::__construct($options); |
|
53 | + $this->_set_display_strategy(new EE_File_Input_Display_Strategy()); |
|
54 | + $this->_set_normalization_strategy(new EE_File_Normalization()); |
|
55 | + $this->add_validation_strategy( |
|
56 | + new EE_Text_Validation_Strategy( |
|
57 | + sprintf( |
|
58 | + // translators: %1$s is a list of allowed file extensions. |
|
59 | + esc_html__('Please provide a file of the requested filetype: %1$s', 'event_espresso'), |
|
60 | + implode(', ', $this->allowed_file_extensions) |
|
61 | + ), |
|
62 | + '~.*\.(' . implode('|', $this->allowed_file_extensions) . ')$~' |
|
63 | + ) |
|
64 | + ); |
|
65 | + parent::__construct($options); |
|
66 | 66 | |
67 | 67 | // It would be great to add this HTML attribute, but jQuery validate chokes on it. |
68 | - $this->set_other_html_attributes( |
|
69 | - $this->other_html_attributes() |
|
70 | - . ' extension="' |
|
71 | - . implode( |
|
72 | - ',', |
|
68 | + $this->set_other_html_attributes( |
|
69 | + $this->other_html_attributes() |
|
70 | + . ' extension="' |
|
71 | + . implode( |
|
72 | + ',', |
|
73 | 73 | // array_merge( |
74 | 74 | // array_map( |
75 | 75 | // function ($mime_type) { |
@@ -82,32 +82,32 @@ discard block |
||
82 | 82 | // }, |
83 | 83 | // $this->allowed_mime_types |
84 | 84 | // ) |
85 | - array_map( |
|
86 | - function ($file_extension) { |
|
87 | - return $file_extension; |
|
88 | - }, |
|
89 | - $this->allowed_file_extensions |
|
90 | - ) |
|
85 | + array_map( |
|
86 | + function ($file_extension) { |
|
87 | + return $file_extension; |
|
88 | + }, |
|
89 | + $this->allowed_file_extensions |
|
90 | + ) |
|
91 | 91 | // ) |
92 | - ) |
|
93 | - . '"' |
|
94 | - ); |
|
95 | - } |
|
92 | + ) |
|
93 | + . '"' |
|
94 | + ); |
|
95 | + } |
|
96 | 96 | |
97 | - /** |
|
98 | - * Takes into account that $_FILES does a weird thing when you have hierarchical form names (eg `<input type="file" |
|
99 | - * name="my[hierarchical][form]">`): it leaves the top-level form part alone, but replaces the SECOND part with |
|
100 | - * "name", "size", "temp_file", etc. So that file's data is located at "my[name][hierarchical][form]", |
|
101 | - * "my[size][hierarchical][form]", "my[temp_name][hierarchical][form]", etc. It's really weird. |
|
102 | - * @since $VID:$ |
|
103 | - * @param array $req_data |
|
104 | - * @return array|mixed|NULL |
|
105 | - * @throws EE_Error |
|
106 | - */ |
|
107 | - public function find_form_data_for_this_section($req_data) |
|
108 | - { |
|
109 | - // ignore $req_data. Files are in the files data handler. |
|
110 | - $fileDataHandler = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\files\FilesDataHandler'); |
|
111 | - return $fileDataHandler->getFileObject($this->html_name()); |
|
112 | - } |
|
97 | + /** |
|
98 | + * Takes into account that $_FILES does a weird thing when you have hierarchical form names (eg `<input type="file" |
|
99 | + * name="my[hierarchical][form]">`): it leaves the top-level form part alone, but replaces the SECOND part with |
|
100 | + * "name", "size", "temp_file", etc. So that file's data is located at "my[name][hierarchical][form]", |
|
101 | + * "my[size][hierarchical][form]", "my[temp_name][hierarchical][form]", etc. It's really weird. |
|
102 | + * @since $VID:$ |
|
103 | + * @param array $req_data |
|
104 | + * @return array|mixed|NULL |
|
105 | + * @throws EE_Error |
|
106 | + */ |
|
107 | + public function find_form_data_for_this_section($req_data) |
|
108 | + { |
|
109 | + // ignore $req_data. Files are in the files data handler. |
|
110 | + $fileDataHandler = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\files\FilesDataHandler'); |
|
111 | + return $fileDataHandler->getFileObject($this->html_name()); |
|
112 | + } |
|
113 | 113 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | public function __construct($options = array()) |
35 | 35 | { |
36 | 36 | if (isset($options['allowed_file_extensions'])) { |
37 | - if (!is_array($options['allowed_file_extensions'])) { |
|
37 | + if ( ! is_array($options['allowed_file_extensions'])) { |
|
38 | 38 | throw new InvalidArgumentException(esc_html__('A valid allowed_file_extensions array was not provided to EE_File_Input', 'event_espresso')); |
39 | 39 | } |
40 | 40 | $this->allowed_file_extensions = $options['allowed_file_extensions']; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $this->allowed_file_extensions = ['csv']; |
43 | 43 | } |
44 | 44 | if (isset($options['allowed_mime_types'])) { |
45 | - if (!is_array($options['allowed_mime_types'])) { |
|
45 | + if ( ! is_array($options['allowed_mime_types'])) { |
|
46 | 46 | throw new InvalidArgumentException(esc_html__('A valid allowed_mime_types array was not provided to EE_File_Input', 'event_espresso')); |
47 | 47 | } |
48 | 48 | $this->allowed_mime_types = $options['allowed_file_extensions']; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | esc_html__('Please provide a file of the requested filetype: %1$s', 'event_espresso'), |
60 | 60 | implode(', ', $this->allowed_file_extensions) |
61 | 61 | ), |
62 | - '~.*\.(' . implode('|', $this->allowed_file_extensions) . ')$~' |
|
62 | + '~.*\.('.implode('|', $this->allowed_file_extensions).')$~' |
|
63 | 63 | ) |
64 | 64 | ); |
65 | 65 | parent::__construct($options); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | // $this->allowed_mime_types |
84 | 84 | // ) |
85 | 85 | array_map( |
86 | - function ($file_extension) { |
|
86 | + function($file_extension) { |
|
87 | 87 | return $file_extension; |
88 | 88 | }, |
89 | 89 | $this->allowed_file_extensions |
@@ -13,37 +13,37 @@ |
||
13 | 13 | class EE_File_Normalization extends EE_Normalization_Strategy_Base |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * Convert the $_FILES inputted data into a well-defined object. |
|
18 | - * @param string $value_to_normalize |
|
19 | - * @return FileSubmissionInterface |
|
20 | - */ |
|
21 | - public function normalize($value_to_normalize) |
|
22 | - { |
|
23 | - if( $value_to_normalize instanceof FileSubmissionInterface){ |
|
24 | - return $value_to_normalize; |
|
25 | - } else { |
|
26 | - throw new EE_Validation_Error( |
|
27 | - esc_html__('The file input has an inavlid format.', 'event_espresso') |
|
28 | - ); |
|
29 | - } |
|
30 | - } |
|
16 | + /** |
|
17 | + * Convert the $_FILES inputted data into a well-defined object. |
|
18 | + * @param string $value_to_normalize |
|
19 | + * @return FileSubmissionInterface |
|
20 | + */ |
|
21 | + public function normalize($value_to_normalize) |
|
22 | + { |
|
23 | + if( $value_to_normalize instanceof FileSubmissionInterface){ |
|
24 | + return $value_to_normalize; |
|
25 | + } else { |
|
26 | + throw new EE_Validation_Error( |
|
27 | + esc_html__('The file input has an inavlid format.', 'event_espresso') |
|
28 | + ); |
|
29 | + } |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * Convert the object back into a string of the filename. |
|
35 | - * |
|
36 | - * @param string $normalized_value |
|
37 | - * @return string |
|
38 | - */ |
|
39 | - public function unnormalize($normalized_value) |
|
40 | - { |
|
41 | - if ($normalized_value instanceof FileSubmissionInterface) { |
|
42 | - // Leave it as the object, it can be treated like a string because it |
|
43 | - // overrides __toString() |
|
44 | - return $normalized_value; |
|
45 | - } else { |
|
46 | - return (string) $normalized_value; |
|
47 | - } |
|
48 | - } |
|
33 | + /** |
|
34 | + * Convert the object back into a string of the filename. |
|
35 | + * |
|
36 | + * @param string $normalized_value |
|
37 | + * @return string |
|
38 | + */ |
|
39 | + public function unnormalize($normalized_value) |
|
40 | + { |
|
41 | + if ($normalized_value instanceof FileSubmissionInterface) { |
|
42 | + // Leave it as the object, it can be treated like a string because it |
|
43 | + // overrides __toString() |
|
44 | + return $normalized_value; |
|
45 | + } else { |
|
46 | + return (string) $normalized_value; |
|
47 | + } |
|
48 | + } |
|
49 | 49 | } |
50 | 50 | \ No newline at end of file |
@@ -20,7 +20,7 @@ |
||
20 | 20 | */ |
21 | 21 | public function normalize($value_to_normalize) |
22 | 22 | { |
23 | - if( $value_to_normalize instanceof FileSubmissionInterface){ |
|
23 | + if ($value_to_normalize instanceof FileSubmissionInterface) { |
|
24 | 24 | return $value_to_normalize; |
25 | 25 | } else { |
26 | 26 | throw new EE_Validation_Error( |