@@ -30,7 +30,7 @@ |
||
30 | 30 | /** |
31 | 31 | * @param RecipeInterface $recipe |
32 | 32 | * @param array $arguments |
33 | - * @return mixed |
|
33 | + * @return boolean |
|
34 | 34 | */ |
35 | 35 | public function brew(RecipeInterface $recipe, $arguments = array()) |
36 | 36 | { |
@@ -18,43 +18,43 @@ |
||
18 | 18 | { |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * @return string |
|
23 | - */ |
|
24 | - public function type() |
|
25 | - { |
|
26 | - return CoffeeMaker::BREW_SHARED; |
|
27 | - } |
|
21 | + /** |
|
22 | + * @return string |
|
23 | + */ |
|
24 | + public function type() |
|
25 | + { |
|
26 | + return CoffeeMaker::BREW_SHARED; |
|
27 | + } |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * @param RecipeInterface $recipe |
|
32 | - * @param array $arguments |
|
33 | - * @return mixed |
|
34 | - */ |
|
35 | - public function brew(RecipeInterface $recipe, $arguments = array()) |
|
36 | - { |
|
37 | - $this->resolveClassAndFilepath($recipe); |
|
38 | - $reflector = $this->injector()->getReflectionClass($recipe->fqcn()); |
|
39 | - $method = $this->resolveInstantiationMethod($reflector); |
|
40 | - switch ($method) { |
|
41 | - case 'instance': |
|
42 | - case 'new_instance': |
|
43 | - case 'new_instance_from_db': |
|
44 | - $service = call_user_func_array( |
|
45 | - array($reflector->getName(), $method), |
|
46 | - $this->injector()->resolveDependencies($recipe, $reflector, $arguments) |
|
47 | - ); |
|
48 | - break; |
|
49 | - case 'newInstance': |
|
50 | - $service = $reflector->newInstance(); |
|
51 | - break; |
|
52 | - case 'newInstanceArgs': |
|
53 | - default: |
|
54 | - $service = $reflector->newInstanceArgs( |
|
55 | - $this->injector()->resolveDependencies($recipe, $reflector, $arguments) |
|
56 | - ); |
|
57 | - } |
|
58 | - return $this->coffeePot()->addService($recipe->identifier(), $service); |
|
59 | - } |
|
30 | + /** |
|
31 | + * @param RecipeInterface $recipe |
|
32 | + * @param array $arguments |
|
33 | + * @return mixed |
|
34 | + */ |
|
35 | + public function brew(RecipeInterface $recipe, $arguments = array()) |
|
36 | + { |
|
37 | + $this->resolveClassAndFilepath($recipe); |
|
38 | + $reflector = $this->injector()->getReflectionClass($recipe->fqcn()); |
|
39 | + $method = $this->resolveInstantiationMethod($reflector); |
|
40 | + switch ($method) { |
|
41 | + case 'instance': |
|
42 | + case 'new_instance': |
|
43 | + case 'new_instance_from_db': |
|
44 | + $service = call_user_func_array( |
|
45 | + array($reflector->getName(), $method), |
|
46 | + $this->injector()->resolveDependencies($recipe, $reflector, $arguments) |
|
47 | + ); |
|
48 | + break; |
|
49 | + case 'newInstance': |
|
50 | + $service = $reflector->newInstance(); |
|
51 | + break; |
|
52 | + case 'newInstanceArgs': |
|
53 | + default: |
|
54 | + $service = $reflector->newInstanceArgs( |
|
55 | + $this->injector()->resolveDependencies($recipe, $reflector, $arguments) |
|
56 | + ); |
|
57 | + } |
|
58 | + return $this->coffeePot()->addService($recipe->identifier(), $service); |
|
59 | + } |
|
60 | 60 | } |
@@ -33,7 +33,7 @@ |
||
33 | 33 | /** |
34 | 34 | * Taken from https://gist.github.com/jaywilliams/119517 |
35 | 35 | * |
36 | - * @param $string |
|
36 | + * @param string $string |
|
37 | 37 | * @return string |
38 | 38 | */ |
39 | 39 | protected function convertAscii($string) |
@@ -2,8 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace EventEspresso\core\services\formatters; |
4 | 4 | |
5 | -use EventEspresso\core\exceptions\InvalidDataTypeException; |
|
6 | - |
|
7 | 5 | /** |
8 | 6 | * Class AsciiOnly |
9 | 7 | * Removes all non-ascii characters from the string |
@@ -15,58 +15,58 @@ |
||
15 | 15 | class AsciiOnly extends FormatterBase |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * Removes all non Ascii characters from string |
|
20 | - * |
|
21 | - * @param string|int|float $input anything easily cast into a string |
|
22 | - * @return string |
|
23 | - */ |
|
24 | - public function format($input) |
|
25 | - { |
|
26 | - // in case an int or float etc was passed in |
|
27 | - $input = (string) $input; |
|
28 | - $input = $this->convertAscii($input); |
|
29 | - return $input; |
|
30 | - } |
|
18 | + /** |
|
19 | + * Removes all non Ascii characters from string |
|
20 | + * |
|
21 | + * @param string|int|float $input anything easily cast into a string |
|
22 | + * @return string |
|
23 | + */ |
|
24 | + public function format($input) |
|
25 | + { |
|
26 | + // in case an int or float etc was passed in |
|
27 | + $input = (string) $input; |
|
28 | + $input = $this->convertAscii($input); |
|
29 | + return $input; |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * Taken from https://gist.github.com/jaywilliams/119517 |
|
35 | - * |
|
36 | - * @param $string |
|
37 | - * @return string |
|
38 | - */ |
|
39 | - protected function convertAscii($string) |
|
40 | - { |
|
41 | - // Replace Single Curly Quotes |
|
42 | - $search[] = chr(226) . chr(128) . chr(152); |
|
43 | - $replace[] = "'"; |
|
44 | - $search[] = chr(226) . chr(128) . chr(153); |
|
45 | - $replace[] = "'"; |
|
46 | - // Replace Smart Double Curly Quotes |
|
47 | - $search[] = chr(226) . chr(128) . chr(156); |
|
48 | - $replace[] = '"'; |
|
49 | - $search[] = chr(226) . chr(128) . chr(157); |
|
50 | - $replace[] = '"'; |
|
51 | - // Replace En Dash |
|
52 | - $search[] = chr(226) . chr(128) . chr(147); |
|
53 | - $replace[] = '--'; |
|
54 | - // Replace Em Dash |
|
55 | - $search[] = chr(226) . chr(128) . chr(148); |
|
56 | - $replace[] = '---'; |
|
57 | - // Replace Bullet |
|
58 | - $search[] = chr(226) . chr(128) . chr(162); |
|
59 | - $replace[] = '*'; |
|
60 | - // Replace Middle Dot |
|
61 | - $search[] = chr(194) . chr(183); |
|
62 | - $replace[] = '*'; |
|
63 | - // Replace Ellipsis with three consecutive dots |
|
64 | - $search[] = chr(226) . chr(128) . chr(166); |
|
65 | - $replace[] = '...'; |
|
66 | - // Apply Replacements |
|
67 | - $string = str_replace($search, $replace, $string); |
|
68 | - // Remove any non-ASCII Characters |
|
69 | - $string = preg_replace("/[^\x01-\x7F]/", "", $string); |
|
70 | - return $string; |
|
71 | - } |
|
33 | + /** |
|
34 | + * Taken from https://gist.github.com/jaywilliams/119517 |
|
35 | + * |
|
36 | + * @param $string |
|
37 | + * @return string |
|
38 | + */ |
|
39 | + protected function convertAscii($string) |
|
40 | + { |
|
41 | + // Replace Single Curly Quotes |
|
42 | + $search[] = chr(226) . chr(128) . chr(152); |
|
43 | + $replace[] = "'"; |
|
44 | + $search[] = chr(226) . chr(128) . chr(153); |
|
45 | + $replace[] = "'"; |
|
46 | + // Replace Smart Double Curly Quotes |
|
47 | + $search[] = chr(226) . chr(128) . chr(156); |
|
48 | + $replace[] = '"'; |
|
49 | + $search[] = chr(226) . chr(128) . chr(157); |
|
50 | + $replace[] = '"'; |
|
51 | + // Replace En Dash |
|
52 | + $search[] = chr(226) . chr(128) . chr(147); |
|
53 | + $replace[] = '--'; |
|
54 | + // Replace Em Dash |
|
55 | + $search[] = chr(226) . chr(128) . chr(148); |
|
56 | + $replace[] = '---'; |
|
57 | + // Replace Bullet |
|
58 | + $search[] = chr(226) . chr(128) . chr(162); |
|
59 | + $replace[] = '*'; |
|
60 | + // Replace Middle Dot |
|
61 | + $search[] = chr(194) . chr(183); |
|
62 | + $replace[] = '*'; |
|
63 | + // Replace Ellipsis with three consecutive dots |
|
64 | + $search[] = chr(226) . chr(128) . chr(166); |
|
65 | + $replace[] = '...'; |
|
66 | + // Apply Replacements |
|
67 | + $string = str_replace($search, $replace, $string); |
|
68 | + // Remove any non-ASCII Characters |
|
69 | + $string = preg_replace("/[^\x01-\x7F]/", "", $string); |
|
70 | + return $string; |
|
71 | + } |
|
72 | 72 | } |
@@ -39,29 +39,29 @@ |
||
39 | 39 | protected function convertAscii($string) |
40 | 40 | { |
41 | 41 | // Replace Single Curly Quotes |
42 | - $search[] = chr(226) . chr(128) . chr(152); |
|
42 | + $search[] = chr(226).chr(128).chr(152); |
|
43 | 43 | $replace[] = "'"; |
44 | - $search[] = chr(226) . chr(128) . chr(153); |
|
44 | + $search[] = chr(226).chr(128).chr(153); |
|
45 | 45 | $replace[] = "'"; |
46 | 46 | // Replace Smart Double Curly Quotes |
47 | - $search[] = chr(226) . chr(128) . chr(156); |
|
47 | + $search[] = chr(226).chr(128).chr(156); |
|
48 | 48 | $replace[] = '"'; |
49 | - $search[] = chr(226) . chr(128) . chr(157); |
|
49 | + $search[] = chr(226).chr(128).chr(157); |
|
50 | 50 | $replace[] = '"'; |
51 | 51 | // Replace En Dash |
52 | - $search[] = chr(226) . chr(128) . chr(147); |
|
52 | + $search[] = chr(226).chr(128).chr(147); |
|
53 | 53 | $replace[] = '--'; |
54 | 54 | // Replace Em Dash |
55 | - $search[] = chr(226) . chr(128) . chr(148); |
|
55 | + $search[] = chr(226).chr(128).chr(148); |
|
56 | 56 | $replace[] = '---'; |
57 | 57 | // Replace Bullet |
58 | - $search[] = chr(226) . chr(128) . chr(162); |
|
58 | + $search[] = chr(226).chr(128).chr(162); |
|
59 | 59 | $replace[] = '*'; |
60 | 60 | // Replace Middle Dot |
61 | - $search[] = chr(194) . chr(183); |
|
61 | + $search[] = chr(194).chr(183); |
|
62 | 62 | $replace[] = '*'; |
63 | 63 | // Replace Ellipsis with three consecutive dots |
64 | - $search[] = chr(226) . chr(128) . chr(166); |
|
64 | + $search[] = chr(226).chr(128).chr(166); |
|
65 | 65 | $replace[] = '...'; |
66 | 66 | // Apply Replacements |
67 | 67 | $string = str_replace($search, $replace, $string); |
@@ -473,7 +473,7 @@ |
||
473 | 473 | * |
474 | 474 | * @param EE_Ticket $ticket |
475 | 475 | * @param int $qty |
476 | - * @return TRUE on success, FALSE on fail |
|
476 | + * @return boolean on success, FALSE on fail |
|
477 | 477 | * @throws InvalidArgumentException |
478 | 478 | * @throws InvalidInterfaceException |
479 | 479 | * @throws InvalidDataTypeException |
@@ -33,529 +33,529 @@ |
||
33 | 33 | class ProcessTicketSelector |
34 | 34 | { |
35 | 35 | |
36 | - /** |
|
37 | - * @var EE_Cart $cart |
|
38 | - */ |
|
39 | - private $cart; |
|
36 | + /** |
|
37 | + * @var EE_Cart $cart |
|
38 | + */ |
|
39 | + private $cart; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @var EE_Core_Config $core_config |
|
43 | - */ |
|
44 | - private $core_config; |
|
41 | + /** |
|
42 | + * @var EE_Core_Config $core_config |
|
43 | + */ |
|
44 | + private $core_config; |
|
45 | 45 | |
46 | - /** |
|
47 | - * @var Request $request |
|
48 | - */ |
|
49 | - private $request; |
|
46 | + /** |
|
47 | + * @var Request $request |
|
48 | + */ |
|
49 | + private $request; |
|
50 | 50 | |
51 | - /** |
|
52 | - * @var EE_Session $session |
|
53 | - */ |
|
54 | - private $session; |
|
51 | + /** |
|
52 | + * @var EE_Session $session |
|
53 | + */ |
|
54 | + private $session; |
|
55 | 55 | |
56 | - /** |
|
57 | - * @var EEM_Ticket $ticket_model |
|
58 | - */ |
|
59 | - private $ticket_model; |
|
56 | + /** |
|
57 | + * @var EEM_Ticket $ticket_model |
|
58 | + */ |
|
59 | + private $ticket_model; |
|
60 | 60 | |
61 | - /** |
|
62 | - * @var TicketDatetimeAvailabilityTracker $tracker |
|
63 | - */ |
|
64 | - private $tracker; |
|
61 | + /** |
|
62 | + * @var TicketDatetimeAvailabilityTracker $tracker |
|
63 | + */ |
|
64 | + private $tracker; |
|
65 | 65 | |
66 | 66 | |
67 | - /** |
|
68 | - * ProcessTicketSelector constructor. |
|
69 | - * NOTE: PLZ use the Loader to instantiate this class if need be |
|
70 | - * so that all dependencies get injected correctly (which will happen automatically) |
|
71 | - * Null values for parameters are only for backwards compatibility but will be removed later on. |
|
72 | - * |
|
73 | - * @param EE_Core_Config $core_config |
|
74 | - * @param Request $request |
|
75 | - * @param EE_Session $session |
|
76 | - * @param EEM_Ticket $ticket_model |
|
77 | - * @param TicketDatetimeAvailabilityTracker $tracker |
|
78 | - * @throws InvalidArgumentException |
|
79 | - * @throws InvalidDataTypeException |
|
80 | - * @throws InvalidInterfaceException |
|
81 | - */ |
|
82 | - public function __construct( |
|
83 | - EE_Core_Config $core_config = null, |
|
84 | - Request $request = null, |
|
85 | - EE_Session $session = null, |
|
86 | - EEM_Ticket $ticket_model = null, |
|
87 | - TicketDatetimeAvailabilityTracker $tracker = null |
|
88 | - ) { |
|
89 | - /** @var LoaderInterface $loader */ |
|
90 | - $loader = LoaderFactory::getLoader(); |
|
91 | - $this->core_config = $core_config instanceof EE_Core_Config |
|
92 | - ? $core_config |
|
93 | - : $loader->getShared('EE_Core_Config'); |
|
94 | - $this->request = $request instanceof Request |
|
95 | - ? $request |
|
96 | - : $loader->getShared('EventEspresso\core\services\request\Request'); |
|
97 | - $this->session = $session instanceof EE_Session |
|
98 | - ? $session |
|
99 | - : $loader->getShared('EE_Session'); |
|
100 | - $this->ticket_model = $ticket_model instanceof EEM_Ticket |
|
101 | - ? $ticket_model |
|
102 | - : $loader->getShared('EEM_Ticket'); |
|
103 | - $this->tracker = $tracker instanceof TicketDatetimeAvailabilityTracker |
|
104 | - ? $tracker |
|
105 | - : $loader->getShared('EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'); |
|
106 | - } |
|
67 | + /** |
|
68 | + * ProcessTicketSelector constructor. |
|
69 | + * NOTE: PLZ use the Loader to instantiate this class if need be |
|
70 | + * so that all dependencies get injected correctly (which will happen automatically) |
|
71 | + * Null values for parameters are only for backwards compatibility but will be removed later on. |
|
72 | + * |
|
73 | + * @param EE_Core_Config $core_config |
|
74 | + * @param Request $request |
|
75 | + * @param EE_Session $session |
|
76 | + * @param EEM_Ticket $ticket_model |
|
77 | + * @param TicketDatetimeAvailabilityTracker $tracker |
|
78 | + * @throws InvalidArgumentException |
|
79 | + * @throws InvalidDataTypeException |
|
80 | + * @throws InvalidInterfaceException |
|
81 | + */ |
|
82 | + public function __construct( |
|
83 | + EE_Core_Config $core_config = null, |
|
84 | + Request $request = null, |
|
85 | + EE_Session $session = null, |
|
86 | + EEM_Ticket $ticket_model = null, |
|
87 | + TicketDatetimeAvailabilityTracker $tracker = null |
|
88 | + ) { |
|
89 | + /** @var LoaderInterface $loader */ |
|
90 | + $loader = LoaderFactory::getLoader(); |
|
91 | + $this->core_config = $core_config instanceof EE_Core_Config |
|
92 | + ? $core_config |
|
93 | + : $loader->getShared('EE_Core_Config'); |
|
94 | + $this->request = $request instanceof Request |
|
95 | + ? $request |
|
96 | + : $loader->getShared('EventEspresso\core\services\request\Request'); |
|
97 | + $this->session = $session instanceof EE_Session |
|
98 | + ? $session |
|
99 | + : $loader->getShared('EE_Session'); |
|
100 | + $this->ticket_model = $ticket_model instanceof EEM_Ticket |
|
101 | + ? $ticket_model |
|
102 | + : $loader->getShared('EEM_Ticket'); |
|
103 | + $this->tracker = $tracker instanceof TicketDatetimeAvailabilityTracker |
|
104 | + ? $tracker |
|
105 | + : $loader->getShared('EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'); |
|
106 | + } |
|
107 | 107 | |
108 | 108 | |
109 | - /** |
|
110 | - * cancelTicketSelections |
|
111 | - * |
|
112 | - * @return bool |
|
113 | - * @throws EE_Error |
|
114 | - * @throws InvalidArgumentException |
|
115 | - * @throws InvalidInterfaceException |
|
116 | - * @throws InvalidDataTypeException |
|
117 | - */ |
|
118 | - public function cancelTicketSelections() |
|
119 | - { |
|
120 | - // check nonce |
|
121 | - if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) { |
|
122 | - return false; |
|
123 | - } |
|
124 | - $this->session->clear_session(__CLASS__, __FUNCTION__); |
|
125 | - if ($this->request->requestParamIsSet('event_id')) { |
|
126 | - EEH_URL::safeRedirectAndExit( |
|
127 | - EEH_Event_View::event_link_url( |
|
128 | - $this->request->getRequestParam('event_id') |
|
129 | - ) |
|
130 | - ); |
|
131 | - } |
|
132 | - EEH_URL::safeRedirectAndExit( |
|
133 | - site_url('/' . $this->core_config->event_cpt_slug . '/') |
|
134 | - ); |
|
135 | - return true; |
|
136 | - } |
|
109 | + /** |
|
110 | + * cancelTicketSelections |
|
111 | + * |
|
112 | + * @return bool |
|
113 | + * @throws EE_Error |
|
114 | + * @throws InvalidArgumentException |
|
115 | + * @throws InvalidInterfaceException |
|
116 | + * @throws InvalidDataTypeException |
|
117 | + */ |
|
118 | + public function cancelTicketSelections() |
|
119 | + { |
|
120 | + // check nonce |
|
121 | + if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) { |
|
122 | + return false; |
|
123 | + } |
|
124 | + $this->session->clear_session(__CLASS__, __FUNCTION__); |
|
125 | + if ($this->request->requestParamIsSet('event_id')) { |
|
126 | + EEH_URL::safeRedirectAndExit( |
|
127 | + EEH_Event_View::event_link_url( |
|
128 | + $this->request->getRequestParam('event_id') |
|
129 | + ) |
|
130 | + ); |
|
131 | + } |
|
132 | + EEH_URL::safeRedirectAndExit( |
|
133 | + site_url('/' . $this->core_config->event_cpt_slug . '/') |
|
134 | + ); |
|
135 | + return true; |
|
136 | + } |
|
137 | 137 | |
138 | 138 | |
139 | - /** |
|
140 | - * processTicketSelectorNonce |
|
141 | - * |
|
142 | - * @param string $nonce_name |
|
143 | - * @param string $id |
|
144 | - * @return bool |
|
145 | - */ |
|
146 | - private function processTicketSelectorNonce($nonce_name, $id = '') |
|
147 | - { |
|
148 | - $nonce_name_with_id = ! empty($id) ? "{$nonce_name}_nonce_{$id}" : "{$nonce_name}_nonce"; |
|
149 | - if ( |
|
150 | - ! $this->request->isAdmin() |
|
151 | - && ( |
|
152 | - ! $this->request->is_set($nonce_name_with_id) |
|
153 | - || ! wp_verify_nonce( |
|
154 | - $this->request->get($nonce_name_with_id), |
|
155 | - $nonce_name |
|
156 | - ) |
|
157 | - ) |
|
158 | - ) { |
|
159 | - EE_Error::add_error( |
|
160 | - sprintf( |
|
161 | - esc_html__( |
|
162 | - 'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', |
|
163 | - 'event_espresso' |
|
164 | - ), |
|
165 | - '<br/>' |
|
166 | - ), |
|
167 | - __FILE__, |
|
168 | - __FUNCTION__, |
|
169 | - __LINE__ |
|
170 | - ); |
|
171 | - return false; |
|
172 | - } |
|
173 | - return true; |
|
174 | - } |
|
139 | + /** |
|
140 | + * processTicketSelectorNonce |
|
141 | + * |
|
142 | + * @param string $nonce_name |
|
143 | + * @param string $id |
|
144 | + * @return bool |
|
145 | + */ |
|
146 | + private function processTicketSelectorNonce($nonce_name, $id = '') |
|
147 | + { |
|
148 | + $nonce_name_with_id = ! empty($id) ? "{$nonce_name}_nonce_{$id}" : "{$nonce_name}_nonce"; |
|
149 | + if ( |
|
150 | + ! $this->request->isAdmin() |
|
151 | + && ( |
|
152 | + ! $this->request->is_set($nonce_name_with_id) |
|
153 | + || ! wp_verify_nonce( |
|
154 | + $this->request->get($nonce_name_with_id), |
|
155 | + $nonce_name |
|
156 | + ) |
|
157 | + ) |
|
158 | + ) { |
|
159 | + EE_Error::add_error( |
|
160 | + sprintf( |
|
161 | + esc_html__( |
|
162 | + 'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', |
|
163 | + 'event_espresso' |
|
164 | + ), |
|
165 | + '<br/>' |
|
166 | + ), |
|
167 | + __FILE__, |
|
168 | + __FUNCTION__, |
|
169 | + __LINE__ |
|
170 | + ); |
|
171 | + return false; |
|
172 | + } |
|
173 | + return true; |
|
174 | + } |
|
175 | 175 | |
176 | 176 | |
177 | - /** |
|
178 | - * process_ticket_selections |
|
179 | - * |
|
180 | - * @return array|bool |
|
181 | - * @throws EE_Error |
|
182 | - * @throws InvalidArgumentException |
|
183 | - * @throws InvalidDataTypeException |
|
184 | - * @throws InvalidInterfaceException |
|
185 | - */ |
|
186 | - public function processTicketSelections() |
|
187 | - { |
|
188 | - do_action('EED_Ticket_Selector__process_ticket_selections__before'); |
|
189 | - if ($this->request->isBot()) { |
|
190 | - EEH_URL::safeRedirectAndExit( |
|
191 | - apply_filters( |
|
192 | - 'FHEE__EE_Ticket_Selector__process_ticket_selections__bot_redirect_url', |
|
193 | - site_url() |
|
194 | - ) |
|
195 | - ); |
|
196 | - } |
|
197 | - // do we have an event id? |
|
198 | - $id = $this->getEventId(); |
|
199 | - // we should really only have 1 registration in the works now |
|
200 | - // (ie, no MER) so unless otherwise requested, clear the session |
|
201 | - if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', true)) { |
|
202 | - $this->session->clear_session(__CLASS__, __FUNCTION__); |
|
203 | - } |
|
204 | - // validate/sanitize/filter data |
|
205 | - $valid = apply_filters( |
|
206 | - 'FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data', |
|
207 | - $this->validatePostData($id) |
|
208 | - ); |
|
209 | - // check total tickets ordered vs max number of attendees that can register |
|
210 | - if (! empty($valid) && $valid['total_tickets'] > $valid['max_atndz']) { |
|
211 | - $this->maxAttendeesViolation($valid); |
|
212 | - } else { |
|
213 | - // all data appears to be valid |
|
214 | - if ($this->processSuccessfulCart($this->addTicketsToCart($valid))) { |
|
215 | - return true; |
|
216 | - } |
|
217 | - } |
|
218 | - // die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT |
|
219 | - // at this point, just return if registration is being made from admin |
|
220 | - if ($this->request->isAdmin() || $this->request->isFrontAjax()) { |
|
221 | - return false; |
|
222 | - } |
|
223 | - if ($valid['return_url']) { |
|
224 | - EEH_URL::safeRedirectAndExit($valid['return_url']); |
|
225 | - } |
|
226 | - if ($id) { |
|
227 | - EEH_URL::safeRedirectAndExit(get_permalink($id)); |
|
228 | - } |
|
229 | - echo EE_Error::get_notices(); |
|
230 | - return false; |
|
231 | - } |
|
177 | + /** |
|
178 | + * process_ticket_selections |
|
179 | + * |
|
180 | + * @return array|bool |
|
181 | + * @throws EE_Error |
|
182 | + * @throws InvalidArgumentException |
|
183 | + * @throws InvalidDataTypeException |
|
184 | + * @throws InvalidInterfaceException |
|
185 | + */ |
|
186 | + public function processTicketSelections() |
|
187 | + { |
|
188 | + do_action('EED_Ticket_Selector__process_ticket_selections__before'); |
|
189 | + if ($this->request->isBot()) { |
|
190 | + EEH_URL::safeRedirectAndExit( |
|
191 | + apply_filters( |
|
192 | + 'FHEE__EE_Ticket_Selector__process_ticket_selections__bot_redirect_url', |
|
193 | + site_url() |
|
194 | + ) |
|
195 | + ); |
|
196 | + } |
|
197 | + // do we have an event id? |
|
198 | + $id = $this->getEventId(); |
|
199 | + // we should really only have 1 registration in the works now |
|
200 | + // (ie, no MER) so unless otherwise requested, clear the session |
|
201 | + if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', true)) { |
|
202 | + $this->session->clear_session(__CLASS__, __FUNCTION__); |
|
203 | + } |
|
204 | + // validate/sanitize/filter data |
|
205 | + $valid = apply_filters( |
|
206 | + 'FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data', |
|
207 | + $this->validatePostData($id) |
|
208 | + ); |
|
209 | + // check total tickets ordered vs max number of attendees that can register |
|
210 | + if (! empty($valid) && $valid['total_tickets'] > $valid['max_atndz']) { |
|
211 | + $this->maxAttendeesViolation($valid); |
|
212 | + } else { |
|
213 | + // all data appears to be valid |
|
214 | + if ($this->processSuccessfulCart($this->addTicketsToCart($valid))) { |
|
215 | + return true; |
|
216 | + } |
|
217 | + } |
|
218 | + // die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT |
|
219 | + // at this point, just return if registration is being made from admin |
|
220 | + if ($this->request->isAdmin() || $this->request->isFrontAjax()) { |
|
221 | + return false; |
|
222 | + } |
|
223 | + if ($valid['return_url']) { |
|
224 | + EEH_URL::safeRedirectAndExit($valid['return_url']); |
|
225 | + } |
|
226 | + if ($id) { |
|
227 | + EEH_URL::safeRedirectAndExit(get_permalink($id)); |
|
228 | + } |
|
229 | + echo EE_Error::get_notices(); |
|
230 | + return false; |
|
231 | + } |
|
232 | 232 | |
233 | 233 | |
234 | - /** |
|
235 | - * @return int |
|
236 | - */ |
|
237 | - private function getEventId() |
|
238 | - { |
|
239 | - // do we have an event id? |
|
240 | - if (! $this->request->requestParamIsSet('tkt-slctr-event-id')) { |
|
241 | - // $_POST['tkt-slctr-event-id'] was not set ?!?!?!? |
|
242 | - EE_Error::add_error( |
|
243 | - sprintf( |
|
244 | - esc_html__( |
|
245 | - 'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', |
|
246 | - 'event_espresso' |
|
247 | - ), |
|
248 | - '<br/>' |
|
249 | - ), |
|
250 | - __FILE__, |
|
251 | - __FUNCTION__, |
|
252 | - __LINE__ |
|
253 | - ); |
|
254 | - } |
|
255 | - // if event id is valid |
|
256 | - return absint($this->request->getRequestParam('tkt-slctr-event-id')); |
|
257 | - } |
|
234 | + /** |
|
235 | + * @return int |
|
236 | + */ |
|
237 | + private function getEventId() |
|
238 | + { |
|
239 | + // do we have an event id? |
|
240 | + if (! $this->request->requestParamIsSet('tkt-slctr-event-id')) { |
|
241 | + // $_POST['tkt-slctr-event-id'] was not set ?!?!?!? |
|
242 | + EE_Error::add_error( |
|
243 | + sprintf( |
|
244 | + esc_html__( |
|
245 | + 'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', |
|
246 | + 'event_espresso' |
|
247 | + ), |
|
248 | + '<br/>' |
|
249 | + ), |
|
250 | + __FILE__, |
|
251 | + __FUNCTION__, |
|
252 | + __LINE__ |
|
253 | + ); |
|
254 | + } |
|
255 | + // if event id is valid |
|
256 | + return absint($this->request->getRequestParam('tkt-slctr-event-id')); |
|
257 | + } |
|
258 | 258 | |
259 | 259 | |
260 | - /** |
|
261 | - * validate_post_data |
|
262 | - * |
|
263 | - * @param int $id |
|
264 | - * @return array |
|
265 | - */ |
|
266 | - private function validatePostData($id = 0) |
|
267 | - { |
|
268 | - if (! $id) { |
|
269 | - EE_Error::add_error( |
|
270 | - esc_html__('The event id provided was not valid.', 'event_espresso'), |
|
271 | - __FILE__, |
|
272 | - __FUNCTION__, |
|
273 | - __LINE__ |
|
274 | - ); |
|
275 | - return array(); |
|
276 | - } |
|
277 | - // start with an empty array() |
|
278 | - $valid_data = array(); |
|
279 | - // grab valid id |
|
280 | - $valid_data['id'] = $id; |
|
281 | - // array of other form names |
|
282 | - $inputs_to_clean = array( |
|
283 | - 'event_id' => 'tkt-slctr-event-id', |
|
284 | - 'max_atndz' => 'tkt-slctr-max-atndz-', |
|
285 | - 'rows' => 'tkt-slctr-rows-', |
|
286 | - 'qty' => 'tkt-slctr-qty-', |
|
287 | - 'ticket_id' => 'tkt-slctr-ticket-id-', |
|
288 | - 'return_url' => 'tkt-slctr-return-url-', |
|
289 | - ); |
|
290 | - // let's track the total number of tickets ordered.' |
|
291 | - $valid_data['total_tickets'] = 0; |
|
292 | - // cycle through $inputs_to_clean array |
|
293 | - foreach ($inputs_to_clean as $what => $input_to_clean) { |
|
294 | - // check for POST data |
|
295 | - if ($this->request->requestParamIsSet($input_to_clean . $id)) { |
|
296 | - // grab value |
|
297 | - $input_value = $this->request->getRequestParam($input_to_clean . $id); |
|
298 | - switch ($what) { |
|
299 | - // integers |
|
300 | - case 'event_id': |
|
301 | - $valid_data[ $what ] = absint($input_value); |
|
302 | - // get event via the event id we put in the form |
|
303 | - break; |
|
304 | - case 'rows': |
|
305 | - case 'max_atndz': |
|
306 | - $valid_data[ $what ] = absint($input_value); |
|
307 | - break; |
|
308 | - // arrays of integers |
|
309 | - case 'qty': |
|
310 | - /** @var array $row_qty */ |
|
311 | - $row_qty = $input_value; |
|
312 | - // if qty is coming from a radio button input, then we need to assemble an array of rows |
|
313 | - if (! is_array($row_qty)) { |
|
314 | - /** @var string $row_qty */ |
|
315 | - // get number of rows |
|
316 | - $rows = $this->request->requestParamIsSet('tkt-slctr-rows-' . $id) |
|
317 | - ? absint($this->request->getRequestParam('tkt-slctr-rows-' . $id)) |
|
318 | - : 1; |
|
319 | - // explode integers by the dash |
|
320 | - $row_qty = explode('-', $row_qty); |
|
321 | - $row = isset($row_qty[0]) ? absint($row_qty[0]) : 1; |
|
322 | - $qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0; |
|
323 | - $row_qty = array($row => $qty); |
|
324 | - for ($x = 1; $x <= $rows; $x++) { |
|
325 | - if (! isset($row_qty[ $x ])) { |
|
326 | - $row_qty[ $x ] = 0; |
|
327 | - } |
|
328 | - } |
|
329 | - } |
|
330 | - ksort($row_qty); |
|
331 | - // cycle thru values |
|
332 | - foreach ($row_qty as $qty) { |
|
333 | - $qty = absint($qty); |
|
334 | - // sanitize as integers |
|
335 | - $valid_data[ $what ][] = $qty; |
|
336 | - $valid_data['total_tickets'] += $qty; |
|
337 | - } |
|
338 | - break; |
|
339 | - // array of integers |
|
340 | - case 'ticket_id': |
|
341 | - // cycle thru values |
|
342 | - foreach ((array) $input_value as $key => $value) { |
|
343 | - // allow only integers |
|
344 | - $valid_data[ $what ][ $key ] = absint($value); |
|
345 | - } |
|
346 | - break; |
|
347 | - case 'return_url': |
|
348 | - // grab and sanitize return-url |
|
349 | - $input_value = esc_url_raw($input_value); |
|
350 | - // was the request coming from an iframe ? if so, then: |
|
351 | - if (strpos($input_value, 'event_list=iframe')) { |
|
352 | - // get anchor fragment |
|
353 | - $input_value = explode('#', $input_value); |
|
354 | - $input_value = end($input_value); |
|
355 | - // use event list url instead, but append anchor |
|
356 | - $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value; |
|
357 | - } |
|
358 | - $valid_data[ $what ] = $input_value; |
|
359 | - break; |
|
360 | - } // end switch $what |
|
361 | - } |
|
362 | - } // end foreach $inputs_to_clean |
|
363 | - return $valid_data; |
|
364 | - } |
|
260 | + /** |
|
261 | + * validate_post_data |
|
262 | + * |
|
263 | + * @param int $id |
|
264 | + * @return array |
|
265 | + */ |
|
266 | + private function validatePostData($id = 0) |
|
267 | + { |
|
268 | + if (! $id) { |
|
269 | + EE_Error::add_error( |
|
270 | + esc_html__('The event id provided was not valid.', 'event_espresso'), |
|
271 | + __FILE__, |
|
272 | + __FUNCTION__, |
|
273 | + __LINE__ |
|
274 | + ); |
|
275 | + return array(); |
|
276 | + } |
|
277 | + // start with an empty array() |
|
278 | + $valid_data = array(); |
|
279 | + // grab valid id |
|
280 | + $valid_data['id'] = $id; |
|
281 | + // array of other form names |
|
282 | + $inputs_to_clean = array( |
|
283 | + 'event_id' => 'tkt-slctr-event-id', |
|
284 | + 'max_atndz' => 'tkt-slctr-max-atndz-', |
|
285 | + 'rows' => 'tkt-slctr-rows-', |
|
286 | + 'qty' => 'tkt-slctr-qty-', |
|
287 | + 'ticket_id' => 'tkt-slctr-ticket-id-', |
|
288 | + 'return_url' => 'tkt-slctr-return-url-', |
|
289 | + ); |
|
290 | + // let's track the total number of tickets ordered.' |
|
291 | + $valid_data['total_tickets'] = 0; |
|
292 | + // cycle through $inputs_to_clean array |
|
293 | + foreach ($inputs_to_clean as $what => $input_to_clean) { |
|
294 | + // check for POST data |
|
295 | + if ($this->request->requestParamIsSet($input_to_clean . $id)) { |
|
296 | + // grab value |
|
297 | + $input_value = $this->request->getRequestParam($input_to_clean . $id); |
|
298 | + switch ($what) { |
|
299 | + // integers |
|
300 | + case 'event_id': |
|
301 | + $valid_data[ $what ] = absint($input_value); |
|
302 | + // get event via the event id we put in the form |
|
303 | + break; |
|
304 | + case 'rows': |
|
305 | + case 'max_atndz': |
|
306 | + $valid_data[ $what ] = absint($input_value); |
|
307 | + break; |
|
308 | + // arrays of integers |
|
309 | + case 'qty': |
|
310 | + /** @var array $row_qty */ |
|
311 | + $row_qty = $input_value; |
|
312 | + // if qty is coming from a radio button input, then we need to assemble an array of rows |
|
313 | + if (! is_array($row_qty)) { |
|
314 | + /** @var string $row_qty */ |
|
315 | + // get number of rows |
|
316 | + $rows = $this->request->requestParamIsSet('tkt-slctr-rows-' . $id) |
|
317 | + ? absint($this->request->getRequestParam('tkt-slctr-rows-' . $id)) |
|
318 | + : 1; |
|
319 | + // explode integers by the dash |
|
320 | + $row_qty = explode('-', $row_qty); |
|
321 | + $row = isset($row_qty[0]) ? absint($row_qty[0]) : 1; |
|
322 | + $qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0; |
|
323 | + $row_qty = array($row => $qty); |
|
324 | + for ($x = 1; $x <= $rows; $x++) { |
|
325 | + if (! isset($row_qty[ $x ])) { |
|
326 | + $row_qty[ $x ] = 0; |
|
327 | + } |
|
328 | + } |
|
329 | + } |
|
330 | + ksort($row_qty); |
|
331 | + // cycle thru values |
|
332 | + foreach ($row_qty as $qty) { |
|
333 | + $qty = absint($qty); |
|
334 | + // sanitize as integers |
|
335 | + $valid_data[ $what ][] = $qty; |
|
336 | + $valid_data['total_tickets'] += $qty; |
|
337 | + } |
|
338 | + break; |
|
339 | + // array of integers |
|
340 | + case 'ticket_id': |
|
341 | + // cycle thru values |
|
342 | + foreach ((array) $input_value as $key => $value) { |
|
343 | + // allow only integers |
|
344 | + $valid_data[ $what ][ $key ] = absint($value); |
|
345 | + } |
|
346 | + break; |
|
347 | + case 'return_url': |
|
348 | + // grab and sanitize return-url |
|
349 | + $input_value = esc_url_raw($input_value); |
|
350 | + // was the request coming from an iframe ? if so, then: |
|
351 | + if (strpos($input_value, 'event_list=iframe')) { |
|
352 | + // get anchor fragment |
|
353 | + $input_value = explode('#', $input_value); |
|
354 | + $input_value = end($input_value); |
|
355 | + // use event list url instead, but append anchor |
|
356 | + $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value; |
|
357 | + } |
|
358 | + $valid_data[ $what ] = $input_value; |
|
359 | + break; |
|
360 | + } // end switch $what |
|
361 | + } |
|
362 | + } // end foreach $inputs_to_clean |
|
363 | + return $valid_data; |
|
364 | + } |
|
365 | 365 | |
366 | 366 | |
367 | - /** |
|
368 | - * @param array $valid |
|
369 | - */ |
|
370 | - private function maxAttendeesViolation(array $valid) |
|
371 | - { |
|
372 | - // ordering too many tickets !!! |
|
373 | - $total_tickets_string = esc_html( |
|
374 | - _n( |
|
375 | - 'You have attempted to purchase %s ticket.', |
|
376 | - 'You have attempted to purchase %s tickets.', |
|
377 | - $valid['total_tickets'], |
|
378 | - 'event_espresso' |
|
379 | - ) |
|
380 | - ); |
|
381 | - $limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']); |
|
382 | - // dev only message |
|
383 | - $max_attendees_string = esc_html( |
|
384 | - _n( |
|
385 | - 'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', |
|
386 | - 'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', |
|
387 | - $valid['max_atndz'], |
|
388 | - 'event_espresso' |
|
389 | - ) |
|
390 | - ); |
|
391 | - $limit_error_2 = sprintf($max_attendees_string, $valid['max_atndz'], $valid['max_atndz']); |
|
392 | - EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__); |
|
393 | - } |
|
367 | + /** |
|
368 | + * @param array $valid |
|
369 | + */ |
|
370 | + private function maxAttendeesViolation(array $valid) |
|
371 | + { |
|
372 | + // ordering too many tickets !!! |
|
373 | + $total_tickets_string = esc_html( |
|
374 | + _n( |
|
375 | + 'You have attempted to purchase %s ticket.', |
|
376 | + 'You have attempted to purchase %s tickets.', |
|
377 | + $valid['total_tickets'], |
|
378 | + 'event_espresso' |
|
379 | + ) |
|
380 | + ); |
|
381 | + $limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']); |
|
382 | + // dev only message |
|
383 | + $max_attendees_string = esc_html( |
|
384 | + _n( |
|
385 | + 'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', |
|
386 | + 'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.', |
|
387 | + $valid['max_atndz'], |
|
388 | + 'event_espresso' |
|
389 | + ) |
|
390 | + ); |
|
391 | + $limit_error_2 = sprintf($max_attendees_string, $valid['max_atndz'], $valid['max_atndz']); |
|
392 | + EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__); |
|
393 | + } |
|
394 | 394 | |
395 | 395 | |
396 | - /** |
|
397 | - * @param array $valid |
|
398 | - * @return int |
|
399 | - * @throws EE_Error |
|
400 | - * @throws InvalidArgumentException |
|
401 | - * @throws InvalidDataTypeException |
|
402 | - * @throws InvalidInterfaceException |
|
403 | - */ |
|
404 | - private function addTicketsToCart(array $valid) |
|
405 | - { |
|
406 | - $tickets_added = 0; |
|
407 | - $tickets_selected = false; |
|
408 | - if (! empty($valid) && $valid['total_tickets'] > 0) { |
|
409 | - // load cart using factory because we don't want to do so until actually needed |
|
410 | - $this->cart = CartFactory::getCart(); |
|
411 | - // cycle thru the number of data rows sent from the event listing |
|
412 | - for ($x = 0; $x < $valid['rows']; $x++) { |
|
413 | - // does this row actually contain a ticket quantity? |
|
414 | - if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) { |
|
415 | - // YES we have a ticket quantity |
|
416 | - $tickets_selected = true; |
|
417 | - $valid_ticket = false; |
|
418 | - // \EEH_Debug_Tools::printr( |
|
419 | - // $valid['ticket_id'][ $x ], |
|
420 | - // '$valid[\'ticket_id\'][ $x ]', |
|
421 | - // __FILE__, __LINE__ |
|
422 | - // ); |
|
423 | - if (isset($valid['ticket_id'][ $x ])) { |
|
424 | - // get ticket via the ticket id we put in the form |
|
425 | - $ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][ $x ]); |
|
426 | - if ($ticket instanceof EE_Ticket) { |
|
427 | - $valid_ticket = true; |
|
428 | - $tickets_added += $this->addTicketToCart( |
|
429 | - $ticket, |
|
430 | - $valid['qty'][ $x ] |
|
431 | - ); |
|
432 | - } |
|
433 | - } |
|
434 | - if ($valid_ticket !== true) { |
|
435 | - // nothing added to cart retrieved |
|
436 | - EE_Error::add_error( |
|
437 | - sprintf( |
|
438 | - esc_html__( |
|
439 | - 'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', |
|
440 | - 'event_espresso' |
|
441 | - ), |
|
442 | - '<br/>' |
|
443 | - ), |
|
444 | - __FILE__, |
|
445 | - __FUNCTION__, |
|
446 | - __LINE__ |
|
447 | - ); |
|
448 | - } |
|
449 | - if (EE_Error::has_error()) { |
|
450 | - break; |
|
451 | - } |
|
452 | - } |
|
453 | - } |
|
454 | - } |
|
455 | - do_action( |
|
456 | - 'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart', |
|
457 | - $this->cart, |
|
458 | - $this |
|
459 | - ); |
|
460 | - if (! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) { |
|
461 | - // no ticket quantities were selected |
|
462 | - EE_Error::add_error( |
|
463 | - esc_html__('You need to select a ticket quantity before you can proceed.', 'event_espresso'), |
|
464 | - __FILE__, |
|
465 | - __FUNCTION__, |
|
466 | - __LINE__ |
|
467 | - ); |
|
468 | - } |
|
469 | - return $tickets_added; |
|
470 | - } |
|
396 | + /** |
|
397 | + * @param array $valid |
|
398 | + * @return int |
|
399 | + * @throws EE_Error |
|
400 | + * @throws InvalidArgumentException |
|
401 | + * @throws InvalidDataTypeException |
|
402 | + * @throws InvalidInterfaceException |
|
403 | + */ |
|
404 | + private function addTicketsToCart(array $valid) |
|
405 | + { |
|
406 | + $tickets_added = 0; |
|
407 | + $tickets_selected = false; |
|
408 | + if (! empty($valid) && $valid['total_tickets'] > 0) { |
|
409 | + // load cart using factory because we don't want to do so until actually needed |
|
410 | + $this->cart = CartFactory::getCart(); |
|
411 | + // cycle thru the number of data rows sent from the event listing |
|
412 | + for ($x = 0; $x < $valid['rows']; $x++) { |
|
413 | + // does this row actually contain a ticket quantity? |
|
414 | + if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) { |
|
415 | + // YES we have a ticket quantity |
|
416 | + $tickets_selected = true; |
|
417 | + $valid_ticket = false; |
|
418 | + // \EEH_Debug_Tools::printr( |
|
419 | + // $valid['ticket_id'][ $x ], |
|
420 | + // '$valid[\'ticket_id\'][ $x ]', |
|
421 | + // __FILE__, __LINE__ |
|
422 | + // ); |
|
423 | + if (isset($valid['ticket_id'][ $x ])) { |
|
424 | + // get ticket via the ticket id we put in the form |
|
425 | + $ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][ $x ]); |
|
426 | + if ($ticket instanceof EE_Ticket) { |
|
427 | + $valid_ticket = true; |
|
428 | + $tickets_added += $this->addTicketToCart( |
|
429 | + $ticket, |
|
430 | + $valid['qty'][ $x ] |
|
431 | + ); |
|
432 | + } |
|
433 | + } |
|
434 | + if ($valid_ticket !== true) { |
|
435 | + // nothing added to cart retrieved |
|
436 | + EE_Error::add_error( |
|
437 | + sprintf( |
|
438 | + esc_html__( |
|
439 | + 'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', |
|
440 | + 'event_espresso' |
|
441 | + ), |
|
442 | + '<br/>' |
|
443 | + ), |
|
444 | + __FILE__, |
|
445 | + __FUNCTION__, |
|
446 | + __LINE__ |
|
447 | + ); |
|
448 | + } |
|
449 | + if (EE_Error::has_error()) { |
|
450 | + break; |
|
451 | + } |
|
452 | + } |
|
453 | + } |
|
454 | + } |
|
455 | + do_action( |
|
456 | + 'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart', |
|
457 | + $this->cart, |
|
458 | + $this |
|
459 | + ); |
|
460 | + if (! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) { |
|
461 | + // no ticket quantities were selected |
|
462 | + EE_Error::add_error( |
|
463 | + esc_html__('You need to select a ticket quantity before you can proceed.', 'event_espresso'), |
|
464 | + __FILE__, |
|
465 | + __FUNCTION__, |
|
466 | + __LINE__ |
|
467 | + ); |
|
468 | + } |
|
469 | + return $tickets_added; |
|
470 | + } |
|
471 | 471 | |
472 | 472 | |
473 | - /** |
|
474 | - * adds a ticket to the cart |
|
475 | - * |
|
476 | - * @param EE_Ticket $ticket |
|
477 | - * @param int $qty |
|
478 | - * @return TRUE on success, FALSE on fail |
|
479 | - * @throws InvalidArgumentException |
|
480 | - * @throws InvalidInterfaceException |
|
481 | - * @throws InvalidDataTypeException |
|
482 | - * @throws EE_Error |
|
483 | - */ |
|
484 | - private function addTicketToCart(EE_Ticket $ticket, $qty = 1) |
|
485 | - { |
|
486 | - // get the number of spaces left for this datetime ticket |
|
487 | - $available_spaces = $this->tracker->ticketDatetimeAvailability($ticket); |
|
488 | - // compare available spaces against the number of tickets being purchased |
|
489 | - if ($available_spaces >= $qty) { |
|
490 | - // allow addons to prevent a ticket from being added to cart |
|
491 | - if ( |
|
492 | - ! apply_filters( |
|
493 | - 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', |
|
494 | - true, |
|
495 | - $ticket, |
|
496 | - $qty, |
|
497 | - $available_spaces |
|
498 | - ) |
|
499 | - ) { |
|
500 | - return false; |
|
501 | - } |
|
502 | - $qty = absint(apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket)); |
|
503 | - // add event to cart |
|
504 | - if ($this->cart->add_ticket_to_cart($ticket, $qty)) { |
|
505 | - $this->tracker->recalculateTicketDatetimeAvailability($ticket, $qty); |
|
506 | - return true; |
|
507 | - } |
|
508 | - return false; |
|
509 | - } |
|
510 | - $this->tracker->processAvailabilityError($ticket, $qty, $this->cart->all_ticket_quantity_count()); |
|
511 | - return false; |
|
512 | - } |
|
473 | + /** |
|
474 | + * adds a ticket to the cart |
|
475 | + * |
|
476 | + * @param EE_Ticket $ticket |
|
477 | + * @param int $qty |
|
478 | + * @return TRUE on success, FALSE on fail |
|
479 | + * @throws InvalidArgumentException |
|
480 | + * @throws InvalidInterfaceException |
|
481 | + * @throws InvalidDataTypeException |
|
482 | + * @throws EE_Error |
|
483 | + */ |
|
484 | + private function addTicketToCart(EE_Ticket $ticket, $qty = 1) |
|
485 | + { |
|
486 | + // get the number of spaces left for this datetime ticket |
|
487 | + $available_spaces = $this->tracker->ticketDatetimeAvailability($ticket); |
|
488 | + // compare available spaces against the number of tickets being purchased |
|
489 | + if ($available_spaces >= $qty) { |
|
490 | + // allow addons to prevent a ticket from being added to cart |
|
491 | + if ( |
|
492 | + ! apply_filters( |
|
493 | + 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', |
|
494 | + true, |
|
495 | + $ticket, |
|
496 | + $qty, |
|
497 | + $available_spaces |
|
498 | + ) |
|
499 | + ) { |
|
500 | + return false; |
|
501 | + } |
|
502 | + $qty = absint(apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket)); |
|
503 | + // add event to cart |
|
504 | + if ($this->cart->add_ticket_to_cart($ticket, $qty)) { |
|
505 | + $this->tracker->recalculateTicketDatetimeAvailability($ticket, $qty); |
|
506 | + return true; |
|
507 | + } |
|
508 | + return false; |
|
509 | + } |
|
510 | + $this->tracker->processAvailabilityError($ticket, $qty, $this->cart->all_ticket_quantity_count()); |
|
511 | + return false; |
|
512 | + } |
|
513 | 513 | |
514 | 514 | |
515 | - /** |
|
516 | - * @param $tickets_added |
|
517 | - * @return bool |
|
518 | - * @throws InvalidInterfaceException |
|
519 | - * @throws InvalidDataTypeException |
|
520 | - * @throws EE_Error |
|
521 | - * @throws InvalidArgumentException |
|
522 | - */ |
|
523 | - private function processSuccessfulCart($tickets_added) |
|
524 | - { |
|
525 | - // exit('KILL REDIRECT BEFORE CART UPDATE'); // <<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE |
|
526 | - if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) { |
|
527 | - // make sure cart is loaded |
|
528 | - if (! $this->cart instanceof EE_Cart) { |
|
529 | - $this->cart = CartFactory::getCart(); |
|
530 | - } |
|
531 | - do_action( |
|
532 | - 'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', |
|
533 | - $this->cart, |
|
534 | - $this |
|
535 | - ); |
|
536 | - $this->cart->recalculate_all_cart_totals(); |
|
537 | - $this->cart->save_cart(false); |
|
538 | - // exit('KILL REDIRECT AFTER CART UPDATE'); // <<<<<<<< OR HERE TO KILL REDIRECT AFTER CART UPDATE |
|
539 | - // just return TRUE for registrations being made from admin |
|
540 | - if ($this->request->isAdmin() || $this->request->isFrontAjax()) { |
|
541 | - return true; |
|
542 | - } |
|
543 | - EEH_URL::safeRedirectAndExit( |
|
544 | - apply_filters( |
|
545 | - 'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', |
|
546 | - $this->core_config->reg_page_url() |
|
547 | - ) |
|
548 | - ); |
|
549 | - } |
|
550 | - if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) { |
|
551 | - // nothing added to cart |
|
552 | - EE_Error::add_attention( |
|
553 | - esc_html__('No tickets were added for the event', 'event_espresso'), |
|
554 | - __FILE__, |
|
555 | - __FUNCTION__, |
|
556 | - __LINE__ |
|
557 | - ); |
|
558 | - } |
|
559 | - return false; |
|
560 | - } |
|
515 | + /** |
|
516 | + * @param $tickets_added |
|
517 | + * @return bool |
|
518 | + * @throws InvalidInterfaceException |
|
519 | + * @throws InvalidDataTypeException |
|
520 | + * @throws EE_Error |
|
521 | + * @throws InvalidArgumentException |
|
522 | + */ |
|
523 | + private function processSuccessfulCart($tickets_added) |
|
524 | + { |
|
525 | + // exit('KILL REDIRECT BEFORE CART UPDATE'); // <<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE |
|
526 | + if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) { |
|
527 | + // make sure cart is loaded |
|
528 | + if (! $this->cart instanceof EE_Cart) { |
|
529 | + $this->cart = CartFactory::getCart(); |
|
530 | + } |
|
531 | + do_action( |
|
532 | + 'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', |
|
533 | + $this->cart, |
|
534 | + $this |
|
535 | + ); |
|
536 | + $this->cart->recalculate_all_cart_totals(); |
|
537 | + $this->cart->save_cart(false); |
|
538 | + // exit('KILL REDIRECT AFTER CART UPDATE'); // <<<<<<<< OR HERE TO KILL REDIRECT AFTER CART UPDATE |
|
539 | + // just return TRUE for registrations being made from admin |
|
540 | + if ($this->request->isAdmin() || $this->request->isFrontAjax()) { |
|
541 | + return true; |
|
542 | + } |
|
543 | + EEH_URL::safeRedirectAndExit( |
|
544 | + apply_filters( |
|
545 | + 'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', |
|
546 | + $this->core_config->reg_page_url() |
|
547 | + ) |
|
548 | + ); |
|
549 | + } |
|
550 | + if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) { |
|
551 | + // nothing added to cart |
|
552 | + EE_Error::add_attention( |
|
553 | + esc_html__('No tickets were added for the event', 'event_espresso'), |
|
554 | + __FILE__, |
|
555 | + __FUNCTION__, |
|
556 | + __LINE__ |
|
557 | + ); |
|
558 | + } |
|
559 | + return false; |
|
560 | + } |
|
561 | 561 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | public function cancelTicketSelections() |
119 | 119 | { |
120 | 120 | // check nonce |
121 | - if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) { |
|
121 | + if ( ! $this->processTicketSelectorNonce('cancel_ticket_selections')) { |
|
122 | 122 | return false; |
123 | 123 | } |
124 | 124 | $this->session->clear_session(__CLASS__, __FUNCTION__); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | ); |
131 | 131 | } |
132 | 132 | EEH_URL::safeRedirectAndExit( |
133 | - site_url('/' . $this->core_config->event_cpt_slug . '/') |
|
133 | + site_url('/'.$this->core_config->event_cpt_slug.'/') |
|
134 | 134 | ); |
135 | 135 | return true; |
136 | 136 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | $this->validatePostData($id) |
208 | 208 | ); |
209 | 209 | // check total tickets ordered vs max number of attendees that can register |
210 | - if (! empty($valid) && $valid['total_tickets'] > $valid['max_atndz']) { |
|
210 | + if ( ! empty($valid) && $valid['total_tickets'] > $valid['max_atndz']) { |
|
211 | 211 | $this->maxAttendeesViolation($valid); |
212 | 212 | } else { |
213 | 213 | // all data appears to be valid |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | private function getEventId() |
238 | 238 | { |
239 | 239 | // do we have an event id? |
240 | - if (! $this->request->requestParamIsSet('tkt-slctr-event-id')) { |
|
240 | + if ( ! $this->request->requestParamIsSet('tkt-slctr-event-id')) { |
|
241 | 241 | // $_POST['tkt-slctr-event-id'] was not set ?!?!?!? |
242 | 242 | EE_Error::add_error( |
243 | 243 | sprintf( |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | */ |
266 | 266 | private function validatePostData($id = 0) |
267 | 267 | { |
268 | - if (! $id) { |
|
268 | + if ( ! $id) { |
|
269 | 269 | EE_Error::add_error( |
270 | 270 | esc_html__('The event id provided was not valid.', 'event_espresso'), |
271 | 271 | __FILE__, |
@@ -292,29 +292,29 @@ discard block |
||
292 | 292 | // cycle through $inputs_to_clean array |
293 | 293 | foreach ($inputs_to_clean as $what => $input_to_clean) { |
294 | 294 | // check for POST data |
295 | - if ($this->request->requestParamIsSet($input_to_clean . $id)) { |
|
295 | + if ($this->request->requestParamIsSet($input_to_clean.$id)) { |
|
296 | 296 | // grab value |
297 | - $input_value = $this->request->getRequestParam($input_to_clean . $id); |
|
297 | + $input_value = $this->request->getRequestParam($input_to_clean.$id); |
|
298 | 298 | switch ($what) { |
299 | 299 | // integers |
300 | 300 | case 'event_id': |
301 | - $valid_data[ $what ] = absint($input_value); |
|
301 | + $valid_data[$what] = absint($input_value); |
|
302 | 302 | // get event via the event id we put in the form |
303 | 303 | break; |
304 | 304 | case 'rows': |
305 | 305 | case 'max_atndz': |
306 | - $valid_data[ $what ] = absint($input_value); |
|
306 | + $valid_data[$what] = absint($input_value); |
|
307 | 307 | break; |
308 | 308 | // arrays of integers |
309 | 309 | case 'qty': |
310 | 310 | /** @var array $row_qty */ |
311 | 311 | $row_qty = $input_value; |
312 | 312 | // if qty is coming from a radio button input, then we need to assemble an array of rows |
313 | - if (! is_array($row_qty)) { |
|
313 | + if ( ! is_array($row_qty)) { |
|
314 | 314 | /** @var string $row_qty */ |
315 | 315 | // get number of rows |
316 | - $rows = $this->request->requestParamIsSet('tkt-slctr-rows-' . $id) |
|
317 | - ? absint($this->request->getRequestParam('tkt-slctr-rows-' . $id)) |
|
316 | + $rows = $this->request->requestParamIsSet('tkt-slctr-rows-'.$id) |
|
317 | + ? absint($this->request->getRequestParam('tkt-slctr-rows-'.$id)) |
|
318 | 318 | : 1; |
319 | 319 | // explode integers by the dash |
320 | 320 | $row_qty = explode('-', $row_qty); |
@@ -322,8 +322,8 @@ discard block |
||
322 | 322 | $qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0; |
323 | 323 | $row_qty = array($row => $qty); |
324 | 324 | for ($x = 1; $x <= $rows; $x++) { |
325 | - if (! isset($row_qty[ $x ])) { |
|
326 | - $row_qty[ $x ] = 0; |
|
325 | + if ( ! isset($row_qty[$x])) { |
|
326 | + $row_qty[$x] = 0; |
|
327 | 327 | } |
328 | 328 | } |
329 | 329 | } |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | foreach ($row_qty as $qty) { |
333 | 333 | $qty = absint($qty); |
334 | 334 | // sanitize as integers |
335 | - $valid_data[ $what ][] = $qty; |
|
335 | + $valid_data[$what][] = $qty; |
|
336 | 336 | $valid_data['total_tickets'] += $qty; |
337 | 337 | } |
338 | 338 | break; |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | // cycle thru values |
342 | 342 | foreach ((array) $input_value as $key => $value) { |
343 | 343 | // allow only integers |
344 | - $valid_data[ $what ][ $key ] = absint($value); |
|
344 | + $valid_data[$what][$key] = absint($value); |
|
345 | 345 | } |
346 | 346 | break; |
347 | 347 | case 'return_url': |
@@ -353,9 +353,9 @@ discard block |
||
353 | 353 | $input_value = explode('#', $input_value); |
354 | 354 | $input_value = end($input_value); |
355 | 355 | // use event list url instead, but append anchor |
356 | - $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value; |
|
356 | + $input_value = EEH_Event_View::event_archive_url().'#'.$input_value; |
|
357 | 357 | } |
358 | - $valid_data[ $what ] = $input_value; |
|
358 | + $valid_data[$what] = $input_value; |
|
359 | 359 | break; |
360 | 360 | } // end switch $what |
361 | 361 | } |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | ) |
390 | 390 | ); |
391 | 391 | $limit_error_2 = sprintf($max_attendees_string, $valid['max_atndz'], $valid['max_atndz']); |
392 | - EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__); |
|
392 | + EE_Error::add_error($limit_error_1.'<br/>'.$limit_error_2, __FILE__, __FUNCTION__, __LINE__); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | |
@@ -405,13 +405,13 @@ discard block |
||
405 | 405 | { |
406 | 406 | $tickets_added = 0; |
407 | 407 | $tickets_selected = false; |
408 | - if (! empty($valid) && $valid['total_tickets'] > 0) { |
|
408 | + if ( ! empty($valid) && $valid['total_tickets'] > 0) { |
|
409 | 409 | // load cart using factory because we don't want to do so until actually needed |
410 | 410 | $this->cart = CartFactory::getCart(); |
411 | 411 | // cycle thru the number of data rows sent from the event listing |
412 | 412 | for ($x = 0; $x < $valid['rows']; $x++) { |
413 | 413 | // does this row actually contain a ticket quantity? |
414 | - if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) { |
|
414 | + if (isset($valid['qty'][$x]) && $valid['qty'][$x] > 0) { |
|
415 | 415 | // YES we have a ticket quantity |
416 | 416 | $tickets_selected = true; |
417 | 417 | $valid_ticket = false; |
@@ -420,14 +420,14 @@ discard block |
||
420 | 420 | // '$valid[\'ticket_id\'][ $x ]', |
421 | 421 | // __FILE__, __LINE__ |
422 | 422 | // ); |
423 | - if (isset($valid['ticket_id'][ $x ])) { |
|
423 | + if (isset($valid['ticket_id'][$x])) { |
|
424 | 424 | // get ticket via the ticket id we put in the form |
425 | - $ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][ $x ]); |
|
425 | + $ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][$x]); |
|
426 | 426 | if ($ticket instanceof EE_Ticket) { |
427 | 427 | $valid_ticket = true; |
428 | 428 | $tickets_added += $this->addTicketToCart( |
429 | 429 | $ticket, |
430 | - $valid['qty'][ $x ] |
|
430 | + $valid['qty'][$x] |
|
431 | 431 | ); |
432 | 432 | } |
433 | 433 | } |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | $this->cart, |
458 | 458 | $this |
459 | 459 | ); |
460 | - if (! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) { |
|
460 | + if ( ! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) { |
|
461 | 461 | // no ticket quantities were selected |
462 | 462 | EE_Error::add_error( |
463 | 463 | esc_html__('You need to select a ticket quantity before you can proceed.', 'event_espresso'), |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | // exit('KILL REDIRECT BEFORE CART UPDATE'); // <<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE |
526 | 526 | if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) { |
527 | 527 | // make sure cart is loaded |
528 | - if (! $this->cart instanceof EE_Cart) { |
|
528 | + if ( ! $this->cart instanceof EE_Cart) { |
|
529 | 529 | $this->cart = CartFactory::getCart(); |
530 | 530 | } |
531 | 531 | do_action( |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | ) |
548 | 548 | ); |
549 | 549 | } |
550 | - if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) { |
|
550 | + if ( ! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) { |
|
551 | 551 | // nothing added to cart |
552 | 552 | EE_Error::add_attention( |
553 | 553 | esc_html__('No tickets were added for the event', 'event_espresso'), |
@@ -13,28 +13,28 @@ |
||
13 | 13 | { |
14 | 14 | |
15 | 15 | |
16 | - /** |
|
17 | - * @param string $name |
|
18 | - * @param array $widget_options |
|
19 | - * @param array $control_options |
|
20 | - */ |
|
21 | - public function __construct($name = '', array $widget_options = array(), array $control_options = array()) |
|
22 | - { |
|
23 | - $id_base = EspressoWidget::getIdBase(get_class($this)); |
|
24 | - $control_options['id_base'] = $id_base; |
|
25 | - $control_options['height'] = isset($control_options['height']) ? $control_options['height'] : 300; |
|
26 | - $control_options['width'] = isset($control_options['width']) ? $control_options['width'] : 350; |
|
27 | - // Register widget with WordPress |
|
28 | - parent::__construct($id_base, $name, $widget_options, $control_options); |
|
29 | - } |
|
16 | + /** |
|
17 | + * @param string $name |
|
18 | + * @param array $widget_options |
|
19 | + * @param array $control_options |
|
20 | + */ |
|
21 | + public function __construct($name = '', array $widget_options = array(), array $control_options = array()) |
|
22 | + { |
|
23 | + $id_base = EspressoWidget::getIdBase(get_class($this)); |
|
24 | + $control_options['id_base'] = $id_base; |
|
25 | + $control_options['height'] = isset($control_options['height']) ? $control_options['height'] : 300; |
|
26 | + $control_options['width'] = isset($control_options['width']) ? $control_options['width'] : 350; |
|
27 | + // Register widget with WordPress |
|
28 | + parent::__construct($id_base, $name, $widget_options, $control_options); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * @param string $widget_class |
|
34 | - * @return string |
|
35 | - */ |
|
36 | - public static function getIdBase($widget_class) |
|
37 | - { |
|
38 | - return sanitize_title(str_replace(array('EEW_', '_'), array('EE_', '-'), $widget_class)) . '-widget'; |
|
39 | - } |
|
32 | + /** |
|
33 | + * @param string $widget_class |
|
34 | + * @return string |
|
35 | + */ |
|
36 | + public static function getIdBase($widget_class) |
|
37 | + { |
|
38 | + return sanitize_title(str_replace(array('EEW_', '_'), array('EE_', '-'), $widget_class)) . '-widget'; |
|
39 | + } |
|
40 | 40 | } |
@@ -35,6 +35,6 @@ |
||
35 | 35 | */ |
36 | 36 | public static function getIdBase($widget_class) |
37 | 37 | { |
38 | - return sanitize_title(str_replace(array('EEW_', '_'), array('EE_', '-'), $widget_class)) . '-widget'; |
|
38 | + return sanitize_title(str_replace(array('EEW_', '_'), array('EE_', '-'), $widget_class)).'-widget'; |
|
39 | 39 | } |
40 | 40 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | '', |
175 | 175 | 'tckt-slctr-tbl-td-qty cntr', |
176 | 176 | '', |
177 | - 'headers="quantity-' . $this->EVT_ID . '"' |
|
177 | + 'headers="quantity-'.$this->EVT_ID.'"' |
|
178 | 178 | ); |
179 | 179 | $this->setTicketStatusDisplay($remaining); |
180 | 180 | if (empty($this->ticket_status_display)) { |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | '', |
241 | 241 | 'tckt-slctr-tbl-td-name', |
242 | 242 | '', |
243 | - 'headers="details-' . $this->EVT_ID . '"' |
|
243 | + 'headers="details-'.$this->EVT_ID.'"' |
|
244 | 244 | ); |
245 | 245 | $html .= EEH_HTML::strong($this->ticket->get_pretty('TKT_name')); |
246 | 246 | $html .= $this->ticket_details->getShowHideLinks(); |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | '', |
275 | 275 | 'tckt-slctr-tbl-td-price jst-rght', |
276 | 276 | '', |
277 | - 'headers="price-' . $this->EVT_ID . '"' |
|
277 | + 'headers="price-'.$this->EVT_ID.'"' |
|
278 | 278 | ); |
279 | 279 | $html .= \EEH_Template::format_currency($this->ticket_price); |
280 | 280 | $html .= $this->ticket->taxable() |
@@ -313,12 +313,12 @@ discard block |
||
313 | 313 | // display submit button since we have tickets available |
314 | 314 | add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
315 | 315 | $this->hidden_input_qty = false; |
316 | - $id = 'ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row; |
|
317 | - $html = '<label class="ee-a11y-screen-reader-text" for="' . $id . '">'; |
|
318 | - $html .= esc_html__('Select this ticket', 'event_espresso') . '</label>'; |
|
319 | - $html .= '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"'; |
|
320 | - $html .= ' id="' . $id . '"'; |
|
321 | - $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"'; |
|
316 | + $id = 'ticket-selector-tbl-qty-slct-'.$this->EVT_ID.'-'.$this->row; |
|
317 | + $html = '<label class="ee-a11y-screen-reader-text" for="'.$id.'">'; |
|
318 | + $html .= esc_html__('Select this ticket', 'event_espresso').'</label>'; |
|
319 | + $html .= '<input type="radio" name="tkt-slctr-qty-'.$this->EVT_ID.'"'; |
|
320 | + $html .= ' id="'.$id.'"'; |
|
321 | + $html .= ' class="ticket-selector-tbl-qty-slct" value="'.$this->row.'-1"'; |
|
322 | 322 | $html .= $this->total_tickets === 1 ? ' checked="checked"' : ''; |
323 | 323 | $html .= ' title=""/>'; |
324 | 324 | return $html; |
@@ -336,11 +336,11 @@ discard block |
||
336 | 336 | // display submit button since we have tickets available |
337 | 337 | add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
338 | 338 | $this->hidden_input_qty = false; |
339 | - $id = 'ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row; |
|
340 | - $html = '<label class="ee-a11y-screen-reader-text" for="' . $id . '">'; |
|
341 | - $html .= esc_html__('Quantity', 'event_espresso') . '</label>'; |
|
342 | - $html .= '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"'; |
|
343 | - $html .= ' id="' . $id . '"'; |
|
339 | + $id = 'ticket-selector-tbl-qty-slct-'.$this->EVT_ID.'-'.$this->row; |
|
340 | + $html = '<label class="ee-a11y-screen-reader-text" for="'.$id.'">'; |
|
341 | + $html .= esc_html__('Quantity', 'event_espresso').'</label>'; |
|
342 | + $html .= '<select name="tkt-slctr-qty-'.$this->EVT_ID.'[]"'; |
|
343 | + $html .= ' id="'.$id.'"'; |
|
344 | 344 | $html .= ' class="ticket-selector-tbl-qty-slct">'; |
345 | 345 | // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased |
346 | 346 | if ($this->min !== 0 && ! $this->ticket->required()) { |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | } |
349 | 349 | // offer ticket quantities from the min to the max |
350 | 350 | for ($i = $this->min; $i <= $this->max; $i++) { |
351 | - $html .= '<option value="' . $i . '"> ' . $i . ' </option>'; |
|
351 | + $html .= '<option value="'.$i.'"> '.$i.' </option>'; |
|
352 | 352 | } |
353 | 353 | $html .= '</select>'; |
354 | 354 | return $html; |
@@ -366,10 +366,10 @@ discard block |
||
366 | 366 | $html = ''; |
367 | 367 | // depending on group reg we need to change the format for qty |
368 | 368 | if ($this->hidden_input_qty) { |
369 | - $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>'; |
|
369 | + $html .= '<input type="hidden" name="tkt-slctr-qty-'.$this->EVT_ID.'[]" value="0"/>'; |
|
370 | 370 | } |
371 | - $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"'; |
|
372 | - $html .= ' value="' . $this->ticket->ID() . '"/>'; |
|
371 | + $html .= '<input type="hidden" name="tkt-slctr-ticket-id-'.$this->EVT_ID.'[]"'; |
|
372 | + $html .= ' value="'.$this->ticket->ID().'"/>'; |
|
373 | 373 | return $html; |
374 | 374 | } |
375 | 375 | } |
@@ -17,356 +17,356 @@ |
||
17 | 17 | class TicketSelectorRowStandard extends TicketSelectorRow |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var TicketDetails $ticket_details |
|
22 | - */ |
|
23 | - protected $ticket_details; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var \EE_Ticket_Selector_Config $template_settings |
|
27 | - */ |
|
28 | - protected $template_settings; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var EE_Tax_Config $tax_settings |
|
32 | - */ |
|
33 | - protected $tax_settings; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var boolean $prices_displayed_including_taxes |
|
37 | - */ |
|
38 | - protected $prices_displayed_including_taxes; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var int $row |
|
42 | - */ |
|
43 | - protected $row; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var int $cols |
|
47 | - */ |
|
48 | - protected $cols; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var boolean $hidden_input_qty |
|
52 | - */ |
|
53 | - protected $hidden_input_qty; |
|
54 | - |
|
55 | - /** |
|
56 | - * @var string $ticket_datetime_classes |
|
57 | - */ |
|
58 | - protected $ticket_datetime_classes; |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * TicketDetails constructor. |
|
63 | - * |
|
64 | - * @param TicketDetails $ticket_details |
|
65 | - * @param EE_Tax_Config $tax_settings |
|
66 | - * @param int $total_tickets |
|
67 | - * @param int $max_attendees |
|
68 | - * @param int $row |
|
69 | - * @param int $cols |
|
70 | - * @param boolean $required_ticket_sold_out |
|
71 | - * @param string $event_status |
|
72 | - * @param string $ticket_datetime_classes |
|
73 | - * @throws EE_Error |
|
74 | - * @throws UnexpectedEntityException |
|
75 | - */ |
|
76 | - public function __construct( |
|
77 | - TicketDetails $ticket_details, |
|
78 | - EE_Tax_Config $tax_settings, |
|
79 | - $total_tickets, |
|
80 | - $max_attendees, |
|
81 | - $row, |
|
82 | - $cols, |
|
83 | - $required_ticket_sold_out, |
|
84 | - $event_status, |
|
85 | - $ticket_datetime_classes |
|
86 | - ) { |
|
87 | - $this->ticket_details = $ticket_details; |
|
88 | - $this->template_settings = $ticket_details->getTemplateSettings(); |
|
89 | - $this->tax_settings = $tax_settings; |
|
90 | - $this->row = $row; |
|
91 | - $this->cols = $cols; |
|
92 | - $this->ticket_datetime_classes = $ticket_datetime_classes; |
|
93 | - parent::__construct( |
|
94 | - $ticket_details->getTicket(), |
|
95 | - $max_attendees, |
|
96 | - $ticket_details->getDateFormat(), |
|
97 | - $event_status, |
|
98 | - $required_ticket_sold_out, |
|
99 | - $total_tickets |
|
100 | - ); |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * other ticket rows will need to know if a required ticket is sold out, |
|
106 | - * so that they are not offered for sale |
|
107 | - * |
|
108 | - * @return boolean |
|
109 | - */ |
|
110 | - public function getRequiredTicketSoldOut() |
|
111 | - { |
|
112 | - return $this->required_ticket_sold_out; |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * @return int |
|
118 | - */ |
|
119 | - public function getCols() |
|
120 | - { |
|
121 | - return $this->cols; |
|
122 | - } |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * getHtml |
|
127 | - * |
|
128 | - * @return string |
|
129 | - * @throws EE_Error |
|
130 | - */ |
|
131 | - public function getHtml() |
|
132 | - { |
|
133 | - $this->min = 0; |
|
134 | - $this->max = $this->ticket->max(); |
|
135 | - $remaining = $this->ticket->remaining(); |
|
136 | - $this->setTicketMinAndMax($remaining); |
|
137 | - // set flag if ticket is required (flag is set to start date so that future tickets are not blocked) |
|
138 | - $this->required_ticket_sold_out = $this->ticket->required() && ! $remaining |
|
139 | - ? $this->ticket->start_date() |
|
140 | - : $this->required_ticket_sold_out; |
|
141 | - $this->setTicketPriceDetails(); |
|
142 | - $this->setTicketStatusClasses($remaining); |
|
143 | - $filtered_row_html = $this->getFilteredRowHtml(); |
|
144 | - if ($filtered_row_html !== false) { |
|
145 | - return $filtered_row_html; |
|
146 | - } |
|
147 | - $ticket_selector_row_html = EEH_HTML::tr( |
|
148 | - '', |
|
149 | - '', |
|
150 | - "tckt-slctr-tbl-tr {$this->status_class}{$this->ticket_datetime_classes} " |
|
151 | - . espresso_get_object_css_class($this->ticket) |
|
152 | - ); |
|
153 | - $filtered_row_content = $this->getFilteredRowContents(); |
|
154 | - if ($filtered_row_content !== false && $this->max_attendees === 1) { |
|
155 | - return $ticket_selector_row_html |
|
156 | - . $filtered_row_content |
|
157 | - . $this->ticketQtyAndIdHiddenInputs() |
|
158 | - . EEH_HTML::trx(); |
|
159 | - } |
|
160 | - if ($filtered_row_content !== false) { |
|
161 | - return $ticket_selector_row_html |
|
162 | - . $filtered_row_content |
|
163 | - . EEH_HTML::trx(); |
|
164 | - } |
|
165 | - $this->hidden_input_qty = $this->max_attendees > 1; |
|
166 | - |
|
167 | - $ticket_selector_row_html .= $this->ticketNameTableCell(); |
|
168 | - $ticket_selector_row_html .= $this->ticketPriceTableCell(); |
|
169 | - $ticket_selector_row_html .= EEH_HTML::td( |
|
170 | - '', |
|
171 | - '', |
|
172 | - 'tckt-slctr-tbl-td-qty cntr', |
|
173 | - '', |
|
174 | - 'headers="quantity-' . $this->EVT_ID . '"' |
|
175 | - ); |
|
176 | - $this->setTicketStatusDisplay($remaining); |
|
177 | - if (empty($this->ticket_status_display)) { |
|
178 | - if ($this->max_attendees === 1) { |
|
179 | - // only ONE attendee is allowed to register at a time |
|
180 | - $ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister(); |
|
181 | - } elseif ($this->max > 0) { |
|
182 | - $ticket_selector_row_html .= $this->ticketQuantitySelector(); |
|
183 | - } |
|
184 | - } |
|
185 | - $ticket_selector_row_html .= $this->ticket_status_display; |
|
186 | - $ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs(); |
|
187 | - $ticket_selector_row_html .= $this->ticket_details->display( |
|
188 | - $this->ticket_price, |
|
189 | - $remaining, |
|
190 | - $this->cols |
|
191 | - ); |
|
192 | - $ticket_selector_row_html .= EEH_HTML::tdx(); |
|
193 | - $ticket_selector_row_html .= EEH_HTML::trx(); |
|
194 | - |
|
195 | - |
|
196 | - $this->row++; |
|
197 | - return $ticket_selector_row_html; |
|
198 | - } |
|
199 | - |
|
200 | - |
|
201 | - /** |
|
202 | - * getTicketPriceDetails |
|
203 | - * |
|
204 | - * @return void |
|
205 | - * @throws EE_Error |
|
206 | - */ |
|
207 | - protected function setTicketPriceDetails() |
|
208 | - { |
|
209 | - $this->ticket_price = $this->tax_settings->prices_displayed_including_taxes |
|
210 | - ? $this->ticket->get_ticket_total_with_taxes() |
|
211 | - : $this->ticket->get_ticket_subtotal(); |
|
212 | - $this->ticket_bundle = false; |
|
213 | - $ticket_min = $this->ticket->min(); |
|
214 | - // for ticket bundles, set min and max qty the same |
|
215 | - if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) { |
|
216 | - $this->ticket_price *= $ticket_min; |
|
217 | - $this->ticket_bundle = true; |
|
218 | - } |
|
219 | - $this->ticket_price = apply_filters( |
|
220 | - 'FHEE__ticket_selector_chart_template__ticket_price', |
|
221 | - $this->ticket_price, |
|
222 | - $this->ticket |
|
223 | - ); |
|
224 | - } |
|
225 | - |
|
226 | - |
|
227 | - /** |
|
228 | - * ticketNameTableCell |
|
229 | - * |
|
230 | - * @return string |
|
231 | - * @throws EE_Error |
|
232 | - */ |
|
233 | - protected function ticketNameTableCell() |
|
234 | - { |
|
235 | - $html = EEH_HTML::td( |
|
236 | - '', |
|
237 | - '', |
|
238 | - 'tckt-slctr-tbl-td-name', |
|
239 | - '', |
|
240 | - 'headers="details-' . $this->EVT_ID . '"' |
|
241 | - ); |
|
242 | - $html .= EEH_HTML::strong($this->ticket->get_pretty('TKT_name')); |
|
243 | - $html .= $this->ticket_details->getShowHideLinks(); |
|
244 | - if ($this->ticket->required()) { |
|
245 | - $html .= EEH_HTML::p( |
|
246 | - apply_filters( |
|
247 | - 'FHEE__ticket_selector_chart_template__ticket_required_message', |
|
248 | - esc_html__('This ticket is required and must be purchased.', 'event_espresso') |
|
249 | - ), |
|
250 | - '', |
|
251 | - 'ticket-required-pg' |
|
252 | - ); |
|
253 | - } |
|
254 | - $html .= EEH_HTML::tdx(); |
|
255 | - return $html; |
|
256 | - } |
|
257 | - |
|
258 | - |
|
259 | - /** |
|
260 | - * ticketPriceTableCell |
|
261 | - * |
|
262 | - * @return string |
|
263 | - * @throws EE_Error |
|
264 | - */ |
|
265 | - protected function ticketPriceTableCell() |
|
266 | - { |
|
267 | - $html = ''; |
|
268 | - if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) { |
|
269 | - $html .= EEH_HTML::td( |
|
270 | - '', |
|
271 | - '', |
|
272 | - 'tckt-slctr-tbl-td-price jst-rght', |
|
273 | - '', |
|
274 | - 'headers="price-' . $this->EVT_ID . '"' |
|
275 | - ); |
|
276 | - $html .= \EEH_Template::format_currency($this->ticket_price); |
|
277 | - $html .= $this->ticket->taxable() |
|
278 | - ? EEH_HTML::span('*', '', 'taxable-tickets-asterisk grey-text') |
|
279 | - : ''; |
|
280 | - $html .= ' '; |
|
281 | - // phpcs:disable WordPress.WP.I18n.NoEmptyStrings |
|
282 | - $html .= EEH_HTML::span( |
|
283 | - $this->ticket_bundle |
|
284 | - ? apply_filters( |
|
285 | - 'FHEE__ticket_selector_chart_template__per_ticket_bundle_text', |
|
286 | - __(' / bundle', 'event_espresso') |
|
287 | - ) |
|
288 | - : apply_filters( |
|
289 | - 'FHEE__ticket_selector_chart_template__per_ticket_text', |
|
290 | - __('', 'event_espresso') |
|
291 | - ), |
|
292 | - '', |
|
293 | - 'smaller-text no-bold' |
|
294 | - ); |
|
295 | - $html .= ' '; |
|
296 | - $html .= EEH_HTML::tdx(); |
|
297 | - $this->cols++; |
|
298 | - } |
|
299 | - return $html; |
|
300 | - } |
|
301 | - |
|
302 | - |
|
303 | - /** |
|
304 | - * onlyOneAttendeeCanRegister |
|
305 | - * |
|
306 | - * @return string |
|
307 | - */ |
|
308 | - protected function onlyOneAttendeeCanRegister() |
|
309 | - { |
|
310 | - // display submit button since we have tickets available |
|
311 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
312 | - $this->hidden_input_qty = false; |
|
313 | - $id = 'ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row; |
|
314 | - $html = '<label class="ee-a11y-screen-reader-text" for="' . $id . '">'; |
|
315 | - $html .= esc_html__('Select this ticket', 'event_espresso') . '</label>'; |
|
316 | - $html .= '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"'; |
|
317 | - $html .= ' id="' . $id . '"'; |
|
318 | - $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"'; |
|
319 | - $html .= $this->total_tickets === 1 ? ' checked="checked"' : ''; |
|
320 | - $html .= ' title=""/>'; |
|
321 | - return $html; |
|
322 | - } |
|
323 | - |
|
324 | - |
|
325 | - /** |
|
326 | - * ticketQuantitySelector |
|
327 | - * |
|
328 | - * @return string |
|
329 | - * @throws EE_Error |
|
330 | - */ |
|
331 | - protected function ticketQuantitySelector() |
|
332 | - { |
|
333 | - // display submit button since we have tickets available |
|
334 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
335 | - $this->hidden_input_qty = false; |
|
336 | - $id = 'ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row; |
|
337 | - $html = '<label class="ee-a11y-screen-reader-text" for="' . $id . '">'; |
|
338 | - $html .= esc_html__('Quantity', 'event_espresso') . '</label>'; |
|
339 | - $html .= '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"'; |
|
340 | - $html .= ' id="' . $id . '"'; |
|
341 | - $html .= ' class="ticket-selector-tbl-qty-slct">'; |
|
342 | - // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased |
|
343 | - if ($this->min !== 0 && ! $this->ticket->required()) { |
|
344 | - $html .= '<option value="0"> 0 </option>'; |
|
345 | - } |
|
346 | - // offer ticket quantities from the min to the max |
|
347 | - for ($i = $this->min; $i <= $this->max; $i++) { |
|
348 | - $html .= '<option value="' . $i . '"> ' . $i . ' </option>'; |
|
349 | - } |
|
350 | - $html .= '</select>'; |
|
351 | - return $html; |
|
352 | - } |
|
353 | - |
|
354 | - |
|
355 | - /** |
|
356 | - * getHiddenInputs |
|
357 | - * |
|
358 | - * @return string |
|
359 | - * @throws EE_Error |
|
360 | - */ |
|
361 | - protected function ticketQtyAndIdHiddenInputs() |
|
362 | - { |
|
363 | - $html = ''; |
|
364 | - // depending on group reg we need to change the format for qty |
|
365 | - if ($this->hidden_input_qty) { |
|
366 | - $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>'; |
|
367 | - } |
|
368 | - $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"'; |
|
369 | - $html .= ' value="' . $this->ticket->ID() . '"/>'; |
|
370 | - return $html; |
|
371 | - } |
|
20 | + /** |
|
21 | + * @var TicketDetails $ticket_details |
|
22 | + */ |
|
23 | + protected $ticket_details; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var \EE_Ticket_Selector_Config $template_settings |
|
27 | + */ |
|
28 | + protected $template_settings; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var EE_Tax_Config $tax_settings |
|
32 | + */ |
|
33 | + protected $tax_settings; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var boolean $prices_displayed_including_taxes |
|
37 | + */ |
|
38 | + protected $prices_displayed_including_taxes; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var int $row |
|
42 | + */ |
|
43 | + protected $row; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var int $cols |
|
47 | + */ |
|
48 | + protected $cols; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var boolean $hidden_input_qty |
|
52 | + */ |
|
53 | + protected $hidden_input_qty; |
|
54 | + |
|
55 | + /** |
|
56 | + * @var string $ticket_datetime_classes |
|
57 | + */ |
|
58 | + protected $ticket_datetime_classes; |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * TicketDetails constructor. |
|
63 | + * |
|
64 | + * @param TicketDetails $ticket_details |
|
65 | + * @param EE_Tax_Config $tax_settings |
|
66 | + * @param int $total_tickets |
|
67 | + * @param int $max_attendees |
|
68 | + * @param int $row |
|
69 | + * @param int $cols |
|
70 | + * @param boolean $required_ticket_sold_out |
|
71 | + * @param string $event_status |
|
72 | + * @param string $ticket_datetime_classes |
|
73 | + * @throws EE_Error |
|
74 | + * @throws UnexpectedEntityException |
|
75 | + */ |
|
76 | + public function __construct( |
|
77 | + TicketDetails $ticket_details, |
|
78 | + EE_Tax_Config $tax_settings, |
|
79 | + $total_tickets, |
|
80 | + $max_attendees, |
|
81 | + $row, |
|
82 | + $cols, |
|
83 | + $required_ticket_sold_out, |
|
84 | + $event_status, |
|
85 | + $ticket_datetime_classes |
|
86 | + ) { |
|
87 | + $this->ticket_details = $ticket_details; |
|
88 | + $this->template_settings = $ticket_details->getTemplateSettings(); |
|
89 | + $this->tax_settings = $tax_settings; |
|
90 | + $this->row = $row; |
|
91 | + $this->cols = $cols; |
|
92 | + $this->ticket_datetime_classes = $ticket_datetime_classes; |
|
93 | + parent::__construct( |
|
94 | + $ticket_details->getTicket(), |
|
95 | + $max_attendees, |
|
96 | + $ticket_details->getDateFormat(), |
|
97 | + $event_status, |
|
98 | + $required_ticket_sold_out, |
|
99 | + $total_tickets |
|
100 | + ); |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * other ticket rows will need to know if a required ticket is sold out, |
|
106 | + * so that they are not offered for sale |
|
107 | + * |
|
108 | + * @return boolean |
|
109 | + */ |
|
110 | + public function getRequiredTicketSoldOut() |
|
111 | + { |
|
112 | + return $this->required_ticket_sold_out; |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * @return int |
|
118 | + */ |
|
119 | + public function getCols() |
|
120 | + { |
|
121 | + return $this->cols; |
|
122 | + } |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * getHtml |
|
127 | + * |
|
128 | + * @return string |
|
129 | + * @throws EE_Error |
|
130 | + */ |
|
131 | + public function getHtml() |
|
132 | + { |
|
133 | + $this->min = 0; |
|
134 | + $this->max = $this->ticket->max(); |
|
135 | + $remaining = $this->ticket->remaining(); |
|
136 | + $this->setTicketMinAndMax($remaining); |
|
137 | + // set flag if ticket is required (flag is set to start date so that future tickets are not blocked) |
|
138 | + $this->required_ticket_sold_out = $this->ticket->required() && ! $remaining |
|
139 | + ? $this->ticket->start_date() |
|
140 | + : $this->required_ticket_sold_out; |
|
141 | + $this->setTicketPriceDetails(); |
|
142 | + $this->setTicketStatusClasses($remaining); |
|
143 | + $filtered_row_html = $this->getFilteredRowHtml(); |
|
144 | + if ($filtered_row_html !== false) { |
|
145 | + return $filtered_row_html; |
|
146 | + } |
|
147 | + $ticket_selector_row_html = EEH_HTML::tr( |
|
148 | + '', |
|
149 | + '', |
|
150 | + "tckt-slctr-tbl-tr {$this->status_class}{$this->ticket_datetime_classes} " |
|
151 | + . espresso_get_object_css_class($this->ticket) |
|
152 | + ); |
|
153 | + $filtered_row_content = $this->getFilteredRowContents(); |
|
154 | + if ($filtered_row_content !== false && $this->max_attendees === 1) { |
|
155 | + return $ticket_selector_row_html |
|
156 | + . $filtered_row_content |
|
157 | + . $this->ticketQtyAndIdHiddenInputs() |
|
158 | + . EEH_HTML::trx(); |
|
159 | + } |
|
160 | + if ($filtered_row_content !== false) { |
|
161 | + return $ticket_selector_row_html |
|
162 | + . $filtered_row_content |
|
163 | + . EEH_HTML::trx(); |
|
164 | + } |
|
165 | + $this->hidden_input_qty = $this->max_attendees > 1; |
|
166 | + |
|
167 | + $ticket_selector_row_html .= $this->ticketNameTableCell(); |
|
168 | + $ticket_selector_row_html .= $this->ticketPriceTableCell(); |
|
169 | + $ticket_selector_row_html .= EEH_HTML::td( |
|
170 | + '', |
|
171 | + '', |
|
172 | + 'tckt-slctr-tbl-td-qty cntr', |
|
173 | + '', |
|
174 | + 'headers="quantity-' . $this->EVT_ID . '"' |
|
175 | + ); |
|
176 | + $this->setTicketStatusDisplay($remaining); |
|
177 | + if (empty($this->ticket_status_display)) { |
|
178 | + if ($this->max_attendees === 1) { |
|
179 | + // only ONE attendee is allowed to register at a time |
|
180 | + $ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister(); |
|
181 | + } elseif ($this->max > 0) { |
|
182 | + $ticket_selector_row_html .= $this->ticketQuantitySelector(); |
|
183 | + } |
|
184 | + } |
|
185 | + $ticket_selector_row_html .= $this->ticket_status_display; |
|
186 | + $ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs(); |
|
187 | + $ticket_selector_row_html .= $this->ticket_details->display( |
|
188 | + $this->ticket_price, |
|
189 | + $remaining, |
|
190 | + $this->cols |
|
191 | + ); |
|
192 | + $ticket_selector_row_html .= EEH_HTML::tdx(); |
|
193 | + $ticket_selector_row_html .= EEH_HTML::trx(); |
|
194 | + |
|
195 | + |
|
196 | + $this->row++; |
|
197 | + return $ticket_selector_row_html; |
|
198 | + } |
|
199 | + |
|
200 | + |
|
201 | + /** |
|
202 | + * getTicketPriceDetails |
|
203 | + * |
|
204 | + * @return void |
|
205 | + * @throws EE_Error |
|
206 | + */ |
|
207 | + protected function setTicketPriceDetails() |
|
208 | + { |
|
209 | + $this->ticket_price = $this->tax_settings->prices_displayed_including_taxes |
|
210 | + ? $this->ticket->get_ticket_total_with_taxes() |
|
211 | + : $this->ticket->get_ticket_subtotal(); |
|
212 | + $this->ticket_bundle = false; |
|
213 | + $ticket_min = $this->ticket->min(); |
|
214 | + // for ticket bundles, set min and max qty the same |
|
215 | + if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) { |
|
216 | + $this->ticket_price *= $ticket_min; |
|
217 | + $this->ticket_bundle = true; |
|
218 | + } |
|
219 | + $this->ticket_price = apply_filters( |
|
220 | + 'FHEE__ticket_selector_chart_template__ticket_price', |
|
221 | + $this->ticket_price, |
|
222 | + $this->ticket |
|
223 | + ); |
|
224 | + } |
|
225 | + |
|
226 | + |
|
227 | + /** |
|
228 | + * ticketNameTableCell |
|
229 | + * |
|
230 | + * @return string |
|
231 | + * @throws EE_Error |
|
232 | + */ |
|
233 | + protected function ticketNameTableCell() |
|
234 | + { |
|
235 | + $html = EEH_HTML::td( |
|
236 | + '', |
|
237 | + '', |
|
238 | + 'tckt-slctr-tbl-td-name', |
|
239 | + '', |
|
240 | + 'headers="details-' . $this->EVT_ID . '"' |
|
241 | + ); |
|
242 | + $html .= EEH_HTML::strong($this->ticket->get_pretty('TKT_name')); |
|
243 | + $html .= $this->ticket_details->getShowHideLinks(); |
|
244 | + if ($this->ticket->required()) { |
|
245 | + $html .= EEH_HTML::p( |
|
246 | + apply_filters( |
|
247 | + 'FHEE__ticket_selector_chart_template__ticket_required_message', |
|
248 | + esc_html__('This ticket is required and must be purchased.', 'event_espresso') |
|
249 | + ), |
|
250 | + '', |
|
251 | + 'ticket-required-pg' |
|
252 | + ); |
|
253 | + } |
|
254 | + $html .= EEH_HTML::tdx(); |
|
255 | + return $html; |
|
256 | + } |
|
257 | + |
|
258 | + |
|
259 | + /** |
|
260 | + * ticketPriceTableCell |
|
261 | + * |
|
262 | + * @return string |
|
263 | + * @throws EE_Error |
|
264 | + */ |
|
265 | + protected function ticketPriceTableCell() |
|
266 | + { |
|
267 | + $html = ''; |
|
268 | + if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) { |
|
269 | + $html .= EEH_HTML::td( |
|
270 | + '', |
|
271 | + '', |
|
272 | + 'tckt-slctr-tbl-td-price jst-rght', |
|
273 | + '', |
|
274 | + 'headers="price-' . $this->EVT_ID . '"' |
|
275 | + ); |
|
276 | + $html .= \EEH_Template::format_currency($this->ticket_price); |
|
277 | + $html .= $this->ticket->taxable() |
|
278 | + ? EEH_HTML::span('*', '', 'taxable-tickets-asterisk grey-text') |
|
279 | + : ''; |
|
280 | + $html .= ' '; |
|
281 | + // phpcs:disable WordPress.WP.I18n.NoEmptyStrings |
|
282 | + $html .= EEH_HTML::span( |
|
283 | + $this->ticket_bundle |
|
284 | + ? apply_filters( |
|
285 | + 'FHEE__ticket_selector_chart_template__per_ticket_bundle_text', |
|
286 | + __(' / bundle', 'event_espresso') |
|
287 | + ) |
|
288 | + : apply_filters( |
|
289 | + 'FHEE__ticket_selector_chart_template__per_ticket_text', |
|
290 | + __('', 'event_espresso') |
|
291 | + ), |
|
292 | + '', |
|
293 | + 'smaller-text no-bold' |
|
294 | + ); |
|
295 | + $html .= ' '; |
|
296 | + $html .= EEH_HTML::tdx(); |
|
297 | + $this->cols++; |
|
298 | + } |
|
299 | + return $html; |
|
300 | + } |
|
301 | + |
|
302 | + |
|
303 | + /** |
|
304 | + * onlyOneAttendeeCanRegister |
|
305 | + * |
|
306 | + * @return string |
|
307 | + */ |
|
308 | + protected function onlyOneAttendeeCanRegister() |
|
309 | + { |
|
310 | + // display submit button since we have tickets available |
|
311 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
312 | + $this->hidden_input_qty = false; |
|
313 | + $id = 'ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row; |
|
314 | + $html = '<label class="ee-a11y-screen-reader-text" for="' . $id . '">'; |
|
315 | + $html .= esc_html__('Select this ticket', 'event_espresso') . '</label>'; |
|
316 | + $html .= '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"'; |
|
317 | + $html .= ' id="' . $id . '"'; |
|
318 | + $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"'; |
|
319 | + $html .= $this->total_tickets === 1 ? ' checked="checked"' : ''; |
|
320 | + $html .= ' title=""/>'; |
|
321 | + return $html; |
|
322 | + } |
|
323 | + |
|
324 | + |
|
325 | + /** |
|
326 | + * ticketQuantitySelector |
|
327 | + * |
|
328 | + * @return string |
|
329 | + * @throws EE_Error |
|
330 | + */ |
|
331 | + protected function ticketQuantitySelector() |
|
332 | + { |
|
333 | + // display submit button since we have tickets available |
|
334 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
335 | + $this->hidden_input_qty = false; |
|
336 | + $id = 'ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row; |
|
337 | + $html = '<label class="ee-a11y-screen-reader-text" for="' . $id . '">'; |
|
338 | + $html .= esc_html__('Quantity', 'event_espresso') . '</label>'; |
|
339 | + $html .= '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"'; |
|
340 | + $html .= ' id="' . $id . '"'; |
|
341 | + $html .= ' class="ticket-selector-tbl-qty-slct">'; |
|
342 | + // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased |
|
343 | + if ($this->min !== 0 && ! $this->ticket->required()) { |
|
344 | + $html .= '<option value="0"> 0 </option>'; |
|
345 | + } |
|
346 | + // offer ticket quantities from the min to the max |
|
347 | + for ($i = $this->min; $i <= $this->max; $i++) { |
|
348 | + $html .= '<option value="' . $i . '"> ' . $i . ' </option>'; |
|
349 | + } |
|
350 | + $html .= '</select>'; |
|
351 | + return $html; |
|
352 | + } |
|
353 | + |
|
354 | + |
|
355 | + /** |
|
356 | + * getHiddenInputs |
|
357 | + * |
|
358 | + * @return string |
|
359 | + * @throws EE_Error |
|
360 | + */ |
|
361 | + protected function ticketQtyAndIdHiddenInputs() |
|
362 | + { |
|
363 | + $html = ''; |
|
364 | + // depending on group reg we need to change the format for qty |
|
365 | + if ($this->hidden_input_qty) { |
|
366 | + $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>'; |
|
367 | + } |
|
368 | + $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"'; |
|
369 | + $html .= ' value="' . $this->ticket->ID() . '"/>'; |
|
370 | + return $html; |
|
371 | + } |
|
372 | 372 | } |
@@ -14,24 +14,24 @@ |
||
14 | 14 | class TicketSelectorIframeEmbedButton extends IframeEmbedButton |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * TicketSelectorIframeEmbedButton constructor. |
|
19 | - */ |
|
20 | - public function __construct() |
|
21 | - { |
|
22 | - parent::__construct( |
|
23 | - esc_html__('Ticket Selector', 'event_espresso'), |
|
24 | - 'ticket_selector' |
|
25 | - ); |
|
26 | - } |
|
17 | + /** |
|
18 | + * TicketSelectorIframeEmbedButton constructor. |
|
19 | + */ |
|
20 | + public function __construct() |
|
21 | + { |
|
22 | + parent::__construct( |
|
23 | + esc_html__('Ticket Selector', 'event_espresso'), |
|
24 | + 'ticket_selector' |
|
25 | + ); |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * Adds an iframe embed code button to the Event editor. |
|
31 | - */ |
|
32 | - public function addEventEditorIframeEmbedButton() |
|
33 | - { |
|
34 | - // add button for iframe code to event editor. |
|
35 | - $this->addEventEditorIframeEmbedButtonFilter(); |
|
36 | - } |
|
29 | + /** |
|
30 | + * Adds an iframe embed code button to the Event editor. |
|
31 | + */ |
|
32 | + public function addEventEditorIframeEmbedButton() |
|
33 | + { |
|
34 | + // add button for iframe code to event editor. |
|
35 | + $this->addEventEditorIframeEmbedButtonFilter(); |
|
36 | + } |
|
37 | 37 | } |
@@ -14,26 +14,26 @@ |
||
14 | 14 | class TicketSelectorRowSimple extends TicketSelectorRow |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * @throws EE_Error |
|
19 | - */ |
|
20 | - public function setupTicketStatusDisplay() |
|
21 | - { |
|
22 | - $remaining = $this->ticket->remaining(); |
|
23 | - $this->setTicketMinAndMax($remaining); |
|
24 | - $this->setTicketStatusClasses($remaining); |
|
25 | - $this->setTicketStatusDisplay($remaining); |
|
26 | - } |
|
17 | + /** |
|
18 | + * @throws EE_Error |
|
19 | + */ |
|
20 | + public function setupTicketStatusDisplay() |
|
21 | + { |
|
22 | + $remaining = $this->ticket->remaining(); |
|
23 | + $this->setTicketMinAndMax($remaining); |
|
24 | + $this->setTicketStatusClasses($remaining); |
|
25 | + $this->setTicketStatusDisplay($remaining); |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | - public function getTicketDescription() |
|
30 | - { |
|
31 | - $filtered_row_content = $this->getFilteredRowContents(); |
|
32 | - if ($filtered_row_content !== false) { |
|
33 | - remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
34 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_false'); |
|
35 | - return $filtered_row_content; |
|
36 | - } |
|
37 | - return $this->ticket->description(); |
|
38 | - } |
|
29 | + public function getTicketDescription() |
|
30 | + { |
|
31 | + $filtered_row_content = $this->getFilteredRowContents(); |
|
32 | + if ($filtered_row_content !== false) { |
|
33 | + remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
34 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_false'); |
|
35 | + return $filtered_row_content; |
|
36 | + } |
|
37 | + return $this->ticket->description(); |
|
38 | + } |
|
39 | 39 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $this |
61 | 61 | ) |
62 | 62 | ); |
63 | - if (! apply_filters('FHEE__EED_Ticket_Selector__ticket_selector_iframe__load_theme_css', false, $this)) { |
|
63 | + if ( ! apply_filters('FHEE__EED_Ticket_Selector__ticket_selector_iframe__load_theme_css', false, $this)) { |
|
64 | 64 | $this->addStylesheets(array('site_theme' => '')); |
65 | 65 | } |
66 | 66 | $this->addScripts( |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | array(), |
80 | 80 | $this |
81 | 81 | ); |
82 | - if (! empty($js_attributes)) { |
|
82 | + if ( ! empty($js_attributes)) { |
|
83 | 83 | $this->addScriptAttributes($js_attributes); |
84 | 84 | } |
85 | 85 | $this->addLocalizedVars( |
@@ -23,83 +23,83 @@ |
||
23 | 23 | class TicketSelectorIframe extends Iframe |
24 | 24 | { |
25 | 25 | |
26 | - /** |
|
27 | - * TicketSelectorIframe constructor. |
|
28 | - * |
|
29 | - * @throws InvalidArgumentException |
|
30 | - * @throws InvalidInterfaceException |
|
31 | - * @throws InvalidDataTypeException |
|
32 | - * @throws DomainException |
|
33 | - * @throws EE_Error |
|
34 | - * @throws ReflectionException |
|
35 | - */ |
|
36 | - public function __construct() |
|
37 | - { |
|
38 | - EE_Registry::instance()->REQ->set_espresso_page(true); |
|
39 | - /** @type \EEM_Event $EEM_Event */ |
|
40 | - $EEM_Event = EE_Registry::instance()->load_model('Event'); |
|
41 | - $event = $EEM_Event->get_one_by_ID( |
|
42 | - EE_Registry::instance()->REQ->get('event', 0) |
|
43 | - ); |
|
44 | - $ticket_selector = LoaderFactory::getLoader()->getShared( |
|
45 | - DisplayTicketSelector::class, |
|
46 | - [null, true] |
|
47 | - ); |
|
48 | - parent::__construct( |
|
49 | - esc_html__('Ticket Selector', 'event_espresso'), |
|
50 | - $ticket_selector->display($event) |
|
51 | - ); |
|
52 | - $this->addStylesheets( |
|
53 | - apply_filters( |
|
54 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
|
55 | - array( |
|
56 | - 'ticket_selector_embed' => TICKET_SELECTOR_ASSETS_URL |
|
57 | - . 'ticket_selector_embed.css?ver=' |
|
58 | - . EVENT_ESPRESSO_VERSION, |
|
59 | - 'ticket_selector' => TICKET_SELECTOR_ASSETS_URL |
|
60 | - . 'ticket_selector.css?ver=' |
|
61 | - . EVENT_ESPRESSO_VERSION, |
|
62 | - ), |
|
63 | - $this |
|
64 | - ) |
|
65 | - ); |
|
66 | - if (! apply_filters('FHEE__EED_Ticket_Selector__ticket_selector_iframe__load_theme_css', false, $this)) { |
|
67 | - $this->addStylesheets(array('site_theme' => '')); |
|
68 | - } |
|
69 | - $this->addScripts( |
|
70 | - apply_filters( |
|
71 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
72 | - array( |
|
73 | - 'ticket_selector_iframe_embed' => TICKET_SELECTOR_ASSETS_URL |
|
74 | - . 'ticket_selector_iframe_embed.js?ver=' |
|
75 | - . EVENT_ESPRESSO_VERSION, |
|
76 | - ), |
|
77 | - $this |
|
78 | - ) |
|
79 | - ); |
|
80 | - $js_attributes = apply_filters( |
|
81 | - 'FHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__js_attributes', |
|
82 | - array(), |
|
83 | - $this |
|
84 | - ); |
|
85 | - if (! empty($js_attributes)) { |
|
86 | - $this->addScriptAttributes($js_attributes); |
|
87 | - } |
|
88 | - $this->addLocalizedVars( |
|
89 | - apply_filters( |
|
90 | - 'FHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__localized_vars', |
|
91 | - array( |
|
92 | - 'ticket_selector_iframe' => true, |
|
93 | - 'EEDTicketSelectorMsg' => __( |
|
94 | - 'Please choose at least one ticket before continuing.', |
|
95 | - 'event_espresso' |
|
96 | - ), |
|
97 | - ) |
|
98 | - ) |
|
99 | - ); |
|
100 | - do_action( |
|
101 | - 'AHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__complete', |
|
102 | - $this |
|
103 | - ); |
|
104 | - } |
|
26 | + /** |
|
27 | + * TicketSelectorIframe constructor. |
|
28 | + * |
|
29 | + * @throws InvalidArgumentException |
|
30 | + * @throws InvalidInterfaceException |
|
31 | + * @throws InvalidDataTypeException |
|
32 | + * @throws DomainException |
|
33 | + * @throws EE_Error |
|
34 | + * @throws ReflectionException |
|
35 | + */ |
|
36 | + public function __construct() |
|
37 | + { |
|
38 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
39 | + /** @type \EEM_Event $EEM_Event */ |
|
40 | + $EEM_Event = EE_Registry::instance()->load_model('Event'); |
|
41 | + $event = $EEM_Event->get_one_by_ID( |
|
42 | + EE_Registry::instance()->REQ->get('event', 0) |
|
43 | + ); |
|
44 | + $ticket_selector = LoaderFactory::getLoader()->getShared( |
|
45 | + DisplayTicketSelector::class, |
|
46 | + [null, true] |
|
47 | + ); |
|
48 | + parent::__construct( |
|
49 | + esc_html__('Ticket Selector', 'event_espresso'), |
|
50 | + $ticket_selector->display($event) |
|
51 | + ); |
|
52 | + $this->addStylesheets( |
|
53 | + apply_filters( |
|
54 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
|
55 | + array( |
|
56 | + 'ticket_selector_embed' => TICKET_SELECTOR_ASSETS_URL |
|
57 | + . 'ticket_selector_embed.css?ver=' |
|
58 | + . EVENT_ESPRESSO_VERSION, |
|
59 | + 'ticket_selector' => TICKET_SELECTOR_ASSETS_URL |
|
60 | + . 'ticket_selector.css?ver=' |
|
61 | + . EVENT_ESPRESSO_VERSION, |
|
62 | + ), |
|
63 | + $this |
|
64 | + ) |
|
65 | + ); |
|
66 | + if (! apply_filters('FHEE__EED_Ticket_Selector__ticket_selector_iframe__load_theme_css', false, $this)) { |
|
67 | + $this->addStylesheets(array('site_theme' => '')); |
|
68 | + } |
|
69 | + $this->addScripts( |
|
70 | + apply_filters( |
|
71 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
72 | + array( |
|
73 | + 'ticket_selector_iframe_embed' => TICKET_SELECTOR_ASSETS_URL |
|
74 | + . 'ticket_selector_iframe_embed.js?ver=' |
|
75 | + . EVENT_ESPRESSO_VERSION, |
|
76 | + ), |
|
77 | + $this |
|
78 | + ) |
|
79 | + ); |
|
80 | + $js_attributes = apply_filters( |
|
81 | + 'FHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__js_attributes', |
|
82 | + array(), |
|
83 | + $this |
|
84 | + ); |
|
85 | + if (! empty($js_attributes)) { |
|
86 | + $this->addScriptAttributes($js_attributes); |
|
87 | + } |
|
88 | + $this->addLocalizedVars( |
|
89 | + apply_filters( |
|
90 | + 'FHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__localized_vars', |
|
91 | + array( |
|
92 | + 'ticket_selector_iframe' => true, |
|
93 | + 'EEDTicketSelectorMsg' => __( |
|
94 | + 'Please choose at least one ticket before continuing.', |
|
95 | + 'event_espresso' |
|
96 | + ), |
|
97 | + ) |
|
98 | + ) |
|
99 | + ); |
|
100 | + do_action( |
|
101 | + 'AHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__complete', |
|
102 | + $this |
|
103 | + ); |
|
104 | + } |
|
105 | 105 | } |
@@ -15,186 +15,186 @@ |
||
15 | 15 | { |
16 | 16 | |
17 | 17 | |
18 | - /** |
|
19 | - * @var \EE_Ticket $ticket |
|
20 | - */ |
|
21 | - protected $ticket; |
|
22 | - |
|
23 | - /** |
|
24 | - * @var \EE_Ticket_Selector_Config $template_settings |
|
25 | - */ |
|
26 | - protected $template_settings; |
|
27 | - |
|
28 | - /** |
|
29 | - * @var string $date_format |
|
30 | - */ |
|
31 | - protected $date_format; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var string $time_format |
|
35 | - */ |
|
36 | - protected $time_format; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var boolean $event_is_expired |
|
40 | - */ |
|
41 | - protected $event_is_expired; |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * TicketDetails constructor. |
|
46 | - * |
|
47 | - * @param \EE_Ticket $ticket |
|
48 | - * @param \EE_Ticket_Selector_Config $template_settings |
|
49 | - * @param array $template_args |
|
50 | - */ |
|
51 | - public function __construct( |
|
52 | - \EE_Ticket $ticket, |
|
53 | - \EE_Ticket_Selector_Config $template_settings, |
|
54 | - array $template_args |
|
55 | - ) { |
|
56 | - $this->ticket = $ticket; |
|
57 | - $this->template_settings = $template_settings; |
|
58 | - $this->date_format = $template_args['date_format']; |
|
59 | - $this->time_format = $template_args['time_format']; |
|
60 | - $this->event_is_expired = $template_args['event_is_expired']; |
|
61 | - } |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * @return \EE_Ticket |
|
66 | - */ |
|
67 | - public function getTicket() |
|
68 | - { |
|
69 | - return $this->ticket; |
|
70 | - } |
|
71 | - |
|
72 | - |
|
73 | - /** |
|
74 | - * @return bool |
|
75 | - */ |
|
76 | - public function showTicketDetails() |
|
77 | - { |
|
78 | - return $this->template_settings->show_ticket_details; |
|
79 | - } |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * @return \EE_Ticket_Selector_Config |
|
84 | - */ |
|
85 | - public function getTemplateSettings() |
|
86 | - { |
|
87 | - return $this->template_settings; |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * @return string |
|
93 | - */ |
|
94 | - public function getDateFormat() |
|
95 | - { |
|
96 | - return $this->date_format; |
|
97 | - } |
|
98 | - |
|
99 | - |
|
100 | - /** |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - public function getTimeFormat() |
|
104 | - { |
|
105 | - return $this->time_format; |
|
106 | - } |
|
107 | - |
|
108 | - |
|
109 | - /** |
|
110 | - * @return string |
|
111 | - */ |
|
112 | - public function getShowHideLinks() |
|
113 | - { |
|
114 | - if (! $this->showTicketDetails()) { |
|
115 | - return ''; |
|
116 | - } |
|
117 | - return \EEH_HTML::link( |
|
118 | - '', |
|
119 | - sprintf(__('show%1$sdetails%1$s+', 'event_espresso'), ' '), |
|
120 | - esc_attr( |
|
121 | - apply_filters( |
|
122 | - 'FHEE__ticket_selector_chart_template__show_ticket_details_link_title', |
|
123 | - __('click to show additional ticket details', 'event_espresso') |
|
124 | - ) |
|
125 | - ), |
|
126 | - "display-{$this->cssId()}", |
|
127 | - 'display-tckt-slctr-tkt-details display-the-hidden lt-grey-text smaller-text hide-if-no-js', |
|
128 | - '', |
|
129 | - 'rel="' . $this->cssId() . '"' |
|
130 | - ) . \EEH_HTML::link( |
|
131 | - '', |
|
132 | - sprintf(__('hide%1$sdetails%1$s-', 'event_espresso'), ' '), |
|
133 | - esc_attr( |
|
134 | - apply_filters( |
|
135 | - 'FHEE__ticket_selector_chart_template__hide_ticket_details_link_title', |
|
136 | - __('click to hide additional ticket details', 'event_espresso') |
|
137 | - ) |
|
138 | - ), |
|
139 | - "hide-{$this->cssId()}", |
|
140 | - 'hide-tckt-slctr-tkt-details hide-the-displayed lt-grey-text smaller-text hide-if-no-js', |
|
141 | - 'display:none;', |
|
142 | - 'rel="' . $this->cssId() . '"' |
|
143 | - ); |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * @return string |
|
149 | - */ |
|
150 | - public function cssId() |
|
151 | - { |
|
152 | - return apply_filters( |
|
153 | - 'FHEE__ticket_selector_chart_template__ticket_details_css_id', |
|
154 | - "tckt-slctr-tkt-details-{$this->ticket->get_event_ID()}-{$this->ticket->ID()}" |
|
155 | - ); |
|
156 | - } |
|
157 | - |
|
158 | - |
|
159 | - /** |
|
160 | - * @param float $ticket_price |
|
161 | - * @param int $remaining |
|
162 | - * @param int $cols |
|
163 | - * @return string |
|
164 | - */ |
|
165 | - public function display( |
|
166 | - $ticket_price = 0.00, |
|
167 | - $remaining, |
|
168 | - $cols = 2 |
|
169 | - ) { |
|
170 | - $template_args = array(); |
|
171 | - $template_args['ticket'] = $this->ticket; |
|
172 | - $template_args['ticket_price'] = $ticket_price; |
|
173 | - $template_args['remaining'] = $remaining; |
|
174 | - $template_args['cols'] = $cols; |
|
175 | - $template_args['show_ticket_details'] = $this->template_settings->show_ticket_details; |
|
176 | - $template_args['show_ticket_sale_columns'] = $this->template_settings->show_ticket_sale_columns; |
|
177 | - $template_args['ticket_details_row_class'] = espresso_get_object_css_class($this->ticket, '', 'details'); |
|
178 | - $template_args['ticket_details_css_id'] = $this->cssId(); |
|
179 | - $template_args['display_ticket_price'] = $ticket_price !== 0 && apply_filters( |
|
180 | - 'FHEE__ticket_selector_chart_template__display_ticket_price_details', |
|
181 | - true |
|
182 | - ); |
|
183 | - $template_args['price_breakdown_heading'] = apply_filters( |
|
184 | - 'FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading', |
|
185 | - esc_html__('Price', 'event_espresso') |
|
186 | - ); |
|
187 | - $template_args['date_format'] = $this->date_format; |
|
188 | - $template_args['time_format'] = $this->time_format; |
|
189 | - $template_args['event_is_expired'] = $this->event_is_expired; |
|
190 | - |
|
191 | - return \EEH_Template::locate_template( |
|
192 | - apply_filters( |
|
193 | - 'FHEE__EventEspresso_modules_ticket_selector_TicketDetails__display__template_path', |
|
194 | - TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_details.template.php', |
|
195 | - $this->ticket |
|
196 | - ), |
|
197 | - $template_args |
|
198 | - ); |
|
199 | - } |
|
18 | + /** |
|
19 | + * @var \EE_Ticket $ticket |
|
20 | + */ |
|
21 | + protected $ticket; |
|
22 | + |
|
23 | + /** |
|
24 | + * @var \EE_Ticket_Selector_Config $template_settings |
|
25 | + */ |
|
26 | + protected $template_settings; |
|
27 | + |
|
28 | + /** |
|
29 | + * @var string $date_format |
|
30 | + */ |
|
31 | + protected $date_format; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var string $time_format |
|
35 | + */ |
|
36 | + protected $time_format; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var boolean $event_is_expired |
|
40 | + */ |
|
41 | + protected $event_is_expired; |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * TicketDetails constructor. |
|
46 | + * |
|
47 | + * @param \EE_Ticket $ticket |
|
48 | + * @param \EE_Ticket_Selector_Config $template_settings |
|
49 | + * @param array $template_args |
|
50 | + */ |
|
51 | + public function __construct( |
|
52 | + \EE_Ticket $ticket, |
|
53 | + \EE_Ticket_Selector_Config $template_settings, |
|
54 | + array $template_args |
|
55 | + ) { |
|
56 | + $this->ticket = $ticket; |
|
57 | + $this->template_settings = $template_settings; |
|
58 | + $this->date_format = $template_args['date_format']; |
|
59 | + $this->time_format = $template_args['time_format']; |
|
60 | + $this->event_is_expired = $template_args['event_is_expired']; |
|
61 | + } |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * @return \EE_Ticket |
|
66 | + */ |
|
67 | + public function getTicket() |
|
68 | + { |
|
69 | + return $this->ticket; |
|
70 | + } |
|
71 | + |
|
72 | + |
|
73 | + /** |
|
74 | + * @return bool |
|
75 | + */ |
|
76 | + public function showTicketDetails() |
|
77 | + { |
|
78 | + return $this->template_settings->show_ticket_details; |
|
79 | + } |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * @return \EE_Ticket_Selector_Config |
|
84 | + */ |
|
85 | + public function getTemplateSettings() |
|
86 | + { |
|
87 | + return $this->template_settings; |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * @return string |
|
93 | + */ |
|
94 | + public function getDateFormat() |
|
95 | + { |
|
96 | + return $this->date_format; |
|
97 | + } |
|
98 | + |
|
99 | + |
|
100 | + /** |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + public function getTimeFormat() |
|
104 | + { |
|
105 | + return $this->time_format; |
|
106 | + } |
|
107 | + |
|
108 | + |
|
109 | + /** |
|
110 | + * @return string |
|
111 | + */ |
|
112 | + public function getShowHideLinks() |
|
113 | + { |
|
114 | + if (! $this->showTicketDetails()) { |
|
115 | + return ''; |
|
116 | + } |
|
117 | + return \EEH_HTML::link( |
|
118 | + '', |
|
119 | + sprintf(__('show%1$sdetails%1$s+', 'event_espresso'), ' '), |
|
120 | + esc_attr( |
|
121 | + apply_filters( |
|
122 | + 'FHEE__ticket_selector_chart_template__show_ticket_details_link_title', |
|
123 | + __('click to show additional ticket details', 'event_espresso') |
|
124 | + ) |
|
125 | + ), |
|
126 | + "display-{$this->cssId()}", |
|
127 | + 'display-tckt-slctr-tkt-details display-the-hidden lt-grey-text smaller-text hide-if-no-js', |
|
128 | + '', |
|
129 | + 'rel="' . $this->cssId() . '"' |
|
130 | + ) . \EEH_HTML::link( |
|
131 | + '', |
|
132 | + sprintf(__('hide%1$sdetails%1$s-', 'event_espresso'), ' '), |
|
133 | + esc_attr( |
|
134 | + apply_filters( |
|
135 | + 'FHEE__ticket_selector_chart_template__hide_ticket_details_link_title', |
|
136 | + __('click to hide additional ticket details', 'event_espresso') |
|
137 | + ) |
|
138 | + ), |
|
139 | + "hide-{$this->cssId()}", |
|
140 | + 'hide-tckt-slctr-tkt-details hide-the-displayed lt-grey-text smaller-text hide-if-no-js', |
|
141 | + 'display:none;', |
|
142 | + 'rel="' . $this->cssId() . '"' |
|
143 | + ); |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * @return string |
|
149 | + */ |
|
150 | + public function cssId() |
|
151 | + { |
|
152 | + return apply_filters( |
|
153 | + 'FHEE__ticket_selector_chart_template__ticket_details_css_id', |
|
154 | + "tckt-slctr-tkt-details-{$this->ticket->get_event_ID()}-{$this->ticket->ID()}" |
|
155 | + ); |
|
156 | + } |
|
157 | + |
|
158 | + |
|
159 | + /** |
|
160 | + * @param float $ticket_price |
|
161 | + * @param int $remaining |
|
162 | + * @param int $cols |
|
163 | + * @return string |
|
164 | + */ |
|
165 | + public function display( |
|
166 | + $ticket_price = 0.00, |
|
167 | + $remaining, |
|
168 | + $cols = 2 |
|
169 | + ) { |
|
170 | + $template_args = array(); |
|
171 | + $template_args['ticket'] = $this->ticket; |
|
172 | + $template_args['ticket_price'] = $ticket_price; |
|
173 | + $template_args['remaining'] = $remaining; |
|
174 | + $template_args['cols'] = $cols; |
|
175 | + $template_args['show_ticket_details'] = $this->template_settings->show_ticket_details; |
|
176 | + $template_args['show_ticket_sale_columns'] = $this->template_settings->show_ticket_sale_columns; |
|
177 | + $template_args['ticket_details_row_class'] = espresso_get_object_css_class($this->ticket, '', 'details'); |
|
178 | + $template_args['ticket_details_css_id'] = $this->cssId(); |
|
179 | + $template_args['display_ticket_price'] = $ticket_price !== 0 && apply_filters( |
|
180 | + 'FHEE__ticket_selector_chart_template__display_ticket_price_details', |
|
181 | + true |
|
182 | + ); |
|
183 | + $template_args['price_breakdown_heading'] = apply_filters( |
|
184 | + 'FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading', |
|
185 | + esc_html__('Price', 'event_espresso') |
|
186 | + ); |
|
187 | + $template_args['date_format'] = $this->date_format; |
|
188 | + $template_args['time_format'] = $this->time_format; |
|
189 | + $template_args['event_is_expired'] = $this->event_is_expired; |
|
190 | + |
|
191 | + return \EEH_Template::locate_template( |
|
192 | + apply_filters( |
|
193 | + 'FHEE__EventEspresso_modules_ticket_selector_TicketDetails__display__template_path', |
|
194 | + TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_details.template.php', |
|
195 | + $this->ticket |
|
196 | + ), |
|
197 | + $template_args |
|
198 | + ); |
|
199 | + } |
|
200 | 200 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function getShowHideLinks() |
113 | 113 | { |
114 | - if (! $this->showTicketDetails()) { |
|
114 | + if ( ! $this->showTicketDetails()) { |
|
115 | 115 | return ''; |
116 | 116 | } |
117 | 117 | return \EEH_HTML::link( |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | "display-{$this->cssId()}", |
127 | 127 | 'display-tckt-slctr-tkt-details display-the-hidden lt-grey-text smaller-text hide-if-no-js', |
128 | 128 | '', |
129 | - 'rel="' . $this->cssId() . '"' |
|
130 | - ) . \EEH_HTML::link( |
|
129 | + 'rel="'.$this->cssId().'"' |
|
130 | + ).\EEH_HTML::link( |
|
131 | 131 | '', |
132 | 132 | sprintf(__('hide%1$sdetails%1$s-', 'event_espresso'), ' '), |
133 | 133 | esc_attr( |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | "hide-{$this->cssId()}", |
140 | 140 | 'hide-tckt-slctr-tkt-details hide-the-displayed lt-grey-text smaller-text hide-if-no-js', |
141 | 141 | 'display:none;', |
142 | - 'rel="' . $this->cssId() . '"' |
|
142 | + 'rel="'.$this->cssId().'"' |
|
143 | 143 | ); |
144 | 144 | } |
145 | 145 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | return \EEH_Template::locate_template( |
192 | 192 | apply_filters( |
193 | 193 | 'FHEE__EventEspresso_modules_ticket_selector_TicketDetails__display__template_path', |
194 | - TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_details.template.php', |
|
194 | + TICKET_SELECTOR_TEMPLATES_PATH.'ticket_details.template.php', |
|
195 | 195 | $this->ticket |
196 | 196 | ), |
197 | 197 | $template_args |