@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param WP $WP |
32 | 32 | * @return void |
33 | 33 | */ |
34 | - public function run( WP $WP ) { |
|
34 | + public function run(WP $WP) { |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param array $attributes |
42 | 42 | * @return string |
43 | 43 | */ |
44 | - public function process_shortcode( $attributes = array() ) { |
|
44 | + public function process_shortcode($attributes = array()) { |
|
45 | 45 | \EE_Error::doing_it_wrong( |
46 | 46 | __METHOD__, |
47 | 47 | __( |
@@ -10,15 +10,15 @@ discard block |
||
10 | 10 | class EES_Espresso_Events extends EES_Shortcode { |
11 | 11 | |
12 | 12 | /** |
13 | - * @deprecated 4.9.27 |
|
14 | - * @return void |
|
13 | + * @deprecated 4.9.27 |
|
14 | + * @return void |
|
15 | 15 | */ |
16 | 16 | public static function set_hooks() { |
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
20 | - * @deprecated 4.9.27 |
|
21 | - * @return void |
|
20 | + * @deprecated 4.9.27 |
|
21 | + * @return void |
|
22 | 22 | */ |
23 | 23 | public static function set_hooks_admin() { |
24 | 24 | } |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | |
27 | 27 | |
28 | 28 | /** |
29 | - * @deprecated 4.9.27 |
|
30 | - * @param WP $WP |
|
29 | + * @deprecated 4.9.27 |
|
30 | + * @param WP $WP |
|
31 | 31 | * @return void |
32 | 32 | */ |
33 | 33 | public function run( WP $WP ) { |
@@ -36,21 +36,21 @@ discard block |
||
36 | 36 | |
37 | 37 | |
38 | 38 | /** |
39 | - * @deprecated 4.9.27 |
|
40 | - * @param array $attributes |
|
39 | + * @deprecated 4.9.27 |
|
40 | + * @param array $attributes |
|
41 | 41 | * @return string |
42 | 42 | */ |
43 | 43 | public function process_shortcode( $attributes = array() ) { |
44 | - \EE_Error::doing_it_wrong( |
|
45 | - __METHOD__, |
|
46 | - __( |
|
47 | - 'Usage is deprecated. Please use \EventEspresso\core\domain\entities\shortcodes\EspressoEvents instead.', |
|
48 | - 'event_espresso' |
|
49 | - ), |
|
50 | - '4.9.27' |
|
51 | - ); |
|
52 | - return ''; |
|
53 | - } |
|
44 | + \EE_Error::doing_it_wrong( |
|
45 | + __METHOD__, |
|
46 | + __( |
|
47 | + 'Usage is deprecated. Please use \EventEspresso\core\domain\entities\shortcodes\EspressoEvents instead.', |
|
48 | + 'event_espresso' |
|
49 | + ), |
|
50 | + '4.9.27' |
|
51 | + ); |
|
52 | + return ''; |
|
53 | + } |
|
54 | 54 | |
55 | 55 | |
56 | 56 | |
@@ -74,23 +74,23 @@ discard block |
||
74 | 74 | */ |
75 | 75 | class EE_Event_List_Query { |
76 | 76 | |
77 | - /** |
|
78 | - * EE_Event_List_Query constructor. |
|
79 | - * |
|
80 | - * @param array $args |
|
81 | - */ |
|
82 | - public function __construct($args = array()) |
|
83 | - { |
|
84 | - \EE_Error::doing_it_wrong( |
|
85 | - __METHOD__, |
|
86 | - __( |
|
87 | - 'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.', |
|
88 | - 'event_espresso' |
|
89 | - ), |
|
90 | - '4.9.27' |
|
91 | - ); |
|
92 | - new \EventEspresso\core\domain\services\wp_queries\EventListQuery($args); |
|
93 | - } |
|
77 | + /** |
|
78 | + * EE_Event_List_Query constructor. |
|
79 | + * |
|
80 | + * @param array $args |
|
81 | + */ |
|
82 | + public function __construct($args = array()) |
|
83 | + { |
|
84 | + \EE_Error::doing_it_wrong( |
|
85 | + __METHOD__, |
|
86 | + __( |
|
87 | + 'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.', |
|
88 | + 'event_espresso' |
|
89 | + ), |
|
90 | + '4.9.27' |
|
91 | + ); |
|
92 | + new \EventEspresso\core\domain\services\wp_queries\EventListQuery($args); |
|
93 | + } |
|
94 | 94 | |
95 | 95 | } |
96 | 96 |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * ESPRESSO_EVENTS |
4 | 6 | * |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @param WP $WP |
19 | 19 | * @return void |
20 | 20 | */ |
21 | - public function run( WP $WP ) {} |
|
21 | + public function run(WP $WP) {} |
|
22 | 22 | |
23 | 23 | |
24 | 24 | /** |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @return string |
48 | 48 | * @throws \EE_Error |
49 | 49 | */ |
50 | - public function process_shortcode( $attributes = array() ) { |
|
50 | + public function process_shortcode($attributes = array()) { |
|
51 | 51 | \EE_Error::doing_it_wrong( |
52 | 52 | __METHOD__, |
53 | 53 | __( |
@@ -41,22 +41,22 @@ |
||
41 | 41 | |
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * @deprecated 4.9.27 |
|
46 | - * @param array $attributes |
|
47 | - * @return string |
|
48 | - * @throws \EE_Error |
|
49 | - */ |
|
44 | + /** |
|
45 | + * @deprecated 4.9.27 |
|
46 | + * @param array $attributes |
|
47 | + * @return string |
|
48 | + * @throws \EE_Error |
|
49 | + */ |
|
50 | 50 | public function process_shortcode( $attributes = array() ) { |
51 | - \EE_Error::doing_it_wrong( |
|
52 | - __METHOD__, |
|
53 | - __( |
|
54 | - 'Usage is deprecated. Please use \EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendeesShortcode instead.', |
|
55 | - 'event_espresso' |
|
56 | - ), |
|
57 | - '4.9.27' |
|
58 | - ); |
|
59 | - return ''; |
|
51 | + \EE_Error::doing_it_wrong( |
|
52 | + __METHOD__, |
|
53 | + __( |
|
54 | + 'Usage is deprecated. Please use \EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendeesShortcode instead.', |
|
55 | + 'event_espresso' |
|
56 | + ), |
|
57 | + '4.9.27' |
|
58 | + ); |
|
59 | + return ''; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 |
@@ -214,16 +214,16 @@ discard block |
||
214 | 214 | */ |
215 | 215 | public static function set_definitions() |
216 | 216 | { |
217 | - if(defined('SPCO_BASE_PATH')) { |
|
217 | + if (defined('SPCO_BASE_PATH')) { |
|
218 | 218 | return; |
219 | 219 | } |
220 | - define('SPCO_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS); |
|
221 | - define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS); |
|
222 | - define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS); |
|
223 | - define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS); |
|
224 | - define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS); |
|
225 | - define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS); |
|
226 | - define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS); |
|
220 | + define('SPCO_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS).DS); |
|
221 | + define('SPCO_CSS_URL', plugin_dir_url(__FILE__).'css'.DS); |
|
222 | + define('SPCO_IMG_URL', plugin_dir_url(__FILE__).'img'.DS); |
|
223 | + define('SPCO_JS_URL', plugin_dir_url(__FILE__).'js'.DS); |
|
224 | + define('SPCO_INC_PATH', SPCO_BASE_PATH.'inc'.DS); |
|
225 | + define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH.'reg_steps'.DS); |
|
226 | + define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH.'templates'.DS); |
|
227 | 227 | EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true); |
228 | 228 | EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
229 | 229 | __('%1$sWe\'re sorry, but you\'re registration time has expired.%2$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 except our apologies for any inconvenience this may have caused.%8$s', |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | '</h4>', |
233 | 233 | '<br />', |
234 | 234 | '<p>', |
235 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
235 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
236 | 236 | '">', |
237 | 237 | '</a>', |
238 | 238 | '</p>' |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | return; |
256 | 256 | } |
257 | 257 | // filter list of reg_steps |
258 | - $reg_steps_to_load = (array)apply_filters( |
|
258 | + $reg_steps_to_load = (array) apply_filters( |
|
259 | 259 | 'AHEE__SPCO__load_reg_steps__reg_steps_to_load', |
260 | 260 | EED_Single_Page_Checkout::get_reg_steps() |
261 | 261 | ); |
@@ -299,25 +299,25 @@ discard block |
||
299 | 299 | if (empty($reg_steps)) { |
300 | 300 | $reg_steps = array( |
301 | 301 | 10 => array( |
302 | - 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
302 | + 'file_path' => SPCO_REG_STEPS_PATH.'attendee_information', |
|
303 | 303 | 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
304 | 304 | 'slug' => 'attendee_information', |
305 | 305 | 'has_hooks' => false, |
306 | 306 | ), |
307 | 307 | 20 => array( |
308 | - 'file_path' => SPCO_REG_STEPS_PATH . 'registration_confirmation', |
|
308 | + 'file_path' => SPCO_REG_STEPS_PATH.'registration_confirmation', |
|
309 | 309 | 'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation', |
310 | 310 | 'slug' => 'registration_confirmation', |
311 | 311 | 'has_hooks' => false, |
312 | 312 | ), |
313 | 313 | 30 => array( |
314 | - 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
314 | + 'file_path' => SPCO_REG_STEPS_PATH.'payment_options', |
|
315 | 315 | 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
316 | 316 | 'slug' => 'payment_options', |
317 | 317 | 'has_hooks' => true, |
318 | 318 | ), |
319 | 319 | 999 => array( |
320 | - 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
320 | + 'file_path' => SPCO_REG_STEPS_PATH.'finalize_registration', |
|
321 | 321 | 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
322 | 322 | 'slug' => 'finalize_registration', |
323 | 323 | 'has_hooks' => false, |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | // DEBUG LOG |
498 | 498 | //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
499 | 499 | // get reg form |
500 | - if( ! $this->_check_form_submission()) { |
|
500 | + if ( ! $this->_check_form_submission()) { |
|
501 | 501 | EED_Single_Page_Checkout::$_initialized = true; |
502 | 502 | return; |
503 | 503 | } |
@@ -1062,7 +1062,7 @@ discard block |
||
1062 | 1062 | if ( ! $registration instanceof EE_Registration) { |
1063 | 1063 | throw new InvalidEntityException($registration, 'EE_Registration'); |
1064 | 1064 | } |
1065 | - $registrations[ $registration->ID() ] = $registration; |
|
1065 | + $registrations[$registration->ID()] = $registration; |
|
1066 | 1066 | } |
1067 | 1067 | } |
1068 | 1068 | $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
@@ -1296,7 +1296,7 @@ discard block |
||
1296 | 1296 | ) { |
1297 | 1297 | EE_Error::add_success( |
1298 | 1298 | $this->checkout->current_step->success_message() |
1299 | - . '<br />' . $this->checkout->next_step->_instructions() |
|
1299 | + . '<br />'.$this->checkout->next_step->_instructions() |
|
1300 | 1300 | ); |
1301 | 1301 | } |
1302 | 1302 | // pack it up, pack it in... |
@@ -1393,7 +1393,7 @@ discard block |
||
1393 | 1393 | '</h4>', |
1394 | 1394 | '<br />', |
1395 | 1395 | '<p>', |
1396 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
1396 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
1397 | 1397 | '">', |
1398 | 1398 | '</a>', |
1399 | 1399 | '</p>' |
@@ -1419,12 +1419,12 @@ discard block |
||
1419 | 1419 | public function enqueue_styles_and_scripts() |
1420 | 1420 | { |
1421 | 1421 | // load css |
1422 | - wp_register_style('single_page_checkout', SPCO_CSS_URL . 'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION); |
|
1422 | + wp_register_style('single_page_checkout', SPCO_CSS_URL.'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION); |
|
1423 | 1423 | wp_enqueue_style('single_page_checkout'); |
1424 | 1424 | // load JS |
1425 | - wp_register_script('jquery_plugin', EE_THIRD_PARTY_URL . 'jquery .plugin.min.js', array('jquery'), '1.0.1', true); |
|
1426 | - wp_register_script('jquery_countdown', EE_THIRD_PARTY_URL . 'jquery .countdown.min.js', array('jquery_plugin'), '2.0.2', true); |
|
1427 | - wp_register_script('single_page_checkout', SPCO_JS_URL . 'single_page_checkout.js', array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'), EVENT_ESPRESSO_VERSION, true); |
|
1425 | + wp_register_script('jquery_plugin', EE_THIRD_PARTY_URL.'jquery .plugin.min.js', array('jquery'), '1.0.1', true); |
|
1426 | + wp_register_script('jquery_countdown', EE_THIRD_PARTY_URL.'jquery .countdown.min.js', array('jquery_plugin'), '2.0.2', true); |
|
1427 | + wp_register_script('single_page_checkout', SPCO_JS_URL.'single_page_checkout.js', array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'), EVENT_ESPRESSO_VERSION, true); |
|
1428 | 1428 | if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) { |
1429 | 1429 | $this->checkout->registration_form->enqueue_js(); |
1430 | 1430 | } |
@@ -1441,7 +1441,7 @@ discard block |
||
1441 | 1441 | * dynamic action hook for enqueueing styles and scripts with spco calls. |
1442 | 1442 | * The hook will end up being something like AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
1443 | 1443 | */ |
1444 | - do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), $this); |
|
1444 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__'.$this->checkout->current_step->slug(), $this); |
|
1445 | 1445 | } |
1446 | 1446 | |
1447 | 1447 | |
@@ -1493,7 +1493,7 @@ discard block |
||
1493 | 1493 | 'layout_strategy' => |
1494 | 1494 | new EE_Template_Layout( |
1495 | 1495 | array( |
1496 | - 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
1496 | + 'layout_template_file' => SPCO_TEMPLATES_PATH.'registration_page_wrapper.template.php', |
|
1497 | 1497 | 'template_args' => array( |
1498 | 1498 | 'empty_cart' => $empty_cart, |
1499 | 1499 | 'revisit' => $this->checkout->revisit, |
@@ -1507,7 +1507,7 @@ discard block |
||
1507 | 1507 | sprintf( |
1508 | 1508 | __('You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', |
1509 | 1509 | 'event_espresso'), |
1510 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
1510 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
1511 | 1511 | '">', |
1512 | 1512 | '</a>' |
1513 | 1513 | ) |
@@ -1564,7 +1564,7 @@ discard block |
||
1564 | 1564 | ) { |
1565 | 1565 | add_filter( |
1566 | 1566 | 'FHEE__EEH_Template__powered_by_event_espresso__url', |
1567 | - function ($url) { |
|
1567 | + function($url) { |
|
1568 | 1568 | return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
1569 | 1569 | } |
1570 | 1570 | ); |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | use EventEspresso\core\exceptions\InvalidEntityException; |
3 | 3 | |
4 | 4 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
5 | - exit('No direct script access allowed'); |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -17,1723 +17,1723 @@ discard block |
||
17 | 17 | class EED_Single_Page_Checkout extends EED_Module |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * $_initialized - has the SPCO controller already been initialized ? |
|
22 | - * |
|
23 | - * @access private |
|
24 | - * @var bool $_initialized |
|
25 | - */ |
|
26 | - private static $_initialized = false; |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * $_checkout_verified - is the EE_Checkout verified as correct for this request ? |
|
31 | - * |
|
32 | - * @access private |
|
33 | - * @var bool $_valid_checkout |
|
34 | - */ |
|
35 | - private static $_checkout_verified = true; |
|
36 | - |
|
37 | - /** |
|
38 | - * $_reg_steps_array - holds initial array of reg steps |
|
39 | - * |
|
40 | - * @access private |
|
41 | - * @var array $_reg_steps_array |
|
42 | - */ |
|
43 | - private static $_reg_steps_array = array(); |
|
44 | - |
|
45 | - /** |
|
46 | - * $checkout - EE_Checkout object for handling the properties of the current checkout process |
|
47 | - * |
|
48 | - * @access public |
|
49 | - * @var EE_Checkout $checkout |
|
50 | - */ |
|
51 | - public $checkout; |
|
52 | - |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * @return EED_Single_Page_Checkout |
|
57 | - */ |
|
58 | - public static function instance() |
|
59 | - { |
|
60 | - add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true'); |
|
61 | - return parent::get_instance(__CLASS__); |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * @return EE_CART |
|
68 | - */ |
|
69 | - public function cart() |
|
70 | - { |
|
71 | - return $this->checkout->cart; |
|
72 | - } |
|
73 | - |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * @return EE_Transaction |
|
78 | - */ |
|
79 | - public function transaction() |
|
80 | - { |
|
81 | - return $this->checkout->transaction; |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - |
|
86 | - /** |
|
87 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
88 | - * |
|
89 | - * @access public |
|
90 | - * @return void |
|
91 | - * @throws \EE_Error |
|
92 | - */ |
|
93 | - public static function set_hooks() |
|
94 | - { |
|
95 | - EED_Single_Page_Checkout::set_definitions(); |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - |
|
100 | - /** |
|
101 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
102 | - * |
|
103 | - * @access public |
|
104 | - * @return void |
|
105 | - * @throws \EE_Error |
|
106 | - */ |
|
107 | - public static function set_hooks_admin() |
|
108 | - { |
|
109 | - EED_Single_Page_Checkout::set_definitions(); |
|
110 | - if ( ! (defined('DOING_AJAX') && DOING_AJAX)) { |
|
111 | - return; |
|
112 | - } |
|
113 | - // going to start an output buffer in case anything gets accidentally output that might disrupt our JSON response |
|
114 | - ob_start(); |
|
115 | - EED_Single_Page_Checkout::load_request_handler(); |
|
116 | - EED_Single_Page_Checkout::load_reg_steps(); |
|
117 | - // set ajax hooks |
|
118 | - add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
119 | - add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
120 | - add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
121 | - add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
122 | - add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
123 | - add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * process ajax request |
|
130 | - * |
|
131 | - * @param string $ajax_action |
|
132 | - * @throws \EE_Error |
|
133 | - */ |
|
134 | - public static function process_ajax_request($ajax_action) |
|
135 | - { |
|
136 | - EE_Registry::instance()->REQ->set('action', $ajax_action); |
|
137 | - EED_Single_Page_Checkout::instance()->_initialize(); |
|
138 | - } |
|
139 | - |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * ajax display registration step |
|
144 | - * |
|
145 | - * @throws \EE_Error |
|
146 | - */ |
|
147 | - public static function display_reg_step() |
|
148 | - { |
|
149 | - EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step'); |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - |
|
154 | - /** |
|
155 | - * ajax process registration step |
|
156 | - * |
|
157 | - * @throws \EE_Error |
|
158 | - */ |
|
159 | - public static function process_reg_step() |
|
160 | - { |
|
161 | - EED_Single_Page_Checkout::process_ajax_request('process_reg_step'); |
|
162 | - } |
|
163 | - |
|
164 | - |
|
165 | - |
|
166 | - /** |
|
167 | - * ajax process registration step |
|
168 | - * |
|
169 | - * @throws \EE_Error |
|
170 | - */ |
|
171 | - public static function update_reg_step() |
|
172 | - { |
|
173 | - EED_Single_Page_Checkout::process_ajax_request('update_reg_step'); |
|
174 | - } |
|
175 | - |
|
176 | - |
|
177 | - |
|
178 | - /** |
|
179 | - * update_checkout |
|
180 | - * |
|
181 | - * @access public |
|
182 | - * @return void |
|
183 | - * @throws \EE_Error |
|
184 | - */ |
|
185 | - public static function update_checkout() |
|
186 | - { |
|
187 | - EED_Single_Page_Checkout::process_ajax_request('update_checkout'); |
|
188 | - } |
|
189 | - |
|
190 | - |
|
191 | - |
|
192 | - /** |
|
193 | - * load_request_handler |
|
194 | - * |
|
195 | - * @access public |
|
196 | - * @return void |
|
197 | - */ |
|
198 | - public static function load_request_handler() |
|
199 | - { |
|
200 | - // load core Request_Handler class |
|
201 | - if ( ! isset(EE_Registry::instance()->REQ)) { |
|
202 | - EE_Registry::instance()->load_core('Request_Handler'); |
|
203 | - } |
|
204 | - } |
|
205 | - |
|
206 | - |
|
207 | - |
|
208 | - /** |
|
209 | - * set_definitions |
|
210 | - * |
|
211 | - * @access public |
|
212 | - * @return void |
|
213 | - * @throws \EE_Error |
|
214 | - */ |
|
215 | - public static function set_definitions() |
|
216 | - { |
|
217 | - if(defined('SPCO_BASE_PATH')) { |
|
218 | - return; |
|
219 | - } |
|
220 | - define('SPCO_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS); |
|
221 | - define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS); |
|
222 | - define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS); |
|
223 | - define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS); |
|
224 | - define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS); |
|
225 | - define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS); |
|
226 | - define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS); |
|
227 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true); |
|
228 | - EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
|
229 | - __('%1$sWe\'re sorry, but you\'re registration time has expired.%2$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 except our apologies for any inconvenience this may have caused.%8$s', |
|
230 | - 'event_espresso'), |
|
231 | - '<h4 class="important-notice">', |
|
232 | - '</h4>', |
|
233 | - '<br />', |
|
234 | - '<p>', |
|
235 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
236 | - '">', |
|
237 | - '</a>', |
|
238 | - '</p>' |
|
239 | - ); |
|
240 | - } |
|
241 | - |
|
242 | - |
|
243 | - |
|
244 | - /** |
|
245 | - * load_reg_steps |
|
246 | - * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array |
|
247 | - * |
|
248 | - * @access private |
|
249 | - * @throws \EE_Error |
|
250 | - */ |
|
251 | - public static function load_reg_steps() |
|
252 | - { |
|
253 | - static $reg_steps_loaded = false; |
|
254 | - if ($reg_steps_loaded) { |
|
255 | - return; |
|
256 | - } |
|
257 | - // filter list of reg_steps |
|
258 | - $reg_steps_to_load = (array)apply_filters( |
|
259 | - 'AHEE__SPCO__load_reg_steps__reg_steps_to_load', |
|
260 | - EED_Single_Page_Checkout::get_reg_steps() |
|
261 | - ); |
|
262 | - // sort by key (order) |
|
263 | - ksort($reg_steps_to_load); |
|
264 | - // loop through folders |
|
265 | - foreach ($reg_steps_to_load as $order => $reg_step) { |
|
266 | - // we need a |
|
267 | - if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
268 | - // copy over to the reg_steps_array |
|
269 | - EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step; |
|
270 | - // register custom key route for each reg step |
|
271 | - // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
|
272 | - EE_Config::register_route($reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step'); |
|
273 | - // add AJAX or other hooks |
|
274 | - if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
|
275 | - // setup autoloaders if necessary |
|
276 | - if ( ! class_exists($reg_step['class_name'])) { |
|
277 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder($reg_step['file_path'], true); |
|
278 | - } |
|
279 | - if (is_callable($reg_step['class_name'], 'set_hooks')) { |
|
280 | - call_user_func(array($reg_step['class_name'], 'set_hooks')); |
|
281 | - } |
|
282 | - } |
|
283 | - } |
|
284 | - } |
|
285 | - $reg_steps_loaded = true; |
|
286 | - } |
|
287 | - |
|
288 | - |
|
289 | - |
|
290 | - /** |
|
291 | - * get_reg_steps |
|
292 | - * |
|
293 | - * @access public |
|
294 | - * @return array |
|
295 | - */ |
|
296 | - public static function get_reg_steps() |
|
297 | - { |
|
298 | - $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps; |
|
299 | - if (empty($reg_steps)) { |
|
300 | - $reg_steps = array( |
|
301 | - 10 => array( |
|
302 | - 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
303 | - 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
|
304 | - 'slug' => 'attendee_information', |
|
305 | - 'has_hooks' => false, |
|
306 | - ), |
|
307 | - 20 => array( |
|
308 | - 'file_path' => SPCO_REG_STEPS_PATH . 'registration_confirmation', |
|
309 | - 'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation', |
|
310 | - 'slug' => 'registration_confirmation', |
|
311 | - 'has_hooks' => false, |
|
312 | - ), |
|
313 | - 30 => array( |
|
314 | - 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
315 | - 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
|
316 | - 'slug' => 'payment_options', |
|
317 | - 'has_hooks' => true, |
|
318 | - ), |
|
319 | - 999 => array( |
|
320 | - 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
321 | - 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
|
322 | - 'slug' => 'finalize_registration', |
|
323 | - 'has_hooks' => false, |
|
324 | - ), |
|
325 | - ); |
|
326 | - } |
|
327 | - return $reg_steps; |
|
328 | - } |
|
329 | - |
|
330 | - |
|
331 | - |
|
332 | - /** |
|
333 | - * registration_checkout_for_admin |
|
334 | - * |
|
335 | - * @access public |
|
336 | - * @return string |
|
337 | - * @throws \EE_Error |
|
338 | - */ |
|
339 | - public static function registration_checkout_for_admin() |
|
340 | - { |
|
341 | - EED_Single_Page_Checkout::load_request_handler(); |
|
342 | - EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
343 | - EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step'); |
|
344 | - EE_Registry::instance()->REQ->set('process_form_submission', false); |
|
345 | - EED_Single_Page_Checkout::instance()->_initialize(); |
|
346 | - EED_Single_Page_Checkout::instance()->_display_spco_reg_form(); |
|
347 | - return EE_Registry::instance()->REQ->get_output(); |
|
348 | - } |
|
349 | - |
|
350 | - |
|
351 | - |
|
352 | - /** |
|
353 | - * process_registration_from_admin |
|
354 | - * |
|
355 | - * @access public |
|
356 | - * @return \EE_Transaction |
|
357 | - * @throws \EE_Error |
|
358 | - */ |
|
359 | - public static function process_registration_from_admin() |
|
360 | - { |
|
361 | - EED_Single_Page_Checkout::load_request_handler(); |
|
362 | - EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
363 | - EE_Registry::instance()->REQ->set('action', 'process_reg_step'); |
|
364 | - EE_Registry::instance()->REQ->set('process_form_submission', true); |
|
365 | - EED_Single_Page_Checkout::instance()->_initialize(); |
|
366 | - if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) { |
|
367 | - $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps); |
|
368 | - if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
369 | - EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step); |
|
370 | - if ($final_reg_step->process_reg_step()) { |
|
371 | - $final_reg_step->set_completed(); |
|
372 | - EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array(); |
|
373 | - return EED_Single_Page_Checkout::instance()->checkout->transaction; |
|
374 | - } |
|
375 | - } |
|
376 | - } |
|
377 | - return null; |
|
378 | - } |
|
379 | - |
|
380 | - |
|
381 | - |
|
382 | - /** |
|
383 | - * run |
|
384 | - * |
|
385 | - * @access public |
|
386 | - * @param WP_Query $WP_Query |
|
387 | - * @return void |
|
388 | - * @throws \EE_Error |
|
389 | - */ |
|
390 | - public function run($WP_Query) |
|
391 | - { |
|
392 | - if ( |
|
393 | - $WP_Query instanceof WP_Query |
|
394 | - && $WP_Query->is_main_query() |
|
395 | - && apply_filters('FHEE__EED_Single_Page_Checkout__run', true) |
|
396 | - && $this->_is_reg_checkout() |
|
397 | - ) { |
|
398 | - $this->_initialize(); |
|
399 | - } |
|
400 | - } |
|
401 | - |
|
402 | - |
|
403 | - |
|
404 | - /** |
|
405 | - * determines whether current url matches reg page url |
|
406 | - * |
|
407 | - * @return bool |
|
408 | - */ |
|
409 | - protected function _is_reg_checkout() |
|
410 | - { |
|
411 | - // get current permalink for reg page without any extra query args |
|
412 | - $reg_page_url = \get_permalink(EE_Config::instance()->core->reg_page_id); |
|
413 | - // get request URI for current request, but without the scheme or host |
|
414 | - $current_request_uri = \EEH_URL::filter_input_server_url('REQUEST_URI'); |
|
415 | - $current_request_uri = html_entity_decode($current_request_uri); |
|
416 | - // get array of query args from the current request URI |
|
417 | - $query_args = \EEH_URL::get_query_string($current_request_uri); |
|
418 | - // grab page id if it is set |
|
419 | - $page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0; |
|
420 | - // and remove the page id from the query args (we will re-add it later) |
|
421 | - unset($query_args['page_id']); |
|
422 | - // now strip all query args from current request URI |
|
423 | - $current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri); |
|
424 | - // and re-add the page id if it was set |
|
425 | - if ($page_id) { |
|
426 | - $current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri); |
|
427 | - } |
|
428 | - // remove slashes and ? |
|
429 | - $current_request_uri = trim($current_request_uri, '?/'); |
|
430 | - // is current request URI part of the known full reg page URL ? |
|
431 | - return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false; |
|
432 | - } |
|
433 | - |
|
434 | - |
|
435 | - |
|
436 | - /** |
|
437 | - * @param WP_Query $wp_query |
|
438 | - * @return void |
|
439 | - * @throws \EE_Error |
|
440 | - */ |
|
441 | - public static function init($wp_query) |
|
442 | - { |
|
443 | - EED_Single_Page_Checkout::instance()->run($wp_query); |
|
444 | - } |
|
445 | - |
|
446 | - |
|
447 | - |
|
448 | - /** |
|
449 | - * _initialize - initial module setup |
|
450 | - * |
|
451 | - * @access private |
|
452 | - * @throws EE_Error |
|
453 | - * @return void |
|
454 | - */ |
|
455 | - private function _initialize() |
|
456 | - { |
|
457 | - // ensure SPCO doesn't run twice |
|
458 | - if (EED_Single_Page_Checkout::$_initialized) { |
|
459 | - return; |
|
460 | - } |
|
461 | - try { |
|
462 | - EED_Single_Page_Checkout::load_reg_steps(); |
|
463 | - $this->_verify_session(); |
|
464 | - // setup the EE_Checkout object |
|
465 | - $this->checkout = $this->_initialize_checkout(); |
|
466 | - // filter checkout |
|
467 | - $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); |
|
468 | - // get the $_GET |
|
469 | - $this->_get_request_vars(); |
|
470 | - if ($this->_block_bots()) { |
|
471 | - return; |
|
472 | - } |
|
473 | - // filter continue_reg |
|
474 | - $this->checkout->continue_reg = apply_filters('FHEE__EED_Single_Page_Checkout__init___continue_reg', true, $this->checkout); |
|
475 | - // load the reg steps array |
|
476 | - if ( ! $this->_load_and_instantiate_reg_steps()) { |
|
477 | - EED_Single_Page_Checkout::$_initialized = true; |
|
478 | - return; |
|
479 | - } |
|
480 | - // set the current step |
|
481 | - $this->checkout->set_current_step($this->checkout->step); |
|
482 | - // and the next step |
|
483 | - $this->checkout->set_next_step(); |
|
484 | - // verify that everything has been setup correctly |
|
485 | - if ( ! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) { |
|
486 | - EED_Single_Page_Checkout::$_initialized = true; |
|
487 | - return; |
|
488 | - } |
|
489 | - // lock the transaction |
|
490 | - $this->checkout->transaction->lock(); |
|
491 | - // make sure all of our cached objects are added to their respective model entity mappers |
|
492 | - $this->checkout->refresh_all_entities(); |
|
493 | - // set amount owing |
|
494 | - $this->checkout->amount_owing = $this->checkout->transaction->remaining(); |
|
495 | - // initialize each reg step, which gives them the chance to potentially alter the process |
|
496 | - $this->_initialize_reg_steps(); |
|
497 | - // DEBUG LOG |
|
498 | - //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
|
499 | - // get reg form |
|
500 | - if( ! $this->_check_form_submission()) { |
|
501 | - EED_Single_Page_Checkout::$_initialized = true; |
|
502 | - return; |
|
503 | - } |
|
504 | - // checkout the action!!! |
|
505 | - $this->_process_form_action(); |
|
506 | - // add some style and make it dance |
|
507 | - $this->add_styles_and_scripts(); |
|
508 | - // kk... SPCO has successfully run |
|
509 | - EED_Single_Page_Checkout::$_initialized = true; |
|
510 | - // set no cache headers and constants |
|
511 | - EE_System::do_not_cache(); |
|
512 | - // add anchor |
|
513 | - add_action('loop_start', array($this, 'set_checkout_anchor'), 1); |
|
514 | - // remove transaction lock |
|
515 | - add_action('shutdown', array($this, 'unlock_transaction'), 1); |
|
516 | - } catch (Exception $e) { |
|
517 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
518 | - } |
|
519 | - } |
|
520 | - |
|
521 | - |
|
522 | - |
|
523 | - /** |
|
524 | - * _verify_session |
|
525 | - * checks that the session is valid and not expired |
|
526 | - * |
|
527 | - * @access private |
|
528 | - * @throws EE_Error |
|
529 | - */ |
|
530 | - private function _verify_session() |
|
531 | - { |
|
532 | - if ( ! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
533 | - throw new EE_Error(__('The EE_Session class could not be loaded.', 'event_espresso')); |
|
534 | - } |
|
535 | - // is session still valid ? |
|
536 | - if (EE_Registry::instance()->SSN->expired() && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === '') { |
|
537 | - $this->checkout = new EE_Checkout(); |
|
538 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
539 | - // EE_Registry::instance()->SSN->reset_cart(); |
|
540 | - // EE_Registry::instance()->SSN->reset_checkout(); |
|
541 | - // EE_Registry::instance()->SSN->reset_transaction(); |
|
542 | - EE_Error::add_attention(EE_Registry::$i18n_js_strings['registration_expiration_notice'], __FILE__, |
|
543 | - __FUNCTION__, __LINE__); |
|
544 | - // EE_Registry::instance()->SSN->reset_expired(); |
|
545 | - } |
|
546 | - } |
|
547 | - |
|
548 | - |
|
549 | - |
|
550 | - /** |
|
551 | - * _initialize_checkout |
|
552 | - * loads and instantiates EE_Checkout |
|
553 | - * |
|
554 | - * @access private |
|
555 | - * @throws EE_Error |
|
556 | - * @return EE_Checkout |
|
557 | - */ |
|
558 | - private function _initialize_checkout() |
|
559 | - { |
|
560 | - // look in session for existing checkout |
|
561 | - /** @type EE_Checkout $checkout */ |
|
562 | - $checkout = EE_Registry::instance()->SSN->checkout(); |
|
563 | - // verify |
|
564 | - if ( ! $checkout instanceof EE_Checkout) { |
|
565 | - // instantiate EE_Checkout object for handling the properties of the current checkout process |
|
566 | - $checkout = EE_Registry::instance()->load_file(SPCO_INC_PATH, 'EE_Checkout', 'class', array(), false); |
|
567 | - } else { |
|
568 | - if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) { |
|
569 | - $this->unlock_transaction(); |
|
570 | - wp_safe_redirect($checkout->redirect_url); |
|
571 | - exit(); |
|
572 | - } |
|
573 | - } |
|
574 | - $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
|
575 | - // verify again |
|
576 | - if ( ! $checkout instanceof EE_Checkout) { |
|
577 | - throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
|
578 | - } |
|
579 | - // reset anything that needs a clean slate for each request |
|
580 | - $checkout->reset_for_current_request(); |
|
581 | - return $checkout; |
|
582 | - } |
|
583 | - |
|
584 | - |
|
585 | - |
|
586 | - /** |
|
587 | - * _get_request_vars |
|
588 | - * |
|
589 | - * @access private |
|
590 | - * @return void |
|
591 | - * @throws \EE_Error |
|
592 | - */ |
|
593 | - private function _get_request_vars() |
|
594 | - { |
|
595 | - // load classes |
|
596 | - EED_Single_Page_Checkout::load_request_handler(); |
|
597 | - //make sure this request is marked as belonging to EE |
|
598 | - EE_Registry::instance()->REQ->set_espresso_page(true); |
|
599 | - // which step is being requested ? |
|
600 | - $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step()); |
|
601 | - // which step is being edited ? |
|
602 | - $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', ''); |
|
603 | - // and what we're doing on the current step |
|
604 | - $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step'); |
|
605 | - // timestamp |
|
606 | - $this->checkout->uts = EE_Registry::instance()->REQ->get('uts', 0); |
|
607 | - // returning to edit ? |
|
608 | - $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', ''); |
|
609 | - // or some other kind of revisit ? |
|
610 | - $this->checkout->revisit = filter_var( |
|
611 | - EE_Registry::instance()->REQ->get('revisit', false), |
|
612 | - FILTER_VALIDATE_BOOLEAN |
|
613 | - ); |
|
614 | - // and whether or not to generate a reg form for this request |
|
615 | - $this->checkout->generate_reg_form = filter_var( |
|
616 | - EE_Registry::instance()->REQ->get('generate_reg_form', true), |
|
617 | - FILTER_VALIDATE_BOOLEAN |
|
618 | - ); |
|
619 | - // and whether or not to process a reg form submission for this request |
|
620 | - $this->checkout->process_form_submission = filter_var( |
|
621 | - EE_Registry::instance()->REQ->get( |
|
622 | - 'process_form_submission', |
|
623 | - $this->checkout->action === 'process_reg_step' |
|
624 | - ), |
|
625 | - FILTER_VALIDATE_BOOLEAN |
|
626 | - ); |
|
627 | - $this->checkout->process_form_submission = filter_var( |
|
628 | - $this->checkout->action !== 'display_spco_reg_step' |
|
629 | - ? $this->checkout->process_form_submission |
|
630 | - : false, |
|
631 | - FILTER_VALIDATE_BOOLEAN |
|
632 | - ); |
|
633 | - // $this->_display_request_vars(); |
|
634 | - } |
|
635 | - |
|
636 | - |
|
637 | - |
|
638 | - /** |
|
639 | - * _display_request_vars |
|
640 | - * |
|
641 | - * @access protected |
|
642 | - * @return void |
|
643 | - */ |
|
644 | - protected function _display_request_vars() |
|
645 | - { |
|
646 | - if ( ! WP_DEBUG) { |
|
647 | - return; |
|
648 | - } |
|
649 | - EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__); |
|
650 | - EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__); |
|
651 | - EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__); |
|
652 | - EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__); |
|
653 | - EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__); |
|
654 | - EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__); |
|
655 | - EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__); |
|
656 | - EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__); |
|
657 | - } |
|
658 | - |
|
659 | - |
|
660 | - |
|
661 | - /** |
|
662 | - * _block_bots |
|
663 | - * checks that the incoming request has either of the following set: |
|
664 | - * a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector |
|
665 | - * a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN |
|
666 | - * so if you're not coming from the Ticket Selector nor returning for a valid IP... |
|
667 | - * then where you coming from man? |
|
668 | - * |
|
669 | - * @return boolean |
|
670 | - */ |
|
671 | - private function _block_bots() |
|
672 | - { |
|
673 | - $invalid_checkout_access = \EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
674 | - if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) { |
|
675 | - return true; |
|
676 | - } |
|
677 | - return false; |
|
678 | - } |
|
679 | - |
|
680 | - |
|
681 | - |
|
682 | - /** |
|
683 | - * _get_first_step |
|
684 | - * gets slug for first step in $_reg_steps_array |
|
685 | - * |
|
686 | - * @access private |
|
687 | - * @throws EE_Error |
|
688 | - * @return string |
|
689 | - */ |
|
690 | - private function _get_first_step() |
|
691 | - { |
|
692 | - $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array); |
|
693 | - return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information'; |
|
694 | - } |
|
695 | - |
|
696 | - |
|
697 | - |
|
698 | - /** |
|
699 | - * _load_and_instantiate_reg_steps |
|
700 | - * instantiates each reg step based on the loaded reg_steps array |
|
701 | - * |
|
702 | - * @access private |
|
703 | - * @throws EE_Error |
|
704 | - * @return bool |
|
705 | - */ |
|
706 | - private function _load_and_instantiate_reg_steps() |
|
707 | - { |
|
708 | - do_action('AHEE__Single_Page_Checkout___load_and_instantiate_reg_steps__start', $this->checkout); |
|
709 | - // have reg_steps already been instantiated ? |
|
710 | - if ( |
|
711 | - empty($this->checkout->reg_steps) |
|
712 | - || apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout) |
|
713 | - ) { |
|
714 | - // if not, then loop through raw reg steps array |
|
715 | - foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
|
716 | - if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
717 | - return false; |
|
718 | - } |
|
719 | - } |
|
720 | - EE_Registry::instance()->CFG->registration->skip_reg_confirmation = true; |
|
721 | - EE_Registry::instance()->CFG->registration->reg_confirmation_last = true; |
|
722 | - // skip the registration_confirmation page ? |
|
723 | - if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) { |
|
724 | - // just remove it from the reg steps array |
|
725 | - $this->checkout->remove_reg_step('registration_confirmation', false); |
|
726 | - } else if ( |
|
727 | - isset($this->checkout->reg_steps['registration_confirmation']) |
|
728 | - && EE_Registry::instance()->CFG->registration->reg_confirmation_last |
|
729 | - ) { |
|
730 | - // set the order to something big like 100 |
|
731 | - $this->checkout->set_reg_step_order('registration_confirmation', 100); |
|
732 | - } |
|
733 | - // filter the array for good luck |
|
734 | - $this->checkout->reg_steps = apply_filters( |
|
735 | - 'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps', |
|
736 | - $this->checkout->reg_steps |
|
737 | - ); |
|
738 | - // finally re-sort based on the reg step class order properties |
|
739 | - $this->checkout->sort_reg_steps(); |
|
740 | - } else { |
|
741 | - foreach ($this->checkout->reg_steps as $reg_step) { |
|
742 | - // set all current step stati to FALSE |
|
743 | - $reg_step->set_is_current_step(false); |
|
744 | - } |
|
745 | - } |
|
746 | - if (empty($this->checkout->reg_steps)) { |
|
747 | - EE_Error::add_error(__('No Reg Steps were loaded..', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
748 | - return false; |
|
749 | - } |
|
750 | - // make reg step details available to JS |
|
751 | - $this->checkout->set_reg_step_JSON_info(); |
|
752 | - return true; |
|
753 | - } |
|
754 | - |
|
755 | - |
|
756 | - |
|
757 | - /** |
|
758 | - * _load_and_instantiate_reg_step |
|
759 | - * |
|
760 | - * @access private |
|
761 | - * @param array $reg_step |
|
762 | - * @param int $order |
|
763 | - * @return bool |
|
764 | - */ |
|
765 | - private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) |
|
766 | - { |
|
767 | - // we need a file_path, class_name, and slug to add a reg step |
|
768 | - if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
769 | - // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
|
770 | - if ( |
|
771 | - $this->checkout->reg_url_link |
|
772 | - && $this->checkout->step !== $reg_step['slug'] |
|
773 | - && $reg_step['slug'] !== 'finalize_registration' |
|
774 | - // normally at this point we would NOT load the reg step, but this filter can change that |
|
775 | - && apply_filters( |
|
776 | - 'FHEE__Single_Page_Checkout___load_and_instantiate_reg_step__bypass_reg_step', |
|
777 | - true, |
|
778 | - $reg_step, |
|
779 | - $this->checkout |
|
780 | - ) |
|
781 | - ) { |
|
782 | - return true; |
|
783 | - } |
|
784 | - // instantiate step class using file path and class name |
|
785 | - $reg_step_obj = EE_Registry::instance()->load_file( |
|
786 | - $reg_step['file_path'], |
|
787 | - $reg_step['class_name'], |
|
788 | - 'class', |
|
789 | - $this->checkout, |
|
790 | - false |
|
791 | - ); |
|
792 | - // did we gets the goods ? |
|
793 | - if ($reg_step_obj instanceof EE_SPCO_Reg_Step) { |
|
794 | - // set reg step order based on config |
|
795 | - $reg_step_obj->set_order($order); |
|
796 | - // add instantiated reg step object to the master reg steps array |
|
797 | - $this->checkout->add_reg_step($reg_step_obj); |
|
798 | - } else { |
|
799 | - EE_Error::add_error( |
|
800 | - __('The current step could not be set.', 'event_espresso'), |
|
801 | - __FILE__, __FUNCTION__, __LINE__ |
|
802 | - ); |
|
803 | - return false; |
|
804 | - } |
|
805 | - } else { |
|
806 | - if (WP_DEBUG) { |
|
807 | - EE_Error::add_error( |
|
808 | - sprintf( |
|
809 | - __('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', 'event_espresso'), |
|
810 | - isset($reg_step['file_path']) ? $reg_step['file_path'] : '', |
|
811 | - isset($reg_step['class_name']) ? $reg_step['class_name'] : '', |
|
812 | - isset($reg_step['slug']) ? $reg_step['slug'] : '', |
|
813 | - '<ul>', |
|
814 | - '<li>', |
|
815 | - '</li>', |
|
816 | - '</ul>' |
|
817 | - ), |
|
818 | - __FILE__, __FUNCTION__, __LINE__ |
|
819 | - ); |
|
820 | - } |
|
821 | - return false; |
|
822 | - } |
|
823 | - return true; |
|
824 | - } |
|
825 | - |
|
826 | - |
|
827 | - |
|
828 | - /** |
|
829 | - * _verify_transaction_and_get_registrations |
|
830 | - * |
|
831 | - * @access private |
|
832 | - * @return bool |
|
833 | - */ |
|
834 | - private function _verify_transaction_and_get_registrations() |
|
835 | - { |
|
836 | - // was there already a valid transaction in the checkout from the session ? |
|
837 | - if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
838 | - // get transaction from db or session |
|
839 | - $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
|
840 | - ? $this->_get_transaction_and_cart_for_previous_visit() |
|
841 | - : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
|
842 | - if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
843 | - EE_Error::add_error( |
|
844 | - __('Your Registration and Transaction information could not be retrieved from the db.', |
|
845 | - 'event_espresso'), |
|
846 | - __FILE__, __FUNCTION__, __LINE__ |
|
847 | - ); |
|
848 | - $this->checkout->transaction = EE_Transaction::new_instance(); |
|
849 | - // add some style and make it dance |
|
850 | - $this->add_styles_and_scripts(); |
|
851 | - EED_Single_Page_Checkout::$_initialized = true; |
|
852 | - return false; |
|
853 | - } |
|
854 | - // and the registrations for the transaction |
|
855 | - $this->_get_registrations($this->checkout->transaction); |
|
856 | - } |
|
857 | - return true; |
|
858 | - } |
|
859 | - |
|
860 | - |
|
861 | - |
|
862 | - /** |
|
863 | - * _get_transaction_and_cart_for_previous_visit |
|
864 | - * |
|
865 | - * @access private |
|
866 | - * @return mixed EE_Transaction|NULL |
|
867 | - */ |
|
868 | - private function _get_transaction_and_cart_for_previous_visit() |
|
869 | - { |
|
870 | - /** @var $TXN_model EEM_Transaction */ |
|
871 | - $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
872 | - // because the reg_url_link is present in the request, this is a return visit to SPCO, so we'll get the transaction data from the db |
|
873 | - $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link); |
|
874 | - // verify transaction |
|
875 | - if ($transaction instanceof EE_Transaction) { |
|
876 | - // and get the cart that was used for that transaction |
|
877 | - $this->checkout->cart = $this->_get_cart_for_transaction($transaction); |
|
878 | - return $transaction; |
|
879 | - } else { |
|
880 | - EE_Error::add_error(__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
881 | - return null; |
|
882 | - } |
|
883 | - } |
|
884 | - |
|
885 | - |
|
886 | - |
|
887 | - /** |
|
888 | - * _get_cart_for_transaction |
|
889 | - * |
|
890 | - * @access private |
|
891 | - * @param EE_Transaction $transaction |
|
892 | - * @return EE_Cart |
|
893 | - */ |
|
894 | - private function _get_cart_for_transaction($transaction) |
|
895 | - { |
|
896 | - return $this->checkout->get_cart_for_transaction($transaction); |
|
897 | - } |
|
898 | - |
|
899 | - |
|
900 | - |
|
901 | - /** |
|
902 | - * get_cart_for_transaction |
|
903 | - * |
|
904 | - * @access public |
|
905 | - * @param EE_Transaction $transaction |
|
906 | - * @return EE_Cart |
|
907 | - */ |
|
908 | - public function get_cart_for_transaction(EE_Transaction $transaction) |
|
909 | - { |
|
910 | - return $this->checkout->get_cart_for_transaction($transaction); |
|
911 | - } |
|
912 | - |
|
913 | - |
|
914 | - |
|
915 | - /** |
|
916 | - * _get_transaction_and_cart_for_current_session |
|
917 | - * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
918 | - * |
|
919 | - * @access private |
|
920 | - * @return EE_Transaction |
|
921 | - * @throws \EE_Error |
|
922 | - */ |
|
923 | - private function _get_cart_for_current_session_and_setup_new_transaction() |
|
924 | - { |
|
925 | - // if there's no transaction, then this is the FIRST visit to SPCO |
|
926 | - // so load up the cart ( passing nothing for the TXN because it doesn't exist yet ) |
|
927 | - $this->checkout->cart = $this->_get_cart_for_transaction(null); |
|
928 | - // and then create a new transaction |
|
929 | - $transaction = $this->_initialize_transaction(); |
|
930 | - // verify transaction |
|
931 | - if ($transaction instanceof EE_Transaction) { |
|
932 | - // save it so that we have an ID for other objects to use |
|
933 | - $transaction->save(); |
|
934 | - // and save TXN data to the cart |
|
935 | - $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID()); |
|
936 | - } else { |
|
937 | - EE_Error::add_error(__('A Valid Transaction could not be initialized.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
938 | - } |
|
939 | - return $transaction; |
|
940 | - } |
|
941 | - |
|
942 | - |
|
943 | - |
|
944 | - /** |
|
945 | - * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
946 | - * |
|
947 | - * @access private |
|
948 | - * @return mixed EE_Transaction|NULL |
|
949 | - */ |
|
950 | - private function _initialize_transaction() |
|
951 | - { |
|
952 | - try { |
|
953 | - // ensure cart totals have been calculated |
|
954 | - $this->checkout->cart->get_grand_total()->recalculate_total_including_taxes(); |
|
955 | - // grab the cart grand total |
|
956 | - $cart_total = $this->checkout->cart->get_cart_grand_total(); |
|
957 | - // create new TXN |
|
958 | - $transaction = EE_Transaction::new_instance( |
|
959 | - array( |
|
960 | - 'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(), |
|
961 | - 'TXN_total' => $cart_total > 0 ? $cart_total : 0, |
|
962 | - 'TXN_paid' => 0, |
|
963 | - 'STS_ID' => EEM_Transaction::failed_status_code, |
|
964 | - ) |
|
965 | - ); |
|
966 | - // save it so that we have an ID for other objects to use |
|
967 | - $transaction->save(); |
|
968 | - // set cron job for following up on TXNs after their session has expired |
|
969 | - EE_Cron_Tasks::schedule_expired_transaction_check( |
|
970 | - EE_Registry::instance()->SSN->expiration() + 1, |
|
971 | - $transaction->ID() |
|
972 | - ); |
|
973 | - return $transaction; |
|
974 | - } catch (Exception $e) { |
|
975 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
976 | - } |
|
977 | - return null; |
|
978 | - } |
|
979 | - |
|
980 | - |
|
981 | - |
|
982 | - /** |
|
983 | - * _get_registrations |
|
984 | - * |
|
985 | - * @access private |
|
986 | - * @param EE_Transaction $transaction |
|
987 | - * @return void |
|
988 | - * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
989 | - * @throws \EE_Error |
|
990 | - */ |
|
991 | - private function _get_registrations(EE_Transaction $transaction) |
|
992 | - { |
|
993 | - // first step: grab the registrants { : o |
|
994 | - $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, true); |
|
995 | - // verify registrations have been set |
|
996 | - if (empty($registrations)) { |
|
997 | - // if no cached registrations, then check the db |
|
998 | - $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
999 | - // still nothing ? well as long as this isn't a revisit |
|
1000 | - if (empty($registrations) && ! $this->checkout->revisit) { |
|
1001 | - // generate new registrations from scratch |
|
1002 | - $registrations = $this->_initialize_registrations($transaction); |
|
1003 | - } |
|
1004 | - } |
|
1005 | - // sort by their original registration order |
|
1006 | - usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count')); |
|
1007 | - // then loop thru the array |
|
1008 | - foreach ($registrations as $registration) { |
|
1009 | - // verify each registration |
|
1010 | - if ($registration instanceof EE_Registration) { |
|
1011 | - // we display all attendee info for the primary registrant |
|
1012 | - if ($this->checkout->reg_url_link === $registration->reg_url_link() |
|
1013 | - && $registration->is_primary_registrant() |
|
1014 | - ) { |
|
1015 | - $this->checkout->primary_revisit = true; |
|
1016 | - break; |
|
1017 | - } else if ($this->checkout->revisit |
|
1018 | - && $this->checkout->reg_url_link !== $registration->reg_url_link() |
|
1019 | - ) { |
|
1020 | - // but hide info if it doesn't belong to you |
|
1021 | - $transaction->clear_cache('Registration', $registration->ID()); |
|
1022 | - } |
|
1023 | - $this->checkout->set_reg_status_updated($registration->ID(), false); |
|
1024 | - } |
|
1025 | - } |
|
1026 | - } |
|
1027 | - |
|
1028 | - |
|
1029 | - |
|
1030 | - /** |
|
1031 | - * adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object |
|
1032 | - * |
|
1033 | - * @access private |
|
1034 | - * @param EE_Transaction $transaction |
|
1035 | - * @return array |
|
1036 | - * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
1037 | - * @throws \EE_Error |
|
1038 | - */ |
|
1039 | - private function _initialize_registrations(EE_Transaction $transaction) |
|
1040 | - { |
|
1041 | - $att_nmbr = 0; |
|
1042 | - $registrations = array(); |
|
1043 | - if ($transaction instanceof EE_Transaction) { |
|
1044 | - /** @type EE_Registration_Processor $registration_processor */ |
|
1045 | - $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1046 | - $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count(); |
|
1047 | - // now let's add the cart items to the $transaction |
|
1048 | - foreach ($this->checkout->cart->get_tickets() as $line_item) { |
|
1049 | - //do the following for each ticket of this type they selected |
|
1050 | - for ($x = 1; $x <= $line_item->quantity(); $x++) { |
|
1051 | - $att_nmbr++; |
|
1052 | - /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */ |
|
1053 | - $CreateRegistrationCommand = EE_Registry::instance() |
|
1054 | - ->create( |
|
1055 | - 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
1056 | - array( |
|
1057 | - $transaction, |
|
1058 | - $line_item, |
|
1059 | - $att_nmbr, |
|
1060 | - $this->checkout->total_ticket_count, |
|
1061 | - ) |
|
1062 | - ); |
|
1063 | - // override capabilities for frontend registrations |
|
1064 | - if ( ! is_admin()) { |
|
1065 | - $CreateRegistrationCommand->setCapCheck( |
|
1066 | - new PublicCapabilities('', 'create_new_registration') |
|
1067 | - ); |
|
1068 | - } |
|
1069 | - $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand); |
|
1070 | - if ( ! $registration instanceof EE_Registration) { |
|
1071 | - throw new InvalidEntityException($registration, 'EE_Registration'); |
|
1072 | - } |
|
1073 | - $registrations[ $registration->ID() ] = $registration; |
|
1074 | - } |
|
1075 | - } |
|
1076 | - $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
|
1077 | - } |
|
1078 | - return $registrations; |
|
1079 | - } |
|
1080 | - |
|
1081 | - |
|
1082 | - |
|
1083 | - /** |
|
1084 | - * sorts registrations by REG_count |
|
1085 | - * |
|
1086 | - * @access public |
|
1087 | - * @param EE_Registration $reg_A |
|
1088 | - * @param EE_Registration $reg_B |
|
1089 | - * @return int |
|
1090 | - */ |
|
1091 | - public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) |
|
1092 | - { |
|
1093 | - // this shouldn't ever happen within the same TXN, but oh well |
|
1094 | - if ($reg_A->count() === $reg_B->count()) { |
|
1095 | - return 0; |
|
1096 | - } |
|
1097 | - return ($reg_A->count() > $reg_B->count()) ? 1 : -1; |
|
1098 | - } |
|
1099 | - |
|
1100 | - |
|
1101 | - |
|
1102 | - /** |
|
1103 | - * _final_verifications |
|
1104 | - * just makes sure that everything is set up correctly before proceeding |
|
1105 | - * |
|
1106 | - * @access private |
|
1107 | - * @return bool |
|
1108 | - * @throws \EE_Error |
|
1109 | - */ |
|
1110 | - private function _final_verifications() |
|
1111 | - { |
|
1112 | - // filter checkout |
|
1113 | - $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout); |
|
1114 | - //verify that current step is still set correctly |
|
1115 | - if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
1116 | - EE_Error::add_error( |
|
1117 | - __('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.', 'event_espresso'), |
|
1118 | - __FILE__, |
|
1119 | - __FUNCTION__, |
|
1120 | - __LINE__ |
|
1121 | - ); |
|
1122 | - return false; |
|
1123 | - } |
|
1124 | - // if returning to SPCO, then verify that primary registrant is set |
|
1125 | - if ( ! empty($this->checkout->reg_url_link)) { |
|
1126 | - $valid_registrant = $this->checkout->transaction->primary_registration(); |
|
1127 | - if ( ! $valid_registrant instanceof EE_Registration) { |
|
1128 | - EE_Error::add_error( |
|
1129 | - __('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.', 'event_espresso'), |
|
1130 | - __FILE__, |
|
1131 | - __FUNCTION__, |
|
1132 | - __LINE__ |
|
1133 | - ); |
|
1134 | - return false; |
|
1135 | - } |
|
1136 | - $valid_registrant = null; |
|
1137 | - foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) { |
|
1138 | - if ( |
|
1139 | - $registration instanceof EE_Registration |
|
1140 | - && $registration->reg_url_link() === $this->checkout->reg_url_link |
|
1141 | - ) { |
|
1142 | - $valid_registrant = $registration; |
|
1143 | - } |
|
1144 | - } |
|
1145 | - if ( ! $valid_registrant instanceof EE_Registration) { |
|
1146 | - // hmmm... maybe we have the wrong session because the user is opening multiple tabs ? |
|
1147 | - if (EED_Single_Page_Checkout::$_checkout_verified) { |
|
1148 | - // clear the session, mark the checkout as unverified, and try again |
|
1149 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
1150 | - EED_Single_Page_Checkout::$_initialized = false; |
|
1151 | - EED_Single_Page_Checkout::$_checkout_verified = false; |
|
1152 | - $this->_initialize(); |
|
1153 | - EE_Error::reset_notices(); |
|
1154 | - return false; |
|
1155 | - } |
|
1156 | - EE_Error::add_error( |
|
1157 | - __('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.', 'event_espresso'), |
|
1158 | - __FILE__, |
|
1159 | - __FUNCTION__, |
|
1160 | - __LINE__ |
|
1161 | - ); |
|
1162 | - return false; |
|
1163 | - } |
|
1164 | - } |
|
1165 | - // now that things have been kinda sufficiently verified, |
|
1166 | - // let's add the checkout to the session so that it's available to other systems |
|
1167 | - EE_Registry::instance()->SSN->set_checkout($this->checkout); |
|
1168 | - return true; |
|
1169 | - } |
|
1170 | - |
|
1171 | - |
|
1172 | - |
|
1173 | - /** |
|
1174 | - * _initialize_reg_steps |
|
1175 | - * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required |
|
1176 | - * then loops thru all of the active reg steps and calls the initialize_reg_step() method |
|
1177 | - * |
|
1178 | - * @access private |
|
1179 | - * @param bool $reinitializing |
|
1180 | - * @throws \EE_Error |
|
1181 | - */ |
|
1182 | - private function _initialize_reg_steps($reinitializing = false) |
|
1183 | - { |
|
1184 | - $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
|
1185 | - // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
|
1186 | - foreach ($this->checkout->reg_steps as $reg_step) { |
|
1187 | - if ( ! $reg_step->initialize_reg_step()) { |
|
1188 | - // if not initialized then maybe this step is being removed... |
|
1189 | - if ( ! $reinitializing && $reg_step->is_current_step()) { |
|
1190 | - // if it was the current step, then we need to start over here |
|
1191 | - $this->_initialize_reg_steps(true); |
|
1192 | - return; |
|
1193 | - } |
|
1194 | - continue; |
|
1195 | - } |
|
1196 | - // add css and JS for current step |
|
1197 | - $reg_step->enqueue_styles_and_scripts(); |
|
1198 | - // i18n |
|
1199 | - $reg_step->translate_js_strings(); |
|
1200 | - if ($reg_step->is_current_step()) { |
|
1201 | - // the text that appears on the reg step form submit button |
|
1202 | - $reg_step->set_submit_button_text(); |
|
1203 | - } |
|
1204 | - } |
|
1205 | - // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information |
|
1206 | - do_action("AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step); |
|
1207 | - } |
|
1208 | - |
|
1209 | - |
|
1210 | - |
|
1211 | - /** |
|
1212 | - * _check_form_submission |
|
1213 | - * |
|
1214 | - * @access private |
|
1215 | - * @return boolean |
|
1216 | - */ |
|
1217 | - private function _check_form_submission() |
|
1218 | - { |
|
1219 | - //does this request require the reg form to be generated ? |
|
1220 | - if ($this->checkout->generate_reg_form) { |
|
1221 | - // ever heard that song by Blue Rodeo ? |
|
1222 | - try { |
|
1223 | - $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form(); |
|
1224 | - // if not displaying a form, then check for form submission |
|
1225 | - if ( |
|
1226 | - $this->checkout->process_form_submission |
|
1227 | - && $this->checkout->current_step->reg_form->was_submitted() |
|
1228 | - ) { |
|
1229 | - // clear out any old data in case this step is being run again |
|
1230 | - $this->checkout->current_step->set_valid_data(array()); |
|
1231 | - // capture submitted form data |
|
1232 | - $this->checkout->current_step->reg_form->receive_form_submission( |
|
1233 | - apply_filters( |
|
1234 | - 'FHEE__Single_Page_Checkout___check_form_submission__request_params', |
|
1235 | - EE_Registry::instance()->REQ->params(), |
|
1236 | - $this->checkout |
|
1237 | - ) |
|
1238 | - ); |
|
1239 | - // validate submitted form data |
|
1240 | - if ( ! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) { |
|
1241 | - // thou shall not pass !!! |
|
1242 | - $this->checkout->continue_reg = false; |
|
1243 | - // any form validation errors? |
|
1244 | - if ($this->checkout->current_step->reg_form->submission_error_message() !== '') { |
|
1245 | - $submission_error_messages = array(); |
|
1246 | - // bad, bad, bad registrant |
|
1247 | - foreach ($this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error) { |
|
1248 | - if ($validation_error instanceof EE_Validation_Error) { |
|
1249 | - $submission_error_messages[] = sprintf( |
|
1250 | - __('%s : %s', 'event_espresso'), |
|
1251 | - $validation_error->get_form_section()->html_label_text(), |
|
1252 | - $validation_error->getMessage() |
|
1253 | - ); |
|
1254 | - } |
|
1255 | - } |
|
1256 | - EE_Error::add_error(implode('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__); |
|
1257 | - } |
|
1258 | - // well not really... what will happen is we'll just get redirected back to redo the current step |
|
1259 | - $this->go_to_next_step(); |
|
1260 | - return false; |
|
1261 | - } |
|
1262 | - } |
|
1263 | - } catch (EE_Error $e) { |
|
1264 | - $e->get_error(); |
|
1265 | - } |
|
1266 | - } |
|
1267 | - return true; |
|
1268 | - } |
|
1269 | - |
|
1270 | - |
|
1271 | - |
|
1272 | - /** |
|
1273 | - * _process_action |
|
1274 | - * |
|
1275 | - * @access private |
|
1276 | - * @return void |
|
1277 | - * @throws \EE_Error |
|
1278 | - */ |
|
1279 | - private function _process_form_action() |
|
1280 | - { |
|
1281 | - // what cha wanna do? |
|
1282 | - switch ($this->checkout->action) { |
|
1283 | - // AJAX next step reg form |
|
1284 | - case 'display_spco_reg_step' : |
|
1285 | - $this->checkout->redirect = false; |
|
1286 | - if (EE_Registry::instance()->REQ->ajax) { |
|
1287 | - $this->checkout->json_response->set_reg_step_html($this->checkout->current_step->display_reg_form()); |
|
1288 | - } |
|
1289 | - break; |
|
1290 | - default : |
|
1291 | - // meh... do one of those other steps first |
|
1292 | - if ( ! empty($this->checkout->action) && is_callable(array($this->checkout->current_step, $this->checkout->action))) { |
|
1293 | - // dynamically creates hook point like: AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step |
|
1294 | - do_action("AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
1295 | - // call action on current step |
|
1296 | - if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) { |
|
1297 | - // good registrant, you get to proceed |
|
1298 | - if ( |
|
1299 | - $this->checkout->current_step->success_message() !== '' |
|
1300 | - && apply_filters( |
|
1301 | - 'FHEE__Single_Page_Checkout___process_form_action__display_success', |
|
1302 | - false |
|
1303 | - ) |
|
1304 | - ) { |
|
1305 | - EE_Error::add_success( |
|
1306 | - $this->checkout->current_step->success_message() |
|
1307 | - . '<br />' . $this->checkout->next_step->_instructions() |
|
1308 | - ); |
|
1309 | - } |
|
1310 | - // pack it up, pack it in... |
|
1311 | - $this->_setup_redirect(); |
|
1312 | - } |
|
1313 | - // dynamically creates hook point like: AHEE__Single_Page_Checkout__after_payment_options__process_reg_step |
|
1314 | - do_action("AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
1315 | - } else { |
|
1316 | - EE_Error::add_error( |
|
1317 | - sprintf( |
|
1318 | - __('The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso'), |
|
1319 | - $this->checkout->action, |
|
1320 | - $this->checkout->current_step->name() |
|
1321 | - ), |
|
1322 | - __FILE__, |
|
1323 | - __FUNCTION__, |
|
1324 | - __LINE__ |
|
1325 | - ); |
|
1326 | - } |
|
1327 | - // end default |
|
1328 | - } |
|
1329 | - // store our progress so far |
|
1330 | - $this->checkout->stash_transaction_and_checkout(); |
|
1331 | - // advance to the next step! If you pass GO, collect $200 |
|
1332 | - $this->go_to_next_step(); |
|
1333 | - } |
|
1334 | - |
|
1335 | - |
|
1336 | - |
|
1337 | - /** |
|
1338 | - * add_styles_and_scripts |
|
1339 | - * |
|
1340 | - * @access public |
|
1341 | - * @return void |
|
1342 | - */ |
|
1343 | - public function add_styles_and_scripts() |
|
1344 | - { |
|
1345 | - // i18n |
|
1346 | - $this->translate_js_strings(); |
|
1347 | - if ($this->checkout->admin_request) { |
|
1348 | - add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1349 | - } else { |
|
1350 | - add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1351 | - } |
|
1352 | - } |
|
1353 | - |
|
1354 | - |
|
1355 | - |
|
1356 | - /** |
|
1357 | - * translate_js_strings |
|
1358 | - * |
|
1359 | - * @access public |
|
1360 | - * @return void |
|
1361 | - */ |
|
1362 | - public function translate_js_strings() |
|
1363 | - { |
|
1364 | - EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit; |
|
1365 | - EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link; |
|
1366 | - EE_Registry::$i18n_js_strings['server_error'] = __('An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso'); |
|
1367 | - EE_Registry::$i18n_js_strings['invalid_json_response'] = __('An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso'); |
|
1368 | - EE_Registry::$i18n_js_strings['validation_error'] = __('There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso'); |
|
1369 | - EE_Registry::$i18n_js_strings['invalid_payment_method'] = __('There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso'); |
|
1370 | - EE_Registry::$i18n_js_strings['reg_step_error'] = __('This registration step could not be completed. Please refresh the page and try again.', 'event_espresso'); |
|
1371 | - EE_Registry::$i18n_js_strings['invalid_coupon'] = __('We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', 'event_espresso'); |
|
1372 | - EE_Registry::$i18n_js_strings['process_registration'] = sprintf( |
|
1373 | - __('Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', 'event_espresso'), |
|
1374 | - '<br/>', |
|
1375 | - '<br/>' |
|
1376 | - ); |
|
1377 | - EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language'); |
|
1378 | - EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id(); |
|
1379 | - EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency; |
|
1380 | - EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20'; |
|
1381 | - EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso'); |
|
1382 | - EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso'); |
|
1383 | - EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso'); |
|
1384 | - EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso'); |
|
1385 | - EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso'); |
|
1386 | - EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso'); |
|
1387 | - EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso'); |
|
1388 | - EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso'); |
|
1389 | - EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso'); |
|
1390 | - EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso'); |
|
1391 | - EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso'); |
|
1392 | - EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso'); |
|
1393 | - EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso'); |
|
1394 | - EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso'); |
|
1395 | - EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
|
1396 | - __( |
|
1397 | - '%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 except our apologies for any inconvenience this may have caused.%8$s', |
|
1398 | - 'event_espresso' |
|
1399 | - ), |
|
1400 | - '<h4 class="important-notice">', |
|
1401 | - '</h4>', |
|
1402 | - '<br />', |
|
1403 | - '<p>', |
|
1404 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
1405 | - '">', |
|
1406 | - '</a>', |
|
1407 | - '</p>' |
|
1408 | - ); |
|
1409 | - EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters('FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true); |
|
1410 | - EE_Registry::$i18n_js_strings['session_extension'] = absint( |
|
1411 | - apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS) |
|
1412 | - ); |
|
1413 | - EE_Registry::$i18n_js_strings['session_expiration'] = gmdate( |
|
1414 | - 'M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
1415 | - ); |
|
1416 | - } |
|
1417 | - |
|
1418 | - |
|
1419 | - |
|
1420 | - /** |
|
1421 | - * enqueue_styles_and_scripts |
|
1422 | - * |
|
1423 | - * @access public |
|
1424 | - * @return void |
|
1425 | - * @throws \EE_Error |
|
1426 | - */ |
|
1427 | - public function enqueue_styles_and_scripts() |
|
1428 | - { |
|
1429 | - // load css |
|
1430 | - wp_register_style('single_page_checkout', SPCO_CSS_URL . 'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION); |
|
1431 | - wp_enqueue_style('single_page_checkout'); |
|
1432 | - // load JS |
|
1433 | - wp_register_script('jquery_plugin', EE_THIRD_PARTY_URL . 'jquery .plugin.min.js', array('jquery'), '1.0.1', true); |
|
1434 | - wp_register_script('jquery_countdown', EE_THIRD_PARTY_URL . 'jquery .countdown.min.js', array('jquery_plugin'), '2.0.2', true); |
|
1435 | - wp_register_script('single_page_checkout', SPCO_JS_URL . 'single_page_checkout.js', array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'), EVENT_ESPRESSO_VERSION, true); |
|
1436 | - if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) { |
|
1437 | - $this->checkout->registration_form->enqueue_js(); |
|
1438 | - } |
|
1439 | - if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) { |
|
1440 | - $this->checkout->current_step->reg_form->enqueue_js(); |
|
1441 | - } |
|
1442 | - wp_enqueue_script('single_page_checkout'); |
|
1443 | - /** |
|
1444 | - * global action hook for enqueueing styles and scripts with |
|
1445 | - * spco calls. |
|
1446 | - */ |
|
1447 | - do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this); |
|
1448 | - /** |
|
1449 | - * dynamic action hook for enqueueing styles and scripts with spco calls. |
|
1450 | - * The hook will end up being something like AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
|
1451 | - */ |
|
1452 | - do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), $this); |
|
1453 | - } |
|
1454 | - |
|
1455 | - |
|
1456 | - |
|
1457 | - /** |
|
1458 | - * display the Registration Single Page Checkout Form |
|
1459 | - * |
|
1460 | - * @access private |
|
1461 | - * @return void |
|
1462 | - * @throws \EE_Error |
|
1463 | - */ |
|
1464 | - private function _display_spco_reg_form() |
|
1465 | - { |
|
1466 | - // if registering via the admin, just display the reg form for the current step |
|
1467 | - if ($this->checkout->admin_request) { |
|
1468 | - EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form()); |
|
1469 | - } else { |
|
1470 | - // add powered by EE msg |
|
1471 | - add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer')); |
|
1472 | - $empty_cart = count($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)) < 1 |
|
1473 | - ? true |
|
1474 | - : false; |
|
1475 | - EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart; |
|
1476 | - $cookies_not_set_msg = ''; |
|
1477 | - if ($empty_cart && ! isset($_COOKIE['ee_cookie_test'])) { |
|
1478 | - $cookies_not_set_msg = apply_filters( |
|
1479 | - 'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg', |
|
1480 | - sprintf( |
|
1481 | - __( |
|
1482 | - '%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', |
|
1483 | - 'event_espresso' |
|
1484 | - ), |
|
1485 | - '<div class="ee-attention">', |
|
1486 | - '</div>', |
|
1487 | - '<h6 class="important-notice">', |
|
1488 | - '</h6>', |
|
1489 | - '<p>', |
|
1490 | - '</p>', |
|
1491 | - '<br />', |
|
1492 | - '<a href="http://www.whatarecookies.com/enable.asp" target="_blank">', |
|
1493 | - '</a>' |
|
1494 | - ) |
|
1495 | - ); |
|
1496 | - } |
|
1497 | - $this->checkout->registration_form = new EE_Form_Section_Proper( |
|
1498 | - array( |
|
1499 | - 'name' => 'single-page-checkout', |
|
1500 | - 'html_id' => 'ee-single-page-checkout-dv', |
|
1501 | - 'layout_strategy' => |
|
1502 | - new EE_Template_Layout( |
|
1503 | - array( |
|
1504 | - 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
1505 | - 'template_args' => array( |
|
1506 | - 'empty_cart' => $empty_cart, |
|
1507 | - 'revisit' => $this->checkout->revisit, |
|
1508 | - 'reg_steps' => $this->checkout->reg_steps, |
|
1509 | - 'next_step' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
|
1510 | - ? $this->checkout->next_step->slug() |
|
1511 | - : '', |
|
1512 | - 'cancel_page_url' => $this->checkout->cancel_page_url, |
|
1513 | - 'empty_msg' => apply_filters( |
|
1514 | - 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
|
1515 | - sprintf( |
|
1516 | - __('You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', |
|
1517 | - 'event_espresso'), |
|
1518 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
1519 | - '">', |
|
1520 | - '</a>' |
|
1521 | - ) |
|
1522 | - ), |
|
1523 | - 'cookies_not_set_msg' => $cookies_not_set_msg, |
|
1524 | - 'registration_time_limit' => $this->checkout->get_registration_time_limit(), |
|
1525 | - 'session_expiration' => gmdate( |
|
1526 | - 'M d, Y H:i:s', |
|
1527 | - EE_Registry::instance()->SSN->expiration() |
|
1528 | - + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
1529 | - ), |
|
1530 | - ), |
|
1531 | - ) |
|
1532 | - ), |
|
1533 | - ) |
|
1534 | - ); |
|
1535 | - // load template and add to output sent that gets filtered into the_content() |
|
1536 | - EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html()); |
|
1537 | - } |
|
1538 | - } |
|
1539 | - |
|
1540 | - |
|
1541 | - |
|
1542 | - /** |
|
1543 | - * add_extra_finalize_registration_inputs |
|
1544 | - * |
|
1545 | - * @access public |
|
1546 | - * @param $next_step |
|
1547 | - * @internal param string $label |
|
1548 | - * @return void |
|
1549 | - */ |
|
1550 | - public function add_extra_finalize_registration_inputs($next_step) |
|
1551 | - { |
|
1552 | - if ($next_step === 'finalize_registration') { |
|
1553 | - echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>'; |
|
1554 | - } |
|
1555 | - } |
|
1556 | - |
|
1557 | - |
|
1558 | - |
|
1559 | - /** |
|
1560 | - * display_registration_footer |
|
1561 | - * |
|
1562 | - * @access public |
|
1563 | - * @return string |
|
1564 | - */ |
|
1565 | - public static function display_registration_footer() |
|
1566 | - { |
|
1567 | - if ( |
|
1568 | - apply_filters( |
|
1569 | - 'FHEE__EE_Front__Controller__show_reg_footer', |
|
1570 | - EE_Registry::instance()->CFG->admin->show_reg_footer |
|
1571 | - ) |
|
1572 | - ) { |
|
1573 | - add_filter( |
|
1574 | - 'FHEE__EEH_Template__powered_by_event_espresso__url', |
|
1575 | - function ($url) { |
|
1576 | - return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
|
1577 | - } |
|
1578 | - ); |
|
1579 | - echo apply_filters( |
|
1580 | - 'FHEE__EE_Front_Controller__display_registration_footer', |
|
1581 | - \EEH_Template::powered_by_event_espresso( |
|
1582 | - '', |
|
1583 | - 'espresso-registration-footer-dv', |
|
1584 | - array('utm_content' => 'registration_checkout') |
|
1585 | - ) |
|
1586 | - ); |
|
1587 | - } |
|
1588 | - return ''; |
|
1589 | - } |
|
1590 | - |
|
1591 | - |
|
1592 | - |
|
1593 | - /** |
|
1594 | - * unlock_transaction |
|
1595 | - * |
|
1596 | - * @access public |
|
1597 | - * @return void |
|
1598 | - * @throws \EE_Error |
|
1599 | - */ |
|
1600 | - public function unlock_transaction() |
|
1601 | - { |
|
1602 | - if ($this->checkout->transaction instanceof EE_Transaction) { |
|
1603 | - $this->checkout->transaction->unlock(); |
|
1604 | - } |
|
1605 | - } |
|
1606 | - |
|
1607 | - |
|
1608 | - |
|
1609 | - /** |
|
1610 | - * _setup_redirect |
|
1611 | - * |
|
1612 | - * @access private |
|
1613 | - * @return void |
|
1614 | - */ |
|
1615 | - private function _setup_redirect() |
|
1616 | - { |
|
1617 | - if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
1618 | - $this->checkout->redirect = true; |
|
1619 | - if (empty($this->checkout->redirect_url)) { |
|
1620 | - $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url(); |
|
1621 | - } |
|
1622 | - $this->checkout->redirect_url = apply_filters( |
|
1623 | - 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', |
|
1624 | - $this->checkout->redirect_url, |
|
1625 | - $this->checkout |
|
1626 | - ); |
|
1627 | - } |
|
1628 | - } |
|
1629 | - |
|
1630 | - |
|
1631 | - |
|
1632 | - /** |
|
1633 | - * handle ajax message responses and redirects |
|
1634 | - * |
|
1635 | - * @access public |
|
1636 | - * @return void |
|
1637 | - * @throws \EE_Error |
|
1638 | - */ |
|
1639 | - public function go_to_next_step() |
|
1640 | - { |
|
1641 | - if (EE_Registry::instance()->REQ->ajax) { |
|
1642 | - // capture contents of output buffer we started earlier in the request, and insert into JSON response |
|
1643 | - $this->checkout->json_response->set_unexpected_errors(ob_get_clean()); |
|
1644 | - } |
|
1645 | - $this->unlock_transaction(); |
|
1646 | - // just return for these conditions |
|
1647 | - if ( |
|
1648 | - $this->checkout->admin_request |
|
1649 | - || $this->checkout->action === 'redirect_form' |
|
1650 | - || $this->checkout->action === 'update_checkout' |
|
1651 | - ) { |
|
1652 | - return; |
|
1653 | - } |
|
1654 | - // AJAX response |
|
1655 | - $this->_handle_json_response(); |
|
1656 | - // redirect to next step or the Thank You page |
|
1657 | - $this->_handle_html_redirects(); |
|
1658 | - // hmmm... must be something wrong, so let's just display the form again ! |
|
1659 | - $this->_display_spco_reg_form(); |
|
1660 | - } |
|
1661 | - |
|
1662 | - |
|
1663 | - |
|
1664 | - /** |
|
1665 | - * _handle_json_response |
|
1666 | - * |
|
1667 | - * @access protected |
|
1668 | - * @return void |
|
1669 | - */ |
|
1670 | - protected function _handle_json_response() |
|
1671 | - { |
|
1672 | - // if this is an ajax request |
|
1673 | - if (EE_Registry::instance()->REQ->ajax) { |
|
1674 | - // DEBUG LOG |
|
1675 | - //$this->checkout->log( |
|
1676 | - // __CLASS__, __FUNCTION__, __LINE__, |
|
1677 | - // array( |
|
1678 | - // 'json_response_redirect_url' => $this->checkout->json_response->redirect_url(), |
|
1679 | - // 'redirect' => $this->checkout->redirect, |
|
1680 | - // 'continue_reg' => $this->checkout->continue_reg, |
|
1681 | - // ) |
|
1682 | - //); |
|
1683 | - $this->checkout->json_response->set_registration_time_limit( |
|
1684 | - $this->checkout->get_registration_time_limit() |
|
1685 | - ); |
|
1686 | - $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing); |
|
1687 | - // just send the ajax ( |
|
1688 | - $json_response = apply_filters( |
|
1689 | - 'FHEE__EE_Single_Page_Checkout__JSON_response', |
|
1690 | - $this->checkout->json_response |
|
1691 | - ); |
|
1692 | - echo $json_response; |
|
1693 | - exit(); |
|
1694 | - } |
|
1695 | - } |
|
1696 | - |
|
1697 | - |
|
1698 | - |
|
1699 | - /** |
|
1700 | - * _handle_redirects |
|
1701 | - * |
|
1702 | - * @access protected |
|
1703 | - * @return void |
|
1704 | - */ |
|
1705 | - protected function _handle_html_redirects() |
|
1706 | - { |
|
1707 | - // going somewhere ? |
|
1708 | - if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) { |
|
1709 | - // store notices in a transient |
|
1710 | - EE_Error::get_notices(false, true, true); |
|
1711 | - // DEBUG LOG |
|
1712 | - //$this->checkout->log( |
|
1713 | - // __CLASS__, __FUNCTION__, __LINE__, |
|
1714 | - // array( |
|
1715 | - // 'headers_sent' => headers_sent(), |
|
1716 | - // 'redirect_url' => $this->checkout->redirect_url, |
|
1717 | - // 'headers_list' => headers_list(), |
|
1718 | - // ) |
|
1719 | - //); |
|
1720 | - wp_safe_redirect($this->checkout->redirect_url); |
|
1721 | - exit(); |
|
1722 | - } |
|
1723 | - } |
|
1724 | - |
|
1725 | - |
|
1726 | - |
|
1727 | - /** |
|
1728 | - * set_checkout_anchor |
|
1729 | - * |
|
1730 | - * @access public |
|
1731 | - * @return void |
|
1732 | - */ |
|
1733 | - public function set_checkout_anchor() |
|
1734 | - { |
|
1735 | - echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>'; |
|
1736 | - } |
|
20 | + /** |
|
21 | + * $_initialized - has the SPCO controller already been initialized ? |
|
22 | + * |
|
23 | + * @access private |
|
24 | + * @var bool $_initialized |
|
25 | + */ |
|
26 | + private static $_initialized = false; |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * $_checkout_verified - is the EE_Checkout verified as correct for this request ? |
|
31 | + * |
|
32 | + * @access private |
|
33 | + * @var bool $_valid_checkout |
|
34 | + */ |
|
35 | + private static $_checkout_verified = true; |
|
36 | + |
|
37 | + /** |
|
38 | + * $_reg_steps_array - holds initial array of reg steps |
|
39 | + * |
|
40 | + * @access private |
|
41 | + * @var array $_reg_steps_array |
|
42 | + */ |
|
43 | + private static $_reg_steps_array = array(); |
|
44 | + |
|
45 | + /** |
|
46 | + * $checkout - EE_Checkout object for handling the properties of the current checkout process |
|
47 | + * |
|
48 | + * @access public |
|
49 | + * @var EE_Checkout $checkout |
|
50 | + */ |
|
51 | + public $checkout; |
|
52 | + |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * @return EED_Single_Page_Checkout |
|
57 | + */ |
|
58 | + public static function instance() |
|
59 | + { |
|
60 | + add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true'); |
|
61 | + return parent::get_instance(__CLASS__); |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * @return EE_CART |
|
68 | + */ |
|
69 | + public function cart() |
|
70 | + { |
|
71 | + return $this->checkout->cart; |
|
72 | + } |
|
73 | + |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * @return EE_Transaction |
|
78 | + */ |
|
79 | + public function transaction() |
|
80 | + { |
|
81 | + return $this->checkout->transaction; |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + |
|
86 | + /** |
|
87 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
88 | + * |
|
89 | + * @access public |
|
90 | + * @return void |
|
91 | + * @throws \EE_Error |
|
92 | + */ |
|
93 | + public static function set_hooks() |
|
94 | + { |
|
95 | + EED_Single_Page_Checkout::set_definitions(); |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + |
|
100 | + /** |
|
101 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
102 | + * |
|
103 | + * @access public |
|
104 | + * @return void |
|
105 | + * @throws \EE_Error |
|
106 | + */ |
|
107 | + public static function set_hooks_admin() |
|
108 | + { |
|
109 | + EED_Single_Page_Checkout::set_definitions(); |
|
110 | + if ( ! (defined('DOING_AJAX') && DOING_AJAX)) { |
|
111 | + return; |
|
112 | + } |
|
113 | + // going to start an output buffer in case anything gets accidentally output that might disrupt our JSON response |
|
114 | + ob_start(); |
|
115 | + EED_Single_Page_Checkout::load_request_handler(); |
|
116 | + EED_Single_Page_Checkout::load_reg_steps(); |
|
117 | + // set ajax hooks |
|
118 | + add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
119 | + add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
120 | + add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
121 | + add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
122 | + add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
123 | + add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * process ajax request |
|
130 | + * |
|
131 | + * @param string $ajax_action |
|
132 | + * @throws \EE_Error |
|
133 | + */ |
|
134 | + public static function process_ajax_request($ajax_action) |
|
135 | + { |
|
136 | + EE_Registry::instance()->REQ->set('action', $ajax_action); |
|
137 | + EED_Single_Page_Checkout::instance()->_initialize(); |
|
138 | + } |
|
139 | + |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * ajax display registration step |
|
144 | + * |
|
145 | + * @throws \EE_Error |
|
146 | + */ |
|
147 | + public static function display_reg_step() |
|
148 | + { |
|
149 | + EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step'); |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + |
|
154 | + /** |
|
155 | + * ajax process registration step |
|
156 | + * |
|
157 | + * @throws \EE_Error |
|
158 | + */ |
|
159 | + public static function process_reg_step() |
|
160 | + { |
|
161 | + EED_Single_Page_Checkout::process_ajax_request('process_reg_step'); |
|
162 | + } |
|
163 | + |
|
164 | + |
|
165 | + |
|
166 | + /** |
|
167 | + * ajax process registration step |
|
168 | + * |
|
169 | + * @throws \EE_Error |
|
170 | + */ |
|
171 | + public static function update_reg_step() |
|
172 | + { |
|
173 | + EED_Single_Page_Checkout::process_ajax_request('update_reg_step'); |
|
174 | + } |
|
175 | + |
|
176 | + |
|
177 | + |
|
178 | + /** |
|
179 | + * update_checkout |
|
180 | + * |
|
181 | + * @access public |
|
182 | + * @return void |
|
183 | + * @throws \EE_Error |
|
184 | + */ |
|
185 | + public static function update_checkout() |
|
186 | + { |
|
187 | + EED_Single_Page_Checkout::process_ajax_request('update_checkout'); |
|
188 | + } |
|
189 | + |
|
190 | + |
|
191 | + |
|
192 | + /** |
|
193 | + * load_request_handler |
|
194 | + * |
|
195 | + * @access public |
|
196 | + * @return void |
|
197 | + */ |
|
198 | + public static function load_request_handler() |
|
199 | + { |
|
200 | + // load core Request_Handler class |
|
201 | + if ( ! isset(EE_Registry::instance()->REQ)) { |
|
202 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
203 | + } |
|
204 | + } |
|
205 | + |
|
206 | + |
|
207 | + |
|
208 | + /** |
|
209 | + * set_definitions |
|
210 | + * |
|
211 | + * @access public |
|
212 | + * @return void |
|
213 | + * @throws \EE_Error |
|
214 | + */ |
|
215 | + public static function set_definitions() |
|
216 | + { |
|
217 | + if(defined('SPCO_BASE_PATH')) { |
|
218 | + return; |
|
219 | + } |
|
220 | + define('SPCO_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS); |
|
221 | + define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS); |
|
222 | + define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS); |
|
223 | + define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS); |
|
224 | + define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS); |
|
225 | + define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS); |
|
226 | + define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS); |
|
227 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true); |
|
228 | + EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
|
229 | + __('%1$sWe\'re sorry, but you\'re registration time has expired.%2$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 except our apologies for any inconvenience this may have caused.%8$s', |
|
230 | + 'event_espresso'), |
|
231 | + '<h4 class="important-notice">', |
|
232 | + '</h4>', |
|
233 | + '<br />', |
|
234 | + '<p>', |
|
235 | + '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
236 | + '">', |
|
237 | + '</a>', |
|
238 | + '</p>' |
|
239 | + ); |
|
240 | + } |
|
241 | + |
|
242 | + |
|
243 | + |
|
244 | + /** |
|
245 | + * load_reg_steps |
|
246 | + * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array |
|
247 | + * |
|
248 | + * @access private |
|
249 | + * @throws \EE_Error |
|
250 | + */ |
|
251 | + public static function load_reg_steps() |
|
252 | + { |
|
253 | + static $reg_steps_loaded = false; |
|
254 | + if ($reg_steps_loaded) { |
|
255 | + return; |
|
256 | + } |
|
257 | + // filter list of reg_steps |
|
258 | + $reg_steps_to_load = (array)apply_filters( |
|
259 | + 'AHEE__SPCO__load_reg_steps__reg_steps_to_load', |
|
260 | + EED_Single_Page_Checkout::get_reg_steps() |
|
261 | + ); |
|
262 | + // sort by key (order) |
|
263 | + ksort($reg_steps_to_load); |
|
264 | + // loop through folders |
|
265 | + foreach ($reg_steps_to_load as $order => $reg_step) { |
|
266 | + // we need a |
|
267 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
268 | + // copy over to the reg_steps_array |
|
269 | + EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step; |
|
270 | + // register custom key route for each reg step |
|
271 | + // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
|
272 | + EE_Config::register_route($reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step'); |
|
273 | + // add AJAX or other hooks |
|
274 | + if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
|
275 | + // setup autoloaders if necessary |
|
276 | + if ( ! class_exists($reg_step['class_name'])) { |
|
277 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($reg_step['file_path'], true); |
|
278 | + } |
|
279 | + if (is_callable($reg_step['class_name'], 'set_hooks')) { |
|
280 | + call_user_func(array($reg_step['class_name'], 'set_hooks')); |
|
281 | + } |
|
282 | + } |
|
283 | + } |
|
284 | + } |
|
285 | + $reg_steps_loaded = true; |
|
286 | + } |
|
287 | + |
|
288 | + |
|
289 | + |
|
290 | + /** |
|
291 | + * get_reg_steps |
|
292 | + * |
|
293 | + * @access public |
|
294 | + * @return array |
|
295 | + */ |
|
296 | + public static function get_reg_steps() |
|
297 | + { |
|
298 | + $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps; |
|
299 | + if (empty($reg_steps)) { |
|
300 | + $reg_steps = array( |
|
301 | + 10 => array( |
|
302 | + 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
303 | + 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
|
304 | + 'slug' => 'attendee_information', |
|
305 | + 'has_hooks' => false, |
|
306 | + ), |
|
307 | + 20 => array( |
|
308 | + 'file_path' => SPCO_REG_STEPS_PATH . 'registration_confirmation', |
|
309 | + 'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation', |
|
310 | + 'slug' => 'registration_confirmation', |
|
311 | + 'has_hooks' => false, |
|
312 | + ), |
|
313 | + 30 => array( |
|
314 | + 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
315 | + 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
|
316 | + 'slug' => 'payment_options', |
|
317 | + 'has_hooks' => true, |
|
318 | + ), |
|
319 | + 999 => array( |
|
320 | + 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
321 | + 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
|
322 | + 'slug' => 'finalize_registration', |
|
323 | + 'has_hooks' => false, |
|
324 | + ), |
|
325 | + ); |
|
326 | + } |
|
327 | + return $reg_steps; |
|
328 | + } |
|
329 | + |
|
330 | + |
|
331 | + |
|
332 | + /** |
|
333 | + * registration_checkout_for_admin |
|
334 | + * |
|
335 | + * @access public |
|
336 | + * @return string |
|
337 | + * @throws \EE_Error |
|
338 | + */ |
|
339 | + public static function registration_checkout_for_admin() |
|
340 | + { |
|
341 | + EED_Single_Page_Checkout::load_request_handler(); |
|
342 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
343 | + EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step'); |
|
344 | + EE_Registry::instance()->REQ->set('process_form_submission', false); |
|
345 | + EED_Single_Page_Checkout::instance()->_initialize(); |
|
346 | + EED_Single_Page_Checkout::instance()->_display_spco_reg_form(); |
|
347 | + return EE_Registry::instance()->REQ->get_output(); |
|
348 | + } |
|
349 | + |
|
350 | + |
|
351 | + |
|
352 | + /** |
|
353 | + * process_registration_from_admin |
|
354 | + * |
|
355 | + * @access public |
|
356 | + * @return \EE_Transaction |
|
357 | + * @throws \EE_Error |
|
358 | + */ |
|
359 | + public static function process_registration_from_admin() |
|
360 | + { |
|
361 | + EED_Single_Page_Checkout::load_request_handler(); |
|
362 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
363 | + EE_Registry::instance()->REQ->set('action', 'process_reg_step'); |
|
364 | + EE_Registry::instance()->REQ->set('process_form_submission', true); |
|
365 | + EED_Single_Page_Checkout::instance()->_initialize(); |
|
366 | + if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) { |
|
367 | + $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps); |
|
368 | + if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
369 | + EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step); |
|
370 | + if ($final_reg_step->process_reg_step()) { |
|
371 | + $final_reg_step->set_completed(); |
|
372 | + EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array(); |
|
373 | + return EED_Single_Page_Checkout::instance()->checkout->transaction; |
|
374 | + } |
|
375 | + } |
|
376 | + } |
|
377 | + return null; |
|
378 | + } |
|
379 | + |
|
380 | + |
|
381 | + |
|
382 | + /** |
|
383 | + * run |
|
384 | + * |
|
385 | + * @access public |
|
386 | + * @param WP_Query $WP_Query |
|
387 | + * @return void |
|
388 | + * @throws \EE_Error |
|
389 | + */ |
|
390 | + public function run($WP_Query) |
|
391 | + { |
|
392 | + if ( |
|
393 | + $WP_Query instanceof WP_Query |
|
394 | + && $WP_Query->is_main_query() |
|
395 | + && apply_filters('FHEE__EED_Single_Page_Checkout__run', true) |
|
396 | + && $this->_is_reg_checkout() |
|
397 | + ) { |
|
398 | + $this->_initialize(); |
|
399 | + } |
|
400 | + } |
|
401 | + |
|
402 | + |
|
403 | + |
|
404 | + /** |
|
405 | + * determines whether current url matches reg page url |
|
406 | + * |
|
407 | + * @return bool |
|
408 | + */ |
|
409 | + protected function _is_reg_checkout() |
|
410 | + { |
|
411 | + // get current permalink for reg page without any extra query args |
|
412 | + $reg_page_url = \get_permalink(EE_Config::instance()->core->reg_page_id); |
|
413 | + // get request URI for current request, but without the scheme or host |
|
414 | + $current_request_uri = \EEH_URL::filter_input_server_url('REQUEST_URI'); |
|
415 | + $current_request_uri = html_entity_decode($current_request_uri); |
|
416 | + // get array of query args from the current request URI |
|
417 | + $query_args = \EEH_URL::get_query_string($current_request_uri); |
|
418 | + // grab page id if it is set |
|
419 | + $page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0; |
|
420 | + // and remove the page id from the query args (we will re-add it later) |
|
421 | + unset($query_args['page_id']); |
|
422 | + // now strip all query args from current request URI |
|
423 | + $current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri); |
|
424 | + // and re-add the page id if it was set |
|
425 | + if ($page_id) { |
|
426 | + $current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri); |
|
427 | + } |
|
428 | + // remove slashes and ? |
|
429 | + $current_request_uri = trim($current_request_uri, '?/'); |
|
430 | + // is current request URI part of the known full reg page URL ? |
|
431 | + return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false; |
|
432 | + } |
|
433 | + |
|
434 | + |
|
435 | + |
|
436 | + /** |
|
437 | + * @param WP_Query $wp_query |
|
438 | + * @return void |
|
439 | + * @throws \EE_Error |
|
440 | + */ |
|
441 | + public static function init($wp_query) |
|
442 | + { |
|
443 | + EED_Single_Page_Checkout::instance()->run($wp_query); |
|
444 | + } |
|
445 | + |
|
446 | + |
|
447 | + |
|
448 | + /** |
|
449 | + * _initialize - initial module setup |
|
450 | + * |
|
451 | + * @access private |
|
452 | + * @throws EE_Error |
|
453 | + * @return void |
|
454 | + */ |
|
455 | + private function _initialize() |
|
456 | + { |
|
457 | + // ensure SPCO doesn't run twice |
|
458 | + if (EED_Single_Page_Checkout::$_initialized) { |
|
459 | + return; |
|
460 | + } |
|
461 | + try { |
|
462 | + EED_Single_Page_Checkout::load_reg_steps(); |
|
463 | + $this->_verify_session(); |
|
464 | + // setup the EE_Checkout object |
|
465 | + $this->checkout = $this->_initialize_checkout(); |
|
466 | + // filter checkout |
|
467 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); |
|
468 | + // get the $_GET |
|
469 | + $this->_get_request_vars(); |
|
470 | + if ($this->_block_bots()) { |
|
471 | + return; |
|
472 | + } |
|
473 | + // filter continue_reg |
|
474 | + $this->checkout->continue_reg = apply_filters('FHEE__EED_Single_Page_Checkout__init___continue_reg', true, $this->checkout); |
|
475 | + // load the reg steps array |
|
476 | + if ( ! $this->_load_and_instantiate_reg_steps()) { |
|
477 | + EED_Single_Page_Checkout::$_initialized = true; |
|
478 | + return; |
|
479 | + } |
|
480 | + // set the current step |
|
481 | + $this->checkout->set_current_step($this->checkout->step); |
|
482 | + // and the next step |
|
483 | + $this->checkout->set_next_step(); |
|
484 | + // verify that everything has been setup correctly |
|
485 | + if ( ! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) { |
|
486 | + EED_Single_Page_Checkout::$_initialized = true; |
|
487 | + return; |
|
488 | + } |
|
489 | + // lock the transaction |
|
490 | + $this->checkout->transaction->lock(); |
|
491 | + // make sure all of our cached objects are added to their respective model entity mappers |
|
492 | + $this->checkout->refresh_all_entities(); |
|
493 | + // set amount owing |
|
494 | + $this->checkout->amount_owing = $this->checkout->transaction->remaining(); |
|
495 | + // initialize each reg step, which gives them the chance to potentially alter the process |
|
496 | + $this->_initialize_reg_steps(); |
|
497 | + // DEBUG LOG |
|
498 | + //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
|
499 | + // get reg form |
|
500 | + if( ! $this->_check_form_submission()) { |
|
501 | + EED_Single_Page_Checkout::$_initialized = true; |
|
502 | + return; |
|
503 | + } |
|
504 | + // checkout the action!!! |
|
505 | + $this->_process_form_action(); |
|
506 | + // add some style and make it dance |
|
507 | + $this->add_styles_and_scripts(); |
|
508 | + // kk... SPCO has successfully run |
|
509 | + EED_Single_Page_Checkout::$_initialized = true; |
|
510 | + // set no cache headers and constants |
|
511 | + EE_System::do_not_cache(); |
|
512 | + // add anchor |
|
513 | + add_action('loop_start', array($this, 'set_checkout_anchor'), 1); |
|
514 | + // remove transaction lock |
|
515 | + add_action('shutdown', array($this, 'unlock_transaction'), 1); |
|
516 | + } catch (Exception $e) { |
|
517 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
518 | + } |
|
519 | + } |
|
520 | + |
|
521 | + |
|
522 | + |
|
523 | + /** |
|
524 | + * _verify_session |
|
525 | + * checks that the session is valid and not expired |
|
526 | + * |
|
527 | + * @access private |
|
528 | + * @throws EE_Error |
|
529 | + */ |
|
530 | + private function _verify_session() |
|
531 | + { |
|
532 | + if ( ! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
533 | + throw new EE_Error(__('The EE_Session class could not be loaded.', 'event_espresso')); |
|
534 | + } |
|
535 | + // is session still valid ? |
|
536 | + if (EE_Registry::instance()->SSN->expired() && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === '') { |
|
537 | + $this->checkout = new EE_Checkout(); |
|
538 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
539 | + // EE_Registry::instance()->SSN->reset_cart(); |
|
540 | + // EE_Registry::instance()->SSN->reset_checkout(); |
|
541 | + // EE_Registry::instance()->SSN->reset_transaction(); |
|
542 | + EE_Error::add_attention(EE_Registry::$i18n_js_strings['registration_expiration_notice'], __FILE__, |
|
543 | + __FUNCTION__, __LINE__); |
|
544 | + // EE_Registry::instance()->SSN->reset_expired(); |
|
545 | + } |
|
546 | + } |
|
547 | + |
|
548 | + |
|
549 | + |
|
550 | + /** |
|
551 | + * _initialize_checkout |
|
552 | + * loads and instantiates EE_Checkout |
|
553 | + * |
|
554 | + * @access private |
|
555 | + * @throws EE_Error |
|
556 | + * @return EE_Checkout |
|
557 | + */ |
|
558 | + private function _initialize_checkout() |
|
559 | + { |
|
560 | + // look in session for existing checkout |
|
561 | + /** @type EE_Checkout $checkout */ |
|
562 | + $checkout = EE_Registry::instance()->SSN->checkout(); |
|
563 | + // verify |
|
564 | + if ( ! $checkout instanceof EE_Checkout) { |
|
565 | + // instantiate EE_Checkout object for handling the properties of the current checkout process |
|
566 | + $checkout = EE_Registry::instance()->load_file(SPCO_INC_PATH, 'EE_Checkout', 'class', array(), false); |
|
567 | + } else { |
|
568 | + if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) { |
|
569 | + $this->unlock_transaction(); |
|
570 | + wp_safe_redirect($checkout->redirect_url); |
|
571 | + exit(); |
|
572 | + } |
|
573 | + } |
|
574 | + $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
|
575 | + // verify again |
|
576 | + if ( ! $checkout instanceof EE_Checkout) { |
|
577 | + throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
|
578 | + } |
|
579 | + // reset anything that needs a clean slate for each request |
|
580 | + $checkout->reset_for_current_request(); |
|
581 | + return $checkout; |
|
582 | + } |
|
583 | + |
|
584 | + |
|
585 | + |
|
586 | + /** |
|
587 | + * _get_request_vars |
|
588 | + * |
|
589 | + * @access private |
|
590 | + * @return void |
|
591 | + * @throws \EE_Error |
|
592 | + */ |
|
593 | + private function _get_request_vars() |
|
594 | + { |
|
595 | + // load classes |
|
596 | + EED_Single_Page_Checkout::load_request_handler(); |
|
597 | + //make sure this request is marked as belonging to EE |
|
598 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
599 | + // which step is being requested ? |
|
600 | + $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step()); |
|
601 | + // which step is being edited ? |
|
602 | + $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', ''); |
|
603 | + // and what we're doing on the current step |
|
604 | + $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step'); |
|
605 | + // timestamp |
|
606 | + $this->checkout->uts = EE_Registry::instance()->REQ->get('uts', 0); |
|
607 | + // returning to edit ? |
|
608 | + $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', ''); |
|
609 | + // or some other kind of revisit ? |
|
610 | + $this->checkout->revisit = filter_var( |
|
611 | + EE_Registry::instance()->REQ->get('revisit', false), |
|
612 | + FILTER_VALIDATE_BOOLEAN |
|
613 | + ); |
|
614 | + // and whether or not to generate a reg form for this request |
|
615 | + $this->checkout->generate_reg_form = filter_var( |
|
616 | + EE_Registry::instance()->REQ->get('generate_reg_form', true), |
|
617 | + FILTER_VALIDATE_BOOLEAN |
|
618 | + ); |
|
619 | + // and whether or not to process a reg form submission for this request |
|
620 | + $this->checkout->process_form_submission = filter_var( |
|
621 | + EE_Registry::instance()->REQ->get( |
|
622 | + 'process_form_submission', |
|
623 | + $this->checkout->action === 'process_reg_step' |
|
624 | + ), |
|
625 | + FILTER_VALIDATE_BOOLEAN |
|
626 | + ); |
|
627 | + $this->checkout->process_form_submission = filter_var( |
|
628 | + $this->checkout->action !== 'display_spco_reg_step' |
|
629 | + ? $this->checkout->process_form_submission |
|
630 | + : false, |
|
631 | + FILTER_VALIDATE_BOOLEAN |
|
632 | + ); |
|
633 | + // $this->_display_request_vars(); |
|
634 | + } |
|
635 | + |
|
636 | + |
|
637 | + |
|
638 | + /** |
|
639 | + * _display_request_vars |
|
640 | + * |
|
641 | + * @access protected |
|
642 | + * @return void |
|
643 | + */ |
|
644 | + protected function _display_request_vars() |
|
645 | + { |
|
646 | + if ( ! WP_DEBUG) { |
|
647 | + return; |
|
648 | + } |
|
649 | + EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__); |
|
650 | + EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__); |
|
651 | + EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__); |
|
652 | + EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__); |
|
653 | + EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__); |
|
654 | + EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__); |
|
655 | + EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__); |
|
656 | + EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__); |
|
657 | + } |
|
658 | + |
|
659 | + |
|
660 | + |
|
661 | + /** |
|
662 | + * _block_bots |
|
663 | + * checks that the incoming request has either of the following set: |
|
664 | + * a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector |
|
665 | + * a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN |
|
666 | + * so if you're not coming from the Ticket Selector nor returning for a valid IP... |
|
667 | + * then where you coming from man? |
|
668 | + * |
|
669 | + * @return boolean |
|
670 | + */ |
|
671 | + private function _block_bots() |
|
672 | + { |
|
673 | + $invalid_checkout_access = \EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
674 | + if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) { |
|
675 | + return true; |
|
676 | + } |
|
677 | + return false; |
|
678 | + } |
|
679 | + |
|
680 | + |
|
681 | + |
|
682 | + /** |
|
683 | + * _get_first_step |
|
684 | + * gets slug for first step in $_reg_steps_array |
|
685 | + * |
|
686 | + * @access private |
|
687 | + * @throws EE_Error |
|
688 | + * @return string |
|
689 | + */ |
|
690 | + private function _get_first_step() |
|
691 | + { |
|
692 | + $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array); |
|
693 | + return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information'; |
|
694 | + } |
|
695 | + |
|
696 | + |
|
697 | + |
|
698 | + /** |
|
699 | + * _load_and_instantiate_reg_steps |
|
700 | + * instantiates each reg step based on the loaded reg_steps array |
|
701 | + * |
|
702 | + * @access private |
|
703 | + * @throws EE_Error |
|
704 | + * @return bool |
|
705 | + */ |
|
706 | + private function _load_and_instantiate_reg_steps() |
|
707 | + { |
|
708 | + do_action('AHEE__Single_Page_Checkout___load_and_instantiate_reg_steps__start', $this->checkout); |
|
709 | + // have reg_steps already been instantiated ? |
|
710 | + if ( |
|
711 | + empty($this->checkout->reg_steps) |
|
712 | + || apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout) |
|
713 | + ) { |
|
714 | + // if not, then loop through raw reg steps array |
|
715 | + foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
|
716 | + if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
717 | + return false; |
|
718 | + } |
|
719 | + } |
|
720 | + EE_Registry::instance()->CFG->registration->skip_reg_confirmation = true; |
|
721 | + EE_Registry::instance()->CFG->registration->reg_confirmation_last = true; |
|
722 | + // skip the registration_confirmation page ? |
|
723 | + if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) { |
|
724 | + // just remove it from the reg steps array |
|
725 | + $this->checkout->remove_reg_step('registration_confirmation', false); |
|
726 | + } else if ( |
|
727 | + isset($this->checkout->reg_steps['registration_confirmation']) |
|
728 | + && EE_Registry::instance()->CFG->registration->reg_confirmation_last |
|
729 | + ) { |
|
730 | + // set the order to something big like 100 |
|
731 | + $this->checkout->set_reg_step_order('registration_confirmation', 100); |
|
732 | + } |
|
733 | + // filter the array for good luck |
|
734 | + $this->checkout->reg_steps = apply_filters( |
|
735 | + 'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps', |
|
736 | + $this->checkout->reg_steps |
|
737 | + ); |
|
738 | + // finally re-sort based on the reg step class order properties |
|
739 | + $this->checkout->sort_reg_steps(); |
|
740 | + } else { |
|
741 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
742 | + // set all current step stati to FALSE |
|
743 | + $reg_step->set_is_current_step(false); |
|
744 | + } |
|
745 | + } |
|
746 | + if (empty($this->checkout->reg_steps)) { |
|
747 | + EE_Error::add_error(__('No Reg Steps were loaded..', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
748 | + return false; |
|
749 | + } |
|
750 | + // make reg step details available to JS |
|
751 | + $this->checkout->set_reg_step_JSON_info(); |
|
752 | + return true; |
|
753 | + } |
|
754 | + |
|
755 | + |
|
756 | + |
|
757 | + /** |
|
758 | + * _load_and_instantiate_reg_step |
|
759 | + * |
|
760 | + * @access private |
|
761 | + * @param array $reg_step |
|
762 | + * @param int $order |
|
763 | + * @return bool |
|
764 | + */ |
|
765 | + private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) |
|
766 | + { |
|
767 | + // we need a file_path, class_name, and slug to add a reg step |
|
768 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
769 | + // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
|
770 | + if ( |
|
771 | + $this->checkout->reg_url_link |
|
772 | + && $this->checkout->step !== $reg_step['slug'] |
|
773 | + && $reg_step['slug'] !== 'finalize_registration' |
|
774 | + // normally at this point we would NOT load the reg step, but this filter can change that |
|
775 | + && apply_filters( |
|
776 | + 'FHEE__Single_Page_Checkout___load_and_instantiate_reg_step__bypass_reg_step', |
|
777 | + true, |
|
778 | + $reg_step, |
|
779 | + $this->checkout |
|
780 | + ) |
|
781 | + ) { |
|
782 | + return true; |
|
783 | + } |
|
784 | + // instantiate step class using file path and class name |
|
785 | + $reg_step_obj = EE_Registry::instance()->load_file( |
|
786 | + $reg_step['file_path'], |
|
787 | + $reg_step['class_name'], |
|
788 | + 'class', |
|
789 | + $this->checkout, |
|
790 | + false |
|
791 | + ); |
|
792 | + // did we gets the goods ? |
|
793 | + if ($reg_step_obj instanceof EE_SPCO_Reg_Step) { |
|
794 | + // set reg step order based on config |
|
795 | + $reg_step_obj->set_order($order); |
|
796 | + // add instantiated reg step object to the master reg steps array |
|
797 | + $this->checkout->add_reg_step($reg_step_obj); |
|
798 | + } else { |
|
799 | + EE_Error::add_error( |
|
800 | + __('The current step could not be set.', 'event_espresso'), |
|
801 | + __FILE__, __FUNCTION__, __LINE__ |
|
802 | + ); |
|
803 | + return false; |
|
804 | + } |
|
805 | + } else { |
|
806 | + if (WP_DEBUG) { |
|
807 | + EE_Error::add_error( |
|
808 | + sprintf( |
|
809 | + __('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', 'event_espresso'), |
|
810 | + isset($reg_step['file_path']) ? $reg_step['file_path'] : '', |
|
811 | + isset($reg_step['class_name']) ? $reg_step['class_name'] : '', |
|
812 | + isset($reg_step['slug']) ? $reg_step['slug'] : '', |
|
813 | + '<ul>', |
|
814 | + '<li>', |
|
815 | + '</li>', |
|
816 | + '</ul>' |
|
817 | + ), |
|
818 | + __FILE__, __FUNCTION__, __LINE__ |
|
819 | + ); |
|
820 | + } |
|
821 | + return false; |
|
822 | + } |
|
823 | + return true; |
|
824 | + } |
|
825 | + |
|
826 | + |
|
827 | + |
|
828 | + /** |
|
829 | + * _verify_transaction_and_get_registrations |
|
830 | + * |
|
831 | + * @access private |
|
832 | + * @return bool |
|
833 | + */ |
|
834 | + private function _verify_transaction_and_get_registrations() |
|
835 | + { |
|
836 | + // was there already a valid transaction in the checkout from the session ? |
|
837 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
838 | + // get transaction from db or session |
|
839 | + $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
|
840 | + ? $this->_get_transaction_and_cart_for_previous_visit() |
|
841 | + : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
|
842 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
843 | + EE_Error::add_error( |
|
844 | + __('Your Registration and Transaction information could not be retrieved from the db.', |
|
845 | + 'event_espresso'), |
|
846 | + __FILE__, __FUNCTION__, __LINE__ |
|
847 | + ); |
|
848 | + $this->checkout->transaction = EE_Transaction::new_instance(); |
|
849 | + // add some style and make it dance |
|
850 | + $this->add_styles_and_scripts(); |
|
851 | + EED_Single_Page_Checkout::$_initialized = true; |
|
852 | + return false; |
|
853 | + } |
|
854 | + // and the registrations for the transaction |
|
855 | + $this->_get_registrations($this->checkout->transaction); |
|
856 | + } |
|
857 | + return true; |
|
858 | + } |
|
859 | + |
|
860 | + |
|
861 | + |
|
862 | + /** |
|
863 | + * _get_transaction_and_cart_for_previous_visit |
|
864 | + * |
|
865 | + * @access private |
|
866 | + * @return mixed EE_Transaction|NULL |
|
867 | + */ |
|
868 | + private function _get_transaction_and_cart_for_previous_visit() |
|
869 | + { |
|
870 | + /** @var $TXN_model EEM_Transaction */ |
|
871 | + $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
872 | + // because the reg_url_link is present in the request, this is a return visit to SPCO, so we'll get the transaction data from the db |
|
873 | + $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link); |
|
874 | + // verify transaction |
|
875 | + if ($transaction instanceof EE_Transaction) { |
|
876 | + // and get the cart that was used for that transaction |
|
877 | + $this->checkout->cart = $this->_get_cart_for_transaction($transaction); |
|
878 | + return $transaction; |
|
879 | + } else { |
|
880 | + EE_Error::add_error(__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
881 | + return null; |
|
882 | + } |
|
883 | + } |
|
884 | + |
|
885 | + |
|
886 | + |
|
887 | + /** |
|
888 | + * _get_cart_for_transaction |
|
889 | + * |
|
890 | + * @access private |
|
891 | + * @param EE_Transaction $transaction |
|
892 | + * @return EE_Cart |
|
893 | + */ |
|
894 | + private function _get_cart_for_transaction($transaction) |
|
895 | + { |
|
896 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
897 | + } |
|
898 | + |
|
899 | + |
|
900 | + |
|
901 | + /** |
|
902 | + * get_cart_for_transaction |
|
903 | + * |
|
904 | + * @access public |
|
905 | + * @param EE_Transaction $transaction |
|
906 | + * @return EE_Cart |
|
907 | + */ |
|
908 | + public function get_cart_for_transaction(EE_Transaction $transaction) |
|
909 | + { |
|
910 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
911 | + } |
|
912 | + |
|
913 | + |
|
914 | + |
|
915 | + /** |
|
916 | + * _get_transaction_and_cart_for_current_session |
|
917 | + * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
918 | + * |
|
919 | + * @access private |
|
920 | + * @return EE_Transaction |
|
921 | + * @throws \EE_Error |
|
922 | + */ |
|
923 | + private function _get_cart_for_current_session_and_setup_new_transaction() |
|
924 | + { |
|
925 | + // if there's no transaction, then this is the FIRST visit to SPCO |
|
926 | + // so load up the cart ( passing nothing for the TXN because it doesn't exist yet ) |
|
927 | + $this->checkout->cart = $this->_get_cart_for_transaction(null); |
|
928 | + // and then create a new transaction |
|
929 | + $transaction = $this->_initialize_transaction(); |
|
930 | + // verify transaction |
|
931 | + if ($transaction instanceof EE_Transaction) { |
|
932 | + // save it so that we have an ID for other objects to use |
|
933 | + $transaction->save(); |
|
934 | + // and save TXN data to the cart |
|
935 | + $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID()); |
|
936 | + } else { |
|
937 | + EE_Error::add_error(__('A Valid Transaction could not be initialized.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
938 | + } |
|
939 | + return $transaction; |
|
940 | + } |
|
941 | + |
|
942 | + |
|
943 | + |
|
944 | + /** |
|
945 | + * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
946 | + * |
|
947 | + * @access private |
|
948 | + * @return mixed EE_Transaction|NULL |
|
949 | + */ |
|
950 | + private function _initialize_transaction() |
|
951 | + { |
|
952 | + try { |
|
953 | + // ensure cart totals have been calculated |
|
954 | + $this->checkout->cart->get_grand_total()->recalculate_total_including_taxes(); |
|
955 | + // grab the cart grand total |
|
956 | + $cart_total = $this->checkout->cart->get_cart_grand_total(); |
|
957 | + // create new TXN |
|
958 | + $transaction = EE_Transaction::new_instance( |
|
959 | + array( |
|
960 | + 'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(), |
|
961 | + 'TXN_total' => $cart_total > 0 ? $cart_total : 0, |
|
962 | + 'TXN_paid' => 0, |
|
963 | + 'STS_ID' => EEM_Transaction::failed_status_code, |
|
964 | + ) |
|
965 | + ); |
|
966 | + // save it so that we have an ID for other objects to use |
|
967 | + $transaction->save(); |
|
968 | + // set cron job for following up on TXNs after their session has expired |
|
969 | + EE_Cron_Tasks::schedule_expired_transaction_check( |
|
970 | + EE_Registry::instance()->SSN->expiration() + 1, |
|
971 | + $transaction->ID() |
|
972 | + ); |
|
973 | + return $transaction; |
|
974 | + } catch (Exception $e) { |
|
975 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
976 | + } |
|
977 | + return null; |
|
978 | + } |
|
979 | + |
|
980 | + |
|
981 | + |
|
982 | + /** |
|
983 | + * _get_registrations |
|
984 | + * |
|
985 | + * @access private |
|
986 | + * @param EE_Transaction $transaction |
|
987 | + * @return void |
|
988 | + * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
989 | + * @throws \EE_Error |
|
990 | + */ |
|
991 | + private function _get_registrations(EE_Transaction $transaction) |
|
992 | + { |
|
993 | + // first step: grab the registrants { : o |
|
994 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, true); |
|
995 | + // verify registrations have been set |
|
996 | + if (empty($registrations)) { |
|
997 | + // if no cached registrations, then check the db |
|
998 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
999 | + // still nothing ? well as long as this isn't a revisit |
|
1000 | + if (empty($registrations) && ! $this->checkout->revisit) { |
|
1001 | + // generate new registrations from scratch |
|
1002 | + $registrations = $this->_initialize_registrations($transaction); |
|
1003 | + } |
|
1004 | + } |
|
1005 | + // sort by their original registration order |
|
1006 | + usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count')); |
|
1007 | + // then loop thru the array |
|
1008 | + foreach ($registrations as $registration) { |
|
1009 | + // verify each registration |
|
1010 | + if ($registration instanceof EE_Registration) { |
|
1011 | + // we display all attendee info for the primary registrant |
|
1012 | + if ($this->checkout->reg_url_link === $registration->reg_url_link() |
|
1013 | + && $registration->is_primary_registrant() |
|
1014 | + ) { |
|
1015 | + $this->checkout->primary_revisit = true; |
|
1016 | + break; |
|
1017 | + } else if ($this->checkout->revisit |
|
1018 | + && $this->checkout->reg_url_link !== $registration->reg_url_link() |
|
1019 | + ) { |
|
1020 | + // but hide info if it doesn't belong to you |
|
1021 | + $transaction->clear_cache('Registration', $registration->ID()); |
|
1022 | + } |
|
1023 | + $this->checkout->set_reg_status_updated($registration->ID(), false); |
|
1024 | + } |
|
1025 | + } |
|
1026 | + } |
|
1027 | + |
|
1028 | + |
|
1029 | + |
|
1030 | + /** |
|
1031 | + * adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object |
|
1032 | + * |
|
1033 | + * @access private |
|
1034 | + * @param EE_Transaction $transaction |
|
1035 | + * @return array |
|
1036 | + * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
1037 | + * @throws \EE_Error |
|
1038 | + */ |
|
1039 | + private function _initialize_registrations(EE_Transaction $transaction) |
|
1040 | + { |
|
1041 | + $att_nmbr = 0; |
|
1042 | + $registrations = array(); |
|
1043 | + if ($transaction instanceof EE_Transaction) { |
|
1044 | + /** @type EE_Registration_Processor $registration_processor */ |
|
1045 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1046 | + $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count(); |
|
1047 | + // now let's add the cart items to the $transaction |
|
1048 | + foreach ($this->checkout->cart->get_tickets() as $line_item) { |
|
1049 | + //do the following for each ticket of this type they selected |
|
1050 | + for ($x = 1; $x <= $line_item->quantity(); $x++) { |
|
1051 | + $att_nmbr++; |
|
1052 | + /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */ |
|
1053 | + $CreateRegistrationCommand = EE_Registry::instance() |
|
1054 | + ->create( |
|
1055 | + 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
1056 | + array( |
|
1057 | + $transaction, |
|
1058 | + $line_item, |
|
1059 | + $att_nmbr, |
|
1060 | + $this->checkout->total_ticket_count, |
|
1061 | + ) |
|
1062 | + ); |
|
1063 | + // override capabilities for frontend registrations |
|
1064 | + if ( ! is_admin()) { |
|
1065 | + $CreateRegistrationCommand->setCapCheck( |
|
1066 | + new PublicCapabilities('', 'create_new_registration') |
|
1067 | + ); |
|
1068 | + } |
|
1069 | + $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand); |
|
1070 | + if ( ! $registration instanceof EE_Registration) { |
|
1071 | + throw new InvalidEntityException($registration, 'EE_Registration'); |
|
1072 | + } |
|
1073 | + $registrations[ $registration->ID() ] = $registration; |
|
1074 | + } |
|
1075 | + } |
|
1076 | + $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
|
1077 | + } |
|
1078 | + return $registrations; |
|
1079 | + } |
|
1080 | + |
|
1081 | + |
|
1082 | + |
|
1083 | + /** |
|
1084 | + * sorts registrations by REG_count |
|
1085 | + * |
|
1086 | + * @access public |
|
1087 | + * @param EE_Registration $reg_A |
|
1088 | + * @param EE_Registration $reg_B |
|
1089 | + * @return int |
|
1090 | + */ |
|
1091 | + public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) |
|
1092 | + { |
|
1093 | + // this shouldn't ever happen within the same TXN, but oh well |
|
1094 | + if ($reg_A->count() === $reg_B->count()) { |
|
1095 | + return 0; |
|
1096 | + } |
|
1097 | + return ($reg_A->count() > $reg_B->count()) ? 1 : -1; |
|
1098 | + } |
|
1099 | + |
|
1100 | + |
|
1101 | + |
|
1102 | + /** |
|
1103 | + * _final_verifications |
|
1104 | + * just makes sure that everything is set up correctly before proceeding |
|
1105 | + * |
|
1106 | + * @access private |
|
1107 | + * @return bool |
|
1108 | + * @throws \EE_Error |
|
1109 | + */ |
|
1110 | + private function _final_verifications() |
|
1111 | + { |
|
1112 | + // filter checkout |
|
1113 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout); |
|
1114 | + //verify that current step is still set correctly |
|
1115 | + if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
1116 | + EE_Error::add_error( |
|
1117 | + __('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.', 'event_espresso'), |
|
1118 | + __FILE__, |
|
1119 | + __FUNCTION__, |
|
1120 | + __LINE__ |
|
1121 | + ); |
|
1122 | + return false; |
|
1123 | + } |
|
1124 | + // if returning to SPCO, then verify that primary registrant is set |
|
1125 | + if ( ! empty($this->checkout->reg_url_link)) { |
|
1126 | + $valid_registrant = $this->checkout->transaction->primary_registration(); |
|
1127 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
1128 | + EE_Error::add_error( |
|
1129 | + __('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.', 'event_espresso'), |
|
1130 | + __FILE__, |
|
1131 | + __FUNCTION__, |
|
1132 | + __LINE__ |
|
1133 | + ); |
|
1134 | + return false; |
|
1135 | + } |
|
1136 | + $valid_registrant = null; |
|
1137 | + foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) { |
|
1138 | + if ( |
|
1139 | + $registration instanceof EE_Registration |
|
1140 | + && $registration->reg_url_link() === $this->checkout->reg_url_link |
|
1141 | + ) { |
|
1142 | + $valid_registrant = $registration; |
|
1143 | + } |
|
1144 | + } |
|
1145 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
1146 | + // hmmm... maybe we have the wrong session because the user is opening multiple tabs ? |
|
1147 | + if (EED_Single_Page_Checkout::$_checkout_verified) { |
|
1148 | + // clear the session, mark the checkout as unverified, and try again |
|
1149 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
1150 | + EED_Single_Page_Checkout::$_initialized = false; |
|
1151 | + EED_Single_Page_Checkout::$_checkout_verified = false; |
|
1152 | + $this->_initialize(); |
|
1153 | + EE_Error::reset_notices(); |
|
1154 | + return false; |
|
1155 | + } |
|
1156 | + EE_Error::add_error( |
|
1157 | + __('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.', 'event_espresso'), |
|
1158 | + __FILE__, |
|
1159 | + __FUNCTION__, |
|
1160 | + __LINE__ |
|
1161 | + ); |
|
1162 | + return false; |
|
1163 | + } |
|
1164 | + } |
|
1165 | + // now that things have been kinda sufficiently verified, |
|
1166 | + // let's add the checkout to the session so that it's available to other systems |
|
1167 | + EE_Registry::instance()->SSN->set_checkout($this->checkout); |
|
1168 | + return true; |
|
1169 | + } |
|
1170 | + |
|
1171 | + |
|
1172 | + |
|
1173 | + /** |
|
1174 | + * _initialize_reg_steps |
|
1175 | + * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required |
|
1176 | + * then loops thru all of the active reg steps and calls the initialize_reg_step() method |
|
1177 | + * |
|
1178 | + * @access private |
|
1179 | + * @param bool $reinitializing |
|
1180 | + * @throws \EE_Error |
|
1181 | + */ |
|
1182 | + private function _initialize_reg_steps($reinitializing = false) |
|
1183 | + { |
|
1184 | + $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
|
1185 | + // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
|
1186 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
1187 | + if ( ! $reg_step->initialize_reg_step()) { |
|
1188 | + // if not initialized then maybe this step is being removed... |
|
1189 | + if ( ! $reinitializing && $reg_step->is_current_step()) { |
|
1190 | + // if it was the current step, then we need to start over here |
|
1191 | + $this->_initialize_reg_steps(true); |
|
1192 | + return; |
|
1193 | + } |
|
1194 | + continue; |
|
1195 | + } |
|
1196 | + // add css and JS for current step |
|
1197 | + $reg_step->enqueue_styles_and_scripts(); |
|
1198 | + // i18n |
|
1199 | + $reg_step->translate_js_strings(); |
|
1200 | + if ($reg_step->is_current_step()) { |
|
1201 | + // the text that appears on the reg step form submit button |
|
1202 | + $reg_step->set_submit_button_text(); |
|
1203 | + } |
|
1204 | + } |
|
1205 | + // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information |
|
1206 | + do_action("AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step); |
|
1207 | + } |
|
1208 | + |
|
1209 | + |
|
1210 | + |
|
1211 | + /** |
|
1212 | + * _check_form_submission |
|
1213 | + * |
|
1214 | + * @access private |
|
1215 | + * @return boolean |
|
1216 | + */ |
|
1217 | + private function _check_form_submission() |
|
1218 | + { |
|
1219 | + //does this request require the reg form to be generated ? |
|
1220 | + if ($this->checkout->generate_reg_form) { |
|
1221 | + // ever heard that song by Blue Rodeo ? |
|
1222 | + try { |
|
1223 | + $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form(); |
|
1224 | + // if not displaying a form, then check for form submission |
|
1225 | + if ( |
|
1226 | + $this->checkout->process_form_submission |
|
1227 | + && $this->checkout->current_step->reg_form->was_submitted() |
|
1228 | + ) { |
|
1229 | + // clear out any old data in case this step is being run again |
|
1230 | + $this->checkout->current_step->set_valid_data(array()); |
|
1231 | + // capture submitted form data |
|
1232 | + $this->checkout->current_step->reg_form->receive_form_submission( |
|
1233 | + apply_filters( |
|
1234 | + 'FHEE__Single_Page_Checkout___check_form_submission__request_params', |
|
1235 | + EE_Registry::instance()->REQ->params(), |
|
1236 | + $this->checkout |
|
1237 | + ) |
|
1238 | + ); |
|
1239 | + // validate submitted form data |
|
1240 | + if ( ! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) { |
|
1241 | + // thou shall not pass !!! |
|
1242 | + $this->checkout->continue_reg = false; |
|
1243 | + // any form validation errors? |
|
1244 | + if ($this->checkout->current_step->reg_form->submission_error_message() !== '') { |
|
1245 | + $submission_error_messages = array(); |
|
1246 | + // bad, bad, bad registrant |
|
1247 | + foreach ($this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error) { |
|
1248 | + if ($validation_error instanceof EE_Validation_Error) { |
|
1249 | + $submission_error_messages[] = sprintf( |
|
1250 | + __('%s : %s', 'event_espresso'), |
|
1251 | + $validation_error->get_form_section()->html_label_text(), |
|
1252 | + $validation_error->getMessage() |
|
1253 | + ); |
|
1254 | + } |
|
1255 | + } |
|
1256 | + EE_Error::add_error(implode('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__); |
|
1257 | + } |
|
1258 | + // well not really... what will happen is we'll just get redirected back to redo the current step |
|
1259 | + $this->go_to_next_step(); |
|
1260 | + return false; |
|
1261 | + } |
|
1262 | + } |
|
1263 | + } catch (EE_Error $e) { |
|
1264 | + $e->get_error(); |
|
1265 | + } |
|
1266 | + } |
|
1267 | + return true; |
|
1268 | + } |
|
1269 | + |
|
1270 | + |
|
1271 | + |
|
1272 | + /** |
|
1273 | + * _process_action |
|
1274 | + * |
|
1275 | + * @access private |
|
1276 | + * @return void |
|
1277 | + * @throws \EE_Error |
|
1278 | + */ |
|
1279 | + private function _process_form_action() |
|
1280 | + { |
|
1281 | + // what cha wanna do? |
|
1282 | + switch ($this->checkout->action) { |
|
1283 | + // AJAX next step reg form |
|
1284 | + case 'display_spco_reg_step' : |
|
1285 | + $this->checkout->redirect = false; |
|
1286 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1287 | + $this->checkout->json_response->set_reg_step_html($this->checkout->current_step->display_reg_form()); |
|
1288 | + } |
|
1289 | + break; |
|
1290 | + default : |
|
1291 | + // meh... do one of those other steps first |
|
1292 | + if ( ! empty($this->checkout->action) && is_callable(array($this->checkout->current_step, $this->checkout->action))) { |
|
1293 | + // dynamically creates hook point like: AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step |
|
1294 | + do_action("AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
1295 | + // call action on current step |
|
1296 | + if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) { |
|
1297 | + // good registrant, you get to proceed |
|
1298 | + if ( |
|
1299 | + $this->checkout->current_step->success_message() !== '' |
|
1300 | + && apply_filters( |
|
1301 | + 'FHEE__Single_Page_Checkout___process_form_action__display_success', |
|
1302 | + false |
|
1303 | + ) |
|
1304 | + ) { |
|
1305 | + EE_Error::add_success( |
|
1306 | + $this->checkout->current_step->success_message() |
|
1307 | + . '<br />' . $this->checkout->next_step->_instructions() |
|
1308 | + ); |
|
1309 | + } |
|
1310 | + // pack it up, pack it in... |
|
1311 | + $this->_setup_redirect(); |
|
1312 | + } |
|
1313 | + // dynamically creates hook point like: AHEE__Single_Page_Checkout__after_payment_options__process_reg_step |
|
1314 | + do_action("AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
1315 | + } else { |
|
1316 | + EE_Error::add_error( |
|
1317 | + sprintf( |
|
1318 | + __('The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso'), |
|
1319 | + $this->checkout->action, |
|
1320 | + $this->checkout->current_step->name() |
|
1321 | + ), |
|
1322 | + __FILE__, |
|
1323 | + __FUNCTION__, |
|
1324 | + __LINE__ |
|
1325 | + ); |
|
1326 | + } |
|
1327 | + // end default |
|
1328 | + } |
|
1329 | + // store our progress so far |
|
1330 | + $this->checkout->stash_transaction_and_checkout(); |
|
1331 | + // advance to the next step! If you pass GO, collect $200 |
|
1332 | + $this->go_to_next_step(); |
|
1333 | + } |
|
1334 | + |
|
1335 | + |
|
1336 | + |
|
1337 | + /** |
|
1338 | + * add_styles_and_scripts |
|
1339 | + * |
|
1340 | + * @access public |
|
1341 | + * @return void |
|
1342 | + */ |
|
1343 | + public function add_styles_and_scripts() |
|
1344 | + { |
|
1345 | + // i18n |
|
1346 | + $this->translate_js_strings(); |
|
1347 | + if ($this->checkout->admin_request) { |
|
1348 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1349 | + } else { |
|
1350 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1351 | + } |
|
1352 | + } |
|
1353 | + |
|
1354 | + |
|
1355 | + |
|
1356 | + /** |
|
1357 | + * translate_js_strings |
|
1358 | + * |
|
1359 | + * @access public |
|
1360 | + * @return void |
|
1361 | + */ |
|
1362 | + public function translate_js_strings() |
|
1363 | + { |
|
1364 | + EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit; |
|
1365 | + EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link; |
|
1366 | + EE_Registry::$i18n_js_strings['server_error'] = __('An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso'); |
|
1367 | + EE_Registry::$i18n_js_strings['invalid_json_response'] = __('An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso'); |
|
1368 | + EE_Registry::$i18n_js_strings['validation_error'] = __('There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso'); |
|
1369 | + EE_Registry::$i18n_js_strings['invalid_payment_method'] = __('There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso'); |
|
1370 | + EE_Registry::$i18n_js_strings['reg_step_error'] = __('This registration step could not be completed. Please refresh the page and try again.', 'event_espresso'); |
|
1371 | + EE_Registry::$i18n_js_strings['invalid_coupon'] = __('We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', 'event_espresso'); |
|
1372 | + EE_Registry::$i18n_js_strings['process_registration'] = sprintf( |
|
1373 | + __('Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', 'event_espresso'), |
|
1374 | + '<br/>', |
|
1375 | + '<br/>' |
|
1376 | + ); |
|
1377 | + EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language'); |
|
1378 | + EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id(); |
|
1379 | + EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency; |
|
1380 | + EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20'; |
|
1381 | + EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso'); |
|
1382 | + EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso'); |
|
1383 | + EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso'); |
|
1384 | + EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso'); |
|
1385 | + EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso'); |
|
1386 | + EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso'); |
|
1387 | + EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso'); |
|
1388 | + EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso'); |
|
1389 | + EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso'); |
|
1390 | + EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso'); |
|
1391 | + EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso'); |
|
1392 | + EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso'); |
|
1393 | + EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso'); |
|
1394 | + EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso'); |
|
1395 | + EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
|
1396 | + __( |
|
1397 | + '%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 except our apologies for any inconvenience this may have caused.%8$s', |
|
1398 | + 'event_espresso' |
|
1399 | + ), |
|
1400 | + '<h4 class="important-notice">', |
|
1401 | + '</h4>', |
|
1402 | + '<br />', |
|
1403 | + '<p>', |
|
1404 | + '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
1405 | + '">', |
|
1406 | + '</a>', |
|
1407 | + '</p>' |
|
1408 | + ); |
|
1409 | + EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters('FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true); |
|
1410 | + EE_Registry::$i18n_js_strings['session_extension'] = absint( |
|
1411 | + apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS) |
|
1412 | + ); |
|
1413 | + EE_Registry::$i18n_js_strings['session_expiration'] = gmdate( |
|
1414 | + 'M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
1415 | + ); |
|
1416 | + } |
|
1417 | + |
|
1418 | + |
|
1419 | + |
|
1420 | + /** |
|
1421 | + * enqueue_styles_and_scripts |
|
1422 | + * |
|
1423 | + * @access public |
|
1424 | + * @return void |
|
1425 | + * @throws \EE_Error |
|
1426 | + */ |
|
1427 | + public function enqueue_styles_and_scripts() |
|
1428 | + { |
|
1429 | + // load css |
|
1430 | + wp_register_style('single_page_checkout', SPCO_CSS_URL . 'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION); |
|
1431 | + wp_enqueue_style('single_page_checkout'); |
|
1432 | + // load JS |
|
1433 | + wp_register_script('jquery_plugin', EE_THIRD_PARTY_URL . 'jquery .plugin.min.js', array('jquery'), '1.0.1', true); |
|
1434 | + wp_register_script('jquery_countdown', EE_THIRD_PARTY_URL . 'jquery .countdown.min.js', array('jquery_plugin'), '2.0.2', true); |
|
1435 | + wp_register_script('single_page_checkout', SPCO_JS_URL . 'single_page_checkout.js', array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'), EVENT_ESPRESSO_VERSION, true); |
|
1436 | + if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) { |
|
1437 | + $this->checkout->registration_form->enqueue_js(); |
|
1438 | + } |
|
1439 | + if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) { |
|
1440 | + $this->checkout->current_step->reg_form->enqueue_js(); |
|
1441 | + } |
|
1442 | + wp_enqueue_script('single_page_checkout'); |
|
1443 | + /** |
|
1444 | + * global action hook for enqueueing styles and scripts with |
|
1445 | + * spco calls. |
|
1446 | + */ |
|
1447 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this); |
|
1448 | + /** |
|
1449 | + * dynamic action hook for enqueueing styles and scripts with spco calls. |
|
1450 | + * The hook will end up being something like AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
|
1451 | + */ |
|
1452 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), $this); |
|
1453 | + } |
|
1454 | + |
|
1455 | + |
|
1456 | + |
|
1457 | + /** |
|
1458 | + * display the Registration Single Page Checkout Form |
|
1459 | + * |
|
1460 | + * @access private |
|
1461 | + * @return void |
|
1462 | + * @throws \EE_Error |
|
1463 | + */ |
|
1464 | + private function _display_spco_reg_form() |
|
1465 | + { |
|
1466 | + // if registering via the admin, just display the reg form for the current step |
|
1467 | + if ($this->checkout->admin_request) { |
|
1468 | + EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form()); |
|
1469 | + } else { |
|
1470 | + // add powered by EE msg |
|
1471 | + add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer')); |
|
1472 | + $empty_cart = count($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)) < 1 |
|
1473 | + ? true |
|
1474 | + : false; |
|
1475 | + EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart; |
|
1476 | + $cookies_not_set_msg = ''; |
|
1477 | + if ($empty_cart && ! isset($_COOKIE['ee_cookie_test'])) { |
|
1478 | + $cookies_not_set_msg = apply_filters( |
|
1479 | + 'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg', |
|
1480 | + sprintf( |
|
1481 | + __( |
|
1482 | + '%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', |
|
1483 | + 'event_espresso' |
|
1484 | + ), |
|
1485 | + '<div class="ee-attention">', |
|
1486 | + '</div>', |
|
1487 | + '<h6 class="important-notice">', |
|
1488 | + '</h6>', |
|
1489 | + '<p>', |
|
1490 | + '</p>', |
|
1491 | + '<br />', |
|
1492 | + '<a href="http://www.whatarecookies.com/enable.asp" target="_blank">', |
|
1493 | + '</a>' |
|
1494 | + ) |
|
1495 | + ); |
|
1496 | + } |
|
1497 | + $this->checkout->registration_form = new EE_Form_Section_Proper( |
|
1498 | + array( |
|
1499 | + 'name' => 'single-page-checkout', |
|
1500 | + 'html_id' => 'ee-single-page-checkout-dv', |
|
1501 | + 'layout_strategy' => |
|
1502 | + new EE_Template_Layout( |
|
1503 | + array( |
|
1504 | + 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
1505 | + 'template_args' => array( |
|
1506 | + 'empty_cart' => $empty_cart, |
|
1507 | + 'revisit' => $this->checkout->revisit, |
|
1508 | + 'reg_steps' => $this->checkout->reg_steps, |
|
1509 | + 'next_step' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
|
1510 | + ? $this->checkout->next_step->slug() |
|
1511 | + : '', |
|
1512 | + 'cancel_page_url' => $this->checkout->cancel_page_url, |
|
1513 | + 'empty_msg' => apply_filters( |
|
1514 | + 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
|
1515 | + sprintf( |
|
1516 | + __('You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', |
|
1517 | + 'event_espresso'), |
|
1518 | + '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
1519 | + '">', |
|
1520 | + '</a>' |
|
1521 | + ) |
|
1522 | + ), |
|
1523 | + 'cookies_not_set_msg' => $cookies_not_set_msg, |
|
1524 | + 'registration_time_limit' => $this->checkout->get_registration_time_limit(), |
|
1525 | + 'session_expiration' => gmdate( |
|
1526 | + 'M d, Y H:i:s', |
|
1527 | + EE_Registry::instance()->SSN->expiration() |
|
1528 | + + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
1529 | + ), |
|
1530 | + ), |
|
1531 | + ) |
|
1532 | + ), |
|
1533 | + ) |
|
1534 | + ); |
|
1535 | + // load template and add to output sent that gets filtered into the_content() |
|
1536 | + EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html()); |
|
1537 | + } |
|
1538 | + } |
|
1539 | + |
|
1540 | + |
|
1541 | + |
|
1542 | + /** |
|
1543 | + * add_extra_finalize_registration_inputs |
|
1544 | + * |
|
1545 | + * @access public |
|
1546 | + * @param $next_step |
|
1547 | + * @internal param string $label |
|
1548 | + * @return void |
|
1549 | + */ |
|
1550 | + public function add_extra_finalize_registration_inputs($next_step) |
|
1551 | + { |
|
1552 | + if ($next_step === 'finalize_registration') { |
|
1553 | + echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>'; |
|
1554 | + } |
|
1555 | + } |
|
1556 | + |
|
1557 | + |
|
1558 | + |
|
1559 | + /** |
|
1560 | + * display_registration_footer |
|
1561 | + * |
|
1562 | + * @access public |
|
1563 | + * @return string |
|
1564 | + */ |
|
1565 | + public static function display_registration_footer() |
|
1566 | + { |
|
1567 | + if ( |
|
1568 | + apply_filters( |
|
1569 | + 'FHEE__EE_Front__Controller__show_reg_footer', |
|
1570 | + EE_Registry::instance()->CFG->admin->show_reg_footer |
|
1571 | + ) |
|
1572 | + ) { |
|
1573 | + add_filter( |
|
1574 | + 'FHEE__EEH_Template__powered_by_event_espresso__url', |
|
1575 | + function ($url) { |
|
1576 | + return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
|
1577 | + } |
|
1578 | + ); |
|
1579 | + echo apply_filters( |
|
1580 | + 'FHEE__EE_Front_Controller__display_registration_footer', |
|
1581 | + \EEH_Template::powered_by_event_espresso( |
|
1582 | + '', |
|
1583 | + 'espresso-registration-footer-dv', |
|
1584 | + array('utm_content' => 'registration_checkout') |
|
1585 | + ) |
|
1586 | + ); |
|
1587 | + } |
|
1588 | + return ''; |
|
1589 | + } |
|
1590 | + |
|
1591 | + |
|
1592 | + |
|
1593 | + /** |
|
1594 | + * unlock_transaction |
|
1595 | + * |
|
1596 | + * @access public |
|
1597 | + * @return void |
|
1598 | + * @throws \EE_Error |
|
1599 | + */ |
|
1600 | + public function unlock_transaction() |
|
1601 | + { |
|
1602 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
1603 | + $this->checkout->transaction->unlock(); |
|
1604 | + } |
|
1605 | + } |
|
1606 | + |
|
1607 | + |
|
1608 | + |
|
1609 | + /** |
|
1610 | + * _setup_redirect |
|
1611 | + * |
|
1612 | + * @access private |
|
1613 | + * @return void |
|
1614 | + */ |
|
1615 | + private function _setup_redirect() |
|
1616 | + { |
|
1617 | + if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
1618 | + $this->checkout->redirect = true; |
|
1619 | + if (empty($this->checkout->redirect_url)) { |
|
1620 | + $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url(); |
|
1621 | + } |
|
1622 | + $this->checkout->redirect_url = apply_filters( |
|
1623 | + 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', |
|
1624 | + $this->checkout->redirect_url, |
|
1625 | + $this->checkout |
|
1626 | + ); |
|
1627 | + } |
|
1628 | + } |
|
1629 | + |
|
1630 | + |
|
1631 | + |
|
1632 | + /** |
|
1633 | + * handle ajax message responses and redirects |
|
1634 | + * |
|
1635 | + * @access public |
|
1636 | + * @return void |
|
1637 | + * @throws \EE_Error |
|
1638 | + */ |
|
1639 | + public function go_to_next_step() |
|
1640 | + { |
|
1641 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1642 | + // capture contents of output buffer we started earlier in the request, and insert into JSON response |
|
1643 | + $this->checkout->json_response->set_unexpected_errors(ob_get_clean()); |
|
1644 | + } |
|
1645 | + $this->unlock_transaction(); |
|
1646 | + // just return for these conditions |
|
1647 | + if ( |
|
1648 | + $this->checkout->admin_request |
|
1649 | + || $this->checkout->action === 'redirect_form' |
|
1650 | + || $this->checkout->action === 'update_checkout' |
|
1651 | + ) { |
|
1652 | + return; |
|
1653 | + } |
|
1654 | + // AJAX response |
|
1655 | + $this->_handle_json_response(); |
|
1656 | + // redirect to next step or the Thank You page |
|
1657 | + $this->_handle_html_redirects(); |
|
1658 | + // hmmm... must be something wrong, so let's just display the form again ! |
|
1659 | + $this->_display_spco_reg_form(); |
|
1660 | + } |
|
1661 | + |
|
1662 | + |
|
1663 | + |
|
1664 | + /** |
|
1665 | + * _handle_json_response |
|
1666 | + * |
|
1667 | + * @access protected |
|
1668 | + * @return void |
|
1669 | + */ |
|
1670 | + protected function _handle_json_response() |
|
1671 | + { |
|
1672 | + // if this is an ajax request |
|
1673 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1674 | + // DEBUG LOG |
|
1675 | + //$this->checkout->log( |
|
1676 | + // __CLASS__, __FUNCTION__, __LINE__, |
|
1677 | + // array( |
|
1678 | + // 'json_response_redirect_url' => $this->checkout->json_response->redirect_url(), |
|
1679 | + // 'redirect' => $this->checkout->redirect, |
|
1680 | + // 'continue_reg' => $this->checkout->continue_reg, |
|
1681 | + // ) |
|
1682 | + //); |
|
1683 | + $this->checkout->json_response->set_registration_time_limit( |
|
1684 | + $this->checkout->get_registration_time_limit() |
|
1685 | + ); |
|
1686 | + $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing); |
|
1687 | + // just send the ajax ( |
|
1688 | + $json_response = apply_filters( |
|
1689 | + 'FHEE__EE_Single_Page_Checkout__JSON_response', |
|
1690 | + $this->checkout->json_response |
|
1691 | + ); |
|
1692 | + echo $json_response; |
|
1693 | + exit(); |
|
1694 | + } |
|
1695 | + } |
|
1696 | + |
|
1697 | + |
|
1698 | + |
|
1699 | + /** |
|
1700 | + * _handle_redirects |
|
1701 | + * |
|
1702 | + * @access protected |
|
1703 | + * @return void |
|
1704 | + */ |
|
1705 | + protected function _handle_html_redirects() |
|
1706 | + { |
|
1707 | + // going somewhere ? |
|
1708 | + if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) { |
|
1709 | + // store notices in a transient |
|
1710 | + EE_Error::get_notices(false, true, true); |
|
1711 | + // DEBUG LOG |
|
1712 | + //$this->checkout->log( |
|
1713 | + // __CLASS__, __FUNCTION__, __LINE__, |
|
1714 | + // array( |
|
1715 | + // 'headers_sent' => headers_sent(), |
|
1716 | + // 'redirect_url' => $this->checkout->redirect_url, |
|
1717 | + // 'headers_list' => headers_list(), |
|
1718 | + // ) |
|
1719 | + //); |
|
1720 | + wp_safe_redirect($this->checkout->redirect_url); |
|
1721 | + exit(); |
|
1722 | + } |
|
1723 | + } |
|
1724 | + |
|
1725 | + |
|
1726 | + |
|
1727 | + /** |
|
1728 | + * set_checkout_anchor |
|
1729 | + * |
|
1730 | + * @access public |
|
1731 | + * @return void |
|
1732 | + */ |
|
1733 | + public function set_checkout_anchor() |
|
1734 | + { |
|
1735 | + echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>'; |
|
1736 | + } |
|
1737 | 1737 | |
1738 | 1738 | |
1739 | 1739 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * EES_Espresso_Txn_Page |
4 | 4 | * |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @throws \Exception |
58 | 58 | * @throws \EE_Error |
59 | 59 | */ |
60 | - public function run( WP $WP ) { |
|
60 | + public function run(WP $WP) { |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * @param array $attributes |
69 | 69 | * @return string |
70 | 70 | */ |
71 | - public function process_shortcode( $attributes = array() ) { |
|
72 | - return __( 'This is the Event Espresso Transactions page. This page receives instant payment notification (IPN) requests and should have a status of published, but should not be easily accessible by site visitors. Do not add it to your website\'s navigation menu or link to it from another page. Also, do not delete it or change its status to private.', 'event_espresso' ); |
|
71 | + public function process_shortcode($attributes = array()) { |
|
72 | + return __('This is the Event Espresso Transactions page. This page receives instant payment notification (IPN) requests and should have a status of published, but should not be easily accessible by site visitors. Do not add it to your website\'s navigation menu or link to it from another page. Also, do not delete it or change its status to private.', 'event_espresso'); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 |
@@ -11,15 +11,15 @@ discard block |
||
11 | 11 | |
12 | 12 | |
13 | 13 | /** |
14 | - * @deprecated 4.9.27 |
|
15 | - * @return void |
|
14 | + * @deprecated 4.9.27 |
|
15 | + * @return void |
|
16 | 16 | */ |
17 | 17 | public static function set_hooks() { |
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
21 | - * @deprecated 4.9.27 |
|
22 | - * @return void |
|
21 | + * @deprecated 4.9.27 |
|
22 | + * @return void |
|
23 | 23 | */ |
24 | 24 | public static function set_hooks_admin() { |
25 | 25 | } |
@@ -27,8 +27,8 @@ discard block |
||
27 | 27 | |
28 | 28 | |
29 | 29 | /** |
30 | - * @deprecated 4.9.27 |
|
31 | - * @return void |
|
30 | + * @deprecated 4.9.27 |
|
31 | + * @return void |
|
32 | 32 | */ |
33 | 33 | public static function set_definitions() { |
34 | 34 | } |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | |
37 | 37 | |
38 | 38 | /** |
39 | - * @deprecated 4.9.27 |
|
40 | - * @param WP $WP |
|
39 | + * @deprecated 4.9.27 |
|
40 | + * @param WP $WP |
|
41 | 41 | * @return void |
42 | 42 | * @throws \Exception |
43 | 43 | * @throws \EE_Error |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | |
50 | 50 | |
51 | 51 | /** |
52 | - * @deprecated 4.9.27 |
|
53 | - * @param array $attributes |
|
52 | + * @deprecated 4.9.27 |
|
53 | + * @param array $attributes |
|
54 | 54 | * @return string |
55 | 55 | */ |
56 | 56 | public function process_shortcode( $attributes = array() ) { |
@@ -64,7 +64,7 @@ |
||
64 | 64 | do_action('AHEE_event_details_before_post', $event_id); |
65 | 65 | espresso_ticket_selector($event); |
66 | 66 | do_action('AHEE_event_details_after_post'); |
67 | - return ob_get_clean(); } |
|
67 | + return ob_get_clean(); } |
|
68 | 68 | } |
69 | 69 | // End of file EspressoTicketSelector.php |
70 | 70 | // Location: EventEspresso\core\domain\entities\shortcodes/EspressoTicketSelector.php |
71 | 71 | \ No newline at end of file |
@@ -21,62 +21,62 @@ |
||
21 | 21 | |
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * the actual shortcode tag that gets registered with WordPress |
|
26 | - * |
|
27 | - * @return string |
|
28 | - */ |
|
29 | - public function getTag() |
|
30 | - { |
|
31 | - return 'ESPRESSO_TICKET_SELECTOR'; |
|
32 | - } |
|
33 | - |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * the time in seconds to cache the results of the processShortcode() method |
|
38 | - * 0 means the processShortcode() results will NOT be cached at all |
|
39 | - * |
|
40 | - * @return int |
|
41 | - */ |
|
42 | - public function cacheExpiration() |
|
43 | - { |
|
44 | - return MINUTE_IN_SECONDS * 5; |
|
45 | - } |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * a place for adding any initialization code that needs to run prior to wp_header(). |
|
50 | - * this may be required for shortcodes that utilize a corresponding module, |
|
51 | - * and need to enqueue assets for that module |
|
52 | - * |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - public function initializeShortcode() |
|
56 | - { |
|
57 | - add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * callback that runs when the shortcode is encountered in post content. |
|
64 | - * IMPORTANT !!! |
|
65 | - * remember that shortcode content should be RETURNED and NOT echoed out |
|
66 | - * |
|
67 | - * @param array $attributes |
|
68 | - * @return string |
|
69 | - */ |
|
70 | - public function processShortcode($attributes = array()) |
|
71 | - { |
|
72 | - extract($attributes, EXTR_OVERWRITE); |
|
73 | - $event_id = isset($event_id) ? $event_id : 0; |
|
74 | - $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id); |
|
75 | - ob_start(); |
|
76 | - do_action('AHEE_event_details_before_post', $event_id); |
|
77 | - espresso_ticket_selector($event); |
|
78 | - do_action('AHEE_event_details_after_post'); |
|
79 | - return ob_get_clean(); } |
|
24 | + /** |
|
25 | + * the actual shortcode tag that gets registered with WordPress |
|
26 | + * |
|
27 | + * @return string |
|
28 | + */ |
|
29 | + public function getTag() |
|
30 | + { |
|
31 | + return 'ESPRESSO_TICKET_SELECTOR'; |
|
32 | + } |
|
33 | + |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * the time in seconds to cache the results of the processShortcode() method |
|
38 | + * 0 means the processShortcode() results will NOT be cached at all |
|
39 | + * |
|
40 | + * @return int |
|
41 | + */ |
|
42 | + public function cacheExpiration() |
|
43 | + { |
|
44 | + return MINUTE_IN_SECONDS * 5; |
|
45 | + } |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * a place for adding any initialization code that needs to run prior to wp_header(). |
|
50 | + * this may be required for shortcodes that utilize a corresponding module, |
|
51 | + * and need to enqueue assets for that module |
|
52 | + * |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + public function initializeShortcode() |
|
56 | + { |
|
57 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * callback that runs when the shortcode is encountered in post content. |
|
64 | + * IMPORTANT !!! |
|
65 | + * remember that shortcode content should be RETURNED and NOT echoed out |
|
66 | + * |
|
67 | + * @param array $attributes |
|
68 | + * @return string |
|
69 | + */ |
|
70 | + public function processShortcode($attributes = array()) |
|
71 | + { |
|
72 | + extract($attributes, EXTR_OVERWRITE); |
|
73 | + $event_id = isset($event_id) ? $event_id : 0; |
|
74 | + $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id); |
|
75 | + ob_start(); |
|
76 | + do_action('AHEE_event_details_before_post', $event_id); |
|
77 | + espresso_ticket_selector($event); |
|
78 | + do_action('AHEE_event_details_after_post'); |
|
79 | + return ob_get_clean(); } |
|
80 | 80 | } |
81 | 81 | // End of file EspressoTicketSelector.php |
82 | 82 | // Location: EventEspresso\core\domain\entities\shortcodes/EspressoTicketSelector.php |
83 | 83 | \ No newline at end of file |
@@ -155,14 +155,14 @@ discard block |
||
155 | 155 | wp_enqueue_script( 'batch_runner', EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', array( 'progress_bar' )); |
156 | 156 | //just copy the bits of EE admin's eei18n that we need in the JS |
157 | 157 | wp_localize_script( |
158 | - 'batch_runner', |
|
159 | - 'eei18n', |
|
160 | - array( |
|
161 | - 'ajax_url' => WP_AJAX_URL, |
|
162 | - 'is_admin' => (bool)is_admin(), |
|
163 | - 'error_message' => esc_html__('An error occurred and the job has been stopped.', 'event_espresso') |
|
164 | - ) |
|
165 | - ); |
|
158 | + 'batch_runner', |
|
159 | + 'eei18n', |
|
160 | + array( |
|
161 | + 'ajax_url' => WP_AJAX_URL, |
|
162 | + 'is_admin' => (bool)is_admin(), |
|
163 | + 'error_message' => esc_html__('An error occurred and the job has been stopped.', 'event_espresso') |
|
164 | + ) |
|
165 | + ); |
|
166 | 166 | $job_handler_classname = stripslashes( $_GET[ 'job_handler' ] ); |
167 | 167 | $request_data = array_diff_key( |
168 | 168 | $_REQUEST, |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | if ( NULL === error_get_last() || ! headers_sent() ) { |
259 | 259 | header('Content-Type: application/json; charset=UTF-8'); |
260 | 260 | } |
261 | - echo wp_json_encode( $json ); |
|
261 | + echo wp_json_encode( $json ); |
|
262 | 262 | exit(); |
263 | 263 | } |
264 | 264 |
@@ -17,13 +17,13 @@ discard block |
||
17 | 17 | * @since 4.8.30.rc.007 |
18 | 18 | * |
19 | 19 | */ |
20 | -if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
21 | - exit( 'No direct script access allowed' ); |
|
20 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
21 | + exit('No direct script access allowed'); |
|
22 | 22 | } |
23 | 23 | |
24 | -define( 'BATCH_URL', plugin_dir_url( __FILE__ ) ); |
|
24 | +define('BATCH_URL', plugin_dir_url(__FILE__)); |
|
25 | 25 | |
26 | -class EED_Batch extends EED_Module{ |
|
26 | +class EED_Batch extends EED_Module { |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | public static function set_hooks() { |
71 | 71 | //because this is a possibel attack vector, let's have this disabled until |
72 | 72 | //we at least have a real use for it on the frontend |
73 | - if( apply_filters( 'FHEE__EED_Batch__set_hooks__enable_frontend_batch', false ) ) { |
|
74 | - add_action( 'wp_enqueue_scripts', array( self::instance(), 'enqueue_scripts' ) ); |
|
75 | - add_filter( 'template_include', array( self::instance(), 'override_template' ), 99 ); |
|
73 | + if (apply_filters('FHEE__EED_Batch__set_hooks__enable_frontend_batch', false)) { |
|
74 | + add_action('wp_enqueue_scripts', array(self::instance(), 'enqueue_scripts')); |
|
75 | + add_filter('template_include', array(self::instance(), 'override_template'), 99); |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
@@ -80,28 +80,28 @@ discard block |
||
80 | 80 | * Initializes some hooks for the admin in order to run batch jobs |
81 | 81 | */ |
82 | 82 | public static function set_hooks_admin() { |
83 | - add_action( 'admin_menu', array( self::instance(), 'register_admin_pages' ) ); |
|
84 | - add_action( 'admin_enqueue_scripts', array( self::instance(), 'enqueue_scripts' ) ); |
|
83 | + add_action('admin_menu', array(self::instance(), 'register_admin_pages')); |
|
84 | + add_action('admin_enqueue_scripts', array(self::instance(), 'enqueue_scripts')); |
|
85 | 85 | |
86 | 86 | //ajax |
87 | - add_action('wp_ajax_espresso_batch_continue',array(self::instance(),'batch_continue')); |
|
88 | - add_action('wp_ajax_espresso_batch_cleanup',array(self::instance(),'batch_cleanup')); |
|
89 | - add_action('wp_ajax_nopriv_espresso_batch_continue',array(self::instance(),'batch_continue')); |
|
90 | - add_action('wp_ajax_nopriv_espresso_batch_cleanup',array(self::instance(),'batch_cleanup')); |
|
87 | + add_action('wp_ajax_espresso_batch_continue', array(self::instance(), 'batch_continue')); |
|
88 | + add_action('wp_ajax_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup')); |
|
89 | + add_action('wp_ajax_nopriv_espresso_batch_continue', array(self::instance(), 'batch_continue')); |
|
90 | + add_action('wp_ajax_nopriv_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup')); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
94 | 94 | * Enqueues batch scripts on the frontend or admin, and creates a job |
95 | 95 | */ |
96 | 96 | public function enqueue_scripts() { |
97 | - if( isset( $_REQUEST[ 'espresso_batch' ] ) |
|
97 | + if (isset($_REQUEST['espresso_batch']) |
|
98 | 98 | || |
99 | 99 | ( |
100 | - isset( $_REQUEST[ 'page' ] ) |
|
101 | - && $_REQUEST[ 'page' ] == 'espresso_batch' |
|
100 | + isset($_REQUEST['page']) |
|
101 | + && $_REQUEST['page'] == 'espresso_batch' |
|
102 | 102 | ) |
103 | 103 | ) { |
104 | - switch( $this->batch_request_type() ) { |
|
104 | + switch ($this->batch_request_type()) { |
|
105 | 105 | case self::batch_job: |
106 | 106 | $this->enqueue_scripts_styles_batch_create(); |
107 | 107 | break; |
@@ -117,11 +117,11 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function enqueue_scripts_styles_batch_create() { |
119 | 119 | $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
120 | - wp_enqueue_script( 'batch_runner_init', BATCH_URL . 'assets/batch_runner_init.js', array( 'batch_runner' ), EVENT_ESPRESSO_VERSION, true ); |
|
121 | - wp_localize_script( 'batch_runner_init', 'ee_job_response', $job_response->to_array() ); |
|
122 | - wp_localize_script( 'batch_runner_init', 'ee_job_i18n', |
|
120 | + wp_enqueue_script('batch_runner_init', BATCH_URL.'assets/batch_runner_init.js', array('batch_runner'), EVENT_ESPRESSO_VERSION, true); |
|
121 | + wp_localize_script('batch_runner_init', 'ee_job_response', $job_response->to_array()); |
|
122 | + wp_localize_script('batch_runner_init', 'ee_job_i18n', |
|
123 | 123 | array( |
124 | - 'return_url' => $_REQUEST['return_url' ], |
|
124 | + 'return_url' => $_REQUEST['return_url'], |
|
125 | 125 | )); |
126 | 126 | } |
127 | 127 | |
@@ -131,15 +131,15 @@ discard block |
||
131 | 131 | public function enqueue_scripts_styles_batch_file_create() { |
132 | 132 | //creates a job based on the request variable |
133 | 133 | $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
134 | - wp_enqueue_script( 'batch_file_runner_init', BATCH_URL . 'assets/batch_file_runner_init.js', array( 'batch_runner' ), EVENT_ESPRESSO_VERSION, true ); |
|
135 | - wp_localize_script( 'batch_file_runner_init', 'ee_job_response', $job_response->to_array() ); |
|
136 | - wp_localize_script( 'batch_file_runner_init', 'ee_job_i18n', |
|
134 | + wp_enqueue_script('batch_file_runner_init', BATCH_URL.'assets/batch_file_runner_init.js', array('batch_runner'), EVENT_ESPRESSO_VERSION, true); |
|
135 | + wp_localize_script('batch_file_runner_init', 'ee_job_response', $job_response->to_array()); |
|
136 | + wp_localize_script('batch_file_runner_init', 'ee_job_i18n', |
|
137 | 137 | array( |
138 | 138 | 'download_and_redirecting' => sprintf( |
139 | 139 | __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'), |
140 | - '<a href="' . $_REQUEST['return_url' ] .'">', |
|
140 | + '<a href="'.$_REQUEST['return_url'].'">', |
|
141 | 141 | '</a>' ), |
142 | - 'return_url' => $_REQUEST['return_url' ], |
|
142 | + 'return_url' => $_REQUEST['return_url'], |
|
143 | 143 | )); |
144 | 144 | } |
145 | 145 | |
@@ -150,26 +150,26 @@ discard block |
||
150 | 150 | * @return \EventEspressoBatchRequest\Helpers\JobStepResponse |
151 | 151 | */ |
152 | 152 | protected function _enqueue_batch_job_scripts_and_styles_and_start_job() { |
153 | - wp_register_script( 'progress_bar', EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js', array( 'jquery' ) ); |
|
154 | - wp_enqueue_style( 'progress_bar', EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css', array(), EVENT_ESPRESSO_VERSION ); |
|
155 | - wp_enqueue_script( 'batch_runner', EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', array( 'progress_bar' )); |
|
153 | + wp_register_script('progress_bar', EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.js', array('jquery')); |
|
154 | + wp_enqueue_style('progress_bar', EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.css', array(), EVENT_ESPRESSO_VERSION); |
|
155 | + wp_enqueue_script('batch_runner', EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/batch_runner.js', array('progress_bar')); |
|
156 | 156 | //just copy the bits of EE admin's eei18n that we need in the JS |
157 | 157 | wp_localize_script( |
158 | 158 | 'batch_runner', |
159 | 159 | 'eei18n', |
160 | 160 | array( |
161 | 161 | 'ajax_url' => WP_AJAX_URL, |
162 | - 'is_admin' => (bool)is_admin(), |
|
162 | + 'is_admin' => (bool) is_admin(), |
|
163 | 163 | 'error_message' => esc_html__('An error occurred and the job has been stopped.', 'event_espresso') |
164 | 164 | ) |
165 | 165 | ); |
166 | - $job_handler_classname = stripslashes( $_GET[ 'job_handler' ] ); |
|
166 | + $job_handler_classname = stripslashes($_GET['job_handler']); |
|
167 | 167 | $request_data = array_diff_key( |
168 | 168 | $_REQUEST, |
169 | - array_flip( array( 'action', 'page', 'ee', 'batch' ) ) ); |
|
169 | + array_flip(array('action', 'page', 'ee', 'batch')) ); |
|
170 | 170 | $batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor(); |
171 | 171 | //eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport' |
172 | - $job_response = $batch_runner->create_job( $job_handler_classname, $request_data ); |
|
172 | + $job_response = $batch_runner->create_job($job_handler_classname, $request_data); |
|
173 | 173 | //remember the response for later. We need it to display the page body |
174 | 174 | $this->_job_step_response = $job_response; |
175 | 175 | return $job_response; |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | * @param string $template |
181 | 181 | * @return string |
182 | 182 | */ |
183 | - public function override_template( $template ) { |
|
184 | - if( isset( $_REQUEST[ 'espresso_batch' ] ) && isset( $_REQUEST[ 'batch' ] ) ) { |
|
185 | - return EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_frontend_wrapper.template.html'; |
|
183 | + public function override_template($template) { |
|
184 | + if (isset($_REQUEST['espresso_batch']) && isset($_REQUEST['batch'])) { |
|
185 | + return EE_MODULES.'batch'.DS.'templates'.DS.'batch_frontend_wrapper.template.html'; |
|
186 | 186 | } |
187 | 187 | return $template; |
188 | 188 | } |
@@ -193,11 +193,11 @@ discard block |
||
193 | 193 | public function register_admin_pages() { |
194 | 194 | add_submenu_page( |
195 | 195 | '', //parent slug. we don't want this to actually appear in the menu |
196 | - __( 'Batch Job', 'event_espresso' ), //page title |
|
196 | + __('Batch Job', 'event_espresso'), //page title |
|
197 | 197 | 'n/a', //menu title |
198 | 198 | 'read', //we want this page to actually be accessible to anyone, |
199 | 199 | 'espresso_batch', //menu slug |
200 | - array( self::instance(), 'show_admin_page' ) |
|
200 | + array(self::instance(), 'show_admin_page') |
|
201 | 201 | ); |
202 | 202 | } |
203 | 203 | |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public function show_admin_page() { |
209 | 209 | echo EEH_Template::locate_template( |
210 | - EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_wrapper.template.html', |
|
211 | - array( 'batch_request_type' => $this->batch_request_type() ) |
|
210 | + EE_MODULES.'batch'.DS.'templates'.DS.'batch_wrapper.template.html', |
|
211 | + array('batch_request_type' => $this->batch_request_type()) |
|
212 | 212 | ); |
213 | 213 | } |
214 | 214 | |
@@ -216,10 +216,10 @@ discard block |
||
216 | 216 | * Receives ajax calls for continuing a job |
217 | 217 | */ |
218 | 218 | public function batch_continue() { |
219 | - $job_id = sanitize_text_field( $_REQUEST[ 'job_id' ] ); |
|
219 | + $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
220 | 220 | $batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor(); |
221 | - $response_obj = $batch_runner->continue_job( $job_id); |
|
222 | - $this->_return_json( $response_obj->to_array() ); |
|
221 | + $response_obj = $batch_runner->continue_job($job_id); |
|
222 | + $this->_return_json($response_obj->to_array()); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
@@ -227,10 +227,10 @@ discard block |
||
227 | 227 | * @return type |
228 | 228 | */ |
229 | 229 | public function batch_cleanup() { |
230 | - $job_id = sanitize_text_field( $_REQUEST[ 'job_id' ] ); |
|
230 | + $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
231 | 231 | $batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor(); |
232 | - $response_obj = $batch_runner->cleanup_job( $job_id ); |
|
233 | - $this->_return_json( $response_obj->to_array() ); |
|
232 | + $response_obj = $batch_runner->cleanup_job($job_id); |
|
233 | + $this->_return_json($response_obj->to_array()); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * 'isEEajax' => true,//indicates this is a response from EE |
247 | 247 | * ) |
248 | 248 | */ |
249 | - protected function _return_json( $data ) { |
|
249 | + protected function _return_json($data) { |
|
250 | 250 | $json = array( |
251 | 251 | 'notices' => EE_Error::get_notices(), |
252 | 252 | 'data' => $data, |
@@ -255,10 +255,10 @@ discard block |
||
255 | 255 | |
256 | 256 | |
257 | 257 | // make sure there are no php errors or headers_sent. Then we can set correct json header. |
258 | - if ( NULL === error_get_last() || ! headers_sent() ) { |
|
258 | + if (NULL === error_get_last() || ! headers_sent()) { |
|
259 | 259 | header('Content-Type: application/json; charset=UTF-8'); |
260 | 260 | } |
261 | - echo wp_json_encode( $json ); |
|
261 | + echo wp_json_encode($json); |
|
262 | 262 | exit(); |
263 | 263 | } |
264 | 264 | |
@@ -274,16 +274,16 @@ discard block |
||
274 | 274 | * @return string: EED_Batch::batch_job, EED_Batch::batch_file_job, EED_Batch::batch_not_job |
275 | 275 | */ |
276 | 276 | public function batch_request_type() { |
277 | - if( $this->_batch_request_type === null ) { |
|
278 | - if( isset( $_GET[ 'batch' ] ) ) { |
|
279 | - if( $_GET[ 'batch' ] == self::batch_job ) { |
|
277 | + if ($this->_batch_request_type === null) { |
|
278 | + if (isset($_GET['batch'])) { |
|
279 | + if ($_GET['batch'] == self::batch_job) { |
|
280 | 280 | $this->_batch_request_type = self::batch_job; |
281 | - } elseif( $_GET[ 'batch' ] == self::batch_file_job ) { |
|
281 | + } elseif ($_GET['batch'] == self::batch_file_job) { |
|
282 | 282 | $this->_batch_request_type = self::batch_file_job; |
283 | 283 | } |
284 | 284 | } |
285 | 285 | //if we didn't find that it was a batch request, indicate it wasn't |
286 | - if( $this->_batch_request_type === null ) { |
|
286 | + if ($this->_batch_request_type === null) { |
|
287 | 287 | $this->_batch_request_type = self::batch_not_job; |
288 | 288 | } |
289 | 289 | } |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | * Unnecessary |
295 | 295 | * @param type $WP |
296 | 296 | */ |
297 | - public function run( $WP ) { |
|
297 | + public function run($WP) { |
|
298 | 298 | |
299 | 299 | } |
300 | 300 |
@@ -14,57 +14,57 @@ |
||
14 | 14 | class EES_Espresso_Cancelled extends EES_Shortcode |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * @deprecated 4.9.27 |
|
19 | - * @return void |
|
20 | - */ |
|
21 | - public static function set_hooks() |
|
22 | - { |
|
23 | - } |
|
17 | + /** |
|
18 | + * @deprecated 4.9.27 |
|
19 | + * @return void |
|
20 | + */ |
|
21 | + public static function set_hooks() |
|
22 | + { |
|
23 | + } |
|
24 | 24 | |
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * @deprecated 4.9.27 |
|
29 | - * @return void |
|
30 | - */ |
|
31 | - public static function set_hooks_admin() |
|
32 | - { |
|
33 | - } |
|
27 | + /** |
|
28 | + * @deprecated 4.9.27 |
|
29 | + * @return void |
|
30 | + */ |
|
31 | + public static function set_hooks_admin() |
|
32 | + { |
|
33 | + } |
|
34 | 34 | |
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * @deprecated 4.9.27 |
|
39 | - * @param WP $WP |
|
40 | - * @return void |
|
41 | - */ |
|
42 | - public function run(WP $WP) |
|
43 | - { |
|
44 | - } |
|
37 | + /** |
|
38 | + * @deprecated 4.9.27 |
|
39 | + * @param WP $WP |
|
40 | + * @return void |
|
41 | + */ |
|
42 | + public function run(WP $WP) |
|
43 | + { |
|
44 | + } |
|
45 | 45 | |
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * process_shortcode - ESPRESSO_CANCELLED |
|
50 | - * |
|
51 | - * @deprecated 4.9.27 |
|
52 | - * @param array $attributes |
|
53 | - * @return string |
|
54 | - * @throws \EE_Error |
|
55 | - */ |
|
56 | - public function process_shortcode($attributes = array()) |
|
57 | - { |
|
58 | - \EE_Error::doing_it_wrong( |
|
59 | - __METHOD__, |
|
60 | - __( |
|
61 | - 'Usage is deprecated. Please use \EventEspresso\core\domain\entities\shortcodes\EspressoCancelled instead.', |
|
62 | - 'event_espresso' |
|
63 | - ), |
|
64 | - '4.9.27' |
|
65 | - ); |
|
66 | - return ''; |
|
67 | - } |
|
48 | + /** |
|
49 | + * process_shortcode - ESPRESSO_CANCELLED |
|
50 | + * |
|
51 | + * @deprecated 4.9.27 |
|
52 | + * @param array $attributes |
|
53 | + * @return string |
|
54 | + * @throws \EE_Error |
|
55 | + */ |
|
56 | + public function process_shortcode($attributes = array()) |
|
57 | + { |
|
58 | + \EE_Error::doing_it_wrong( |
|
59 | + __METHOD__, |
|
60 | + __( |
|
61 | + 'Usage is deprecated. Please use \EventEspresso\core\domain\entities\shortcodes\EspressoCancelled instead.', |
|
62 | + 'event_espresso' |
|
63 | + ), |
|
64 | + '4.9.27' |
|
65 | + ); |
|
66 | + return ''; |
|
67 | + } |
|
68 | 68 | |
69 | 69 | } |
70 | 70 | // End of file EES_Espresso_Cancelled.shortcode.php |
@@ -10,8 +10,8 @@ discard block |
||
10 | 10 | class EES_Espresso_Ticket_Selector extends EES_Shortcode { |
11 | 11 | |
12 | 12 | /** |
13 | - * @deprecated 4.9.27 |
|
14 | - * @return void |
|
13 | + * @deprecated 4.9.27 |
|
14 | + * @return void |
|
15 | 15 | */ |
16 | 16 | public static function set_hooks() { |
17 | 17 | } |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | |
20 | 20 | |
21 | 21 | /** |
22 | - * @deprecated 4.9.27 |
|
23 | - * @return void |
|
22 | + * @deprecated 4.9.27 |
|
23 | + * @return void |
|
24 | 24 | */ |
25 | 25 | public static function set_hooks_admin() { |
26 | 26 | } |
@@ -28,29 +28,29 @@ discard block |
||
28 | 28 | |
29 | 29 | |
30 | 30 | /** |
31 | - * @deprecated 4.9.27 |
|
32 | - * @param \WP $WP |
|
31 | + * @deprecated 4.9.27 |
|
32 | + * @param \WP $WP |
|
33 | 33 | */ |
34 | 34 | public function run( WP $WP ) { |
35 | 35 | } |
36 | 36 | |
37 | 37 | |
38 | 38 | /** |
39 | - * @deprecated 4.9.27 |
|
40 | - * @param array $attributes |
|
39 | + * @deprecated 4.9.27 |
|
40 | + * @param array $attributes |
|
41 | 41 | * @return string |
42 | 42 | */ |
43 | 43 | public function process_shortcode( $attributes = array() ) { |
44 | - \EE_Error::doing_it_wrong( |
|
45 | - __METHOD__, |
|
46 | - __( |
|
47 | - 'Usage is deprecated. Please use \EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector instead.', |
|
48 | - 'event_espresso' |
|
49 | - ), |
|
50 | - '4.9.27' |
|
51 | - ); |
|
52 | - return ''; |
|
53 | - } |
|
44 | + \EE_Error::doing_it_wrong( |
|
45 | + __METHOD__, |
|
46 | + __( |
|
47 | + 'Usage is deprecated. Please use \EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector instead.', |
|
48 | + 'event_espresso' |
|
49 | + ), |
|
50 | + '4.9.27' |
|
51 | + ); |
|
52 | + return ''; |
|
53 | + } |
|
54 | 54 | |
55 | 55 | } |
56 | 56 | // End of file EES_Espresso_Ticket_Selector.shortcode.php |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @deprecated 4.9.27 |
32 | 32 | * @param \WP $WP |
33 | 33 | */ |
34 | - public function run( WP $WP ) { |
|
34 | + public function run(WP $WP) { |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @param array $attributes |
41 | 41 | * @return string |
42 | 42 | */ |
43 | - public function process_shortcode( $attributes = array() ) { |
|
43 | + public function process_shortcode($attributes = array()) { |
|
44 | 44 | \EE_Error::doing_it_wrong( |
45 | 45 | __METHOD__, |
46 | 46 | __( |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * EES_Espresso_Ticket_Selector |
4 | 6 | * |
@@ -6,7 +6,6 @@ discard block |
||
6 | 6 | * @package Event Espresso |
7 | 7 | * @subpackage /shortcodes/ |
8 | 8 | * @author Brent Christensen |
9 | - |
|
10 | 9 | * ------------------------------------------------------------------------ |
11 | 10 | */ |
12 | 11 | class EES_Espresso_Checkout extends EES_Shortcode { |
@@ -31,15 +30,15 @@ discard block |
||
31 | 30 | |
32 | 31 | |
33 | 32 | |
34 | - /** |
|
35 | - * run - initial shortcode module setup called during "wp_loaded" hook |
|
36 | - * this method is primarily used for loading resources that will be required by the shortcode when it is actually processed |
|
37 | - * |
|
38 | - * @access public |
|
39 | - * @param WP $WP |
|
40 | - * @return void |
|
41 | - * @throws \EE_Error |
|
42 | - */ |
|
33 | + /** |
|
34 | + * run - initial shortcode module setup called during "wp_loaded" hook |
|
35 | + * this method is primarily used for loading resources that will be required by the shortcode when it is actually processed |
|
36 | + * |
|
37 | + * @access public |
|
38 | + * @param WP $WP |
|
39 | + * @return void |
|
40 | + * @throws \EE_Error |
|
41 | + */ |
|
43 | 42 | public function run( WP $WP ) { |
44 | 43 | } |
45 | 44 | |
@@ -53,16 +52,16 @@ discard block |
||
53 | 52 | * @return string |
54 | 53 | */ |
55 | 54 | public function process_shortcode( $attributes = array() ) { |
56 | - \EE_Error::doing_it_wrong( |
|
57 | - __METHOD__, |
|
58 | - __( |
|
59 | - 'Usage is deprecated. Please use \EventEspresso\core\domain\entities\shortcodes\EspressoCheckout::processShortcode() instead.', |
|
60 | - 'event_espresso' |
|
61 | - ), |
|
62 | - '4.9.27' |
|
63 | - ); |
|
64 | - return ''; |
|
65 | - } |
|
55 | + \EE_Error::doing_it_wrong( |
|
56 | + __METHOD__, |
|
57 | + __( |
|
58 | + 'Usage is deprecated. Please use \EventEspresso\core\domain\entities\shortcodes\EspressoCheckout::processShortcode() instead.', |
|
59 | + 'event_espresso' |
|
60 | + ), |
|
61 | + '4.9.27' |
|
62 | + ); |
|
63 | + return ''; |
|
64 | + } |
|
66 | 65 | |
67 | 66 | } |
68 | 67 | // End of file EES_Espresso_Checkout.shortcode.php |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @return void |
41 | 41 | * @throws \EE_Error |
42 | 42 | */ |
43 | - public function run( WP $WP ) { |
|
43 | + public function run(WP $WP) { |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param array $attributes |
53 | 53 | * @return string |
54 | 54 | */ |
55 | - public function process_shortcode( $attributes = array() ) { |
|
55 | + public function process_shortcode($attributes = array()) { |
|
56 | 56 | \EE_Error::doing_it_wrong( |
57 | 57 | __METHOD__, |
58 | 58 | __( |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * EES_Espresso_Checkout |
4 | 6 | * |