@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public static function set_definitions() |
143 | 143 | { |
144 | - define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS); |
|
145 | - define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS); |
|
144 | + define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
145 | + define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | { |
334 | 334 | wp_register_script( |
335 | 335 | 'thank_you_page', |
336 | - THANK_YOU_ASSETS_URL . 'thank_you_page.js', |
|
336 | + THANK_YOU_ASSETS_URL.'thank_you_page.js', |
|
337 | 337 | array('espresso_core', 'heartbeat'), |
338 | 338 | EVENT_ESPRESSO_VERSION, |
339 | 339 | true |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | $this->_get_reg_url_link(); |
355 | 355 | if ( ! $this->get_txn()) { |
356 | 356 | echo EEH_HTML::div( |
357 | - EEH_HTML::h4(__('We\'re sorry...', 'event_espresso'), '', '') . |
|
357 | + EEH_HTML::h4(__('We\'re sorry...', 'event_espresso'), '', ''). |
|
358 | 358 | sprintf( |
359 | 359 | __( |
360 | 360 | 'This is a system page for displaying transaction information after a purchase.%1$sYou are most likely seeing this notice because you have navigated to this page%1$sthrough some means other than completing a transaction.%1$sSorry for the disappointment, but you will most likely find nothing of interest here.%1$s%1$s', |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_ajax_content')); |
470 | 470 | } |
471 | 471 | return EEH_Template::locate_template( |
472 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-overview.template.php', |
|
472 | + THANK_YOU_TEMPLATES_PATH.'thank-you-page-overview.template.php', |
|
473 | 473 | $template_args, |
474 | 474 | true, |
475 | 475 | true |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | '$SPCO_attendee_information_url' |
637 | 637 | ); |
638 | 638 | echo EEH_Template::locate_template( |
639 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-registration-details.template.php', |
|
639 | + THANK_YOU_TEMPLATES_PATH.'thank-you-page-registration-details.template.php', |
|
640 | 640 | $template_args, |
641 | 641 | true, |
642 | 642 | true |
@@ -844,7 +844,7 @@ discard block |
||
844 | 844 | '$SPCO_payment_options_url' |
845 | 845 | ); |
846 | 846 | return EEH_Template::locate_template( |
847 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-transaction-details.template.php', |
|
847 | + THANK_YOU_TEMPLATES_PATH.'thank-you-page-transaction-details.template.php', |
|
848 | 848 | $template_args, |
849 | 849 | true, |
850 | 850 | true |
@@ -875,25 +875,25 @@ discard block |
||
875 | 875 | $payment->set_status(EEM_Payment::status_id_pending); |
876 | 876 | } |
877 | 877 | $payment_declined_msg = $payment->STS_ID() === EEM_Payment::status_id_declined |
878 | - ? '<br /><span class="small-text">' . $payment->gateway_response() . '</span>' |
|
878 | + ? '<br /><span class="small-text">'.$payment->gateway_response().'</span>' |
|
879 | 879 | : ''; |
880 | 880 | $html .= ' |
881 | 881 | <tr> |
882 | 882 | <td> |
883 | - ' . $payment->timestamp() . ' |
|
883 | + ' . $payment->timestamp().' |
|
884 | 884 | </td> |
885 | 885 | <td> |
886 | 886 | ' . ( |
887 | 887 | $payment->payment_method() instanceof EE_Payment_Method |
888 | 888 | ? $payment->payment_method()->name() |
889 | 889 | : __('Unknown', 'event_espresso') |
890 | - ) . ' |
|
890 | + ).' |
|
891 | 891 | </td> |
892 | 892 | <td class="jst-rght"> |
893 | - ' . EEH_Template::format_currency($payment->amount()) . ' |
|
893 | + ' . EEH_Template::format_currency($payment->amount()).' |
|
894 | 894 | </td> |
895 | 895 | <td class="jst-rght" style="line-height:1;"> |
896 | - ' . $payment->pretty_status(true) . $payment_declined_msg . ' |
|
896 | + ' . $payment->pretty_status(true).$payment_declined_msg.' |
|
897 | 897 | </td> |
898 | 898 | </tr>'; |
899 | 899 | do_action('AHEE__thank_you_page_payment_details_template__after_each_payment', $payment); |
@@ -952,7 +952,7 @@ discard block |
||
952 | 952 | '$SPCO_payment_options_url' |
953 | 953 | ); |
954 | 954 | return EEH_Template::locate_template( |
955 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-payment-details.template.php', |
|
955 | + THANK_YOU_TEMPLATES_PATH.'thank-you-page-payment-details.template.php', |
|
956 | 956 | $template_args, |
957 | 957 | true, |
958 | 958 | true |
@@ -14,757 +14,757 @@ discard block |
||
14 | 14 | class EED_Thank_You_Page extends EED_Module |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * time in seconds to wait for the IPN to arrive before telling the registrant to bugger off ( 1200s = 20 minutes ) |
|
19 | - */ |
|
20 | - const IPN_wait_time = 1200; |
|
21 | - |
|
22 | - /** |
|
23 | - * The transaction specified by the reg_url_link passed from the Request, or from the Session |
|
24 | - * |
|
25 | - * @var EE_Transaction $_current_txn |
|
26 | - */ |
|
27 | - private $_current_txn; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var EE_Registration $_primary_registrant |
|
31 | - */ |
|
32 | - private $_primary_registrant; |
|
33 | - |
|
34 | - /** |
|
35 | - * The reg_url_link passed from the Request, or from the Session |
|
36 | - * |
|
37 | - * @var string $_reg_url_link |
|
38 | - */ |
|
39 | - private $_reg_url_link; |
|
40 | - |
|
41 | - /** |
|
42 | - * whether the incoming reg_url_link is for the primary registrant or not |
|
43 | - * |
|
44 | - * @var boolean $_is_primary |
|
45 | - */ |
|
46 | - private $_is_primary; |
|
47 | - |
|
48 | - /** |
|
49 | - * The URL for revisiting the SPCO attendee information step |
|
50 | - * |
|
51 | - * @var string $_SPCO_attendee_information_url |
|
52 | - */ |
|
53 | - private $_SPCO_attendee_information_url; |
|
54 | - |
|
55 | - /** |
|
56 | - * The URL for revisiting the SPCO payment options step |
|
57 | - * |
|
58 | - * @var string $_SPCO_payment_options_url |
|
59 | - */ |
|
60 | - private $_SPCO_payment_options_url; |
|
61 | - |
|
62 | - /** |
|
63 | - * whether to display the Payment Options link |
|
64 | - * |
|
65 | - * @var boolean $_show_try_pay_again_link |
|
66 | - */ |
|
67 | - private $_show_try_pay_again_link = false; |
|
68 | - |
|
69 | - /** |
|
70 | - * whether payments are allowed at this time |
|
71 | - * |
|
72 | - * @var boolean $_payments_closed |
|
73 | - */ |
|
74 | - private $_payments_closed = false; |
|
75 | - |
|
76 | - /** |
|
77 | - * whether the selected payment method is Bank, Check , Invoice, etc |
|
78 | - * |
|
79 | - * @var boolean $_is_offline_payment_method |
|
80 | - */ |
|
81 | - private $_is_offline_payment_method = true; |
|
82 | - |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * @return EED_Module|EED_Thank_You_Page |
|
87 | - */ |
|
88 | - public static function instance() |
|
89 | - { |
|
90 | - return parent::get_instance(__CLASS__); |
|
91 | - } |
|
92 | - |
|
93 | - |
|
94 | - /** |
|
95 | - * set_hooks - for hooking into EE Core, modules, etc |
|
96 | - * |
|
97 | - * @return void |
|
98 | - */ |
|
99 | - public static function set_hooks() |
|
100 | - { |
|
101 | - add_action('wp_loaded', array('EED_Thank_You_Page', 'set_definitions'), 2); |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - |
|
106 | - /** |
|
107 | - * set_hooks_admin - for hooking into EE Admin Core, modules, etc |
|
108 | - * |
|
109 | - * @return void |
|
110 | - */ |
|
111 | - public static function set_hooks_admin() |
|
112 | - { |
|
113 | - // AJAX for IPN monitoring |
|
114 | - add_filter('heartbeat_received', array('EED_Thank_You_Page', 'thank_you_page_IPN_monitor'), 10, 3); |
|
115 | - add_filter( |
|
116 | - 'heartbeat_nopriv_received', |
|
117 | - array('EED_Thank_You_Page', 'thank_you_page_IPN_monitor'), |
|
118 | - 10, |
|
119 | - 3 |
|
120 | - ); |
|
121 | - add_action( |
|
122 | - 'wp_ajax_espresso_resend_reg_confirmation_email', |
|
123 | - array('EED_Thank_You_Page', 'resend_reg_confirmation_email'), |
|
124 | - 10, |
|
125 | - 2 |
|
126 | - ); |
|
127 | - add_action( |
|
128 | - 'wp_ajax_nopriv_espresso_resend_reg_confirmation_email', |
|
129 | - array('EED_Thank_You_Page', 'resend_reg_confirmation_email'), |
|
130 | - 10, |
|
131 | - 2 |
|
132 | - ); |
|
133 | - } |
|
134 | - |
|
135 | - |
|
136 | - |
|
137 | - /** |
|
138 | - * set_definitions |
|
139 | - * |
|
140 | - * @return void |
|
141 | - */ |
|
142 | - public static function set_definitions() |
|
143 | - { |
|
144 | - define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS); |
|
145 | - define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS); |
|
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - |
|
150 | - /** |
|
151 | - * get_txn |
|
152 | - * |
|
153 | - * @return EE_Transaction |
|
154 | - */ |
|
155 | - public function get_txn() |
|
156 | - { |
|
157 | - if ($this->_current_txn instanceof EE_Transaction) { |
|
158 | - return $this->_current_txn; |
|
159 | - } |
|
160 | - $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
161 | - if ( ! $TXN_model instanceof EEM_Transaction) { |
|
162 | - EE_Error::add_error( |
|
163 | - __('The transaction model could not be established.', 'event_espresso'), |
|
164 | - __FILE__, |
|
165 | - __FUNCTION__, |
|
166 | - __LINE__ |
|
167 | - ); |
|
168 | - return null; |
|
169 | - } |
|
170 | - //get the transaction. yes, we may have just loaded it, but it may have been updated, or this may be via an ajax request |
|
171 | - $this->_current_txn = $TXN_model->get_transaction_from_reg_url_link($this->_reg_url_link); |
|
172 | - // verify TXN |
|
173 | - if (WP_DEBUG && ! $this->_current_txn instanceof EE_Transaction) { |
|
174 | - EE_Error::add_error( |
|
175 | - __( |
|
176 | - 'No transaction information could be retrieved or the transaction data is not of the correct type.', |
|
177 | - 'event_espresso' |
|
178 | - ), |
|
179 | - __FILE__, |
|
180 | - __FUNCTION__, |
|
181 | - __LINE__ |
|
182 | - ); |
|
183 | - return null; |
|
184 | - } |
|
185 | - return $this->_current_txn; |
|
186 | - } |
|
187 | - |
|
188 | - |
|
189 | - |
|
190 | - /** |
|
191 | - * get_txn_payments |
|
192 | - * |
|
193 | - * @param int $since |
|
194 | - * @return mixed array of EE_Payment || FALSE |
|
195 | - * @throws \EE_Error |
|
196 | - */ |
|
197 | - public function get_txn_payments($since = 0) |
|
198 | - { |
|
199 | - if ( ! $this->get_txn()) { |
|
200 | - return false; |
|
201 | - } |
|
202 | - $args = array('order_by' => array('PAY_timestamp' => 'ASC')); |
|
203 | - if ($since > 0) { |
|
204 | - $args[0] = array('PAY_timestamp' => array('>', $since)); |
|
205 | - } |
|
206 | - // get array of payments with most recent first |
|
207 | - return $this->_current_txn->payments($args); |
|
208 | - } |
|
209 | - |
|
210 | - |
|
211 | - |
|
212 | - /** |
|
213 | - * get_reg_url_link |
|
214 | - * |
|
215 | - * @return void |
|
216 | - */ |
|
217 | - private function _get_reg_url_link() |
|
218 | - { |
|
219 | - if ( ! empty($this->_reg_url_link)) { |
|
220 | - return; |
|
221 | - } |
|
222 | - // only do thank you page stuff if we have a REG_url_link in the url |
|
223 | - if (WP_DEBUG && ! EE_Registry::instance()->REQ->is_set('e_reg_url_link')) { |
|
224 | - EE_Error::add_error( |
|
225 | - __( |
|
226 | - 'No transaction information could be retrieved because the registration URL link is missing or invalid.', |
|
227 | - 'event_espresso' |
|
228 | - ), |
|
229 | - __FILE__, |
|
230 | - __FUNCTION__, |
|
231 | - __LINE__ |
|
232 | - ); |
|
233 | - return; |
|
234 | - } |
|
235 | - // check for reg_url_link |
|
236 | - $this->_reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link'); |
|
237 | - } |
|
238 | - |
|
239 | - |
|
240 | - |
|
241 | - /** |
|
242 | - * set_reg_url_link |
|
243 | - * |
|
244 | - * @param string $reg_url_link |
|
245 | - */ |
|
246 | - public function set_reg_url_link($reg_url_link = null) |
|
247 | - { |
|
248 | - $this->_reg_url_link = ! empty($reg_url_link) ? $reg_url_link : $this->_reg_url_link; |
|
249 | - } |
|
250 | - |
|
251 | - |
|
252 | - |
|
253 | - /** |
|
254 | - * run - initial module setup |
|
255 | - * this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters |
|
256 | - * |
|
257 | - * @param WP $WP |
|
258 | - * @return void |
|
259 | - * @throws \EE_Error |
|
260 | - */ |
|
261 | - public function run($WP) |
|
262 | - { |
|
263 | - |
|
264 | - } |
|
265 | - |
|
266 | - |
|
267 | - |
|
268 | - /** |
|
269 | - * load_resources |
|
270 | - * |
|
271 | - * @return void |
|
272 | - * @throws \EE_Error |
|
273 | - */ |
|
274 | - public function load_resources() { |
|
275 | - $this->_get_reg_url_link(); |
|
276 | - // resend_reg_confirmation_email ? |
|
277 | - if (EE_Registry::instance()->REQ->is_set('resend')) { |
|
278 | - EED_Thank_You_Page::resend_reg_confirmation_email(); |
|
279 | - } |
|
280 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
281 | - $this->_translate_strings(); |
|
282 | - // load assets |
|
283 | - add_action('wp_enqueue_scripts', array($this, 'load_js'), 10); |
|
284 | - } |
|
285 | - |
|
286 | - |
|
287 | - |
|
288 | - /** |
|
289 | - * load_js |
|
290 | - * |
|
291 | - * @return void |
|
292 | - */ |
|
293 | - protected function _translate_strings() |
|
294 | - { |
|
295 | - EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->_reg_url_link; |
|
296 | - EE_Registry::$i18n_js_strings['initial_access'] = time(); |
|
297 | - EE_Registry::$i18n_js_strings['IPN_wait_time'] = EED_Thank_You_Page::IPN_wait_time; |
|
298 | - EE_Registry::$i18n_js_strings['TXN_complete'] = EEM_Transaction::complete_status_code; |
|
299 | - EE_Registry::$i18n_js_strings['TXN_incomplete'] = EEM_Transaction::incomplete_status_code; |
|
300 | - EE_Registry::$i18n_js_strings['checking_for_new_payments'] = __( |
|
301 | - 'checking for new payments...', |
|
302 | - 'event_espresso' |
|
303 | - ); |
|
304 | - EE_Registry::$i18n_js_strings['loading_payment_info'] = __( |
|
305 | - 'loading payment information...', |
|
306 | - 'event_espresso' |
|
307 | - ); |
|
308 | - EE_Registry::$i18n_js_strings['server_error'] = __( |
|
309 | - 'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again.', |
|
310 | - 'event_espresso' |
|
311 | - ); |
|
312 | - EE_Registry::$i18n_js_strings['slow_IPN'] = apply_filters( |
|
313 | - 'EED_Thank_You_Page__load_js__slow_IPN', |
|
314 | - sprintf( |
|
315 | - __( |
|
316 | - '%sThe Payment Notification appears to be taking longer than usual to arrive. Maybe check back later or just wait for your payment and registration confirmation results to be sent to you via email. We apologize for any inconvenience this may have caused.%s', |
|
317 | - 'event_espresso' |
|
318 | - ), |
|
319 | - '<div id="espresso-thank-you-page-slow-IPN-dv" class="ee-attention jst-left">', |
|
320 | - '</div>' |
|
321 | - ) |
|
322 | - ); |
|
323 | - } |
|
324 | - |
|
325 | - |
|
326 | - |
|
327 | - /** |
|
328 | - * load_js |
|
329 | - * |
|
330 | - * @return void |
|
331 | - */ |
|
332 | - public function load_js() |
|
333 | - { |
|
334 | - wp_register_script( |
|
335 | - 'thank_you_page', |
|
336 | - THANK_YOU_ASSETS_URL . 'thank_you_page.js', |
|
337 | - array('espresso_core', 'heartbeat'), |
|
338 | - EVENT_ESPRESSO_VERSION, |
|
339 | - true |
|
340 | - ); |
|
341 | - wp_enqueue_script('thank_you_page'); |
|
342 | - wp_enqueue_style('espresso_default'); |
|
343 | - } |
|
344 | - |
|
345 | - |
|
346 | - |
|
347 | - /** |
|
348 | - * init |
|
349 | - * |
|
350 | - * @return void |
|
351 | - * @throws \EE_Error |
|
352 | - */ |
|
353 | - public function init() |
|
354 | - { |
|
355 | - $this->_get_reg_url_link(); |
|
356 | - if ( ! $this->get_txn()) { |
|
357 | - echo EEH_HTML::div( |
|
358 | - EEH_HTML::h4(__('We\'re sorry...', 'event_espresso'), '', '') . |
|
359 | - sprintf( |
|
360 | - __( |
|
361 | - 'This is a system page for displaying transaction information after a purchase.%1$sYou are most likely seeing this notice because you have navigated to this page%1$sthrough some means other than completing a transaction.%1$sSorry for the disappointment, but you will most likely find nothing of interest here.%1$s%1$s', |
|
362 | - 'event_espresso' |
|
363 | - ), |
|
364 | - '<br/>' |
|
365 | - ), |
|
366 | - '', |
|
367 | - 'ee-attention' |
|
368 | - ); |
|
369 | - return null; |
|
370 | - } |
|
371 | - // if we've made it to the Thank You page, then let's toggle any "Failed" transactions to "Incomplete" |
|
372 | - if ($this->_current_txn->status_ID() === EEM_Transaction::failed_status_code) { |
|
373 | - $this->_current_txn->set_status(EEM_Transaction::incomplete_status_code); |
|
374 | - $this->_current_txn->save(); |
|
375 | - } |
|
376 | - $this->_primary_registrant = $this->_current_txn->primary_registration() instanceof EE_Registration |
|
377 | - ? $this->_current_txn->primary_registration() |
|
378 | - : null; |
|
379 | - $this->_is_primary = $this->_primary_registrant->reg_url_link() === $this->_reg_url_link ? true : false; |
|
380 | - $show_try_pay_again_link_default = apply_filters( |
|
381 | - 'AFEE__EED_Thank_You_Page__init__show_try_pay_again_link_default', |
|
382 | - true |
|
383 | - ); |
|
384 | - $this->_show_try_pay_again_link = $show_try_pay_again_link_default; |
|
385 | - // txn status ? |
|
386 | - if ($this->_current_txn->is_completed()) { |
|
387 | - $this->_show_try_pay_again_link = $show_try_pay_again_link_default; |
|
388 | - } else if ( |
|
389 | - $this->_current_txn->is_incomplete() |
|
390 | - && ($this->_primary_registrant->is_approved() |
|
391 | - || $this->_primary_registrant->is_pending_payment()) |
|
392 | - ) { |
|
393 | - $this->_show_try_pay_again_link = true; |
|
394 | - } else if ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment()) { |
|
395 | - // its pending |
|
396 | - $this->_show_try_pay_again_link = isset( |
|
397 | - EE_Registry::instance()->CFG->registration->show_pending_payment_options |
|
398 | - ) |
|
399 | - && EE_Registry::instance()->CFG->registration->show_pending_payment_options |
|
400 | - ? true |
|
401 | - : $show_try_pay_again_link_default; |
|
402 | - } |
|
403 | - $this->_payments_closed = ! $this->_current_txn->payment_method() instanceof EE_Payment_Method |
|
404 | - ? true |
|
405 | - : false; |
|
406 | - $this->_is_offline_payment_method = false; |
|
407 | - if ( |
|
408 | - // if payment method is unknown |
|
409 | - ! $this->_current_txn->payment_method() instanceof EE_Payment_Method |
|
410 | - || ( |
|
411 | - // or is an offline payment method |
|
412 | - $this->_current_txn->payment_method() instanceof EE_Payment_Method |
|
413 | - && $this->_current_txn->payment_method()->is_off_line() |
|
414 | - ) |
|
415 | - ) { |
|
416 | - $this->_is_offline_payment_method = true; |
|
417 | - } |
|
418 | - // link to SPCO |
|
419 | - $revisit_spco_url = add_query_arg( |
|
420 | - array('ee' => '_register', 'revisit' => true, 'e_reg_url_link' => $this->_reg_url_link), |
|
421 | - EE_Registry::instance()->CFG->core->reg_page_url() |
|
422 | - ); |
|
423 | - // link to SPCO payment_options |
|
424 | - $this->_SPCO_payment_options_url = $this->_primary_registrant instanceof EE_Registration |
|
425 | - ? $this->_primary_registrant->payment_overview_url() |
|
426 | - : add_query_arg( |
|
427 | - array('step' => 'payment_options'), |
|
428 | - $revisit_spco_url |
|
429 | - ); |
|
430 | - // link to SPCO attendee_information |
|
431 | - $this->_SPCO_attendee_information_url = $this->_primary_registrant instanceof EE_Registration |
|
432 | - ? $this->_primary_registrant->edit_attendee_information_url() |
|
433 | - : false; |
|
434 | - do_action('AHEE__EED_Thank_You_Page__init_end', $this->_current_txn); |
|
435 | - // set no cache headers and constants |
|
436 | - EE_System::do_not_cache(); |
|
437 | - } |
|
438 | - |
|
439 | - |
|
440 | - |
|
441 | - /** |
|
442 | - * display_thank_you_page_results |
|
443 | - * |
|
444 | - * @return string |
|
445 | - * @throws \EE_Error |
|
446 | - */ |
|
447 | - public function thank_you_page_results() |
|
448 | - { |
|
449 | - $this->init(); |
|
450 | - if ( ! $this->_current_txn instanceof EE_Transaction) { |
|
451 | - return EE_Error::get_notices(); |
|
452 | - } |
|
453 | - // link to receipt |
|
454 | - $template_args['TXN_receipt_url'] = $this->_current_txn->receipt_url('html'); |
|
455 | - if ( ! empty($template_args['TXN_receipt_url'])) { |
|
456 | - $template_args['order_conf_desc'] = __( |
|
457 | - '%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation or click the button below to view / download / print a full description of your purchases and registration information.', |
|
458 | - 'event_espresso' |
|
459 | - ); |
|
460 | - } else { |
|
461 | - $template_args['order_conf_desc'] = __( |
|
462 | - '%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation.', |
|
463 | - 'event_espresso' |
|
464 | - ); |
|
465 | - } |
|
466 | - $template_args['transaction'] = $this->_current_txn; |
|
467 | - $template_args['revisit'] = EE_Registry::instance()->REQ->get('revisit', false); |
|
468 | - add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_registration_details')); |
|
469 | - if ($this->_is_primary && ! $this->_current_txn->is_free()) { |
|
470 | - add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_ajax_content')); |
|
471 | - } |
|
472 | - return EEH_Template::locate_template( |
|
473 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-overview.template.php', |
|
474 | - $template_args, |
|
475 | - true, |
|
476 | - true |
|
477 | - ); |
|
478 | - } |
|
479 | - |
|
480 | - |
|
481 | - |
|
482 | - /** |
|
483 | - * thank_you_page_IPN_monitor |
|
484 | - * this basically just pulls the TXN based on the reg_url_link sent from the server, |
|
485 | - * then checks that the TXN status is not failed, and that no other errors have been generated. |
|
486 | - * it also calculates the IPN wait time since the Thank You page was first loaded |
|
487 | - * |
|
488 | - * @param array $response |
|
489 | - * @param array $data |
|
490 | - * @return array |
|
491 | - * @throws \EE_Error |
|
492 | - */ |
|
493 | - public static function thank_you_page_IPN_monitor($response = array(), $data = array()) |
|
494 | - { |
|
495 | - // does this heartbeat contain our data ? |
|
496 | - if ( ! isset($data['espresso_thank_you_page'])) { |
|
497 | - return $response; |
|
498 | - } |
|
499 | - // check for reg_url_link in the incoming heartbeat data |
|
500 | - if ( ! isset($data['espresso_thank_you_page']['e_reg_url_link'])) { |
|
501 | - $response['espresso_thank_you_page'] = array( |
|
502 | - 'errors' => ! empty($notices['errors']) |
|
503 | - ? $notices['errors'] |
|
504 | - : __( |
|
505 | - 'No transaction information could be retrieved because the registration URL link is missing or invalid.', |
|
506 | - 'event_espresso' |
|
507 | - ) |
|
508 | - ); |
|
509 | - return $response; |
|
510 | - } |
|
511 | - // kk heartbeat has our data |
|
512 | - $response['espresso_thank_you_page'] = array(); |
|
513 | - // set_definitions, instantiate the thank you page class, and get the ball rolling |
|
514 | - EED_Thank_You_Page::set_definitions(); |
|
515 | - /** @var $espresso_thank_you_page EED_Thank_You_Page */ |
|
516 | - $espresso_thank_you_page = EED_Thank_You_Page::instance(); |
|
517 | - $espresso_thank_you_page->set_reg_url_link($data['espresso_thank_you_page']['e_reg_url_link']); |
|
518 | - $espresso_thank_you_page->init(); |
|
519 | - //get TXN |
|
520 | - $TXN = $espresso_thank_you_page->get_txn(); |
|
521 | - // no TXN? then get out |
|
522 | - if ( ! $TXN instanceof EE_Transaction) { |
|
523 | - $notices = EE_Error::get_notices(); |
|
524 | - $response['espresso_thank_you_page'] = array( |
|
525 | - 'errors' => ! empty($notices['errors']) |
|
526 | - ? $notices['errors'] |
|
527 | - : sprintf( |
|
528 | - __( |
|
529 | - 'The information for your transaction could not be retrieved from the server or the transaction data received was invalid because of a technical reason. (%s)', |
|
530 | - 'event_espresso' |
|
531 | - ), |
|
532 | - __LINE__ |
|
533 | - ) |
|
534 | - ); |
|
535 | - return $response; |
|
536 | - } |
|
537 | - // grab transient of TXN's status |
|
538 | - $txn_status = isset($data['espresso_thank_you_page']['txn_status']) |
|
539 | - ? $data['espresso_thank_you_page']['txn_status'] |
|
540 | - : null; |
|
541 | - // has the TXN status changed since we last checked (or empty because this is the first time running through this code)? |
|
542 | - if ($txn_status !== $TXN->status_ID()) { |
|
543 | - // switch between two possible basic outcomes |
|
544 | - switch ($TXN->status_ID()) { |
|
545 | - // TXN has been updated in some way |
|
546 | - case EEM_Transaction::overpaid_status_code: |
|
547 | - case EEM_Transaction::complete_status_code: |
|
548 | - case EEM_Transaction::incomplete_status_code: |
|
549 | - // send updated TXN results back to client, |
|
550 | - $response['espresso_thank_you_page'] = array( |
|
551 | - 'transaction_details' => $espresso_thank_you_page->get_transaction_details(), |
|
552 | - 'txn_status' => $TXN->status_ID() |
|
553 | - ); |
|
554 | - break; |
|
555 | - // or we have a bad TXN, or really slow IPN, so calculate the wait time and send that back... |
|
556 | - case EEM_Transaction::failed_status_code: |
|
557 | - default: |
|
558 | - // keep on waiting... |
|
559 | - return $espresso_thank_you_page->_update_server_wait_time($data['espresso_thank_you_page']); |
|
560 | - } |
|
561 | - // or is the TXN still failed (never been updated) ??? |
|
562 | - } else if ($TXN->failed()) { |
|
563 | - // keep on waiting... |
|
564 | - return $espresso_thank_you_page->_update_server_wait_time($data['espresso_thank_you_page']); |
|
565 | - } |
|
566 | - // TXN is happening so let's get the payments now |
|
567 | - // if we've already gotten payments then the heartbeat data will contain the timestamp of the last time we checked |
|
568 | - $since = isset($data['espresso_thank_you_page']['get_payments_since']) |
|
569 | - ? $data['espresso_thank_you_page']['get_payments_since'] |
|
570 | - : 0; |
|
571 | - // then check for payments |
|
572 | - $payments = $espresso_thank_you_page->get_txn_payments($since); |
|
573 | - // has a payment been processed ? |
|
574 | - if ( ! empty($payments) || $espresso_thank_you_page->_is_offline_payment_method) { |
|
575 | - if ($since) { |
|
576 | - $response['espresso_thank_you_page'] = array( |
|
577 | - 'new_payments' => $espresso_thank_you_page->get_new_payments($payments), |
|
578 | - 'transaction_details' => $espresso_thank_you_page->get_transaction_details(), |
|
579 | - 'txn_status' => $TXN->status_ID() |
|
580 | - ); |
|
581 | - } else { |
|
582 | - $response['espresso_thank_you_page']['payment_details'] = $espresso_thank_you_page->get_payment_details( |
|
583 | - $payments |
|
584 | - ); |
|
585 | - } |
|
586 | - // reset time to check for payments |
|
587 | - $response['espresso_thank_you_page']['get_payments_since'] = time(); |
|
588 | - } else { |
|
589 | - $response['espresso_thank_you_page']['get_payments_since'] = $since; |
|
590 | - } |
|
591 | - return $response; |
|
592 | - } |
|
593 | - |
|
594 | - |
|
595 | - |
|
596 | - /** |
|
597 | - * _update_server_wait_time |
|
598 | - * |
|
599 | - * @param array $thank_you_page_data thank you page portion of the incoming JSON array from the WP heartbeat data |
|
600 | - * @return array |
|
601 | - * @throws \EE_Error |
|
602 | - */ |
|
603 | - private function _update_server_wait_time($thank_you_page_data = array()) |
|
604 | - { |
|
605 | - $response['espresso_thank_you_page'] = array( |
|
606 | - 'still_waiting' => isset($thank_you_page_data['initial_access']) |
|
607 | - ? time() - $thank_you_page_data['initial_access'] |
|
608 | - : 0, |
|
609 | - 'txn_status' => $this->_current_txn->status_ID() |
|
610 | - ); |
|
611 | - return $response; |
|
612 | - } |
|
613 | - |
|
614 | - |
|
615 | - |
|
616 | - /** |
|
617 | - * get_registration_details |
|
618 | - * |
|
619 | - * @throws \EE_Error |
|
620 | - */ |
|
621 | - public function get_registration_details() |
|
622 | - { |
|
623 | - //prepare variables for displaying |
|
624 | - $template_args = array(); |
|
625 | - $template_args['transaction'] = $this->_current_txn; |
|
626 | - $template_args['reg_url_link'] = $this->_reg_url_link; |
|
627 | - $template_args['is_primary'] = $this->_is_primary; |
|
628 | - $template_args['SPCO_attendee_information_url'] = $this->_SPCO_attendee_information_url; |
|
629 | - $template_args['resend_reg_confirmation_url'] = add_query_arg( |
|
630 | - array('token' => $this->_reg_url_link, 'resend_reg_confirmation' => 'true'), |
|
631 | - EE_Registry::instance()->CFG->core->thank_you_page_url() |
|
632 | - ); |
|
633 | - // verify template arguments |
|
634 | - EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction'); |
|
635 | - EEH_Template_Validator::verify_isnt_null( |
|
636 | - $template_args['SPCO_attendee_information_url'], |
|
637 | - '$SPCO_attendee_information_url' |
|
638 | - ); |
|
639 | - echo EEH_Template::locate_template( |
|
640 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-registration-details.template.php', |
|
641 | - $template_args, |
|
642 | - true, |
|
643 | - true |
|
644 | - ); |
|
645 | - } |
|
646 | - |
|
647 | - |
|
648 | - |
|
649 | - /** |
|
650 | - * resend_reg_confirmation_email |
|
651 | - * |
|
652 | - * @throws \EE_Error |
|
653 | - */ |
|
654 | - public static function resend_reg_confirmation_email() |
|
655 | - { |
|
656 | - EE_Registry::instance()->load_core('Request_Handler'); |
|
657 | - $reg_url_link = EE_Registry::instance()->REQ->get('token'); |
|
658 | - // was a REG_ID passed ? |
|
659 | - if ($reg_url_link) { |
|
660 | - $registration = EE_Registry::instance()->load_model('Registration')->get_one( |
|
661 | - array(array('REG_url_link' => $reg_url_link)) |
|
662 | - ); |
|
663 | - if ($registration instanceof EE_Registration) { |
|
664 | - // resend email |
|
665 | - EED_Messages::process_resend(array('_REG_ID' => $registration->ID())); |
|
666 | - } else { |
|
667 | - EE_Error::add_error( |
|
668 | - __( |
|
669 | - 'The Registration Confirmation email could not be sent because a valid Registration could not be retrieved from the database.', |
|
670 | - 'event_espresso' |
|
671 | - ), |
|
672 | - __FILE__, |
|
673 | - __FUNCTION__, |
|
674 | - __LINE__ |
|
675 | - ); |
|
676 | - } |
|
677 | - } else { |
|
678 | - EE_Error::add_error( |
|
679 | - __( |
|
680 | - 'The Registration Confirmation email could not be sent because a registration token is missing or invalid.', |
|
681 | - 'event_espresso' |
|
682 | - ), |
|
683 | - __FILE__, |
|
684 | - __FUNCTION__, |
|
685 | - __LINE__ |
|
686 | - ); |
|
687 | - } |
|
688 | - // request sent via AJAX ? |
|
689 | - if (EE_FRONT_AJAX) { |
|
690 | - echo wp_json_encode(EE_Error::get_notices(false)); |
|
691 | - die(); |
|
692 | - // or was JS disabled ? |
|
693 | - } else { |
|
694 | - // save errors so that they get picked up on the next request |
|
695 | - EE_Error::get_notices(true, true); |
|
696 | - wp_safe_redirect( |
|
697 | - add_query_arg( |
|
698 | - array('e_reg_url_link' => $reg_url_link), |
|
699 | - EE_Registry::instance()->CFG->core->thank_you_page_url() |
|
700 | - ) |
|
701 | - ); |
|
702 | - } |
|
703 | - } |
|
704 | - |
|
705 | - |
|
706 | - |
|
707 | - /** |
|
708 | - * get_ajax_content |
|
709 | - * |
|
710 | - * @return void |
|
711 | - * @throws \EE_Error |
|
712 | - */ |
|
713 | - public function get_ajax_content() |
|
714 | - { |
|
715 | - if ( ! $this->get_txn()) { |
|
716 | - return; |
|
717 | - } |
|
718 | - // first determine which event(s) require pre-approval or not |
|
719 | - $events = array(); |
|
720 | - $events_requiring_pre_approval = array(); |
|
721 | - foreach ($this->_current_txn->registrations() as $registration) { |
|
722 | - if ($registration instanceof EE_Registration) { |
|
723 | - $event = $registration->event(); |
|
724 | - if ($event instanceof EE_Event) { |
|
725 | - if ($registration->is_not_approved() && $registration->event() instanceof EE_Event) { |
|
726 | - $events_requiring_pre_approval[$event->ID()] = $event; |
|
727 | - } else { |
|
728 | - $events[$event->ID()] = $event; |
|
729 | - } |
|
730 | - } |
|
731 | - } |
|
732 | - } |
|
733 | - $this->display_details_for_events_requiring_pre_approval($events_requiring_pre_approval); |
|
734 | - $this->display_details_for_events($events); |
|
735 | - } |
|
736 | - |
|
737 | - |
|
738 | - |
|
739 | - /** |
|
740 | - * display_details_for_events |
|
741 | - * |
|
742 | - * @param EE_Event[] $events |
|
743 | - * @return void |
|
744 | - */ |
|
745 | - public function display_details_for_events($events = array()) |
|
746 | - { |
|
747 | - if ( ! empty($events)) { |
|
748 | - ?> |
|
17 | + /** |
|
18 | + * time in seconds to wait for the IPN to arrive before telling the registrant to bugger off ( 1200s = 20 minutes ) |
|
19 | + */ |
|
20 | + const IPN_wait_time = 1200; |
|
21 | + |
|
22 | + /** |
|
23 | + * The transaction specified by the reg_url_link passed from the Request, or from the Session |
|
24 | + * |
|
25 | + * @var EE_Transaction $_current_txn |
|
26 | + */ |
|
27 | + private $_current_txn; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var EE_Registration $_primary_registrant |
|
31 | + */ |
|
32 | + private $_primary_registrant; |
|
33 | + |
|
34 | + /** |
|
35 | + * The reg_url_link passed from the Request, or from the Session |
|
36 | + * |
|
37 | + * @var string $_reg_url_link |
|
38 | + */ |
|
39 | + private $_reg_url_link; |
|
40 | + |
|
41 | + /** |
|
42 | + * whether the incoming reg_url_link is for the primary registrant or not |
|
43 | + * |
|
44 | + * @var boolean $_is_primary |
|
45 | + */ |
|
46 | + private $_is_primary; |
|
47 | + |
|
48 | + /** |
|
49 | + * The URL for revisiting the SPCO attendee information step |
|
50 | + * |
|
51 | + * @var string $_SPCO_attendee_information_url |
|
52 | + */ |
|
53 | + private $_SPCO_attendee_information_url; |
|
54 | + |
|
55 | + /** |
|
56 | + * The URL for revisiting the SPCO payment options step |
|
57 | + * |
|
58 | + * @var string $_SPCO_payment_options_url |
|
59 | + */ |
|
60 | + private $_SPCO_payment_options_url; |
|
61 | + |
|
62 | + /** |
|
63 | + * whether to display the Payment Options link |
|
64 | + * |
|
65 | + * @var boolean $_show_try_pay_again_link |
|
66 | + */ |
|
67 | + private $_show_try_pay_again_link = false; |
|
68 | + |
|
69 | + /** |
|
70 | + * whether payments are allowed at this time |
|
71 | + * |
|
72 | + * @var boolean $_payments_closed |
|
73 | + */ |
|
74 | + private $_payments_closed = false; |
|
75 | + |
|
76 | + /** |
|
77 | + * whether the selected payment method is Bank, Check , Invoice, etc |
|
78 | + * |
|
79 | + * @var boolean $_is_offline_payment_method |
|
80 | + */ |
|
81 | + private $_is_offline_payment_method = true; |
|
82 | + |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * @return EED_Module|EED_Thank_You_Page |
|
87 | + */ |
|
88 | + public static function instance() |
|
89 | + { |
|
90 | + return parent::get_instance(__CLASS__); |
|
91 | + } |
|
92 | + |
|
93 | + |
|
94 | + /** |
|
95 | + * set_hooks - for hooking into EE Core, modules, etc |
|
96 | + * |
|
97 | + * @return void |
|
98 | + */ |
|
99 | + public static function set_hooks() |
|
100 | + { |
|
101 | + add_action('wp_loaded', array('EED_Thank_You_Page', 'set_definitions'), 2); |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + |
|
106 | + /** |
|
107 | + * set_hooks_admin - for hooking into EE Admin Core, modules, etc |
|
108 | + * |
|
109 | + * @return void |
|
110 | + */ |
|
111 | + public static function set_hooks_admin() |
|
112 | + { |
|
113 | + // AJAX for IPN monitoring |
|
114 | + add_filter('heartbeat_received', array('EED_Thank_You_Page', 'thank_you_page_IPN_monitor'), 10, 3); |
|
115 | + add_filter( |
|
116 | + 'heartbeat_nopriv_received', |
|
117 | + array('EED_Thank_You_Page', 'thank_you_page_IPN_monitor'), |
|
118 | + 10, |
|
119 | + 3 |
|
120 | + ); |
|
121 | + add_action( |
|
122 | + 'wp_ajax_espresso_resend_reg_confirmation_email', |
|
123 | + array('EED_Thank_You_Page', 'resend_reg_confirmation_email'), |
|
124 | + 10, |
|
125 | + 2 |
|
126 | + ); |
|
127 | + add_action( |
|
128 | + 'wp_ajax_nopriv_espresso_resend_reg_confirmation_email', |
|
129 | + array('EED_Thank_You_Page', 'resend_reg_confirmation_email'), |
|
130 | + 10, |
|
131 | + 2 |
|
132 | + ); |
|
133 | + } |
|
134 | + |
|
135 | + |
|
136 | + |
|
137 | + /** |
|
138 | + * set_definitions |
|
139 | + * |
|
140 | + * @return void |
|
141 | + */ |
|
142 | + public static function set_definitions() |
|
143 | + { |
|
144 | + define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS); |
|
145 | + define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS); |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + |
|
150 | + /** |
|
151 | + * get_txn |
|
152 | + * |
|
153 | + * @return EE_Transaction |
|
154 | + */ |
|
155 | + public function get_txn() |
|
156 | + { |
|
157 | + if ($this->_current_txn instanceof EE_Transaction) { |
|
158 | + return $this->_current_txn; |
|
159 | + } |
|
160 | + $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
161 | + if ( ! $TXN_model instanceof EEM_Transaction) { |
|
162 | + EE_Error::add_error( |
|
163 | + __('The transaction model could not be established.', 'event_espresso'), |
|
164 | + __FILE__, |
|
165 | + __FUNCTION__, |
|
166 | + __LINE__ |
|
167 | + ); |
|
168 | + return null; |
|
169 | + } |
|
170 | + //get the transaction. yes, we may have just loaded it, but it may have been updated, or this may be via an ajax request |
|
171 | + $this->_current_txn = $TXN_model->get_transaction_from_reg_url_link($this->_reg_url_link); |
|
172 | + // verify TXN |
|
173 | + if (WP_DEBUG && ! $this->_current_txn instanceof EE_Transaction) { |
|
174 | + EE_Error::add_error( |
|
175 | + __( |
|
176 | + 'No transaction information could be retrieved or the transaction data is not of the correct type.', |
|
177 | + 'event_espresso' |
|
178 | + ), |
|
179 | + __FILE__, |
|
180 | + __FUNCTION__, |
|
181 | + __LINE__ |
|
182 | + ); |
|
183 | + return null; |
|
184 | + } |
|
185 | + return $this->_current_txn; |
|
186 | + } |
|
187 | + |
|
188 | + |
|
189 | + |
|
190 | + /** |
|
191 | + * get_txn_payments |
|
192 | + * |
|
193 | + * @param int $since |
|
194 | + * @return mixed array of EE_Payment || FALSE |
|
195 | + * @throws \EE_Error |
|
196 | + */ |
|
197 | + public function get_txn_payments($since = 0) |
|
198 | + { |
|
199 | + if ( ! $this->get_txn()) { |
|
200 | + return false; |
|
201 | + } |
|
202 | + $args = array('order_by' => array('PAY_timestamp' => 'ASC')); |
|
203 | + if ($since > 0) { |
|
204 | + $args[0] = array('PAY_timestamp' => array('>', $since)); |
|
205 | + } |
|
206 | + // get array of payments with most recent first |
|
207 | + return $this->_current_txn->payments($args); |
|
208 | + } |
|
209 | + |
|
210 | + |
|
211 | + |
|
212 | + /** |
|
213 | + * get_reg_url_link |
|
214 | + * |
|
215 | + * @return void |
|
216 | + */ |
|
217 | + private function _get_reg_url_link() |
|
218 | + { |
|
219 | + if ( ! empty($this->_reg_url_link)) { |
|
220 | + return; |
|
221 | + } |
|
222 | + // only do thank you page stuff if we have a REG_url_link in the url |
|
223 | + if (WP_DEBUG && ! EE_Registry::instance()->REQ->is_set('e_reg_url_link')) { |
|
224 | + EE_Error::add_error( |
|
225 | + __( |
|
226 | + 'No transaction information could be retrieved because the registration URL link is missing or invalid.', |
|
227 | + 'event_espresso' |
|
228 | + ), |
|
229 | + __FILE__, |
|
230 | + __FUNCTION__, |
|
231 | + __LINE__ |
|
232 | + ); |
|
233 | + return; |
|
234 | + } |
|
235 | + // check for reg_url_link |
|
236 | + $this->_reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link'); |
|
237 | + } |
|
238 | + |
|
239 | + |
|
240 | + |
|
241 | + /** |
|
242 | + * set_reg_url_link |
|
243 | + * |
|
244 | + * @param string $reg_url_link |
|
245 | + */ |
|
246 | + public function set_reg_url_link($reg_url_link = null) |
|
247 | + { |
|
248 | + $this->_reg_url_link = ! empty($reg_url_link) ? $reg_url_link : $this->_reg_url_link; |
|
249 | + } |
|
250 | + |
|
251 | + |
|
252 | + |
|
253 | + /** |
|
254 | + * run - initial module setup |
|
255 | + * this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters |
|
256 | + * |
|
257 | + * @param WP $WP |
|
258 | + * @return void |
|
259 | + * @throws \EE_Error |
|
260 | + */ |
|
261 | + public function run($WP) |
|
262 | + { |
|
263 | + |
|
264 | + } |
|
265 | + |
|
266 | + |
|
267 | + |
|
268 | + /** |
|
269 | + * load_resources |
|
270 | + * |
|
271 | + * @return void |
|
272 | + * @throws \EE_Error |
|
273 | + */ |
|
274 | + public function load_resources() { |
|
275 | + $this->_get_reg_url_link(); |
|
276 | + // resend_reg_confirmation_email ? |
|
277 | + if (EE_Registry::instance()->REQ->is_set('resend')) { |
|
278 | + EED_Thank_You_Page::resend_reg_confirmation_email(); |
|
279 | + } |
|
280 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
281 | + $this->_translate_strings(); |
|
282 | + // load assets |
|
283 | + add_action('wp_enqueue_scripts', array($this, 'load_js'), 10); |
|
284 | + } |
|
285 | + |
|
286 | + |
|
287 | + |
|
288 | + /** |
|
289 | + * load_js |
|
290 | + * |
|
291 | + * @return void |
|
292 | + */ |
|
293 | + protected function _translate_strings() |
|
294 | + { |
|
295 | + EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->_reg_url_link; |
|
296 | + EE_Registry::$i18n_js_strings['initial_access'] = time(); |
|
297 | + EE_Registry::$i18n_js_strings['IPN_wait_time'] = EED_Thank_You_Page::IPN_wait_time; |
|
298 | + EE_Registry::$i18n_js_strings['TXN_complete'] = EEM_Transaction::complete_status_code; |
|
299 | + EE_Registry::$i18n_js_strings['TXN_incomplete'] = EEM_Transaction::incomplete_status_code; |
|
300 | + EE_Registry::$i18n_js_strings['checking_for_new_payments'] = __( |
|
301 | + 'checking for new payments...', |
|
302 | + 'event_espresso' |
|
303 | + ); |
|
304 | + EE_Registry::$i18n_js_strings['loading_payment_info'] = __( |
|
305 | + 'loading payment information...', |
|
306 | + 'event_espresso' |
|
307 | + ); |
|
308 | + EE_Registry::$i18n_js_strings['server_error'] = __( |
|
309 | + 'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again.', |
|
310 | + 'event_espresso' |
|
311 | + ); |
|
312 | + EE_Registry::$i18n_js_strings['slow_IPN'] = apply_filters( |
|
313 | + 'EED_Thank_You_Page__load_js__slow_IPN', |
|
314 | + sprintf( |
|
315 | + __( |
|
316 | + '%sThe Payment Notification appears to be taking longer than usual to arrive. Maybe check back later or just wait for your payment and registration confirmation results to be sent to you via email. We apologize for any inconvenience this may have caused.%s', |
|
317 | + 'event_espresso' |
|
318 | + ), |
|
319 | + '<div id="espresso-thank-you-page-slow-IPN-dv" class="ee-attention jst-left">', |
|
320 | + '</div>' |
|
321 | + ) |
|
322 | + ); |
|
323 | + } |
|
324 | + |
|
325 | + |
|
326 | + |
|
327 | + /** |
|
328 | + * load_js |
|
329 | + * |
|
330 | + * @return void |
|
331 | + */ |
|
332 | + public function load_js() |
|
333 | + { |
|
334 | + wp_register_script( |
|
335 | + 'thank_you_page', |
|
336 | + THANK_YOU_ASSETS_URL . 'thank_you_page.js', |
|
337 | + array('espresso_core', 'heartbeat'), |
|
338 | + EVENT_ESPRESSO_VERSION, |
|
339 | + true |
|
340 | + ); |
|
341 | + wp_enqueue_script('thank_you_page'); |
|
342 | + wp_enqueue_style('espresso_default'); |
|
343 | + } |
|
344 | + |
|
345 | + |
|
346 | + |
|
347 | + /** |
|
348 | + * init |
|
349 | + * |
|
350 | + * @return void |
|
351 | + * @throws \EE_Error |
|
352 | + */ |
|
353 | + public function init() |
|
354 | + { |
|
355 | + $this->_get_reg_url_link(); |
|
356 | + if ( ! $this->get_txn()) { |
|
357 | + echo EEH_HTML::div( |
|
358 | + EEH_HTML::h4(__('We\'re sorry...', 'event_espresso'), '', '') . |
|
359 | + sprintf( |
|
360 | + __( |
|
361 | + 'This is a system page for displaying transaction information after a purchase.%1$sYou are most likely seeing this notice because you have navigated to this page%1$sthrough some means other than completing a transaction.%1$sSorry for the disappointment, but you will most likely find nothing of interest here.%1$s%1$s', |
|
362 | + 'event_espresso' |
|
363 | + ), |
|
364 | + '<br/>' |
|
365 | + ), |
|
366 | + '', |
|
367 | + 'ee-attention' |
|
368 | + ); |
|
369 | + return null; |
|
370 | + } |
|
371 | + // if we've made it to the Thank You page, then let's toggle any "Failed" transactions to "Incomplete" |
|
372 | + if ($this->_current_txn->status_ID() === EEM_Transaction::failed_status_code) { |
|
373 | + $this->_current_txn->set_status(EEM_Transaction::incomplete_status_code); |
|
374 | + $this->_current_txn->save(); |
|
375 | + } |
|
376 | + $this->_primary_registrant = $this->_current_txn->primary_registration() instanceof EE_Registration |
|
377 | + ? $this->_current_txn->primary_registration() |
|
378 | + : null; |
|
379 | + $this->_is_primary = $this->_primary_registrant->reg_url_link() === $this->_reg_url_link ? true : false; |
|
380 | + $show_try_pay_again_link_default = apply_filters( |
|
381 | + 'AFEE__EED_Thank_You_Page__init__show_try_pay_again_link_default', |
|
382 | + true |
|
383 | + ); |
|
384 | + $this->_show_try_pay_again_link = $show_try_pay_again_link_default; |
|
385 | + // txn status ? |
|
386 | + if ($this->_current_txn->is_completed()) { |
|
387 | + $this->_show_try_pay_again_link = $show_try_pay_again_link_default; |
|
388 | + } else if ( |
|
389 | + $this->_current_txn->is_incomplete() |
|
390 | + && ($this->_primary_registrant->is_approved() |
|
391 | + || $this->_primary_registrant->is_pending_payment()) |
|
392 | + ) { |
|
393 | + $this->_show_try_pay_again_link = true; |
|
394 | + } else if ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment()) { |
|
395 | + // its pending |
|
396 | + $this->_show_try_pay_again_link = isset( |
|
397 | + EE_Registry::instance()->CFG->registration->show_pending_payment_options |
|
398 | + ) |
|
399 | + && EE_Registry::instance()->CFG->registration->show_pending_payment_options |
|
400 | + ? true |
|
401 | + : $show_try_pay_again_link_default; |
|
402 | + } |
|
403 | + $this->_payments_closed = ! $this->_current_txn->payment_method() instanceof EE_Payment_Method |
|
404 | + ? true |
|
405 | + : false; |
|
406 | + $this->_is_offline_payment_method = false; |
|
407 | + if ( |
|
408 | + // if payment method is unknown |
|
409 | + ! $this->_current_txn->payment_method() instanceof EE_Payment_Method |
|
410 | + || ( |
|
411 | + // or is an offline payment method |
|
412 | + $this->_current_txn->payment_method() instanceof EE_Payment_Method |
|
413 | + && $this->_current_txn->payment_method()->is_off_line() |
|
414 | + ) |
|
415 | + ) { |
|
416 | + $this->_is_offline_payment_method = true; |
|
417 | + } |
|
418 | + // link to SPCO |
|
419 | + $revisit_spco_url = add_query_arg( |
|
420 | + array('ee' => '_register', 'revisit' => true, 'e_reg_url_link' => $this->_reg_url_link), |
|
421 | + EE_Registry::instance()->CFG->core->reg_page_url() |
|
422 | + ); |
|
423 | + // link to SPCO payment_options |
|
424 | + $this->_SPCO_payment_options_url = $this->_primary_registrant instanceof EE_Registration |
|
425 | + ? $this->_primary_registrant->payment_overview_url() |
|
426 | + : add_query_arg( |
|
427 | + array('step' => 'payment_options'), |
|
428 | + $revisit_spco_url |
|
429 | + ); |
|
430 | + // link to SPCO attendee_information |
|
431 | + $this->_SPCO_attendee_information_url = $this->_primary_registrant instanceof EE_Registration |
|
432 | + ? $this->_primary_registrant->edit_attendee_information_url() |
|
433 | + : false; |
|
434 | + do_action('AHEE__EED_Thank_You_Page__init_end', $this->_current_txn); |
|
435 | + // set no cache headers and constants |
|
436 | + EE_System::do_not_cache(); |
|
437 | + } |
|
438 | + |
|
439 | + |
|
440 | + |
|
441 | + /** |
|
442 | + * display_thank_you_page_results |
|
443 | + * |
|
444 | + * @return string |
|
445 | + * @throws \EE_Error |
|
446 | + */ |
|
447 | + public function thank_you_page_results() |
|
448 | + { |
|
449 | + $this->init(); |
|
450 | + if ( ! $this->_current_txn instanceof EE_Transaction) { |
|
451 | + return EE_Error::get_notices(); |
|
452 | + } |
|
453 | + // link to receipt |
|
454 | + $template_args['TXN_receipt_url'] = $this->_current_txn->receipt_url('html'); |
|
455 | + if ( ! empty($template_args['TXN_receipt_url'])) { |
|
456 | + $template_args['order_conf_desc'] = __( |
|
457 | + '%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation or click the button below to view / download / print a full description of your purchases and registration information.', |
|
458 | + 'event_espresso' |
|
459 | + ); |
|
460 | + } else { |
|
461 | + $template_args['order_conf_desc'] = __( |
|
462 | + '%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation.', |
|
463 | + 'event_espresso' |
|
464 | + ); |
|
465 | + } |
|
466 | + $template_args['transaction'] = $this->_current_txn; |
|
467 | + $template_args['revisit'] = EE_Registry::instance()->REQ->get('revisit', false); |
|
468 | + add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_registration_details')); |
|
469 | + if ($this->_is_primary && ! $this->_current_txn->is_free()) { |
|
470 | + add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_ajax_content')); |
|
471 | + } |
|
472 | + return EEH_Template::locate_template( |
|
473 | + THANK_YOU_TEMPLATES_PATH . 'thank-you-page-overview.template.php', |
|
474 | + $template_args, |
|
475 | + true, |
|
476 | + true |
|
477 | + ); |
|
478 | + } |
|
479 | + |
|
480 | + |
|
481 | + |
|
482 | + /** |
|
483 | + * thank_you_page_IPN_monitor |
|
484 | + * this basically just pulls the TXN based on the reg_url_link sent from the server, |
|
485 | + * then checks that the TXN status is not failed, and that no other errors have been generated. |
|
486 | + * it also calculates the IPN wait time since the Thank You page was first loaded |
|
487 | + * |
|
488 | + * @param array $response |
|
489 | + * @param array $data |
|
490 | + * @return array |
|
491 | + * @throws \EE_Error |
|
492 | + */ |
|
493 | + public static function thank_you_page_IPN_monitor($response = array(), $data = array()) |
|
494 | + { |
|
495 | + // does this heartbeat contain our data ? |
|
496 | + if ( ! isset($data['espresso_thank_you_page'])) { |
|
497 | + return $response; |
|
498 | + } |
|
499 | + // check for reg_url_link in the incoming heartbeat data |
|
500 | + if ( ! isset($data['espresso_thank_you_page']['e_reg_url_link'])) { |
|
501 | + $response['espresso_thank_you_page'] = array( |
|
502 | + 'errors' => ! empty($notices['errors']) |
|
503 | + ? $notices['errors'] |
|
504 | + : __( |
|
505 | + 'No transaction information could be retrieved because the registration URL link is missing or invalid.', |
|
506 | + 'event_espresso' |
|
507 | + ) |
|
508 | + ); |
|
509 | + return $response; |
|
510 | + } |
|
511 | + // kk heartbeat has our data |
|
512 | + $response['espresso_thank_you_page'] = array(); |
|
513 | + // set_definitions, instantiate the thank you page class, and get the ball rolling |
|
514 | + EED_Thank_You_Page::set_definitions(); |
|
515 | + /** @var $espresso_thank_you_page EED_Thank_You_Page */ |
|
516 | + $espresso_thank_you_page = EED_Thank_You_Page::instance(); |
|
517 | + $espresso_thank_you_page->set_reg_url_link($data['espresso_thank_you_page']['e_reg_url_link']); |
|
518 | + $espresso_thank_you_page->init(); |
|
519 | + //get TXN |
|
520 | + $TXN = $espresso_thank_you_page->get_txn(); |
|
521 | + // no TXN? then get out |
|
522 | + if ( ! $TXN instanceof EE_Transaction) { |
|
523 | + $notices = EE_Error::get_notices(); |
|
524 | + $response['espresso_thank_you_page'] = array( |
|
525 | + 'errors' => ! empty($notices['errors']) |
|
526 | + ? $notices['errors'] |
|
527 | + : sprintf( |
|
528 | + __( |
|
529 | + 'The information for your transaction could not be retrieved from the server or the transaction data received was invalid because of a technical reason. (%s)', |
|
530 | + 'event_espresso' |
|
531 | + ), |
|
532 | + __LINE__ |
|
533 | + ) |
|
534 | + ); |
|
535 | + return $response; |
|
536 | + } |
|
537 | + // grab transient of TXN's status |
|
538 | + $txn_status = isset($data['espresso_thank_you_page']['txn_status']) |
|
539 | + ? $data['espresso_thank_you_page']['txn_status'] |
|
540 | + : null; |
|
541 | + // has the TXN status changed since we last checked (or empty because this is the first time running through this code)? |
|
542 | + if ($txn_status !== $TXN->status_ID()) { |
|
543 | + // switch between two possible basic outcomes |
|
544 | + switch ($TXN->status_ID()) { |
|
545 | + // TXN has been updated in some way |
|
546 | + case EEM_Transaction::overpaid_status_code: |
|
547 | + case EEM_Transaction::complete_status_code: |
|
548 | + case EEM_Transaction::incomplete_status_code: |
|
549 | + // send updated TXN results back to client, |
|
550 | + $response['espresso_thank_you_page'] = array( |
|
551 | + 'transaction_details' => $espresso_thank_you_page->get_transaction_details(), |
|
552 | + 'txn_status' => $TXN->status_ID() |
|
553 | + ); |
|
554 | + break; |
|
555 | + // or we have a bad TXN, or really slow IPN, so calculate the wait time and send that back... |
|
556 | + case EEM_Transaction::failed_status_code: |
|
557 | + default: |
|
558 | + // keep on waiting... |
|
559 | + return $espresso_thank_you_page->_update_server_wait_time($data['espresso_thank_you_page']); |
|
560 | + } |
|
561 | + // or is the TXN still failed (never been updated) ??? |
|
562 | + } else if ($TXN->failed()) { |
|
563 | + // keep on waiting... |
|
564 | + return $espresso_thank_you_page->_update_server_wait_time($data['espresso_thank_you_page']); |
|
565 | + } |
|
566 | + // TXN is happening so let's get the payments now |
|
567 | + // if we've already gotten payments then the heartbeat data will contain the timestamp of the last time we checked |
|
568 | + $since = isset($data['espresso_thank_you_page']['get_payments_since']) |
|
569 | + ? $data['espresso_thank_you_page']['get_payments_since'] |
|
570 | + : 0; |
|
571 | + // then check for payments |
|
572 | + $payments = $espresso_thank_you_page->get_txn_payments($since); |
|
573 | + // has a payment been processed ? |
|
574 | + if ( ! empty($payments) || $espresso_thank_you_page->_is_offline_payment_method) { |
|
575 | + if ($since) { |
|
576 | + $response['espresso_thank_you_page'] = array( |
|
577 | + 'new_payments' => $espresso_thank_you_page->get_new_payments($payments), |
|
578 | + 'transaction_details' => $espresso_thank_you_page->get_transaction_details(), |
|
579 | + 'txn_status' => $TXN->status_ID() |
|
580 | + ); |
|
581 | + } else { |
|
582 | + $response['espresso_thank_you_page']['payment_details'] = $espresso_thank_you_page->get_payment_details( |
|
583 | + $payments |
|
584 | + ); |
|
585 | + } |
|
586 | + // reset time to check for payments |
|
587 | + $response['espresso_thank_you_page']['get_payments_since'] = time(); |
|
588 | + } else { |
|
589 | + $response['espresso_thank_you_page']['get_payments_since'] = $since; |
|
590 | + } |
|
591 | + return $response; |
|
592 | + } |
|
593 | + |
|
594 | + |
|
595 | + |
|
596 | + /** |
|
597 | + * _update_server_wait_time |
|
598 | + * |
|
599 | + * @param array $thank_you_page_data thank you page portion of the incoming JSON array from the WP heartbeat data |
|
600 | + * @return array |
|
601 | + * @throws \EE_Error |
|
602 | + */ |
|
603 | + private function _update_server_wait_time($thank_you_page_data = array()) |
|
604 | + { |
|
605 | + $response['espresso_thank_you_page'] = array( |
|
606 | + 'still_waiting' => isset($thank_you_page_data['initial_access']) |
|
607 | + ? time() - $thank_you_page_data['initial_access'] |
|
608 | + : 0, |
|
609 | + 'txn_status' => $this->_current_txn->status_ID() |
|
610 | + ); |
|
611 | + return $response; |
|
612 | + } |
|
613 | + |
|
614 | + |
|
615 | + |
|
616 | + /** |
|
617 | + * get_registration_details |
|
618 | + * |
|
619 | + * @throws \EE_Error |
|
620 | + */ |
|
621 | + public function get_registration_details() |
|
622 | + { |
|
623 | + //prepare variables for displaying |
|
624 | + $template_args = array(); |
|
625 | + $template_args['transaction'] = $this->_current_txn; |
|
626 | + $template_args['reg_url_link'] = $this->_reg_url_link; |
|
627 | + $template_args['is_primary'] = $this->_is_primary; |
|
628 | + $template_args['SPCO_attendee_information_url'] = $this->_SPCO_attendee_information_url; |
|
629 | + $template_args['resend_reg_confirmation_url'] = add_query_arg( |
|
630 | + array('token' => $this->_reg_url_link, 'resend_reg_confirmation' => 'true'), |
|
631 | + EE_Registry::instance()->CFG->core->thank_you_page_url() |
|
632 | + ); |
|
633 | + // verify template arguments |
|
634 | + EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction'); |
|
635 | + EEH_Template_Validator::verify_isnt_null( |
|
636 | + $template_args['SPCO_attendee_information_url'], |
|
637 | + '$SPCO_attendee_information_url' |
|
638 | + ); |
|
639 | + echo EEH_Template::locate_template( |
|
640 | + THANK_YOU_TEMPLATES_PATH . 'thank-you-page-registration-details.template.php', |
|
641 | + $template_args, |
|
642 | + true, |
|
643 | + true |
|
644 | + ); |
|
645 | + } |
|
646 | + |
|
647 | + |
|
648 | + |
|
649 | + /** |
|
650 | + * resend_reg_confirmation_email |
|
651 | + * |
|
652 | + * @throws \EE_Error |
|
653 | + */ |
|
654 | + public static function resend_reg_confirmation_email() |
|
655 | + { |
|
656 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
657 | + $reg_url_link = EE_Registry::instance()->REQ->get('token'); |
|
658 | + // was a REG_ID passed ? |
|
659 | + if ($reg_url_link) { |
|
660 | + $registration = EE_Registry::instance()->load_model('Registration')->get_one( |
|
661 | + array(array('REG_url_link' => $reg_url_link)) |
|
662 | + ); |
|
663 | + if ($registration instanceof EE_Registration) { |
|
664 | + // resend email |
|
665 | + EED_Messages::process_resend(array('_REG_ID' => $registration->ID())); |
|
666 | + } else { |
|
667 | + EE_Error::add_error( |
|
668 | + __( |
|
669 | + 'The Registration Confirmation email could not be sent because a valid Registration could not be retrieved from the database.', |
|
670 | + 'event_espresso' |
|
671 | + ), |
|
672 | + __FILE__, |
|
673 | + __FUNCTION__, |
|
674 | + __LINE__ |
|
675 | + ); |
|
676 | + } |
|
677 | + } else { |
|
678 | + EE_Error::add_error( |
|
679 | + __( |
|
680 | + 'The Registration Confirmation email could not be sent because a registration token is missing or invalid.', |
|
681 | + 'event_espresso' |
|
682 | + ), |
|
683 | + __FILE__, |
|
684 | + __FUNCTION__, |
|
685 | + __LINE__ |
|
686 | + ); |
|
687 | + } |
|
688 | + // request sent via AJAX ? |
|
689 | + if (EE_FRONT_AJAX) { |
|
690 | + echo wp_json_encode(EE_Error::get_notices(false)); |
|
691 | + die(); |
|
692 | + // or was JS disabled ? |
|
693 | + } else { |
|
694 | + // save errors so that they get picked up on the next request |
|
695 | + EE_Error::get_notices(true, true); |
|
696 | + wp_safe_redirect( |
|
697 | + add_query_arg( |
|
698 | + array('e_reg_url_link' => $reg_url_link), |
|
699 | + EE_Registry::instance()->CFG->core->thank_you_page_url() |
|
700 | + ) |
|
701 | + ); |
|
702 | + } |
|
703 | + } |
|
704 | + |
|
705 | + |
|
706 | + |
|
707 | + /** |
|
708 | + * get_ajax_content |
|
709 | + * |
|
710 | + * @return void |
|
711 | + * @throws \EE_Error |
|
712 | + */ |
|
713 | + public function get_ajax_content() |
|
714 | + { |
|
715 | + if ( ! $this->get_txn()) { |
|
716 | + return; |
|
717 | + } |
|
718 | + // first determine which event(s) require pre-approval or not |
|
719 | + $events = array(); |
|
720 | + $events_requiring_pre_approval = array(); |
|
721 | + foreach ($this->_current_txn->registrations() as $registration) { |
|
722 | + if ($registration instanceof EE_Registration) { |
|
723 | + $event = $registration->event(); |
|
724 | + if ($event instanceof EE_Event) { |
|
725 | + if ($registration->is_not_approved() && $registration->event() instanceof EE_Event) { |
|
726 | + $events_requiring_pre_approval[$event->ID()] = $event; |
|
727 | + } else { |
|
728 | + $events[$event->ID()] = $event; |
|
729 | + } |
|
730 | + } |
|
731 | + } |
|
732 | + } |
|
733 | + $this->display_details_for_events_requiring_pre_approval($events_requiring_pre_approval); |
|
734 | + $this->display_details_for_events($events); |
|
735 | + } |
|
736 | + |
|
737 | + |
|
738 | + |
|
739 | + /** |
|
740 | + * display_details_for_events |
|
741 | + * |
|
742 | + * @param EE_Event[] $events |
|
743 | + * @return void |
|
744 | + */ |
|
745 | + public function display_details_for_events($events = array()) |
|
746 | + { |
|
747 | + if ( ! empty($events)) { |
|
748 | + ?> |
|
749 | 749 | <div id="espresso-thank-you-page-ajax-content-dv"> |
750 | 750 | <div id="espresso-thank-you-page-ajax-transaction-dv"></div> |
751 | 751 | <div id="espresso-thank-you-page-ajax-payment-dv"></div> |
752 | 752 | <div id="espresso-thank-you-page-ajax-loading-dv"> |
753 | 753 | <div id="ee-ajax-loading-dv" class="float-left lt-blue-text"> |
754 | 754 | <span class="dashicons dashicons-upload"></span><span id="ee-ajax-loading-msg-spn"><?php _e( |
755 | - 'loading transaction and payment information...', |
|
756 | - 'event_espresso' |
|
757 | - ); ?></span> |
|
755 | + 'loading transaction and payment information...', |
|
756 | + 'event_espresso' |
|
757 | + ); ?></span> |
|
758 | 758 | </div> |
759 | 759 | <?php if ( ! $this->_is_offline_payment_method && ! $this->_payments_closed) : ?> |
760 | 760 | <p id="ee-ajax-loading-pg" class="highlight-bg small-text clear"> |
761 | 761 | <?php echo apply_filters( |
762 | - 'EED_Thank_You_Page__get_ajax_content__waiting_for_IPN_msg', |
|
763 | - __( |
|
764 | - 'Some payment gateways can take 15 minutes or more to return their payment notification, so please be patient if you require payment confirmation as soon as possible. Please note that as soon as everything is finalized, we will send your full payment and registration confirmation results to you via email.', |
|
765 | - 'event_espresso' |
|
766 | - ) |
|
767 | - ); ?> |
|
762 | + 'EED_Thank_You_Page__get_ajax_content__waiting_for_IPN_msg', |
|
763 | + __( |
|
764 | + 'Some payment gateways can take 15 minutes or more to return their payment notification, so please be patient if you require payment confirmation as soon as possible. Please note that as soon as everything is finalized, we will send your full payment and registration confirmation results to you via email.', |
|
765 | + 'event_espresso' |
|
766 | + ) |
|
767 | + ); ?> |
|
768 | 768 | <br/> |
769 | 769 | <span class="jst-rght ee-block small-text lt-grey-text"> |
770 | 770 | <?php _e('current wait time ', 'event_espresso'); ?> |
@@ -775,120 +775,120 @@ discard block |
||
775 | 775 | <div class="clear"></div> |
776 | 776 | </div> |
777 | 777 | <?php |
778 | - } |
|
779 | - } |
|
778 | + } |
|
779 | + } |
|
780 | 780 | |
781 | 781 | |
782 | 782 | |
783 | - /** |
|
784 | - * display_details_for_events_requiring_pre_approval |
|
785 | - * |
|
786 | - * @param EE_Event[] $events |
|
787 | - * @return void |
|
788 | - */ |
|
789 | - public function display_details_for_events_requiring_pre_approval($events = array()) |
|
790 | - { |
|
791 | - if ( ! empty($events)) { |
|
792 | - ?> |
|
783 | + /** |
|
784 | + * display_details_for_events_requiring_pre_approval |
|
785 | + * |
|
786 | + * @param EE_Event[] $events |
|
787 | + * @return void |
|
788 | + */ |
|
789 | + public function display_details_for_events_requiring_pre_approval($events = array()) |
|
790 | + { |
|
791 | + if ( ! empty($events)) { |
|
792 | + ?> |
|
793 | 793 | <div id="espresso-thank-you-page-not-approved-message-dv"> |
794 | 794 | <h4 class="orange-text"><?php _e('Important Notice:', 'event_espresso'); ?></h4> |
795 | 795 | <p id="events-requiring-pre-approval-pg" class="small-text"> |
796 | 796 | <?php echo apply_filters( |
797 | - 'AHEE__EED_Thank_You_Page__get_ajax_content__not_approved_message', |
|
798 | - __( |
|
799 | - 'The following Event(s) you have registered for do not require payment at this time and will not be billed for during this transaction. Billing will only occur after all attendees have been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.', |
|
800 | - 'event_espresso' |
|
801 | - ) |
|
802 | - ); ?> |
|
797 | + 'AHEE__EED_Thank_You_Page__get_ajax_content__not_approved_message', |
|
798 | + __( |
|
799 | + 'The following Event(s) you have registered for do not require payment at this time and will not be billed for during this transaction. Billing will only occur after all attendees have been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.', |
|
800 | + 'event_espresso' |
|
801 | + ) |
|
802 | + ); ?> |
|
803 | 803 | </p> |
804 | 804 | <ul class="events-requiring-pre-approval-ul"> |
805 | 805 | <?php foreach ($events as $event) { |
806 | - if ($event instanceof EE_Event) { |
|
807 | - echo '<li><span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>', |
|
808 | - $event->name(), |
|
809 | - '</li>'; |
|
810 | - } |
|
811 | - } ?> |
|
806 | + if ($event instanceof EE_Event) { |
|
807 | + echo '<li><span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>', |
|
808 | + $event->name(), |
|
809 | + '</li>'; |
|
810 | + } |
|
811 | + } ?> |
|
812 | 812 | </ul> |
813 | 813 | <div class="clear"></div> |
814 | 814 | </div> |
815 | 815 | <?php |
816 | - } |
|
817 | - } |
|
818 | - |
|
819 | - |
|
820 | - |
|
821 | - /** |
|
822 | - * get_transaction_details |
|
823 | - * |
|
824 | - * @return string |
|
825 | - * @throws \EE_Error |
|
826 | - */ |
|
827 | - public function get_transaction_details() |
|
828 | - { |
|
829 | - //prepare variables for displaying |
|
830 | - $template_args = array(); |
|
831 | - $template_args['transaction'] = $this->_current_txn; |
|
832 | - $template_args['reg_url_link'] = $this->_reg_url_link; |
|
833 | - $template_args['primary_registrant_name'] = $this->_primary_registrant->attendee()->full_name(true); |
|
834 | - // link to SPCO payment_options |
|
835 | - $template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link; |
|
836 | - $template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url; |
|
837 | - // verify template arguments |
|
838 | - EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction'); |
|
839 | - EEH_Template_Validator::verify_isnt_null( |
|
840 | - $template_args['show_try_pay_again_link'], |
|
841 | - '$show_try_pay_again_link' |
|
842 | - ); |
|
843 | - EEH_Template_Validator::verify_isnt_null( |
|
844 | - $template_args['SPCO_payment_options_url'], |
|
845 | - '$SPCO_payment_options_url' |
|
846 | - ); |
|
847 | - return EEH_Template::locate_template( |
|
848 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-transaction-details.template.php', |
|
849 | - $template_args, |
|
850 | - true, |
|
851 | - true |
|
852 | - ); |
|
853 | - } |
|
854 | - |
|
855 | - |
|
856 | - |
|
857 | - /** |
|
858 | - * get_payment_row_html |
|
859 | - * |
|
860 | - * @param EE_Payment $payment |
|
861 | - * @return string |
|
862 | - * @throws \EE_Error |
|
863 | - */ |
|
864 | - public function get_payment_row_html($payment = null) |
|
865 | - { |
|
866 | - $html = ''; |
|
867 | - if ($payment instanceof EE_Payment) { |
|
868 | - if ( |
|
869 | - $payment->payment_method() instanceof EE_Payment_Method |
|
870 | - && $payment->status() === EEM_Payment::status_id_failed |
|
871 | - && $payment->payment_method()->is_off_site() |
|
872 | - ) { |
|
873 | - // considering the registrant has made it to the Thank You page, |
|
874 | - // any failed payments may actually be pending and the IPN is just slow |
|
875 | - // so let's |
|
876 | - $payment->set_status(EEM_Payment::status_id_pending); |
|
877 | - } |
|
878 | - $payment_declined_msg = $payment->STS_ID() === EEM_Payment::status_id_declined |
|
879 | - ? '<br /><span class="small-text">' . $payment->gateway_response() . '</span>' |
|
880 | - : ''; |
|
881 | - $html .= ' |
|
816 | + } |
|
817 | + } |
|
818 | + |
|
819 | + |
|
820 | + |
|
821 | + /** |
|
822 | + * get_transaction_details |
|
823 | + * |
|
824 | + * @return string |
|
825 | + * @throws \EE_Error |
|
826 | + */ |
|
827 | + public function get_transaction_details() |
|
828 | + { |
|
829 | + //prepare variables for displaying |
|
830 | + $template_args = array(); |
|
831 | + $template_args['transaction'] = $this->_current_txn; |
|
832 | + $template_args['reg_url_link'] = $this->_reg_url_link; |
|
833 | + $template_args['primary_registrant_name'] = $this->_primary_registrant->attendee()->full_name(true); |
|
834 | + // link to SPCO payment_options |
|
835 | + $template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link; |
|
836 | + $template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url; |
|
837 | + // verify template arguments |
|
838 | + EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction'); |
|
839 | + EEH_Template_Validator::verify_isnt_null( |
|
840 | + $template_args['show_try_pay_again_link'], |
|
841 | + '$show_try_pay_again_link' |
|
842 | + ); |
|
843 | + EEH_Template_Validator::verify_isnt_null( |
|
844 | + $template_args['SPCO_payment_options_url'], |
|
845 | + '$SPCO_payment_options_url' |
|
846 | + ); |
|
847 | + return EEH_Template::locate_template( |
|
848 | + THANK_YOU_TEMPLATES_PATH . 'thank-you-page-transaction-details.template.php', |
|
849 | + $template_args, |
|
850 | + true, |
|
851 | + true |
|
852 | + ); |
|
853 | + } |
|
854 | + |
|
855 | + |
|
856 | + |
|
857 | + /** |
|
858 | + * get_payment_row_html |
|
859 | + * |
|
860 | + * @param EE_Payment $payment |
|
861 | + * @return string |
|
862 | + * @throws \EE_Error |
|
863 | + */ |
|
864 | + public function get_payment_row_html($payment = null) |
|
865 | + { |
|
866 | + $html = ''; |
|
867 | + if ($payment instanceof EE_Payment) { |
|
868 | + if ( |
|
869 | + $payment->payment_method() instanceof EE_Payment_Method |
|
870 | + && $payment->status() === EEM_Payment::status_id_failed |
|
871 | + && $payment->payment_method()->is_off_site() |
|
872 | + ) { |
|
873 | + // considering the registrant has made it to the Thank You page, |
|
874 | + // any failed payments may actually be pending and the IPN is just slow |
|
875 | + // so let's |
|
876 | + $payment->set_status(EEM_Payment::status_id_pending); |
|
877 | + } |
|
878 | + $payment_declined_msg = $payment->STS_ID() === EEM_Payment::status_id_declined |
|
879 | + ? '<br /><span class="small-text">' . $payment->gateway_response() . '</span>' |
|
880 | + : ''; |
|
881 | + $html .= ' |
|
882 | 882 | <tr> |
883 | 883 | <td> |
884 | 884 | ' . $payment->timestamp() . ' |
885 | 885 | </td> |
886 | 886 | <td> |
887 | 887 | ' . ( |
888 | - $payment->payment_method() instanceof EE_Payment_Method |
|
889 | - ? $payment->payment_method()->name() |
|
890 | - : __('Unknown', 'event_espresso') |
|
891 | - ) . ' |
|
888 | + $payment->payment_method() instanceof EE_Payment_Method |
|
889 | + ? $payment->payment_method()->name() |
|
890 | + : __('Unknown', 'event_espresso') |
|
891 | + ) . ' |
|
892 | 892 | </td> |
893 | 893 | <td class="jst-rght"> |
894 | 894 | ' . EEH_Template::format_currency($payment->amount()) . ' |
@@ -897,87 +897,87 @@ discard block |
||
897 | 897 | ' . $payment->pretty_status(true) . $payment_declined_msg . ' |
898 | 898 | </td> |
899 | 899 | </tr>'; |
900 | - do_action('AHEE__thank_you_page_payment_details_template__after_each_payment', $payment); |
|
901 | - } |
|
902 | - return $html; |
|
903 | - } |
|
904 | - |
|
905 | - |
|
906 | - |
|
907 | - /** |
|
908 | - * get_payment_details |
|
909 | - * |
|
910 | - * @param array $payments |
|
911 | - * @return string |
|
912 | - * @throws \EE_Error |
|
913 | - */ |
|
914 | - public function get_payment_details($payments = array()) |
|
915 | - { |
|
916 | - //prepare variables for displaying |
|
917 | - $template_args = array(); |
|
918 | - $template_args['transaction'] = $this->_current_txn; |
|
919 | - $template_args['reg_url_link'] = $this->_reg_url_link; |
|
920 | - $template_args['payments'] = array(); |
|
921 | - foreach ($payments as $payment) { |
|
922 | - $template_args['payments'][] = $this->get_payment_row_html($payment); |
|
923 | - } |
|
924 | - //create a hacky payment object, but dont save it |
|
925 | - $payment = EE_Payment::new_instance( |
|
926 | - array( |
|
927 | - 'TXN_ID' => $this->_current_txn->ID(), |
|
928 | - 'STS_ID' => EEM_Payment::status_id_pending, |
|
929 | - 'PAY_timestamp' => time(), |
|
930 | - 'PAY_amount' => $this->_current_txn->total(), |
|
931 | - 'PMD_ID' => $this->_current_txn->payment_method_ID() |
|
932 | - ) |
|
933 | - ); |
|
934 | - $payment_method = $this->_current_txn->payment_method(); |
|
935 | - if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base) { |
|
936 | - $template_args['gateway_content'] = $payment_method->type_obj()->payment_overview_content($payment); |
|
937 | - } else { |
|
938 | - $template_args['gateway_content'] = ''; |
|
939 | - } |
|
940 | - // link to SPCO payment_options |
|
941 | - $template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link; |
|
942 | - $template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url; |
|
943 | - // verify template arguments |
|
944 | - EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction'); |
|
945 | - EEH_Template_Validator::verify_isnt_null($template_args['payments'], '$payments'); |
|
946 | - EEH_Template_Validator::verify_isnt_null( |
|
947 | - $template_args['show_try_pay_again_link'], |
|
948 | - '$show_try_pay_again_link' |
|
949 | - ); |
|
950 | - EEH_Template_Validator::verify_isnt_null($template_args['gateway_content'], '$gateway_content'); |
|
951 | - EEH_Template_Validator::verify_isnt_null( |
|
952 | - $template_args['SPCO_payment_options_url'], |
|
953 | - '$SPCO_payment_options_url' |
|
954 | - ); |
|
955 | - return EEH_Template::locate_template( |
|
956 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-payment-details.template.php', |
|
957 | - $template_args, |
|
958 | - true, |
|
959 | - true |
|
960 | - ); |
|
961 | - } |
|
962 | - |
|
963 | - |
|
964 | - |
|
965 | - /** |
|
966 | - * get_payment_details |
|
967 | - * |
|
968 | - * @param array $payments |
|
969 | - * @return string |
|
970 | - * @throws \EE_Error |
|
971 | - */ |
|
972 | - public function get_new_payments($payments = array()) |
|
973 | - { |
|
974 | - $payments_html = ''; |
|
975 | - //prepare variables for displaying |
|
976 | - foreach ($payments as $payment) { |
|
977 | - $payments_html .= $this->get_payment_row_html($payment); |
|
978 | - } |
|
979 | - return $payments_html; |
|
980 | - } |
|
900 | + do_action('AHEE__thank_you_page_payment_details_template__after_each_payment', $payment); |
|
901 | + } |
|
902 | + return $html; |
|
903 | + } |
|
904 | + |
|
905 | + |
|
906 | + |
|
907 | + /** |
|
908 | + * get_payment_details |
|
909 | + * |
|
910 | + * @param array $payments |
|
911 | + * @return string |
|
912 | + * @throws \EE_Error |
|
913 | + */ |
|
914 | + public function get_payment_details($payments = array()) |
|
915 | + { |
|
916 | + //prepare variables for displaying |
|
917 | + $template_args = array(); |
|
918 | + $template_args['transaction'] = $this->_current_txn; |
|
919 | + $template_args['reg_url_link'] = $this->_reg_url_link; |
|
920 | + $template_args['payments'] = array(); |
|
921 | + foreach ($payments as $payment) { |
|
922 | + $template_args['payments'][] = $this->get_payment_row_html($payment); |
|
923 | + } |
|
924 | + //create a hacky payment object, but dont save it |
|
925 | + $payment = EE_Payment::new_instance( |
|
926 | + array( |
|
927 | + 'TXN_ID' => $this->_current_txn->ID(), |
|
928 | + 'STS_ID' => EEM_Payment::status_id_pending, |
|
929 | + 'PAY_timestamp' => time(), |
|
930 | + 'PAY_amount' => $this->_current_txn->total(), |
|
931 | + 'PMD_ID' => $this->_current_txn->payment_method_ID() |
|
932 | + ) |
|
933 | + ); |
|
934 | + $payment_method = $this->_current_txn->payment_method(); |
|
935 | + if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base) { |
|
936 | + $template_args['gateway_content'] = $payment_method->type_obj()->payment_overview_content($payment); |
|
937 | + } else { |
|
938 | + $template_args['gateway_content'] = ''; |
|
939 | + } |
|
940 | + // link to SPCO payment_options |
|
941 | + $template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link; |
|
942 | + $template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url; |
|
943 | + // verify template arguments |
|
944 | + EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction'); |
|
945 | + EEH_Template_Validator::verify_isnt_null($template_args['payments'], '$payments'); |
|
946 | + EEH_Template_Validator::verify_isnt_null( |
|
947 | + $template_args['show_try_pay_again_link'], |
|
948 | + '$show_try_pay_again_link' |
|
949 | + ); |
|
950 | + EEH_Template_Validator::verify_isnt_null($template_args['gateway_content'], '$gateway_content'); |
|
951 | + EEH_Template_Validator::verify_isnt_null( |
|
952 | + $template_args['SPCO_payment_options_url'], |
|
953 | + '$SPCO_payment_options_url' |
|
954 | + ); |
|
955 | + return EEH_Template::locate_template( |
|
956 | + THANK_YOU_TEMPLATES_PATH . 'thank-you-page-payment-details.template.php', |
|
957 | + $template_args, |
|
958 | + true, |
|
959 | + true |
|
960 | + ); |
|
961 | + } |
|
962 | + |
|
963 | + |
|
964 | + |
|
965 | + /** |
|
966 | + * get_payment_details |
|
967 | + * |
|
968 | + * @param array $payments |
|
969 | + * @return string |
|
970 | + * @throws \EE_Error |
|
971 | + */ |
|
972 | + public function get_new_payments($payments = array()) |
|
973 | + { |
|
974 | + $payments_html = ''; |
|
975 | + //prepare variables for displaying |
|
976 | + foreach ($payments as $payment) { |
|
977 | + $payments_html .= $this->get_payment_row_html($payment); |
|
978 | + } |
|
979 | + return $payments_html; |
|
980 | + } |
|
981 | 981 | |
982 | 982 | |
983 | 983 | } |
@@ -52,7 +52,7 @@ |
||
52 | 52 | return; |
53 | 53 | } |
54 | 54 | $post = reset($wp_query->posts); |
55 | - if ( ! $post instanceof WP_Post || $post->ID !== EE_Registry::instance()->CFG->core->thank_you_page_id ) { |
|
55 | + if ( ! $post instanceof WP_Post || $post->ID !== EE_Registry::instance()->CFG->core->thank_you_page_id) { |
|
56 | 56 | return; |
57 | 57 | } |
58 | 58 | $this->is_thank_you_page = true; |
@@ -20,75 +20,75 @@ |
||
20 | 20 | class EspressoThankYou extends EspressoShortcode |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * @var boolean $is_thank_you_page |
|
25 | - */ |
|
26 | - private $is_thank_you_page = false; |
|
27 | - |
|
28 | - /** |
|
29 | - * the actual shortcode tag that gets registered with WordPress |
|
30 | - * |
|
31 | - * @return string |
|
32 | - */ |
|
33 | - public function getTag() |
|
34 | - { |
|
35 | - return 'ESPRESSO_THANK_YOU'; |
|
36 | - } |
|
37 | - |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * the time in seconds to cache the results of the processShortcode() method |
|
42 | - * 0 means the processShortcode() results will NOT be cached at all |
|
43 | - * |
|
44 | - * @return int |
|
45 | - */ |
|
46 | - public function cacheExpiration() |
|
47 | - { |
|
48 | - return 0; |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * a place for adding any initialization code that needs to run prior to wp_header(). |
|
54 | - * this may be required for shortcodes that utilize a corresponding module, |
|
55 | - * and need to enqueue assets for that module |
|
56 | - * |
|
57 | - * @return void |
|
58 | - * @throws \EE_Error |
|
59 | - */ |
|
60 | - public function initializeShortcode() |
|
61 | - { |
|
62 | - global $wp_query; |
|
63 | - if (empty($wp_query->posts) || count($wp_query->posts) > 1) { |
|
64 | - return; |
|
65 | - } |
|
66 | - $post = reset($wp_query->posts); |
|
67 | - if ( ! $post instanceof WP_Post || $post->ID !== EE_Registry::instance()->CFG->core->thank_you_page_id ) { |
|
68 | - return; |
|
69 | - } |
|
70 | - $this->is_thank_you_page = true; |
|
71 | - \EED_Thank_You_Page::instance()->load_resources(); |
|
72 | - $this->shortcodeHasBeenInitialized(); |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * callback that runs when the shortcode is encountered in post content. |
|
79 | - * IMPORTANT !!! |
|
80 | - * remember that shortcode content should be RETURNED and NOT echoed out |
|
81 | - * |
|
82 | - * @param array $attributes |
|
83 | - * @return string |
|
84 | - * @throws \EE_Error |
|
85 | - */ |
|
86 | - public function processShortcode($attributes = array()) |
|
87 | - { |
|
88 | - return $this->is_thank_you_page |
|
89 | - ? \EED_Thank_You_Page::instance()->thank_you_page_results() |
|
90 | - : ''; |
|
91 | - } |
|
23 | + /** |
|
24 | + * @var boolean $is_thank_you_page |
|
25 | + */ |
|
26 | + private $is_thank_you_page = false; |
|
27 | + |
|
28 | + /** |
|
29 | + * the actual shortcode tag that gets registered with WordPress |
|
30 | + * |
|
31 | + * @return string |
|
32 | + */ |
|
33 | + public function getTag() |
|
34 | + { |
|
35 | + return 'ESPRESSO_THANK_YOU'; |
|
36 | + } |
|
37 | + |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * the time in seconds to cache the results of the processShortcode() method |
|
42 | + * 0 means the processShortcode() results will NOT be cached at all |
|
43 | + * |
|
44 | + * @return int |
|
45 | + */ |
|
46 | + public function cacheExpiration() |
|
47 | + { |
|
48 | + return 0; |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * a place for adding any initialization code that needs to run prior to wp_header(). |
|
54 | + * this may be required for shortcodes that utilize a corresponding module, |
|
55 | + * and need to enqueue assets for that module |
|
56 | + * |
|
57 | + * @return void |
|
58 | + * @throws \EE_Error |
|
59 | + */ |
|
60 | + public function initializeShortcode() |
|
61 | + { |
|
62 | + global $wp_query; |
|
63 | + if (empty($wp_query->posts) || count($wp_query->posts) > 1) { |
|
64 | + return; |
|
65 | + } |
|
66 | + $post = reset($wp_query->posts); |
|
67 | + if ( ! $post instanceof WP_Post || $post->ID !== EE_Registry::instance()->CFG->core->thank_you_page_id ) { |
|
68 | + return; |
|
69 | + } |
|
70 | + $this->is_thank_you_page = true; |
|
71 | + \EED_Thank_You_Page::instance()->load_resources(); |
|
72 | + $this->shortcodeHasBeenInitialized(); |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * callback that runs when the shortcode is encountered in post content. |
|
79 | + * IMPORTANT !!! |
|
80 | + * remember that shortcode content should be RETURNED and NOT echoed out |
|
81 | + * |
|
82 | + * @param array $attributes |
|
83 | + * @return string |
|
84 | + * @throws \EE_Error |
|
85 | + */ |
|
86 | + public function processShortcode($attributes = array()) |
|
87 | + { |
|
88 | + return $this->is_thank_you_page |
|
89 | + ? \EED_Thank_You_Page::instance()->thank_you_page_results() |
|
90 | + : ''; |
|
91 | + } |
|
92 | 92 | |
93 | 93 | |
94 | 94 |
@@ -38,7 +38,7 @@ |
||
38 | 38 | |
39 | 39 | |
40 | 40 | /** |
41 | - * @param string|array $capability - the capability to be checked, like: 'ee_edit_registrations', |
|
41 | + * @param string $capability - the capability to be checked, like: 'ee_edit_registrations', |
|
42 | 42 | * or an array of capability strings |
43 | 43 | * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
44 | 44 | * @param int $ID - (optional) ID for item where current_user_can is being called from |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | use EventEspresso\core\exceptions\InvalidDataTypeException; |
5 | 5 | |
6 | 6 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
7 | - exit('No direct script access allowed'); |
|
7 | + exit('No direct script access allowed'); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | |
@@ -20,72 +20,72 @@ discard block |
||
20 | 20 | class CapCheck implements CapCheckInterface |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * @var string|array $capability |
|
25 | - */ |
|
26 | - private $capability; |
|
27 | - |
|
28 | - /** |
|
29 | - * @var string $context |
|
30 | - */ |
|
31 | - private $context; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var int|string $ID |
|
35 | - */ |
|
36 | - private $ID; |
|
37 | - |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * @param string|array $capability - the capability to be checked, like: 'ee_edit_registrations', |
|
42 | - * or an array of capability strings |
|
43 | - * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
|
44 | - * @param int $ID - (optional) ID for item where current_user_can is being called from |
|
45 | - * @throws InvalidDataTypeException |
|
46 | - */ |
|
47 | - public function __construct($capability, $context, $ID = 0) |
|
48 | - { |
|
49 | - if ( ! is_string($capability)) { |
|
50 | - throw new InvalidDataTypeException('$capability', $capability, 'string'); |
|
51 | - } |
|
52 | - if ( ! is_string($context)) { |
|
53 | - throw new InvalidDataTypeException('$context', $context, 'string'); |
|
54 | - } |
|
55 | - $this->capability = $capability; |
|
56 | - $this->context = strtolower(str_replace(' ', '_', $context)); |
|
57 | - $this->ID = $ID; |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * @return string|array |
|
64 | - */ |
|
65 | - public function capability() |
|
66 | - { |
|
67 | - return $this->capability; |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * @return string |
|
74 | - */ |
|
75 | - public function context() |
|
76 | - { |
|
77 | - return $this->context; |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * @return int|string |
|
84 | - */ |
|
85 | - public function ID() |
|
86 | - { |
|
87 | - return $this->ID; |
|
88 | - } |
|
23 | + /** |
|
24 | + * @var string|array $capability |
|
25 | + */ |
|
26 | + private $capability; |
|
27 | + |
|
28 | + /** |
|
29 | + * @var string $context |
|
30 | + */ |
|
31 | + private $context; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var int|string $ID |
|
35 | + */ |
|
36 | + private $ID; |
|
37 | + |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * @param string|array $capability - the capability to be checked, like: 'ee_edit_registrations', |
|
42 | + * or an array of capability strings |
|
43 | + * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
|
44 | + * @param int $ID - (optional) ID for item where current_user_can is being called from |
|
45 | + * @throws InvalidDataTypeException |
|
46 | + */ |
|
47 | + public function __construct($capability, $context, $ID = 0) |
|
48 | + { |
|
49 | + if ( ! is_string($capability)) { |
|
50 | + throw new InvalidDataTypeException('$capability', $capability, 'string'); |
|
51 | + } |
|
52 | + if ( ! is_string($context)) { |
|
53 | + throw new InvalidDataTypeException('$context', $context, 'string'); |
|
54 | + } |
|
55 | + $this->capability = $capability; |
|
56 | + $this->context = strtolower(str_replace(' ', '_', $context)); |
|
57 | + $this->ID = $ID; |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * @return string|array |
|
64 | + */ |
|
65 | + public function capability() |
|
66 | + { |
|
67 | + return $this->capability; |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * @return string |
|
74 | + */ |
|
75 | + public function context() |
|
76 | + { |
|
77 | + return $this->context; |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * @return int|string |
|
84 | + */ |
|
85 | + public function ID() |
|
86 | + { |
|
87 | + return $this->ID; |
|
88 | + } |
|
89 | 89 | |
90 | 90 | |
91 | 91 | } |
@@ -8,8 +8,8 @@ discard block |
||
8 | 8 | use EventEspresso\core\services\locators\LocatorInterface; |
9 | 9 | use EventEspresso\core\services\locators\FileLocator; |
10 | 10 | |
11 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
12 | - exit( 'No direct script access allowed' ); |
|
11 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
12 | + exit('No direct script access allowed'); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | LocatorInterface $file_locator = null |
82 | 82 | ) { |
83 | 83 | $this->collection_details = $collection_details; |
84 | - if ( ! $collection instanceof CollectionInterface ) { |
|
85 | - $collection = new Collection( $this->collection_details->getCollectionInterface() ); |
|
84 | + if ( ! $collection instanceof CollectionInterface) { |
|
85 | + $collection = new Collection($this->collection_details->getCollectionInterface()); |
|
86 | 86 | } |
87 | 87 | $this->collection = $collection; |
88 | 88 | $this->file_locator = $file_locator; |
@@ -110,12 +110,12 @@ discard block |
||
110 | 110 | * @throws \EventEspresso\core\exceptions\InvalidEntityException |
111 | 111 | */ |
112 | 112 | protected function loadAllFromFilepaths() { |
113 | - if ( ! $this->file_locator instanceof FileLocator ) { |
|
113 | + if ( ! $this->file_locator instanceof FileLocator) { |
|
114 | 114 | $this->file_locator = new FileLocator(); |
115 | 115 | } |
116 | - $this->file_locator->setFileMask( $this->collection_details->getFileMask() ); |
|
116 | + $this->file_locator->setFileMask($this->collection_details->getFileMask()); |
|
117 | 117 | // find all of the files that match the file mask in the specified folder |
118 | - $this->file_locator->locate( $this->collection_details->getCollectionPaths() ); |
|
118 | + $this->file_locator->locate($this->collection_details->getCollectionPaths()); |
|
119 | 119 | // filter the results |
120 | 120 | $filepaths = (array) apply_filters( |
121 | 121 | 'FHEE__CollectionLoader__loadAllFromFilepath__filepaths', |
@@ -123,11 +123,11 @@ discard block |
||
123 | 123 | $this->collection_details->collectionName(), |
124 | 124 | $this->collection_details |
125 | 125 | ); |
126 | - if ( empty( $filepaths ) ) { |
|
126 | + if (empty($filepaths)) { |
|
127 | 127 | return; |
128 | 128 | } |
129 | - foreach ( $filepaths as $filepath ) { |
|
130 | - $this->loadClassFromFilepath( $filepath ); |
|
129 | + foreach ($filepaths as $filepath) { |
|
130 | + $this->loadClassFromFilepath($filepath); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
@@ -144,22 +144,22 @@ discard block |
||
144 | 144 | * @throws \EventEspresso\core\exceptions\InvalidFilePathException |
145 | 145 | * @throws \EventEspresso\core\exceptions\InvalidClassException |
146 | 146 | */ |
147 | - protected function loadClassFromFilepath( $filepath ) { |
|
148 | - if ( ! is_string( $filepath ) ) { |
|
149 | - throw new InvalidDataTypeException( '$filepath', $filepath, 'string' ); |
|
147 | + protected function loadClassFromFilepath($filepath) { |
|
148 | + if ( ! is_string($filepath)) { |
|
149 | + throw new InvalidDataTypeException('$filepath', $filepath, 'string'); |
|
150 | 150 | } |
151 | - if ( ! is_readable( $filepath ) ) { |
|
152 | - throw new InvalidFilePathException( $filepath ); |
|
151 | + if ( ! is_readable($filepath)) { |
|
152 | + throw new InvalidFilePathException($filepath); |
|
153 | 153 | } |
154 | - require_once( $filepath ); |
|
154 | + require_once($filepath); |
|
155 | 155 | // extract filename from path |
156 | - $file_name = basename( $filepath ); |
|
156 | + $file_name = basename($filepath); |
|
157 | 157 | // now remove any file extensions |
158 | - $class_name = \EEH_File::get_classname_from_filepath_with_standard_filename( $file_name ); |
|
159 | - if ( ! class_exists( $class_name ) ) { |
|
160 | - throw new InvalidClassException( $class_name ); |
|
158 | + $class_name = \EEH_File::get_classname_from_filepath_with_standard_filename($file_name); |
|
159 | + if ( ! class_exists($class_name)) { |
|
160 | + throw new InvalidClassException($class_name); |
|
161 | 161 | } |
162 | - return $this->addEntityToCollection( new $class_name(), $file_name ); |
|
162 | + return $this->addEntityToCollection(new $class_name(), $file_name); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
@@ -173,15 +173,15 @@ discard block |
||
173 | 173 | * @return string |
174 | 174 | * @throws \EventEspresso\core\exceptions\InvalidEntityException |
175 | 175 | */ |
176 | - protected function addEntityToCollection( $entity, $identifier ) { |
|
176 | + protected function addEntityToCollection($entity, $identifier) { |
|
177 | 177 | do_action( |
178 | 178 | 'FHEE__CollectionLoader__addEntityToCollection__entity', |
179 | 179 | $entity, |
180 | 180 | $this->collection_details->collectionName(), |
181 | 181 | $this->collection_details |
182 | 182 | ); |
183 | - $identifier = $this->setIdentifier( $entity, $identifier ); |
|
184 | - if ( $this->collection->has( $identifier ) ) { |
|
183 | + $identifier = $this->setIdentifier($entity, $identifier); |
|
184 | + if ($this->collection->has($identifier)) { |
|
185 | 185 | do_action( |
186 | 186 | 'FHEE__CollectionLoader__addEntityToCollection__entity_already_added', |
187 | 187 | $this, |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | ); |
191 | 191 | return CollectionLoader::ENTITY_EXISTS; |
192 | 192 | } |
193 | - if( $this->collection->add( $entity, $identifier ) ) { |
|
193 | + if ($this->collection->add($entity, $identifier)) { |
|
194 | 194 | do_action( |
195 | 195 | 'FHEE__CollectionLoader__addEntityToCollection__entity_added', |
196 | 196 | $this, |
@@ -220,8 +220,8 @@ discard block |
||
220 | 220 | * @return string |
221 | 221 | * @throws \EventEspresso\core\exceptions\InvalidEntityException |
222 | 222 | */ |
223 | - protected function setIdentifier( $entity, $identifier ) { |
|
224 | - switch($this->collection_details->identifierType()) { |
|
223 | + protected function setIdentifier($entity, $identifier) { |
|
224 | + switch ($this->collection_details->identifierType()) { |
|
225 | 225 | // every unique object gets added to the collection, but not duplicates of the exact same object |
226 | 226 | case CollectionDetails::ID_OBJECT_HASH : |
227 | 227 | $identifier = spl_object_hash($entity); |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | $this->collection_details->collectionName(), |
279 | 279 | $this->collection_details |
280 | 280 | ); |
281 | - foreach ( $FQCNs as $FQCN ) { |
|
282 | - $this->loadClassFromFQCN( $FQCN ); |
|
281 | + foreach ($FQCNs as $FQCN) { |
|
282 | + $this->loadClassFromFQCN($FQCN); |
|
283 | 283 | } |
284 | 284 | } |
285 | 285 | |
@@ -295,15 +295,15 @@ discard block |
||
295 | 295 | * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
296 | 296 | * @throws \EventEspresso\core\exceptions\InvalidClassException |
297 | 297 | */ |
298 | - protected function loadClassFromFQCN( $FQCN ) { |
|
299 | - if ( ! is_string( $FQCN ) ) { |
|
300 | - throw new InvalidDataTypeException( '$FQCN', $FQCN, 'string' ); |
|
298 | + protected function loadClassFromFQCN($FQCN) { |
|
299 | + if ( ! is_string($FQCN)) { |
|
300 | + throw new InvalidDataTypeException('$FQCN', $FQCN, 'string'); |
|
301 | 301 | } |
302 | - if ( ! class_exists( $FQCN ) ) { |
|
303 | - throw new InvalidClassException( $FQCN ); |
|
302 | + if ( ! class_exists($FQCN)) { |
|
303 | + throw new InvalidClassException($FQCN); |
|
304 | 304 | } |
305 | 305 | return $this->addEntityToCollection( |
306 | - \EE_Registry::instance()->create( $FQCN ), |
|
306 | + \EE_Registry::instance()->create($FQCN), |
|
307 | 307 | $FQCN |
308 | 308 | ); |
309 | 309 | } |
@@ -199,13 +199,13 @@ discard block |
||
199 | 199 | ); |
200 | 200 | return CollectionLoader::ENTITY_ADDED; |
201 | 201 | } |
202 | - do_action( |
|
203 | - 'FHEE__CollectionLoader__addEntityToCollection__entity_not_added', |
|
204 | - $this, |
|
205 | - $this->collection_details->collectionName(), |
|
206 | - $this->collection_details |
|
207 | - ); |
|
208 | - return CollectionLoader::ENTITY_NOT_ADDED; |
|
202 | + do_action( |
|
203 | + 'FHEE__CollectionLoader__addEntityToCollection__entity_not_added', |
|
204 | + $this, |
|
205 | + $this->collection_details->collectionName(), |
|
206 | + $this->collection_details |
|
207 | + ); |
|
208 | + return CollectionLoader::ENTITY_NOT_ADDED; |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | |
@@ -220,37 +220,37 @@ discard block |
||
220 | 220 | * @throws \EventEspresso\core\exceptions\InvalidEntityException |
221 | 221 | */ |
222 | 222 | protected function setIdentifier( $entity, $identifier ) { |
223 | - switch($this->collection_details->identifierType()) { |
|
224 | - // every unique object gets added to the collection, but not duplicates of the exact same object |
|
225 | - case CollectionDetails::ID_OBJECT_HASH : |
|
226 | - $identifier = spl_object_hash($entity); |
|
227 | - break; |
|
228 | - // only one entity per class can be added to collection, like a singleton |
|
229 | - case CollectionDetails::ID_CLASS_NAME : |
|
230 | - $identifier = get_class($entity); |
|
231 | - break; |
|
232 | - // objects added to the collection based on entity callback, so the entity itself decides |
|
233 | - case CollectionDetails::ID_CALLBACK_METHOD : |
|
234 | - $identifier_callback = $this->collection_details->identifierCallback(); |
|
235 | - if ( ! method_exists($entity, $identifier_callback)) { |
|
236 | - throw new InvalidEntityException( |
|
237 | - $entity, |
|
238 | - $this->collection_details->getCollectionInterface(), |
|
239 | - sprintf( |
|
240 | - __( |
|
241 | - 'The current collection is configured to use a method named "%1$s" when setting or retrieving objects. The supplied entity is an instance |
|
223 | + switch($this->collection_details->identifierType()) { |
|
224 | + // every unique object gets added to the collection, but not duplicates of the exact same object |
|
225 | + case CollectionDetails::ID_OBJECT_HASH : |
|
226 | + $identifier = spl_object_hash($entity); |
|
227 | + break; |
|
228 | + // only one entity per class can be added to collection, like a singleton |
|
229 | + case CollectionDetails::ID_CLASS_NAME : |
|
230 | + $identifier = get_class($entity); |
|
231 | + break; |
|
232 | + // objects added to the collection based on entity callback, so the entity itself decides |
|
233 | + case CollectionDetails::ID_CALLBACK_METHOD : |
|
234 | + $identifier_callback = $this->collection_details->identifierCallback(); |
|
235 | + if ( ! method_exists($entity, $identifier_callback)) { |
|
236 | + throw new InvalidEntityException( |
|
237 | + $entity, |
|
238 | + $this->collection_details->getCollectionInterface(), |
|
239 | + sprintf( |
|
240 | + __( |
|
241 | + 'The current collection is configured to use a method named "%1$s" when setting or retrieving objects. The supplied entity is an instance |
|
242 | 242 | of "%2$s", but does not contain this method.', |
243 | - 'event_espresso' |
|
244 | - ), |
|
245 | - $identifier_callback, |
|
246 | - get_class($entity) |
|
247 | - ) |
|
248 | - ); |
|
249 | - } |
|
250 | - $identifier = $entity->{$identifier_callback}(); |
|
251 | - break; |
|
252 | - |
|
253 | - } |
|
243 | + 'event_espresso' |
|
244 | + ), |
|
245 | + $identifier_callback, |
|
246 | + get_class($entity) |
|
247 | + ) |
|
248 | + ); |
|
249 | + } |
|
250 | + $identifier = $entity->{$identifier_callback}(); |
|
251 | + break; |
|
252 | + |
|
253 | + } |
|
254 | 254 | return apply_filters( |
255 | 255 | 'FHEE__CollectionLoader__addEntityToCollection__identifier', |
256 | 256 | $identifier, |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * get_event |
37 | 37 | * attempts to retrieve an EE_Event object any way it can |
38 | 38 | * |
39 | - * @param int|WP_Post $EVT_ID |
|
39 | + * @param integer $EVT_ID |
|
40 | 40 | * @return EE_Event|null |
41 | 41 | * @throws \EE_Error |
42 | 42 | */ |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @access public |
115 | 115 | * @param int $EVT_ID |
116 | - * @return string |
|
116 | + * @return boolean |
|
117 | 117 | */ |
118 | 118 | public static function event_has_content_or_excerpt( $EVT_ID = 0 ) { |
119 | 119 | $event = EEH_Event_View::get_event( $EVT_ID ); |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * event_active_status |
134 | 134 | * |
135 | 135 | * @access public |
136 | - * @param null $num_words |
|
136 | + * @param integer $num_words |
|
137 | 137 | * @param null $more |
138 | 138 | * @return string |
139 | 139 | */ |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | * |
445 | 445 | * @access public |
446 | 446 | * @param int $EVT_ID |
447 | - * @param null $include_expired |
|
447 | + * @param false|null $include_expired |
|
448 | 448 | * @param bool $include_deleted |
449 | 449 | * @param null $limit |
450 | 450 | * @return EE_Datetime[] |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @return EE_Event|null |
41 | 41 | * @throws \EE_Error |
42 | 42 | */ |
43 | - public static function get_event( $EVT_ID = 0 ) { |
|
43 | + public static function get_event($EVT_ID = 0) { |
|
44 | 44 | // international newspaper? |
45 | 45 | global $post; |
46 | 46 | $EVT_ID = $EVT_ID instanceof WP_Post && $EVT_ID->post_type === 'espresso_events' |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | //If the event we have isn't an event but we do have an EVT_ID, let's try getting the event using the ID. |
69 | - if (! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) { |
|
69 | + if ( ! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) { |
|
70 | 70 | EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
71 | 71 | } |
72 | 72 | } |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | * @param int $EVT_ID |
84 | 84 | * @return boolean |
85 | 85 | */ |
86 | - public static function display_ticket_selector( $EVT_ID = 0 ) { |
|
87 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
86 | + public static function display_ticket_selector($EVT_ID = 0) { |
|
87 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
88 | 88 | return $event instanceof EE_Event ? $event->display_ticket_selector() : FALSE; |
89 | 89 | } |
90 | 90 | |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | * @param int $EVT_ID |
98 | 98 | * @return string |
99 | 99 | */ |
100 | - public static function event_status( $EVT_ID = 0 ) { |
|
101 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
102 | - return $event instanceof EE_Event ? $event->pretty_active_status( FALSE ) : ''; |
|
100 | + public static function event_status($EVT_ID = 0) { |
|
101 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
102 | + return $event instanceof EE_Event ? $event->pretty_active_status(FALSE) : ''; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | * @param int $EVT_ID |
112 | 112 | * @return string |
113 | 113 | */ |
114 | - public static function event_active_status( $EVT_ID = 0 ) { |
|
115 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
114 | + public static function event_active_status($EVT_ID = 0) { |
|
115 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
116 | 116 | return $event instanceof EE_Event ? $event->pretty_active_status() : 'inactive'; |
117 | 117 | } |
118 | 118 | |
@@ -125,13 +125,13 @@ discard block |
||
125 | 125 | * @param int $EVT_ID |
126 | 126 | * @return string |
127 | 127 | */ |
128 | - public static function event_has_content_or_excerpt( $EVT_ID = 0 ) { |
|
129 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
128 | + public static function event_has_content_or_excerpt($EVT_ID = 0) { |
|
129 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
130 | 130 | $has_content_or_excerpt = FALSE; |
131 | - if ( $event instanceof EE_Event ) { |
|
132 | - $has_content_or_excerpt = $event->description() != '' || $event->short_description( NULL, NULL, TRUE ) != '' ? TRUE : FALSE; |
|
131 | + if ($event instanceof EE_Event) { |
|
132 | + $has_content_or_excerpt = $event->description() != '' || $event->short_description(NULL, NULL, TRUE) != '' ? TRUE : FALSE; |
|
133 | 133 | } |
134 | - if ( is_archive() && ! ( espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list() )) { |
|
134 | + if (is_archive() && ! (espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list())) { |
|
135 | 135 | $has_content_or_excerpt = FALSE; |
136 | 136 | } |
137 | 137 | return $has_content_or_excerpt; |
@@ -147,15 +147,15 @@ discard block |
||
147 | 147 | * @param null $more |
148 | 148 | * @return string |
149 | 149 | */ |
150 | - public static function event_content_or_excerpt( $num_words = NULL, $more = NULL ) { |
|
150 | + public static function event_content_or_excerpt($num_words = NULL, $more = NULL) { |
|
151 | 151 | global $post; |
152 | 152 | ob_start(); |
153 | - if (( is_single() ) || ( is_archive() && espresso_display_full_description_in_event_list() )) { |
|
153 | + if ((is_single()) || (is_archive() && espresso_display_full_description_in_event_list())) { |
|
154 | 154 | // admin has chosen "full description" |
155 | 155 | // for the "Event Espresso - Events > Templates > Display Description" option |
156 | 156 | the_content(); |
157 | - } else if (( is_archive() && espresso_display_excerpt_in_event_list() ) ) { |
|
158 | - if ( has_excerpt( $post->ID )) { |
|
157 | + } else if ((is_archive() && espresso_display_excerpt_in_event_list())) { |
|
158 | + if (has_excerpt($post->ID)) { |
|
159 | 159 | // admin has chosen "excerpt (short desc)" |
160 | 160 | // for the "Event Espresso - Events > Templates > Display Description" option |
161 | 161 | // AND an excerpt actually exists |
@@ -164,20 +164,20 @@ discard block |
||
164 | 164 | // admin has chosen "excerpt (short desc)" |
165 | 165 | // for the "Event Espresso - Events > Templates > Display Description" option |
166 | 166 | // but NO excerpt actually exists, so we need to create one |
167 | - if ( ! empty( $num_words )) { |
|
168 | - if ( empty( $more )) { |
|
169 | - $more_link_text = __( '(more…)' ); |
|
170 | - $more = ' <a href="' . get_permalink() . '"'; |
|
167 | + if ( ! empty($num_words)) { |
|
168 | + if (empty($more)) { |
|
169 | + $more_link_text = __('(more…)'); |
|
170 | + $more = ' <a href="'.get_permalink().'"'; |
|
171 | 171 | $more .= ' class="more-link"'; |
172 | 172 | $more .= \EED_Events_Archive::link_target(); |
173 | - $more .= '>' . $more_link_text . '</a>'; |
|
174 | - $more = apply_filters( 'the_content_more_link', $more, $more_link_text ); |
|
173 | + $more .= '>'.$more_link_text.'</a>'; |
|
174 | + $more = apply_filters('the_content_more_link', $more, $more_link_text); |
|
175 | 175 | } |
176 | - $content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' )); |
|
176 | + $content = str_replace('NOMORELINK', '', get_the_content('NOMORELINK')); |
|
177 | 177 | |
178 | - $content = wp_trim_words( $content, $num_words, ' ' ) . $more; |
|
178 | + $content = wp_trim_words($content, $num_words, ' ').$more; |
|
179 | 179 | } else { |
180 | - $content = get_the_content(); |
|
180 | + $content = get_the_content(); |
|
181 | 181 | } |
182 | 182 | global $allowedtags; |
183 | 183 | // make sure links are allowed |
@@ -191,15 +191,15 @@ discard block |
||
191 | 191 | // but get previous value so we can reset it |
192 | 192 | $prev_value = $allowedtags['a']['target']; |
193 | 193 | $allowedtags['a']['target'] = true; |
194 | - $content = wp_kses( $content, $allowedtags ); |
|
195 | - $content = strip_shortcodes( $content ); |
|
196 | - echo apply_filters( 'the_content', $content ); |
|
194 | + $content = wp_kses($content, $allowedtags); |
|
195 | + $content = strip_shortcodes($content); |
|
196 | + echo apply_filters('the_content', $content); |
|
197 | 197 | $allowedtags['a']['target'] = $prev_value; |
198 | 198 | } |
199 | 199 | } else { |
200 | 200 | // admin has chosen "none" |
201 | 201 | // for the "Event Espresso - Events > Templates > Display Description" option |
202 | - echo apply_filters( 'the_content', '' ); |
|
202 | + echo apply_filters('the_content', ''); |
|
203 | 203 | } |
204 | 204 | return ob_get_clean(); |
205 | 205 | } |
@@ -213,13 +213,13 @@ discard block |
||
213 | 213 | * @param int $EVT_ID |
214 | 214 | * @return EE_Ticket[] |
215 | 215 | */ |
216 | - public static function event_tickets_available( $EVT_ID = 0 ) { |
|
217 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
216 | + public static function event_tickets_available($EVT_ID = 0) { |
|
217 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
218 | 218 | $tickets_available_for_purchase = array(); |
219 | - if( $event instanceof EE_Event ) { |
|
220 | - $datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, FALSE ); |
|
221 | - foreach( $datetimes as $datetime ) { |
|
222 | - $tickets_available_for_purchase = array_merge( $tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase() ); |
|
219 | + if ($event instanceof EE_Event) { |
|
220 | + $datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, FALSE); |
|
221 | + foreach ($datetimes as $datetime) { |
|
222 | + $tickets_available_for_purchase = array_merge($tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase()); |
|
223 | 223 | } |
224 | 224 | } |
225 | 225 | return $tickets_available_for_purchase; |
@@ -235,17 +235,17 @@ discard block |
||
235 | 235 | * @param bool $hide_uncategorized |
236 | 236 | * @return string |
237 | 237 | */ |
238 | - public static function event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE ) { |
|
238 | + public static function event_categories($EVT_ID = 0, $hide_uncategorized = TRUE) { |
|
239 | 239 | $category_links = array(); |
240 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
241 | - if ( $event instanceof EE_Event ) { |
|
242 | - $event_categories = get_the_terms( $event->ID(), 'espresso_event_categories' ); |
|
243 | - if ( $event_categories ) { |
|
240 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
241 | + if ($event instanceof EE_Event) { |
|
242 | + $event_categories = get_the_terms($event->ID(), 'espresso_event_categories'); |
|
243 | + if ($event_categories) { |
|
244 | 244 | // loop thru terms and create links |
245 | - foreach ( $event_categories as $term ) { |
|
246 | - $url = get_term_link( $term, 'espresso_venue_categories' ); |
|
247 | - if ( ! is_wp_error( $url ) && (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) { |
|
248 | - $category_links[] = '<a href="' . esc_url( $url ) |
|
245 | + foreach ($event_categories as $term) { |
|
246 | + $url = get_term_link($term, 'espresso_venue_categories'); |
|
247 | + if ( ! is_wp_error($url) && (($hide_uncategorized && strtolower($term->name) != __('uncategorized', 'event_espresso')) || ! $hide_uncategorized)) { |
|
248 | + $category_links[] = '<a href="'.esc_url($url) |
|
249 | 249 | . '" rel="tag"' |
250 | 250 | . \EED_Events_Archive::link_target() |
251 | 251 | .'>' |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | } |
256 | 256 | } |
257 | 257 | } |
258 | - return implode( ', ', $category_links ); |
|
258 | + return implode(', ', $category_links); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | |
@@ -269,10 +269,10 @@ discard block |
||
269 | 269 | * @param int $EVT_ID |
270 | 270 | * @return string |
271 | 271 | */ |
272 | - public static function the_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) { |
|
273 | - $datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID ); |
|
274 | - $format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt; |
|
275 | - return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) : ''; |
|
272 | + public static function the_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) { |
|
273 | + $datetime = EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
274 | + $format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt; |
|
275 | + return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : ''; |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | |
@@ -286,10 +286,10 @@ discard block |
||
286 | 286 | * @param int $EVT_ID |
287 | 287 | * @return string |
288 | 288 | */ |
289 | - public static function the_event_end_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) { |
|
290 | - $datetime = EEH_Event_View::get_last_date_obj( $EVT_ID ); |
|
291 | - $format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt; |
|
292 | - return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : ''; |
|
289 | + public static function the_event_end_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) { |
|
290 | + $datetime = EEH_Event_View::get_last_date_obj($EVT_ID); |
|
291 | + $format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt; |
|
292 | + return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : ''; |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | |
@@ -303,10 +303,10 @@ discard block |
||
303 | 303 | * @param int $EVT_ID |
304 | 304 | * @return string |
305 | 305 | */ |
306 | - public static function the_earliest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) { |
|
307 | - $datetime = EEH_Event_View::get_earliest_date_obj( $EVT_ID ); |
|
308 | - $format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt; |
|
309 | - return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) : ''; |
|
306 | + public static function the_earliest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) { |
|
307 | + $datetime = EEH_Event_View::get_earliest_date_obj($EVT_ID); |
|
308 | + $format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt; |
|
309 | + return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : ''; |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | |
@@ -320,10 +320,10 @@ discard block |
||
320 | 320 | * @param int $EVT_ID |
321 | 321 | * @return string |
322 | 322 | */ |
323 | - public static function the_latest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) { |
|
324 | - $datetime = EEH_Event_View::get_latest_date_obj( $EVT_ID ); |
|
325 | - $format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt; |
|
326 | - return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : ''; |
|
323 | + public static function the_latest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) { |
|
324 | + $datetime = EEH_Event_View::get_latest_date_obj($EVT_ID); |
|
325 | + $format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt; |
|
326 | + return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : ''; |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | |
@@ -335,13 +335,13 @@ discard block |
||
335 | 335 | * @param int $EVT_ID |
336 | 336 | * @return string |
337 | 337 | */ |
338 | - public static function event_date_as_calendar_page( $EVT_ID = 0 ) { |
|
339 | - $datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID ); |
|
340 | - if ( $datetime instanceof EE_Datetime ) { |
|
338 | + public static function event_date_as_calendar_page($EVT_ID = 0) { |
|
339 | + $datetime = EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
340 | + if ($datetime instanceof EE_Datetime) { |
|
341 | 341 | ?> |
342 | 342 | <div class="event-date-calendar-page-dv"> |
343 | - <div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime( 'DTT_EVT_start', 'M' );?></div> |
|
344 | - <div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date( 'd' );?></div> |
|
343 | + <div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime('DTT_EVT_start', 'M'); ?></div> |
|
344 | + <div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date('d'); ?></div> |
|
345 | 345 | </div> |
346 | 346 | <?php |
347 | 347 | } |
@@ -356,17 +356,17 @@ discard block |
||
356 | 356 | * @param int $EVT_ID |
357 | 357 | * @return string |
358 | 358 | */ |
359 | - public static function get_primary_date_obj( $EVT_ID = 0 ) { |
|
360 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
361 | - if ( $event instanceof EE_Event ) { |
|
359 | + public static function get_primary_date_obj($EVT_ID = 0) { |
|
360 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
361 | + if ($event instanceof EE_Event) { |
|
362 | 362 | $datetimes = $event->get_many_related( |
363 | 363 | 'Datetime', |
364 | 364 | array( |
365 | 365 | 'limit' => 1, |
366 | - 'order_by' => array( 'DTT_order' => 'ASC' ) |
|
366 | + 'order_by' => array('DTT_order' => 'ASC') |
|
367 | 367 | ) |
368 | 368 | ); |
369 | - return reset( $datetimes ); |
|
369 | + return reset($datetimes); |
|
370 | 370 | } else { |
371 | 371 | return FALSE; |
372 | 372 | } |
@@ -381,17 +381,17 @@ discard block |
||
381 | 381 | * @param int $EVT_ID |
382 | 382 | * @return string |
383 | 383 | */ |
384 | - public static function get_last_date_obj( $EVT_ID = 0 ) { |
|
385 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
386 | - if ( $event instanceof EE_Event ) { |
|
384 | + public static function get_last_date_obj($EVT_ID = 0) { |
|
385 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
386 | + if ($event instanceof EE_Event) { |
|
387 | 387 | $datetimes = $event->get_many_related( |
388 | 388 | 'Datetime', |
389 | 389 | array( |
390 | 390 | 'limit' => 1, |
391 | - 'order_by' => array( 'DTT_order' => 'DESC' ) |
|
391 | + 'order_by' => array('DTT_order' => 'DESC') |
|
392 | 392 | ) |
393 | 393 | ); |
394 | - return end( $datetimes ); |
|
394 | + return end($datetimes); |
|
395 | 395 | } else { |
396 | 396 | return FALSE; |
397 | 397 | } |
@@ -406,17 +406,17 @@ discard block |
||
406 | 406 | * @param int $EVT_ID |
407 | 407 | * @return string |
408 | 408 | */ |
409 | - public static function get_earliest_date_obj( $EVT_ID = 0 ) { |
|
410 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
411 | - if ( $event instanceof EE_Event ) { |
|
409 | + public static function get_earliest_date_obj($EVT_ID = 0) { |
|
410 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
411 | + if ($event instanceof EE_Event) { |
|
412 | 412 | $datetimes = $event->get_many_related( |
413 | 413 | 'Datetime', |
414 | 414 | array( |
415 | 415 | 'limit' => 1, |
416 | - 'order_by' => array( 'DTT_EVT_start' => 'ASC' ) |
|
416 | + 'order_by' => array('DTT_EVT_start' => 'ASC') |
|
417 | 417 | ) |
418 | 418 | ); |
419 | - return reset( $datetimes ); |
|
419 | + return reset($datetimes); |
|
420 | 420 | } else { |
421 | 421 | return FALSE; |
422 | 422 | } |
@@ -431,17 +431,17 @@ discard block |
||
431 | 431 | * @param int $EVT_ID |
432 | 432 | * @return string |
433 | 433 | */ |
434 | - public static function get_latest_date_obj( $EVT_ID = 0 ) { |
|
435 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
436 | - if ( $event instanceof EE_Event ) { |
|
434 | + public static function get_latest_date_obj($EVT_ID = 0) { |
|
435 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
436 | + if ($event instanceof EE_Event) { |
|
437 | 437 | $datetimes = $event->get_many_related( |
438 | 438 | 'Datetime', |
439 | 439 | array( |
440 | 440 | 'limit' => 1, |
441 | - 'order_by' => array( 'DTT_EVT_start' => 'DESC' ) |
|
441 | + 'order_by' => array('DTT_EVT_start' => 'DESC') |
|
442 | 442 | ) |
443 | 443 | ); |
444 | - return end( $datetimes ); |
|
444 | + return end($datetimes); |
|
445 | 445 | } else { |
446 | 446 | return FALSE; |
447 | 447 | } |
@@ -459,17 +459,17 @@ discard block |
||
459 | 459 | * @param null $limit |
460 | 460 | * @return EE_Datetime[] |
461 | 461 | */ |
462 | - public static function get_all_date_obj( $EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL ) { |
|
463 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
464 | - if($include_expired === null){ |
|
465 | - if($event instanceof EE_Event && $event->is_expired()){ |
|
462 | + public static function get_all_date_obj($EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL) { |
|
463 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
464 | + if ($include_expired === null) { |
|
465 | + if ($event instanceof EE_Event && $event->is_expired()) { |
|
466 | 466 | $include_expired = true; |
467 | - }else{ |
|
467 | + } else { |
|
468 | 468 | $include_expired = false; |
469 | 469 | } |
470 | 470 | } |
471 | 471 | |
472 | - if ( $event instanceof EE_Event ) { |
|
472 | + if ($event instanceof EE_Event) { |
|
473 | 473 | return $event->datetimes_ordered($include_expired, $include_deleted, $limit); |
474 | 474 | } else { |
475 | 475 | return array(); |
@@ -485,11 +485,11 @@ discard block |
||
485 | 485 | * @param int $EVT_ID |
486 | 486 | * @return string |
487 | 487 | */ |
488 | - public static function event_link_url( $EVT_ID = 0 ) { |
|
489 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
490 | - if ( $event instanceof EE_Event ) { |
|
491 | - $url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink( $event->ID() ); |
|
492 | - return preg_match( "~^(?:f|ht)tps?://~i", $url ) ? $url : 'http://' . $url; |
|
488 | + public static function event_link_url($EVT_ID = 0) { |
|
489 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
490 | + if ($event instanceof EE_Event) { |
|
491 | + $url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink($event->ID()); |
|
492 | + return preg_match("~^(?:f|ht)tps?://~i", $url) ? $url : 'http://'.$url; |
|
493 | 493 | } |
494 | 494 | return NULL; |
495 | 495 | } |
@@ -503,10 +503,10 @@ discard block |
||
503 | 503 | * @param int $EVT_ID |
504 | 504 | * @return string |
505 | 505 | */ |
506 | - public static function event_phone( $EVT_ID = 0 ) { |
|
507 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
508 | - if ( $event instanceof EE_Event ) { |
|
509 | - return EEH_Schema::telephone( $event->phone() ); |
|
506 | + public static function event_phone($EVT_ID = 0) { |
|
507 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
508 | + if ($event instanceof EE_Event) { |
|
509 | + return EEH_Schema::telephone($event->phone()); |
|
510 | 510 | } |
511 | 511 | return NULL; |
512 | 512 | } |
@@ -523,26 +523,26 @@ discard block |
||
523 | 523 | * @param string $after |
524 | 524 | * @return string |
525 | 525 | */ |
526 | - public static function edit_event_link( $EVT_ID = 0, $link = '', $before = '', $after = '' ) { |
|
527 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
528 | - if ( $event instanceof EE_Event ) { |
|
526 | + public static function edit_event_link($EVT_ID = 0, $link = '', $before = '', $after = '') { |
|
527 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
528 | + if ($event instanceof EE_Event) { |
|
529 | 529 | // can the user edit this post ? |
530 | - if ( current_user_can( 'edit_post', $event->ID() )) { |
|
530 | + if (current_user_can('edit_post', $event->ID())) { |
|
531 | 531 | // set link text |
532 | - $link_text = ! empty( $link ) ? $link : __('edit this event'); |
|
532 | + $link_text = ! empty($link) ? $link : __('edit this event'); |
|
533 | 533 | // generate nonce |
534 | - $nonce = wp_create_nonce( 'edit_nonce' ); |
|
534 | + $nonce = wp_create_nonce('edit_nonce'); |
|
535 | 535 | // generate url to event editor for this event |
536 | - $url = add_query_arg( array( 'page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce ), admin_url() ); |
|
536 | + $url = add_query_arg(array('page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce), admin_url()); |
|
537 | 537 | // get edit CPT text |
538 | - $post_type_obj = get_post_type_object( 'espresso_events' ); |
|
538 | + $post_type_obj = get_post_type_object('espresso_events'); |
|
539 | 539 | // build final link html |
540 | - $link = '<a class="post-edit-link" href="' . $url . '" '; |
|
541 | - $link .= ' title="' . esc_attr( $post_type_obj->labels->edit_item ) . '"'; |
|
540 | + $link = '<a class="post-edit-link" href="'.$url.'" '; |
|
541 | + $link .= ' title="'.esc_attr($post_type_obj->labels->edit_item).'"'; |
|
542 | 542 | $link .= \EED_Events_Archive::link_target(); |
543 | - $link .='>' . $link_text . '</a>'; |
|
543 | + $link .= '>'.$link_text.'</a>'; |
|
544 | 544 | // put it all together |
545 | - return $before . apply_filters( 'edit_post_link', $link, $event->ID() ) . $after; |
|
545 | + return $before.apply_filters('edit_post_link', $link, $event->ID()).$after; |
|
546 | 546 | } |
547 | 547 | } |
548 | 548 | return ''; |
@@ -32,49 +32,49 @@ discard block |
||
32 | 32 | |
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * get_event |
|
37 | - * attempts to retrieve an EE_Event object any way it can |
|
38 | - * |
|
39 | - * @param int|WP_Post $EVT_ID |
|
40 | - * @return EE_Event|null |
|
41 | - * @throws \EE_Error |
|
42 | - */ |
|
35 | + /** |
|
36 | + * get_event |
|
37 | + * attempts to retrieve an EE_Event object any way it can |
|
38 | + * |
|
39 | + * @param int|WP_Post $EVT_ID |
|
40 | + * @return EE_Event|null |
|
41 | + * @throws \EE_Error |
|
42 | + */ |
|
43 | 43 | public static function get_event( $EVT_ID = 0 ) { |
44 | - // international newspaper? |
|
45 | - global $post; |
|
46 | - $EVT_ID = $EVT_ID instanceof WP_Post && $EVT_ID->post_type === 'espresso_events' |
|
47 | - ? $EVT_ID->ID |
|
48 | - : absint($EVT_ID); |
|
49 | - // do we already have the Event you are looking for? |
|
50 | - if (EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID) { |
|
51 | - return EEH_Event_View::$_event; |
|
52 | - } |
|
53 | - //reset property so that the new event is cached. |
|
54 | - EEH_Event_View::$_event = null; |
|
55 | - |
|
56 | - if ($EVT_ID || $post instanceof WP_Post) { |
|
57 | - //if the post type is for an event and it has a cached event and we don't have a different incoming $EVT_ID |
|
58 | - //then let's just use that cached event on the $post object. |
|
59 | - if (($post instanceof WP_Post |
|
60 | - && $post->post_type === 'espresso_events' |
|
61 | - ) |
|
62 | - && isset($post->EE_Event) |
|
63 | - && ($EVT_ID === 0 |
|
64 | - || $EVT_ID === $post->ID |
|
65 | - ) |
|
66 | - ) { |
|
67 | - EEH_Event_View::$_event = $post->EE_Event; |
|
68 | - } |
|
69 | - |
|
70 | - //If the event we have isn't an event but we do have an EVT_ID, let's try getting the event using the ID. |
|
71 | - if (! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) { |
|
72 | - EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
73 | - } |
|
74 | - } |
|
75 | - |
|
76 | - return EEH_Event_View::$_event; |
|
77 | - } |
|
44 | + // international newspaper? |
|
45 | + global $post; |
|
46 | + $EVT_ID = $EVT_ID instanceof WP_Post && $EVT_ID->post_type === 'espresso_events' |
|
47 | + ? $EVT_ID->ID |
|
48 | + : absint($EVT_ID); |
|
49 | + // do we already have the Event you are looking for? |
|
50 | + if (EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID) { |
|
51 | + return EEH_Event_View::$_event; |
|
52 | + } |
|
53 | + //reset property so that the new event is cached. |
|
54 | + EEH_Event_View::$_event = null; |
|
55 | + |
|
56 | + if ($EVT_ID || $post instanceof WP_Post) { |
|
57 | + //if the post type is for an event and it has a cached event and we don't have a different incoming $EVT_ID |
|
58 | + //then let's just use that cached event on the $post object. |
|
59 | + if (($post instanceof WP_Post |
|
60 | + && $post->post_type === 'espresso_events' |
|
61 | + ) |
|
62 | + && isset($post->EE_Event) |
|
63 | + && ($EVT_ID === 0 |
|
64 | + || $EVT_ID === $post->ID |
|
65 | + ) |
|
66 | + ) { |
|
67 | + EEH_Event_View::$_event = $post->EE_Event; |
|
68 | + } |
|
69 | + |
|
70 | + //If the event we have isn't an event but we do have an EVT_ID, let's try getting the event using the ID. |
|
71 | + if (! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) { |
|
72 | + EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
73 | + } |
|
74 | + } |
|
75 | + |
|
76 | + return EEH_Event_View::$_event; |
|
77 | + } |
|
78 | 78 | |
79 | 79 | |
80 | 80 | |
@@ -150,58 +150,58 @@ discard block |
||
150 | 150 | * @return string |
151 | 151 | */ |
152 | 152 | public static function event_content_or_excerpt( $num_words = NULL, $more = NULL ) { |
153 | - global $post; |
|
153 | + global $post; |
|
154 | 154 | ob_start(); |
155 | 155 | if (( is_single() ) || ( is_archive() && espresso_display_full_description_in_event_list() )) { |
156 | 156 | // admin has chosen "full description" |
157 | - // for the "Event Espresso - Events > Templates > Display Description" option |
|
157 | + // for the "Event Espresso - Events > Templates > Display Description" option |
|
158 | 158 | the_content(); |
159 | 159 | } else if (( is_archive() && espresso_display_excerpt_in_event_list() ) ) { |
160 | - if ( has_excerpt( $post->ID )) { |
|
161 | - // admin has chosen "excerpt (short desc)" |
|
162 | - // for the "Event Espresso - Events > Templates > Display Description" option |
|
163 | - // AND an excerpt actually exists |
|
164 | - the_excerpt(); |
|
165 | - } else { |
|
166 | - // admin has chosen "excerpt (short desc)" |
|
167 | - // for the "Event Espresso - Events > Templates > Display Description" option |
|
168 | - // but NO excerpt actually exists, so we need to create one |
|
169 | - if ( ! empty( $num_words )) { |
|
170 | - if ( empty( $more )) { |
|
171 | - $more_link_text = __( '(more…)' ); |
|
172 | - $more = ' <a href="' . get_permalink() . '"'; |
|
173 | - $more .= ' class="more-link"'; |
|
174 | - $more .= \EED_Events_Archive::link_target(); |
|
175 | - $more .= '>' . $more_link_text . '</a>'; |
|
176 | - $more = apply_filters( 'the_content_more_link', $more, $more_link_text ); |
|
177 | - } |
|
178 | - $content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' )); |
|
179 | - |
|
180 | - $content = wp_trim_words( $content, $num_words, ' ' ) . $more; |
|
181 | - } else { |
|
182 | - $content = get_the_content(); |
|
183 | - } |
|
184 | - global $allowedtags; |
|
185 | - // make sure links are allowed |
|
186 | - $allowedtags['a'] = isset($allowedtags['a']) |
|
187 | - ? $allowedtags['a'] |
|
188 | - : array(); |
|
189 | - // as well as target attribute |
|
190 | - $allowedtags['a']['target'] = isset($allowedtags['a']['target']) |
|
191 | - ? $allowedtags['a']['target'] |
|
192 | - : false; |
|
193 | - // but get previous value so we can reset it |
|
194 | - $prev_value = $allowedtags['a']['target']; |
|
195 | - $allowedtags['a']['target'] = true; |
|
196 | - $content = wp_kses( $content, $allowedtags ); |
|
197 | - $content = strip_shortcodes( $content ); |
|
198 | - echo apply_filters( 'the_content', $content ); |
|
199 | - $allowedtags['a']['target'] = $prev_value; |
|
200 | - } |
|
201 | - } else { |
|
202 | - // admin has chosen "none" |
|
203 | - // for the "Event Espresso - Events > Templates > Display Description" option |
|
204 | - echo apply_filters( 'the_content', '' ); |
|
160 | + if ( has_excerpt( $post->ID )) { |
|
161 | + // admin has chosen "excerpt (short desc)" |
|
162 | + // for the "Event Espresso - Events > Templates > Display Description" option |
|
163 | + // AND an excerpt actually exists |
|
164 | + the_excerpt(); |
|
165 | + } else { |
|
166 | + // admin has chosen "excerpt (short desc)" |
|
167 | + // for the "Event Espresso - Events > Templates > Display Description" option |
|
168 | + // but NO excerpt actually exists, so we need to create one |
|
169 | + if ( ! empty( $num_words )) { |
|
170 | + if ( empty( $more )) { |
|
171 | + $more_link_text = __( '(more…)' ); |
|
172 | + $more = ' <a href="' . get_permalink() . '"'; |
|
173 | + $more .= ' class="more-link"'; |
|
174 | + $more .= \EED_Events_Archive::link_target(); |
|
175 | + $more .= '>' . $more_link_text . '</a>'; |
|
176 | + $more = apply_filters( 'the_content_more_link', $more, $more_link_text ); |
|
177 | + } |
|
178 | + $content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' )); |
|
179 | + |
|
180 | + $content = wp_trim_words( $content, $num_words, ' ' ) . $more; |
|
181 | + } else { |
|
182 | + $content = get_the_content(); |
|
183 | + } |
|
184 | + global $allowedtags; |
|
185 | + // make sure links are allowed |
|
186 | + $allowedtags['a'] = isset($allowedtags['a']) |
|
187 | + ? $allowedtags['a'] |
|
188 | + : array(); |
|
189 | + // as well as target attribute |
|
190 | + $allowedtags['a']['target'] = isset($allowedtags['a']['target']) |
|
191 | + ? $allowedtags['a']['target'] |
|
192 | + : false; |
|
193 | + // but get previous value so we can reset it |
|
194 | + $prev_value = $allowedtags['a']['target']; |
|
195 | + $allowedtags['a']['target'] = true; |
|
196 | + $content = wp_kses( $content, $allowedtags ); |
|
197 | + $content = strip_shortcodes( $content ); |
|
198 | + echo apply_filters( 'the_content', $content ); |
|
199 | + $allowedtags['a']['target'] = $prev_value; |
|
200 | + } |
|
201 | + } else { |
|
202 | + // admin has chosen "none" |
|
203 | + // for the "Event Espresso - Events > Templates > Display Description" option |
|
204 | + echo apply_filters( 'the_content', '' ); |
|
205 | 205 | } |
206 | 206 | return ob_get_clean(); |
207 | 207 | } |
@@ -248,11 +248,11 @@ discard block |
||
248 | 248 | $url = get_term_link( $term, 'espresso_venue_categories' ); |
249 | 249 | if ( ! is_wp_error( $url ) && (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) { |
250 | 250 | $category_links[] = '<a href="' . esc_url( $url ) |
251 | - . '" rel="tag"' |
|
252 | - . \EED_Events_Archive::link_target() |
|
253 | - .'>' |
|
254 | - . $term->name |
|
255 | - . '</a>'; |
|
251 | + . '" rel="tag"' |
|
252 | + . \EED_Events_Archive::link_target() |
|
253 | + .'>' |
|
254 | + . $term->name |
|
255 | + . '</a>'; |
|
256 | 256 | } |
257 | 257 | } |
258 | 258 | } |
@@ -117,44 +117,44 @@ discard block |
||
117 | 117 | // remove last segment |
118 | 118 | array_pop($shortcode_path); |
119 | 119 | // glue it back together |
120 | - $shortcode_path = implode(DS, $shortcode_path) . DS; |
|
120 | + $shortcode_path = implode(DS, $shortcode_path).DS; |
|
121 | 121 | } else { |
122 | 122 | // we need to generate the filename based off of the folder name |
123 | 123 | // grab and sanitize shortcode directory name |
124 | 124 | $shortcode = sanitize_key(basename($shortcode_path)); |
125 | - $shortcode_path = rtrim($shortcode_path, DS) . DS; |
|
125 | + $shortcode_path = rtrim($shortcode_path, DS).DS; |
|
126 | 126 | } |
127 | 127 | // create classname from shortcode directory or file name |
128 | 128 | $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode))); |
129 | 129 | // add class prefix |
130 | - $shortcode_class = 'EES_' . $shortcode; |
|
130 | + $shortcode_class = 'EES_'.$shortcode; |
|
131 | 131 | // does the shortcode exist ? |
132 | - if ( ! is_readable($shortcode_path . DS . $shortcode_class . $shortcode_ext)) { |
|
132 | + if ( ! is_readable($shortcode_path.DS.$shortcode_class.$shortcode_ext)) { |
|
133 | 133 | $msg = sprintf( |
134 | 134 | esc_html__( |
135 | 135 | 'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', |
136 | 136 | 'event_espresso' |
137 | 137 | ), |
138 | 138 | $shortcode_class, |
139 | - $shortcode_path . DS . $shortcode_class . $shortcode_ext |
|
139 | + $shortcode_path.DS.$shortcode_class.$shortcode_ext |
|
140 | 140 | ); |
141 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
141 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
142 | 142 | return false; |
143 | 143 | } |
144 | 144 | // load the shortcode class file |
145 | - require_once($shortcode_path . $shortcode_class . $shortcode_ext); |
|
145 | + require_once($shortcode_path.$shortcode_class.$shortcode_ext); |
|
146 | 146 | // verify that class exists |
147 | 147 | if ( ! class_exists($shortcode_class)) { |
148 | 148 | $msg = sprintf( |
149 | 149 | esc_html__('The requested %s shortcode class does not exist.', 'event_espresso'), |
150 | 150 | $shortcode_class |
151 | 151 | ); |
152 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
152 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
153 | 153 | return false; |
154 | 154 | } |
155 | 155 | $shortcode = strtoupper($shortcode); |
156 | 156 | // add to array of registered shortcodes |
157 | - $this->registry->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext; |
|
157 | + $this->registry->shortcodes->{$shortcode} = $shortcode_path.$shortcode_class.$shortcode_ext; |
|
158 | 158 | return true; |
159 | 159 | } |
160 | 160 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | // cycle thru shortcode folders |
173 | 173 | foreach ($this->registry->shortcodes as $shortcode => $shortcode_path) { |
174 | 174 | // add class prefix |
175 | - $shortcode_class = 'EES_' . $shortcode; |
|
175 | + $shortcode_class = 'EES_'.$shortcode; |
|
176 | 176 | // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
177 | 177 | // which set hooks ? |
178 | 178 | if (is_admin()) { |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | { |
291 | 291 | $has_shortcode = false; |
292 | 292 | foreach ($this->registry->shortcodes as $shortcode_class => $shortcode) { |
293 | - if ($load_all || has_shortcode($content, $shortcode_class) ) { |
|
293 | + if ($load_all || has_shortcode($content, $shortcode_class)) { |
|
294 | 294 | // load up the shortcode |
295 | 295 | $this->initializeShortcode($shortcode_class); |
296 | 296 | $has_shortcode = true; |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | */ |
403 | 403 | public static function addShortcodeClassPrefix($class_name) |
404 | 404 | { |
405 | - return strpos($class_name, 'EES_') === 0 ? $class_name : 'EES_' . $class_name; |
|
405 | + return strpos($class_name, 'EES_') === 0 ? $class_name : 'EES_'.$class_name; |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | { |
415 | 415 | static $shortcode_tags = array(); |
416 | 416 | if (empty($shortcode_tags)) { |
417 | - $shortcode_tags = array_keys((array)$this->registry->shortcodes); |
|
417 | + $shortcode_tags = array_keys((array) $this->registry->shortcodes); |
|
418 | 418 | } |
419 | 419 | return $shortcode_tags; |
420 | 420 | } |
@@ -25,429 +25,429 @@ |
||
25 | 25 | class LegacyShortcodesManager |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * @var EE_Registry $registry |
|
30 | - */ |
|
31 | - private $registry; |
|
32 | - |
|
33 | - |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * LegacyShortcodesManager constructor. |
|
38 | - * |
|
39 | - * @param \EE_Registry $registry |
|
40 | - */ |
|
41 | - public function __construct(EE_Registry $registry) |
|
42 | - { |
|
43 | - $this->registry = $registry; |
|
44 | - } |
|
45 | - |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * @return EE_Registry |
|
50 | - */ |
|
51 | - public function registry() |
|
52 | - { |
|
53 | - return $this->registry; |
|
54 | - } |
|
55 | - |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * registerShortcodes |
|
60 | - * |
|
61 | - * @return void |
|
62 | - */ |
|
63 | - public function registerShortcodes() |
|
64 | - { |
|
65 | - $this->registry->shortcodes = $this->getShortcodes(); |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * getShortcodes |
|
72 | - * |
|
73 | - * @return array |
|
74 | - */ |
|
75 | - public function getShortcodes() |
|
76 | - { |
|
77 | - // previously this method would glob the shortcodes directory |
|
78 | - // then filter that list of shortcodes to register, |
|
79 | - // but now we are going to just supply an empty array. |
|
80 | - // this allows any shortcodes that have not yet been converted to the new system |
|
81 | - // to still get loaded and processed, albeit using the same legacy logic as before |
|
82 | - $shortcodes_to_register = apply_filters( |
|
83 | - 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register', |
|
84 | - array() |
|
85 | - ); |
|
86 | - if ( ! empty($shortcodes_to_register)) { |
|
87 | - // cycle thru shortcode folders |
|
88 | - foreach ($shortcodes_to_register as $shortcode_path) { |
|
89 | - // add to list of installed shortcode modules |
|
90 | - $this->registerShortcode($shortcode_path); |
|
91 | - } |
|
92 | - } |
|
93 | - // filter list of installed modules |
|
94 | - return apply_filters( |
|
95 | - 'FHEE__EE_Config___register_shortcodes__installed_shortcodes', |
|
96 | - ! empty($this->registry->shortcodes) |
|
97 | - ? $this->registry->shortcodes |
|
98 | - : array() |
|
99 | - ); |
|
100 | - } |
|
101 | - |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * register_shortcode - makes core aware of this shortcode |
|
106 | - * |
|
107 | - * @access public |
|
108 | - * @param string $shortcode_path - full path up to and including shortcode folder |
|
109 | - * @return bool |
|
110 | - */ |
|
111 | - public function registerShortcode($shortcode_path = null) |
|
112 | - { |
|
113 | - do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path); |
|
114 | - $shortcode_ext = '.shortcode.php'; |
|
115 | - // make all separators match |
|
116 | - $shortcode_path = str_replace(array('\\', '/'), DS, $shortcode_path); |
|
117 | - // does the file path INCLUDE the actual file name as part of the path ? |
|
118 | - if (strpos($shortcode_path, $shortcode_ext) !== false) { |
|
119 | - // grab shortcode file name from directory name and break apart at dots |
|
120 | - $shortcode_file = explode('.', basename($shortcode_path)); |
|
121 | - // take first segment from file name pieces and remove class prefix if it exists |
|
122 | - $shortcode = strpos($shortcode_file[0], 'EES_') === 0 |
|
123 | - ? substr($shortcode_file[0], 4) |
|
124 | - : $shortcode_file[0]; |
|
125 | - // sanitize shortcode directory name |
|
126 | - $shortcode = sanitize_key($shortcode); |
|
127 | - // now we need to rebuild the shortcode path |
|
128 | - $shortcode_path = explode(DS, $shortcode_path); |
|
129 | - // remove last segment |
|
130 | - array_pop($shortcode_path); |
|
131 | - // glue it back together |
|
132 | - $shortcode_path = implode(DS, $shortcode_path) . DS; |
|
133 | - } else { |
|
134 | - // we need to generate the filename based off of the folder name |
|
135 | - // grab and sanitize shortcode directory name |
|
136 | - $shortcode = sanitize_key(basename($shortcode_path)); |
|
137 | - $shortcode_path = rtrim($shortcode_path, DS) . DS; |
|
138 | - } |
|
139 | - // create classname from shortcode directory or file name |
|
140 | - $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode))); |
|
141 | - // add class prefix |
|
142 | - $shortcode_class = 'EES_' . $shortcode; |
|
143 | - // does the shortcode exist ? |
|
144 | - if ( ! is_readable($shortcode_path . DS . $shortcode_class . $shortcode_ext)) { |
|
145 | - $msg = sprintf( |
|
146 | - esc_html__( |
|
147 | - 'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', |
|
148 | - 'event_espresso' |
|
149 | - ), |
|
150 | - $shortcode_class, |
|
151 | - $shortcode_path . DS . $shortcode_class . $shortcode_ext |
|
152 | - ); |
|
153 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
154 | - return false; |
|
155 | - } |
|
156 | - // load the shortcode class file |
|
157 | - require_once($shortcode_path . $shortcode_class . $shortcode_ext); |
|
158 | - // verify that class exists |
|
159 | - if ( ! class_exists($shortcode_class)) { |
|
160 | - $msg = sprintf( |
|
161 | - esc_html__('The requested %s shortcode class does not exist.', 'event_espresso'), |
|
162 | - $shortcode_class |
|
163 | - ); |
|
164 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
165 | - return false; |
|
166 | - } |
|
167 | - $shortcode = strtoupper($shortcode); |
|
168 | - // add to array of registered shortcodes |
|
169 | - $this->registry->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext; |
|
170 | - return true; |
|
171 | - } |
|
172 | - |
|
173 | - |
|
174 | - |
|
175 | - /** |
|
176 | - * _initialize_shortcodes |
|
177 | - * allow shortcodes to set hooks for the rest of the system |
|
178 | - * |
|
179 | - * @access private |
|
180 | - * @return void |
|
181 | - */ |
|
182 | - public function addShortcodes() |
|
183 | - { |
|
184 | - // cycle thru shortcode folders |
|
185 | - foreach ($this->registry->shortcodes as $shortcode => $shortcode_path) { |
|
186 | - // add class prefix |
|
187 | - $shortcode_class = 'EES_' . $shortcode; |
|
188 | - // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
189 | - // which set hooks ? |
|
190 | - if (is_admin()) { |
|
191 | - // fire immediately |
|
192 | - call_user_func(array($shortcode_class, 'set_hooks_admin')); |
|
193 | - } else { |
|
194 | - // delay until other systems are online |
|
195 | - add_action( |
|
196 | - 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
|
197 | - array($shortcode_class, 'set_hooks') |
|
198 | - ); |
|
199 | - // convert classname to UPPERCASE and create WP shortcode. |
|
200 | - $shortcode_tag = strtoupper($shortcode); |
|
201 | - // but first check if the shortcode has already |
|
202 | - // been added before assigning 'fallback_shortcode_processor' |
|
203 | - if ( ! shortcode_exists($shortcode_tag)) { |
|
204 | - // NOTE: this shortcode declaration will get overridden if the shortcode |
|
205 | - // is successfully detected in the post content in initializeShortcode() |
|
206 | - add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor')); |
|
207 | - } |
|
208 | - } |
|
209 | - } |
|
210 | - } |
|
211 | - |
|
212 | - |
|
213 | - |
|
214 | - /** |
|
215 | - * callback for the WP "get_header" hook point |
|
216 | - * checks posts for EE shortcodes, and initializes them, |
|
217 | - * then toggles filter switch that loads core default assets |
|
218 | - * |
|
219 | - * @param \WP_Query $wp_query |
|
220 | - * @return void |
|
221 | - */ |
|
222 | - public function initializeShortcodes(WP_Query $wp_query) |
|
223 | - { |
|
224 | - if (empty($this->registry->shortcodes) || ! $wp_query->is_main_query() || is_admin()) { |
|
225 | - return; |
|
226 | - } |
|
227 | - global $wp; |
|
228 | - /** @var EE_Front_controller $Front_Controller */ |
|
229 | - $Front_Controller = $this->registry->load_core('Front_Controller', array(), false); |
|
230 | - do_action('AHEE__EE_Front_Controller__initialize_shortcodes__begin', $wp, $Front_Controller); |
|
231 | - $Front_Controller->Request_Handler()->set_request_vars(); |
|
232 | - // grab post_name from request |
|
233 | - $current_post = apply_filters( |
|
234 | - 'FHEE__EE_Front_Controller__initialize_shortcodes__current_post_name', |
|
235 | - $Front_Controller->Request_Handler()->get('post_name') |
|
236 | - ); |
|
237 | - $show_on_front = get_option('show_on_front'); |
|
238 | - // if it's not set, then check if frontpage is blog |
|
239 | - if (empty($current_post)) { |
|
240 | - // yup.. this is the posts page, prepare to load all shortcode modules |
|
241 | - $current_post = 'posts'; |
|
242 | - // unless.. |
|
243 | - if ($show_on_front === 'page') { |
|
244 | - // some other page is set as the homepage |
|
245 | - $page_on_front = get_option('page_on_front'); |
|
246 | - if ($page_on_front) { |
|
247 | - // k now we need to find the post_name for this page |
|
248 | - global $wpdb; |
|
249 | - $page_on_front = $wpdb->get_var( |
|
250 | - $wpdb->prepare( |
|
251 | - "SELECT post_name from {$wpdb->posts} WHERE post_type='page' AND post_status='publish' AND ID=%d", |
|
252 | - $page_on_front |
|
253 | - ) |
|
254 | - ); |
|
255 | - // set the current post slug to what it actually is |
|
256 | - $current_post = $page_on_front ? $page_on_front : $current_post; |
|
257 | - } |
|
258 | - } |
|
259 | - } |
|
260 | - // in case $current_post is hierarchical like: /parent-page/current-page |
|
261 | - $current_post = basename($current_post); |
|
262 | - if ( |
|
263 | - // is current page/post the "blog" page ? |
|
264 | - $current_post === EE_Config::get_page_for_posts() |
|
265 | - // or are we on a category page? |
|
266 | - || ( |
|
267 | - is_array(term_exists($current_post, 'category')) |
|
268 | - || array_key_exists('category_name', $wp->query_vars) |
|
269 | - ) |
|
270 | - ) { |
|
271 | - // initialize all legacy shortcodes |
|
272 | - $load_assets = $this->parseContentForShortcodes('', true); |
|
273 | - } else { |
|
274 | - global $wpdb; |
|
275 | - $post_content = $wpdb->get_var( |
|
276 | - $wpdb->prepare( |
|
277 | - "SELECT post_content from {$wpdb->posts} WHERE post_status='publish' AND post_name=%s", |
|
278 | - $current_post |
|
279 | - ) |
|
280 | - ); |
|
281 | - $load_assets = $this->parseContentForShortcodes($post_content); |
|
282 | - } |
|
283 | - if ($load_assets) { |
|
284 | - $this->registry->REQ->set_espresso_page(true); |
|
285 | - add_filter('FHEE_load_css', '__return_true'); |
|
286 | - add_filter('FHEE_load_js', '__return_true'); |
|
287 | - } |
|
288 | - do_action('AHEE__EE_Front_Controller__initialize_shortcodes__end', $Front_Controller); |
|
289 | - } |
|
290 | - |
|
291 | - |
|
292 | - |
|
293 | - /** |
|
294 | - * checks supplied content against list of legacy shortcodes, |
|
295 | - * then initializes any found shortcodes, and returns true. |
|
296 | - * returns false if no shortcodes found. |
|
297 | - * |
|
298 | - * @param string $content |
|
299 | - * @param bool $load_all if true, then ALL active legacy shortcodes will be initialized |
|
300 | - * @return bool |
|
301 | - */ |
|
302 | - public function parseContentForShortcodes($content = '', $load_all = false) |
|
303 | - { |
|
304 | - $has_shortcode = false; |
|
305 | - foreach ($this->registry->shortcodes as $shortcode_class => $shortcode) { |
|
306 | - if ($load_all || has_shortcode($content, $shortcode_class) ) { |
|
307 | - // load up the shortcode |
|
308 | - $this->initializeShortcode($shortcode_class); |
|
309 | - $has_shortcode = true; |
|
310 | - } |
|
311 | - } |
|
312 | - return $has_shortcode; |
|
313 | - } |
|
314 | - |
|
315 | - |
|
316 | - |
|
317 | - /** |
|
318 | - * given a shortcode name, will instantiate the shortcode and call it's run() method |
|
319 | - * |
|
320 | - * @param string $shortcode_class |
|
321 | - * @param WP $wp |
|
322 | - */ |
|
323 | - public function initializeShortcode($shortcode_class = '', WP $wp = null) |
|
324 | - { |
|
325 | - // don't do anything if shortcode is already initialized |
|
326 | - if ( |
|
327 | - empty($this->registry->shortcodes->{$shortcode_class}) |
|
328 | - || ! is_string($this->registry->shortcodes->{$shortcode_class}) |
|
329 | - ) { |
|
330 | - return; |
|
331 | - } |
|
332 | - // let's pause to reflect on this... |
|
333 | - $sc_reflector = new ReflectionClass(LegacyShortcodesManager::addShortcodeClassPrefix($shortcode_class)); |
|
334 | - // ensure that class is actually a shortcode |
|
335 | - if ( |
|
336 | - defined('WP_DEBUG') |
|
337 | - && WP_DEBUG === true |
|
338 | - && ! $sc_reflector->isSubclassOf('EES_Shortcode') |
|
339 | - ) { |
|
340 | - EE_Error::add_error( |
|
341 | - sprintf( |
|
342 | - esc_html__( |
|
343 | - 'The requested %s shortcode is not of the class "EES_Shortcode". Please check your files.', |
|
344 | - 'event_espresso' |
|
345 | - ), |
|
346 | - $shortcode_class |
|
347 | - ), |
|
348 | - __FILE__, |
|
349 | - __FUNCTION__, |
|
350 | - __LINE__ |
|
351 | - ); |
|
352 | - add_filter('FHEE_run_EE_the_content', '__return_true'); |
|
353 | - return; |
|
354 | - } |
|
355 | - global $wp; |
|
356 | - // and pass the request object to the run method |
|
357 | - $this->registry->shortcodes->{$shortcode_class} = $sc_reflector->newInstance(); |
|
358 | - // fire the shortcode class's run method, so that it can activate resources |
|
359 | - $this->registry->shortcodes->{$shortcode_class}->run($wp); |
|
360 | - } |
|
361 | - |
|
362 | - |
|
363 | - |
|
364 | - /** |
|
365 | - * get classname, remove EES_prefix, and convert to UPPERCASE |
|
366 | - * |
|
367 | - * @param string $class_name |
|
368 | - * @return string |
|
369 | - */ |
|
370 | - public static function generateShortcodeTagFromClassName($class_name) |
|
371 | - { |
|
372 | - return strtoupper(str_replace('EES_', '', $class_name)); |
|
373 | - } |
|
374 | - |
|
375 | - |
|
376 | - |
|
377 | - /** |
|
378 | - * add EES_prefix and Capitalize words |
|
379 | - * |
|
380 | - * @param string $tag |
|
381 | - * @return string |
|
382 | - */ |
|
383 | - public static function generateShortcodeClassNameFromTag($tag) |
|
384 | - { |
|
385 | - // order of operation runs from inside to out |
|
386 | - // 5) maybe add prefix |
|
387 | - return LegacyShortcodesManager::addShortcodeClassPrefix( |
|
388 | - // 4) find spaces, replace with underscores |
|
389 | - str_replace( |
|
390 | - ' ', |
|
391 | - '_', |
|
392 | - // 3) capitalize first letter of each word |
|
393 | - ucwords( |
|
394 | - // 2) also change to lowercase so ucwords() will work |
|
395 | - strtolower( |
|
396 | - // 1) find underscores, replace with spaces so ucwords() will work |
|
397 | - str_replace( |
|
398 | - '_', |
|
399 | - ' ', |
|
400 | - $tag |
|
401 | - ) |
|
402 | - ) |
|
403 | - ) |
|
404 | - ) |
|
405 | - ); |
|
406 | - } |
|
407 | - |
|
408 | - |
|
409 | - |
|
410 | - /** |
|
411 | - * maybe add EES_prefix |
|
412 | - * |
|
413 | - * @param string $class_name |
|
414 | - * @return string |
|
415 | - */ |
|
416 | - public static function addShortcodeClassPrefix($class_name) |
|
417 | - { |
|
418 | - return strpos($class_name, 'EES_') === 0 ? $class_name : 'EES_' . $class_name; |
|
419 | - } |
|
420 | - |
|
421 | - |
|
422 | - |
|
423 | - /** |
|
424 | - * @return array |
|
425 | - */ |
|
426 | - public function getEspressoShortcodeTags() |
|
427 | - { |
|
428 | - static $shortcode_tags = array(); |
|
429 | - if (empty($shortcode_tags)) { |
|
430 | - $shortcode_tags = array_keys((array)$this->registry->shortcodes); |
|
431 | - } |
|
432 | - return $shortcode_tags; |
|
433 | - } |
|
434 | - |
|
435 | - |
|
436 | - |
|
437 | - /** |
|
438 | - * @param string $content |
|
439 | - * @return string |
|
440 | - */ |
|
441 | - public function doShortcode($content) |
|
442 | - { |
|
443 | - foreach ($this->getEspressoShortcodeTags() as $shortcode_tag) { |
|
444 | - if (strpos($content, $shortcode_tag) !== false) { |
|
445 | - $shortcode_class = LegacyShortcodesManager::generateShortcodeClassNameFromTag($shortcode_tag); |
|
446 | - $this->initializeShortcode($shortcode_class); |
|
447 | - } |
|
448 | - } |
|
449 | - return do_shortcode($content); |
|
450 | - } |
|
28 | + /** |
|
29 | + * @var EE_Registry $registry |
|
30 | + */ |
|
31 | + private $registry; |
|
32 | + |
|
33 | + |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * LegacyShortcodesManager constructor. |
|
38 | + * |
|
39 | + * @param \EE_Registry $registry |
|
40 | + */ |
|
41 | + public function __construct(EE_Registry $registry) |
|
42 | + { |
|
43 | + $this->registry = $registry; |
|
44 | + } |
|
45 | + |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * @return EE_Registry |
|
50 | + */ |
|
51 | + public function registry() |
|
52 | + { |
|
53 | + return $this->registry; |
|
54 | + } |
|
55 | + |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * registerShortcodes |
|
60 | + * |
|
61 | + * @return void |
|
62 | + */ |
|
63 | + public function registerShortcodes() |
|
64 | + { |
|
65 | + $this->registry->shortcodes = $this->getShortcodes(); |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * getShortcodes |
|
72 | + * |
|
73 | + * @return array |
|
74 | + */ |
|
75 | + public function getShortcodes() |
|
76 | + { |
|
77 | + // previously this method would glob the shortcodes directory |
|
78 | + // then filter that list of shortcodes to register, |
|
79 | + // but now we are going to just supply an empty array. |
|
80 | + // this allows any shortcodes that have not yet been converted to the new system |
|
81 | + // to still get loaded and processed, albeit using the same legacy logic as before |
|
82 | + $shortcodes_to_register = apply_filters( |
|
83 | + 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register', |
|
84 | + array() |
|
85 | + ); |
|
86 | + if ( ! empty($shortcodes_to_register)) { |
|
87 | + // cycle thru shortcode folders |
|
88 | + foreach ($shortcodes_to_register as $shortcode_path) { |
|
89 | + // add to list of installed shortcode modules |
|
90 | + $this->registerShortcode($shortcode_path); |
|
91 | + } |
|
92 | + } |
|
93 | + // filter list of installed modules |
|
94 | + return apply_filters( |
|
95 | + 'FHEE__EE_Config___register_shortcodes__installed_shortcodes', |
|
96 | + ! empty($this->registry->shortcodes) |
|
97 | + ? $this->registry->shortcodes |
|
98 | + : array() |
|
99 | + ); |
|
100 | + } |
|
101 | + |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * register_shortcode - makes core aware of this shortcode |
|
106 | + * |
|
107 | + * @access public |
|
108 | + * @param string $shortcode_path - full path up to and including shortcode folder |
|
109 | + * @return bool |
|
110 | + */ |
|
111 | + public function registerShortcode($shortcode_path = null) |
|
112 | + { |
|
113 | + do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path); |
|
114 | + $shortcode_ext = '.shortcode.php'; |
|
115 | + // make all separators match |
|
116 | + $shortcode_path = str_replace(array('\\', '/'), DS, $shortcode_path); |
|
117 | + // does the file path INCLUDE the actual file name as part of the path ? |
|
118 | + if (strpos($shortcode_path, $shortcode_ext) !== false) { |
|
119 | + // grab shortcode file name from directory name and break apart at dots |
|
120 | + $shortcode_file = explode('.', basename($shortcode_path)); |
|
121 | + // take first segment from file name pieces and remove class prefix if it exists |
|
122 | + $shortcode = strpos($shortcode_file[0], 'EES_') === 0 |
|
123 | + ? substr($shortcode_file[0], 4) |
|
124 | + : $shortcode_file[0]; |
|
125 | + // sanitize shortcode directory name |
|
126 | + $shortcode = sanitize_key($shortcode); |
|
127 | + // now we need to rebuild the shortcode path |
|
128 | + $shortcode_path = explode(DS, $shortcode_path); |
|
129 | + // remove last segment |
|
130 | + array_pop($shortcode_path); |
|
131 | + // glue it back together |
|
132 | + $shortcode_path = implode(DS, $shortcode_path) . DS; |
|
133 | + } else { |
|
134 | + // we need to generate the filename based off of the folder name |
|
135 | + // grab and sanitize shortcode directory name |
|
136 | + $shortcode = sanitize_key(basename($shortcode_path)); |
|
137 | + $shortcode_path = rtrim($shortcode_path, DS) . DS; |
|
138 | + } |
|
139 | + // create classname from shortcode directory or file name |
|
140 | + $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode))); |
|
141 | + // add class prefix |
|
142 | + $shortcode_class = 'EES_' . $shortcode; |
|
143 | + // does the shortcode exist ? |
|
144 | + if ( ! is_readable($shortcode_path . DS . $shortcode_class . $shortcode_ext)) { |
|
145 | + $msg = sprintf( |
|
146 | + esc_html__( |
|
147 | + 'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', |
|
148 | + 'event_espresso' |
|
149 | + ), |
|
150 | + $shortcode_class, |
|
151 | + $shortcode_path . DS . $shortcode_class . $shortcode_ext |
|
152 | + ); |
|
153 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
154 | + return false; |
|
155 | + } |
|
156 | + // load the shortcode class file |
|
157 | + require_once($shortcode_path . $shortcode_class . $shortcode_ext); |
|
158 | + // verify that class exists |
|
159 | + if ( ! class_exists($shortcode_class)) { |
|
160 | + $msg = sprintf( |
|
161 | + esc_html__('The requested %s shortcode class does not exist.', 'event_espresso'), |
|
162 | + $shortcode_class |
|
163 | + ); |
|
164 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
165 | + return false; |
|
166 | + } |
|
167 | + $shortcode = strtoupper($shortcode); |
|
168 | + // add to array of registered shortcodes |
|
169 | + $this->registry->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext; |
|
170 | + return true; |
|
171 | + } |
|
172 | + |
|
173 | + |
|
174 | + |
|
175 | + /** |
|
176 | + * _initialize_shortcodes |
|
177 | + * allow shortcodes to set hooks for the rest of the system |
|
178 | + * |
|
179 | + * @access private |
|
180 | + * @return void |
|
181 | + */ |
|
182 | + public function addShortcodes() |
|
183 | + { |
|
184 | + // cycle thru shortcode folders |
|
185 | + foreach ($this->registry->shortcodes as $shortcode => $shortcode_path) { |
|
186 | + // add class prefix |
|
187 | + $shortcode_class = 'EES_' . $shortcode; |
|
188 | + // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
189 | + // which set hooks ? |
|
190 | + if (is_admin()) { |
|
191 | + // fire immediately |
|
192 | + call_user_func(array($shortcode_class, 'set_hooks_admin')); |
|
193 | + } else { |
|
194 | + // delay until other systems are online |
|
195 | + add_action( |
|
196 | + 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
|
197 | + array($shortcode_class, 'set_hooks') |
|
198 | + ); |
|
199 | + // convert classname to UPPERCASE and create WP shortcode. |
|
200 | + $shortcode_tag = strtoupper($shortcode); |
|
201 | + // but first check if the shortcode has already |
|
202 | + // been added before assigning 'fallback_shortcode_processor' |
|
203 | + if ( ! shortcode_exists($shortcode_tag)) { |
|
204 | + // NOTE: this shortcode declaration will get overridden if the shortcode |
|
205 | + // is successfully detected in the post content in initializeShortcode() |
|
206 | + add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor')); |
|
207 | + } |
|
208 | + } |
|
209 | + } |
|
210 | + } |
|
211 | + |
|
212 | + |
|
213 | + |
|
214 | + /** |
|
215 | + * callback for the WP "get_header" hook point |
|
216 | + * checks posts for EE shortcodes, and initializes them, |
|
217 | + * then toggles filter switch that loads core default assets |
|
218 | + * |
|
219 | + * @param \WP_Query $wp_query |
|
220 | + * @return void |
|
221 | + */ |
|
222 | + public function initializeShortcodes(WP_Query $wp_query) |
|
223 | + { |
|
224 | + if (empty($this->registry->shortcodes) || ! $wp_query->is_main_query() || is_admin()) { |
|
225 | + return; |
|
226 | + } |
|
227 | + global $wp; |
|
228 | + /** @var EE_Front_controller $Front_Controller */ |
|
229 | + $Front_Controller = $this->registry->load_core('Front_Controller', array(), false); |
|
230 | + do_action('AHEE__EE_Front_Controller__initialize_shortcodes__begin', $wp, $Front_Controller); |
|
231 | + $Front_Controller->Request_Handler()->set_request_vars(); |
|
232 | + // grab post_name from request |
|
233 | + $current_post = apply_filters( |
|
234 | + 'FHEE__EE_Front_Controller__initialize_shortcodes__current_post_name', |
|
235 | + $Front_Controller->Request_Handler()->get('post_name') |
|
236 | + ); |
|
237 | + $show_on_front = get_option('show_on_front'); |
|
238 | + // if it's not set, then check if frontpage is blog |
|
239 | + if (empty($current_post)) { |
|
240 | + // yup.. this is the posts page, prepare to load all shortcode modules |
|
241 | + $current_post = 'posts'; |
|
242 | + // unless.. |
|
243 | + if ($show_on_front === 'page') { |
|
244 | + // some other page is set as the homepage |
|
245 | + $page_on_front = get_option('page_on_front'); |
|
246 | + if ($page_on_front) { |
|
247 | + // k now we need to find the post_name for this page |
|
248 | + global $wpdb; |
|
249 | + $page_on_front = $wpdb->get_var( |
|
250 | + $wpdb->prepare( |
|
251 | + "SELECT post_name from {$wpdb->posts} WHERE post_type='page' AND post_status='publish' AND ID=%d", |
|
252 | + $page_on_front |
|
253 | + ) |
|
254 | + ); |
|
255 | + // set the current post slug to what it actually is |
|
256 | + $current_post = $page_on_front ? $page_on_front : $current_post; |
|
257 | + } |
|
258 | + } |
|
259 | + } |
|
260 | + // in case $current_post is hierarchical like: /parent-page/current-page |
|
261 | + $current_post = basename($current_post); |
|
262 | + if ( |
|
263 | + // is current page/post the "blog" page ? |
|
264 | + $current_post === EE_Config::get_page_for_posts() |
|
265 | + // or are we on a category page? |
|
266 | + || ( |
|
267 | + is_array(term_exists($current_post, 'category')) |
|
268 | + || array_key_exists('category_name', $wp->query_vars) |
|
269 | + ) |
|
270 | + ) { |
|
271 | + // initialize all legacy shortcodes |
|
272 | + $load_assets = $this->parseContentForShortcodes('', true); |
|
273 | + } else { |
|
274 | + global $wpdb; |
|
275 | + $post_content = $wpdb->get_var( |
|
276 | + $wpdb->prepare( |
|
277 | + "SELECT post_content from {$wpdb->posts} WHERE post_status='publish' AND post_name=%s", |
|
278 | + $current_post |
|
279 | + ) |
|
280 | + ); |
|
281 | + $load_assets = $this->parseContentForShortcodes($post_content); |
|
282 | + } |
|
283 | + if ($load_assets) { |
|
284 | + $this->registry->REQ->set_espresso_page(true); |
|
285 | + add_filter('FHEE_load_css', '__return_true'); |
|
286 | + add_filter('FHEE_load_js', '__return_true'); |
|
287 | + } |
|
288 | + do_action('AHEE__EE_Front_Controller__initialize_shortcodes__end', $Front_Controller); |
|
289 | + } |
|
290 | + |
|
291 | + |
|
292 | + |
|
293 | + /** |
|
294 | + * checks supplied content against list of legacy shortcodes, |
|
295 | + * then initializes any found shortcodes, and returns true. |
|
296 | + * returns false if no shortcodes found. |
|
297 | + * |
|
298 | + * @param string $content |
|
299 | + * @param bool $load_all if true, then ALL active legacy shortcodes will be initialized |
|
300 | + * @return bool |
|
301 | + */ |
|
302 | + public function parseContentForShortcodes($content = '', $load_all = false) |
|
303 | + { |
|
304 | + $has_shortcode = false; |
|
305 | + foreach ($this->registry->shortcodes as $shortcode_class => $shortcode) { |
|
306 | + if ($load_all || has_shortcode($content, $shortcode_class) ) { |
|
307 | + // load up the shortcode |
|
308 | + $this->initializeShortcode($shortcode_class); |
|
309 | + $has_shortcode = true; |
|
310 | + } |
|
311 | + } |
|
312 | + return $has_shortcode; |
|
313 | + } |
|
314 | + |
|
315 | + |
|
316 | + |
|
317 | + /** |
|
318 | + * given a shortcode name, will instantiate the shortcode and call it's run() method |
|
319 | + * |
|
320 | + * @param string $shortcode_class |
|
321 | + * @param WP $wp |
|
322 | + */ |
|
323 | + public function initializeShortcode($shortcode_class = '', WP $wp = null) |
|
324 | + { |
|
325 | + // don't do anything if shortcode is already initialized |
|
326 | + if ( |
|
327 | + empty($this->registry->shortcodes->{$shortcode_class}) |
|
328 | + || ! is_string($this->registry->shortcodes->{$shortcode_class}) |
|
329 | + ) { |
|
330 | + return; |
|
331 | + } |
|
332 | + // let's pause to reflect on this... |
|
333 | + $sc_reflector = new ReflectionClass(LegacyShortcodesManager::addShortcodeClassPrefix($shortcode_class)); |
|
334 | + // ensure that class is actually a shortcode |
|
335 | + if ( |
|
336 | + defined('WP_DEBUG') |
|
337 | + && WP_DEBUG === true |
|
338 | + && ! $sc_reflector->isSubclassOf('EES_Shortcode') |
|
339 | + ) { |
|
340 | + EE_Error::add_error( |
|
341 | + sprintf( |
|
342 | + esc_html__( |
|
343 | + 'The requested %s shortcode is not of the class "EES_Shortcode". Please check your files.', |
|
344 | + 'event_espresso' |
|
345 | + ), |
|
346 | + $shortcode_class |
|
347 | + ), |
|
348 | + __FILE__, |
|
349 | + __FUNCTION__, |
|
350 | + __LINE__ |
|
351 | + ); |
|
352 | + add_filter('FHEE_run_EE_the_content', '__return_true'); |
|
353 | + return; |
|
354 | + } |
|
355 | + global $wp; |
|
356 | + // and pass the request object to the run method |
|
357 | + $this->registry->shortcodes->{$shortcode_class} = $sc_reflector->newInstance(); |
|
358 | + // fire the shortcode class's run method, so that it can activate resources |
|
359 | + $this->registry->shortcodes->{$shortcode_class}->run($wp); |
|
360 | + } |
|
361 | + |
|
362 | + |
|
363 | + |
|
364 | + /** |
|
365 | + * get classname, remove EES_prefix, and convert to UPPERCASE |
|
366 | + * |
|
367 | + * @param string $class_name |
|
368 | + * @return string |
|
369 | + */ |
|
370 | + public static function generateShortcodeTagFromClassName($class_name) |
|
371 | + { |
|
372 | + return strtoupper(str_replace('EES_', '', $class_name)); |
|
373 | + } |
|
374 | + |
|
375 | + |
|
376 | + |
|
377 | + /** |
|
378 | + * add EES_prefix and Capitalize words |
|
379 | + * |
|
380 | + * @param string $tag |
|
381 | + * @return string |
|
382 | + */ |
|
383 | + public static function generateShortcodeClassNameFromTag($tag) |
|
384 | + { |
|
385 | + // order of operation runs from inside to out |
|
386 | + // 5) maybe add prefix |
|
387 | + return LegacyShortcodesManager::addShortcodeClassPrefix( |
|
388 | + // 4) find spaces, replace with underscores |
|
389 | + str_replace( |
|
390 | + ' ', |
|
391 | + '_', |
|
392 | + // 3) capitalize first letter of each word |
|
393 | + ucwords( |
|
394 | + // 2) also change to lowercase so ucwords() will work |
|
395 | + strtolower( |
|
396 | + // 1) find underscores, replace with spaces so ucwords() will work |
|
397 | + str_replace( |
|
398 | + '_', |
|
399 | + ' ', |
|
400 | + $tag |
|
401 | + ) |
|
402 | + ) |
|
403 | + ) |
|
404 | + ) |
|
405 | + ); |
|
406 | + } |
|
407 | + |
|
408 | + |
|
409 | + |
|
410 | + /** |
|
411 | + * maybe add EES_prefix |
|
412 | + * |
|
413 | + * @param string $class_name |
|
414 | + * @return string |
|
415 | + */ |
|
416 | + public static function addShortcodeClassPrefix($class_name) |
|
417 | + { |
|
418 | + return strpos($class_name, 'EES_') === 0 ? $class_name : 'EES_' . $class_name; |
|
419 | + } |
|
420 | + |
|
421 | + |
|
422 | + |
|
423 | + /** |
|
424 | + * @return array |
|
425 | + */ |
|
426 | + public function getEspressoShortcodeTags() |
|
427 | + { |
|
428 | + static $shortcode_tags = array(); |
|
429 | + if (empty($shortcode_tags)) { |
|
430 | + $shortcode_tags = array_keys((array)$this->registry->shortcodes); |
|
431 | + } |
|
432 | + return $shortcode_tags; |
|
433 | + } |
|
434 | + |
|
435 | + |
|
436 | + |
|
437 | + /** |
|
438 | + * @param string $content |
|
439 | + * @return string |
|
440 | + */ |
|
441 | + public function doShortcode($content) |
|
442 | + { |
|
443 | + foreach ($this->getEspressoShortcodeTags() as $shortcode_tag) { |
|
444 | + if (strpos($content, $shortcode_tag) !== false) { |
|
445 | + $shortcode_class = LegacyShortcodesManager::generateShortcodeClassNameFromTag($shortcode_tag); |
|
446 | + $this->initializeShortcode($shortcode_class); |
|
447 | + } |
|
448 | + } |
|
449 | + return do_shortcode($content); |
|
450 | + } |
|
451 | 451 | |
452 | 452 | |
453 | 453 |
@@ -20,17 +20,17 @@ discard block |
||
20 | 20 | |
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * class constructor - should ONLY be instantiated by EE_Front_Controller |
|
25 | - */ |
|
26 | - final public function __construct() |
|
27 | - { |
|
28 | - $shortcode = LegacyShortcodesManager::generateShortcodeTagFromClassName(get_class($this)); |
|
29 | - // assign shortcode to the preferred callback, which overwrites the "fallback shortcode processor" assigned earlier |
|
30 | - add_shortcode($shortcode, array($this, 'process_shortcode')); |
|
31 | - // make sure system knows this is an EE page |
|
32 | - EE_Registry::instance()->REQ->set_espresso_page(true); |
|
33 | - } |
|
23 | + /** |
|
24 | + * class constructor - should ONLY be instantiated by EE_Front_Controller |
|
25 | + */ |
|
26 | + final public function __construct() |
|
27 | + { |
|
28 | + $shortcode = LegacyShortcodesManager::generateShortcodeTagFromClassName(get_class($this)); |
|
29 | + // assign shortcode to the preferred callback, which overwrites the "fallback shortcode processor" assigned earlier |
|
30 | + add_shortcode($shortcode, array($this, 'process_shortcode')); |
|
31 | + // make sure system knows this is an EE page |
|
32 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
33 | + } |
|
34 | 34 | |
35 | 35 | |
36 | 36 | |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | } |
78 | 78 | $shortcode = str_replace( 'EES_', '', strtoupper( $shortcode_class )); |
79 | 79 | $shortcode_obj = isset( EE_Registry::instance()->shortcodes->{$shortcode} ) |
80 | - ? EE_Registry::instance()->shortcodes->{$shortcode} |
|
81 | - : null; |
|
80 | + ? EE_Registry::instance()->shortcodes->{$shortcode} |
|
81 | + : null; |
|
82 | 82 | return $shortcode_obj instanceof $shortcode_class || $shortcode_class === 'self' |
83 | - ? $shortcode_obj |
|
84 | - : new $shortcode_class(); |
|
83 | + ? $shortcode_obj |
|
84 | + : new $shortcode_class(); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | |
@@ -135,59 +135,59 @@ discard block |
||
135 | 135 | |
136 | 136 | |
137 | 137 | |
138 | - /** |
|
139 | - * Performs basic sanitization on shortcode attributes |
|
140 | - * Since incoming attributes from the shortcode usage in the WP editor will all be strings, |
|
141 | - * most attributes will by default be sanitized using the sanitize_text_field() function. |
|
142 | - * This can be overridden by supplying an array for the $custom_sanitization param, |
|
143 | - * where keys match keys in your attributes array, |
|
144 | - * and values represent the sanitization function you wish to be applied to that attribute. |
|
145 | - * So for example, if you had an integer attribute named "event_id" |
|
146 | - * that you wanted to be sanitized using absint(), |
|
147 | - * then you would pass the following for your $custom_sanitization array: |
|
148 | - * array('event_id' => 'absint') |
|
149 | - * all other attributes would be sanitized using the defaults in the switch statement below |
|
150 | - * |
|
151 | - * @param array $attributes |
|
152 | - * @param array $custom_sanitization |
|
153 | - * @return array |
|
154 | - */ |
|
155 | - public static function sanitize_attributes(array $attributes, $custom_sanitization = array()) |
|
156 | - { |
|
157 | - foreach ($attributes as $key => $value) { |
|
158 | - // is a custom sanitization callback specified ? |
|
159 | - if ( isset($custom_sanitization[$key])) { |
|
160 | - $callback = $custom_sanitization[$key]; |
|
161 | - if ($callback === 'skip_sanitization') { |
|
162 | - $attributes[$key] = $value; |
|
163 | - continue; |
|
164 | - } else if (function_exists($callback)){ |
|
165 | - $attributes[$key] = $callback($value); |
|
166 | - continue; |
|
167 | - } |
|
168 | - } |
|
169 | - switch (true) { |
|
170 | - case $value === null : |
|
171 | - case is_int($value) : |
|
172 | - case is_float($value) : |
|
173 | - // typical booleans |
|
174 | - case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true) : |
|
175 | - $attributes[$key] = $value; |
|
176 | - break; |
|
177 | - case is_string($value) : |
|
178 | - $attributes[$key] = sanitize_text_field($value); |
|
179 | - break; |
|
180 | - case is_array($value) : |
|
181 | - $attributes[$key] = \EES_Shortcode::sanitize_attributes($value); |
|
182 | - break; |
|
183 | - default : |
|
184 | - // only remaining data types are Object and Resource |
|
185 | - // which are not allowed as shortcode attributes |
|
186 | - $attributes[$key] = null; |
|
187 | - break; |
|
188 | - } |
|
189 | - } |
|
190 | - return $attributes; |
|
138 | + /** |
|
139 | + * Performs basic sanitization on shortcode attributes |
|
140 | + * Since incoming attributes from the shortcode usage in the WP editor will all be strings, |
|
141 | + * most attributes will by default be sanitized using the sanitize_text_field() function. |
|
142 | + * This can be overridden by supplying an array for the $custom_sanitization param, |
|
143 | + * where keys match keys in your attributes array, |
|
144 | + * and values represent the sanitization function you wish to be applied to that attribute. |
|
145 | + * So for example, if you had an integer attribute named "event_id" |
|
146 | + * that you wanted to be sanitized using absint(), |
|
147 | + * then you would pass the following for your $custom_sanitization array: |
|
148 | + * array('event_id' => 'absint') |
|
149 | + * all other attributes would be sanitized using the defaults in the switch statement below |
|
150 | + * |
|
151 | + * @param array $attributes |
|
152 | + * @param array $custom_sanitization |
|
153 | + * @return array |
|
154 | + */ |
|
155 | + public static function sanitize_attributes(array $attributes, $custom_sanitization = array()) |
|
156 | + { |
|
157 | + foreach ($attributes as $key => $value) { |
|
158 | + // is a custom sanitization callback specified ? |
|
159 | + if ( isset($custom_sanitization[$key])) { |
|
160 | + $callback = $custom_sanitization[$key]; |
|
161 | + if ($callback === 'skip_sanitization') { |
|
162 | + $attributes[$key] = $value; |
|
163 | + continue; |
|
164 | + } else if (function_exists($callback)){ |
|
165 | + $attributes[$key] = $callback($value); |
|
166 | + continue; |
|
167 | + } |
|
168 | + } |
|
169 | + switch (true) { |
|
170 | + case $value === null : |
|
171 | + case is_int($value) : |
|
172 | + case is_float($value) : |
|
173 | + // typical booleans |
|
174 | + case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true) : |
|
175 | + $attributes[$key] = $value; |
|
176 | + break; |
|
177 | + case is_string($value) : |
|
178 | + $attributes[$key] = sanitize_text_field($value); |
|
179 | + break; |
|
180 | + case is_array($value) : |
|
181 | + $attributes[$key] = \EES_Shortcode::sanitize_attributes($value); |
|
182 | + break; |
|
183 | + default : |
|
184 | + // only remaining data types are Object and Resource |
|
185 | + // which are not allowed as shortcode attributes |
|
186 | + $attributes[$key] = null; |
|
187 | + break; |
|
188 | + } |
|
189 | + } |
|
190 | + return $attributes; |
|
191 | 191 | } |
192 | 192 | |
193 | 193 |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @param WP $WP |
48 | 48 | * @return void |
49 | 49 | */ |
50 | - public abstract function run( WP $WP ); |
|
50 | + public abstract function run(WP $WP); |
|
51 | 51 | |
52 | 52 | |
53 | 53 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @param array $attributes |
60 | 60 | * @return mixed |
61 | 61 | */ |
62 | - public abstract function process_shortcode( $attributes = array() ); |
|
62 | + public abstract function process_shortcode($attributes = array()); |
|
63 | 63 | |
64 | 64 | |
65 | 65 | |
@@ -70,13 +70,13 @@ discard block |
||
70 | 70 | * @param string $shortcode_class |
71 | 71 | * @return \EES_Shortcode |
72 | 72 | */ |
73 | - final public static function instance( $shortcode_class = null ) { |
|
74 | - $shortcode_class = ! empty( $shortcode_class ) ? $shortcode_class : get_called_class(); |
|
75 | - if ( $shortcode_class === 'EES_Shortcode' || empty( $shortcode_class )) { |
|
73 | + final public static function instance($shortcode_class = null) { |
|
74 | + $shortcode_class = ! empty($shortcode_class) ? $shortcode_class : get_called_class(); |
|
75 | + if ($shortcode_class === 'EES_Shortcode' || empty($shortcode_class)) { |
|
76 | 76 | return null; |
77 | 77 | } |
78 | - $shortcode = str_replace( 'EES_', '', strtoupper( $shortcode_class )); |
|
79 | - $shortcode_obj = isset( EE_Registry::instance()->shortcodes->{$shortcode} ) |
|
78 | + $shortcode = str_replace('EES_', '', strtoupper($shortcode_class)); |
|
79 | + $shortcode_obj = isset(EE_Registry::instance()->shortcodes->{$shortcode} ) |
|
80 | 80 | ? EE_Registry::instance()->shortcodes->{$shortcode} |
81 | 81 | : null; |
82 | 82 | return $shortcode_obj instanceof $shortcode_class || $shortcode_class === 'self' |
@@ -95,23 +95,23 @@ discard block |
||
95 | 95 | * @param $attributes |
96 | 96 | * @return mixed |
97 | 97 | */ |
98 | - final public static function fallback_shortcode_processor( $attributes ) { |
|
99 | - if ( EE_Maintenance_Mode::disable_frontend_for_maintenance() ) { |
|
98 | + final public static function fallback_shortcode_processor($attributes) { |
|
99 | + if (EE_Maintenance_Mode::disable_frontend_for_maintenance()) { |
|
100 | 100 | return null; |
101 | 101 | } |
102 | 102 | // what shortcode was actually parsed ? |
103 | 103 | $shortcode_class = get_called_class(); |
104 | 104 | // notify rest of system that fallback processor was triggered |
105 | - add_filter( 'FHEE__fallback_shortcode_processor__' . $shortcode_class, '__return_true' ); |
|
105 | + add_filter('FHEE__fallback_shortcode_processor__'.$shortcode_class, '__return_true'); |
|
106 | 106 | // get instance of actual shortcode |
107 | - $shortcode_obj = self::instance( $shortcode_class ); |
|
107 | + $shortcode_obj = self::instance($shortcode_class); |
|
108 | 108 | // verify class |
109 | - if ( $shortcode_obj instanceof EES_Shortcode ) { |
|
109 | + if ($shortcode_obj instanceof EES_Shortcode) { |
|
110 | 110 | global $wp; |
111 | - $shortcode_obj->run( $wp ); |
|
111 | + $shortcode_obj->run($wp); |
|
112 | 112 | // set attributes and run the shortcode |
113 | - $shortcode_obj->_attributes = (array)$attributes; |
|
114 | - return $shortcode_obj->process_shortcode( $shortcode_obj->_attributes ); |
|
113 | + $shortcode_obj->_attributes = (array) $attributes; |
|
114 | + return $shortcode_obj->process_shortcode($shortcode_obj->_attributes); |
|
115 | 115 | } else { |
116 | 116 | return null; |
117 | 117 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @param $attributes |
128 | 128 | * @return string |
129 | 129 | */ |
130 | - final public static function invalid_shortcode_processor( $attributes ) { |
|
130 | + final public static function invalid_shortcode_processor($attributes) { |
|
131 | 131 | return ''; |
132 | 132 | } |
133 | 133 | |
@@ -156,12 +156,12 @@ discard block |
||
156 | 156 | { |
157 | 157 | foreach ($attributes as $key => $value) { |
158 | 158 | // is a custom sanitization callback specified ? |
159 | - if ( isset($custom_sanitization[$key])) { |
|
159 | + if (isset($custom_sanitization[$key])) { |
|
160 | 160 | $callback = $custom_sanitization[$key]; |
161 | 161 | if ($callback === 'skip_sanitization') { |
162 | 162 | $attributes[$key] = $value; |
163 | 163 | continue; |
164 | - } else if (function_exists($callback)){ |
|
164 | + } else if (function_exists($callback)) { |
|
165 | 165 | $attributes[$key] = $callback($value); |
166 | 166 | continue; |
167 | 167 | } |
@@ -108,7 +108,7 @@ |
||
108 | 108 | private function getAttributes(array $attributes) |
109 | 109 | { |
110 | 110 | return array_merge( |
111 | - (array)apply_filters( |
|
111 | + (array) apply_filters( |
|
112 | 112 | 'EES_Espresso_Events__process_shortcode__default_espresso_events_shortcode_atts', |
113 | 113 | array( |
114 | 114 | 'title' => '', |
@@ -34,139 +34,139 @@ |
||
34 | 34 | |
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * the actual shortcode tag that gets registered with WordPress |
|
39 | - * |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - public function getTag() |
|
43 | - { |
|
44 | - return 'ESPRESSO_EVENTS'; |
|
45 | - } |
|
46 | - |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * the time in seconds to cache the results of the processShortcode() method |
|
51 | - * 0 means the processShortcode() results will NOT be cached at all |
|
52 | - * |
|
53 | - * @return int |
|
54 | - */ |
|
55 | - public function cacheExpiration() |
|
56 | - { |
|
57 | - return 0; |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * a place for adding any initialization code that needs to run prior to wp_header(). |
|
64 | - * this may be required for shortcodes that utilize a corresponding module, |
|
65 | - * and need to enqueue assets for that module |
|
66 | - * |
|
67 | - * @return void |
|
68 | - */ |
|
69 | - public function initializeShortcode() |
|
70 | - { |
|
71 | - EED_Events_Archive::instance()->event_list(); |
|
72 | - $this->shortcodeHasBeenInitialized(); |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * callback that runs when the shortcode is encountered in post content. |
|
79 | - * IMPORTANT !!! |
|
80 | - * remember that shortcode content should be RETURNED and NOT echoed out |
|
81 | - * |
|
82 | - * @param array $attributes |
|
83 | - * @return string |
|
84 | - */ |
|
85 | - public function processShortcode($attributes = array()) |
|
86 | - { |
|
87 | - // grab attributes and merge with defaults |
|
88 | - $attributes = $this->getAttributes($attributes); |
|
89 | - // make sure we use the_excerpt() |
|
90 | - add_filter('FHEE__EES_Espresso_Events__process_shortcode__true', '__return_true'); |
|
91 | - // apply query filters |
|
92 | - add_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true'); |
|
93 | - // run the query |
|
94 | - global $wp_query; |
|
95 | - // yes we have to overwrite the main wp query, but it's ok... |
|
96 | - // we're going to reset it again below, so everything will be Hunky Dory (amazing album) |
|
97 | - $wp_query = new EventListQuery($attributes); |
|
98 | - // check what template is loaded and load filters accordingly |
|
99 | - EED_Events_Archive::instance()->template_include('loop-espresso_events.php'); |
|
100 | - // load our template |
|
101 | - $event_list = EEH_Template::locate_template( |
|
102 | - 'loop-espresso_events.php', |
|
103 | - array(), |
|
104 | - true, |
|
105 | - true |
|
106 | - ); |
|
107 | - // now reset the query and post data |
|
108 | - wp_reset_query(); |
|
109 | - wp_reset_postdata(); |
|
110 | - EED_Events_Archive::remove_all_events_archive_filters(); |
|
111 | - // remove query filters |
|
112 | - remove_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true'); |
|
113 | - // pull our content from the output buffer and return it |
|
114 | - return $event_list; |
|
115 | - } |
|
116 | - |
|
117 | - |
|
118 | - |
|
119 | - /** |
|
120 | - * merge incoming attributes with filtered defaults |
|
121 | - * |
|
122 | - * @param array $attributes |
|
123 | - * @return array |
|
124 | - */ |
|
125 | - private function getAttributes(array $attributes) |
|
126 | - { |
|
127 | - return array_merge( |
|
128 | - (array)apply_filters( |
|
129 | - 'EES_Espresso_Events__process_shortcode__default_espresso_events_shortcode_atts', |
|
130 | - array( |
|
131 | - 'title' => '', |
|
132 | - 'limit' => 10, |
|
133 | - 'css_class' => '', |
|
134 | - 'show_expired' => false, |
|
135 | - 'month' => '', |
|
136 | - 'category_slug' => '', |
|
137 | - 'order_by' => 'start_date', |
|
138 | - 'sort' => 'ASC', |
|
139 | - 'show_title' => true, |
|
140 | - ) |
|
141 | - ), |
|
142 | - $attributes |
|
143 | - ); |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - |
|
148 | - /** |
|
149 | - * array for defining custom attribute sanitization callbacks, |
|
150 | - * where keys match keys in your attributes array, |
|
151 | - * and values represent the sanitization function you wish to be applied to that attribute. |
|
152 | - * So for example, if you had an integer attribute named "event_id" |
|
153 | - * that you wanted to be sanitized using absint(), |
|
154 | - * then you would pass the following for your $custom_sanitization array: |
|
155 | - * array('event_id' => 'absint') |
|
156 | - * |
|
157 | - * @return array |
|
158 | - */ |
|
159 | - protected function customAttributeSanitizationMap() |
|
160 | - { |
|
161 | - // the following get sanitized/whitelisted in EEH_Event_Query |
|
162 | - return array( |
|
163 | - 'category_slug' => 'skip_sanitization', |
|
164 | - 'show_expired' => 'skip_sanitization', |
|
165 | - 'order_by' => 'skip_sanitization', |
|
166 | - 'month' => 'skip_sanitization', |
|
167 | - 'sort' => 'skip_sanitization', |
|
168 | - ); |
|
169 | - } |
|
37 | + /** |
|
38 | + * the actual shortcode tag that gets registered with WordPress |
|
39 | + * |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + public function getTag() |
|
43 | + { |
|
44 | + return 'ESPRESSO_EVENTS'; |
|
45 | + } |
|
46 | + |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * the time in seconds to cache the results of the processShortcode() method |
|
51 | + * 0 means the processShortcode() results will NOT be cached at all |
|
52 | + * |
|
53 | + * @return int |
|
54 | + */ |
|
55 | + public function cacheExpiration() |
|
56 | + { |
|
57 | + return 0; |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * a place for adding any initialization code that needs to run prior to wp_header(). |
|
64 | + * this may be required for shortcodes that utilize a corresponding module, |
|
65 | + * and need to enqueue assets for that module |
|
66 | + * |
|
67 | + * @return void |
|
68 | + */ |
|
69 | + public function initializeShortcode() |
|
70 | + { |
|
71 | + EED_Events_Archive::instance()->event_list(); |
|
72 | + $this->shortcodeHasBeenInitialized(); |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * callback that runs when the shortcode is encountered in post content. |
|
79 | + * IMPORTANT !!! |
|
80 | + * remember that shortcode content should be RETURNED and NOT echoed out |
|
81 | + * |
|
82 | + * @param array $attributes |
|
83 | + * @return string |
|
84 | + */ |
|
85 | + public function processShortcode($attributes = array()) |
|
86 | + { |
|
87 | + // grab attributes and merge with defaults |
|
88 | + $attributes = $this->getAttributes($attributes); |
|
89 | + // make sure we use the_excerpt() |
|
90 | + add_filter('FHEE__EES_Espresso_Events__process_shortcode__true', '__return_true'); |
|
91 | + // apply query filters |
|
92 | + add_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true'); |
|
93 | + // run the query |
|
94 | + global $wp_query; |
|
95 | + // yes we have to overwrite the main wp query, but it's ok... |
|
96 | + // we're going to reset it again below, so everything will be Hunky Dory (amazing album) |
|
97 | + $wp_query = new EventListQuery($attributes); |
|
98 | + // check what template is loaded and load filters accordingly |
|
99 | + EED_Events_Archive::instance()->template_include('loop-espresso_events.php'); |
|
100 | + // load our template |
|
101 | + $event_list = EEH_Template::locate_template( |
|
102 | + 'loop-espresso_events.php', |
|
103 | + array(), |
|
104 | + true, |
|
105 | + true |
|
106 | + ); |
|
107 | + // now reset the query and post data |
|
108 | + wp_reset_query(); |
|
109 | + wp_reset_postdata(); |
|
110 | + EED_Events_Archive::remove_all_events_archive_filters(); |
|
111 | + // remove query filters |
|
112 | + remove_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true'); |
|
113 | + // pull our content from the output buffer and return it |
|
114 | + return $event_list; |
|
115 | + } |
|
116 | + |
|
117 | + |
|
118 | + |
|
119 | + /** |
|
120 | + * merge incoming attributes with filtered defaults |
|
121 | + * |
|
122 | + * @param array $attributes |
|
123 | + * @return array |
|
124 | + */ |
|
125 | + private function getAttributes(array $attributes) |
|
126 | + { |
|
127 | + return array_merge( |
|
128 | + (array)apply_filters( |
|
129 | + 'EES_Espresso_Events__process_shortcode__default_espresso_events_shortcode_atts', |
|
130 | + array( |
|
131 | + 'title' => '', |
|
132 | + 'limit' => 10, |
|
133 | + 'css_class' => '', |
|
134 | + 'show_expired' => false, |
|
135 | + 'month' => '', |
|
136 | + 'category_slug' => '', |
|
137 | + 'order_by' => 'start_date', |
|
138 | + 'sort' => 'ASC', |
|
139 | + 'show_title' => true, |
|
140 | + ) |
|
141 | + ), |
|
142 | + $attributes |
|
143 | + ); |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + |
|
148 | + /** |
|
149 | + * array for defining custom attribute sanitization callbacks, |
|
150 | + * where keys match keys in your attributes array, |
|
151 | + * and values represent the sanitization function you wish to be applied to that attribute. |
|
152 | + * So for example, if you had an integer attribute named "event_id" |
|
153 | + * that you wanted to be sanitized using absint(), |
|
154 | + * then you would pass the following for your $custom_sanitization array: |
|
155 | + * array('event_id' => 'absint') |
|
156 | + * |
|
157 | + * @return array |
|
158 | + */ |
|
159 | + protected function customAttributeSanitizationMap() |
|
160 | + { |
|
161 | + // the following get sanitized/whitelisted in EEH_Event_Query |
|
162 | + return array( |
|
163 | + 'category_slug' => 'skip_sanitization', |
|
164 | + 'show_expired' => 'skip_sanitization', |
|
165 | + 'order_by' => 'skip_sanitization', |
|
166 | + 'month' => 'skip_sanitization', |
|
167 | + 'sort' => 'skip_sanitization', |
|
168 | + ); |
|
169 | + } |
|
170 | 170 | |
171 | 171 | |
172 | 172 |
@@ -588,6 +588,7 @@ |
||
588 | 588 | * @param EE_Registration $registration |
589 | 589 | * @param EE_Question $question |
590 | 590 | * @param mixed EE_Answer|NULL $answer |
591 | + * @param EE_Answer $answer |
|
591 | 592 | * @return EE_Form_Input_Base |
592 | 593 | * @throws \EE_Error |
593 | 594 | */ |
@@ -2,17 +2,17 @@ discard block |
||
2 | 2 | |
3 | 3 | if ( ! defined( 'EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
4 | 4 | /** |
5 | - * |
|
6 | - * Class EE_SPCO_Reg_Step_Attendee_Information |
|
7 | - * |
|
8 | - * Description |
|
9 | - * |
|
10 | - * @package Event Espresso |
|
11 | - * @subpackage core |
|
12 | - * @author Brent Christensen |
|
13 | - * @since 4.5.0 |
|
14 | - * |
|
15 | - */ |
|
5 | + * |
|
6 | + * Class EE_SPCO_Reg_Step_Attendee_Information |
|
7 | + * |
|
8 | + * Description |
|
9 | + * |
|
10 | + * @package Event Espresso |
|
11 | + * @subpackage core |
|
12 | + * @author Brent Christensen |
|
13 | + * @since 4.5.0 |
|
14 | + * |
|
15 | + */ |
|
16 | 16 | class EE_SPCO_Reg_Step_Attendee_Information extends EE_SPCO_Reg_Step { |
17 | 17 | |
18 | 18 | /** |
@@ -137,28 +137,28 @@ discard block |
||
137 | 137 | $registration instanceof EE_Registration |
138 | 138 | && $this->checkout->visit_allows_processing_of_this_registration( $registration ) |
139 | 139 | ) { |
140 | - $subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration); |
|
141 | - if ( ! $this->checkout->admin_request) { |
|
142 | - $template_args['registrations'][$registration->reg_url_link()] = $registration; |
|
143 | - $template_args['ticket_count'][$registration->ticket()->ID()] = isset( |
|
144 | - $template_args['ticket_count'][$registration->ticket()->ID()] |
|
145 | - ) |
|
146 | - ? $template_args['ticket_count'][$registration->ticket()->ID()] + 1 |
|
147 | - : 1; |
|
148 | - $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
149 | - $this->checkout->cart->get_grand_total(), |
|
150 | - 'Ticket', |
|
151 | - array($registration->ticket()->ID()) |
|
152 | - ); |
|
153 | - $ticket_line_item = is_array($ticket_line_item) |
|
154 | - ? reset($ticket_line_item) |
|
155 | - : $ticket_line_item; |
|
156 | - $template_args['ticket_line_item'][$registration->ticket()->ID()] = |
|
157 | - $Line_Item_Display->display_line_item($ticket_line_item); |
|
158 | - } |
|
159 | - if ($registration->is_primary_registrant()) { |
|
160 | - $primary_registrant = $registration->reg_url_link(); |
|
161 | - } |
|
140 | + $subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration); |
|
141 | + if ( ! $this->checkout->admin_request) { |
|
142 | + $template_args['registrations'][$registration->reg_url_link()] = $registration; |
|
143 | + $template_args['ticket_count'][$registration->ticket()->ID()] = isset( |
|
144 | + $template_args['ticket_count'][$registration->ticket()->ID()] |
|
145 | + ) |
|
146 | + ? $template_args['ticket_count'][$registration->ticket()->ID()] + 1 |
|
147 | + : 1; |
|
148 | + $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
149 | + $this->checkout->cart->get_grand_total(), |
|
150 | + 'Ticket', |
|
151 | + array($registration->ticket()->ID()) |
|
152 | + ); |
|
153 | + $ticket_line_item = is_array($ticket_line_item) |
|
154 | + ? reset($ticket_line_item) |
|
155 | + : $ticket_line_item; |
|
156 | + $template_args['ticket_line_item'][$registration->ticket()->ID()] = |
|
157 | + $Line_Item_Display->display_line_item($ticket_line_item); |
|
158 | + } |
|
159 | + if ($registration->is_primary_registrant()) { |
|
160 | + $primary_registrant = $registration->reg_url_link(); |
|
161 | + } |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | // print_copy_info ? |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | // generate hidden input |
171 | 171 | if ( |
172 | 172 | isset( $subsections[ $primary_registrant ] ) |
173 | - && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper |
|
173 | + && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper |
|
174 | 174 | ) { |
175 | 175 | $subsections[ $primary_registrant ]->add_subsections( $copy_options, 'primary_registrant', false ); |
176 | 176 | } |
@@ -198,42 +198,42 @@ discard block |
||
198 | 198 | |
199 | 199 | |
200 | 200 | |
201 | - /** |
|
201 | + /** |
|
202 | 202 | * @param EE_Registration $registration |
203 | 203 | * @return EE_Form_Section_Base |
204 | 204 | * @throws \EE_Error |
205 | 205 | */ |
206 | 206 | private function _registrations_reg_form( EE_Registration $registration ) { |
207 | 207 | static $attendee_nmbr = 1; |
208 | - $form_args = array(); |
|
208 | + $form_args = array(); |
|
209 | 209 | // verify that registration has valid event |
210 | 210 | if ( $registration->event() instanceof EE_Event ) { |
211 | 211 | $question_groups = $registration->event()->question_groups( |
212 | - array( |
|
213 | - array( |
|
214 | - 'Event.EVT_ID' => $registration->event()->ID(), |
|
215 | - 'Event_Question_Group.EQG_primary' => $registration->count() === 1 ? true : false |
|
216 | - ), |
|
217 | - 'order_by' => array('QSG_order' => 'ASC') |
|
218 | - ) |
|
219 | - ); |
|
212 | + array( |
|
213 | + array( |
|
214 | + 'Event.EVT_ID' => $registration->event()->ID(), |
|
215 | + 'Event_Question_Group.EQG_primary' => $registration->count() === 1 ? true : false |
|
216 | + ), |
|
217 | + 'order_by' => array('QSG_order' => 'ASC') |
|
218 | + ) |
|
219 | + ); |
|
220 | 220 | if ( $question_groups ) { |
221 | - // array of params to pass to parent constructor |
|
222 | - $form_args = array( |
|
223 | - 'html_id' => 'ee-registration-' . $registration->reg_url_link(), |
|
224 | - 'html_class' => 'ee-reg-form-attendee-dv', |
|
225 | - 'html_style' => $this->checkout->admin_request |
|
226 | - ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;' |
|
227 | - : '', |
|
228 | - 'subsections' => array(), |
|
229 | - 'layout_strategy' => new EE_Fieldset_Section_Layout( |
|
230 | - array( |
|
231 | - 'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text', |
|
232 | - 'legend_text' => sprintf(__('Attendee %d', 'event_espresso'), $attendee_nmbr) |
|
233 | - ) |
|
234 | - ) |
|
235 | - ); |
|
236 | - foreach ( $question_groups as $question_group ) { |
|
221 | + // array of params to pass to parent constructor |
|
222 | + $form_args = array( |
|
223 | + 'html_id' => 'ee-registration-' . $registration->reg_url_link(), |
|
224 | + 'html_class' => 'ee-reg-form-attendee-dv', |
|
225 | + 'html_style' => $this->checkout->admin_request |
|
226 | + ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;' |
|
227 | + : '', |
|
228 | + 'subsections' => array(), |
|
229 | + 'layout_strategy' => new EE_Fieldset_Section_Layout( |
|
230 | + array( |
|
231 | + 'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text', |
|
232 | + 'legend_text' => sprintf(__('Attendee %d', 'event_espresso'), $attendee_nmbr) |
|
233 | + ) |
|
234 | + ) |
|
235 | + ); |
|
236 | + foreach ( $question_groups as $question_group ) { |
|
237 | 237 | if ( $question_group instanceof EE_Question_Group ) { |
238 | 238 | $form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form( |
239 | 239 | $registration, |
@@ -241,19 +241,19 @@ discard block |
||
241 | 241 | ); |
242 | 242 | } |
243 | 243 | } |
244 | - // add hidden input |
|
245 | - $form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input( |
|
246 | - $registration |
|
247 | - ); |
|
248 | - // if we have question groups for additional attendees, then display the copy options |
|
244 | + // add hidden input |
|
245 | + $form_args['subsections']['additional_attendee_reg_info'] = $this->_additional_attendee_reg_info_input( |
|
246 | + $registration |
|
247 | + ); |
|
248 | + // if we have question groups for additional attendees, then display the copy options |
|
249 | 249 | $this->_print_copy_info = $attendee_nmbr > 1 ? true : $this->_print_copy_info; |
250 | - if ($registration->is_primary_registrant()) { |
|
251 | - // generate hidden input |
|
252 | - $form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs($registration); |
|
253 | - } |
|
254 | - } |
|
250 | + if ($registration->is_primary_registrant()) { |
|
251 | + // generate hidden input |
|
252 | + $form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs($registration); |
|
253 | + } |
|
254 | + } |
|
255 | 255 | } |
256 | - $attendee_nmbr++; |
|
256 | + $attendee_nmbr++; |
|
257 | 257 | return ! empty($form_args) ? new EE_Form_Section_Proper( $form_args ) : new EE_Form_Section_HTML(); |
258 | 258 | } |
259 | 259 | |
@@ -886,7 +886,7 @@ discard block |
||
886 | 886 | if ( isset( $valid_data[ $reg_url_link ] ) ) { |
887 | 887 | // do we need to copy basic info from primary attendee ? |
888 | 888 | $copy_primary = isset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) |
889 | - && absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0 |
|
889 | + && absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0 |
|
890 | 890 | ? true |
891 | 891 | : false; |
892 | 892 | // filter form input data for this registration |
@@ -1046,7 +1046,7 @@ discard block |
||
1046 | 1046 | ) ) { |
1047 | 1047 | return true; |
1048 | 1048 | } |
1049 | - /* |
|
1049 | + /* |
|
1050 | 1050 | * $answer_cache_id is the key used to find the EE_Answer we want |
1051 | 1051 | * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477 |
1052 | 1052 | */ |
@@ -1054,7 +1054,7 @@ discard block |
||
1054 | 1054 | ? $form_input . '-' . $registration->reg_url_link() |
1055 | 1055 | : $form_input; |
1056 | 1056 | $answer_is_obj = isset( $this->_registration_answers[ $answer_cache_id ] ) |
1057 | - && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer |
|
1057 | + && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer |
|
1058 | 1058 | ? true |
1059 | 1059 | : false; |
1060 | 1060 | //rename form_inputs if they are EE_Attendee properties |
@@ -1221,7 +1221,7 @@ discard block |
||
1221 | 1221 | } |
1222 | 1222 | foreach ( $critical_attendee_details as $critical_attendee_detail ) { |
1223 | 1223 | if ( ! isset( $attendee_data[ $critical_attendee_detail ] ) |
1224 | - || empty( $attendee_data[ $critical_attendee_detail ] ) |
|
1224 | + || empty( $attendee_data[ $critical_attendee_detail ] ) |
|
1225 | 1225 | ) { |
1226 | 1226 | $attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get( |
1227 | 1227 | $critical_attendee_detail |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php use EventEspresso\core\services\commands\attendee\CreateAttendeeCommand; |
2 | 2 | |
3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
4 | 4 | /** |
5 | 5 | * |
6 | 6 | * Class EE_SPCO_Reg_Step_Attendee_Information |
@@ -43,21 +43,21 @@ discard block |
||
43 | 43 | * @access public |
44 | 44 | * @param EE_Checkout $checkout |
45 | 45 | */ |
46 | - public function __construct( EE_Checkout $checkout ) { |
|
46 | + public function __construct(EE_Checkout $checkout) { |
|
47 | 47 | $this->_slug = 'attendee_information'; |
48 | 48 | $this->_name = __('Attendee Information', 'event_espresso'); |
49 | - $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_main.template.php'; |
|
49 | + $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'attendee_info_main.template.php'; |
|
50 | 50 | $this->checkout = $checkout; |
51 | 51 | $this->_reset_success_message(); |
52 | 52 | $this->set_instructions( |
53 | - __( 'Please answer the following registration questions before proceeding.', 'event_espresso' ) |
|
53 | + __('Please answer the following registration questions before proceeding.', 'event_espresso') |
|
54 | 54 | ); |
55 | 55 | } |
56 | 56 | |
57 | 57 | |
58 | 58 | |
59 | 59 | public function translate_js_strings() { |
60 | - EE_Registry::$i18n_js_strings['required_field'] = __( ' is a required question.', 'event_espresso' ); |
|
60 | + EE_Registry::$i18n_js_strings['required_field'] = __(' is a required question.', 'event_espresso'); |
|
61 | 61 | EE_Registry::$i18n_js_strings['required_multi_field'] = __( |
62 | 62 | ' is a required question. Please enter a value for at least one of the options.', |
63 | 63 | 'event_espresso' |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | // calculate taxes |
118 | 118 | $Line_Item_Display->display_line_item( |
119 | 119 | $this->checkout->cart->get_grand_total(), |
120 | - array( 'set_tax_rate' => true ) |
|
120 | + array('set_tax_rate' => true) |
|
121 | 121 | ); |
122 | 122 | /** @var $subsections EE_Form_Section_Proper[] */ |
123 | 123 | $subsections = array( |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | 'ticket_count' => array() |
130 | 130 | ); |
131 | 131 | // grab the saved registrations from the transaction |
132 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
133 | - if ( $registrations ) { |
|
134 | - foreach ( $registrations as $registration ) { |
|
132 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
133 | + if ($registrations) { |
|
134 | + foreach ($registrations as $registration) { |
|
135 | 135 | // can this registration be processed during this visit ? |
136 | 136 | if ( |
137 | 137 | $registration instanceof EE_Registration |
138 | - && $this->checkout->visit_allows_processing_of_this_registration( $registration ) |
|
138 | + && $this->checkout->visit_allows_processing_of_this_registration($registration) |
|
139 | 139 | ) { |
140 | 140 | $subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration); |
141 | 141 | if ( ! $this->checkout->admin_request) { |
@@ -162,17 +162,17 @@ discard block |
||
162 | 162 | } |
163 | 163 | } |
164 | 164 | // print_copy_info ? |
165 | - if ( $primary_registrant && ! $this->checkout->admin_request && count( $registrations ) > 1 ) { |
|
165 | + if ($primary_registrant && ! $this->checkout->admin_request && count($registrations) > 1) { |
|
166 | 166 | // TODO: add admin option for toggling copy attendee info, then use that value to change $this->_print_copy_info |
167 | 167 | $copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info |
168 | 168 | ? $this->_copy_attendee_info_form() |
169 | 169 | : $this->_auto_copy_attendee_info(); |
170 | 170 | // generate hidden input |
171 | 171 | if ( |
172 | - isset( $subsections[ $primary_registrant ] ) |
|
173 | - && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper |
|
172 | + isset($subsections[$primary_registrant]) |
|
173 | + && $subsections[$primary_registrant] instanceof EE_Form_Section_Proper |
|
174 | 174 | ) { |
175 | - $subsections[ $primary_registrant ]->add_subsections( $copy_options, 'primary_registrant', false ); |
|
175 | + $subsections[$primary_registrant]->add_subsections($copy_options, 'primary_registrant', false); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
@@ -184,8 +184,7 @@ discard block |
||
184 | 184 | 'html_id' => $this->reg_form_name(), |
185 | 185 | 'subsections' => $subsections, |
186 | 186 | 'layout_strategy' => $this->checkout->admin_request ? |
187 | - new EE_Div_Per_Section_Layout() : |
|
188 | - new EE_Template_Layout( |
|
187 | + new EE_Div_Per_Section_Layout() : new EE_Template_Layout( |
|
189 | 188 | array( |
190 | 189 | 'layout_template_file' => $this->_template, // layout_template |
191 | 190 | 'template_args' => $template_args |
@@ -203,11 +202,11 @@ discard block |
||
203 | 202 | * @return EE_Form_Section_Base |
204 | 203 | * @throws \EE_Error |
205 | 204 | */ |
206 | - private function _registrations_reg_form( EE_Registration $registration ) { |
|
205 | + private function _registrations_reg_form(EE_Registration $registration) { |
|
207 | 206 | static $attendee_nmbr = 1; |
208 | 207 | $form_args = array(); |
209 | 208 | // verify that registration has valid event |
210 | - if ( $registration->event() instanceof EE_Event ) { |
|
209 | + if ($registration->event() instanceof EE_Event) { |
|
211 | 210 | $question_groups = $registration->event()->question_groups( |
212 | 211 | array( |
213 | 212 | array( |
@@ -217,10 +216,10 @@ discard block |
||
217 | 216 | 'order_by' => array('QSG_order' => 'ASC') |
218 | 217 | ) |
219 | 218 | ); |
220 | - if ( $question_groups ) { |
|
219 | + if ($question_groups) { |
|
221 | 220 | // array of params to pass to parent constructor |
222 | 221 | $form_args = array( |
223 | - 'html_id' => 'ee-registration-' . $registration->reg_url_link(), |
|
222 | + 'html_id' => 'ee-registration-'.$registration->reg_url_link(), |
|
224 | 223 | 'html_class' => 'ee-reg-form-attendee-dv', |
225 | 224 | 'html_style' => $this->checkout->admin_request |
226 | 225 | ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;' |
@@ -233,9 +232,9 @@ discard block |
||
233 | 232 | ) |
234 | 233 | ) |
235 | 234 | ); |
236 | - foreach ( $question_groups as $question_group ) { |
|
237 | - if ( $question_group instanceof EE_Question_Group ) { |
|
238 | - $form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form( |
|
235 | + foreach ($question_groups as $question_group) { |
|
236 | + if ($question_group instanceof EE_Question_Group) { |
|
237 | + $form_args['subsections'][$question_group->identifier()] = $this->_question_group_reg_form( |
|
239 | 238 | $registration, |
240 | 239 | $question_group |
241 | 240 | ); |
@@ -254,7 +253,7 @@ discard block |
||
254 | 253 | } |
255 | 254 | } |
256 | 255 | $attendee_nmbr++; |
257 | - return ! empty($form_args) ? new EE_Form_Section_Proper( $form_args ) : new EE_Form_Section_HTML(); |
|
256 | + return ! empty($form_args) ? new EE_Form_Section_Proper($form_args) : new EE_Form_Section_HTML(); |
|
258 | 257 | } |
259 | 258 | |
260 | 259 | |
@@ -275,7 +274,7 @@ discard block |
||
275 | 274 | // generate hidden input |
276 | 275 | return new EE_Hidden_Input( |
277 | 276 | array( |
278 | - 'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(), |
|
277 | + 'html_id' => 'additional-attendee-reg-info-'.$registration->reg_url_link(), |
|
279 | 278 | 'default' => $additional_attendee_reg_info |
280 | 279 | ) |
281 | 280 | ); |
@@ -289,26 +288,26 @@ discard block |
||
289 | 288 | * @return EE_Form_Section_Proper |
290 | 289 | * @throws \EE_Error |
291 | 290 | */ |
292 | - private function _question_group_reg_form( EE_Registration $registration, EE_Question_Group $question_group ){ |
|
291 | + private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group) { |
|
293 | 292 | // array of params to pass to parent constructor |
294 | 293 | $form_args = array( |
295 | - 'html_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier(), |
|
294 | + 'html_id' => 'ee-reg-form-qstn-grp-'.$question_group->identifier(), |
|
296 | 295 | 'html_class' => $this->checkout->admin_request |
297 | 296 | ? 'form-table ee-reg-form-qstn-grp-dv' |
298 | 297 | : 'ee-reg-form-qstn-grp-dv', |
299 | - 'html_label_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-lbl', |
|
298 | + 'html_label_id' => 'ee-reg-form-qstn-grp-'.$question_group->identifier().'-lbl', |
|
300 | 299 | 'subsections' => array( |
301 | - 'reg_form_qstn_grp_hdr' => $this->_question_group_header( $question_group ) |
|
300 | + 'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group) |
|
302 | 301 | ), |
303 | 302 | 'layout_strategy' => $this->checkout->admin_request |
304 | 303 | ? new EE_Admin_Two_Column_Layout() |
305 | 304 | : new EE_Div_Per_Section_Layout() |
306 | 305 | ); |
307 | 306 | // where params |
308 | - $query_params = array( 'QST_deleted' => 0 ); |
|
307 | + $query_params = array('QST_deleted' => 0); |
|
309 | 308 | // don't load admin only questions on the frontend |
310 | - if ( ! $this->checkout->admin_request ) { |
|
311 | - $query_params['QST_admin_only'] = array( '!=', true ); |
|
309 | + if ( ! $this->checkout->admin_request) { |
|
310 | + $query_params['QST_admin_only'] = array('!=', true); |
|
312 | 311 | } |
313 | 312 | $questions = $question_group->get_many_related( |
314 | 313 | 'Question', |
@@ -330,10 +329,10 @@ discard block |
||
330 | 329 | ) |
331 | 330 | ); |
332 | 331 | // loop thru questions |
333 | - foreach ( $questions as $question ) { |
|
334 | - if( $question instanceof EE_Question ){ |
|
332 | + foreach ($questions as $question) { |
|
333 | + if ($question instanceof EE_Question) { |
|
335 | 334 | $identifier = $question->is_system_question() ? $question->system_ID() : $question->ID(); |
336 | - $form_args['subsections'][ $identifier ] = $this->reg_form_question( $registration, $question ); |
|
335 | + $form_args['subsections'][$identifier] = $this->reg_form_question($registration, $question); |
|
337 | 336 | } |
338 | 337 | } |
339 | 338 | $form_args['subsections'] = apply_filters( |
@@ -354,7 +353,7 @@ discard block |
||
354 | 353 | ) |
355 | 354 | ); |
356 | 355 | // d( $form_args ); |
357 | - $question_group_reg_form = new EE_Form_Section_Proper( $form_args ); |
|
356 | + $question_group_reg_form = new EE_Form_Section_Proper($form_args); |
|
358 | 357 | return apply_filters( |
359 | 358 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', |
360 | 359 | $question_group_reg_form, |
@@ -371,11 +370,11 @@ discard block |
||
371 | 370 | * @param EE_Question_Group $question_group |
372 | 371 | * @return EE_Form_Section_HTML |
373 | 372 | */ |
374 | - private function _question_group_header( EE_Question_Group $question_group ){ |
|
373 | + private function _question_group_header(EE_Question_Group $question_group) { |
|
375 | 374 | $html = ''; |
376 | 375 | // group_name |
377 | - if ( $question_group->show_group_name() && $question_group->name() !== '' ) { |
|
378 | - if ( $this->checkout->admin_request ) { |
|
376 | + if ($question_group->show_group_name() && $question_group->name() !== '') { |
|
377 | + if ($this->checkout->admin_request) { |
|
379 | 378 | $html .= EEH_HTML::br(); |
380 | 379 | $html .= EEH_HTML::h3( |
381 | 380 | $question_group->name(), |
@@ -389,7 +388,7 @@ discard block |
||
389 | 388 | } |
390 | 389 | } |
391 | 390 | // group_desc |
392 | - if ( $question_group->show_group_desc() && $question_group->desc() !== '' ) { |
|
391 | + if ($question_group->show_group_desc() && $question_group->desc() !== '') { |
|
393 | 392 | $html .= EEH_HTML::p( |
394 | 393 | $question_group->desc(), |
395 | 394 | '', |
@@ -399,7 +398,7 @@ discard block |
||
399 | 398 | ); |
400 | 399 | |
401 | 400 | } |
402 | - return new EE_Form_Section_HTML( $html ); |
|
401 | + return new EE_Form_Section_HTML($html); |
|
403 | 402 | } |
404 | 403 | |
405 | 404 | |
@@ -409,7 +408,7 @@ discard block |
||
409 | 408 | * @return EE_Form_Section_Proper |
410 | 409 | * @throws \EE_Error |
411 | 410 | */ |
412 | - private function _copy_attendee_info_form(){ |
|
411 | + private function _copy_attendee_info_form() { |
|
413 | 412 | // array of params to pass to parent constructor |
414 | 413 | return new EE_Form_Section_Proper( |
415 | 414 | array( |
@@ -438,7 +437,7 @@ discard block |
||
438 | 437 | private function _auto_copy_attendee_info() { |
439 | 438 | return new EE_Form_Section_HTML( |
440 | 439 | EEH_Template::locate_template( |
441 | - SPCO_REG_STEPS_PATH . $this->_slug . DS . '_auto_copy_attendee_info.template.php', |
|
440 | + SPCO_REG_STEPS_PATH.$this->_slug.DS.'_auto_copy_attendee_info.template.php', |
|
442 | 441 | apply_filters( |
443 | 442 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args', |
444 | 443 | array() |
@@ -462,32 +461,32 @@ discard block |
||
462 | 461 | $copy_attendee_info_inputs = array(); |
463 | 462 | $prev_ticket = NULL; |
464 | 463 | // grab the saved registrations from the transaction |
465 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
466 | - foreach ( $registrations as $registration ) { |
|
464 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
465 | + foreach ($registrations as $registration) { |
|
467 | 466 | // for all attendees other than the primary attendee |
468 | - if ( $registration instanceof EE_Registration && ! $registration->is_primary_registrant() ) { |
|
467 | + if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) { |
|
469 | 468 | // if this is a new ticket OR if this is the very first additional attendee after the primary attendee |
470 | - if ( $registration->ticket()->ID() !== $prev_ticket ) { |
|
469 | + if ($registration->ticket()->ID() !== $prev_ticket) { |
|
471 | 470 | $item_name = $registration->ticket()->name(); |
472 | 471 | $item_name .= $registration->ticket()->description() !== '' |
473 | - ? ' - ' . $registration->ticket()->description() |
|
472 | + ? ' - '.$registration->ticket()->description() |
|
474 | 473 | : ''; |
475 | - $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']' ] = new EE_Form_Section_HTML( |
|
476 | - '<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>' |
|
474 | + $copy_attendee_info_inputs['spco_copy_attendee_chk[ticket-'.$registration->ticket()->ID().']'] = new EE_Form_Section_HTML( |
|
475 | + '<h6 class="spco-copy-attendee-event-hdr">'.$item_name.'</h6>' |
|
477 | 476 | ); |
478 | 477 | $prev_ticket = $registration->ticket()->ID(); |
479 | 478 | } |
480 | 479 | |
481 | - $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] = new |
|
480 | + $copy_attendee_info_inputs['spco_copy_attendee_chk['.$registration->ID().']'] = new |
|
482 | 481 | EE_Checkbox_Multi_Input( |
483 | 482 | array( |
484 | 483 | $registration->ID() => sprintf( |
485 | - __( 'Attendee #%s', 'event_espresso' ), |
|
484 | + __('Attendee #%s', 'event_espresso'), |
|
486 | 485 | $registration->count() |
487 | 486 | ) |
488 | 487 | ), |
489 | 488 | array( |
490 | - 'html_id' => 'spco-copy-attendee-chk-' . $registration->reg_url_link(), |
|
489 | + 'html_id' => 'spco-copy-attendee-chk-'.$registration->reg_url_link(), |
|
491 | 490 | 'html_class' => 'spco-copy-attendee-chk ee-do-not-validate', |
492 | 491 | 'display_html_label_text' => false |
493 | 492 | ) |
@@ -507,7 +506,7 @@ discard block |
||
507 | 506 | * @return EE_Form_Input_Base |
508 | 507 | * @throws \EE_Error |
509 | 508 | */ |
510 | - private function _additional_primary_registrant_inputs( EE_Registration $registration ){ |
|
509 | + private function _additional_primary_registrant_inputs(EE_Registration $registration) { |
|
511 | 510 | // generate hidden input |
512 | 511 | return new EE_Hidden_Input( |
513 | 512 | array( |
@@ -526,7 +525,7 @@ discard block |
||
526 | 525 | * @return EE_Form_Input_Base |
527 | 526 | * @throws \EE_Error |
528 | 527 | */ |
529 | - public function reg_form_question( EE_Registration $registration, EE_Question $question ){ |
|
528 | + public function reg_form_question(EE_Registration $registration, EE_Question $question) { |
|
530 | 529 | |
531 | 530 | // if this question was for an attendee detail, then check for that answer |
532 | 531 | $answer_value = EEM_Answer::instance()->get_attendee_property_answer_value( |
@@ -535,32 +534,32 @@ discard block |
||
535 | 534 | ); |
536 | 535 | $answer = $answer_value === null |
537 | 536 | ? EEM_Answer::instance()->get_one( |
538 | - array( array( 'QST_ID' => $question->ID(), 'REG_ID' => $registration->ID() ) ) |
|
537 | + array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID())) |
|
539 | 538 | ) |
540 | 539 | : null; |
541 | 540 | // if NOT returning to edit an existing registration |
542 | 541 | // OR if this question is for an attendee property |
543 | 542 | // OR we still don't have an EE_Answer object |
544 | - if( $answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link() ) { |
|
543 | + if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) { |
|
545 | 544 | // create an EE_Answer object for storing everything in |
546 | - $answer = EE_Answer::new_instance ( array( |
|
545 | + $answer = EE_Answer::new_instance(array( |
|
547 | 546 | 'QST_ID'=> $question->ID(), |
548 | 547 | 'REG_ID'=> $registration->ID() |
549 | 548 | )); |
550 | 549 | } |
551 | 550 | // verify instance |
552 | - if( $answer instanceof EE_Answer ){ |
|
553 | - if ( ! empty( $answer_value )) { |
|
554 | - $answer->set( 'ANS_value', $answer_value ); |
|
551 | + if ($answer instanceof EE_Answer) { |
|
552 | + if ( ! empty($answer_value)) { |
|
553 | + $answer->set('ANS_value', $answer_value); |
|
555 | 554 | } |
556 | - $answer->cache( 'Question', $question ); |
|
555 | + $answer->cache('Question', $question); |
|
557 | 556 | //remember system ID had a bug where sometimes it could be null |
558 | - $answer_cache_id =$question->is_system_question() |
|
559 | - ? $question->system_ID() . '-' . $registration->reg_url_link() |
|
560 | - : $question->ID() . '-' . $registration->reg_url_link(); |
|
561 | - $registration->cache( 'Answer', $answer, $answer_cache_id ); |
|
557 | + $answer_cache_id = $question->is_system_question() |
|
558 | + ? $question->system_ID().'-'.$registration->reg_url_link() |
|
559 | + : $question->ID().'-'.$registration->reg_url_link(); |
|
560 | + $registration->cache('Answer', $answer, $answer_cache_id); |
|
562 | 561 | } |
563 | - return $this->_generate_question_input( $registration, $question, $answer ); |
|
562 | + return $this->_generate_question_input($registration, $question, $answer); |
|
564 | 563 | |
565 | 564 | } |
566 | 565 | |
@@ -573,46 +572,46 @@ discard block |
||
573 | 572 | * @return EE_Form_Input_Base |
574 | 573 | * @throws \EE_Error |
575 | 574 | */ |
576 | - private function _generate_question_input( EE_Registration $registration, EE_Question $question, $answer ){ |
|
575 | + private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer) { |
|
577 | 576 | $identifier = $question->is_system_question() ? $question->system_ID() : $question->ID(); |
578 | - $this->_required_questions[ $identifier ] = $question->required() ? true : false; |
|
577 | + $this->_required_questions[$identifier] = $question->required() ? true : false; |
|
579 | 578 | add_filter( |
580 | 579 | 'FHEE__EE_Question__generate_form_input__country_options', |
581 | - array( $this, 'use_cached_countries_for_form_input' ), |
|
580 | + array($this, 'use_cached_countries_for_form_input'), |
|
582 | 581 | 10, |
583 | 582 | 4 |
584 | 583 | ); |
585 | 584 | add_filter( |
586 | 585 | 'FHEE__EE_Question__generate_form_input__state_options', |
587 | - array( $this, 'use_cached_states_for_form_input' ), |
|
586 | + array($this, 'use_cached_states_for_form_input'), |
|
588 | 587 | 10, |
589 | 588 | 4 |
590 | 589 | ); |
591 | 590 | $input_constructor_args = array( |
592 | - 'html_name' => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']', |
|
593 | - 'html_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
594 | - 'html_class' => 'ee-reg-qstn ee-reg-qstn-' . $identifier, |
|
595 | - 'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
591 | + 'html_name' => 'ee_reg_qstn['.$registration->ID().']['.$identifier.']', |
|
592 | + 'html_id' => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier, |
|
593 | + 'html_class' => 'ee-reg-qstn ee-reg-qstn-'.$identifier, |
|
594 | + 'html_label_id' => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier, |
|
596 | 595 | 'html_label_class' => 'ee-reg-qstn', |
597 | 596 | ); |
598 | - $input_constructor_args['html_label_id'] .= '-lbl'; |
|
599 | - if ( $answer instanceof EE_Answer && $answer->ID() ) { |
|
600 | - $input_constructor_args[ 'html_name' ] .= '[' . $answer->ID() . ']'; |
|
601 | - $input_constructor_args[ 'html_id' ] .= '-' . $answer->ID(); |
|
602 | - $input_constructor_args[ 'html_label_id' ] .= '-' . $answer->ID(); |
|
597 | + $input_constructor_args['html_label_id'] .= '-lbl'; |
|
598 | + if ($answer instanceof EE_Answer && $answer->ID()) { |
|
599 | + $input_constructor_args['html_name'] .= '['.$answer->ID().']'; |
|
600 | + $input_constructor_args['html_id'] .= '-'.$answer->ID(); |
|
601 | + $input_constructor_args['html_label_id'] .= '-'.$answer->ID(); |
|
603 | 602 | } |
604 | - $form_input = $question->generate_form_input( |
|
603 | + $form_input = $question->generate_form_input( |
|
605 | 604 | $registration, |
606 | 605 | $answer, |
607 | 606 | $input_constructor_args |
608 | 607 | ); |
609 | 608 | remove_filter( |
610 | 609 | 'FHEE__EE_Question__generate_form_input__country_options', |
611 | - array( $this, 'use_cached_countries_for_form_input' ) |
|
610 | + array($this, 'use_cached_countries_for_form_input') |
|
612 | 611 | ); |
613 | 612 | remove_filter( |
614 | 613 | 'FHEE__EE_Question__generate_form_input__state_options', |
615 | - array( $this, 'use_cached_states_for_form_input' ) |
|
614 | + array($this, 'use_cached_states_for_form_input') |
|
616 | 615 | ); |
617 | 616 | return $form_input; |
618 | 617 | } |
@@ -634,22 +633,22 @@ discard block |
||
634 | 633 | \EE_Registration $registration = null, |
635 | 634 | \EE_Answer $answer = null |
636 | 635 | ) { |
637 | - $country_options = array( '' => '' ); |
|
636 | + $country_options = array('' => ''); |
|
638 | 637 | // get possibly cached list of countries |
639 | 638 | $countries = $this->checkout->action === 'process_reg_step' |
640 | 639 | ? EEM_Country::instance()->get_all_countries() |
641 | 640 | : EEM_Country::instance()->get_all_active_countries(); |
642 | - if ( ! empty( $countries )) { |
|
643 | - foreach( $countries as $country ){ |
|
644 | - if ( $country instanceof EE_Country ) { |
|
645 | - $country_options[ $country->ID() ] = $country->name(); |
|
641 | + if ( ! empty($countries)) { |
|
642 | + foreach ($countries as $country) { |
|
643 | + if ($country instanceof EE_Country) { |
|
644 | + $country_options[$country->ID()] = $country->name(); |
|
646 | 645 | } |
647 | 646 | } |
648 | 647 | } |
649 | - if( $question instanceof EE_Question |
|
650 | - && $registration instanceof EE_Registration ) { |
|
648 | + if ($question instanceof EE_Question |
|
649 | + && $registration instanceof EE_Registration) { |
|
651 | 650 | $answer = EEM_Answer::instance()->get_one( |
652 | - array( array( 'QST_ID' => $question->ID(), 'REG_ID' => $registration->ID() ) ) |
|
651 | + array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID())) |
|
653 | 652 | ); |
654 | 653 | } else { |
655 | 654 | $answer = EE_Answer::new_instance(); |
@@ -682,14 +681,14 @@ discard block |
||
682 | 681 | \EE_Registration $registration = null, |
683 | 682 | \EE_Answer $answer = null |
684 | 683 | ) { |
685 | - $state_options = array( '' => array( '' => '')); |
|
684 | + $state_options = array('' => array('' => '')); |
|
686 | 685 | $states = $this->checkout->action === 'process_reg_step' |
687 | 686 | ? EEM_State::instance()->get_all_states() |
688 | 687 | : EEM_State::instance()->get_all_active_states(); |
689 | - if ( ! empty( $states )) { |
|
690 | - foreach( $states as $state ){ |
|
691 | - if ( $state instanceof EE_State ) { |
|
692 | - $state_options[ $state->country()->name() ][ $state->ID() ] = $state->name(); |
|
688 | + if ( ! empty($states)) { |
|
689 | + foreach ($states as $state) { |
|
690 | + if ($state instanceof EE_State) { |
|
691 | + $state_options[$state->country()->name()][$state->ID()] = $state->name(); |
|
693 | 692 | } |
694 | 693 | } |
695 | 694 | } |
@@ -717,24 +716,24 @@ discard block |
||
717 | 716 | * @throws \EE_Error |
718 | 717 | */ |
719 | 718 | public function process_reg_step() { |
720 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
719 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
721 | 720 | // grab validated data from form |
722 | 721 | $valid_data = $this->checkout->current_step->valid_data(); |
723 | 722 | // EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ ); |
724 | 723 | // EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ ); |
725 | 724 | // if we don't have any $valid_data then something went TERRIBLY WRONG !!! |
726 | - if ( empty( $valid_data )) { |
|
725 | + if (empty($valid_data)) { |
|
727 | 726 | EE_Error::add_error( |
728 | - __( 'No valid question responses were received.', 'event_espresso' ), |
|
727 | + __('No valid question responses were received.', 'event_espresso'), |
|
729 | 728 | __FILE__, |
730 | 729 | __FUNCTION__, |
731 | 730 | __LINE__ |
732 | 731 | ); |
733 | 732 | return false; |
734 | 733 | } |
735 | - if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg ) { |
|
734 | + if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
736 | 735 | EE_Error::add_error( |
737 | - __( 'A valid transaction could not be initiated for processing your registrations.', 'event_espresso' ), |
|
736 | + __('A valid transaction could not be initiated for processing your registrations.', 'event_espresso'), |
|
738 | 737 | __FILE__, |
739 | 738 | __FUNCTION__, |
740 | 739 | __LINE__ |
@@ -742,11 +741,11 @@ discard block |
||
742 | 741 | return false; |
743 | 742 | } |
744 | 743 | // get cached registrations |
745 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
744 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
746 | 745 | // verify we got the goods |
747 | - if ( empty( $registrations )) { |
|
746 | + if (empty($registrations)) { |
|
748 | 747 | EE_Error::add_error( |
749 | - __( 'Your form data could not be applied to any valid registrations.', 'event_espresso' ), |
|
748 | + __('Your form data could not be applied to any valid registrations.', 'event_espresso'), |
|
750 | 749 | __FILE__, |
751 | 750 | __FUNCTION__, |
752 | 751 | __LINE__ |
@@ -754,15 +753,15 @@ discard block |
||
754 | 753 | return false; |
755 | 754 | } |
756 | 755 | // extract attendee info from form data and save to model objects |
757 | - $registrations_processed = $this->_process_registrations( $registrations, $valid_data ); |
|
756 | + $registrations_processed = $this->_process_registrations($registrations, $valid_data); |
|
758 | 757 | // if first pass thru SPCO, |
759 | 758 | // then let's check processed registrations against the total number of tickets in the cart |
760 | - if ( $registrations_processed === false ) { |
|
759 | + if ($registrations_processed === false) { |
|
761 | 760 | // but return immediately if the previous step exited early due to errors |
762 | 761 | return false; |
763 | - } else if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count ) { |
|
762 | + } else if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
764 | 763 | // generate a correctly translated string for all possible singular/plural combinations |
765 | - if ( $this->checkout->total_ticket_count === 1 && $registrations_processed !== 1 ) { |
|
764 | + if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) { |
|
766 | 765 | $error_msg = sprintf( |
767 | 766 | __( |
768 | 767 | 'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed', |
@@ -771,7 +770,7 @@ discard block |
||
771 | 770 | $this->checkout->total_ticket_count, |
772 | 771 | $registrations_processed |
773 | 772 | ); |
774 | - } else if ( $this->checkout->total_ticket_count !== 1 && $registrations_processed === 1 ) { |
|
773 | + } else if ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) { |
|
775 | 774 | $error_msg = sprintf( |
776 | 775 | __( |
777 | 776 | 'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed', |
@@ -790,17 +789,17 @@ discard block |
||
790 | 789 | $registrations_processed |
791 | 790 | ); |
792 | 791 | } |
793 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
792 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
794 | 793 | return false; |
795 | 794 | } |
796 | 795 | // mark this reg step as completed |
797 | 796 | $this->set_completed(); |
798 | 797 | $this->_set_success_message( |
799 | - __( 'The Attendee Information Step has been successfully completed.', 'event_espresso' ) |
|
798 | + __('The Attendee Information Step has been successfully completed.', 'event_espresso') |
|
800 | 799 | ); |
801 | 800 | //do action in case a plugin wants to do something with the data submitted in step 1. |
802 | 801 | //passes EE_Single_Page_Checkout, and it's posted data |
803 | - do_action( 'AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data ); |
|
802 | + do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data); |
|
804 | 803 | return true; |
805 | 804 | } |
806 | 805 | |
@@ -814,9 +813,9 @@ discard block |
||
814 | 813 | * @return boolean | int |
815 | 814 | * @throws \EE_Error |
816 | 815 | */ |
817 | - private function _process_registrations( $registrations = array(), $valid_data = array() ) { |
|
816 | + private function _process_registrations($registrations = array(), $valid_data = array()) { |
|
818 | 817 | // load resources and set some defaults |
819 | - EE_Registry::instance()->load_model( 'Attendee' ); |
|
818 | + EE_Registry::instance()->load_model('Attendee'); |
|
820 | 819 | // holder for primary registrant attendee object |
821 | 820 | $this->checkout->primary_attendee_obj = NULL; |
822 | 821 | // array for tracking reg form data for the primary registrant |
@@ -833,9 +832,9 @@ discard block |
||
833 | 832 | // attendee counter |
834 | 833 | $att_nmbr = 0; |
835 | 834 | // grab the saved registrations from the transaction |
836 | - foreach ( $registrations as $registration ) { |
|
835 | + foreach ($registrations as $registration) { |
|
837 | 836 | // verify EE_Registration object |
838 | - if ( ! $registration instanceof EE_Registration ) { |
|
837 | + if ( ! $registration instanceof EE_Registration) { |
|
839 | 838 | EE_Error::add_error( |
840 | 839 | __( |
841 | 840 | 'An invalid Registration object was discovered when attempting to process your registration information.', |
@@ -850,12 +849,12 @@ discard block |
||
850 | 849 | /** @var string $reg_url_link */ |
851 | 850 | $reg_url_link = $registration->reg_url_link(); |
852 | 851 | // reg_url_link exists ? |
853 | - if ( ! empty( $reg_url_link ) ) { |
|
852 | + if ( ! empty($reg_url_link)) { |
|
854 | 853 | // should this registration be processed during this visit ? |
855 | - if ( $this->checkout->visit_allows_processing_of_this_registration( $registration ) ) { |
|
854 | + if ($this->checkout->visit_allows_processing_of_this_registration($registration)) { |
|
856 | 855 | // if NOT revisiting, then let's save the registration now, |
857 | 856 | // so that we have a REG_ID to use when generating other objects |
858 | - if ( ! $this->checkout->revisit ) { |
|
857 | + if ( ! $this->checkout->revisit) { |
|
859 | 858 | $registration->save(); |
860 | 859 | } |
861 | 860 | /** |
@@ -865,7 +864,7 @@ discard block |
||
865 | 864 | * @var bool if true is returned by the plugin then the |
866 | 865 | * registration processing is halted. |
867 | 866 | */ |
868 | - if ( apply_filters( |
|
867 | + if (apply_filters( |
|
869 | 868 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process', |
870 | 869 | false, |
871 | 870 | $att_nmbr, |
@@ -873,38 +872,38 @@ discard block |
||
873 | 872 | $registrations, |
874 | 873 | $valid_data, |
875 | 874 | $this |
876 | - ) ) { |
|
875 | + )) { |
|
877 | 876 | return false; |
878 | 877 | } |
879 | 878 | |
880 | 879 | // Houston, we have a registration! |
881 | 880 | $att_nmbr++; |
882 | - $this->_attendee_data[ $reg_url_link ] = array(); |
|
881 | + $this->_attendee_data[$reg_url_link] = array(); |
|
883 | 882 | // grab any existing related answer objects |
884 | 883 | $this->_registration_answers = $registration->answers(); |
885 | 884 | // unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ); |
886 | - if ( isset( $valid_data[ $reg_url_link ] ) ) { |
|
885 | + if (isset($valid_data[$reg_url_link])) { |
|
887 | 886 | // do we need to copy basic info from primary attendee ? |
888 | - $copy_primary = isset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) |
|
889 | - && absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0 |
|
887 | + $copy_primary = isset($valid_data[$reg_url_link]['additional_attendee_reg_info']) |
|
888 | + && absint($valid_data[$reg_url_link]['additional_attendee_reg_info']) === 0 |
|
890 | 889 | ? true |
891 | 890 | : false; |
892 | 891 | // filter form input data for this registration |
893 | - $valid_data[ $reg_url_link ] = (array)apply_filters( |
|
892 | + $valid_data[$reg_url_link] = (array) apply_filters( |
|
894 | 893 | 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', |
895 | - $valid_data[ $reg_url_link ] |
|
894 | + $valid_data[$reg_url_link] |
|
896 | 895 | ); |
897 | 896 | // EEH_Debug_Tools::printr( $valid_data[ $reg_url_link ], '$valid_data[ $reg_url_link ]', __FILE__, __LINE__ ); |
898 | - if ( isset( $valid_data['primary_attendee'] )) { |
|
899 | - $primary_registrant['line_item_id'] = ! empty( $valid_data['primary_attendee'] ) |
|
897 | + if (isset($valid_data['primary_attendee'])) { |
|
898 | + $primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee']) |
|
900 | 899 | ? $valid_data['primary_attendee'] |
901 | 900 | : false; |
902 | - unset( $valid_data['primary_attendee'] ); |
|
901 | + unset($valid_data['primary_attendee']); |
|
903 | 902 | } |
904 | 903 | // now loop through our array of valid post data && process attendee reg forms |
905 | - foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs ) { |
|
906 | - if ( ! in_array( $form_section, $non_input_form_sections )) { |
|
907 | - foreach ( $form_inputs as $form_input => $input_value ) { |
|
904 | + foreach ($valid_data[$reg_url_link] as $form_section => $form_inputs) { |
|
905 | + if ( ! in_array($form_section, $non_input_form_sections)) { |
|
906 | + foreach ($form_inputs as $form_input => $input_value) { |
|
908 | 907 | // \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ ); |
909 | 908 | // check for critical inputs |
910 | 909 | if ( |
@@ -918,16 +917,16 @@ discard block |
||
918 | 917 | // store a bit of data about the primary attendee |
919 | 918 | if ( |
920 | 919 | $att_nmbr === 1 |
921 | - && ! empty( $input_value ) |
|
920 | + && ! empty($input_value) |
|
922 | 921 | && $reg_url_link === $primary_registrant['line_item_id'] |
923 | 922 | ) { |
924 | - $primary_registrant[ $form_input ] = $input_value; |
|
923 | + $primary_registrant[$form_input] = $input_value; |
|
925 | 924 | } else if ( |
926 | 925 | $copy_primary |
927 | 926 | && $input_value === null |
928 | - && isset( $primary_registrant[ $form_input ] ) |
|
927 | + && isset($primary_registrant[$form_input]) |
|
929 | 928 | ) { |
930 | - $input_value = $primary_registrant[ $form_input ]; |
|
929 | + $input_value = $primary_registrant[$form_input]; |
|
931 | 930 | } |
932 | 931 | // now attempt to save the input data |
933 | 932 | if ( |
@@ -967,47 +966,47 @@ discard block |
||
967 | 966 | $attendee = $this->checkout->primary_attendee_obj; |
968 | 967 | } else { |
969 | 968 | // ensure critical details are set for additional attendees |
970 | - $this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1 |
|
969 | + $this->_attendee_data[$reg_url_link] = $att_nmbr > 1 |
|
971 | 970 | ? $this->_copy_critical_attendee_details_from_primary_registrant( |
972 | - $this->_attendee_data[ $reg_url_link ] |
|
971 | + $this->_attendee_data[$reg_url_link] |
|
973 | 972 | ) |
974 | - : $this->_attendee_data[ $reg_url_link ]; |
|
973 | + : $this->_attendee_data[$reg_url_link]; |
|
975 | 974 | // execute create attendee command (which may return an existing attendee) |
976 | 975 | $attendee = EE_Registry::instance()->BUS->execute( |
977 | 976 | new CreateAttendeeCommand( |
978 | - $this->_attendee_data[ $reg_url_link ], |
|
977 | + $this->_attendee_data[$reg_url_link], |
|
979 | 978 | $registration |
980 | 979 | ) |
981 | 980 | ); |
982 | 981 | // who's #1 ? |
983 | - if ( $att_nmbr === 1 ) { |
|
982 | + if ($att_nmbr === 1) { |
|
984 | 983 | $this->checkout->primary_attendee_obj = $attendee; |
985 | 984 | } |
986 | 985 | } |
987 | 986 | // EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ ); |
988 | 987 | // add relation to registration, set attendee ID, and cache attendee |
989 | - $this->_associate_attendee_with_registration( $registration, $attendee ); |
|
988 | + $this->_associate_attendee_with_registration($registration, $attendee); |
|
990 | 989 | // \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ ); |
991 | - if ( ! $registration->attendee() instanceof EE_Attendee ) { |
|
992 | - EE_Error::add_error( sprintf( __( 'Registration %s has an invalid or missing Attendee object.', 'event_espresso' ), $reg_url_link ), __FILE__, __FUNCTION__, __LINE__ ); |
|
990 | + if ( ! $registration->attendee() instanceof EE_Attendee) { |
|
991 | + EE_Error::add_error(sprintf(__('Registration %s has an invalid or missing Attendee object.', 'event_espresso'), $reg_url_link), __FILE__, __FUNCTION__, __LINE__); |
|
993 | 992 | return false; |
994 | 993 | } |
995 | 994 | /** @type EE_Registration_Processor $registration_processor */ |
996 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
995 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
997 | 996 | // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
998 | - $registration_processor->toggle_incomplete_registration_status_to_default( $registration, false ); |
|
997 | + $registration_processor->toggle_incomplete_registration_status_to_default($registration, false); |
|
999 | 998 | // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned |
1000 | 999 | $this->checkout->transaction->toggle_failed_transaction_status(); |
1001 | 1000 | // if we've gotten this far, then let's save what we have |
1002 | 1001 | $registration->save(); |
1003 | 1002 | // add relation between TXN and registration |
1004 | - $this->_associate_registration_with_transaction( $registration ); |
|
1003 | + $this->_associate_registration_with_transaction($registration); |
|
1005 | 1004 | } // end of if ( ! $this->checkout->revisit || $this->checkout->primary_revisit || ( $this->checkout->revisit && $this->checkout->reg_url_link == $reg_url_link )) { |
1006 | 1005 | |
1007 | - } else { |
|
1008 | - EE_Error::add_error( __( 'An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1006 | + } else { |
|
1007 | + EE_Error::add_error(__('An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1009 | 1008 | // remove malformed data |
1010 | - unset( $valid_data[ $reg_url_link ] ); |
|
1009 | + unset($valid_data[$reg_url_link]); |
|
1011 | 1010 | return false; |
1012 | 1011 | } |
1013 | 1012 | |
@@ -1036,14 +1035,14 @@ discard block |
||
1036 | 1035 | // \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ ); |
1037 | 1036 | // allow for plugins to hook in and do their own processing of the form input. |
1038 | 1037 | // For plugins to bypass normal processing here, they just need to return a boolean value. |
1039 | - if ( apply_filters( |
|
1038 | + if (apply_filters( |
|
1040 | 1039 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input', |
1041 | 1040 | false, |
1042 | 1041 | $registration, |
1043 | 1042 | $form_input, |
1044 | 1043 | $input_value, |
1045 | 1044 | $this |
1046 | - ) ) { |
|
1045 | + )) { |
|
1047 | 1046 | return true; |
1048 | 1047 | } |
1049 | 1048 | /* |
@@ -1051,14 +1050,14 @@ discard block |
||
1051 | 1050 | * @see https://events.codebasehq.com/projects/event-espresso/tickets/10477 |
1052 | 1051 | */ |
1053 | 1052 | $answer_cache_id = $this->checkout->reg_url_link |
1054 | - ? $form_input . '-' . $registration->reg_url_link() |
|
1053 | + ? $form_input.'-'.$registration->reg_url_link() |
|
1055 | 1054 | : $form_input; |
1056 | - $answer_is_obj = isset( $this->_registration_answers[ $answer_cache_id ] ) |
|
1057 | - && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer |
|
1055 | + $answer_is_obj = isset($this->_registration_answers[$answer_cache_id]) |
|
1056 | + && $this->_registration_answers[$answer_cache_id] instanceof EE_Answer |
|
1058 | 1057 | ? true |
1059 | 1058 | : false; |
1060 | 1059 | //rename form_inputs if they are EE_Attendee properties |
1061 | - switch( (string)$form_input ) { |
|
1060 | + switch ((string) $form_input) { |
|
1062 | 1061 | |
1063 | 1062 | case 'state' : |
1064 | 1063 | case 'STA_ID' : |
@@ -1073,32 +1072,32 @@ discard block |
||
1073 | 1072 | break; |
1074 | 1073 | |
1075 | 1074 | default : |
1076 | - $ATT_input = 'ATT_' . $form_input; |
|
1075 | + $ATT_input = 'ATT_'.$form_input; |
|
1077 | 1076 | //EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ ); |
1078 | - $attendee_property = EEM_Attendee::instance()->has_field( $ATT_input ) ? true : false; |
|
1079 | - $form_input = $attendee_property ? 'ATT_' . $form_input : $form_input; |
|
1077 | + $attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false; |
|
1078 | + $form_input = $attendee_property ? 'ATT_'.$form_input : $form_input; |
|
1080 | 1079 | } |
1081 | 1080 | // EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ ); |
1082 | 1081 | // EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ ); |
1083 | 1082 | // EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ ); |
1084 | 1083 | // if this form input has a corresponding attendee property |
1085 | - if ( $attendee_property ) { |
|
1086 | - $this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value; |
|
1087 | - if ( $answer_is_obj ) { |
|
1084 | + if ($attendee_property) { |
|
1085 | + $this->_attendee_data[$registration->reg_url_link()][$form_input] = $input_value; |
|
1086 | + if ($answer_is_obj) { |
|
1088 | 1087 | // and delete the corresponding answer since we won't be storing this data in that object |
1089 | - $registration->_remove_relation_to( $this->_registration_answers[ $answer_cache_id ], 'Answer' ); |
|
1090 | - $this->_registration_answers[ $answer_cache_id ]->delete_permanently(); |
|
1088 | + $registration->_remove_relation_to($this->_registration_answers[$answer_cache_id], 'Answer'); |
|
1089 | + $this->_registration_answers[$answer_cache_id]->delete_permanently(); |
|
1091 | 1090 | } |
1092 | 1091 | return true; |
1093 | - } elseif ( $answer_is_obj ) { |
|
1092 | + } elseif ($answer_is_obj) { |
|
1094 | 1093 | // save this data to the answer object |
1095 | - $this->_registration_answers[ $answer_cache_id ]->set_value( $input_value ); |
|
1096 | - $result = $this->_registration_answers[ $answer_cache_id ]->save(); |
|
1094 | + $this->_registration_answers[$answer_cache_id]->set_value($input_value); |
|
1095 | + $result = $this->_registration_answers[$answer_cache_id]->save(); |
|
1097 | 1096 | return $result !== false ? true : false; |
1098 | 1097 | } else { |
1099 | - foreach ( $this->_registration_answers as $answer ) { |
|
1100 | - if ( $answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id ) { |
|
1101 | - $answer->set_value( $input_value ); |
|
1098 | + foreach ($this->_registration_answers as $answer) { |
|
1099 | + if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) { |
|
1100 | + $answer->set_value($input_value); |
|
1102 | 1101 | $result = $answer->save(); |
1103 | 1102 | return $result !== false ? true : false; |
1104 | 1103 | } |
@@ -1120,15 +1119,15 @@ discard block |
||
1120 | 1119 | $form_input = '', |
1121 | 1120 | $input_value = '' |
1122 | 1121 | ) { |
1123 | - if ( empty( $input_value ) ) { |
|
1122 | + if (empty($input_value)) { |
|
1124 | 1123 | // if the form input isn't marked as being required, then just return |
1125 | - if ( ! isset( $this->_required_questions[ $form_input ] ) || ! $this->_required_questions[ $form_input ] ) { |
|
1124 | + if ( ! isset($this->_required_questions[$form_input]) || ! $this->_required_questions[$form_input]) { |
|
1126 | 1125 | return true; |
1127 | 1126 | } |
1128 | - switch ( $form_input ) { |
|
1127 | + switch ($form_input) { |
|
1129 | 1128 | case 'fname' : |
1130 | 1129 | EE_Error::add_error( |
1131 | - __( 'First Name is a required value.', 'event_espresso' ), |
|
1130 | + __('First Name is a required value.', 'event_espresso'), |
|
1132 | 1131 | __FILE__, |
1133 | 1132 | __FUNCTION__, |
1134 | 1133 | __LINE__ |
@@ -1137,7 +1136,7 @@ discard block |
||
1137 | 1136 | break; |
1138 | 1137 | case 'lname' : |
1139 | 1138 | EE_Error::add_error( |
1140 | - __( 'Last Name is a required value.', 'event_espresso' ), |
|
1139 | + __('Last Name is a required value.', 'event_espresso'), |
|
1141 | 1140 | __FILE__, |
1142 | 1141 | __FUNCTION__, |
1143 | 1142 | __LINE__ |
@@ -1146,7 +1145,7 @@ discard block |
||
1146 | 1145 | break; |
1147 | 1146 | case 'email' : |
1148 | 1147 | EE_Error::add_error( |
1149 | - __( 'Please enter a valid email address.', 'event_espresso' ), |
|
1148 | + __('Please enter a valid email address.', 'event_espresso'), |
|
1150 | 1149 | __FILE__, |
1151 | 1150 | __FUNCTION__, |
1152 | 1151 | __LINE__ |
@@ -1168,11 +1167,11 @@ discard block |
||
1168 | 1167 | * @return void |
1169 | 1168 | * @throws \EE_Error |
1170 | 1169 | */ |
1171 | - private function _associate_attendee_with_registration( EE_Registration $registration, EE_Attendee $attendee ) { |
|
1170 | + private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee) { |
|
1172 | 1171 | // add relation to attendee |
1173 | - $registration->_add_relation_to( $attendee, 'Attendee' ); |
|
1174 | - $registration->set_attendee_id( $attendee->ID() ); |
|
1175 | - $registration->update_cache_after_object_save( 'Attendee', $attendee ); |
|
1172 | + $registration->_add_relation_to($attendee, 'Attendee'); |
|
1173 | + $registration->set_attendee_id($attendee->ID()); |
|
1174 | + $registration->update_cache_after_object_save('Attendee', $attendee); |
|
1176 | 1175 | } |
1177 | 1176 | |
1178 | 1177 | |
@@ -1184,10 +1183,10 @@ discard block |
||
1184 | 1183 | * @return void |
1185 | 1184 | * @throws \EE_Error |
1186 | 1185 | */ |
1187 | - private function _associate_registration_with_transaction( EE_Registration $registration ) { |
|
1186 | + private function _associate_registration_with_transaction(EE_Registration $registration) { |
|
1188 | 1187 | // add relation to registration |
1189 | - $this->checkout->transaction->_add_relation_to( $registration, 'Registration' ); |
|
1190 | - $this->checkout->transaction->update_cache_after_object_save( 'Registration', $registration ); |
|
1188 | + $this->checkout->transaction->_add_relation_to($registration, 'Registration'); |
|
1189 | + $this->checkout->transaction->update_cache_after_object_save('Registration', $registration); |
|
1191 | 1190 | } |
1192 | 1191 | |
1193 | 1192 | |
@@ -1200,14 +1199,14 @@ discard block |
||
1200 | 1199 | * @return array |
1201 | 1200 | * @throws \EE_Error |
1202 | 1201 | */ |
1203 | - private function _copy_critical_attendee_details_from_primary_registrant( $attendee_data = array() ) { |
|
1202 | + private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array()) { |
|
1204 | 1203 | // bare minimum critical details include first name, last name, email address |
1205 | - $critical_attendee_details = array( 'ATT_fname', 'ATT_lname', 'ATT_email' ); |
|
1204 | + $critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email'); |
|
1206 | 1205 | // add address info to critical details? |
1207 | - if ( apply_filters( |
|
1206 | + if (apply_filters( |
|
1208 | 1207 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details', |
1209 | 1208 | false |
1210 | - ) ) { |
|
1209 | + )) { |
|
1211 | 1210 | $address_details = array( |
1212 | 1211 | 'ATT_address', |
1213 | 1212 | 'ATT_address2', |
@@ -1217,13 +1216,13 @@ discard block |
||
1217 | 1216 | 'ATT_zip', |
1218 | 1217 | 'ATT_phone' |
1219 | 1218 | ); |
1220 | - $critical_attendee_details = array_merge( $critical_attendee_details, $address_details ); |
|
1219 | + $critical_attendee_details = array_merge($critical_attendee_details, $address_details); |
|
1221 | 1220 | } |
1222 | - foreach ( $critical_attendee_details as $critical_attendee_detail ) { |
|
1223 | - if ( ! isset( $attendee_data[ $critical_attendee_detail ] ) |
|
1224 | - || empty( $attendee_data[ $critical_attendee_detail ] ) |
|
1221 | + foreach ($critical_attendee_details as $critical_attendee_detail) { |
|
1222 | + if ( ! isset($attendee_data[$critical_attendee_detail]) |
|
1223 | + || empty($attendee_data[$critical_attendee_detail]) |
|
1225 | 1224 | ) { |
1226 | - $attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get( |
|
1225 | + $attendee_data[$critical_attendee_detail] = $this->checkout->primary_attendee_obj->get( |
|
1227 | 1226 | $critical_attendee_detail |
1228 | 1227 | ); |
1229 | 1228 | } |
@@ -1243,7 +1242,7 @@ discard block |
||
1243 | 1242 | */ |
1244 | 1243 | public function update_reg_step() { |
1245 | 1244 | // save everything |
1246 | - if ( $this->process_reg_step() ) { |
|
1245 | + if ($this->process_reg_step()) { |
|
1247 | 1246 | $this->checkout->redirect = true; |
1248 | 1247 | $this->checkout->redirect_url = add_query_arg( |
1249 | 1248 | array( |
@@ -1252,7 +1251,7 @@ discard block |
||
1252 | 1251 | ), |
1253 | 1252 | $this->checkout->thank_you_page_url |
1254 | 1253 | ); |
1255 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
1254 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
1256 | 1255 | return true; |
1257 | 1256 | } |
1258 | 1257 | return false; |